Beispiel #1
0
 public bool addSP(string mahd, string masp, string sl, string dongia)
 {
     db = new CMART8Entities();
     try
     {
         try {
             CTHOADON cthd = db.CTHOADONs.Single(st => st.SOHD.Equals(mahd) && st.MASP.Equals(masp));
             int      dem  = int.Parse(cthd.SOLUONG.ToString()) + int.Parse(sl);
             cthd.SOLUONG = dem;
             db.SaveChanges();
             return(true);
         }
         catch
         {
             CTHOADON cthd = new CTHOADON();
             cthd.SOHD    = mahd;
             cthd.MASP    = masp;
             cthd.DONGIA  = float.Parse(dongia);
             cthd.SOLUONG = int.Parse(sl);
             db.CTHOADONs.Add(cthd);
             db.SaveChanges();
             return(true);
         }
     }
     catch
     { return(false); }
 }
Beispiel #2
0
        public bool editSP(string id, string ten, string hinhanh, string maloai, string mancc)
        {
            db = new CMART8Entities();
            SANPHAM SP = db.SANPHAMs.Single(st => st.MASP.Equals(id));

            try
            {
                if (maloai != SP.MALOAI)
                {
                    LOAISANPHAM lsp1 = db.LOAISANPHAMs.Single(st => st.MALOAI.Equals(maloai));
                    LOAISANPHAM lsp2 = db.LOAISANPHAMs.Single(st => st.MALOAI.Equals(SP.MALOAI));
                    SP.TENSP       = ten;
                    SP.HINHANH     = hinhanh;
                    SP.MALOAI      = maloai;
                    SP.MANCC       = mancc;
                    lsp2.SOLUONGSP = lsp2.SOLUONGSP - 1;
                    lsp1.SOLUONGSP = lsp1.SOLUONGSP + 1;
                    db.SaveChanges();
                }
                else
                {
                    SP.TENSP   = ten;
                    SP.HINHANH = hinhanh;
                    SP.MANCC   = mancc;
                    db.SaveChanges();
                }
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Beispiel #3
0
        public string autoID()
        {
            db = new CMART8Entities();
            string s  = "";
            string yy = DateTime.Now.Year.ToString();

            yy = yy.Substring(yy.Length - 2, 2);
            string mm = "0" + DateTime.Now.Month.ToString();

            mm = mm.Substring(mm.Length - 2, 2);
            string dd = "0" + DateTime.Now.Day.ToString();

            dd = dd.Substring(dd.Length - 2, 2);
            List <PHIEUNHAPHANGCHINHANH> hd = db.PHIEUNHAPHANGCHINHANHs.Where(st => st.SOPHIEU.Substring(3, 6).Equals(yy + mm + dd)).ToList();

            hd = db.PHIEUNHAPHANGCHINHANHs.ToList().Where(h => h.SOPHIEU.Contains(yy + mm + dd)).ToList();
            if (hd.Count == 0)
            {
                s = "CN-" + yy + mm.Substring(mm.Length - 2, 2) + dd.Substring(dd.Length - 2, 2) + "-0001";
            }
            else
            {
                string mahd = "000" + hd.Select(h => h.SOPHIEU.Substring(10)).OrderBy(so => so).Last();
                mahd = mahd.Substring(mahd.Length - 4, 4);
                int ma = int.Parse(mahd) + 1;
                mahd = "000" + ma.ToString();
                mahd = mahd.Substring(mahd.Length - 4, 4);
                s    = "CN-" + yy + mm + dd + "-" + mahd;
            }
            return(s);
        }
Beispiel #4
0
        public bool addTTKM(string masp, float giakm, DateTime tgbd, DateTime tgkt, string noidung, string hinhanh)
        {
            db = new CMART8Entities();
            KHUYENMAI TTKM = new KHUYENMAI();

            try
            {
                TTKM.MAKM    = DateTime.Now.ToString();
                TTKM.MASP    = masp;
                TTKM.GIAKM   = giakm;
                TTKM.HINHANH = hinhanh;
                //TTKM.THOIGIANBD = DateTime.Parse(tgbd);
                //TTKM.THOIGIANKT = DateTime.Parse(tgkt);
                TTKM.THOIGIANBD = tgbd;
                TTKM.THOIGIANKT = tgkt;
                TTKM.NOIDUNG    = noidung;
                db.KHUYENMAIs.Add(TTKM);
                db.SaveChanges();
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Beispiel #5
0
        public bool deleteTK(string ID)
        {
            db = new CMART8Entities();
            TAIKHOAN TK = db.TAIKHOANs.ToList().Single(st => st.MATK.Equals(ID));

            db.TAIKHOANs.Remove(TK);
            db.SaveChanges();
            return(true);
        }
Beispiel #6
0
        public bool deleteTTKM(String id)
        {
            db = new CMART8Entities();
            KHUYENMAI TTKM = db.KHUYENMAIs.Single(st => st.MAKM.Contains(id));

            db.KHUYENMAIs.Remove(TTKM);
            db.SaveChanges();
            return(true);
        }
Beispiel #7
0
        public bool deleteLSG(string ID, string gia, string ngayhl)
        {
            db = new CMART8Entities();
            LICHSUGIA LSG = db.LICHSUGIAs.ToList().Single(st => st.MASP.Equals(ID) && st.GIABAN.ToString().Equals(gia) && st.NGAYHIEULUC.ToString().Equals(ngayhl));

            db.LICHSUGIAs.Remove(LSG);
            db.SaveChanges();
            return(true);
        }
Beispiel #8
0
        public bool checkExit(string username)
        {
            db = new CMART8Entities();
            List <TAIKHOAN> tmp = db.TAIKHOANs.Where(st => st.TENDANGNHAP.Equals(username)).ToList();

            if (tmp.Count != 0)
            {
                return(false);
            }
            return(true);
        }
Beispiel #9
0
        public bool checkExist(string sTmp)
        {
            db = new CMART8Entities();
            List <KHUYENMAI> tmp = db.KHUYENMAIs.Where(st => st.MAKM.Equals(sTmp)).ToList();

            if (tmp.Count != 0)
            {
                return(false);
            }
            return(true);
        }
Beispiel #10
0
      public bool checkExist(string sTmp)
      {
          db = new CMART8Entities();
          List <NHACUNGCAP> tmp = db.NHACUNGCAPs.Where(st => st.TENNCC.Equals(sTmp) || st.MANCC.Equals(sTmp)).ToList();

          if (tmp.Count != 0)
          {
              return(false);
          }
          return(true);
      }
Beispiel #11
0
        public bool checkExist(string sTmp)
        {
            db = new CMART8Entities();
            List <SANPHAM> tmp = db.SANPHAMs.Where(st => st.TENSP.Equals(sTmp) || st.MASP.Equals(sTmp)).ToList();

            if (tmp.Count != 0)
            {
                return(false);
            }
            return(true);
        }
Beispiel #12
0
        public void deleteListCTNHTS(string sophieuts)
        {
            db = new CMART8Entities();
            List <CTPHIEUNHAPHANGTRUSO> tmp = db.CTPHIEUNHAPHANGTRUSOes.Where(x => x.SOPHIEUNHTS.Equals(sophieuts)).ToList();

            foreach (CTPHIEUNHAPHANGTRUSO p in tmp)
            {
                db.CTPHIEUNHAPHANGTRUSOes.Remove(p);
            }
            db.SaveChanges();
        }
Beispiel #13
0
        public bool checkExit(string soPhieu)
        {
            db = new CMART8Entities();
            List <PHIEUNHAPHANGTRUSO> tmp = db.PHIEUNHAPHANGTRUSOes.Where(st => st.SOPHIEUDX.Equals(soPhieu)).ToList();

            if (tmp.Count != 0)
            {
                return(false);
            }
            return(true);
        }
Beispiel #14
0
        public PHIEUNHAPHANGCHINHANH createNHCN(TAIKHOAN tk)
        {
            db = new CMART8Entities();
            PHIEUNHAPHANGCHINHANH pnh = new PHIEUNHAPHANGCHINHANH();

            pnh.SOPHIEU  = autoID();
            pnh.NGAYNHAP = DateTime.Now;
            pnh.MATK     = tk.MATK;
            db.PHIEUNHAPHANGCHINHANHs.Add(pnh);
            db.SaveChanges();
            return(pnh);
        }
Beispiel #15
0
        public PHIEUNHAPHANGTRUSO createNHTS(string matk)
        {
            db = new CMART8Entities();
            string             id   = autoID();
            PHIEUNHAPHANGTRUSO nhts = new PHIEUNHAPHANGTRUSO();

            nhts.SOPHIEU  = id;
            nhts.MATK     = matk;
            nhts.NGAYNHAP = DateTime.Now;
            db.PHIEUNHAPHANGTRUSOes.Add(nhts);
            db.SaveChanges();
            return(nhts);
        }
Beispiel #16
0
 public bool deleteSP(string sohd, string masp)
 {
     db = new CMART8Entities();
     try
     {
         CTHOADON cthd = db.CTHOADONs.Single(st => st.SOHD.Equals(sohd) && st.MASP.Equals(masp));
         db.CTHOADONs.Remove(cthd);
         db.SaveChanges();
         return(true);
     }
     catch {
         return(false);
     }
 }
Beispiel #17
0
        //Load combobox
        public List <PHIEUDEXUAT> loadListPDX()
        {
            db = new CMART8Entities();
            List <PHIEUDEXUAT> pdx = db.PHIEUDEXUATs.ToList();

            for (int i = pdx.Count - 1; i >= 0; i--)
            {
                if (!checkExit(pdx.ElementAt(i).SOPHIEUDX))
                {
                    pdx.RemoveAt(i);
                }
            }
            return(pdx);
        }
Beispiel #18
0
 //Delete PN
 public bool deletePN(PHIEUNHAPHANGTRUSO PN)
 {
     try
     {
         db = new CMART8Entities();
         PHIEUNHAPHANGTRUSO pn = db.PHIEUNHAPHANGTRUSOes.Find(PN.SOPHIEU);
         db.PHIEUNHAPHANGTRUSOes.Remove(pn);
         db.SaveChanges();
         return(true);
     }
     catch {
         return(false);
     }
 }
Beispiel #19
0
        //load dữ liệu cho combobox
        public List <PHIEUNHAPHANGTRUSO> loadListNHTS()
        {
            db = new CMART8Entities();
            List <PHIEUNHAPHANGTRUSO> pdx = db.PHIEUNHAPHANGTRUSOes.ToList();

            for (int i = pdx.Count - 1; i >= 0; i--)
            {
                if (!checkExit(pdx.ElementAt(i).SOPHIEU))
                {
                    pdx.RemoveAt(i);
                }
            }
            return(pdx);
        }
 public bool deleteLSP(String id)
 {
     try
     {
         db = new CMART8Entities();
         LOAISANPHAM LSP = db.LOAISANPHAMs.Single(st => st.MALOAI.Contains(id));
         db.LOAISANPHAMs.Remove(LSP);
         db.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Beispiel #21
0
 public bool deleteNCC(String id)
 {
     try
     {
         db = new CMART8Entities();
         NHACUNGCAP ncc = db.NHACUNGCAPs.Single(st => st.MANCC.Contains(id));
         db.NHACUNGCAPs.Remove(ncc);
         db.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Beispiel #22
0
 //update Phieu nhap hang tru so
 public bool updatePNHTS(PHIEUNHAPHANGTRUSO PN, string tongTien, string soPhieuDX)
 {
     try
     {
         db = new CMART8Entities();
         PHIEUNHAPHANGTRUSO pn = db.PHIEUNHAPHANGTRUSOes.Find(PN.SOPHIEU);
         pn.TONGTIEN        = ulong.Parse(tongTien);
         pn.SOPHIEUDX       = soPhieuDX;
         db.Entry(pn).State = System.Data.EntityState.Modified;
         db.SaveChanges();
         return(true);
     }
     catch {
         return(false);
     }
 }
Beispiel #23
0
 //add list Chi tiết phiếu nhập hàng trụ sở
 public bool addListCTNHTS(List <CTPHIEUNHAPHANGTRUSO> list)
 {
     try
     {
         db = new CMART8Entities();
         foreach (CTPHIEUNHAPHANGTRUSO item in list)
         {
             db.CTPHIEUNHAPHANGTRUSOes.Add(item);
         }
         db.SaveChanges();
         return(true);
     }
     catch {
         return(false);
     }
 }
Beispiel #24
0
 public bool deleteSP(String id)
 {
     try
     {
         db = new CMART8Entities();
         SANPHAM     SP  = db.SANPHAMs.Single(st => st.MASP.Contains(id));
         LOAISANPHAM lsp = db.LOAISANPHAMs.Single(st => st.MALOAI.Equals(SP.MALOAI));
         db.SANPHAMs.Remove(SP);
         lsp.SOLUONGSP = lsp.SOLUONGSP - 1;
         db.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
        public bool editLSP(string id, string ten)
        {
            db = new CMART8Entities();
            LOAISANPHAM LSP = db.LOAISANPHAMs.Single(st => st.MALOAI.Equals(id));

            try
            {
                LSP.TENLOAI = ten;
                db.SaveChanges();

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Beispiel #26
0
 //Update Phiếu nhập hàng chi nhánh
 public bool updatePNHTS(PHIEUNHAPHANGCHINHANH PN, string sophieuTS, string chinhanh)
 {
     try
     {
         db = new CMART8Entities();
         PHIEUNHAPHANGCHINHANH pn = db.PHIEUNHAPHANGCHINHANHs.Find(PN.SOPHIEU);
         pn.SOPHIEUNHTS     = sophieuTS;
         pn.CHINHANH        = chinhanh;
         db.Entry(pn).State = System.Data.EntityState.Modified;
         db.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
 public GUI_LichSuGia(TAIKHOAN tmp)
 {
     TK    = tmp;
     ctl   = new BUS_LichSuGia();
     ctlSP = new BUS_SanPham();
     db    = new CMART8Entities();
     vl    = new ValidationExtension();
     InitializeComponent();
     controlFunction(TK.QUYEN);
     btnAdd.Click    += btnAdd_Click;
     btnEdit.Click   += btnEdit_Click;
     lstLSG.Click    += lstLSG_Click;
     btnSearch.Click += btnSearch_Click;
     btnCancel.Click += btnCancel_Click;
     btnSave.Click   += btnSave_Click;
     btnDelete.Click += btnDelete_Click;
 }
Beispiel #28
0
 public bool updateHD(string id, string tongtien, string tienkh, string tientra, string tongsl)
 {
     try
     {
         db = new CMART8Entities();
         HOADON hd = db.HOADONs.Single(st => st.SOHD.Equals(id));
         hd.TONGTIEN     = tongtien;
         hd.TIENKHACHDUA = tienkh;
         hd.TIENKHATRA   = tientra;
         hd.TONGSL       = int.Parse(tongsl);
         db.SaveChanges();
         return(true);
     }
     catch {
         return(false);
     }
 }
Beispiel #29
0
        public void addCTNHTS(string tmp, PHIEUNHAPHANGTRUSO PN, TAIKHOAN TK)
        {
            db = new CMART8Entities();
            var ctpdx = db.CTPHIEUDEXUATs.Where(x => x.SOPHIEU.Equals(tmp)).ToList();

            foreach (var item in ctpdx)
            {
                CTPHIEUNHAPHANGTRUSO nhts = new CTPHIEUNHAPHANGTRUSO();
                nhts.SOPHIEUNHTS = PN.SOPHIEU;
                nhts.MASP        = item.MASP;
                nhts.SOLUONG     = item.SOLUONG;
                nhts.GIANHAP     = 0;
                nhts.HANSD       = DateTime.Now.AddMonths(6);
                nhts.TINHTRANG   = "Đủ";
                db.CTPHIEUNHAPHANGTRUSOes.Add(nhts);
                db.SaveChanges();
            }
        }
Beispiel #30
0
        public HOADON createHD(string POS, string maTK)
        {
            db = new CMART8Entities();
            string id = autoID();
            HOADON hd = new HOADON();

            hd.SOHD         = id;
            hd.NGAYBAN      = DateTime.Now;
            hd.MATK         = maTK;
            hd.POS          = POS;
            hd.TONGSL       = 0;
            hd.TONGTIEN     = "0";
            hd.TIENKHACHDUA = "0";
            hd.TIENKHATRA   = "0";
            db.HOADONs.Add(hd);
            db.SaveChanges();
            return(hd);
        }