private void hienthiThongtinSanpham(long sanphamID)
        {
            SanphamController   BRLsanpham  = new SanphamController();
            List <SanphamModel> glstSanpham = BRLsanpham.SanphamGetbyPK(sanphamID);

            if (glstSanpham.Count < 1)
            {
                Response.Redirect("~/DanhsachSanpham.aspx");
            }
            int loaispID = glstSanpham[0].FK_iLoaiSanphamID;

            if (loaispID > 0)
            {
                List <LoaiSanphamModel> glstLoaiSanpham = BRLsanpham.LoaiSanphamGetbyPK(loaispID);
                if (glstSanpham.Count > 0)
                {
                    lblLoaiSanpham.Text = glstLoaiSanpham[0].sTenLoaiSanpham;
                }
            }
            imageSanpham.ImageUrl = string.Format("~/{0}", glstSanpham[0].sHinhanh);
            lblTenSanpham.Text    = glstSanpham[0].sTenSanpham;
            decimal giaDangapdung = BRLsanpham.GetGiaDangApdungByFKSanphamID(glstSanpham[0].PK_iSanphamID);

            if (giaDangapdung > 0)
            {
                lblGiaChuaKhuyenmai.Text = string.Format("{0:C0}", giaDangapdung);
            }
            else
            {
                lblGiaChuaKhuyenmai.Text = "Liên hệ";
            }
        }
        protected void ddlLoaiSanpham_SelectedIndexChanged(object sender, EventArgs e)
        {
            lblThongbaoLoaiSanphamNgungKinhdoanh.Text = string.Empty;
            SanphamController   brlSanpham = new SanphamController();
            List <SanphamModel> glstSanpham;
            int loaiSanphamID = Convert.ToInt32(ddlLoaiSanpham.SelectedValue);

            if (loaiSanphamID < 1)
            {
                glstSanpham = brlSanpham.SanphamGetbyPK(0);
            }
            else
            {
                glstSanpham = brlSanpham.SanphamGetbyFK_iloaiSanphamID(loaiSanphamID);
                List <LoaiSanphamModel> glstLoaisanpham = brlSanpham.LoaiSanphamGetbyPK(loaiSanphamID);
                if (glstLoaisanpham.Count > 0)
                {
                    if (glstLoaisanpham[0].IsNgungKinhdoanh)
                    {
                        lblThongbaoLoaiSanphamNgungKinhdoanh.Text = string.Format("Thông báo: Loại sản phẩm <b>\"{0}\"</b> này đã ngừng kinh doanh.", glstLoaisanpham[0].sTenLoaiSanpham);
                    }
                }
            }
            glstSanpham.Sort((sp1, sp2) => sp1.sTenSanpham.CompareTo(sp2.sTenSanpham));
            rptSanpham.DataSource = glstSanpham;
            rptSanpham.DataBind();
        }
