public void LoadAll()
        {
            string sql = "SELECT * FROM Sold_Product";

            this.dt    = DataAccess.GetDataTable(sql);
            this.count = dt.Rows.Count;
            this.arr   = new SoldProductcs[this.count];

            for (int i = 0; i < this.count; i++)
            {
                SoldProductcs p = new SoldProductcs();
                p.BranchID              = Convert.ToInt32(dt.Rows[i]["Branch_ID"]);
                p.ProductId             = Convert.ToInt32(dt.Rows[i]["PID"]);
                p.Pname                 = dt.Rows[i]["PName"].ToString();
                p.ProductSalesUnitPrice = Convert.ToInt32(dt.Rows[i]["P_Sales_Unit_Price"]);
                p.Ptype                 = dt.Rows[i]["P_Type"].ToString();
                p.ProdducExpDate        = dt.Rows[i]["P_EXP_Date"].ToString();
                p.MfgDate               = dt.Rows[i]["P_MFG_Date"].ToString();

                p.Quantity   = Convert.ToInt32(dt.Rows[i]["P_Quantity"]);
                p.TotalPrice = Convert.ToInt32(dt.Rows[i]["P_Total_Price"]);
                p.CashMemoNo = Convert.ToInt32(dt.Rows[i]["Cash_Memo_NO"]);
                p.SoldDate   = dt.Rows[i]["Sold_Date"].ToString();
                this.arr[i]  = p;
            }
        }
        public bool searchbybid(int temp2)
        {
            string sql = "select  *  from Sold_Product where Branch_ID=" + temp2;

            this.dt    = DataAccess.GetDataTable(sql);
            this.count = dt.Rows.Count;
            this.arr   = new SoldProductcs[this.count];
            if (this.count > 0)
            {
                for (int i = 0; i < this.count; i++)
                {
                    SoldProductcs p = new SoldProductcs();
                    p.BranchID              = Convert.ToInt32(dt.Rows[i]["Branch_ID"]);
                    p.ProductId             = Convert.ToInt32(dt.Rows[i]["PID"]);
                    p.Pname                 = dt.Rows[i]["PName"].ToString();
                    p.ProductSalesUnitPrice = Convert.ToInt32(dt.Rows[i]["P_Sales_Unit_Price"]);
                    p.Ptype                 = dt.Rows[i]["P_Type"].ToString();
                    p.ProdducExpDate        = dt.Rows[i]["P_EXP_Date"].ToString();
                    p.MfgDate               = dt.Rows[i]["P_MFG_Date"].ToString();

                    p.Quantity   = Convert.ToInt32(dt.Rows[i]["P_Quantity"]);
                    p.TotalPrice = Convert.ToInt32(dt.Rows[i]["P_Total_Price"]);
                    p.CashMemoNo = Convert.ToInt32(dt.Rows[i]["Cash_Memo_NO"]);
                    p.SoldDate   = dt.Rows[i]["Sold_Date"].ToString();
                    this.arr[i]  = p;
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 3
0
        private void button2_Click(object sender, EventArgs e)
        {
            CashMemo cm = new CashMemo();

            cm.CustomerName  = textBoxCname.Text;
            cm.CustomerPhone = Convert.ToInt32(textBoxcPhone.Text);
            cm.Date          = DateTime.Today.ToShortDateString();
            cm.newentry();
            cm.CashMemoNO = cm.returnid();
            for (int i = 0; i <= Rowcount - 1; i++)
            {
                SoldProductcs sp = new SoldProductcs();
                sp.BranchID  = LoginForm.BRCHID;
                sp.ProductId = Convert.ToInt32(dataGridView1.Rows[i].Cells[0].Value);
                Branch_Product bp1 = new Branch_Product();
                bp1.Productid = sp.ProductId;
                bp1.BranchId  = sp.BranchID;
                bp1.ptype2();
                sp.Pname = bp1.ProductName;
                sp.ProductSalesUnitPrice = bp1.SalesPrice;
                sp.Ptype          = bp1.ProductType;
                sp.ProdducExpDate = bp1.ProductExpdate;
                sp.MfgDate        = bp1.ProductMfgdate;
                sp.Quantity       = Convert.ToInt32(dataGridView1.Rows[i].Cells[3].Value);
                bp1.Quantity     -= sp.Quantity;
                bp1.proupdate2(bp1.Quantity);
                sp.TotalPrice = Convert.ToInt32(dataGridView1.Rows[i].Cells[4].Value);
                sp.CashMemoNo = cm.CashMemoNO;
                sp.SoldDate   = DateTime.Today.ToShortDateString();
                sp.newentry();
            }
        }