Exemple #1
0
        private void btn_Them_Click(object sender, EventArgs e)
        {
            //kiểm tra rỗng
            if (txt_madm.Text == "" || txt_tendm.Text == "")
            {
                MessageBox.Show("Không được để trống");
                return;
            }
            //kiểm tra trùng
            DANHMUCSANPHAM dm = new DANHMUCSANPHAM();
            var            kt = from s in ql.DANHMUCSANPHAMs where s.MADM == txt_madm.Text select s;

            if (kt.Count() > 0)
            {
                MessageBox.Show("Trùng khóa chính");
                return;
            }
            dm.MADM  = txt_madm.Text;
            dm.TENDM = txt_tendm.Text;
            ql.DANHMUCSANPHAMs.InsertOnSubmit(dm);
            ql.SubmitChanges();
            frm_DMSP_Load(sender, e);
            MessageBox.Show("Thành công");
            txt_tendm.Text = "";
        }
        public ActionResult Add(DANHMUCSANPHAM model)
        {
            var DanhMucSanPham = db.DANHMUCSANPHAMs.Find(model.MaDM);

            db.DANHMUCSANPHAMs.Add(model);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public ActionResult Edit(DANHMUCSANPHAM model)
        {
            var obj = db.DANHMUCSANPHAMs.Find(model.MaDM);

            obj.MaDM = model.MaDM;
            obj.Ten  = model.Ten;
            db.SaveChanges();
            return(RedirectToAction("index", model));
        }
Exemple #4
0
        public ActionResult ThemDanhMuc(DANHMUCSANPHAM cs)
        {
            DANHMUCSANPHAM ds = new DANHMUCSANPHAM();

            ds.IDCha      = cs.IDCha;
            ds.TenDanhMuc = cs.TenDanhMuc;
            ds.Metatitle  = RewriteURL.RewriteUrl(cs.TenDanhMuc);
            ds.NgayTao    = DateTime.Now;
            ds.NguoiTao   = UserInfo.Username;
            ds.TrangThai  = 0;
            var dao = new DanhMucSanPhamDAO();

            dao.ThemDanhMuc(ds);
            return(RedirectToAction("ChoDuyet"));
        }
Exemple #5
0
        public bool delete_DMSP(int idncc, int idsp)
        {
            DANHMUCSANPHAM dmsp = quanLyKho.DANHMUCSANPHAMs.SingleOrDefault(n => n.ID_NCC == idncc && n.ID_SP == idsp);
            var            kt   = quanLyKho.CHITIETPHIEUDATs.Where(n => n.PHIEUDAT.TINHTRANG == false && n.PHIEUDAT.ID_NCC == idncc && n.ID_SP == idsp);

            if (kt.Count() == 0)
            {
                quanLyKho.DANHMUCSANPHAMs.DeleteOnSubmit(dmsp);
                quanLyKho.SubmitChanges();
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #6
0
 public bool insert_DMSP(int idncc, int idsp, int gianhap)
 {
     try
     {
         DANHMUCSANPHAM dmsp = new DANHMUCSANPHAM();
         dmsp.ID_NCC = idncc;
         dmsp.ID_SP  = idsp;
         dmsp.GIABAN = gianhap;
         quanLyKho.DANHMUCSANPHAMs.InsertOnSubmit(dmsp);
         quanLyKho.SubmitChanges();
     }
     catch
     {
         return(false);
     }
     return(true);
 }
Exemple #7
0
        public bool update_DMSP(int idncc, int idsp, int idspmoi, int gianhap)
        {
            DANHMUCSANPHAM dmsp = quanLyKho.DANHMUCSANPHAMs.SingleOrDefault(n => n.ID_NCC == idncc && n.ID_SP == idsp);
            var            kt   = quanLyKho.CHITIETPHIEUDATs.Where(n => n.PHIEUDAT.TINHTRANG == false && n.PHIEUDAT.ID_NCC == idncc && n.ID_SP == idsp);

            if (kt.Count() == 0)
            {
                dmsp.ID_SP  = idspmoi;
                dmsp.GIABAN = gianhap;
                try
                {
                    quanLyKho.SubmitChanges();
                    return(true);
                }
                catch
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
        //Lấy sản phẩm trong nhà cung cấp(Danh mục sản phẩm)
        public int SanPham_NCC(int id_ncc)
        {
            DANHMUCSANPHAM sp = quanLyKho.DANHMUCSANPHAMs.FirstOrDefault(s => s.ID_NCC == id_ncc);

            return(sp.ID_SP);
        }
 public void ThemDanhMuc(DANHMUCSANPHAM ds)
 {
     db.DANHMUCSANPHAMs.Add(ds);
     db.SaveChanges();
 }