protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                Business.Inventory.ProductCategory objProductCategory = new Business.Inventory.ProductCategory();
                Entity.Inventory.ProductCategory   productCategory    = new Entity.Inventory.ProductCategory();

                productCategory.ProductCategoryId   = ProductCategoryId;
                productCategory.ProductCategoryName = txtProductCategoryName.Text;

                int i = objProductCategory.Save(productCategory);

                if (i > 0)
                {
                    ClearControls();
                    LoadProductCategory();
                    Message.IsSuccess = true;
                    Message.Text      = "Model Category saved successfully...";
                }
                else
                {
                    Message.IsSuccess = false;
                    Message.Text      = "Can not save!!!";
                }
                Message.Show = true;
            }
            catch (Exception ex)
            {
                ex.WriteException();

                Message.IsSuccess = false;
                Message.Text      = ex.Message;
                Message.Show      = true;
            }
        }
Ejemplo n.º 2
0
        private void LoadProductCategory()
        {
            Business.Inventory.ProductCategory objProductCategory = new Business.Inventory.ProductCategory();

            DataTable dt = objProductCategory.GetAll();

            if (dt.Rows.Count > 0)
            {
                ddlProductCategory.DataSource     = dt;
                ddlProductCategory.DataTextField  = "ProductCategoryName";
                ddlProductCategory.DataValueField = "ProductCategoryId";
                ddlProductCategory.DataBind();
            }
            ddlProductCategory.InsertSelect();
        }
        protected void gvProductCategory_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            try
            {
                Business.Inventory.ProductCategory objProductCategory = new Business.Inventory.ProductCategory();
                Entity.Inventory.ProductCategory   productCategory    = new Entity.Inventory.ProductCategory();

                if (e.CommandName == "Ed")
                {
                    int productCategoryId = int.Parse(e.CommandArgument.ToString());
                    productCategory             = objProductCategory.GetById(productCategoryId);
                    ProductCategoryId           = productCategory.ProductCategoryId;
                    txtProductCategoryName.Text = productCategory.ProductCategoryName;
                }
            }
            catch (Exception ex)
            {
                ex.WriteException();

                Message.IsSuccess = false;
                Message.Text      = ex.Message;
                Message.Show      = true;
            }
        }
 protected void LoadProductCategory()
 {
     Business.Inventory.ProductCategory objProductCategory = new Business.Inventory.ProductCategory();
     gvProductCategory.DataSource = objProductCategory.GetAll();
     gvProductCategory.DataBind();
 }