private void btndelete_ItemClick(object sender, ItemClickEventArgs e) { if (!string.IsNullOrEmpty(_Batchno)) { if (XtraMessageBox.Show("Do you want to delete selected invoices " , "POS", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { gridView1.PostEditor(); foreach (Ledgers.ARAPRECEIPTSDETAILSRow drm in ledgers1.ARAPRECEIPTSDETAILS.Rows) { if (drm.SEL == false) { var bl = new BLPurchasePayment(); bl.DoDeleteInvoice(drm); } } ledgers1.ARAPRECEIPTSDETAILS.Clear(); gridControl1.ResetBindings(); GetPaymentDetails(); } } }
void GetPaymentDetails() { var bl = new BLPurchasePayment {batchno = _Batchno}; bl.GetPurchasePayment(); ledgers1.Merge(bl.drTable); lookupbankname.EditValue = bl.dRow.BANKID; CheckAll(); if (bl.dRow.POSTED) { btnpost.Enabled = false; } else { btnpost.Enabled = true; } }
void DoPost() { if (!string.IsNullOrEmpty(_Batchno)) { var bhl = new BLPurchasePayment(); bhl.batchno = _Batchno; bhl.drTable = ledgers1.ARAPRECEIPTSDETAILS; var strstatus = bhl.DoPost(); if (strstatus == "1") { ledgers1.ARAPRECEIPTSDETAILS.Clear(); _Batchno = string.Empty; gridControl1.ResetBindings(); aRAPRECEIPTSBindingSource.DataSource = new PurchasePayment().GetArapReceiptMainPostUnPost(false); // aRAPRECEIPTSBindingSource1.DataSource = new PurchasePayment().GetArapReceiptMainPostUnPost(true); lookupbatch.EditValue = null; lookupbatch.Properties.DataSource = aRAPRECEIPTSBindingSource; } else { XtraMessageBox.Show(strstatus, "POS", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
void DoSave(string batchno,bool isnew=false) { Ledgers.ARAPRECEIPTSRow newrow = null; gridView1.PostEditor(); gridView1.UpdateCurrentRow(); aRAPRECEIPTSDETAILSBindingSource.EndEdit(); if (string.IsNullOrEmpty(batchno)) { newrow = (Ledgers.ARAPRECEIPTSRow) new Ledgers.ARAPRECEIPTSDataTable().NewRow(); newrow.AMOUNT = GetTotal(); newrow.BANKID = lookupbankname.EditValue == null ? 0 : int.Parse(lookupbankname.EditValue.ToString()); newrow.POSTED = false; newrow.TDATE = DateTime.Now.Date; } else { var dt = new PurchasePayment().GetArapReceiptWithBatchno(batchno); newrow = (Ledgers.ARAPRECEIPTSRow) dt.Rows[0]; if(!isnew) newrow.AMOUNT = newrow.AMOUNT + GetTotal(); else { newrow.AMOUNT = GetTotal(); } } var bhl = new BLPurchasePayment(); var changes = (Ledgers.ARAPRECEIPTSDETAILSDataTable)ledgers1.ARAPRECEIPTSDETAILS.GetChanges(DataRowState.Modified | DataRowState.Added); // var deleted = (Ledgers.ARAPRECEIPTSDETAILSDataTable)ledgers1.ARAPRECEIPTSDETAILS.GetChanges(DataRowState.Modified | DataRowState.Added); bhl.dRow = newrow; bhl.drTable = ledgers1.ARAPRECEIPTSDETAILS; try { var strstatus = bhl.DoSave(); if (strstatus == "1") { CheckAll(); aRAPRECEIPTSBindingSource.DataSource = new PurchasePayment().GetArapReceiptMainPostUnPost(false); btnpost.Enabled = true; btnsave.Enabled = false; btndelete.Enabled = true; _Batchno = VIRETAILDAL.COMMON.Utils.PurPayment; btnpost.Enabled = false; popupControlContainer1.Visible = false; Application.DoEvents(); XtraMessageBox.Show("Data Saved Sucessfully", "POS", MessageBoxButtons.OK, MessageBoxIcon.Information); foreach (DataRow d in ledgers1.ARAPRECEIPTSDETAILS.Rows) { if (d.RowState != DataRowState.Deleted) { d["ARAPTRANID"] = _Batchno; } } var addedRows = from row in ledgers1.ARAPRECEIPTSDETAILS where row.RowState == DataRowState.Added select row; foreach (var row in addedRows.ToArray()) { row.Delete(); } if (changes != null) ledgers1.Merge(changes); ledgers1.AcceptChanges(); } else { XtraMessageBox.Show(strstatus, "POS", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { XtraMessageBox.Show(ex.ToString()); } }