Exemplo n.º 1
0
        public List <BOCategories> LoadCategories(int userid, string hostCode)
        {
            DACategories pDAL = new DACategories();

            try
            {
                var          dtCategories = pDAL.LoadCategories(userid, hostCode);
                var          categories   = new List <BOCategories>();
                BOCategories cat          = null;
                foreach (DataRow item in dtCategories.Rows)
                {
                    cat = new BOCategories();
                    cat.CategoryCode = item["Code"].ToString();
                    cat.CategoryName = item["Name"].ToString();
                    cat.Id           = Convert.ToInt32(item["Id"]);

                    categories.Add(cat);
                }

                return(categories);
            }
            catch
            {
                throw;
            }
            finally
            {
                pDAL = null;
            }
        }
Exemplo n.º 2
0
        public IBOCategories BOCategories(ICategoriesRepository repo)
        {
            BOCategories boCategories = (BOCategories)BOCategories();

            boCategories.Repository = repo;
            return(boCategories);
        }
Exemplo n.º 3
0
        public async Task <IHttpActionResult> DeleteCategories(Int32 id)
        {
            var result = Task.Factory.StartNew(() =>
            {
                IUnitOfWork uow = new UnitOfWorkImp(new IRepositoryConnection[] { CategoriesRepository });
                var bo          = new BOCategories();
                bo.Repository   = CategoriesRepository;
                bo.Init(id);

                uow.Delete(bo);

                string err;
                if (!uow.Commit(out err))
                {
                    var resp = new HttpResponseMessage(HttpStatusCode.BadRequest)
                    {
                        Content = new StringContent(err)
                    };
                    throw new HttpResponseException(resp);
                }
                return(true);
            });
            await result;

            if (!result.Result)
            {
                return(NotFound());
            }

            return(Ok(result.Result));
        }
Exemplo 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));
        }
Exemplo n.º 5
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;
            }
        }
Exemplo n.º 6
0
        public IBOCategories BOCategories()
        {
            var boCategories = new BOCategories()
            {
                CategoryID   = this.CategoryID,
                CategoryName = this.CategoryName,
                Description  = this.Description,
                Picture      = this.Picture != null?Convert.FromBase64String(this.Picture) : null
            };

            return(boCategories);
        }
Exemplo n.º 7
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;
            }
        }
Exemplo n.º 8
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));
        }
Exemplo n.º 9
0
        public int InsertSubCategory(BOCategories categories)
        {
            DACategories pDAL = new DACategories();

            try
            {
                return(pDAL.InsertSubCategory(categories));
            }
            catch
            {
                throw;
            }
            finally
            {
                pDAL = null;
            }
        }
Exemplo n.º 10
0
        public List <BOCategories> LoadSubCategories(int userid, string hostCode)
        {
            DACategories pDAL = new DACategories();

            try
            {
                var dtSubCategories = pDAL.LoadSubCategories(userid, hostCode);

                var          subCategories = new List <BOCategories>();
                BOCategories cat           = null;
                foreach (DataRow item in dtSubCategories.Rows)
                {
                    cat = new BOCategories();
                    cat.CategoryCode    = item["CategoryCode"].ToString();
                    cat.SubCategoryCode = item["SubCategoryCode"].ToString();
                    cat.SubCategoryName = item["SubCategoryName"].ToString();

                    if (item["ParentSubCategoryId"] != null && item["ParentSubCategoryId"] != DBNull.Value)
                    {
                        cat.ParentSubCategoryId = Convert.ToInt32(item["ParentSubCategoryId"].ToString());
                    }

                    cat.ParentSubCategoryName = item["ParentSubCategoryName"].ToString();
                    cat.SubCategoryId         = Convert.ToInt32(item["Id"]);
                    cat.Id           = Convert.ToInt32(item["CategoryId"]);
                    cat.CategoryName = item["CategoryName"].ToString();

                    subCategories.Add(cat);
                }

                return(subCategories);
            }
            catch
            {
                throw;
            }
            finally
            {
                pDAL = null;
            }
        }