private void GetRecords() { try { Cursor.Current = Cursors.WaitCursor; bsRecords.DataSource = Data_PaymentStaging.GetPaymentStagingByUsername(Global.Username); } catch (Exception ex) { Utils.ShowException(ex); } finally { Cursor.Current = Cursors.Default; } }
private void btnClear_Click(object sender, EventArgs e) { try { if (grdRecords.RowCount > 0 && Utils.AskQuestion("You you sure you want to clear all Payments?") == DialogResult.Yes) { Data_PaymentStaging.DeleteAllPaymentStaging(Global.Username); GetRecords(); } } catch (Exception ex) { Utils.ShowException(ex); } }
private void grdRecords_CellEndEdit(object sender, DataGridViewCellEventArgs e) { try { Data_PaymentStaging payment = grdRecords.Rows[e.RowIndex].DataBoundItem as Data_PaymentStaging; if (payment != null) { Data_PaymentStaging.SavePaymentStaging(payment); } } catch (Exception ex) { Utils.ShowException(ex); } }
private void SavePaymentStaging() { try { List <Data_PaymentStaging> payments = bsRecords.DataSource as List <Data_PaymentStaging>; if (payments != null) { Data_PaymentStaging.SavePaymentStaging(Global.Username, payments); } } catch (Exception ex) { Utils.ShowException(ex); } }
private void DeleteFromPaymentStaging() { try { if (grdRecords.RowCount > 0 && Utils.AskQuestion("Are you sure you want to delete this Payment?") == DialogResult.Yes) { Data_PaymentStaging payment = Utils.GetCurrentRecord <Data_PaymentStaging>(bsRecords); if (payment != null) { Data_PaymentStaging.DeleteFromPaymentStaging(payment.Username, payment.SuppplierId); GetRecords(); } } } catch (Exception ex) { Utils.ShowException(ex); } }
private void btnSave_Click(object sender, EventArgs e) { try { List <Data_PaymentStaging> staging = new List <Data_PaymentStaging>(); foreach (DataGridViewRow i in grdSuppliers.Rows) { DataGridViewCheckBoxCell cell = i.Cells["Selected"] as DataGridViewCheckBoxCell; bool isSelected = Convert.ToBoolean(cell.Value); if (isSelected) { Data_Supplier supplier = i.DataBoundItem as Data_Supplier; if (supplier != null) { staging.Add(new Data_PaymentStaging() { Username = Global.Username, SuppplierId = supplier.SupplierID, Amount = amount }); } } } Data_PaymentStaging.SavePaymentStaging(Global.Username, staging); DialogResult = DialogResult.OK; } catch (Exception ex) { Utils.ShowException(ex); } }