private void SelectPayment() { if (grdPayment.RowCount > 0) { if (Program.MsgBox_Show("Are you sure want to cancel this payment ? ", "Confirmation", "YesNo")) { var oPaymentDt = new PaymentDt(); oPaymentDt.ID = grdPayment.SelectedRows[0].Cells["ID"].Value.ToString(); if (oPaymentDt.SelectOne().Rows.Count > 0) { var conn = new SqlConnection(HisConfiguration.ConnectionString); SqlTransaction trans = null; try { conn.Open(); trans = conn.BeginTransaction(); oPaymentDt.ID = BussinessRules.ID.GenerateIDNumberWithBeginTransaction("PaymentDt", "ID", conn, trans, "FP"); oPaymentDt.Amount = -(oPaymentDt.Amount); oPaymentDt.UserInsert = _UserID; oPaymentDt.UserUpdate = _UserID; oPaymentDt.Insert(conn, trans); trans.Commit(); _retval = true; } catch (Exception ex) { if (trans != null) { trans.Rollback(); trans.Dispose(); } MessageBox.Show(ex.Message); } finally { if (trans != null) { trans.Dispose(); } conn.Close(); conn.Dispose(); } Close(); } else { Program.MsgBox_Show("Payment is not found, please select another payment"); PopulateGrid(); } oPaymentDt.Dispose(); oPaymentDt = null; } } }
private void PopulateGrid() { grdPayment.SuspendLayout(); grdPayment.AutoGenerateColumns = false; var oPaymentDt = new PaymentDt(); var tmpDVPaymentDt = new DataView(oPaymentDt.SelectByReceiptNoForCancelPayment(_ReceiptNo.Trim())); grdPayment.DataSource = tmpDVPaymentDt; grdPayment.ResumeLayout(); oPaymentDt.Dispose(); oPaymentDt = null; }
private void PopulateGrid() { gridSettlement.SuspendLayout(); gridSettlement.AutoGenerateColumns = false; var PaymentDt = new PaymentDt(); var dtb = PaymentDt.SelectAllPaymentMethod(dtpSettlementDate.Value.Date, txtCashierID.Text.Trim()); gridSettlement.DataSource = dtb; gridSettlement.ResumeLayout(); txtGrandTotal.Text = string.Format(Program.FormatCurrency, (from DataRow row in dtb.Rows //where row["IsDeleted"].Equals(false) select Convert.ToDecimal(row["Amount"])).Sum() ); PaymentDt.Dispose(); PaymentDt = null; dtb.Dispose(); dtb = null; }