示例#1
0
        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();
        }
示例#2
0
        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;
        }