protected void ImageButtonSearch_Click(object sender, ImageClickEventArgs e)
        {
            GridViewSupplierProducts.DataSource = Suppliers_Products.Get_Supplier_Products(TextBoxSearch.Text);
            GridViewSupplierProducts.DataBind();

            PanelSupplierProducts.Visible = true;
        }
        private void BindSuppliersGrid()
        {
            string P_name = ViewState["P_name"].ToString();
            double Price  = Convert.ToDouble(ViewState["Price"]);
            string Mark   = ViewState["Mark"].ToString();
            double Inch   = Convert.ToDouble(ViewState["Inch"]);
            string Style  = ViewState["Style"].ToString();

            GridViewProductSuppliers.DataSource = Suppliers_Products.Get_Product_Suppliers_For_Update_Info(P_name, Price, Mark, Style, Inch);
            GridViewProductSuppliers.DataBind();
        }
Exemple #3
0
        protected void BtnExecute_Click(object sender, EventArgs e)
        {
            int    row_index = ((GridViewRow)((Button)sender).NamingContainer).RowIndex;
            string strDay    = ((TextBox)GridViewProductSuppliers.Rows[row_index].FindControl("txtReturnDay")).Text;
            string strMonth  = ((TextBox)GridViewProductSuppliers.Rows[row_index].FindControl("txtReturnMonth")).Text;
            string strYear   = ((TextBox)GridViewProductSuppliers.Rows[row_index].FindControl("txtReturnYear")).Text;
            string amount    = ((TextBox)GridViewProductSuppliers.Rows[row_index].FindControl("txtReturnedAmount")).Text;

            if (string.IsNullOrEmpty(amount))
            {
                lblMsg.Text      = "يجب تحديد الكميه المرتجعه";
                lblMsg.ForeColor = System.Drawing.Color.Red;
            }
            else if (string.IsNullOrEmpty(strDay) || string.IsNullOrEmpty(strMonth) || string.IsNullOrEmpty(strYear))
            {
                lblMsg.Text      = "يجب تحديد تاريخ المرتجع";
                lblMsg.ForeColor = System.Drawing.Color.Red;
            }
            else
            {
                Suppliers_Products SP = new Suppliers_Products();
                SP.Supplier_Name     = GridViewProductSuppliers.Rows[row_index].Cells[0].Text;
                SP.Purchase_Date     = Convert.ToDateTime(GridViewProductSuppliers.Rows[row_index].Cells[1].Text);
                SP.Price             = Convert.ToInt32(GridViewProductSuppliers.Rows[row_index].Cells[2].Text);
                SP.Returned_Products = Convert.ToInt32(amount);
                int Day   = Convert.ToInt32(strDay);
                int Month = Convert.ToInt32(strMonth);
                int Year  = Convert.ToInt32(strYear);
                SP.Return_Date = new DateTime(Year, Month, Day, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second);
                string  m       = "";
                Product product = new Product();
                product.P_name = GridViewProducts.Rows[row_index].Cells[0].Text;
                product.Mark   = GridViewProducts.Rows[row_index].Cells[1].Text;
                product.Inch   = Convert.ToDouble(GridViewProducts.Rows[row_index].Cells[2].Text);
                product.Style  = GridViewProducts.Rows[row_index].Cells[3].Text;
                if (!SP.Return_Products_To_Suuplier(out m, product.P_name, product.Mark, product.Style, product.Inch))
                {
                    lblMsg.Text      = m;
                    lblMsg.ForeColor = System.Drawing.Color.Red;
                }
                else
                {
                    lblMsg.Text      = "تم بنجاح";
                    lblMsg.ForeColor = System.Drawing.Color.Green;
                }
            }
        }
        protected void GridViewProducts_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            PanelDetailedResult.Visible = true;
            PanelSuppliers.Visible      = false;
            PanelProductDetails.Visible = false;
            PanelInitailResult.Visible  = false;
            // Get the Selected product info
            int     row_index = ((GridViewRow)((LinkButton)e.CommandSource).NamingContainer).RowIndex;
            Product product   = new Product();

            product.P_name         = GridViewProducts.Rows[row_index].Cells[0].Text;
            product.Mark           = GridViewProducts.Rows[row_index].Cells[1].Text;
            product.Inch           = Convert.ToDouble(GridViewProducts.Rows[row_index].Cells[2].Text);
            product.Style          = GridViewProducts.Rows[row_index].Cells[3].Text;
            product.Purchase_Price = Convert.ToDouble(GridViewProducts.Rows[row_index].Cells[4].Text);
            product                  = product.Get_Product_info();
            lblP_name.Text           = product.P_name;
            lblMark.Text             = product.Mark;
            lblStyle.Text            = product.Style;
            lblInch.Text             = product.Inch.ToString();
            lblPurchase_Price.Text   = product.Purchase_Price.ToString();
            lblRegSellPrice.Text     = product.Regulare_Price.ToString();
            lblSpecialSellPrice.Text = product.Special_Price.ToString();
            lblAmount.Text           = product.Amount.ToString();
            TxtDesc.Text             = product.Description;
            if (RadioButtonListCategories.SelectedValue == "Tol")
            {
                PanelTol.Visible    = true;
                PanelMotors.Visible = true;
            }
            else if (RadioButtonListCategories.SelectedValue == "Motors")
            {
                PanelTol.Visible    = false;
                PanelMotors.Visible = true;
            }
            else
            {
                PanelTol.Visible    = false;
                PanelMotors.Visible = false;
            }
            //get the product suppliers with the product key (name- price- mark- style- inch)
            GridViewSuppliers.DataSource = Suppliers_Products.Get_Specific_Product_Suppliers(product.P_name, product.Purchase_Price);
            GridViewSuppliers.DataBind();
        }
        protected void GridViewProductSuppliers_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            #region Edit_Row_Mode
            if (e.CommandName == "Edit_Row")
            {
                int      row_index     = ((GridViewRow)((ImageButton)e.CommandSource).NamingContainer).RowIndex;
                string   S_name        = ((Label)GridViewProductSuppliers.Rows[row_index].FindControl("lblsupplier")).Text;
                DateTime Purchase_Date = Convert.ToDateTime(((Label)GridViewProductSuppliers.Rows[row_index].FindControl("lblPurchase_Date")).Text);
                ViewState["OldS_name"]             = S_name;
                ViewState["OldPurchase_Date"]      = Purchase_Date;
                GridViewProductSuppliers.EditIndex = row_index;
                BindSuppliersGrid();
                SetFocus(ImageButtonBackToAddProducts);
            }
            #endregion
            #region Cancel_Edit_Mode
            else if (e.CommandName == "Cancel_Update")
            {
                GridViewProductSuppliers.EditIndex = -1;
                BindSuppliersGrid();
            }
            #endregion
            #region Confirm_Update
            else if (e.CommandName == "Confirm_Update")
            {
                int    row_index      = ((GridViewRow)((ImageButton)e.CommandSource).NamingContainer).RowIndex;
                string P_name         = ViewState["P_name"].ToString();
                double Purchase_Price = Convert.ToDouble(ViewState["Price"]);
                string Mark           = ViewState["Mark"].ToString();
                double Inch           = Convert.ToDouble(ViewState["Inch"]);
                string Style          = ViewState["Style"].ToString();

                string S_name = ((TextBox)GridViewProductSuppliers.Rows[row_index].FindControl("txtsupplier")).Text;

                int      PucrhaseDay   = Convert.ToInt32(((TextBox)GridViewProductSuppliers.Rows[row_index].FindControl("txtPurchaseDay")).Text);
                int      PucrhaseMonth = Convert.ToInt32(((TextBox)GridViewProductSuppliers.Rows[row_index].FindControl("txtPurchaseMonth")).Text);
                int      PucrhaseYear  = Convert.ToInt32(((TextBox)GridViewProductSuppliers.Rows[row_index].FindControl("txtPurchaseYear")).Text);
                DateTime Purchase_Date = new DateTime(PucrhaseYear, PucrhaseMonth, PucrhaseDay);

                Suppliers_Products sp = new Suppliers_Products();
                sp.Supplier_Name     = ViewState["OldS_name"].ToString();
                sp.Purchase_Date     = Convert.ToDateTime(ViewState["OldPurchase_Date"]);
                sp.Amount            = Convert.ToDecimal(((TextBox)GridViewProductSuppliers.Rows[row_index].FindControl("txtSupplierAmount")).Text);
                sp.Returned_Products = Convert.ToInt32(((TextBox)GridViewProductSuppliers.Rows[row_index].FindControl("txtReturnedAmount")).Text);

                int ReturnYear;
                if (int.TryParse(((TextBox)GridViewProductSuppliers.Rows[row_index].FindControl("txtReturnYear")).Text, out ReturnYear))
                {
                    int ReturnDay   = Convert.ToInt32(((TextBox)GridViewProductSuppliers.Rows[row_index].FindControl("txtReturnDay")).Text);
                    int ReturnMonth = Convert.ToInt32(((TextBox)GridViewProductSuppliers.Rows[row_index].FindControl("txtReturnMonth")).Text);

                    sp.Return_Date = new DateTime(ReturnYear, ReturnMonth, ReturnDay);
                }
                else
                {
                    sp.Return_Date = new DateTime(0001, 01, 01);
                }

                string m = "";
                if (!sp.Update_Supplier_Products(out m, P_name, Mark, Style, Inch, Purchase_Price, S_name, Purchase_Date))
                {
                    lblFinishMsg.Text      = m;
                    lblFinishMsg.ForeColor = System.Drawing.Color.Red;
                }
                else
                {
                    lblFinishMsg.Text                  = "تم بنجاح";
                    lblFinishMsg.ForeColor             = System.Drawing.Color.Green;
                    GridViewProductSuppliers.EditIndex = -1;
                    BindSuppliersGrid();
                }
            }
            #endregion
            #region Delete_item
            else if (e.CommandName == "Delete_Row")
            {
                int      row_index      = ((GridViewRow)((ImageButton)e.CommandSource).NamingContainer).RowIndex;
                string   S_name         = ((Label)GridViewProductSuppliers.Rows[row_index].FindControl("lblsupplier")).Text;
                DateTime Purchase_Date  = Convert.ToDateTime(((Label)GridViewProductSuppliers.Rows[row_index].FindControl("lblPurchase_Date")).Text);
                string   P_name         = ViewState["P_name"].ToString();
                double   Purchase_Price = Convert.ToDouble(ViewState["Price"]);
                string   Mark           = ViewState["Mark"].ToString();
                double   Inch           = Convert.ToDouble(ViewState["Inch"]);
                string   Style          = ViewState["Style"].ToString();

                Suppliers_Products sp = new Suppliers_Products();
                sp.Supplier_Name = S_name;
                sp.Purchase_Date = Purchase_Date;
                string m = "";
                if (!sp.Delete_Supplier_Products_Item(out m, P_name, Mark, Style, Inch, Purchase_Price))
                {
                    lblFinishMsg.Text      = m;
                    lblFinishMsg.ForeColor = System.Drawing.Color.Red;
                }
                else
                {
                    lblFinishMsg.Text      = "تم بنجاح";
                    lblFinishMsg.ForeColor = System.Drawing.Color.Green;
                    BindSuppliersGrid();
                }
            }
            #endregion
        }