Пример #1
0
        private void btnThem_Click(object sender, EventArgs e)
        {
            if (txtHangSanXuat.Text.Length == 0)
            {
                MessageBox.Show("Chưa Nhập Dữ Liệu!");
                return;
            }
            HANG_SAN_XUAT hsx = HangSanXuat.LayHangSanXuat(txtHangSanXuat.Text);

            if (hsx != null)
            {
                MessageBox.Show("Dữ Liệu Tồn Tại!");
                return;
            }
            hsx      = new HANG_SAN_XUAT();
            hsx.HANG = txtHangSanXuat.Text;
            if (HangSanXuat.ThemHangSanXuat(hsx))
            {
                MessageBox.Show("Thêm Thành Công!");
                LoadThongTin();
                txtHangSanXuat.Text = "";
            }
            else
            {
                MessageBox.Show("Thêm Thất Bại!");
            }
        }
Пример #2
0
 public ActionResult ThemMoi([Bind(Include = "TenHangSanXuat")] HangSanXuat hsxuat, HttpPostedFileBase upload)
 {
     if (Session["DangNhapAdmin"] == null)
     {
         return(RedirectToAction("Index", "DangNhap"));
     }
     if (ModelState.IsValid)
     {
         string logoPath = "";
         if (upload != null && upload.ContentLength > 0)
         {
             string extension = Path.GetFileNameWithoutExtension(upload.FileName);
             string timeUTC   = DateTime.Now.ToFileTimeUtc().ToString();
             string a         = upload.FileName.Replace(extension, timeUTC);
             logoPath = Path.GetFileName(a);
             upload.SaveAs(Path.Combine(Server.MapPath("~/Images/Logo/") + logoPath));
         }
         hsxuat.BiXoa   = 0;
         hsxuat.LogoURL = logoPath;
         db.HangSanXuats.Add(hsxuat);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(hsxuat));
 }
Пример #3
0
 protected void btnLuu_Click(object sender, EventArgs e)
 {
     try
     {
         if (txtHangSanXuat.Text.Trim() != "")
         {
             HangSanXuat hsx = new HangSanXuat();
             if (Request.QueryString["hid"] == null)
             {
                 hsx.InsertFields(txtHangSanXuat.Text, txtThongTin.Text, null, null, null, null);
             }
             else
             {
                 hsx.UpdateFields(Convert.ToInt32(Request.QueryString["hid"]),
                                  txtHangSanXuat.Text, txtThongTin.Text, null, null, null, null);
             }
             Cache.Remove("hsx");
             string strScript = "<script language='JavaScript'>" + "window.parent.Refresh();</script>";
             ClientScript.RegisterStartupScript(GetType(), "Refresh", strScript);
         }
     }
     catch (Exception ex)
     {
         Response.Write(ex.ToString());
     }
 }
Пример #4
0
 public static void UpdateManufacturer(HangSanXuat hsx)
 {
     using (var db = new ShopConnectionDB())
     {
         db.Update <HangSanXuat>("SET TenHangSanXuat=@0 WHERE MaHangSanXuat=@1", hsx.TenHangSanXuat, hsx.MaHangSanXuat);
     }
 }
Пример #5
0
        private void btnLuu_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            // Thêm mới
            if (item == null)
            {
                item = new HangSanXuat
                {
                    Ten = txtTen.Text
                };

                lspBLL.Them(item);
                this.Close();

                if (from != null)
                {
                    (from as frmDanhSachHSX).CapNhat();
                    from.Focus();
                }

                MessageBox.Show("Thêm thành công.", "Thông báo");
                return;
            }

            item.Ten = txtTen.Text;
            lspBLL.Sua(item);

            (from as frmDanhSachHSX).CapNhat();
            from.Focus();

            MessageBox.Show("Sửa thành công.", "Thông báo");
        }
