private void CreateSaleButton_Click(object sender, EventArgs e) { Sales sales = null; if (sales != null) { sales.Activate(); } else { sales = new Sales(); sales.Show(); } }
private void Main_Menu_KeyDown(object sender, KeyEventArgs e) { // go to the category form if (e.KeyCode == Keys.F1) { sendcategory(); } // form exit else if (e.KeyCode == Keys.End) { cnclw_btn.PerformClick(); } // go to the brand form else if (e.KeyCode == Keys.F2) { sendBrand(); } // go to the item store form else if (e.KeyCode == Keys.F3) { Item_StoreSend(); } // go to the sales details form else if (e.KeyCode == Keys.F4) { Sales sl = new Sales(); sl.Show(); } // go to the customer details form else if (e.KeyCode == Keys.F5) { Customer cm = new Customer(); cm.Show(); } // go to the report form else if (e.KeyCode == Keys.F6) { Report rp = new Report(); rp.Show(); } // payment calculation focus else if (e.Control && e.KeyCode == Keys.M) { itemno_txt.Text = ""; qt_txt.Text = ""; this.payment_txt.Focus(); } // item enter focus else if (e.Control && e.KeyCode == Keys.I) { this.itemno_txt.Focus(); this.payment_txt.Text = ""; this.qt_txt.Text = ""; } // added item remove else if (e.Control && e.KeyCode == Keys.D || e.Control && e.KeyCode == Keys.Delete) { int oldQTY = 0; int index; try { //get current row field number index = sales_gride.CurrentRow.Index; //database searching string sql = "select * from items where item_id like '" + sales_gride.Rows[index].Cells[1].Value + "' || barcode_id like '" + sales_gride.Rows[index].Cells[2].Value + "' "; MySqlCommand cmd1 = new MySqlCommand(sql, conn); conn.Open(); MySqlDataReader reder = cmd1.ExecuteReader(); while (reder.Read()) { // get and set value oldQTY = int.Parse(reder["qty"].ToString()); } conn.Close(); // devition item count //set number of items itemcount = itemcount - int.Parse(sales_gride.Rows[index].Cells[5].Value.ToString()); itemQty_lbl.Text = itemcount.ToString(); // update database int x = oldQTY + int.Parse(sales_gride.Rows[index].Cells[5].Value.ToString()); string insertquery = "UPDATE items SET qty=@qty WHERE item_id like '" + sales_gride.Rows[index].Cells[1].Value + "' || barcode_id like '" + sales_gride.Rows[index].Cells[2].Value + "'"; MySqlCommand cmd = new MySqlCommand(insertquery, conn); string passX = x.ToString(); conn.Open(); cmd.Parameters.AddWithValue("@qty", passX); cmd.ExecuteNonQuery(); conn.Close(); // remove row in datagride view sales_gride.Rows.RemoveAt(index); //make total int total = 0; for (int i = 0; i < sales_gride.Rows.Count; i++) { int xy = int.Parse(sales_gride.Rows[i].Cells[6].Value.ToString()); total = total + xy; } //set total total_lbl.Text = total.ToString(); // price calculation int payment = int.Parse(payment_lbl.Text.Trim()); int payble = payment - int.Parse(total_lbl.Text.ToString()); balance_lbl.Text = payble.ToString(); } catch (Exception ex) { MessageBox.Show(ex.Message); } conn.Close(); } // go to the print form else if (e.Control && e.KeyCode == Keys.P) { if (pay_methd_lbl.Text == "Borrower") { if (cus_id_txt.Text == "") { MessageBox.Show("Please enter customer id...", "POS Info", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { saveCustomerBill(); sendPrintDetails(); this.itemno_txt.Focus(); } } else { sendPrintDetails(); this.itemno_txt.Focus(); } } // select the data gride view else if (e.Control && e.KeyCode == Keys.Down) { sales_gride.Select(); } }
private void sale_btn_img_Click(object sender, EventArgs e) { Sales sl = new Sales(); sl.Show(); }