private void VES_But_Update_Click(object sender, EventArgs e) { BalanseConn VESConn = new BalanseConn(); DialogResult result1; result1 = MessageBox.Show("This will update the sales record. All PO payments will be removed. Do you want to continue?", "Update Sales Record", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result1 == DialogResult.Yes) { if (!IsEmpty(VES_TB_Total.Text)) { if (VES_TB_Total.Text == VES_TB_RunTotal.Text) { VESConn.DropSales(srowid); AddSalesTransaction(); foreach (DataGridViewRow row in VES_DGV_PO.Rows) { int invoice_no = Convert.ToInt32(row.Cells[2].Value.ToString()); if (CheckPayment(invoice_no) == true) { VESConn.DropPayment(invoice_no); } } MessageBox.Show("Record updated."); this.Close(); } if (VES_TB_Total.Text != VES_TB_RunTotal.Text) { DialogResult result2; result2 = MessageBox.Show("Running Total is not equal to Total Sales. Do you still want to add the report?", "Add Sales", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result2 == DialogResult.Yes) { VESConn.DropSales(srowid); AddSalesTransaction(); foreach (DataGridViewRow row in VES_DGV_PO.Rows) { int invoice_no = Convert.ToInt32(row.Cells[2].Value.ToString()); if (CheckPayment(invoice_no) == true) { VESConn.DropPayment(invoice_no); } } MessageBox.Show("Record updated."); this.Close(); } } } } if (result1 == DialogResult.No) { Close(); } }
private void VES_But_Delete_Click(object sender, EventArgs e) { BalanseConn VESConn = new BalanseConn(); DialogResult result1; result1 = MessageBox.Show("This will delete the sales record. Do you want to continue?", "Delete Sales Record", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result1 == DialogResult.Yes) { VESConn.DropSales(srowid); foreach (DataGridViewRow row in VES_DGV_PO.Rows) { int invoice_no = Convert.ToInt32(row.Cells[2].Value.ToString()); if (CheckPayment(invoice_no) == true) { VESConn.DropPayment(invoice_no); } } MessageBox.Show("Record deleted"); this.Close(); } if (result1 == DialogResult.No) { Close(); } }
private void POSub_But_Save_Click(object sender, EventArgs e) { BalanseConn conn = new BalanseConn(); conn.DropPayment(inv_no); string outputrowid = ""; DateTime update_date = DateTime.Now; foreach (DataGridViewRow row in dgv_PoPayments.Rows) { if (row.Cells[3].Value.ToString() == "Yes") { outputrowid += conn.InsertPO_Payment( DateTime.ParseExact(POPay_TB_PODate.Text, "MM/dd/yyyy", CultureInfo.InvariantCulture), POPay_TB_Branch.Text, Convert.ToDecimal(POPay_TB_POAmt.Text), row.Cells[0].Value.ToString().ToUpper(), DateTime.ParseExact(row.Cells[2].Value.ToString(), "MM/dd/yyyy", CultureInfo.InvariantCulture), Convert.ToDecimal(row.Cells[1].Value.ToString()), update_date, this.encoder, inv_no, 1) + ","; } else { outputrowid += conn.InsertPO_Payment( DateTime.ParseExact(POPay_TB_PODate.Text, "MM/dd/yyyy", CultureInfo.InvariantCulture), POPay_TB_Branch.Text, Convert.ToDecimal(POPay_TB_POAmt.Text), row.Cells[0].Value.ToString().ToUpper(), DateTime.ParseExact(row.Cells[2].Value.ToString(), "MM/dd/yyyy", CultureInfo.InvariantCulture), Convert.ToDecimal(row.Cells[1].Value.ToString()), update_date, this.encoder, inv_no, 0 ) + ","; } conn.UpdatePOStatus(POPay_DD_Status.Text, inv_no, update_date); } if ((outputrowid.Split(',').Length - 1) == dgv_PoPayments.Rows.Count) { MessageBox.Show("Payments Saved"); this.Close(); } else { MessageBox.Show("There was an error saving the payments."); } }