예제 #1
0
    protected void gvProduct_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "DeleteRecord")
        {
            if (e.CommandArgument != null)
            {
                ProductBAL balProduct = new ProductBAL();
                ProductENT entProduct = new ProductENT();

                #region Delete image from folder
                entProduct = balProduct.SelectByPK(Convert.ToInt32(e.CommandArgument.ToString()));
                FileInfo path = new FileInfo(Server.MapPath(entProduct.ProductImage.Value.ToString()));
                path.Delete();
                #endregion Delete image from folder

                if (balProduct.Delete(Convert.ToInt32(e.CommandArgument.ToString().Trim())))
                {
                    FillProductGridView();
                }
                else
                {
                    lblMessage.Text    = balProduct.Message;
                    divMessage.Visible = true;
                }
            }
        }
    }
예제 #2
0
 public int UpdateProduct(ProductBAL B)
 {
     try
     {
         using (C.Con)
         {
             MySqlCommand cmd = new MySqlCommand("UpdateProduct", C.Con)
             {
                 CommandType = CommandType.StoredProcedure
             };
             cmd.Parameters.Add(new MySqlParameter("P_ID", B.Product_ID));
             cmd.Parameters.Add(new MySqlParameter("P_Name", B.Product_Name));
             cmd.Parameters.Add(new MySqlParameter("B_ID", B.Brand_ID));
             cmd.Parameters.Add(new MySqlParameter("B_Rate", B.Product_Cost));
             cmd.Parameters.Add(new MySqlParameter("S_Rate", B.Selling_Rate));
             cmd.Parameters.Add(new MySqlParameter("Description", B.Description));
             cmd.Connection.Open();
             int Result = cmd.ExecuteNonQuery();
             C.Con.Close();
             return(Result);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         throw;
     }
 }
    private void FillProductDetails(Int32 ProductID)
    {
        ProductENT entProduct = new ProductENT();
        ProductBAL balProduct = new ProductBAL();

        entProduct = balProduct.SelectByPK(ProductID);

        if (!entProduct.Equals(null))
        {
            imgProduct.ImageUrl = entProduct.ProductImage.Value.ToString();
            lblProductName.Text = entProduct.ProductName.Value.ToString();
            lblPrice.Text       = entProduct.Price.Value.ToString();
            lblDescription.Text = entProduct.Description.Value.ToString();

            if (Request.QueryString["CategoryName"] == "T-shirt")
            {
                divTshirt.Visible = true;
            }

            else if (Request.QueryString["CategoryName"] == "Calendar")
            {
                divCalendar.Visible = true;
            }

            else if (Request.QueryString["CategoryName"] == "Canvas")
            {
                divCanvas.Visible = true;
            }
        }
    }
예제 #4
0
    protected void LinkButtonupdate_click(object sender, System.EventArgs e)
    {
        CSLOrderingARCBAL.LinqToSqlDataContext db = null;
        try
        {
            pnlGradeDetails.Visible = true;
            pnlGradeList.Visible    = false;
            litAction.Text          = "You choose to <b>EDIT GRADE MAPPING</b>";
            LinkButton lbctg = sender as LinkButton;
            if (lbctg != null)
            {
                GridViewRow gvr  = (GridViewRow)lbctg.NamingContainer;
                Label       lbl1 = gvr.FindControl("lblProductGradeID") as Label;
                ViewState["ProductGradeID"] = lbl1.Text;
            }

            db = new LinqToSqlDataContext();
            var usrDtls = ProductBAL.GetProductGradeById(Convert.ToInt32(ViewState["ProductGradeID"].ToString()));


            if (usrDtls != null)
            {
                txtProductCode.Text    = usrDtls.ProductCode;
                ddlGrade.SelectedValue = usrDtls.Grade.ToString();
            }

            db.Dispose();
        }
        catch (Exception objException)
        {
            db = new CSLOrderingARCBAL.LinqToSqlDataContext();
            db.USP_SaveErrorDetails(Request.Url.ToString(), "LinkButtonupdate_click", Convert.ToString(objException.Message), Convert.ToString(objException.InnerException), Convert.ToString(objException.StackTrace), "", HttpContext.Current.Request.UserHostAddress, false, Convert.ToString(HttpContext.Current.Session[enumSessions.User_Id.ToString()]));
            db.Dispose();
        }
    }
예제 #5
0
        public void Get()
        {
            ProductBAL obj = new ProductBAL();
            Product    p   = obj.Get(2);

            Assert.IsNotNull(p);
        }
    private void FillControls(SqlInt32 ProductID)
    {
        ProductBAL balProduct = new ProductBAL();
        ProductENT entProduct = new ProductENT();

        entProduct = balProduct.SelectByPK(ProductID);

        if (!entProduct.CategoryID.IsNull)
        {
            ddlCategoryID.SelectedValue = entProduct.CategoryID.Value.ToString();
        }

        if (!entProduct.ProductName.IsNull)
        {
            txtProductName.Text = entProduct.ProductName.Value.ToString();
        }

        if (!entProduct.Description.IsNull)
        {
            txtDescription.Text = entProduct.Description.Value.ToString();
        }

        if (!entProduct.Price.IsNull)
        {
            txtPrice.Text = entProduct.Price.Value.ToString();
        }
    }
예제 #7
0
    private void Manage()
    {
        var product = new Product {
            ProductID = Convert.ToInt32(ProductBAL.Manage(Request.QueryString))
        };

        Response.Write(product.ToJSON());
    }
예제 #8
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        string productCode = "";

        if (!String.IsNullOrEmpty(txtProductCode.Text.Trim()))
        {
            ProductCode_Grade_Map objGrade = new ProductCode_Grade_Map();

            objGrade.ProductCode = txtProductCode.Text.Trim();
            productCode          = txtProductCode.Text.Trim();
            objGrade.Grade       = ddlGrade.SelectedValue.ToString();
            objGrade.CreatedOn   = DateTime.Now;
            objGrade.CreatedBy   = Session[enumSessions.User_Name.ToString()].ToString();
            objGrade.IsDeleted   = false;
            Boolean flag = false;
            if (ViewState["ProductGradeID"] != null)
            {
                objGrade.ProductGradeID = Convert.ToInt32(ViewState["ProductGradeID"]);
                flag = ProductBAL.UpdateProductGrade(objGrade);
            }
            else
            {
                flag = ProductBAL.InsertProductGrade(objGrade);
            }
            if (flag == false)
            {
                string script = "alertify.alert('" + ltrDuplicate.Text + "');";
                ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "alert", script, true);
            }
            else
            {
                string script = "alertify.alert('" + ltrSaved.Text + "');";
                ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "alert", script, true);
            }

            LoadData();
            ClearControl();
            ViewState["ProductGradeID"] = null;
        }
        pnlGradeDetails.Visible = false;
        pnlGradeList.Visible    = true;

        LinqToSqlDataContext db = new LinqToSqlDataContext();
        Audit audit             = new Audit();

        audit.UserName  = Session[enumSessions.User_Name.ToString()].ToString();
        audit.ChangeID  = Convert.ToInt32(enumAudit.Manage_Products_Grade);
        audit.CreatedOn = DateTime.Now;
        audit.Notes     = "Grade: " + ddlGrade.SelectedValue.ToString() + ", Product Code: " + productCode;
        if (Request.ServerVariables["LOGON_USER"] != null)
        {
            audit.WindowsUser = Request.ServerVariables["LOGON_USER"];
        }
        audit.IPAddress = Request.UserHostAddress;
        db.Audits.InsertOnSubmit(audit);
        db.SubmitChanges();
    }