Exemple #3
0
        private void hienthiGiaCuaSanpham(long sanphamID)
        {
            List <BanggiaModel> glstGiaCuaSanpham = new SanphamController().GetBanggiaByFKiSanphamID(sanphamID);

            glstGiaCuaSanpham.Sort((gia1, gia2) => gia1.tNgaybatdauapdung.CompareTo(gia2.tNgaybatdauapdung));
            rptGiaCuaSanpham.DataSource = glstGiaCuaSanpham;
            rptGiaCuaSanpham.DataBind();
        }
        private void hienthiKhuyenmaiCuaSanpham(long sanphamID)
        {
            List <KhuyenmaiModel> glstKhuyenmaiCuaSanpham = new SanphamController().GetKhuyenmaiByFKiSanphamID(sanphamID);

            glstKhuyenmaiCuaSanpham.Sort((km1, km2) => km1.tNgaybatdau.CompareTo(km2.tNgaybatdau));
            rptKhuyenmaiCuaSanpham.DataSource = glstKhuyenmaiCuaSanpham;
            rptKhuyenmaiCuaSanpham.DataBind();
        }
        private void hienLoaiSanpham()
        {
            List <LoaiSanphamModel> glstLoaiSanpham = new SanphamController().LoaiSanphamGetbyPK(0);

            glstLoaiSanpham.Sort((lsp1, lsp2) => lsp1.sTenLoaiSanpham.CompareTo(lsp2.sTenLoaiSanpham));
            rptLoaiSanpham.DataSource = glstLoaiSanpham;
            rptLoaiSanpham.DataBind();
        }
 protected void rptSanpham_ItemDataBound(object sender, RepeaterItemEventArgs e)
 {
     if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
     {
         SanphamModel sanpham = e.Item.DataItem as SanphamModel;
         if (sanpham != null)
         {
             Image imgSanpham = e.Item.FindControl("imgSanpham") as Image;
             if (imgSanpham != null)
             {
                 imgSanpham.ImageUrl = string.Format("~/{0}", sanpham.sHinhanh);
             }
             Literal           ltrGiaDangApdung = e.Item.FindControl("ltrGiaDangApdung") as Literal;
             SanphamController brlSanpham       = new SanphamController();
             if (ltrGiaDangApdung != null)
             {
                 decimal giaDangApdung = brlSanpham.GetGiaDangApdungByFKSanphamID(sanpham.PK_iSanphamID);
                 ltrGiaDangApdung.Text = giaDangApdung < 0 ? "Liên hệ" : giaDangApdung.ToString("C0");
             }
             Literal ltrLoaiSanpham = e.Item.FindControl("ltrLoaiSanpham") as Literal;
             if (ltrLoaiSanpham != null)
             {
                 int loaiSanphamID = sanpham.FK_iLoaiSanphamID;
                 if (loaiSanphamID > 0)
                 {
                     List <LoaiSanphamModel> glstLoaisanpham = brlSanpham.LoaiSanphamGetbyPK(loaiSanphamID);
                     if (glstLoaisanpham.Count > 0)
                     {
                         ltrLoaiSanpham.Text = glstLoaisanpham[0].sTenLoaiSanpham;
                     }
                 }
             }
             Literal ltrKhuyenmaiDangApdung = e.Item.FindControl("ltrKhuyenmaiDangApdung") as Literal;
             if (ltrKhuyenmaiDangApdung != null)
             {
                 int khuyenmaiDangapdung = Convert.ToInt32(brlSanpham.GetKhuyenmaiDangApdungByFKSanphamID(sanpham.PK_iSanphamID) * 100);
                 ltrKhuyenmaiDangApdung.Text = khuyenmaiDangapdung < 0 ? string.Empty : string.Format("{0}%", khuyenmaiDangapdung);
             }
             HyperLink hrefDieuChinhgia = e.Item.FindControl("hrefDieuChinhgia") as HyperLink;
             if (hrefDieuChinhgia != null)
             {
                 hrefDieuChinhgia.NavigateUrl = string.Format("~/DieuchinhGia.aspx?gsp={0}", sanpham.PK_iSanphamID);
             }
             HyperLink hrefDieuChinhKhuyenmai = e.Item.FindControl("hrefDieuChinhKhuyenmai") as HyperLink;
             if (hrefDieuChinhKhuyenmai != null)
             {
                 hrefDieuChinhKhuyenmai.NavigateUrl = string.Format("~/DieuchinhKhuyenmai.aspx?kmsp={0}", sanpham.PK_iSanphamID);
             }
             HyperLink hrefCongthuc = e.Item.FindControl("hrefCongthuc") as HyperLink;
             if (hrefCongthuc != null)
             {
                 hrefCongthuc.NavigateUrl = string.Format("~/Congthuc.aspx?ctsp={0}", sanpham.PK_iSanphamID);
             }
         } //sanpham
     }     //ItemType
 }
 private void Search()
 {
     string lsp = (comboBox1.SelectedItem == null || comboBox1.SelectedItem.Equals("(Tất cả)") ? "" : comboBox1.SelectedItem.ToString());
     string ncc = (comboBox2.SelectedItem == null || comboBox2.SelectedItem.Equals("(Tất cả)") ? "" : comboBox2.SelectedItem.ToString());
     string ContentSearch = (textBox3.Text != null ? textBox3.Text : "");
     int temp = 0;
     bool IsNummeric = (textBox3.Text != null ? int.TryParse(textBox3.Text, out temp) : false);
     lstSanpham = SanphamController.Search(ContentSearch, lsp, ncc, IsNummeric);
     dataGridView1.DataSource = lstSanpham;
 }
        private void hienthiLoaiSanpham()
        {
            List <LoaiSanphamModel> glstLoaiSanpham = new SanphamController().LoaiSanphamGetbyPK(0);

            glstLoaiSanpham.Sort((lsp1, lsp2) => lsp1.sTenLoaiSanpham.CompareTo(lsp2.sTenLoaiSanpham));
            ddlLoaiSanpham.DataSource     = glstLoaiSanpham;
            ddlLoaiSanpham.DataTextField  = "sTenLoaiSanpham";
            ddlLoaiSanpham.DataValueField = "PK_iLoaiSanphamID";
            ddlLoaiSanpham.DataBind();
            ddlLoaiSanpham.Items.Insert(0, new ListItem("Tất cả", "0"));
        }
