private void btnSave_Click(object sender, EventArgs e) { if (dxValidationProvider1.Validate()) { sc = new wrCustomers.Server2Client(); wrCustomers.CustomerAccount c = new wrCustomers.CustomerAccount(); string Remarks = txtRMKS.Text == "" ? "Credit Payment" : txtRMKS.Text; c.CustomerID = Convert.ToInt32(lueCNM.EditValue); c.TransDate = txtPDT.DateTime; c.Description = Remarks; c.Debit = 0; c.Credit = Convert.ToDouble(txtAMNT.Text); c.Balance = Convert.ToDouble(txtNBAL.Text); cus = new wrCustomers.wsCustomers(); sc = cus.addTrans(c); if (sc.Message == null) { XtraMessageBox.Show("Payment done successfully!"); lueCNM.EditValue = null; txtCBAL.Text = "0"; txtAMNT.Text = "0"; txtNBAL.Text = "0"; txtRMKS.Text = ""; } else { XtraMessageBox.Show(sc.Message); } } }
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(); }