Exemple #1
0
        protected void btn_Save_Click(object sender, EventArgs e)
        {
            sanPhamDAL spDAL = new sanPhamDAL();
            SAN_PHAM   sp    = new SAN_PHAM();

            lb_messenger.Visible = true;
            var idSP = Request.QueryString["MaSP"];

            if (!String.IsNullOrEmpty(txt_tenSP.Text) && !String.IsNullOrEmpty(txt_moTa.Text) &&
                !String.IsNullOrEmpty(txt_anh.Text) && !String.IsNullOrEmpty(txt_gia.Text))
            {
                sp.MA_SP  = Convert.ToInt32(idSP);
                sp.TEN_SP = txt_tenSP.Text;
                sp.MO_TA  = txt_moTa.Text;
                sp.ANH    = txt_gia.Text;
                sp.GIA    = Convert.ToDouble(txt_gia.Text);

                int result = spDAL.Update(sp);

                if (result == 1)
                {
                    lb_messenger.Text     = "Thành Công";
                    lb_messenger.CssClass = "text-success";
                }
                else
                {
                    lb_messenger.Text = "Thất Bại";
                }
            }

            else
            {
                lb_messenger.Text = "Phải Nhập Đủ Các Trường";
            }
        }
Exemple #2
0
        // The return type can be changed to IEnumerable, however to support
        // paging and sorting, the following parameters must be added:
        //     int maximumRows
        //     int startRowIndex
        //     out int totalRowCount
        //     string sortByExpression
        public List <SAN_PHAM> SanPhamLoad_GetData()
        {
            sanPhamDAL sp       = new sanPhamDAL();
            var        itemList = sp.GetList();

            return(itemList);
        }
Exemple #3
0
        // The id parameter should match the DataKeyNames value set on the control
        // or be decorated with a value provider attribute, e.g. [QueryString]int id
        public SAN_PHAM SanPhamDetail_GetItem([QueryString("MaSP")] int id)
        {
            sanPhamDAL sp  = new sanPhamDAL();
            var        sp2 = sp.GetDVByMa(id);

            return(sp2);
        }
Exemple #4
0
        // The id parameter should match the DataKeyNames value set on the control
        // or be decorated with a value provider attribute, e.g. [QueryString]int id
        public SAN_PHAM SanPhamDetail_GetItem([QueryString("MaSP")] int id)
        {
            DB_SPAEntities context = new DB_SPAEntities();
            sanPhamDAL     sp      = new sanPhamDAL();
            var            sp2     = sp.GetDVByMa(id);

            return(sp2);
        }
Exemple #5
0
        protected void btn_Save_Click(object sender, EventArgs e)
        {
            try
            {
                sanPhamDAL spDAL = new sanPhamDAL();
                SAN_PHAM   sp    = new SAN_PHAM();

                lb_messenger.Visible = true;
                var    idSP     = Request.QueryString["MaSP"];
                string location = "";
                string fn       = "";
                if (FileUpload_hinh.HasFile)
                {
                    DateTime foo      = DateTime.UtcNow;
                    long     unixTime = ((DateTimeOffset)foo).ToUnixTimeSeconds();
                    fn       = "DV" + unixTime.ToString() + "_" + System.IO.Path.GetFileName(FileUpload_hinh.PostedFile.FileName);
                    location = Server.MapPath("~/Resource/image/") + fn;
                    FileUpload_hinh.PostedFile.SaveAs(location);
                }

                if (!String.IsNullOrEmpty(txt_tenSP.Text) && !String.IsNullOrEmpty(txt_moTa.Text) &&
                    !String.IsNullOrEmpty(txt_gia.Text))
                {
                    sp.MA_SP  = Convert.ToInt32(idSP);
                    sp.TEN_SP = txt_tenSP.Text;
                    sp.MO_TA  = txt_moTa.Text;
                    sp.ANH    = fn;
                    sp.GIA    = Convert.ToDouble(txt_gia.Text);

                    int result = spDAL.Update(sp);

                    if (result == 1)
                    {
                        lb_messenger.Text     = "Cập Nhật Sản Phẩm Thành Công";
                        lb_messenger.CssClass = "text-success";
                    }
                    else
                    {
                        lb_messenger.Text = "Cập Nhật Sản Phẩm Thất Bại";
                    }
                }

                else
                {
                    lb_messenger.Text = "Phải Nhập Đủ Các Trường";
                }
            } catch (Exception ex)
            {
                lb_messenger.Text = ex.ToString();
            }
            ViewState["Edit_sp"] = false;
        }
