private void btnSave_Click(object sender, EventArgs e) { if (dxValidationProvider1.Validate()) { sc = new wrSuppliers.Server2Client(); sup = new wrSuppliers.wsSuppliers(); wrSuppliers.SupplierAccount s = new wrSuppliers.SupplierAccount(); string Remarks = txtRMKS.Text == "" ? "Debit Payment" : txtRMKS.Text; s.SupplierID = Convert.ToInt32(lueSNM.EditValue); s.TransDate = txtPDT.DateTime; s.Description = Remarks; s.Debit = 0; s.Credit = Convert.ToDouble(txtAMNT.Text); s.Balance = Convert.ToDouble(txtNBAL.Text); sc = sup.addTrans(s); if (sc.Message == null) { XtraMessageBox.Show("Payment done successfully!"); lueSNM.EditValue = null; txtCBAL.Text = "0"; txtAMNT.Text = "0"; txtNBAL.Text = "0"; txtRMKS.Text = ""; } else { XtraMessageBox.Show(sc.Message); } } }
private void btnOK_Click(object sender, EventArgs e) { sc = new wrPurchases.Server2Client(); pur = new wrPurchases.wsPurchases(); wrPurchases.Purchase prc = new wrPurchases.Purchase(); //Products prd = new Products(); prc.InvoiceNo = txtINV.Text; prc.PurchaseDate = dtpPDT.DateTime; prc.SupplierID = Convert.ToInt32(lueSUP.EditValue); prc.Amount = Convert.ToDouble(txtAMT.EditValue); prc.Payment = Convert.ToDouble(txtPAM.EditValue); prc.Balance = Convert.ToDouble(txtBAL.EditValue); sc = pur.addPurchase(prc); if (sc.Message != null) { XtraMessageBox.Show(sc.Message); return; } sup = new wrSuppliers.wsSuppliers(); wrSuppliers.Server2Client s2c = new wrSuppliers.Server2Client(); wrSuppliers.SupplierAccount s = new wrSuppliers.SupplierAccount(); s.SupplierID = Convert.ToInt32(lueSUP.EditValue); s.TransDate = dtpPDT.DateTime; s.Description = txtINV.Text; s.Debit = Convert.ToDouble(txtAMT.EditValue); s.Credit = Convert.ToDouble(txtPAM.EditValue); s.Balance = SupplierBalance + Convert.ToDouble(txtBAL.Text); s2c = sup.addTrans(s); if (sc.Message != null) { XtraMessageBox.Show(sc.Message); return; } Guid g; for (int i = 0; i <= grv.RowCount - 1; i++) { int cid = Convert.ToInt32(grv.GetRowCellValue(i, colCID)); string pnm = grv.GetRowCellValue(i, colPNM).ToString(); double bvl = Convert.ToDouble(grv.GetRowCellValue(i, colBVL)); double svl = Convert.ToDouble(grv.GetRowCellValue(i, colSVL)); int qty = Convert.ToInt32(grv.GetRowCellValue(i, colQTY)); double amt = Convert.ToDouble(grv.GetRowCellValue(i, colAMT)); string bcd = grv.GetRowCellValue(i, colBCD).ToString(); wrPurchases.PurchaseDetail pdt = new wrPurchases.PurchaseDetail(); pdt.InvoiceNo = txtINV.Text; g = Guid.NewGuid(); pdt.ProductCode = g.ToString(); pdt.BuyingValue = bvl; pdt.SellingValue = svl; pdt.Quantity = qty; pdt.Amount = amt; sc = pur.addPurchaseDetails(pdt); if (sc.Message != null) { XtraMessageBox.Show(sc.Message); return; } wrProducts.wsProducts prd = new wrProducts.wsProducts(); wrProducts.Product p = new wrProducts.Product(); wrProducts.Server2Client spc = new wrProducts.Server2Client(); p.CategoryID = cid; p.SupplierID = Convert.ToInt32(lueSUP.EditValue); p.ProductCode = g.ToString(); p.ProductName = pnm; p.BuyingValue = bvl; p.SellingValue = svl; p.SupplierID = Convert.ToInt32(lueSUP.EditValue); p.Quantity = qty; p.BarCode = bcd; spc = prd.AddProduct(p); if (sc.Message != null) { XtraMessageBox.Show(sc.Message); return; } } XtraMessageBox.Show("Product(s) purchased successfully!"); InitInvoice(); dtpPDT.DateTime = DateTime.Now.Date; dt = new DataTable(); InitDataTable(); InitSuppliers(); InitCategories(); grd.DataSource = null; }