You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
130 lines
4.8 KiB
130 lines
4.8 KiB
3 months ago
|
using BiskLog_Point_Of_Sale.Classes;
|
||
|
using BiskLog_Point_Of_Sale.Company_Setup;
|
||
|
using BiskLog_Point_Of_Sale.Properties;
|
||
|
using Point_Of_Sale_Managment;
|
||
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.ComponentModel;
|
||
|
using System.Data;
|
||
|
using System.Data.SqlClient;
|
||
|
using System.Drawing;
|
||
|
using System.Linq;
|
||
|
using System.Text;
|
||
|
using System.Threading.Tasks;
|
||
|
using System.Windows.Forms;
|
||
|
|
||
|
namespace Point_Of_Sale_Managment.CashierModule
|
||
|
{
|
||
|
public partial class HeldTransactions : Form
|
||
|
{
|
||
|
private List<HeldItems> held { get; set; } = new List<HeldItems>();
|
||
|
public List<HeldItems> selectedheld { get; set; } = new List<HeldItems>();
|
||
|
List<string> added = new List<string>();
|
||
|
DatabaseConn conn = new DatabaseConn();
|
||
|
SqlConnection cn;
|
||
|
SqlCommand cm;
|
||
|
SqlDataReader dr;
|
||
|
public HeldTransactions()
|
||
|
{
|
||
|
InitializeComponent();
|
||
|
cn = new SqlConnection(conn.MyConnection());
|
||
|
holding.Left = (ClientSize.Width - holding.Width) / 2;
|
||
|
holding.Top = (ClientSize.Height - holding.Height) / 2;
|
||
|
}
|
||
|
private async Task GetHeld()
|
||
|
{
|
||
|
held.Clear();
|
||
|
cn.Open();
|
||
|
cm = new SqlCommand("Exec usp_get_held_sales @BranchID = @branchID,@month=@dateMonth,@year=@dateYear,@day=@dateDay", cn);
|
||
|
cm.Parameters.AddWithValue("@dateYear", date.Value.Year);
|
||
|
cm.Parameters.AddWithValue("@dateMonth", date.Value.Month);
|
||
|
cm.Parameters.AddWithValue("@dateDay", date.Value.Day);
|
||
|
cm.Parameters.AddWithValue("@branchID", Settings.Default.BranchID);
|
||
|
dr = cm.ExecuteReader();
|
||
|
while (dr.Read())
|
||
|
{
|
||
|
held.Add(new HeldItems
|
||
|
{
|
||
|
branchID = Settings.Default.BranchID,
|
||
|
cashier = dr["cashier"].ToString(),
|
||
|
customerID = dr["customerID"].ToString(),
|
||
|
date = DateTime.Now.ToString(),
|
||
|
discount = dr["discount"].ToString(),
|
||
|
distinctive = dr["distinctive"].ToString(),
|
||
|
id = dr["productID"].ToString(),
|
||
|
invoiceID = dr["invoiceID"].ToString(),
|
||
|
pcode = dr["productID"].ToString(),
|
||
|
price = dr["price"].ToString(),
|
||
|
quantity = dr["quantity"].ToString(),
|
||
|
total = dr["total"].ToString(),
|
||
|
transno = dr["transactionID"].ToString(),
|
||
|
unit = dr["unit"].ToString(),
|
||
|
rowid = dr["Customer Name"].ToString(),
|
||
|
countID = dr["Product"].ToString(),
|
||
|
status = dr["unitName"].ToString(),
|
||
|
});
|
||
|
}
|
||
|
dr.Close();
|
||
|
cn.Close();
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
private async void HeldTransactions_Load(object sender, EventArgs e)
|
||
|
{
|
||
|
transactionHeld.Rows.Clear();
|
||
|
holding.Visible = true;
|
||
|
await GetHeld();
|
||
|
int i = 1;
|
||
|
foreach (HeldItems items in held)
|
||
|
{
|
||
|
if (!added.Contains(items.transno))
|
||
|
{
|
||
|
added.Add(items.transno);
|
||
|
transactionHeld.Rows.Add(i, items.transno, items.rowid, items.date, Settings.Default.currrencyCode + " " + items.total);
|
||
|
i++;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
holding.Visible = false;
|
||
|
}
|
||
|
|
||
|
private void transactionHeld_CellClick(object sender, DataGridViewCellEventArgs d)
|
||
|
{
|
||
|
detailsPanel.Rows.Clear();
|
||
|
if (d.RowIndex != -1)
|
||
|
{
|
||
|
string ID = transactionHeld.Rows[d.RowIndex].Cells[1].Value.ToString();
|
||
|
selectedheld = this.held.Where((e) => e.transno == ID).ToList();
|
||
|
foreach (HeldItems held in this.held.Where((e) => e.transno == ID))
|
||
|
{
|
||
|
detailsPanel.Rows.Add(held.countID, held.quantity, held.status, held.total);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void button1_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
this.DialogResult = DialogResult.Yes;
|
||
|
this.Close();
|
||
|
}
|
||
|
private int CancelHeld()
|
||
|
{
|
||
|
cn.Open();
|
||
|
cm = new SqlCommand("Exec usp_remove_held_transaction @BranchID = @branchID,@heldTransno=@held", cn);
|
||
|
cm.Parameters.AddWithValue("@held", selectedheld.FirstOrDefault().transno);
|
||
|
cm.Parameters.AddWithValue("@branchID", Settings.Default.BranchID);
|
||
|
cm.ExecuteNonQuery();
|
||
|
cn.Close();
|
||
|
return 1;
|
||
|
}
|
||
|
private async void button2_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
holding.Visible = true;
|
||
|
Task<int> task = new Task<int>(CancelHeld);
|
||
|
task.Start();
|
||
|
await task;
|
||
|
holding.Visible = false;
|
||
|
}
|
||
|
}
|
||
|
}
|