예제 #9
0
        public static void FillDropDownListProduct(DropDownList ddl)
        {
            ProductBAL balProduct = new ProductBAL();

            ddl.DataSource     = balProduct.SelectForDropDownList();
            ddl.DataValueField = "ProductID";
            ddl.DataTextField  = "ProductName";
            ddl.DataBind();
            ddl.Items.Insert(0, new ListItem("Select Product", "-1"));
        }
        public static void FillDropDownListProductID(DropDownList ddl, SqlInt32 UserID)
        {
            ProductBAL balProduct = new ProductBAL();

            ddl.DataSource     = balProduct.SelectDropDownList(UserID);
            ddl.DataTextField  = "ProductName";
            ddl.DataValueField = "ProductID";
            ddl.DataBind();
            ddl.Items.Insert(0, new ListItem("---Select Product---", "-99"));
        }
예제 #11
0
        private void BtnUpdate_Click(object sender, EventArgs e)
        {
            ProductBAL PB = new ProductBAL();

            if (TxtProductName.Text.Trim() != "")
            {
                PB.Product_Name = TxtProductName.Text.Trim();
                if (CMBBrandValueMember != 0)
                {
                    PB.Brand_ID = CMBBrandValueMember;
                    if (TxtCost.Text.Trim() != "")
                    {
                        PB.Product_Cost = Convert.ToDecimal(TxtCost.Text.Trim());
                        if (TxtSellingRate.Text.Trim() != "")
                        {
                            PB.Selling_Rate = Convert.ToDecimal(TxtSellingRate.Text.Trim());
                            PB.Description  = TxtDescription.Text.Trim();
                            PB.Product_ID   = ProductID;
                            ProductDAL PD     = new ProductDAL();
                            int        result = PD.UpdateProduct(PB);
                            if (result > 0)
                            {
                                MessageBox.Show("Product Updated Successfully");
                                LoadDGVProducts();
                            }
                            else
                            {
                                MessageBox.Show("Something Went Wrong");
                            }
                        }
                        else
                        {
                            MessageBox.Show("Please Enter the selling price of the product");
                            TxtSellingRate.Focus();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Please Enter the Product Cost");
                        TxtCost.Focus();
                    }
                }
                else
                {
                    MessageBox.Show("Please Select the Brand Name");
                }
            }
            else
            {
                MessageBox.Show("Product Name cannot be blank");
                TxtProductName.Focus();
            }
        }
    private void LoadControls(SqlInt32 ProductID)
    {
        ProductENT entProduct = new ProductENT();
        ProductBAL balProduct = new ProductBAL();

        entProduct = balProduct.SelectByPK(ProductID);

        if (!entProduct.ProductName.IsNull)
        {
            txtProductName.Text = entProduct.ProductName.Value.ToString();
        }
    }
예제 #13
0
    private void FillRepeatorCalendar()
    {
        DataTable  dtCalendar = new DataTable();
        ProductBAL balProduct = new ProductBAL();

        dtCalendar = balProduct.SelectAllCalendar();

        if (dtCalendar != null && dtCalendar.Rows.Count > 0)
        {
            rptCalendar.DataSource = dtCalendar;
            rptCalendar.DataBind();
        }
    }
예제 #14
0
    public void FillProductGridView()
    {
        DataTable  dtProduct  = new DataTable();
        ProductBAL balProduct = new ProductBAL();

        dtProduct = balProduct.SelectAll();

        if (dtProduct != null && dtProduct.Rows.Count > 0)
        {
            gvProduct.DataSource = dtProduct;
            gvProduct.DataBind();
        }
    }
예제 #15
0
    private void FillRepeatorProduct()
    {
        DataTable  dtProduct  = new DataTable();
        ProductBAL balProduct = new ProductBAL();

        dtProduct = balProduct.SelectAll();

        if (dtProduct != null && dtProduct.Rows.Count > 0)
        {
            rptProducts.DataSource = dtProduct;
            rptProducts.DataBind();
        }
    }
예제 #16
0
    private void FillRepeatorCanvas()
    {
        DataTable  dtCanvas   = new DataTable();
        ProductBAL balProduct = new ProductBAL();

        dtCanvas = balProduct.SelectAllCanvas();

        if (dtCanvas != null && dtCanvas.Rows.Count > 0)
        {
            rptCanvas.DataSource = dtCanvas;
            rptCanvas.DataBind();
        }
    }
예제 #17
0
        public void TestAdd()
        {
            ProductBAL obj = new ProductBAL();
            Product    p   = new Product()
            {
                Pname = "Abv",
                Price = 100,
                Stock = 10
            };

            obj.Add(p);
            Product p1 = obj.Get(4);

            Assert.IsNotNull(p1);
        }
예제 #18
0
 protected void gvProduct_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "DeleteRecord" && e.CommandArgument != null)
     {
         ProductBAL balProduct = new ProductBAL();
         if (balProduct.Delete(Convert.ToInt32(e.CommandArgument)))
         {
             FillProductGridView(Convert.ToInt32(Session["UserID"]));
         }
         else
         {
             lblMessage.Text = balProduct.Message;
         }
     }
 }
