Ejemplo n.º 1
0
        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();
        }
Ejemplo n.º 2
0
        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();
        }
Ejemplo n.º 3
0
        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();
        }