Example #1
0
        public void gopBan(int mabanhientai, int mabangop)
        {
            List <DanhSachMonGoi> bangop = qlcf.DanhSachMonGois.Where(t => t.MaBan == mabangop).ToList();


            foreach (DanhSachMonGoi ban in bangop)
            {
                if (kiemtramontontai(ban.MaMon, mabanhientai))
                {
                    DanhSachMonGoi banhientai = new DanhSachMonGoi();
                    banhientai.MaBan   = mabanhientai;
                    banhientai.MaMon   = ban.MaMon;
                    banhientai.SoLuong = ban.SoLuong;
                    qlcf.DanhSachMonGois.InsertOnSubmit(banhientai);
                }
                else
                {
                    DanhSachMonGoi b = qlcf.DanhSachMonGois.Where(t => t.MaBan == mabanhientai && t.MaMon == ban.MaMon).FirstOrDefault();
                    b.SoLuong += ban.SoLuong;
                }
            }


            Ban trangthaibangop = qlcf.Bans.Where(t => t.MaBan == mabangop).FirstOrDefault();

            trangthaibangop.TrangThai = 0;

            qlcf.DanhSachMonGois.DeleteAllOnSubmit(bangop);

            qlcf.SubmitChanges();
        }
Example #2
0
        public void chuyenBan(int mabanhientai, int mabanchuyen)
        {
            List <DanhSachMonGoi> banhientai = qlcf.DanhSachMonGois.Where(t => t.MaBan == mabanhientai).ToList();

            foreach (DanhSachMonGoi ban in banhientai)
            {
                DanhSachMonGoi banchuyen = new DanhSachMonGoi();
                banchuyen.MaBan   = mabanchuyen;
                banchuyen.MaMon   = ban.MaMon;
                banchuyen.SoLuong = ban.SoLuong;
                qlcf.DanhSachMonGois.InsertOnSubmit(banchuyen);
            }

            Ban trangthaibanhientai = qlcf.Bans.Where(t => t.MaBan == mabanhientai).FirstOrDefault();

            trangthaibanhientai.TrangThai = 0;

            Ban trangthaibanchuyen = qlcf.Bans.Where(t => t.MaBan == mabanchuyen).FirstOrDefault();

            trangthaibanchuyen.TrangThai = 1;

            qlcf.DanhSachMonGois.DeleteAllOnSubmit(banhientai);

            qlcf.SubmitChanges();
        }
Example #3
0
        public void xoaMonDaGoi(string mamon, int maban)
        {
            DanhSachMonGoi mons = qlThucDon.DanhSachMonGois.Where(t => t.MaMon == mamon && t.MaBan == maban).FirstOrDefault();

            if (mons != null)
            {
                qlThucDon.DanhSachMonGois.DeleteOnSubmit(mons);
            }
            qlThucDon.SubmitChanges();
        }
Example #4
0
        public void capNhatSoLuongMon(string mamon, int maban, int soluong)
        {
            DanhSachMonGoi mons = qlThucDon.DanhSachMonGois.Where(t => t.MaBan == maban && t.MaMon == mamon).FirstOrDefault();

            if (mons != null)
            {
                mons.SoLuong = soluong;
            }
            qlThucDon.SubmitChanges();
        }
Example #5
0
        public bool kiemtramontontai(string mamon, int maban)
        {
            DanhSachMonGoi ban = qlcf.DanhSachMonGois.Where(t => t.MaMon == mamon && t.MaBan == maban).FirstOrDefault();

            if (ban == null)
            {
                return(true);
            }
            return(false);
        }
Example #6
0
        public bool kiemtratrangthaichuyenban(int ma)
        {
            DanhSachMonGoi ban = qlcf.DanhSachMonGois.Where(t => t.MaBan == ma).FirstOrDefault();

            if (ban != null)
            {
                return(true);
            }
            return(false);
        }
Example #7
0
        public void themDanhSachMonGoi(int maban, string mamon, int soluon, decimal gia)
        {
            DanhSachMonGoi ds = new DanhSachMonGoi();

            ds.MaBan   = maban;
            ds.MaMon   = mamon;
            ds.SoLuong = soluon;
            ds.Gia     = gia;
            qlThucDon.DanhSachMonGois.InsertOnSubmit(ds);
            qlThucDon.SubmitChanges();
        }
Example #8
0
 public bool KiemTraSoLuongDaDat(int maban)
 {
     try
     {
         DanhSachMonGoi ds = qlcf.DanhSachMonGois.Where(t => t.MaBan == maban).FirstOrDefault();
         if (ds.SoLuong != 0)
         {
             return(true);
         }
         return(false);
     }
     catch
     {
         MessageBox.Show("Chưa có sản phẩm!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     return(false);
 }