예제 #19
0
    private void FillProductGridView(SqlInt32 UserID)
    {
        ProductBAL balProduct = new ProductBAL();

        DataTable dtProduct = balProduct.SelectAll(UserID);

        if (dtProduct != null && dtProduct.Rows.Count > 0)
        {
            gvProduct.DataSource = dtProduct;
            gvProduct.DataBind();
            lblMessage.Text = "No Of Record : " + dtProduct.Rows.Count.ToString();
        }
        else
        {
            lblMessage.Text = "No Data Here";
        }
    }
예제 #20
0
 public int InsertProduct(ProductBAL B)
 {
     try
     {
         DataTable dt  = CheckProductByName(B.Product_Name);
         int       Res = 0;
         foreach (DataRow dr in dt.Rows)
         {
             Res = Convert.ToInt32(dr[0].ToString());
         }
         if (Res == 0)
         {
             using (C.Con)
             {
                 MySqlCommand cmd = new MySqlCommand("AddProduct", C.Con)
                 {
                     CommandType = CommandType.StoredProcedure
                 };
                 cmd.Parameters.Add(new MySqlParameter("P_Name", B.Product_Name));
                 cmd.Parameters.Add(new MySqlParameter("Brand_ID", B.Brand_ID));
                 cmd.Parameters.Add(new MySqlParameter("B_Rate", B.Selling_Rate));
                 cmd.Parameters.Add(new MySqlParameter("S_Rate", B.Product_Cost));
                 cmd.Parameters.Add(new MySqlParameter("Description", B.Description));
                 cmd.Connection.Open();
                 int Result = cmd.ExecuteNonQuery();
                 C.Con.Close();
                 return(Result);
             }
         }
         else
         {
             MessageBox.Show("Entered Product " + B.Product_Name + " Exist Already! Please Use a Unique Name for Each Product");
             return(0);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         return(0);
     }
 }
예제 #21
0
    public void LoadData()
    {
        CSLOrderingARCBAL.LinqToSqlDataContext db = null;
        try
        {
            ddlGrade.DataSource     = ProductBAL.GradeList();
            ddlGrade.DataTextField  = "Grade";
            ddlGrade.DataValueField = "Grade";
            ddlGrade.DataBind();

            gvGrade.DataSource = ProductBAL.GetProductGrade();
            gvGrade.DataBind();
        }

        catch (Exception objException)
        {
            db = new CSLOrderingARCBAL.LinqToSqlDataContext();
            db.USP_SaveErrorDetails(Request.Url.ToString(), "LoadData", Convert.ToString(objException.Message), Convert.ToString(objException.InnerException), Convert.ToString(objException.StackTrace), "", HttpContext.Current.Request.UserHostAddress, false, Convert.ToString(HttpContext.Current.Session[enumSessions.User_Id.ToString()]));
            db.Dispose();
        }
    }
예제 #22
0
    private void Search()
    {
        SqlString ProductName = SqlString.Null;

       
        if (txtSearchProductName.Text.Trim() != "")
            ProductName = Convert.ToString(txtSearchProductName.Text.Trim());

        ProductBAL balProduct = new ProductBAL ();
        DataTable dtProduct = balProduct.Search(ProductName);
        if (dtProduct != null && dtProduct.Rows.Count > 0)
        {
            gvProduct.DataSource = dtProduct;
            gvProduct.DataBind();
        }
        else
        {
            gvProduct.DataSource = null;
            gvProduct.DataBind();
        }
    }
예제 #23
0
 protected void LinkButtondelete_click(object sender, System.EventArgs e)
 {
     CSLOrderingARCBAL.LinqToSqlDataContext db = null;
     try
     {
         LinkButton lbdel = sender as LinkButton;
         if (lbdel != null)
         {
             GridViewRow gvr  = (GridViewRow)lbdel.NamingContainer;
             Label       lbl2 = gvr.FindControl("lblProductGradeID") as Label;
             ViewState["ProductGradeID"] = lbl2.Text;
         }
         else
         {
             //Reset
             if (ViewState["ProductGradeID"] != null)
             {
             }
             else
             {
                 //Do a cancel as no value in ViewState
                 btnCancel_Click(sender, e);
             }
         }
         db = new LinqToSqlDataContext();
         Boolean retunStatus = ProductBAL.DeleteProductGrade(Convert.ToInt32(ViewState["ProductGradeID"].ToString()));
         if (retunStatus == true)
         {
             LoadData();
             string script = "alertify.alert('" + ltrGrade.Text + "');";
             ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "alert", script, true);
         }
     }
     catch (Exception objException)
     {
         db = new CSLOrderingARCBAL.LinqToSqlDataContext();
         db.USP_SaveErrorDetails(Request.Url.ToString(), "LinkButtondelete_click", Convert.ToString(objException.Message), Convert.ToString(objException.InnerException), Convert.ToString(objException.StackTrace), "", HttpContext.Current.Request.UserHostAddress, false, Convert.ToString(HttpContext.Current.Session[enumSessions.User_Id.ToString()]));
         db.Dispose();
     }
 }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        #region ServerSide Validation


        #endregion ServerSide Validations

        ProductENT entProduct = new ProductENT();
        ProductBAL balProduct = new ProductBAL();

        #region Gather Data

        if (txtProductName.Text.Trim() != String.Empty)
        {
            entProduct.ProductName = txtProductName.Text.Trim();
        }

        entProduct.CreationDate = DateTime.Now;

        entProduct.UserID = Convert.ToInt32(Session["UserID"]);

        if (Request.QueryString["ProductID"] == null)
        {
            balProduct.Insert(entProduct);
            lblMessage.Text = "Data Insert SuccessFully";
            ClearControl();
        }
        else
        {
            entProduct.ProductID = Convert.ToInt32(Request.QueryString["ProductID"]);
            balProduct.Update(entProduct);
            Response.Redirect("~/AdminPanel/Product/ProductList.aspx");
        }

        #endregion Gather Data
    }