Пример #6
0
        public ActionResult DeleteConfirmed(int id)
        {
            HangSanXuat hangSanXuat = db.HangSanXuats.Find(id);

            db.HangSanXuats.Remove(hangSanXuat);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public FormThayDoiChiTietSanPham()
 {
     InitializeComponent();
     cbbHangSanXuat.DataSource    = new BindingList <HANG_SAN_XUAT>(HangSanXuat.LayHangSanXuat());
     cbbHangSanXuat.DisplayMember = "HANG";
     cbbHangSanXuat.ValueMember   = "MA_HANG";
     LoadThongTin();
 }
Пример #8
0
        public void AddRows(DataGridView dgvHangSanXuat)
        {
            dgvHangSanXuat.DataSource = null;
            HangSanXuat lspMoi = new HangSanXuat();

            lstHangSanXuat.Add(lspMoi);
            dgvHangSanXuat.DataSource = lstHangSanXuat;
        }
Пример #9
0
    private void LoadData()
    {
        HangSanXuat hsx = new HangSanXuat();
        DataSet ds = hsx.SelectAll();

        grdHangSanXuat.DataSource = ds.Tables[0];
        grdHangSanXuat.DataBind();
    }
Пример #10
0
        public override void Them(string data)
        {
            HangSanXuat hang  = new HangSanXuat(data);
            string      query = "Insert into NhaSanXuat (MaNSX,TenHSX,QuocGia) values(" + hang.MaHangSX + ", " +
                                hang.TenHangSX + ", " + hang.QuocGia;

            thaoTacDuLieu(query);
        }
Пример #11
0
 public ActionResult Edit([Bind(Include = "MaHSX,TenHSX")] HangSanXuat hangSanXuat)
 {
     if (ModelState.IsValid)
     {
         db.Entry(hangSanXuat).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(hangSanXuat));
 }
Пример #12
0
        private int GetMaHangSanXuat(string tenHSX)
        {
            using (CSDLQuanLyQuanAoDataContext db = new CSDLQuanLyQuanAoDataContext())
            {
                HangSanXuat lsp = db.HangSanXuats.Where(p => p.TenHangSanXuat.Equals(tenHSX)).SingleOrDefault();

                // MessageBox.Show(lsp.MaLoaiSanPham + "");
                return(lsp.MaHangSanXuat);
            }
        }
        public string GetLastMaHangSanXuats()
        {
            HangSanXuat hsx = qlhh.HangSanXuats.Where(t => t.MaHangSanXuat == "HSX001").FirstOrDefault();

            if (hsx == null)
            {
                return("HSX001");
            }
            return(qlhh.HangSanXuats.OrderByDescending(t => t.MaHangSanXuat).FirstOrDefault().MaHangSanXuat);
        }
Пример #14
0
        internal void EditHangSX(HangSanXuat loai)
        {
            var lsp = db.HangSanXuats.Find(loai.Id);

            lsp.TenHang         = loai.TenHang;
            lsp.TruSoChinh      = loai.TruSoChinh;
            lsp.QuocGia         = loai.QuocGia;
            db.Entry(lsp).State = EntityState.Modified;
            db.SaveChanges();
        }
        public ActionResult ThemHangSX([Bind(Include = "TenHang,TruSoChinh,QuocGia")] HangSanXuat loai)
        {
            HangSanXuatModel spm = new HangSanXuatModel();

            if (ModelState.IsValid && spm.KiemTraTen(loai.TenHang))
            {
                string maloai = spm.ThemHangSX(loai);
                return(View("Index"));
            }
            return(View("Index", loai));
        }
Пример #16
0
 public void Them(int maHSX, string tenHSX)
 {
     using (CSDLQuanLyQuanAoDataContext db = new CSDLQuanLyQuanAoDataContext())
     {
         HangSanXuat hangSX = new HangSanXuat();
         hangSX.MaHangSanXuat  = maHSX;
         hangSX.TenHangSanXuat = tenHSX;
         db.HangSanXuats.InsertOnSubmit(hangSX);
         db.SubmitChanges();
     }
 }
Пример #17
0
        public ActionResult Create([Bind(Include = "MaHSX,TenHSX")] HangSanXuat hangSanXuat)
        {
            if (ModelState.IsValid)
            {
                db.HangSanXuats.Add(hangSanXuat);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(hangSanXuat));
        }
        public ActionResult EditHangSX([Bind(Include = "HangSX,TenHang,TruSoChinh,QuocGia")] HangSanXuat loai)
        {
            HangSanXuatModel spm = new HangSanXuatModel();

            if (ModelState.IsValid)
            {
                spm.EditHangSX(loai);
                return(RedirectToAction("Index"));
            }
            return(View(loai));
        }
        //thay đổi catefory
        //Hiện thị cate cần thay đổi
        public ActionResult EditCat(int CatID)
        {
            HangSanXuat hang = null;

            using (var pro = new MobileShopEntities())
            {
                hang = pro.HangSanXuats
                       .Where(p => p.ID == CatID)
                       .FirstOrDefault();
            }
            return(View(hang));
        }
Пример #20
0
        public ActionResult Chitiethsx(int id)
        {
            HangSanXuat hsx = db.HangSanXuats.SingleOrDefault(n => n.MaNsx == id);

            ViewBag.MaNsx = hsx.MaNsx;
            if (hsx == null)
            {
                Response.StatusCode = 404;
                return(null);
            }
            return(View(hsx));
        }
        public ActionResult EditHangSX([Bind(Include = "HangSX,TenHang,TruSoChinh,QuocGia")] HangSanXuat loai)
        {
            HangSanXuatModel spm = new HangSanXuatModel();

            if (ModelState.IsValid && spm.KiemTraTen(loai.TenHang))
            {
                TempData["EditSuccess"] = "Oke";
                spm.EditHangSX(loai);
                return(RedirectToAction("Index"));
            }
            TempData["ErrorEdit"] = "Lỗi";
            return(View(loai));
        }
        public ActionResult ThemHangSX([Bind(Include = "TenHang,TruSoChinh,QuocGia")] HangSanXuat loai)
        {
            HangSanXuatModel spm = new HangSanXuatModel();

            if (ModelState.IsValid && spm.KiemTraTen(loai.TenHang))
            {
                TempData["AddSuccess"] = "oke";
                string maloai = spm.ThemHangSX(loai);
                return(View("Index"));
            }
            TempData["ErrorAdd"] = "Lỗi";
            return(View("Index", loai));
        }
Пример #23
0
 public ActionResult Create(HangSanXuat hsx)
 {
     try
     {
         // TODO: Add insert logic here
         _1461467DAWEB.Areas.Admin.Models.Manufacturer.insertManufacturer(hsx);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Пример #24
0
        public void Sua(int ma, string ten)
        {
            using (CSDLQuanLyQuanAoDataContext db = new CSDLQuanLyQuanAoDataContext())
            {
                HangSanXuat hangSX = db.HangSanXuats.Where(p => p.MaHangSanXuat == ma).SingleOrDefault();

                if (hangSX != null)
                {
                    hangSX.TenHangSanXuat = ten;
                    db.SubmitChanges();
                }
            }
        }
Пример #25
0
        public ActionResult HienThiSanPhamTheoHang(int id, int?page)
        {
            Session["a"] = "TheoHang";

            var         lst  = db.SanPhams.Where(s => s.BiXoa == 0 && s.MaHangSanXuat == id).OrderBy(s => s.MaSanPham);
            HangSanXuat hang = db.HangSanXuats.Single(l => l.MaHangSanXuat == id);

            ViewBag.TieuDe = "Danh sách sản phẩm theo Hãng " + hang.TenHangSanXuat;
            int pageNumber = (page ?? 1);
            int pageSize   = 12;

            return(View("DanhSachSanPham", lst.ToPagedList(pageNumber, pageSize)));
        }
Пример #26
0
        // GET: HangSanXuats/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            HangSanXuat hangSanXuat = db.HangSanXuats.Find(id);

            if (hangSanXuat == null)
            {
                return(HttpNotFound());
            }
            return(View(hangSanXuat));
        }
        public int deleteHangSanXuat(string maSX)
        {
            HangSanXuat hsx = qlhh.HangSanXuats.Where(t => t.MaHangSanXuat == maSX).FirstOrDefault();

            if (hsx != null)
            {
                qlhh.HangSanXuats.DeleteOnSubmit(hsx);
                qlhh.SubmitChanges();
                return(1);
            }
            else
            {
                return(0);
            }
        }
        public int updateHangSanXuat(string maSX, string tenNSX)
        {
            HangSanXuat hsx = qlhh.HangSanXuats.Where(t => t.MaHangSanXuat == maSX).FirstOrDefault();

            if (hsx != null)
            {
                hsx.TenHangSanXuat = tenNSX;
                qlhh.SubmitChanges();
                return(1);
            }
            else
            {
                return(0);
            }
        }
Пример #29
0
        public ActionResult HienThiSanPhamTheoHang(int id, int?page)
        {
            if (Session["BiKhoa"] != null)
            {
                return(RedirectToAction("LogOffs", "Account"));
            }
            var         lst  = db.SanPhams.Where(s => s.BiXoa == 0 && s.MaHangSanXuat == id).OrderBy(s => s.MaSanPham);
            HangSanXuat hang = db.HangSanXuats.Single(l => l.MaHangSanXuat == id);

            ViewBag.TieuDe = "Danh sách sản phẩm theo Hãng " + hang.TenHangSanXuat;
            int pageNumber = (page ?? 1);
            int pageSize   = 4;

            return(View("DanhSachSanPham", lst.ToPagedList(pageNumber, pageSize)));
        }
        public ActionResult EditHangSX(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            HangSanXuatModel lm = new HangSanXuatModel();
            HangSanXuat      sp = lm.FindById(id);

            if (sp == null)
            {
                return(HttpNotFound());
            }
            return(View(sp));
        }
Пример #31
0
        public ActionResult xacnhanxoahsx(int id)
        {
            HangSanXuat hsx = db.HangSanXuats.SingleOrDefault(n => n.MaNsx == id);

            ViewBag.MaNsx = hsx.MaNsx;
            if (hsx == null)
            {
                Response.StatusCode = 404;
                return(null);
            }

            db.HangSanXuats.DeleteOnSubmit(hsx);
            db.SubmitChanges();
            return(RedirectToAction("HangSanXuat"));
        }
Пример #32
0
 public bool Xoa(int ma)
 {
     try
     {
         using (CSDLQuanLyQuanAoDataContext db = new CSDLQuanLyQuanAoDataContext())
         {
             HangSanXuat hangSX = db.HangSanXuats.Where(p => p.MaHangSanXuat == ma).SingleOrDefault();
             db.HangSanXuats.DeleteOnSubmit(hangSX);
             db.SubmitChanges();
             return(true);
         }
     }
     catch
     {
         return(false);
     }
 }
Пример #33
0
    private void LoadData(string Id)
    {
        try
        {
            HangSanXuat hsx = new HangSanXuat();
            DataSet ds = hsx.SelectByID(Convert.ToInt32(Id));

            if (ds.Tables[0].Rows.Count > 0)
            {
                txtHangSanXuat.Text = ds.Tables[0].Rows[0]["TenHangSanXuat"].ToString();
                txtThongTin.Text = ds.Tables[0].Rows[0]["ThongTin"].ToString();
            }
        }
        catch (Exception ex)
        {
            Response.Write(ex.ToString());
        }
    }
Пример #34
0
        public static ArrayList LayChiTietHangSX(string mh)
        {
            ArrayList list = new ArrayList();
            string query = String.Format("SELECT * FROM HangSanXuat WHERE Status = 1 and MaHSX = '" + mh + "'");

            try
            {
                conn.Open();
                command.CommandText = query;
                SqlDataReader reader = command.ExecuteReader();

                while (reader.Read())
                {
                    int id = reader.GetInt32(0);
                    string mahangsx = reader.GetString(1);
                    string tenhangsx = reader.GetString(2);
                    int status = reader.GetInt32(3);
                    string hinhhsx = reader.GetString(4);
                    HangSanXuat hangsanxuat = new HangSanXuat(id, mahangsx, tenhangsx, status, hinhhsx);
                    list.Add(hangsanxuat);
                }
            }
            finally
            {
                conn.Close();
            }

            return list;
        }
Пример #35
0
    protected void btnXoa_Click(object sender, EventArgs e)
    {
        try
        {
            switch (ViewState["TYPE"].ToString())
            {
                case "thuoctinh":
                    if (Common.LoaiNguoiDungID() == 3)
                    {
                        ThuocTinh tt = new ThuocTinh();
                        tt.Delete(id);
                    }
                    else
                    {
                        Response.Redirect("../message.aspx?msg=Access denied");
                    }
                    break;
                case "nhomsanpham":
                    if (Common.LoaiNguoiDungID() == 3)
                    {
                        NhomSanPham nhomsanpham = new NhomSanPham();
                        nhomsanpham.Delete(id);
                    }
                    else
                    {
                        Response.Redirect("../message.aspx?msg=Access denied");
                    }
                    break;
                case "vitrisanpham":
                    if ((Common.LoaiNguoiDungID() == 3) || (Common.LoaiNguoiDungID() == 2))
                    {
                        ViTriSanPham vtsp = new ViTriSanPham();
                        vtsp.Delete(id);
                    }
                    else
                    {
                        Response.Redirect("../message.aspx?msg=Access denied");
                    }
                    break;
                case "cuahangnhomsanpham":
                    if (Common.LoaiNguoiDungID() == 2)
                    {
                        deleteCuaHangNhomSanPham(id);
                    }
                    else
                    {
                        Response.Redirect("../message.aspx?msg=Access denied");
                    }
                    break;
                case "nhomsanphamcuahang":
                    if (Common.LoaiNguoiDungID() == 2)
                    {
                        deleteNhomSanPhamCuaHang(id);
                    }
                    else
                    {
                        Response.Redirect("../message.aspx?msg=Access denied");
                    }
                    break;

                case "nhanxetsanpham":
                    if (Common.LoaiNguoiDungID() != 1)
                    {
                        NhanXetSanPham nhanxet = new NhanXetSanPham();
                        nhanxet.Delete(id);
                    }
                    else
                    {
                        Response.Redirect("../message.aspx?msg=Access denied");
                    }
                    break;
                case "tintuc":
                    if ((Common.LoaiNguoiDungID() == 3) || (Common.LoaiNguoiDungID() == 2))
                    {
                        TinTuc tt = new TinTuc();
                        tt.Delete(id);
                    }
                    else
                    {
                        Response.Redirect("../message.aspx?msg=Access denied");
                    }
                    break;
                case "hotrotructuyen":
                    if ((Common.LoaiNguoiDungID() == 3) || (Common.LoaiNguoiDungID() == 2))
                    {
                        HoTroTrucTuyen ht = new HoTroTrucTuyen();
                        ht.Delete(id);
                    }
                    else
                    {
                        Response.Redirect("../message.aspx?msg=Access denied");
                    }
                    break;
                case "hoidapsanpham":
                    if (Common.LoaiNguoiDungID() != 1)
                    {
                        HoiDapSanPham hoidap = new HoiDapSanPham();
                        hoidap.Delete(id);
                    }
                    else
                    {
                        Response.Redirect("../message.aspx?msg=Access denied");
                    }
                    break;
                case "nguoidung":
                    if (Common.LoaiNguoiDungID() == 3)
                    {
                        if (CheckExistCuaHang(id) != true)
                        {
                            NguoiDung nguoidung = new NguoiDung();
                            nguoidung.Delete(id);
                        }
                        else
                        {
                            Response.Redirect("../message.aspx?msg=Không thể xóa người dùng đã có cửa hàng", false);
                        }
                    }
                    else
                    {
                        Response.Redirect("../message.aspx?msg=Access denied");
                    }
                    break;
                case "hangsanxuat":
                    if (Common.LoaiNguoiDungID() == 3)
                    {
                        HangSanXuat hsx = new HangSanXuat();
                        hsx.Delete(id);
                    }
                    else
                    {
                        Response.Redirect("../message.aspx?msg=Access denied");
                    }
                    break;
                case "khuvuc":
                    if (Common.LoaiNguoiDungID() == 3)
                    {
                        KhuVuc kv = new KhuVuc();
                        kv.Delete(id);
                    }
                    else
                    {
                        Response.Redirect("../message.aspx?msg=Access denied");
                    }
                    break;
                case "quangcao":
                    if (Common.LoaiNguoiDungID() == 2 || Common.LoaiNguoiDungID() == 3)
                    {
                        QuangCao qcao = new QuangCao();
                        DataSet ds = qcao.SelectByQuangCaoID(id);
                        if (ds.Tables[0].Rows.Count == 1)
                        {
                            if (Common.LoaiNguoiDungID() == 3)
                            {
                                //Administrator
                                if (ds.Tables[0].Rows[0]["LoaiNguoiDungID"].ToString() == "3") qcao.Delete(id);
                            }
                            else
                            {
                                //e-Store
                                if (ds.Tables[0].Rows[0]["LoaiNguoiDungID"].ToString() == "2"
                                    && ds.Tables[0].Rows[0]["NguoiDungID"].ToString() == Common.NguoiDungID().ToString())
                                    qcao.Delete(id);
                            }
                        }
                    }
                    else
                    {
                        Response.Redirect("../message.aspx?msg=Access denied");
                    }
                    break;
                case "sanpham":
                    {
                        SanPham sanpham = new SanPham();
                        DataSet dssp = sanpham.SelectBySanPhamID(id);
                        if (Common.LoaiNguoiDungID() == 2)
                        {
                            if (dssp.Tables[0].Rows.Count == 1)
                            {
                                //e-Store
                                if (dssp.Tables[0].Rows[0]["LoaiNguoiDungID"].ToString() ==
                                    Common.LoaiNguoiDungID().ToString()
                                    &&
                                    dssp.Tables[0].Rows[0]["NguoiDungID"].ToString() == Common.NguoiDungID().ToString())
                                {
                                    sanpham.Delete(id);
                                }
                            }
                        }
                        else if (Common.LoaiNguoiDungID() == 3)
                        {
                            if (dssp.Tables[0].Rows.Count == 1)
                            {
                                sanpham.Delete(id);
                            }
                        }
                        else
                        {
                            Response.Redirect("../message.aspx?msg=Access denied");
                        }
                    }
                    break;
                case "sanphammau":
                    {
                        SanPhamMau sanpham = new SanPhamMau();
                        DataSet dssp = sanpham.SelectByID(id);
                        if (Common.LoaiNguoiDungID() == 3)
                        {
                            if (dssp.Tables[0].Rows.Count == 1)
                            {
                                sanpham.Delete(id);
                            }
                        }
                        else
                        {
                            Response.Redirect("../message.aspx?msg=Access denied");
                        }
                    }
                    break;
                case "anhsanpham":
                    if ((Common.LoaiNguoiDungID() == 2) || (Common.LoaiNguoiDungID() == 3))
                    {
                        Anh anhsanpham = new Anh();
                        DataSet dssp = anhsanpham.SelectByID(id);
                        if (dssp.Tables[0].Rows.Count == 1)
                        {
                            anhsanpham.Delete(id);

                            if (File.Exists(Server.MapPath(Request.QueryString["src"])))
                            {
                                File.Delete(Server.MapPath(Request.QueryString["src"]));
                            }
                        }
                    }
                    else
                    {
                        Response.Redirect("../message.aspx?msg=Access denied");
                    }
                    break;
            }
            string strScript = "<script language='JavaScript'>" + "window.parent.Refresh();</script>";
            ClientScript.RegisterStartupScript(Type.GetType("System.String"), "Refresh", strScript);
        }
        catch (Exception ex)
        {
            Response.Write(ex.ToString());
        }
    }
Пример #36
0
    private void LoadHangSanXuat()
    {
        HangSanXuat hsx = new HangSanXuat();
        DataSet ds;
        if (Cache["hsx"] == null)
        {
            ds = hsx.SelectAll();
            Cache.Insert("hsx", ds);
        }
        else
        {
            ds = (DataSet) Cache["hsx"];
        }
        ddlHangSanXuat.DataSource = ds.Tables[0];
        ddlHangSanXuat.DataTextField = "TenHangSanXuat";
        ddlHangSanXuat.DataValueField = "HangSanXuatID";
        ddlHangSanXuat.DataBind();

        ddlHangSanXuat.Items.Insert(0, "Tất cả");
        ddlHangSanXuat.Items[0].Value = "0";
    }
Пример #37
0
    private void LoadHangSanXuat()
    {
        HangSanXuat hsx = new HangSanXuat();
        DataSet ds = hsx.SelectAll();

        ddlHangSanXuat.DataSource = ds.Tables[0];
        ddlHangSanXuat.DataTextField = "TenHangSanXuat";
        ddlHangSanXuat.DataValueField = "HangSanXuatID";
        ddlHangSanXuat.DataBind();

        ddlHangSanXuat.Items.Insert(0, "Tất cả");
        ddlHangSanXuat.Items[0].Value = "0";
    }
Пример #38
0
    private void LoadDropDownDaTa()
    {
        try
        {
            HangSanXuat hangsanxuat = new HangSanXuat();
            DataSet dsHangSanXuat = hangsanxuat.SelectAll();
            if (Cache["hsx"] == null)
            {
                dsHangSanXuat = hangsanxuat.SelectAll();
                Cache.Insert("hsx", dsHangSanXuat);
            }
            else
            {
                dsHangSanXuat = (DataSet) Cache["hsx"];
            }
            DataTable dtHangSanXuat = dsHangSanXuat.Tables[0];

            ddlHangSanXuat.DataSource = dtHangSanXuat;
            ddlHangSanXuat.DataTextField = "TenHangSanXuat";
            ddlHangSanXuat.DataValueField = "HangSanXuatID";
            ddlHangSanXuat.DataBind();

            KhuVuc khuvuc = new KhuVuc();
            DataSet dsKhuVuc;

            if (Cache["kv"] == null)
            {
                dsKhuVuc = khuvuc.SelectAll();
                Cache.Insert("kv", dsKhuVuc);
            }
            else
            {
                dsKhuVuc = (DataSet) Cache["kv"];
            }

            DataTable dtKhuVuc = dsKhuVuc.Tables[0];

            ddlKhuVuc.DataSource = dtKhuVuc;
            ddlKhuVuc.DataTextField = "TenKhuVuc";
            ddlKhuVuc.DataValueField = "KhuVucID";
            ddlKhuVuc.DataBind();
        }
        catch (Exception ex)
        {
            Response.Write(ex.ToString());
        }
    }
Пример #39
0
    private void loadSearchDropdown()
    {
        ddlDanhMuc.Items.Clear();
        NhomSanPham nhomsanpham = new NhomSanPham();
        DataSet ds = nhomsanpham.SelectNhomSanPhamByNhomChaID(0);

        ddlDanhMuc.Items.Insert(0, "Tất cả");
        ddlDanhMuc.Items[0].Value = "";

        int n = ddlDanhMuc.SelectedIndex;

        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
        {
            ListItem item = new ListItem("+ " + ds.Tables[0].Rows[i]["TenNhomSanPham"],
                                         ds.Tables[0].Rows[i]["NhomSanPhamID"].ToString());
            ddlDanhMuc.Items.Add(item);
            DataSet subds =
                nhomsanpham.SelectNhomSanPhamByNhomChaID(int.Parse(ds.Tables[0].Rows[i]["NhomSanPhamID"].ToString()));
            for (int j = 0; j < subds.Tables[0].Rows.Count; j++)
            {
                ListItem subitem = new ListItem("+.... " + subds.Tables[0].Rows[j]["TenNhomSanPham"],
                                                subds.Tables[0].Rows[j]["NhomSanPhamID"].ToString());
                ddlDanhMuc.Items.Add(subitem);
            }
        }

        HangSanXuat hsx = new HangSanXuat();
        DataSet dshsx = hsx.SelectAll();

        ddlHangSanXuat.DataSource = dshsx.Tables[0];
        ddlHangSanXuat.DataTextField = "TenHangSanXuat";
        ddlHangSanXuat.DataValueField = "HangSanXuatID";
        ddlHangSanXuat.DataBind();
        ddlHangSanXuat.Items.Insert(0, "Tất cả");
        ddlHangSanXuat.Items[0].Value = "";

        KhuVuc kv = new KhuVuc();
        DataSet dskv = kv.SelectAll();

        ddlKhuVuc.DataSource = dskv.Tables[0];
        ddlKhuVuc.DataTextField = "TenKhuVuc";
        ddlKhuVuc.DataValueField = "KhuVucID";
        ddlKhuVuc.DataBind();
        ddlKhuVuc.Items.Insert(0, "Tất cả");
        ddlKhuVuc.Items[0].Value = "";
    }
Пример #40
0
    private void LoadDropDownDaTa()
    {
        try
        {
            CuaHang ch = new CuaHang();
            DataSet dsch;
            string cacheCh = "ch" + Common.NguoiDungID();
            if (Cache[cacheCh] == null)
            {
                dsch = ch.SelectByNguoiDungID(Common.NguoiDungID());
                Cache.Insert(cacheCh, dsch);
            }
            else
            {
                dsch = (DataSet) Cache[cacheCh];
            }
            if (dsch.Tables[0].Rows.Count > 0)
            {
                LoadDanhMucConForDropDown(0, int.Parse(dsch.Tables[0].Rows[0]["CuaHangID"].ToString()), 0);
            }
            HangSanXuat hangsanxuat = new HangSanXuat();
            DataSet dsHangSanXuat = hangsanxuat.SelectAll();
            if (Cache["hsx"] == null)
            {
                dsHangSanXuat = hangsanxuat.SelectAll();
                Cache.Insert("hsx", dsHangSanXuat);
            }
            else
            {
                dsHangSanXuat = (DataSet) Cache["hsx"];
            }
            DataTable dtHangSanXuat = dsHangSanXuat.Tables[0];

            ddlHangSanXuat.DataSource = dtHangSanXuat;
            ddlHangSanXuat.DataTextField = "TenHangSanXuat";
            ddlHangSanXuat.DataValueField = "HangSanXuatID";
            ddlHangSanXuat.DataBind();

            KhuVuc khuvuc = new KhuVuc();
            DataSet dsKhuVuc;

            if (Cache["kv"] == null)
            {
                dsKhuVuc = khuvuc.SelectAll();
                Cache.Insert("kv", dsKhuVuc);
            }
            else
            {
                dsKhuVuc = (DataSet) Cache["kv"];
            }

            DataTable dtKhuVuc = dsKhuVuc.Tables[0];

            ddlKhuVuc.DataSource = dtKhuVuc;
            ddlKhuVuc.DataTextField = "TenKhuVuc";
            ddlKhuVuc.DataValueField = "KhuVucID";
            ddlKhuVuc.DataBind();
        }
        catch (Exception ex)
        {
            Response.Write(ex.ToString());
        }
    }
Пример #41
0
    private void loadSearchDropdown()
    {
        ddlDanhMuc.Items.Clear();
        NhomSanPham nhomsanpham = new NhomSanPham();
        DataSet ds = nhomsanpham.SelectNhomSanPhamByNhomChaID(0);

        ddlDanhMuc.Items.Insert(0, "Tất cả");
        ddlDanhMuc.Items[0].Value = "";

        int n = ddlDanhMuc.SelectedIndex;

        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
        {
            ListItem item = new ListItem("+ " + ds.Tables[0].Rows[i]["TenNhomSanPham"],
                                         ds.Tables[0].Rows[i]["NhomSanPhamID"].ToString());
            ddlDanhMuc.Items.Add(item);
            DataSet subds =
                nhomsanpham.SelectNhomSanPhamByNhomChaID(int.Parse(ds.Tables[0].Rows[i]["NhomSanPhamID"].ToString()));
            for (int j = 0; j < subds.Tables[0].Rows.Count; j++)
            {
                ListItem subitem = new ListItem("+.... " + subds.Tables[0].Rows[j]["TenNhomSanPham"],
                                                subds.Tables[0].Rows[j]["NhomSanPhamID"].ToString());
                ddlDanhMuc.Items.Add(subitem);
            }
        }

        //NhomSanPham nsp = new NhomSanPham();
        //DataSet dsnsp = nsp.SelectAll();

        //ddlDanhMuc.DataSource = dsnsp.Tables[0];
        //ddlDanhMuc.DataTextField = "TenNhomSanPham";
        //ddlDanhMuc.DataValueField = "NhomSanPhamID";
        //ddlDanhMuc.DataBind();
        //ddlDanhMuc.Items.Insert(0, "Tất cả");
        //ddlDanhMuc.Items[0].Value = "";

        HangSanXuat hangsanxuat = new HangSanXuat();
        DataSet dsHangSanXuat = hangsanxuat.SelectAll();
        if (Cache["hsx"] == null)
        {
            dsHangSanXuat = hangsanxuat.SelectAll();
            Cache.Insert("hsx", dsHangSanXuat);
        }
        else
        {
            dsHangSanXuat = (DataSet) Cache["hsx"];
        }
        DataTable dtHangSanXuat = dsHangSanXuat.Tables[0];

        ddlHangSanXuat.DataSource = dtHangSanXuat;
        ddlHangSanXuat.DataTextField = "TenHangSanXuat";
        ddlHangSanXuat.DataValueField = "HangSanXuatID";
        ddlHangSanXuat.DataBind();

        KhuVuc khuvuc = new KhuVuc();
        DataSet dsKhuVuc;

        if (Cache["kv"] == null)
        {
            dsKhuVuc = khuvuc.SelectAll();
            Cache.Insert("kv", dsKhuVuc);
        }
        else
        {
            dsKhuVuc = (DataSet) Cache["kv"];
        }

        DataTable dtKhuVuc = dsKhuVuc.Tables[0];

        ddlKhuVuc.DataSource = dtKhuVuc;
        ddlKhuVuc.DataTextField = "TenKhuVuc";
        ddlKhuVuc.DataValueField = "KhuVucID";
        ddlKhuVuc.DataBind();
    }
Пример #42
0
        public static ArrayList LayHangSanXuat()
        {
            ArrayList list = new ArrayList();
            string query = String.Format("SELECT * FROM HangSanXuat WHERE  Status = 1");

            try
            {
                conn.Open();
                command.CommandText = query;
                SqlDataReader reader = command.ExecuteReader();

                while (reader.Read())
                {
                    string mahsx = reader.GetString(1);
                    string tenhsx = reader.GetString(2);
                    int status = reader.GetInt32(3);
                    HangSanXuat danhmuc = new HangSanXuat(mahsx, tenhsx, status);
                    list.Add(danhmuc);
                }
            }
            finally
            {
                conn.Close();
            }

            return list;
        }