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; using BiskLog_Point_Of_Sale.Cashier_Module; using BiskLog_Point_Of_Sale.Classes; using BiskLog_Point_Of_Sale.Multiple_Login; using BiskLog_Point_Of_Sale.Properties; namespace Point_Of_Sale_Managment.CashierModule { public partial class CashierCustomerBill : Form { SqlConnection cn; SqlCommand command; DatabaseConn conn = new DatabaseConn(); SqlDataReader dr; string currency; public string id, name, address, telephone, email; public CustomerClass customer = new CustomerClass(); NewSalesPOS formSale; public CashierCustomerBill(NewSalesPOS formsales = null) { InitializeComponent(); cn = new SqlConnection(conn.MyConnection()); formSale = formsales; currency = Settings.Default.currrencyCode + " "; } private void DataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex != -1) { string colName = dataGridView1.Columns[e.ColumnIndex].Name; id = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString(); name = dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString(); address = dataGridView1.Rows[e.RowIndex].Cells[3].Value.ToString(); telephone = dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString(); email = dataGridView1.Rows[e.RowIndex].Cells[4].Value.ToString(); customer.id = id; customer.firstname = name; this.DialogResult = DialogResult.OK; this.Close(); } } public void products(string key) { dataGridView1.Rows.Clear(); cn.Open(); command = new SqlCommand("Select C.customerID,C.Firstname,C.Surname,C.address,C.telephone,C.email,C.financialStatus from tblCustomers C " + "where C.branchID = @branch and C.status = 'ACTIVE' and C.name_key1 like '%" + key + "%' or " + "C.branchID = @branch and C.status = 'ACTIVE' and C.name_key2 like '%" + key + "%' or " + "C.branchID = @branch and C.status = 'ACTIVE' and C.firstname like '%" + key + "%' or " + "C.branchID = @branch and C.status = 'ACTIVE' and C.surname like '%" + key + "%' or " + "C.branchID = @branch and C.status = 'ACTIVE' and C.telephone like '%" + key + "%'", cn); command.Parameters.AddWithValue("@branch", CashierMain.branch); command.ExecuteNonQuery(); dr = command.ExecuteReader(); while (dr.Read()) { dataGridView1.Rows.Add(dr[0].ToString(), dr[1].ToString().ToUpper() + " " + dr[2].ToString().ToUpper(), dr[4].ToString(), dr[3].ToString(), dr[5].ToString()); } dr.Close(); cn.Close(); } private void Exit_Click(object sender, EventArgs e) { this.Close(); } private void Exit_MouseEnter(object sender, EventArgs e) { exit.BackColor = Color.Crimson; } private void Exit_MouseLeave(object sender, EventArgs e) { exit.BackColor = Color.Transparent; } private void ProNAME_TextChanged(object sender, EventArgs e) { if (String.IsNullOrEmpty(proNAME.Text)) { dataGridView1.Rows.Clear(); } else { products(proNAME.Text); } } } }