private void btnSell_Click(object sender, EventArgs e) { if (grv.RowCount <= 0) { XtraMessageBox.Show("Please add some product to sell"); return; } wrCustomers.Server2Client scc = new wrCustomers.Server2Client(); wrCustomers.wsCustomers cus = new wrCustomers.wsCustomers(); scc = cus.CreateDefaultCustomer(); int CusID = scc.Count; wrSales.Sale s = new wrSales.Sale(); s.InvoiceNo = txtINV.Text; s.SaleDate = dtpSDT.DateTime; s.CustomerID = CusID; s.Amount = Convert.ToDouble(txtAMT.EditValue); s.Discount = Convert.ToDouble(txtDSC.EditValue); s.Payment = Convert.ToDouble(txtPAM.EditValue); s.Balance = Convert.ToDouble(txtBAL.EditValue); sls = new wrSales.wsSales(); sc = sls.AddSale(s); if (sc.Message != null) { XtraMessageBox.Show(sc.Message); return; } for (int i = 0; i <= grv.RowCount - 1; i++) { wrProducts.Server2Client spc = new wrProducts.Server2Client(); wrProducts.wsProducts prd = new wrProducts.wsProducts(); wrSales.Server2Client ssc = new wrSales.Server2Client(); wrSales.SaleDetail sd = new wrSales.SaleDetail(); sd.InvoiceNo = txtINV.Text; sd.ProductID = Convert.ToInt32(grv.GetRowCellValue(i, colPID)); sd.Quantity = Convert.ToInt32(grv.GetRowCellValue(i, colQTY)); sd.BuyingValue = Convert.ToDouble(grv.GetRowCellValue(i, colBVL)); sd.SellingValue = Convert.ToDouble(grv.GetRowCellValue(i, colSVL)); sd.Amount = sd.Quantity * sd.SellingValue; ssc = sls.AddSaleDetails(sd); spc = prd.updateQuantity(sd.ProductID, sd.Quantity, "-"); } XtraMessageBox.Show("Product(s) Sold!"); grd.DataSource = null; InitInvoiceNo(); lueCAT.EditValue = null; luePNM.EditValue = null; lueCAT.Properties.DataSource = null; luePNM.Properties.DataSource = null; InitCategories(); InitProducts(); Reset(); }
private void bDel_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { CID = Convert.ToInt32(grv.GetFocusedRowCellValue(colCID)); wrProducts.Category c = new wrProducts.Category(); c.CategoryID = CID; c.CategoryName = txtCNM.Text.ToUpper(); if (XtraMessageBox.Show("Are you sure you want to delete this Category? Deleting this category will also delete corresponding Products", "Confirm Delete", MessageBoxButtons.YesNo) == DialogResult.Yes) { sc = new wrProducts.Server2Client(); prd = new wrProducts.wsProducts(); sc = prd.DeleteCategory(c); if (sc.Message == null) { XtraMessageBox.Show("Category deleted successfully!"); } else { XtraMessageBox.Show(sc.Message); } LoadData(); } }
public ucProducts() { InitializeComponent(); InitDataTable(); sc = new wrProducts.Server2Client(); prd = new wrProducts.wsProducts(); sc = prd.GetProductValues(); DataTable d = new DataTable(); d = sc.dataTable; for (int i = 0; i <= d.Rows.Count - 1; i++) { //CategoryName, ProductName, BuyingValue, SellingValue, TotalQuantity DataRow r = dt.NewRow(); r["CategoryName"] = d.Rows[i].ItemArray[0].ToString(); r["ProductName"] = d.Rows[i].ItemArray[1].ToString(); r["BuyingValue"] = Convert.ToDouble(d.Rows[i].ItemArray[2]); r["SellingValue"] = Convert.ToDouble(d.Rows[i].ItemArray[3]); r["TotalQuantity"] = Convert.ToInt32(d.Rows[i].ItemArray[4]); r["TotalBuyingValue"] = Convert.ToDouble(d.Rows[i].ItemArray[2]) * Convert.ToInt32(d.Rows[i].ItemArray[4]); r["TotalSellingValue"] = Convert.ToDouble(d.Rows[i].ItemArray[3]) * Convert.ToInt32(d.Rows[i].ItemArray[4]); dt.Rows.Add(r); } grd.DataSource = dt; grd.Refresh(); }
private void btnOK_Click(object sender, EventArgs e) { if (!dxVP.Validate()) { return; } wrProducts.Product p = new wrProducts.Product(); p.ProductID = Convert.ToInt32(luePRD.EditValue); p.CategoryID = Convert.ToInt32(lueCAT2.EditValue); p.ProductName = txtPNM.EditValue.ToString(); p.BuyingValue = Convert.ToDouble(txtBVL.EditValue); p.SellingValue = Convert.ToDouble(txtSVL.EditValue); p.Quantity = Convert.ToInt32(txtQTY.EditValue); p.BarCode = txtBCD.Text; sc = new wrProducts.Server2Client(); prd = new wrProducts.wsProducts(); sc = prd.updateProduct(p); if (sc.Message != null) { XtraMessageBox.Show(sc.Message); } else { DialogResult = DialogResult.OK; } }
private void btnDelete_Click(object sender, EventArgs e) { if (grv.RowCount > 0) { for (int i = 0; i < grv.SelectedRowsCount; i++) { if (grv.GetSelectedRows()[i] >= 0) { int x = Convert.ToInt32(grv.GetSelectedRows()[i]); int id = Convert.ToInt32(grv.GetRowCellValue(x, colPID)); sc = new wrProducts.Server2Client(); prd = new wrProducts.wsProducts(); sc = prd.deleteProduct(id); if (sc.Message != null) { XtraMessageBox.Show(sc.Message); } } } lueCAT_EditValueChanged(null, null); } else { XtraMessageBox.Show("Nothing to delete"); } }
private void grv_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e) { int qty = 0; double prc = 0; switch (e.Column.Caption) { case "Particulars": int PID = Convert.ToInt32(grv.GetFocusedRowCellValue(colPID)); wrProducts.Server2Client spc = new wrProducts.Server2Client(); wrProducts.wsProducts prd = new wrProducts.wsProducts(); wrProducts.Product p = new wrProducts.Product(); p = prd.GetProductByID(PID); grv.SetFocusedRowCellValue(colBVL, p.BuyingValue); grv.SetFocusedRowCellValue(colSVL, p.SellingValue); grv.UpdateCurrentRow(); break; case "Quantity": qty = Convert.ToInt32(grv.GetFocusedRowCellValue(colQTY)); prc = Convert.ToDouble(grv.GetFocusedRowCellValue(colSVL)); grv.SetFocusedRowCellValue(colAMT, qty * prc); grv.UpdateCurrentRow(); break; case "Rate": qty = Convert.ToInt32(grv.GetFocusedRowCellValue(colQTY)); prc = Convert.ToDouble(grv.GetFocusedRowCellValue(colSVL)); grv.SetFocusedRowCellValue(colAMT, qty * prc); grv.UpdateCurrentRow(); break; } }
void InitCategories() { wrProducts.Server2Client spc = new wrProducts.Server2Client(); wrProducts.wsProducts prd = new wrProducts.wsProducts(); spc = prd.GetCategories(); lueCAT.Properties.DataSource = spc.dataTable; lueCAT.Properties.DisplayMember = "CategoryName"; lueCAT.Properties.ValueMember = "ID"; }
void InitProducts() { wrProducts.Server2Client spc = new wrProducts.Server2Client(); wrProducts.wsProducts prd = new wrProducts.wsProducts(); spc = prd.GetProducts(); luePNM.Properties.DataSource = spc.dataTable; luePNM.Properties.DisplayMember = "ProductName"; luePNM.Properties.ValueMember = "ID"; }
void InitProducts(int CategoryID) { sc = new wrProducts.Server2Client(); prd = new wrProducts.wsProducts(); sc = prd.GetProductByCategory(CategoryID); luePRD.Properties.DataSource = sc.dataTable; luePRD.Properties.DisplayMember = "ProductName"; luePRD.Properties.ValueMember = "ID"; }
private void lueCAT_EditValueChanged(object sender, EventArgs e) { int CID = Convert.ToInt32(lueCAT.EditValue); sc = new wrProducts.Server2Client(); prd = new wrProducts.wsProducts(); sc = prd.GetProductByCategory(CID); grd.DataSource = sc.dataTable; }
public frmDeleteProduct() { InitializeComponent(); sc = new wrProducts.Server2Client(); prd = new wrProducts.wsProducts(); sc = prd.GetCategories(); lueCAT.Properties.DataSource = sc.dataTable; lueCAT.Properties.DisplayMember = "CategoryName"; lueCAT.Properties.ValueMember = "ID"; }
void InitCategories() { wrProducts.Server2Client s2c = new wrProducts.Server2Client(); wrProducts.wsProducts cat = new wrProducts.wsProducts(); s2c = cat.GetCategories(); lueCAT1.Properties.DataSource = s2c.dataTable; lueCAT1.Properties.DisplayMember = "CategoryName"; lueCAT1.Properties.ValueMember = "ID"; lueCAT2.Properties.DataSource = s2c.dataTable; lueCAT2.Properties.DisplayMember = "CategoryName"; lueCAT2.Properties.ValueMember = "ID"; }
private void bPCATS_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { wrProducts.Server2Client sc = new wrProducts.Server2Client(); wrProducts.wsProducts pd = new wrProducts.wsProducts(); sc = pd.ProductListByCategorySimplified(); rptProductByCat rpt = new rptProductByCat() { DataSource = sc.dataTable }; GroupField grp = new GroupField("CategoryName"); rpt.groupHeader.GroupFields.Add(grp); rpt.lbCAT.DataBindings.Add("Text", null, "CategoryName"); rpt.lbPNM.DataBindings.Add("Text", null, "ProductName"); rpt.lbBVL.DataBindings.Add("Text", null, "BuyingValue", "{0:C2}"); rpt.lbSVL.DataBindings.Add("Text", null, "SellingValue", "{0:C2}"); rpt.lbQTY.DataBindings.Add("Text", null, "SumOfQuantity"); rpt.lbBCD.Text = ""; //rpt.lbSBVL.DataBindings.Add("Text", null, "BuyingValue", "{0:C2}"); //rpt.lbSSVL.DataBindings.Add("Text", null, "SellingValue", "{0:C2}"); //rpt.lbSQTY.DataBindings.Add("Text", null, "Quantity"); //rpt.lbGBVL.DataBindings.Add("Text", null, "BuyingValue", "{0:C2}"); //rpt.lbGSVL.DataBindings.Add("Text", null, "SellingValue", "{0:C2}"); //rpt.lbGQTY.DataBindings.Add("Text", null, "Quantity"); //sbvl.FormatString = "{0:C2}"; //ssvl.FormatString = "{0:C2}"; //gbvl.FormatString = "{0:C2}"; //gsvl.FormatString = "{0:C2}"; //sbvl.Running = SummaryRunning.Group; //ssvl.Running = SummaryRunning.Group; //sqty.Running = SummaryRunning.Group; //gbvl.Running = SummaryRunning.Report; //gsvl.Running = SummaryRunning.Report; //gqty.Running = SummaryRunning.Report; //rpt.lbSBVL.Summary = sbvl; //rpt.lbSSVL.Summary = ssvl; //rpt.lbSQTY.Summary = sqty; //rpt.lbGBVL.Summary = gbvl; //rpt.lbGSVL.Summary = gsvl; //rpt.lbGQTY.Summary = gqty; dv.PrintingSystem = rpt.PrintingSystem; rpt.CreateDocument(true); }
private void lueCAT1_EditValueChanged(object sender, EventArgs e) { if (lueCAT1.EditValue != null) { int cid = Convert.ToInt32(lueCAT1.EditValue); wrProducts.Server2Client s2c = new wrProducts.Server2Client(); wrProducts.wsProducts prd = new wrProducts.wsProducts(); s2c = prd.GetProductByCategory(cid); luePNM1.Properties.DataSource = s2c.dataTable; luePNM1.Properties.DisplayMember = "ProductName"; luePNM1.Properties.ValueMember = "ID"; } }
private void lueCAT_EditValueChanged(object sender, EventArgs e) { if (slueCAT.RowCount <= 0) { return; } int CAT = Convert.ToInt32(lueCAT.EditValue); sc = new wrProducts.Server2Client(); prd = new wrProducts.wsProducts(); sc = prd.GetProductByCategory(CAT); luePNM.Properties.DataSource = sc.dataTable; luePNM.Properties.DisplayMember = "ProductName"; luePNM.Properties.ValueMember = "ProductName"; }
private void luePNM1_EditValueChanged(object sender, EventArgs e) { if (luePNM1.EditValue != null) { int pid = Convert.ToInt32(luePNM1.EditValue); wrProducts.Server2Client s2c = new wrProducts.Server2Client(); wrProducts.wsProducts prd = new wrProducts.wsProducts(); wrProducts.Product p = new wrProducts.Product(); p = prd.GetProductByID(pid); txtBVL1.EditValue = p.BuyingValue; txtSVL1.EditValue = p.SellingValue; txtQTY1.EditValue = 1; } }
private void lueCAT_EditValueChanged(object sender, EventArgs e) { if (lueCAT.EditValue == null) { InitProducts(); } else { int CID = Convert.ToInt32(lueCAT.EditValue); wrProducts.Server2Client spc = new wrProducts.Server2Client(); wrProducts.wsProducts prd = new wrProducts.wsProducts(); spc = prd.GetProductByCategory(CID); luePNM.Properties.DataSource = spc.dataTable; luePNM.Properties.DisplayMember = "ProductName"; luePNM.Properties.ValueMember = "ID"; } }
public frmRowEdit(int RowHandle, int CatID, string PNM, double BVL, double SVL, int QTY, string BCD) { InitializeComponent(); wrProducts.Server2Client sc = new wrProducts.Server2Client(); wrProducts.wsProducts cat = new wrProducts.wsProducts(); sc = cat.GetCategories(); lueCAT.Properties.DataSource = sc.dataTable; lueCAT.Properties.DisplayMember = "CategoryName"; lueCAT.Properties.ValueMember = "ID"; lueCAT.EditValue = CatID; txtPNM.EditValue = PNM; txtBVL.EditValue = BVL; txtSVL.EditValue = SVL; txtQTY.EditValue = QTY; txtBCD.EditValue = BCD; }
private void txtBCD_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { wrProducts.Server2Client spc = new wrProducts.Server2Client(); wrProducts.wsProducts prd = new wrProducts.wsProducts(); wrProducts.Product p = new wrProducts.Product(); p = prd.GetProductByBarCode(txtBCD.Text); if (p.Quantity < 1) { lblInfo.Text = "Product not available!"; txtBCD.Text = ""; txtBCD.Focus(); return; } if (p.Message == null) { DataRow r = dt.NewRow(); r["ProductID"] = p.ProductID; r["ProductName"] = p.ProductName; r["BarCode"] = p.BarCode; r["BuyingValue"] = p.BuyingValue; r["SellingValue"] = p.SellingValue; r["Quantity"] = 1; r["Amount"] = 1 * p.SellingValue; dt.Rows.Add(r); grd.DataSource = dt; grd.Refresh(); double TotalAmount = Convert.ToDouble(colAMT.SummaryText); txtAMT.Text = TotalAmount.ToString(); txtPAM.Text = TotalAmount.ToString(); txtBCD.Text = ""; txtBCD.Focus(); } else { lblInfo.Text = p.Message; } } }
private void luePNM_EditValueChanged(object sender, EventArgs e) { if (luePNM.EditValue == null) { Clear(); } else { int PID = Convert.ToInt32(luePNM.EditValue); wrProducts.Server2Client spc = new wrProducts.Server2Client(); wrProducts.wsProducts prd = new wrProducts.wsProducts(); wrProducts.Product p = new wrProducts.Product(); p = prd.GetProductByID(PID); BuyingValue = p.BuyingValue; txtSVL.EditValue = p.SellingValue; txtQTY.Properties.MaxValue = p.Quantity; BarCode = p.BarCode; } }
private void btnSave_Click(object sender, EventArgs e) { if (grv.RowCount <= 0) { XtraMessageBox.Show("Please add some product first!"); return; } sc = new wrProducts.Server2Client(); prd = new wrProducts.wsProducts(); for (int i = 0; i <= grv.RowCount - 1; i++) { wrProducts.Product p = new wrProducts.Product(); p.CategoryID = Convert.ToInt32(grv.GetRowCellValue(i, colCAT)); p.ProductName = grv.GetRowCellValue(i, colPNM).ToString(); p.BuyingValue = Convert.ToDouble(grv.GetRowCellValue(i, colBVL)); p.SellingValue = Convert.ToDouble(grv.GetRowCellValue(i, colSVL)); p.Quantity = Convert.ToInt32(grv.GetRowCellValue(i, colQTY)); p.BarCode = grv.GetRowCellValue(i, colBCD).ToString(); sc = prd.AddProduct(p); if (sc.Message != null) { XtraMessageBox.Show(sc.Message); return; } } XtraMessageBox.Show("Product(s) added successfully!"); grd.DataSource = null; grd.Refresh(); lueCAT.EditValue = null; txtPNM.EditValue = null; txtBVL.EditValue = 0; txtSVL.EditValue = 0; txtQTY.EditValue = 1; txtBCD.EditValue = null; lueCAT.Focus(); }
private void LoadData() { sc = new wrProducts.Server2Client(); prd = new wrProducts.wsProducts(); sc = prd.GetProductCategories(); grd.DataSource = sc.dataTable; if (grv.RowCount <= 0) { bEdit.Enabled = false; bDel.Enabled = false; } else { bEdit.Enabled = true; bDel.Enabled = true; } }
private void btnSave_Click(object sender, EventArgs e) { sc = new wrProducts.Server2Client(); prd = new wrProducts.wsProducts(); wrProducts.Category c = new wrProducts.Category(); c.CategoryID = CID; c.CategoryName = txtCNM.Text.ToUpper(); if (!IsEdit) { sc = prd.AddCategory(c); if (sc.Message == null) { XtraMessageBox.Show("New Category added successfully!"); } else { XtraMessageBox.Show(sc.Message); } txtCNM.Text = ""; txtCNM.Focus(); } else { sc = prd.UpdateCategory(c); if (sc.Message == null) { XtraMessageBox.Show("Category updated successfully!"); } else { XtraMessageBox.Show(sc.Message); } dp.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Hidden; } LoadData(); }
private void bPSUPX_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { wrProducts.Server2Client sc = new wrProducts.Server2Client(); wrProducts.wsProducts pd = new wrProducts.wsProducts(); sc = pd.ProductListBySupplierExtended(); rptProductBySup rpt = new rptProductBySup() { DataSource = sc.dataTable }; GroupField grp = new GroupField("SupplierName"); rpt.groupHeader.GroupFields.Add(grp); rpt.lbSUP.DataBindings.Add("Text", null, "SupplierName"); rpt.lbPNM.DataBindings.Add("Text", null, "ProductName"); rpt.lbBVL.DataBindings.Add("Text", null, "BuyingValue", "{0:C2}"); rpt.lbSVL.DataBindings.Add("Text", null, "SellingValue", "{0:C2}"); rpt.lbQTY.DataBindings.Add("Text", null, "Quantity"); rpt.lbBCD.DataBindings.Add("Text", null, "BarCode"); dv.PrintingSystem = rpt.PrintingSystem; rpt.CreateDocument(true); }
private void btnSell_Click(object sender, EventArgs e) { if (lueCNM.EditValue == null) { XtraMessageBox.Show("Please select Customer!"); return; } if (grv.RowCount <= 0) { XtraMessageBox.Show("Please add some product to sell"); return; } wrSales.Sale s = new wrSales.Sale(); s.InvoiceNo = txtINV.Text; s.SaleDate = dtpSDT.DateTime; s.CustomerID = Convert.ToInt32(lueCNM.EditValue); s.Amount = Convert.ToDouble(txtAMT.EditValue); s.Discount = Convert.ToDouble(txtDSC.EditValue); s.Payment = Convert.ToDouble(txtPAM.EditValue); s.Balance = Convert.ToDouble(txtBAL.EditValue); sc = new wrSales.Server2Client(); sls = new wrSales.wsSales(); sc = sls.AddSale(s); if (sc.Message != null) { XtraMessageBox.Show(sc.Message); return; } wrCustomers.Server2Client scc = new wrCustomers.Server2Client(); wrCustomers.wsCustomers cus = new wrCustomers.wsCustomers(); wrCustomers.CustomerAccount ca = new wrCustomers.CustomerAccount(); ca.CustomerID = Convert.ToInt32(lueCNM.EditValue); ca.TransDate = s.SaleDate; ca.Description = s.InvoiceNo; if (s.Balance == 0) { ca.Debit = s.Payment; ca.Credit = s.Payment; } else { ca.Debit = s.Amount - s.Discount; ca.Credit = s.Payment; } ca.Balance = CustomerBalance + s.Balance; scc = cus.addTrans(ca); if (scc.Message != null) { XtraMessageBox.Show(scc.Message); return; } for (int i = 0; i <= grv.RowCount - 1; i++) { wrProducts.Server2Client spc = new wrProducts.Server2Client(); wrProducts.wsProducts prd = new wrProducts.wsProducts(); wrSales.SaleDetail sd = new wrSales.SaleDetail(); sd.InvoiceNo = txtINV.Text; sd.ProductID = Convert.ToInt32(grv.GetRowCellValue(i, colPID)); sd.Quantity = Convert.ToInt32(grv.GetRowCellValue(i, colQTY)); sd.BuyingValue = Convert.ToDouble(grv.GetRowCellValue(i, colBVL)); sd.SellingValue = Convert.ToDouble(grv.GetRowCellValue(i, colSVL)); sd.Amount = sd.Quantity * sd.SellingValue; sc = new wrSales.Server2Client(); sc = sls.AddSaleDetails(sd); spc = prd.updateQuantity(sd.ProductID, sd.Quantity, "-"); } if (XtraMessageBox.Show("Do you want to print receipt?", "Print Receipt", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { sc = new wrSales.Server2Client(); sls = new wrSales.wsSales(); sc = sls.getSoldProductsByInvoiceNo(txtINV.Text); rptCashMemo rpt = new rptCashMemo() { DataSource = sc.dataTable }; rpt.lblCNM.Text = cc.CustomerName; rpt.lblADR.Text = cc.Address; rpt.lblPHN.Text = cc.Phone; rpt.lblINV.Text = txtINV.Text; rpt.lblSDT.Text = dtpSDT.DateTime.ToShortDateString(); rpt.lblPNM.DataBindings.Add("Text", null, "ProductName"); rpt.lbSNO.DataBindings.Add("Text", null, "BarCode"); rpt.lblQTY.DataBindings.Add("Text", null, "Quantity"); rpt.lblPRC.DataBindings.Add("Text", null, "SellingValue", "{0:c}"); rpt.lblAMT.DataBindings.Add("Text", null, "Amount", "{0:c}"); if (s.Discount > 0) { rpt.xrLabel8.Visible = true; rpt.lblDSC.Text = "(-) " + s.Discount.ToString("c2"); } else { rpt.xrLabel8.Visible = false; rpt.lblDSC.Text = ""; } rpt.lblTTL.Text = (s.Amount - s.Discount).ToString("c2"); rpt.lblAMW.Text = "Rupees " + Utils.NumbersToWords(Convert.ToInt32(s.Amount - s.Discount)) + " only"; rpt.ShowPreviewDialog(); } grd.DataSource = null; dt = new DataTable(); InitDataTable(); InitInvoiceNo(); lueCAT.EditValue = null; luePNM.EditValue = null; lueCAT.Properties.DataSource = null; luePNM.Properties.DataSource = null; InitCategories(); InitProducts(); Reset(); }
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; }