Beispiel #1
0
        protected void txtProductName_OnTextChanged(object sender, EventArgs e)
        {
            objProductBiz = new ProductBiz();
            objProduct    = new Product();
            objProduct    = objProductBiz.AddProductForPurchase(txtProductName.Text.Trim());

            txtProductCode.Text  = objProduct.ProductId.ToString();
            txtCurrentStock.Text = objProduct.ProductStock.ToString();
            txtSalePrice.Text    = objProduct.ProductSellPrice.ToString("N2");

            txtPurchaseQuantity.Attributes.Add("onfocus", "this.select()");
            txtPurchaseQuantity.Focus();
        }
Beispiel #2
0
        protected void gvSellProduct_OnRowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "RowDelete")
            {
                GridViewRow gvr      = (GridViewRow)((Control)e.CommandSource).NamingContainer;
                int         rowIndex = gvr.RowIndex;
                int         id       = Convert.ToInt32(((Label)gvr.FindControl("ProductCode")).Text);
                DataTable   dt       = (DataTable)Session["SaleDetail"];

                foreach (DataRow dataRow in dt.Rows)
                {
                    if (Convert.ToInt32(dataRow["ProductCode"]) == id)
                    {
                        dataRow.Delete();
                        break;
                    }
                }
                Session["SaleDetail"]    = dt;
                gvSellProduct.DataSource = dt;
                gvSellProduct.DataBind();

                txtProductCode.Attributes.Add("onfocus", "this.select()");
                txtProductCode.Focus();
            }

            if (e.CommandName == "RowEdit")
            {
                GridViewRow gvr      = (GridViewRow)((Control)e.CommandSource).NamingContainer;
                int         rowIndex = gvr.RowIndex;
                int         id       = Convert.ToInt32(((Label)gvr.FindControl("ProductCode")).Text);
                DataTable   dt       = (DataTable)Session["SaleDetail"];

                foreach (DataRow dataRow in dt.Rows)
                {
                    if (Convert.ToInt32(dataRow["ProductCode"]) == id)
                    {
                        objProductBiz = new ProductBiz();
                        objProduct    = new Product();
                        objProduct    = objProductBiz.AddProductForPurchase(id.ToString());

                        txtProductStock.Text        = objProduct.ProductStock.ToString();
                        txtProductCode.Text         = dataRow["ProductCode"].ToString();
                        txtProductName.Text         = dataRow["ProductName"].ToString();
                        txtProductPricePerUnit.Text = dataRow["SalePrice"].ToString();
                        txtVat.Text = dataRow["ProductVat"].ToString();
                        txtQty.Text = dataRow["SaleQuantity"].ToString();
                        txtTotalPriceOfWholeQty.Text     = dataRow["TotalAmount"].ToString();
                        txtTotalPriceOfWholeProduct.Text = (Convert.ToDecimal(dataRow["TotalAmount"]) + Convert.ToDecimal(dataRow["ProductVat"])).ToString();
                        break;
                    }
                }
                txtQty.Attributes.Add("onfocus", "this.select()");
                txtQty.Focus();
            }

            if (gvSellProduct.Rows.Count == 0)
            {
                txtProductCode.Attributes.Add("onfocus", "this.select()");
                txtProductCode.Focus();

                txtToBePaid.Text      = string.Empty;
                pnlSaleDetail.Visible = false;
            }
        }
Beispiel #3
0
        protected void gvDisplayPurchaseDetail_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "RowDelete")
            {
                GridViewRow gvr      = (GridViewRow)((Control)e.CommandSource).NamingContainer;
                int         rowIndex = gvr.RowIndex;
                int         id       = Convert.ToInt32(((Label)gvr.FindControl("ProductCode")).Text);
                DataTable   dt       = (DataTable)Session["PurchaseDetail"];

                foreach (DataRow dataRow in dt.Rows)
                {
                    if (Convert.ToInt32(dataRow["ProductCode"]) == id)
                    {
                        dataRow.Delete();
                        break;
                    }
                }
                Session["PurchaseDetail"]          = dt;
                gvDisplayPurchaseDetail.DataSource = dt;
                gvDisplayPurchaseDetail.DataBind();

                AmountCalculation();

                txtProductCode.Attributes.Add("onfocus", "this.select()");
                txtProductCode.Focus();
            }

            if (e.CommandName == "RowEdit")
            {
                GridViewRow gvr      = (GridViewRow)((Control)e.CommandSource).NamingContainer;
                int         rowIndex = gvr.RowIndex;
                int         id       = Convert.ToInt32(((Label)gvr.FindControl("ProductCode")).Text);
                DataTable   dt       = (DataTable)Session["PurchaseDetail"];

                foreach (DataRow dataRow in dt.Rows)
                {
                    if (Convert.ToInt32(dataRow["ProductCode"]) == id)
                    {
                        objProductBiz = new ProductBiz();
                        objProduct    = new Product();
                        objProduct    = objProductBiz.AddProductForPurchase(id.ToString());

                        txtCurrentStock.Text     = objProduct.ProductStock.ToString();
                        txtProductCode.Text      = dataRow["ProductCode"].ToString();
                        txtProductName.Text      = dataRow["ProductName"].ToString();
                        txtPurchasePrice.Text    = dataRow["PurchasePrice"].ToString();
                        txtPurchaseQuantity.Text = dataRow["PurchaseQuantity"].ToString();
                        txtSalePrice.Text        = dataRow["SalePrice"].ToString();
                        txtProductTotal.Text     = dataRow["TotalAmount"].ToString();
                        break;
                    }
                }
            }

            if (gvDisplayPurchaseDetail.Rows.Count == 0)
            {
                txtProductCode.Attributes.Add("onfocus", "this.select()");
                txtProductCode.Focus();

                txtTotalPurchaseAmount.Text             = string.Empty;
                pnlAddPurchaseDetailstoGridView.Visible = false;
            }
        }