void BindCategory(ProductEntity.Category category)
 {
     categoryid.Value        = category.ID;
     categoryname.Value      = category.Name;
     discription.Value       = discription.Value;
     ddlStatus.SelectedValue = category.StatusId.ToString();
 }
 bool UploadImage(ProductEntity.Category v, out string message)
 {
     if (imagefile.HasFile)
     {
         if (imagefile.PostedFile.ContentType == "image/png")
         {
             if (imagefile.PostedFile.ContentLength < 1024000)
             {
                 string filename = Hash.getHashSha256(v.ID) + System.IO.Path.GetExtension(imagefile.FileName);
                 imagefile.SaveAs(Server.MapPath("~/images/categories/") + filename);
                 message         = "FILE_UPLOAD_SUCCESS";
                 v.CategoryImage = filename;
                 return(true);
             }
             else
             {
                 message = "FILE_UPLOAD_TOO_BIG";
             }
         }
         else
         {
             message = "INVALID_IMAGE_FORMAT";
         }
         return(false);
     }
     message = "NO_FILE_UPLOADED";
     return(true);
 }
        public ProductEntity.Category GetCategory()
        {
            var v = new ProductEntity.Category();

            v.ID          = categoryid.Value;
            v.Name        = categoryname.Value;
            v.CreatedBy   = Session["User"] as UserEntity;
            v.CreatedDate = DateTime.Now;
            v.Discription = discription.Value;
            v.StatusId    = int.Parse(ddlStatus.SelectedValue);
            return(v);
        }
示例#4
0
        public List <ProductEntity.Category> GetCategories()
        {
            DataTable dt = GetTable();
            List <ProductEntity.Category> ls = new List <ProductEntity.Category>();

            foreach (DataRow row in dt.Rows)
            {
                ProductEntity.Category category = RowToCategory(row);
                ls.Add(category);
            }
            return(ls);
        }
示例#5
0
        public ProductEntity.Category GetCategory()
        {
            var v = new ProductEntity.Category();

            v.ID          = categoryid.Value;
            v.Name        = categoryname.Value;
            v.CreatedBy   = Session["User"] as UserEntity;
            v.CreatedDate = DateTime.Now;
            v.Discription = discription.Value;
            v.Status      = StatusBus.Instance.GetStatus(int.Parse(ddlStatus.SelectedValue));
            v.CreatedBy   = UserBus.Instance.GetUser(User.Identity.Name);
            return(v);
        }
示例#6
0
        public int UpdateCategory(ProductEntity.Category e, string id)
        {
            string sql = "update tb_category set categoryname = @name, discription = @discription, categoryimage = @image, statusid = @status where categoryid = @id";

            SqlParameter[] pars = new SqlParameter[]
            {
                new SqlParameter("@id", id),
                new SqlParameter("@name", e.Name),
                new SqlParameter("@discription", e.Discription),
                new SqlParameter("@image", e.CategoryImage == null?(object)DBNull.Value : e.CategoryImage),
                new SqlParameter("@status", e.StatusId)
            };
            return(DataConfig.Instance.ExecuteNonQuery(sql, pars));
        }
示例#7
0
 ProductEntity.Category RowToCategory(DataRow row)
 {
     ProductEntity.Category category = new ProductEntity.Category();
     category.ID          = row["categoryid"].ToString();
     category.Name        = row["categoryname"].ToString();
     category.Discription = row["discription"].ToString();
     category.CreatedBy   = new UserEntity()
     {
         Username = row["username"].ToString()
     };
     category.CreatedDate   = (DateTime)row["createddate"];
     category.CategoryImage = row["categoryimage"].ToString();
     category.Status        = StatusBus.Instance.GetStatus((int)row["statusid"]);
     return(category);
 }
示例#8
0
        public int AddCategory(ProductEntity.Category e)
        {
            string sql = "insert into tb_category values(@categoryid, @name, @discription, @image, @date, @by, @status)";

            SqlParameter[] pars = new SqlParameter[]
            {
                new SqlParameter("@categoryid", e.ID),
                new SqlParameter("@name", e.Name),
                new SqlParameter("@discription", e.Discription),
                new SqlParameter("@image", e.CategoryImage == null?(object)DBNull.Value : e.CategoryImage),
                new SqlParameter("@date", e.CreatedDate),
                new SqlParameter("@by", e.CreatedBy.Username),
                new SqlParameter("@status", e.StatusId)
            };
            return(DataConfig.Instance.ExecuteNonQuery(sql, pars));
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         string query = Request.QueryString["cate"];
         if (String.IsNullOrEmpty(query))
         {
             Response.Redirect("CategoryList.aspx");
             return;
         }
         ProductEntity.Category category = CategoryBus.Instance.GetBasicCategoryById(query);
         if (category == null)
         {
             Response.Redirect("CategoryList.aspx");
             return;
         }
         BindData();
         BindCategory(category);
     }
 }
示例#10
0
        public ProductEntity.Category GetBasicCategoryById(string id)
        {
            string sql = "select * from tb_category where categoryid = @id";

            SqlParameter[] pars = new SqlParameter[] {
                new SqlParameter("@id", id)
            };

            DataTable dt = DataConfig.Instance.GetTable(sql, pars);

            if (dt.Rows.Count < 1)
            {
                return(null);
            }
            var cate = new ProductEntity.Category();

            cate.ID   = dt.Rows[0]["categoryid"].ToString();
            cate.Name = dt.Rows[0]["categoryname"].ToString();
            return(cate);
        }
示例#11
0
        public List <ProductEntity.Category> GetCategories()
        {
            DataTable dt = GetTable();
            List <ProductEntity.Category> ls = new List <ProductEntity.Category>();

            foreach (DataRow row in dt.Rows)
            {
                ProductEntity.Category category = new ProductEntity.Category();
                category.ID          = row["categoryid"].ToString();
                category.Name        = row["categoryname"].ToString();
                category.Discription = row["discription"].ToString();
                category.CreatedBy   = new UserEntity()
                {
                    Username = row["username"].ToString()
                };
                category.CreatedDate   = (DateTime)row["createddate"];
                category.CategoryImage = row["categoryimage"].ToString();
                category.StatusId      = (int)row["statusid"];
                category.StatusName    = row["statusname"].ToString();
                ls.Add(category);
            }
            return(ls);
        }