Exemple #9
0
        private void hienthiLoaisanpham()
        {
            List <LoaiSanphamModel> glstLoaiSanpham = new SanphamController().LoaiSanphamGetbyPK(0);

            glstLoaiSanpham = glstLoaiSanpham.FindAll(lsp => !lsp.IsNgungKinhdoanh);
            glstLoaiSanpham.Sort((lsp1, lsp2) => lsp1.sTenLoaiSanpham.CompareTo(lsp2.sTenLoaiSanpham));
            ddlLoaiSanpham.DataSource     = glstLoaiSanpham;
            ddlLoaiSanpham.DataTextField  = "sTenLoaiSanpham";
            ddlLoaiSanpham.DataValueField = "PK_iLoaiSanphamID";
            ddlLoaiSanpham.DataBind();
        }
Exemple #10
0
        private void hienthiDulieuKhiSuaSanpham()
        {
            ltrThemSuaSanpham.Text               = "Cập nhật thông tin sản phẩm";
            panelNgungcungcap.Visible            = true;
            btnThemSanpham.Visible               = false;
            btnCapnhatSanpham.Visible            = true;
            lblLoaiSanphamNayNgungkinhdoanh.Text = string.Empty;
            long sanphamID = Convert.ToInt64(Request.QueryString[m_QUERYSUA]);

            if (sanphamID < 1)
            {
                throw new ApplicationException("Mã sản phẩm không hợp lệ.");
            }
            SanphamController   BrlSanpham  = new SanphamController();
            List <SanphamModel> glstSanpham = BrlSanpham.SanphamGetbyPK(sanphamID);

            if (glstSanpham.Count < 1)
            {
                throw new ApplicationException("Sản phẩm cần sửa không tồn tại.");
            }
            txtTensanpham.Text       = glstSanpham[0].sTenSanpham;
            txtXuatxu.Text           = glstSanpham[0].sXuatxu;
            txtMota.Text             = glstSanpham[0].sMota;
            privewimg.ImageUrl       = string.Format("~/{0}", glstSanpham[0].sHinhanh);
            cbIsNgungcungcap.Checked = glstSanpham[0].isNgungcungcap;
            hienthiLoaisanpham();
            int loaiSanphamID = glstSanpham[0].FK_iLoaiSanphamID;

            if (loaiSanphamID > 0)
            {
                List <LoaiSanphamModel> glstLoaiSanpham = BrlSanpham.LoaiSanphamGetbyPK(loaiSanphamID);
                if (glstLoaiSanpham.Count > 0)
                {
                    if (glstLoaiSanpham[0].IsNgungKinhdoanh)
                    {
                        lblLoaiSanphamNayNgungkinhdoanh.Text = string.Format("Thông báo: Loại sản phẩm <b>\"{0}\"</b> đã ngừng kinh doanh,<br>nếu cập nhật sản phẩm này sẽ chuyển sang loại sản phẩm được chọn.", glstLoaiSanpham[0].sTenLoaiSanpham);
                    }
                    ddlLoaiSanpham.ClearSelection();
                    ListItem itemLoaisanpham = ddlLoaiSanpham.Items.FindByValue(loaiSanphamID.ToString());
                    if (itemLoaisanpham != null)
                    {
                        itemLoaisanpham.Selected = true;
                    }
                }
            }
        }
 private void InitData()
 {
     dataGridView1.AutoGenerateColumns = false;
     lstSanpham = SanphamController.ViewAll();
     dataGridView1.DataSource = lstSanpham;
     lstLoaisanpham = LoaisanphamController.ViewAll();
     foreach (LoaiSanPham lsp in lstLoaisanpham)
     {
         comboBox1.Items.Add(lsp.Tenloaisanpham);
     }
     lstNhacungcap = NhacungcapController.ViewAll();
     foreach (Nhacungcap ncc in lstNhacungcap)
     {
         comboBox2.Items.Add(ncc.Tennhacungcap);
     }
     comboBox1.SelectedIndex = 0;
     comboBox2.SelectedIndex = 0;
 }
