private void lueINV_EditValueChanged(object sender, EventArgs e) { if (lueINV.EditValue == null) { return; } string INV = lueINV.EditValue.ToString(); wrSales.Customer c = new wrSales.Customer(); sls = new wrSales.wsSales(); c = sls.GetCustomerByInvoice(INV); lueCUS.EditValue = c.CustomerID; sc = new wrSales.Server2Client(); sls = new wrSales.wsSales(); sc = sls.getSalesByInvoice(INV); dtpSDT.DateTime = DateTime.Parse(sc.dataTable.Rows[0].ItemArray[0].ToString()); grd.DataSource = sc.dataTable; double TotalAmount = Convert.ToDouble(colAMT.SummaryText); txtAMT.Text = TotalAmount.ToString(); txtPAM.Text = TotalAmount.ToString(); }
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(); }
void InitInvoiceNo() { sc = new wrSales.Server2Client(); sls = new wrSales.wsSales(); sc = sls.GetSales(); lueINV.Properties.DataSource = sc.dataTable; lueINV.Properties.DisplayMember = "InvoiceNo"; lueINV.Properties.ValueMember = "InvoiceNo"; }
private void bInvoiceNo_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { frmSelect frm = new frmSelect(false); if (frm.ShowDialog() == DialogResult.OK) { wrSales.Server2Client sc = new wrSales.Server2Client(); wrSales.wsSales s = new wrSales.wsSales(); string dt = null; if (frm.RetVal == 0) { sc = s.getProfitLossByDate(frm.DateOn); dt = "Date " + frm.DateOn.ToShortDateString(); } else { sc = s.getProfitLossByDates(frm.DateFrom, frm.DateTo); dt = "Between " + frm.DateFrom.ToShortDateString() + " and " + frm.DateTo.ToShortDateString(); } rptPL rpt = new rptPL() { DataSource = sc.dataTable }; XRSummary gsv = new XRSummary(); XRSummary gbv = new XRSummary(); XRSummary gpf = new XRSummary(); rpt.lbDT.Text = dt; rpt.lbSDT.DataBindings.Add("Text", null, "SaleDate", "{0:dd-MM-yyyy}"); rpt.lbSVL.DataBindings.Add("Text", null, "TotalSellingValue", "{0:C2}"); rpt.lbBVL.DataBindings.Add("Text", null, "TotalBuyingValue", "{0:C2}"); rpt.lbPFT.DataBindings.Add("Text", null, "Profit", "{0:C2}"); rpt.lbGSV.DataBindings.Add("Text", null, "TotalSellingValue", "{0:C2}"); rpt.lbGBV.DataBindings.Add("Text", null, "TotalBuyingValue", "{0:C2}"); rpt.lbGPF.DataBindings.Add("Text", null, "Profit", "{0:C2}"); gsv.FormatString = "{0:C2}"; gbv.FormatString = "{0:C2}"; gpf.FormatString = "{0:C2}"; gsv.Running = SummaryRunning.Report; gbv.Running = SummaryRunning.Report; gpf.Running = SummaryRunning.Report; rpt.lbGSV.Summary = gsv; rpt.lbGBV.Summary = gbv; rpt.lbGPF.Summary = gpf; dv.PrintingSystem = rpt.PrintingSystem; rpt.CreateDocument(true); } }
private void btnOK_Click(object sender, EventArgs e) { int CID = Convert.ToInt32(lueCUS.EditValue); wrSales.Server2Client sc = new wrSales.Server2Client(); wrSales.wsSales s = new wrSales.wsSales(); rptCustomerSales rpt = new rptCustomerSales(); if (chkALL.Checked) { sc = s.SalesToCustomerByID(CID); rpt.DataSource = sc.dataTable; rpt.lbTTL.Text = "Product(s) sold to Customer"; } else { sc = s.SalesToCustomerByDates(CID, dtpFR.DateTime, dtpTO.DateTime); rpt.DataSource = sc.dataTable; rpt.lbTTL.Text = "Product(s) sold to Customer between " + dtpFR.DateTime.ToShortDateString() + " and " + dtpTO.DateTime.ToShortDateString(); } GroupField grp = new GroupField("SaleDate"); rpt.GroupHeader1.GroupFields.Add(grp); wrCustomers.wsCustomers cus = new wrCustomers.wsCustomers(); wrCustomers.Customer c = new wrCustomers.Customer(); c = cus.getCustomer(CID); rpt.lbCNM.Text = c.CustomerName; rpt.lbADR.Text = c.Address; rpt.lbPHN.Text = c.Phone; rpt.lbSDT.DataBindings.Add("Text", null, "SaleDate", "{0:dd-MM-yyyy}"); rpt.lbPNM.DataBindings.Add("Text", null, "ProductName"); rpt.lbSNO.DataBindings.Add("Text", null, "BarCode"); rpt.lbSVL.DataBindings.Add("Text", null, "SellingValue", "{0:C2}"); rpt.lbQTY.DataBindings.Add("Text", null, "Quantity"); rpt.lbAMT.DataBindings.Add("Text", null, "Amount", "{0:C2}"); dv.PrintingSystem = rpt.PrintingSystem; rpt.CreateDocument(true); popCustomer.HidePopup(); }
private void btnUpdate_Click(object sender, EventArgs e) { sc = new wrSales.Server2Client(); sls = new wrSales.wsSales(); wrSales.Sale ss = new wrSales.Sale(); wrSales.SaleDetail sd = new wrSales.SaleDetail(); ss.SaleDate = dtpSDT.DateTime; ss.InvoiceNo = lueINV.EditValue.ToString(); ss.Amount = Convert.ToDouble(txtAMT.EditValue); ss.Discount = Convert.ToDouble(txtDSC.EditValue); ss.Payment = Convert.ToDouble(txtPAM.EditValue); ss.Balance = Convert.ToDouble(txtBAL.EditValue); sc = sls.UpdateSales(ss); if (sc.Message != null) { XtraMessageBox.Show(sc.Message); return; } for (int i = 0; i <= grv.RowCount - 1; i++) { sd.SaleDetailID = Convert.ToInt32(grv.GetRowCellValue(i, colSID)); sd.SellingValue = Convert.ToDouble(grv.GetRowCellValue(i, colSVL)); sd.Amount = Convert.ToDouble(grv.GetRowCellValue(i, colAMT)); sc = sls.UpdateSaleDetail(sd); if (sc.Message != null) { XtraMessageBox.Show(sc.Message); return; } } XtraMessageBox.Show("Done!"); sc = sls.getSoldProductsByInvoiceNo(lueINV.EditValue.ToString()); XRSummary total = new XRSummary(); rptCashMemo rpc = new rptCashMemo() { DataSource = sc.dataTable }; rpc.lblCNM.DataBindings.Add("Text", null, "CustomerName"); rpc.lblADR.DataBindings.Add("Text", null, "Address"); rpc.lblPHN.DataBindings.Add("Text", null, "Phone"); rpc.lblINV.DataBindings.Add("Text", null, "InvoiceNo"); rpc.lblSDT.DataBindings.Add("Text", null, "SaleDate", "{0:dd-MM-yyyy}"); rpc.lblPNM.DataBindings.Add("Text", null, "ProductName"); rpc.lbSNO.DataBindings.Add("Text", null, "BarCode"); rpc.lblQTY.DataBindings.Add("Text", null, "Quantity"); rpc.lblPRC.DataBindings.Add("Text", null, "SellingValue", "{0:c}"); rpc.lblDSC.DataBindings.Add("Text", null, "Discount", "{0:C2}"); rpc.lblAMT.DataBindings.Add("Text", null, "Amount", "{0:c}"); rpc.lblTTL.DataBindings.Add("Text", null, "Amount", "{0:c}"); total.FormatString = "{0:C2}"; total.Running = SummaryRunning.Report; rpc.lblTTL.Summary = total; //rpt.lblTTL.Text = s.Amount.ToString("c2"); double dsc = 0; int amt = 0; for (int i = 0; i <= sc.dataTable.Rows.Count - 1; i++) { dsc += Convert.ToDouble(sc.dataTable.Rows[i].ItemArray[10]); amt += Convert.ToInt32(sc.dataTable.Rows[i].ItemArray[9]); } if (dsc <= 0) { rpc.xrLabel8.Visible = false; rpc.lblDSC.Visible = false; } rpc.lblAMW.Text = "Rupees " + Utils.NumbersToWords(Convert.ToInt32(amt)) + " only"; rpc.ShowPreviewDialog(); }
private void bSoldProducts_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { frmSelect frm = new frmSelect(); if (frm.ShowDialog() == DialogResult.OK) { wrSales.Server2Client sc; wrSales.wsSales s; rptSoldProducts rpt = new rptSoldProducts(); wrSettings.wrSettings stg = new wrSettings.wrSettings(); double SVC = 0; if (frm.RetVal == 0) { sc = new wrSales.Server2Client(); s = new wrSales.wsSales(); sc = s.getSoldProductsByDate(frm.DateOn); SVC = stg.GetServicingByDate(frm.DateOn); rptProductSold r = new rptProductSold() { DataSource = sc.dataTable }; //rpt.DataSource = sc.dataTable; //SELECT Sale.InvoiceNo, Product.ProductName, GROUP_CONCAT(Product.BarCode) BarCode, SaleDetail.SellingValue, Sum(SaleDetail.Quantity) AS SumOfQuantity, Sale.Amount, Sale.Discount, Sale.Payment, Sale.Balance r.lbTTL.Text = "Products sold On " + frm.DateOn.ToShortDateString(); XRSummary tam = new XRSummary(); XRSummary tdc = new XRSummary(); XRSummary tpm = new XRSummary(); XRSummary tbl = new XRSummary(); XRSummary gam = new XRSummary(); XRSummary gdc = new XRSummary(); XRSummary gpm = new XRSummary(); XRSummary gbl = new XRSummary(); //GroupField grp = new GroupField("SaleDate"); //GroupField cnm = new GroupField("CustomerName"); GroupField sdt = new GroupField("SaleDate"); GroupField inv = new GroupField("InvoiceNo"); //rpt.GroupHeader1.GroupFields.Add(grp); //rpt.GroupHeader2.GroupFields.Add(cnm); r.grpSDT.GroupFields.Add(sdt); r.grpSDT.GroupFields.Add(inv); //r.sbnINV.Band. r.lbINV.DataBindings.Add("Text", null, "InvoiceNo"); r.lbSDT.DataBindings.Add("Text", null, "SaleDate", "{0:dd-MM-yyyy}"); r.lbPNM.DataBindings.Add("Text", null, "ProductName"); r.lbBCD.DataBindings.Add("Text", null, "BarCode"); r.lbSVL.DataBindings.Add("Text", null, "SellingValue", "{0:C2}"); r.lbQTY.DataBindings.Add("Text", null, "SumOfQuantity"); r.lbAMT.DataBindings.Add("Text", null, "Amount", "{0:C2}"); r.lbDSC.DataBindings.Add("Text", null, "Discount", "{0:C2}"); r.lbPAM.DataBindings.Add("Text", null, "Payment", "{0:C2}"); r.lbBAL.DataBindings.Add("Text", null, "Balance", "{0:C2}"); r.lbTAM.DataBindings.Add("Text", null, "Amount", "{0:C2}"); r.lbTDC.DataBindings.Add("Text", null, "Discount", "{0:C2}"); r.lbTPM.DataBindings.Add("Text", null, "Payment", "{0:C2}"); r.lbTBL.DataBindings.Add("Text", null, "Balance", "{0:C2}"); r.lbGAM.DataBindings.Add("Text", null, "Amount", "{0:C2}"); r.lbGDC.DataBindings.Add("Text", null, "Discount", "{0:C2}"); r.lbGPM.DataBindings.Add("Text", null, "Payment", "{0:C2}"); r.lbGBL.DataBindings.Add("Text", null, "Balance", "{0:C2}"); tam.FormatString = "{0:C2}"; tdc.FormatString = "{0:C2}"; tpm.FormatString = "{0:C2}"; tbl.FormatString = "{0:C2}"; gam.FormatString = "{0:C2}"; gdc.FormatString = "{0:C2}"; gpm.FormatString = "{0:C2}"; gbl.FormatString = "{0:C2}"; tam.Running = SummaryRunning.Group; tdc.Running = SummaryRunning.Group; tpm.Running = SummaryRunning.Group; tbl.Running = SummaryRunning.Group; gam.Running = SummaryRunning.Report; gdc.Running = SummaryRunning.Report; gpm.Running = SummaryRunning.Report; gbl.Running = SummaryRunning.Report; r.lbTAM.Summary = tam; r.lbTDC.Summary = tdc; r.lbTPM.Summary = tpm; r.lbTBL.Summary = tbl; r.lbGAM.Summary = gam; r.lbGDC.Summary = gdc; r.lbGPM.Summary = gpm; r.lbGBL.Summary = gbl; r.lbSVC.Text = SVC.ToString("C2"); dv.PrintingSystem = r.PrintingSystem; r.CreateDocument(true); } else if (frm.RetVal == 1) { sc = new wrSales.Server2Client(); s = new wrSales.wsSales(); sc = s.getSoldProductsByDates(frm.DateFrom, frm.DateTo); SVC = stg.GetServicingByDates(frm.DateFrom, frm.DateTo); //rpt.DataSource = sc.dataTable; //rpt.lbTTL.Text = "Products sold Between " + frm.DateFrom.ToShortDateString() + " and " + frm.DateTo.ToShortDateString(); //XRSummary stt = new XRSummary(); //XRSummary gtt = new XRSummary(); //GroupField grp = new GroupField("SaleDate"); //rpt.GroupHeader1.GroupFields.Add(grp); //rpt.lbSDT.DataBindings.Add("Text", null, "SaleDate", "{0:dd-MM-yyyy}"); //rpt.lbPNM.DataBindings.Add("Text", null, "ProductName"); //rpt.lbPID.DataBindings.Add("Text", null, "BarCode"); //rpt.lbSVL.DataBindings.Add("Text", null, "SellingValue", "{0:C2}"); //rpt.lbQTY.DataBindings.Add("Text", null, "Quantity"); //rpt.lbAMT.DataBindings.Add("Text", null, "Amount", "{0:C2}"); //rpt.lbSTT.DataBindings.Add("Text", null, "Amount", "{0:C2}"); //rpt.lbGTT.DataBindings.Add("Text", null, "Amount", "{0:C2}"); //stt.FormatString = "{0:C2}"; //gtt.FormatString = "{0:C2}"; //stt.Running = SummaryRunning.Group; //gtt.Running = SummaryRunning.Report; //rpt.lbSTT.Summary = stt; //rpt.lbGTT.Summary = gtt; //dv.PrintingSystem = rpt.PrintingSystem; //rpt.CreateDocument(true); rptProductSold r = new rptProductSold() { DataSource = sc.dataTable }; //rpt.DataSource = sc.dataTable; //SELECT Sale.InvoiceNo, Product.ProductName, GROUP_CONCAT(Product.BarCode) BarCode, SaleDetail.SellingValue, Sum(SaleDetail.Quantity) AS SumOfQuantity, Sale.Amount, Sale.Discount, Sale.Payment, Sale.Balance r.lbTTL.Text = "Products sold On " + frm.DateOn.ToShortDateString(); XRSummary tam = new XRSummary(); XRSummary tdc = new XRSummary(); XRSummary tpm = new XRSummary(); XRSummary tbl = new XRSummary(); XRSummary gam = new XRSummary(); XRSummary gdc = new XRSummary(); XRSummary gpm = new XRSummary(); XRSummary gbl = new XRSummary(); //GroupField grp = new GroupField("SaleDate"); //GroupField cnm = new GroupField("CustomerName"); GroupField sdt = new GroupField("SaleDate"); GroupField inv = new GroupField("InvoiceNo"); //rpt.GroupHeader1.GroupFields.Add(grp); //rpt.GroupHeader2.GroupFields.Add(cnm); r.grpSDT.GroupFields.Add(sdt); r.grpSDT.GroupFields.Add(inv); //r.sbnINV.Band. r.lbINV.DataBindings.Add("Text", null, "InvoiceNo"); r.lbSDT.DataBindings.Add("Text", null, "SaleDate", "{0:dd-MM-yyyy}"); r.lbPNM.DataBindings.Add("Text", null, "ProductName"); r.lbBCD.DataBindings.Add("Text", null, "BarCode"); r.lbSVL.DataBindings.Add("Text", null, "SellingValue", "{0:C2}"); r.lbQTY.DataBindings.Add("Text", null, "SumOfQuantity"); r.lbAMT.DataBindings.Add("Text", null, "Amount", "{0:C2}"); r.lbDSC.DataBindings.Add("Text", null, "Discount", "{0:C2}"); r.lbPAM.DataBindings.Add("Text", null, "Payment", "{0:C2}"); r.lbBAL.DataBindings.Add("Text", null, "Balance", "{0:C2}"); r.lbTAM.DataBindings.Add("Text", null, "Amount", "{0:C2}"); r.lbTDC.DataBindings.Add("Text", null, "Discount", "{0:C2}"); r.lbTPM.DataBindings.Add("Text", null, "Payment", "{0:C2}"); r.lbTBL.DataBindings.Add("Text", null, "Balance", "{0:C2}"); r.lbGAM.DataBindings.Add("Text", null, "Amount", "{0:C2}"); r.lbGDC.DataBindings.Add("Text", null, "Discount", "{0:C2}"); r.lbGPM.DataBindings.Add("Text", null, "Payment", "{0:C2}"); r.lbGBL.DataBindings.Add("Text", null, "Balance", "{0:C2}"); tam.FormatString = "{0:C2}"; tdc.FormatString = "{0:C2}"; tpm.FormatString = "{0:C2}"; tbl.FormatString = "{0:C2}"; gam.FormatString = "{0:C2}"; gdc.FormatString = "{0:C2}"; gpm.FormatString = "{0:C2}"; gbl.FormatString = "{0:C2}"; tam.Running = SummaryRunning.Group; tdc.Running = SummaryRunning.Group; tpm.Running = SummaryRunning.Group; tbl.Running = SummaryRunning.Group; gam.Running = SummaryRunning.Report; gdc.Running = SummaryRunning.Report; gpm.Running = SummaryRunning.Report; gbl.Running = SummaryRunning.Report; r.lbTAM.Summary = tam; r.lbTDC.Summary = tdc; r.lbTPM.Summary = tpm; r.lbTBL.Summary = tbl; r.lbGAM.Summary = gam; r.lbGDC.Summary = gdc; r.lbGPM.Summary = gpm; r.lbGBL.Summary = gbl; r.lbSVC.Text = SVC.ToString("C2"); dv.PrintingSystem = r.PrintingSystem; r.CreateDocument(true); } else { sc = new wrSales.Server2Client(); s = new wrSales.wsSales(); //sc = s.getSoldByInvoice(frm.InvoiceNo); sc = s.getSoldProductsByInvoiceNo(frm.InvoiceNo); XRSummary total = new XRSummary(); rptCashMemo rpc = new rptCashMemo() { DataSource = sc.dataTable }; rpc.lblCNM.DataBindings.Add("Text", null, "CustomerName"); rpc.lblADR.DataBindings.Add("Text", null, "Address"); rpc.lblPHN.DataBindings.Add("Text", null, "Phone"); rpc.lblINV.DataBindings.Add("Text", null, "InvoiceNo"); rpc.lblSDT.DataBindings.Add("Text", null, "SaleDate", "{0:dd-MM-yyyy}"); rpc.lblPNM.DataBindings.Add("Text", null, "ProductName"); rpc.lbSNO.DataBindings.Add("Text", null, "BarCode"); rpc.lblQTY.DataBindings.Add("Text", null, "Quantity"); rpc.lblPRC.DataBindings.Add("Text", null, "SellingValue", "{0:c}"); rpc.lblDSC.DataBindings.Add("Text", null, "Discount", "{0:C2}"); rpc.lblAMT.DataBindings.Add("Text", null, "Amount", "{0:c}"); rpc.lblTTL.DataBindings.Add("Text", null, "Amount", "{0:c}"); total.FormatString = "{0:C2}"; total.Running = SummaryRunning.Report; rpc.lblTTL.Summary = total; //rpt.lblTTL.Text = s.Amount.ToString("c2"); double dsc = 0; int amt = 0; for (int i = 0; i <= sc.dataTable.Rows.Count - 1; i++) { dsc += Convert.ToDouble(sc.dataTable.Rows[i].ItemArray[10]); amt += Convert.ToInt32(sc.dataTable.Rows[i].ItemArray[9]); } if (dsc <= 0) { rpc.xrLabel8.Visible = false; rpc.lblDSC.Visible = false; } rpc.lblAMW.Text = "Rupees " + Utils.NumbersToWords(Convert.ToInt32(amt)) + " only"; dv.PrintingSystem = rpc.PrintingSystem; rpc.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(); }