Exemple #6
0
        protected void btn_Delete_Click(object sender, EventArgs e)
        {
            sanPhamDAL sp = new sanPhamDAL();
            int        id = Convert.ToInt32((sender as LinkButton).CommandArgument);
            int        kq = sp.Delete(id);

            lb_messenger.Visible = true;
            if (kq != 0)
            {
                lb_messenger.Text = "Xóa Thành Công";
            }
            SanPhamLoad_GetData();
            Page.Response.Redirect(Page.Request.Url.ToString(), true);
        }
Exemple #7
0
        protected void addDataIntoControl()
        {
            sanPhamDAL spDAL = new sanPhamDAL();

            var idSP = Request.QueryString["MaSP"];
            var sp   = spDAL.GetDVByMa(Convert.ToInt32(idSP));

            if (sp != null)
            {
                txt_tenSP.Text = sp.TEN_SP;
                txt_moTa.Text  = sp.MO_TA;
                txt_anh.Text   = sp.ANH;
                txt_gia.Text   = sp.GIA.ToString();
            }
        }
Exemple #8
0
        protected void btn_Save_Click(object sender, EventArgs e)
        {
            sanPhamDAL spDAL = new sanPhamDAL();
            SAN_PHAM   sp    = new SAN_PHAM();

            lb_messenger.Visible = true;

            if (FileUpload_hinh.HasFile)
            {
                try
                {
                    if (FileUpload_hinh.PostedFile.ContentType == "image/jpeg")
                    {
                        if (FileUpload_hinh.PostedFile.ContentLength < 102400)
                        {
                            string filename = Path.GetFileName(FileUpload_hinh.FileName.ToString());
                            FileUpload_hinh.SaveAs(Server.MapPath("~/Resource/image/") + filename);
                        }
                    }
                }
                catch { }
            }

            if (!String.IsNullOrEmpty(txt_tenSP.Text) && !String.IsNullOrEmpty(txt_gia.Text))
            {
                sp.TEN_SP = txt_tenSP.Text;
                sp.MO_TA  = txt_moTa.Text;
                sp.ANH    = Path.GetFileName(FileUpload_hinh.FileName.ToString());
                sp.GIA    = Convert.ToDouble(txt_gia.Text);

                int result = spDAL.Add(sp);

                if (result == 1)
                {
                    lb_messenger.Text     = "Thêm Sản Phẩm Thành Công";
                    lb_messenger.CssClass = "text-success";
                }
                else
                {
                    lb_messenger.Text = "Thêm Sản Phẩm Thất Bại";
                }
            }
            else
            {
                lb_messenger.Text = "Phải Nhập Đủ Các Trường";
            }
        }
Exemple #9
0
        protected void addDataIntoControl()
        {
            try
            {
                sanPhamDAL spDAL = new sanPhamDAL();

                var idSP = Request.QueryString["MaSP"];
                var sp   = spDAL.GetDVByMa(Convert.ToInt32(idSP));
                if (sp != null)
                {
                    txt_tenSP.Text = sp.TEN_SP;
                    txt_moTa.Text  = sp.MO_TA;

                    txt_gia.Text = sp.GIA.ToString();
                }
            } catch (Exception ex)
            {
                lb_messenger.Text = ex.ToString();
            }
            ViewState["Edit_sp"] = true;
        }