public FrmEditInvoiceLookUp(AdminUpdateInvoice idit) { InitializeComponent(); cn = new SqlConnection(dbcon.MyConnection()); edit = idit; this.KeyPreview = true; }
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { string colName = dataGridView1.Columns[e.ColumnIndex].Name; if (colName == "Edit") { // Show the Update Invoice usercontrol // Compute automatically the amount of the ordered products if (!AdminAdministrator.Instance.PnlContainer.Controls.ContainsKey("AdminUpdateInvoice")) { AdminUpdateInvoice update = new AdminUpdateInvoice(); update.Dock = DockStyle.Fill; AdminAdministrator.Instance.PnlContainer.Controls.Add(update); update.lblID.Text = dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString(); update.lblInvoiceNo.Text = dataGridView1.Rows[e.RowIndex].Cells[3].Value.ToString(); update.txtCustomer.Text = dataGridView1.Rows[e.RowIndex].Cells[4].Value.ToString(); update.txtAddress.Text = dataGridView1.Rows[e.RowIndex].Cells[5].Value.ToString(); update.cbxPayment.Text = dataGridView1.Rows[e.RowIndex].Cells[11].Value.ToString(); update.Dmdays.Text = dataGridView1.Rows[e.RowIndex].Cells[12].Value.ToString(); update.txtBilling.Text = dataGridView1.Rows[e.RowIndex].Cells[13].Value.ToString(); update.lblSalesTotal.Text = dataGridView1.Rows[e.RowIndex].Cells[6].Value.ToString(); update.lblDiscount.Text = dataGridView1.Rows[e.RowIndex].Cells[7].Value.ToString(); update.lblVAT.Text = dataGridView1.Rows[e.RowIndex].Cells[8].Value.ToString(); update.lblVatable.Text = dataGridView1.Rows[e.RowIndex].Cells[9].Value.ToString(); update.lblTotalAmount.Text = dataGridView1.Rows[e.RowIndex].Cells[10].Value.ToString(); update.txtRemarks.Text = dataGridView1.Rows[e.RowIndex].Cells[17].Value.ToString(); update.txtPrvComment.Text = dataGridView1.Rows[e.RowIndex].Cells[18].Value.ToString(); update.dataGridView1.Rows.Clear(); update.DueDateAutomation(); int i = 0; cn.Open(); cm = new SqlCommand("SELECT * FROM tblInvoiceOrder WHERE invoiceno like '" + dataGridView1.Rows[e.RowIndex].Cells[3].Value.ToString() + "'", cn); dr = cm.ExecuteReader(); while (dr.Read()) { i++; update.dataGridView1.Rows.Add(i, dr[0].ToString(), dr[7].ToString(), dr[4].ToString(), dr[5].ToString(), dr[6].ToString(), dr[8].ToString(), dr[9].ToString()); } cn.Close(); update.GetOrderTotal(); } AdminAdministrator.Instance.PnlContainer.Controls["AdminUpdateInvoice"].BringToFront(); AdminAdministrator.Instance.BackButton.Visible = false; AdminAdministrator.Instance.BackToInvoiceButton.Visible = true; AdminAdministrator.Instance.BackToInvoiceButton.Location = new System.Drawing.Point(8, 9); } else if (colName == "Delete") { if (MessageBox.Show("Are you sure you want to Delete this Invoice?", "Deleting Invoice", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { cn.Open(); cm = new SqlCommand("DELETE FROM tblInvoiceOrder WHERE invoiceno like '" + dataGridView1.Rows[e.RowIndex].Cells[3].Value.ToString() + "'", cn); cm.ExecuteNonQuery(); cn.Close(); ShowAllInvoices(); cn.Open(); cm = new SqlCommand("DELETE FROM tblInvoiceRecords WHERE invoiceno like '" + dataGridView1.Rows[e.RowIndex].Cells[3].Value.ToString() + "'", cn); cm.ExecuteNonQuery(); cn.Close(); MessageBox.Show("Invoice Successfully Deleted.", "Deleting Invoice", MessageBoxButtons.OK, MessageBoxIcon.Information); ShowAllInvoices(); } } else if (colName == "Cancel") { if (MessageBox.Show("Are you sure you want to Cancel this Invoice? Once this done, You can never get the Invoice back!", "Cancelling Invoice", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { if (!AdminAdministrator.Instance.PnlContainer.Controls.ContainsKey("AdminCancelInvoiceVerifier")) { AdminCancelInvoiceVerifier cancel = new AdminCancelInvoiceVerifier(this); cancel.Dock = DockStyle.Fill; AdminAdministrator.Instance.PnlContainer.Controls.Add(cancel); cancel.lblID.Text = dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString(); cancel.lblInvoiceNo.Text = dataGridView1.Rows[e.RowIndex].Cells[3].Value.ToString(); cancel.txtCustomer.Text = dataGridView1.Rows[e.RowIndex].Cells[4].Value.ToString(); cancel.txtAddress.Text = dataGridView1.Rows[e.RowIndex].Cells[5].Value.ToString(); cancel.cbxPayment.Text = dataGridView1.Rows[e.RowIndex].Cells[11].Value.ToString(); cancel.Dmdays.Text = dataGridView1.Rows[e.RowIndex].Cells[12].Value.ToString(); cancel.lblSalesTotal.Text = dataGridView1.Rows[e.RowIndex].Cells[6].Value.ToString(); cancel.lblDiscount.Text = dataGridView1.Rows[e.RowIndex].Cells[7].Value.ToString(); cancel.lblVAT.Text = dataGridView1.Rows[e.RowIndex].Cells[8].Value.ToString(); cancel.lblVatable.Text = dataGridView1.Rows[e.RowIndex].Cells[9].Value.ToString(); cancel.lblTotalAmount.Text = dataGridView1.Rows[e.RowIndex].Cells[10].Value.ToString(); cancel.dataGridView1.Rows.Clear(); int i = 0; cn.Open(); cm = new SqlCommand("SELECT * FROM tblInvoiceOrder WHERE invoiceno like '" + dataGridView1.Rows[e.RowIndex].Cells[3].Value.ToString() + "'", cn); dr = cm.ExecuteReader(); while (dr.Read()) { i++; cancel.dataGridView1.Rows.Add(i, dr[0].ToString(), dr[7].ToString(), dr[4].ToString(), dr[5].ToString(), dr[6].ToString(), dr[8].ToString(), dr[9].ToString()); } cn.Close(); //Compute automatically the amount of the ordered products cancel.txtUsername.Text = AdminAdministrator.PassCanName; cancel.GetOrderTotal(); cancel.Show(); } AdminAdministrator.Instance.PnlContainer.Controls["AdminCancelInvoiceVerifier"].BringToFront(); AdminAdministrator.Instance.BackButton.Visible = false; AdminAdministrator.Instance.BackToInvoiceButton.Visible = true; AdminAdministrator.Instance.BackToInvoiceButton.Location = new System.Drawing.Point(8, 9); } } }
public FrmEditInvoiceDiscount(AdminUpdateInvoice idit) { InitializeComponent(); cn = new SqlConnection(dbcon.MyConnection()); edit = idit; }
public FrmInvoiceEditPrintPreview(AdminUpdateInvoice idit) { InitializeComponent(); edit = idit; }