예제 #25
0
    public static string[] GetCompletionList(string prefixText)
    {
        String[] dt = ProductBAL.GetProductCodeList(prefixText);

        return(dt.ToArray());
    }
예제 #26
0
 private void GetProduct()
 {
     Response.Write(ProductBAL.GetProduct(Request.QueryString).ToJSON());
 }
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        #region ServerSide Validation
        String strErrorMessage = "";

        if (ddlCategoryID.SelectedIndex <= 0)
        {
            strErrorMessage += "Select Category<br/>";
        }

        if (txtProductName.Text == "")
        {
            strErrorMessage += "Enter Product Name<br/>";
        }

        if (txtDescription.Text == "")
        {
            strErrorMessage += "Enter Description<br/>";
        }

        if (txtPrice.Text == "")
        {
            strErrorMessage += "Enter Price<br/>";
        }

        if (strErrorMessage != "")
        {
            lblMessage.Text    = strErrorMessage;
            divMessage.Visible = true;
        }

        #endregion ServerSide Validation

        #region Collect FormData
        ProductENT entProduct = new ProductENT();

        if (ddlCategoryID.SelectedIndex != 0)
        {
            entProduct.CategoryID = Convert.ToInt32(ddlCategoryID.SelectedValue);
        }

        if (txtProductName.Text != "")
        {
            entProduct.ProductName = txtProductName.Text.Trim();
        }

        if (txtDescription.Text != "")
        {
            entProduct.Description = txtDescription.Text.Trim();
        }

        if (txtPrice.Text != "")
        {
            entProduct.Price = Convert.ToInt32(txtPrice.Text.Trim());
        }

        #region Upload File
        if (fuProductImage.HasFile)
        {
            string strPath = "~/ProductImage/";
            if (ddlCategoryID.SelectedItem.ToString() == "Calendar")
            {
                strPath += "Calendar/";
            }
            if (ddlCategoryID.SelectedItem.ToString() == "T-shirt")
            {
                strPath += "T-shirt/";
            }
            if (ddlCategoryID.SelectedItem.ToString() == "Canvas")
            {
                strPath += "Canvas/";
            }
            string strPhysicalPath = Server.MapPath(strPath) + fuProductImage.FileName;
            fuProductImage.SaveAs(strPhysicalPath);
            entProduct.ProductImage = strPath + fuProductImage.FileName;
        }
        else
        {
            lblMessage.Text    = "Select File";
            divMessage.Visible = true;
        }
        #endregion Upload File

        #endregion Collect FormData

        ProductBAL balProduct = new ProductBAL();

        if (Request.QueryString["ProductID"] == null)
        {
            if (balProduct.Insert(entProduct))
            {
                ClearControls();
                lblMessage.Text    = "Add Successfully";
                divMessage.Visible = true;
            }
            else
            {
                lblMessage.Text    = balProduct.Message;
                divMessage.Visible = true;
            }
        }
        else
        {
            entProduct.ProductID = Convert.ToInt32(Request.QueryString["ProductID"]);

            if (balProduct.Update(entProduct))
            {
                ClearControls();
                Response.Redirect("~/AdminPanel/Product/ProductList.aspx");
            }
            else
            {
                lblMessage.Text    = balProduct.Message;
                divMessage.Visible = true;
            }
        }
    }