Esempio n. 1
0
        protected void btnSubCategory_Click(object sender, EventArgs e)
        {
            try
            {
                var categories = new BOCategories();

                int subCatid = 0;
                if (ViewState["SubCatId"] != null)
                    subCatid = Convert.ToInt16(ViewState["SubCatId"]);

                categories.SubCategoryId = subCatid;
                //categories.ParentSubCategoryId = Convert.ToInt32(drpParentSubCategory.SelectedValue);
                categories.SubCategoryCode = txtSubCategoryCode.Text.Trim();
                categories.SubCategoryName = txtSubCategoryName.Text.Trim();
                categories.HostCode = Session["HostCode"].ToString();
                categories.UserId = Convert.ToInt32(Session["UserId"]);
                categories.Id = Convert.ToInt32(drpcategoryID.SelectedValue);

                var index = drpcategoryID.SelectedIndex;
                var parentIndex = drpcategoryID.SelectedIndex;
                var isInserted = (new BLCategories()).InsertSubCategory(categories);
                if (isInserted == -1)
                {
                    this.btnSubCategory.Text = "Add SubCategory";
                    txtSubCategoryCode.Text = string.Empty;
                    txtSubCategoryName.Text = string.Empty;
                    ViewState["SubCatId"] = null;
                    drpcategoryID.SelectedIndex = index;
                    //drpParentSubCategory.SelectedIndex = parentIndex;
                    BindSubCategoriesGrid();
                    drpcategoryID_SelectedIndexChanged(null, null);
                    subcatUpdatePanel.Update();
                    lblErrorMsg.ForeColor = System.Drawing.Color.Green;
                    if (subCatid > 0)
                        lblErrorMsg.Text = "Sub Category updated successfully.";
                    else
                        lblErrorMsg.Text = "Sub Category inserted successfully.";
                }
                else
                {
                    lblErrorMsg.ForeColor = System.Drawing.Color.Red;
                    lblSubCategoryMsg.Text = "Process failed. Please try again.";
                }
            }
            catch (Exception ex)
            {
                lblErrorMsg.ForeColor = System.Drawing.Color.Red;
                lblErrorMsg.Text = ex.Message;
            }
        }
Esempio n. 2
0
        public int InsertCategory(BOCategories categories)
        {
            SqlParameter[] sqlParams = new SqlParameter[9];
            sqlParams[0] = new SqlParameter("@CategoryCode", categories.CategoryCode);
            sqlParams[1] = new SqlParameter("@CategoryName", categories.CategoryName);
            sqlParams[2] = new SqlParameter("@Status", 'A');
            sqlParams[3] = new SqlParameter("@HostCode", categories.HostCode);
            sqlParams[4] = new SqlParameter("@RecordId", categories.Id);
            sqlParams[5] = new SqlParameter("@CreatedDate", DateTime.Now);
            sqlParams[6] = new SqlParameter("@ModifiedDate", DateTime.Now);
            sqlParams[7] = new SqlParameter("@CreatedBy", categories.UserId);
            sqlParams[8] = new SqlParameter("@ModifiedBy", categories.UserId);

            return cmnDA.ExecuteNonQuery("pr_Categories_AddOrUpdate", sqlParams);
        }
Esempio n. 3
0
        protected void btnCategory_Click(object sender, EventArgs e)
        {
            try
            {
                var categories = new BOCategories();

                int catid = 0;
                if (ViewState["CatId"] != null)
                    catid = Convert.ToInt16(ViewState["CatId"]);

                categories.Id = catid;
                categories.CategoryCode = txtCategoryCode.Text.Trim();
                categories.CategoryName = txtCategoryName.Text.Trim();
                categories.HostCode = Session["HostCode"].ToString();
                categories.UserId = Convert.ToInt32(Session["UserId"]);

                var isInserted = (new BLCategories()).InsertCategory(categories);
                if (isInserted == -1)
                {
                    subcatUpdatePanel.Update();
                    LoadCategories();
                    BindCategoriesGrid();
                    this.btnCategory.Text = "Add Category";
                    txtCategoryCode.Text = string.Empty;
                    txtCategoryName.Text = string.Empty;
                    lblErrorMsg.ForeColor = System.Drawing.Color.Green;
                    if (catid > 0)
                    {
                        lblErrorMsg.Text = "Category updated successfully.";
                    }
                    else
                    {
                        lblErrorMsg.Text = "Category inserted successfully.";
                    }
                    ViewState["CatId"] = null;
                }
                else
                {
                    lblErrorMsg.ForeColor = System.Drawing.Color.Red;
                    lblErrorMsg.Text = "Process failed. Please try again.";
                }
            }
            catch (Exception ex)
            {
                lblErrorMsg.ForeColor = System.Drawing.Color.Red;
                lblErrorMsg.Text = ex.Message;
            }
        }
Esempio n. 4
0
        public int InsertSubCategory(BOCategories categories)
        {
            SqlParameter[] sqlParams = new SqlParameter[11];
            sqlParams[0] = new SqlParameter("@CategoryId", categories.Id);
            if (categories.ParentSubCategoryId > 0)
                sqlParams[1] = new SqlParameter("@SubCategoryId", categories.ParentSubCategoryId);
            else
                sqlParams[1] = new SqlParameter("@SubCategoryId", DBNull.Value);

            sqlParams[2] = new SqlParameter("@SubCategoryCode", categories.SubCategoryCode);
            sqlParams[3] = new SqlParameter("@SubCategoryName", categories.SubCategoryName);
            sqlParams[4] = new SqlParameter("@Status", 'A');
            sqlParams[5] = new SqlParameter("@HostCode", categories.HostCode);
            sqlParams[6] = new SqlParameter("@RecordId", categories.SubCategoryId);
            sqlParams[7] = new SqlParameter("@CreatedDate", DateTime.Now);
            sqlParams[8] = new SqlParameter("@ModifiedDate", DateTime.Now);
            sqlParams[9] = new SqlParameter("@CreatedBy", categories.UserId);
            sqlParams[10] = new SqlParameter("@ModifiedBy", categories.UserId);

            return cmnDA.ExecuteNonQuery("pr_SubCategories_AddOrUpdate", sqlParams);
        }