Exemple #12
0
        protected void btnCapnhatSanpham_Click(object sender, EventArgs e)
        {
            long sanphamID = Convert.ToInt64(Request.QueryString[m_QUERYSUA]);

            try
            {
                lblRgexSanpham.Text      = string.Empty;
                lblRegexUploadImage.Text = string.Empty;
                string tenSP = txtTensanpham.Text;
                string mota  = txtMota.Text;
                if (string.IsNullOrEmpty(mota))
                {
                    mota = string.Empty;
                }
                string            xuatxu     = txtXuatxu.Text;
                string            hinhanh    = "hinhanhtest";
                int               loaispID   = Convert.ToInt32(ddlLoaiSanpham.SelectedValue);
                SanphamController brlSanpham = new SanphamController();
                brlSanpham.ValidateSanpham(sanphamID, tenSP, mota, xuatxu, hinhanh, loaispID);
                try
                {
                    hinhanh = Luuhinhanh(hdImageUpload);
                }
                catch (Exception)
                {
                    lblRegexUploadImage.Text = "Vui lòng chọn tệp hành ảnh với phần mở rộng là png,jpg,jpeg.";
                    return;
                }
                if (string.IsNullOrEmpty(hinhanh))
                {
                    hinhanh = "hinhanhtest";
                }
                brlSanpham.SuaSanpham(sanphamID, tenSP, mota, xuatxu, hinhanh, loaispID, cbIsNgungcungcap.Checked);
                hienthiDulieuKhiSuaSanpham();
                Response.Write(@"<script language='javascript'>alert('Cập nhật thành công.');</script>");
            }
            catch (ApplicationException ex)
            {
                lblRgexSanpham.Text = ex.Message;
            }
        }
Exemple #13
0
        private void hienthiThongtinSanpham(long sanphamID)
        {
            SanphamController   BRLsanpham  = new SanphamController();
            List <SanphamModel> glstSanpham = BRLsanpham.SanphamGetbyPK(sanphamID);

            if (glstSanpham.Count < 1)
            {
                Response.Redirect("~/DanhsachSanpham.aspx");
            }
            int loaispID = glstSanpham[0].FK_iLoaiSanphamID;

            if (loaispID > 0)
            {
                List <LoaiSanphamModel> glstLoaiSanpham = BRLsanpham.LoaiSanphamGetbyPK(loaispID);
                if (glstSanpham.Count > 0)
                {
                    lblLoaiSanpham.Text = glstLoaiSanpham[0].sTenLoaiSanpham;
                }
            }
            imageSanpham.ImageUrl = string.Format("~/{0}", glstSanpham[0].sHinhanh);
            lblTenSanpham.Text    = glstSanpham[0].sTenSanpham;
        }
