Example #1
0
 public static bool DeleteHang(string maHang)
 {
     try
     {
         using (var db = new SieuThiDBDataContext())
         {
             var nv = db.Hangs.Single(x => x.MaHang.ToLower() == maHang.ToLower());
             if (nv != null)
             {
                 db.Hangs.DeleteOnSubmit(nv);
                 db.SubmitChanges();
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
     }
     catch
     {
         return(false);
     }
     #endregion
 }
Example #2
0
 public static bool DeleteNhanVien(int id)
 {
     try
     {
         using (var db = new SieuThiDBDataContext())
         {
             var nv = db.NhanViens.Single(x => x.MaNV == id);
             if (nv != null)
             {
                 db.NhanViens.DeleteOnSubmit(nv);
                 db.SubmitChanges();
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
     }
     catch
     {
         return(false);
     }
     #endregion
 }
Example #3
0
 public static bool DeleteNhaCC(string id)
 {
     try
     {
         using (var db = new SieuThiDBDataContext())
         {
             var nv = db.nhacungcaps.Single(x => x.ma == id);
             if (nv != null)
             {
                 db.nhacungcaps.DeleteOnSubmit(nv);
                 db.SubmitChanges();
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
     }
     catch
     {
         return(false);
     }
     #endregion
 }
        // Xoa gian hang
        public static bool DeleteGianHang(int id)
        {
            try
            {


                using (var db = new SieuThiDBDataContext())
                {
                    var gh = db.GianHangs.Single(x => x.MaGianHang == id);
                    if (gh != null)
                    {
                        db.GianHangs.DeleteOnSubmit(gh);
                        db.SubmitChanges();
                        return true;
                    }
                    else
                    {
                        return false;
                    }
                }
            }
            catch
            {
                return false;
            }
           
        }
        public void Validation()
        {
            if (txtMKold.Text == "")
            {
                lblThongBao.Text = "Bạn phải nhập mật khẩu cũ";
                return;
            }
            if (txtMKnew.Text == "")
            {
                lblThongBao.Text = "Bạn phải nhập mật khẩu mới";
                return;
            }
            if (txtMKnewConfirm.Text == "")
            {
                lblThongBao.Text = "Bạn phải xác nhận mật khẩu mới";
                return;
            }

            var acc = (from i in data.DangNhaps
                       where i.Username == txtTenDN.Text
                       select i
                       ).SingleOrDefault();

            //string MKold = GetMd5(txtMKold.Text);
            //string MKnew = GetMd5(txtMKnew.Text);
            //if(MKold != acc.Password)
            //{
            //    lblThongBao.Text = "Nhập mật khẩu cũ sai";
            //    return;
            //}
            //if(MKnew == MKold)
            //{
            //    lblThongBao.Text = "Mật khẩu mới phải khác mật khẩu cũ";
            //    return;
            //}

            if (txtMKold.Text != acc.Password)
            {
                lblThongBao.Text = "Nhập mật khẩu cũ sai";
                return;
            }
            if (txtMKnew.Text == txtMKold.Text)
            {
                lblThongBao.Text = "Mật khẩu mới phải khác mật khẩu cũ";
                return;
            }
            if (txtMKnewConfirm.Text != txtMKnew.Text)
            {
                lblThongBao.Text = "Xác thực mật khẩu mới không chính xác";
                return;
            }


            acc.Password = txtMKnew.Text;
            data.SubmitChanges();
            this.Hide();
        }
 public static bool InsertHangNhap(HangNhap hn)
 {
     try
     {
         using (SieuThiDBDataContext db = new SieuThiDBDataContext())
         {
             db.HangNhaps.InsertOnSubmit(hn);
             db.SubmitChanges();
             return(true);
         }
     }
     catch
     {
         return(false);
     }
 }
 public static bool InsertHoaDon(HoaDon hd)
 {
     try
     {
         using (SieuThiDBDataContext db = new SieuThiDBDataContext())
         {
             db.HoaDons.InsertOnSubmit(hd);
             db.SubmitChanges();
             return(true);
         }
     }
     catch
     {
         return(false);
     }
 }
 public static bool InsertDonHang(DonHang dh)
 {
     try
     {
         using (SieuThiDBDataContext db = new SieuThiDBDataContext())
         {
             db.DonHangs.InsertOnSubmit(dh);
             db.SubmitChanges();
             return(true);
         }
     }
     catch
     {
         return(false);
     }
 }
 public static bool updateLoaiHang(LoaiHang _lh)
 {
     try
     {
         using (var db = new SieuThiDBDataContext())
         {
             var loaiHang = db.LoaiHangs.Single(x => x.MaLoaiHang == _lh.MaLoaiHang);
             loaiHang.TenLoaiHang = _lh.TenLoaiHang;
             db.SubmitChanges();
             return(true);
         }
     }
     catch
     {
         return(false);
     }
 }
 public static bool createLoaiHang(LoaiHang loaiHang)
 {
     try
     {
         using (SieuThiDBDataContext db = new SieuThiDBDataContext())
         {
             var lh = new LoaiHang();
             lh.TenLoaiHang = loaiHang.TenLoaiHang;
             db.LoaiHangs.InsertOnSubmit(lh);
             db.SubmitChanges();
             return(true);
         }
     }
     catch
     {
         return(false);
     }
 }
Example #11
0
 public static bool UpdateNhanVien(NhanVien _nv)
 {
     try
     {
         using (var db = new SieuThiDBDataContext())
         {
             var nv = db.NhanViens.Single(x => x.MaNV == _nv.MaNV);
             nv.TenNV       = _nv.TenNV;
             nv.DienThoaiLH = _nv.DienThoaiLH;
             nv.MoTaKhac    = _nv.MoTaKhac;
             db.SubmitChanges();
             return(true);
         }
     }
     catch
     {
         return(false);
     }
 }
 // Cap nhat Gian hang
 public static bool UpdateGianHang(GianHang _gh)
 {
     try
     {
         using (var db = new SieuThiDBDataContext())
         {
             var gh = db.GianHangs.Single(x => x.MaGianHang == _gh.MaGianHang);
             gh.TenGianHang = _gh.TenGianHang;
             gh.LoaiHangMa = _gh.LoaiHangMa;
             
             db.SubmitChanges();
             return true;
         }
     }
     catch
     {
         return false;
     }
 }
 // Tạo Gian hang
 public static bool CreateGianHang(GianHang gh)
 {
     try
     {
         using (SieuThiDBDataContext db = new SieuThiDBDataContext())
         {
             var gh1 = new GianHang();
            
             gh1.TenGianHang = gh.TenGianHang ?? "";
             gh1.LoaiHangMa = gh.LoaiHangMa;
             db.GianHangs.InsertOnSubmit(gh1);
             db.SubmitChanges();
             return true;
         }
     }
     catch
     {
         return false;
     }
 }
Example #14
0
 public static bool CreateNhanVien(NhanVien nv)
 {
     try
     {
         using (SieuThiDBDataContext db = new SieuThiDBDataContext())
         {
             var nv1 = new NhanVien();
             nv1.TenNV       = nv.TenNV;
             nv1.MoTaKhac    = nv.MoTaKhac ?? "";
             nv1.DienThoaiLH = nv.DienThoaiLH ?? "";
             db.NhanViens.InsertOnSubmit(nv1);
             db.SubmitChanges();
             return(true);
         }
     }
     catch
     {
         return(false);
     }
 }
Example #15
0
        public static bool UpdateHang(Hang hang)
        {
            try
            {
                using (var db = new SieuThiDBDataContext())
                {
                    var hang1 = db.Hangs.Single(x => x.MaHang == hang.MaHang);
                    hang1.DVT        = hang.DVT ?? "";
                    hang1.GhiChu     = hang.GhiChu ?? "";
                    hang1.MaLoaiHang = hang.MaLoaiHang;
                    hang1.MaNCC      = hang.MaNCC;
                    hang1.TenHang    = hang.TenHang ?? "";
                    db.SubmitChanges();

                    return(true);
                }
            }
            catch
            {
                return(false);
            }
        }
Example #16
0
        // Cap nhat nhacc
        public static bool UpdateNhaCC(NhaCungCap _cc)
        {
            try
            {
                using (var db = new SieuThiDBDataContext())
                {
                    var cc = db.NhaCungCaps.Single(x => x.MaNCC == _cc.MaNCC);
                    cc.TenNCC    = _cc.TenNCC;
                    cc.DiaChi    = _cc.DiaChi;
                    cc.DienThoai = _cc.DienThoai;
                    cc.MaSoThue  = _cc.MaSoThue;
                    cc.Fax       = _cc.Fax;


                    db.SubmitChanges();
                    return(true);
                }
            }
            catch
            {
                return(false);
            }
        }
Example #17
0
        public static bool UpdateNhaCC(nhacungcap _cc)
        {
            try
            {
                using (var db = new SieuThiDBDataContext())
                {
                    var cc = db.nhacungcaps.Single(x => x.ma == _cc.ma);
                    cc.tennhacungcap = _cc.tennhacungcap;
                    cc.ma            = _cc.ma;
                    cc.diachi        = _cc.diachi;
                    cc.sodienthoai   = _cc.sodienthoai;
                    cc.masothue      = _cc.masothue;
                    cc.fax           = _cc.fax;

                    db.SubmitChanges();
                    return(true);
                }
            }
            catch
            {
                return(false);
            }
        }
Example #18
0
 public static bool CreateNhaCC(nhacungcap cc)
 {
     try
     {
         using (SieuThiDBDataContext db = new SieuThiDBDataContext())
         {
             var cc1 = new nhacungcap();
             cc1.tennhacungcap = cc.tennhacungcap;
             cc1.ma            = cc.ma;
             cc1.diachi        = cc.diachi;
             cc1.sodienthoai   = cc.sodienthoai;
             cc1.masothue      = cc.masothue;
             cc1.fax           = cc.fax;
             db.nhacungcaps.InsertOnSubmit(cc1);
             db.SubmitChanges();
             return(true);
         }
     }
     catch
     {
         return(false);
     }
 }
Example #19
0
 public static bool CreateHang(Hang hang)
 {
     try
     {
         using (SieuThiDBDataContext db = new SieuThiDBDataContext())
         {
             var hang1 = new Hang();
             hang1.MaHang     = hang.MaHang;
             hang1.DVT        = hang.DVT ?? "";
             hang1.GhiChu     = hang.GhiChu ?? "";
             hang1.MaLoaiHang = hang.MaLoaiHang;
             hang1.MaNCC      = hang.MaNCC;
             hang1.TenHang    = hang.TenHang ?? "";
             db.Hangs.InsertOnSubmit(hang1);
             db.SubmitChanges();
             return(true);
         }
     }
     catch
     {
         return(false);
     }
 }
 public static bool deleteLoaiHang(int id)
 {
     try
     {
         using (var db = new SieuThiDBDataContext())
         {
             var nv = db.LoaiHangs.Single(x => x.MaLoaiHang == id);
             if (nv != null)
             {
                 db.LoaiHangs.DeleteOnSubmit(nv);
                 db.SubmitChanges();
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
     }
     catch
     {
         return(false);
     }
 }
Example #21
0
 // Xoa nhacc
 public static bool DeleteNhaCC(int id)
 {
     try
     {
         using (var db = new SieuThiDBDataContext())
         {
             var cc = db.NhaCungCaps.Single(x => x.MaNCC == id);
             if (cc != null)
             {
                 db.NhaCungCaps.DeleteOnSubmit(cc);
                 db.SubmitChanges();
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
     }
     catch
     {
         return(false);
     }
 }
Example #22
0
        // Tạo nhacc
        public static bool CreateNhaCC(NhaCungCap cc)
        {
            try
            {
                using (SieuThiDBDataContext db = new SieuThiDBDataContext())
                {
                    var cc1 = new NhaCungCap();

                    cc1.TenNCC    = cc.TenNCC ?? "";
                    cc1.MaNCC     = cc.MaNCC;
                    cc1.DiaChi    = cc.DiaChi;
                    cc1.DienThoai = cc.DienThoai;
                    cc1.MaSoThue  = cc.MaSoThue;
                    cc1.Fax       = cc.Fax;
                    db.NhaCungCaps.InsertOnSubmit(cc1);
                    db.SubmitChanges();
                    return(true);
                }
            }
            catch
            {
                return(false);
            }
        }