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.
119 lines
4.1 KiB
119 lines
4.1 KiB
3 months ago
|
using BiskLog_Point_Of_Sale.Cashier_Module;
|
||
|
using BiskLog_Point_Of_Sale.Cashier_Module.Invoice;
|
||
|
using BiskLog_Point_Of_Sale.Classes;
|
||
|
using BiskLog_Point_Of_Sale.Invoice;
|
||
|
using BiskLog_Point_Of_Sale.Properties;
|
||
|
using Point_Of_Sale_Managment.CashierModule;
|
||
|
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.Cashier_Module.Invoice
|
||
|
{
|
||
|
public partial class CashierInvoiceMain : Form
|
||
|
{
|
||
|
SqlConnection cn;
|
||
|
SqlCommand cm;
|
||
|
SqlDataReader dr;
|
||
|
DatabaseConn conn = new DatabaseConn();
|
||
|
CashierMain mainForm;
|
||
|
public CashierInvoiceMain(CashierMain form = null)
|
||
|
{
|
||
|
InitializeComponent();
|
||
|
cn = new SqlConnection(conn.MyConnection());
|
||
|
holding.Left = (ClientSize.Width - holding.Width) / 2;
|
||
|
if (form != null)
|
||
|
{
|
||
|
mainForm = form;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private async void InvoiceMain_Load(object sender, EventArgs e)
|
||
|
{
|
||
|
Task<int> task = new Task<int>(LoadInvoice);
|
||
|
holding.Visible = true;
|
||
|
task.Start();
|
||
|
await task;
|
||
|
holding.Visible = false;
|
||
|
}
|
||
|
private void AddProducts_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
CashierAddInvoice newInvoice = new CashierAddInvoice(this);
|
||
|
newInvoice.BringToFront();
|
||
|
newInvoice.ShowDialog();
|
||
|
}
|
||
|
public int LoadInvoice()
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
int i = 1;
|
||
|
cn.Open();
|
||
|
dataGridView1.Invoke(new Action(() =>
|
||
|
{
|
||
|
dataGridView1.Rows.Clear();
|
||
|
cm = new SqlCommand("Select Distinct invoiceID,count(invoiceID),dateGenerated,generatedBy,sum(totalprice),status " +
|
||
|
"from tblInvoice where branchID = @branchID and invoiceID like '%" + txtSearch.Text + "%'group by invoiceID,dateGenerated," +
|
||
|
"generatedBy,status order by dateGenerated desc", cn);
|
||
|
cm.Parameters.AddWithValue("@branchID", Settings.Default.BranchID);
|
||
|
cm.ExecuteNonQuery();
|
||
|
dr = cm.ExecuteReader();
|
||
|
while (dr.Read())
|
||
|
{
|
||
|
dataGridView1.Rows.Add(i, dr[0].ToString(), dr[1].ToString(), Convert.ToDateTime(dr[2].ToString()).ToLongDateString(),
|
||
|
dr[3].ToString(), dr[4].ToString(), dr[5].ToString());
|
||
|
i++;
|
||
|
}
|
||
|
}));
|
||
|
dr.Close();
|
||
|
cn.Close();
|
||
|
return 1;
|
||
|
}
|
||
|
catch
|
||
|
{
|
||
|
cn.Close();
|
||
|
return 0;
|
||
|
}
|
||
|
}
|
||
|
private async void TxtSearch_TextChanged(object sender, EventArgs e)
|
||
|
{
|
||
|
Task<int> task = new Task<int>(LoadInvoice);
|
||
|
holding.Visible = true;
|
||
|
task.Start();
|
||
|
await task;
|
||
|
holding.Visible = false;
|
||
|
}
|
||
|
|
||
|
private void DataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
|
||
|
{
|
||
|
if (e.RowIndex != -1)
|
||
|
{
|
||
|
string id = dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString();
|
||
|
string cost = dataGridView1.Rows[e.RowIndex].Cells[5].Value.ToString();
|
||
|
string status = dataGridView1.Rows[e.RowIndex].Cells[6].Value.ToString();
|
||
|
CashierInvoiceDialog invoice = new CashierInvoiceDialog(this, id, cost, status);
|
||
|
invoice.BringToFront();
|
||
|
invoice.ShowDialog();
|
||
|
}
|
||
|
}
|
||
|
public void ShowSalesPOS(Form form, List<InvoicePOS> invoice,string id)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
mainForm.POS(invoice: invoice, id: id);
|
||
|
form.Close();
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
ErrorLogging.WriteToFile(ex.ToString());
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|