Exemple #14
0
 protected void btnThemSanpham_Click(object sender, EventArgs e)
 {
     try
     {
         lblRgexSanpham.Text      = string.Empty;
         lblRegexUploadImage.Text = string.Empty;
         string tenSP = txtTensanpham.Text;
         string mota  = txtMota.Text;
         if (string.IsNullOrEmpty(mota))
         {
             mota = string.Empty;
         }
         string            xuatxu     = txtXuatxu.Text;
         string            hinhanh    = string.IsNullOrEmpty(hdImageUpload.Value) ? string.Empty : "hinhanhtest";
         int               loaispID   = Convert.ToInt32(ddlLoaiSanpham.SelectedValue);
         SanphamController brlSanpham = new SanphamController();
         brlSanpham.ValidateSanpham(0, tenSP, mota, xuatxu, hinhanh, loaispID);
         try
         {
             hinhanh = Luuhinhanh(hdImageUpload);
         }
         catch (Exception)
         {
             lblRegexUploadImage.Text = "Vui lòng chọn tệp hành ảnh với phần mở rộng là png,jpg,jpeg.";
             return;
         }
         if (string.IsNullOrEmpty(hinhanh))
         {
             lblRegexUploadImage.Text = "Vui lòng chọn tệp hành ảnh với phần mở rộng là png,jpg,jpeg.";
             return;
         }
         brlSanpham.ThemSanpham(tenSP, mota, xuatxu, hinhanh, loaispID);
         Response.Write(@"<script language='javascript'>alert('Thêm sản phẩm thành công.');</script>");
     }
     catch (ApplicationException ex)
     {
         lblRgexSanpham.Text = ex.Message;
     }
 }
 protected void rptKhuyenmaiCuaSanpham_ItemCommand(object source, RepeaterCommandEventArgs e)
 {
     if (e.CommandName.Equals("SuaKhuyenmai"))
     {
         lblRegexKhuyenmaiSanpham.Text = string.Empty;
         long khuyenmaiID = Convert.ToInt64(e.CommandArgument);
         if (khuyenmaiID <= 0)
         {
             return;
         }
         panelSuakhuyenmai.Visible = true;
         btnThemKhuyenmai.Visible  = false;
         ltrThemSuaKhuyenmai.Text  = "Chỉnh sửa khuyến mại cho sản phẩm:";
         List <KhuyenmaiModel> glstKhuyenmai = new SanphamController().GetKhuyenmaiByPK(khuyenmaiID);
         if (glstKhuyenmai.Count > 0)
         {
             txtKhuyenmai.Attributes.Add("data-khuyenmai", glstKhuyenmai[0].PK_iKhuyenmaiID.ToString());
             txtKhuyenmai.Text   = Convert.ToInt32((glstKhuyenmai[0].fKhuyenmai * 100)).ToString();
             txtNgayapdung.Text  = string.Format("{0:yyyy-MM-ddTHH:mm}", glstKhuyenmai[0].tNgaybatdau);
             txtNgayKetthuc.Text = string.Format("{0:yyyy-MM-ddTHH:mm}", glstKhuyenmai[0].tNgayketthuc);
         }
     }
     if (e.CommandName.Equals("XoaKhuyenmai"))
     {
         long khuyenmaiID = Convert.ToInt64(e.CommandArgument);
         if (khuyenmaiID <= 0)
         {
             return;
         }
         new SanphamController().XoaKhuyenmai(khuyenmaiID);
         long sanphamID = 0;
         long.TryParse(Request.QueryString[QUERYKHUYENMAI], out sanphamID);
         if (sanphamID > 0)
         {
             hienthiKhuyenmaiCuaSanpham(sanphamID);
         }
     }
 }
Exemple #16
0
 protected void rptGiaCuaSanpham_ItemCommand(object source, RepeaterCommandEventArgs e)
 {
     if (e.CommandName.Equals("Suagia"))
     {
         lblRegexThemgiaSanpham.Text = string.Empty;
         long banggiaID = Convert.ToInt64(e.CommandArgument);
         if (banggiaID <= 0)
         {
             return;
         }
         panelSuagia.Visible = true;
         btnThemgia.Visible  = false;
         ltrThemSuaGia.Text  = "Cập nhật giá sản phẩm:";
         List <BanggiaModel> glstBanggia = new SanphamController().GetBanggiaByPK(banggiaID);
         if (glstBanggia.Count > 0)
         {
             txtGia.Attributes.Add("data-bangia", glstBanggia[0].PK_iBanggiaID.ToString());
             txtGia.Text        = (glstBanggia[0].mGia / 1000).ToString();
             txtNgayapdung.Text = string.Format("{0:yyyy-MM-ddTHH:mm}", glstBanggia[0].tNgaybatdauapdung);
         }
     }
     if (e.CommandName.Equals("Xoagia"))
     {
         long banggiaID = Convert.ToInt64(e.CommandArgument);
         if (banggiaID <= 0)
         {
             return;
         }
         new SanphamController().XoaBanggia(banggiaID);
         long sanphamID = 0;
         long.TryParse(Request.QueryString[QUERYGIA], out sanphamID);
         if (sanphamID > 0)
         {
             hienthiGiaCuaSanpham(sanphamID);
         }
     }
 }