コード例 #1
0
 private void LoadPhieuNhap(List <PHIEUNHAP> ls = null)
 {
     if (ls == null)
     {
         using (QuanLyKhoEntities db = new QuanLyKhoEntities())
         {
             pHIEUNHAPBindingSource.DataSource = db.PHIEUNHAPs.ToList();
         }
     }
     else
     {
         pHIEUNHAPBindingSource.DataSource = ls;
     }
 }
コード例 #2
0
 private void LoadPhieuXuat(List <PHIEUXUAT> ls = null)
 {
     if (ls == null)
     {
         using (QuanLyKhoEntities db = new QuanLyKhoEntities())
         {
             pHIEUXUATBindingSource.DataSource = db.PHIEUXUATs.ToList();
         }
     }
     else
     {
         pHIEUXUATBindingSource.DataSource = ls;
     }
 }
コード例 #3
0
 private void LoadDonVi(List <DONVI> ls = null)
 {
     if (ls != null)
     {
         dONVIBindingSource1.DataSource = ls;
     }
     else
     {
         using (QuanLyKhoEntities db = new QuanLyKhoEntities())
         {
             dONVIBindingSource1.DataSource = db.DONVIs.ToList();
         }
     }
 }
コード例 #4
0
 private void LoadNhaCungCap(List <NHACUNGCAP> ls = null)
 {
     if (ls != null)
     {
         nHACUNGCAPBindingSource1.DataSource = ls;
     }
     else
     {
         using (QuanLyKhoEntities db = new QuanLyKhoEntities())
         {
             nHACUNGCAPBindingSource1.DataSource = db.NHACUNGCAPs.ToList();
         }
     }
 }
コード例 #5
0
 private void LoadHangNhap(List <HANGNHAP> ls = null)
 {
     if (ls == null)
     {
         using (QuanLyKhoEntities db = new QuanLyKhoEntities())
         {
             hANGNHAPBindingSource.DataSource = db.HANGNHAPs.ToList();
         }
     }
     else
     {
         hANGNHAPBindingSource.DataSource = ls;
     }
 }
コード例 #6
0
 private void LoadHangXuat(List <HANGXUAT> ls = null)
 {
     if (ls == null)
     {
         using (QuanLyKhoEntities db = new QuanLyKhoEntities())
         {
             hANGXUATBindingSource.DataSource = db.HANGXUATs.ToList();
         }
     }
     else
     {
         hANGXUATBindingSource.DataSource = ls;
     }
 }
コード例 #7
0
ファイル: ManagerLogin.cs プロジェクト: tuyet96/quanLyKhoMoi
 public bool IsUserName(string userName)
 {
     using (QuanLyKhoEntities db = new QuanLyKhoEntities())
     {
         var user = db.Table_User.Where(x => x.UserName == userName).ToList();
         if (user.Count == 0)
         {
             return(false);
         }
         else
         {
             return(true);
         }
     }
 }
コード例 #8
0
ファイル: ManagerLogin.cs プロジェクト: tuyet96/quanLyKhoMoi
 public static int GetId(string userName)
 {
     using (QuanLyKhoEntities db = new QuanLyKhoEntities())
     {
         var user = db.Table_User.Where(x => x.UserName == userName).FirstOrDefault();
         if (user == null)
         {
             return(-1);
         }
         else
         {
             return(user.UserId);
         }
     }
 }
コード例 #9
0
 private void LoadNhanVien(List <NHANVIEN> ls = null)
 {
     if (ls != null)
     {
         nHANVIENBindingSource1.DataSource = ls;
         return;
     }
     else
     {
         using (QuanLyKhoEntities db = new QuanLyKhoEntities())
         {
             nHANVIENBindingSource1.DataSource = db.NHANVIENs.ToList();
         }
     }
 }
コード例 #10
0
 private void LoadNhomHang(List <NHOMHANG> ls = null)
 {
     if (ls != null)
     {
         nHOMHANGBindingSource.DataSource = ls;
         return;
     }
     else
     {
         using (QuanLyKhoEntities db = new QuanLyKhoEntities())
         {
             nHOMHANGBindingSource.DataSource = db.NHOMHANGs.ToList();
         }
     }
 }
コード例 #11
0
 private void btnTKDonVi_Click(object sender, EventArgs e)
 {
     using (QuanLyKhoEntities db = new QuanLyKhoEntities())
     {
         if (string.IsNullOrEmpty(txtTKDonVi.Text) || txtTKDonVi.Text == " ")
         {
             LoadDonVi();
         }
         else
         {
             var lsDV = db.DONVIs.Where(x => x.tendonvi == txtTKDonVi.Text || x.chucnang == txtTKDonVi.Text).ToList();
             LoadDonVi(lsDV);
         }
     }
 }
コード例 #12
0
 private void btnTKNCC_Click(object sender, EventArgs e)
 {
     using (QuanLyKhoEntities db = new QuanLyKhoEntities())
     {
         if (string.IsNullOrEmpty(txtTKNCC.Text) || txtTKNCC.Text == " ")
         {
             LoadNhaCungCap();
         }
         else
         {
             var lsNCC = db.NHACUNGCAPs.Where(x => x.tenNCC == txtTKNCC.Text || x.sodienthoai == txtTKNCC.Text || x.diachi == txtTKNCC.Text).ToList();
             LoadNhaCungCap(lsNCC);
         }
     }
 }
コード例 #13
0
 private void tilXoaNV_Click(object sender, EventArgs e)
 {
     using (QuanLyKhoEntities db = new QuanLyKhoEntities())
     {
         var nv = nHANVIENBindingSource1.Current as NHANVIEN;
         var NV = db.NHANVIENs.SingleOrDefault(x => x.ma == nv.ma);
         if (NV != null)
         {
             db.NHANVIENs.Attach(NV);
             db.NHANVIENs.Remove(NV);
             db.SaveChanges();
             LoadNhanVien();
         }
     }
 }
コード例 #14
0
 private void btnTKNV_Click(object sender, EventArgs e)
 {
     using (QuanLyKhoEntities db = new QuanLyKhoEntities())
     {
         if (string.IsNullOrEmpty(txtTKNV.Text) || txtTKNV.Text == " ")
         {
             LoadNhanVien();
         }
         else
         {
             var lsNCC = db.NHANVIENs.Where(x => x.hoten == txtTKNV.Text || x.gioitinh == txtTKNV.Text).ToList();
             LoadNhanVien(lsNCC);
         }
     }
 }
コード例 #15
0
 private void btnTKNhomHang_Click(object sender, EventArgs e)
 {
     using (QuanLyKhoEntities db = new QuanLyKhoEntities())
     {
         if (string.IsNullOrEmpty(txtTKNhomHang.Text) || txtTKNhomHang.Text == " ")
         {
             LoadNhomHang();
         }
         else
         {
             var nh = db.NHOMHANGs.Where(x => x.tennhom == txtTKNhomHang.Text || x.tacdung == txtTKNhomHang.Text).ToList();
             LoadNhomHang(nh);
         }
     }
 }
コード例 #16
0
ファイル: ManagerLogin.cs プロジェクト: tuyet96/quanLyKhoMoi
 public string GetPassword(string userName)
 {
     using (QuanLyKhoEntities db = new QuanLyKhoEntities())
     {
         var pass = db.Table_User.Where(x => x.UserName == userName).Select(x => x.UserPassword).FirstOrDefault();
         if (pass != null)
         {
             return(pass);
         }
         else
         {
             return(null);
         }
     }
 }
コード例 #17
0
 private void txtTimKiem_TextChanged(object sender, EventArgs e)
 {
     using (QuanLyKhoEntities db = new QuanLyKhoEntities())
     {
         if (string.IsNullOrEmpty(txtTimKiem.Text) || txtTimKiem.Text == " ")
         {
             LoadHangHoa();
         }
         else
         {
             var ls = db.HANGHOAs.Where(x => x.tenhang.Contains(txtTimKiem.Text) || x.donvitinh.Contains(txtTimKiem.Text)).ToList();
             LoadHangHoa(ls);
         }
     }
 }
コード例 #18
0
 private void btnTkPX_Click(object sender, EventArgs e)
 {
     using (QuanLyKhoEntities db = new QuanLyKhoEntities())
     {
         if (txtTkPX.Text == " " || string.IsNullOrEmpty(txtTkPX.Text))
         {
             LoadPhieuXuat();
         }
         else
         {
             var lsPX = db.PHIEUXUATs.Where(x => x.Spxuat == txtTkPX.Text).ToList();
             LoadPhieuXuat(lsPX);
         }
     }
 }
コード例 #19
0
 private void btnTkHN_Click(object sender, EventArgs e)
 {
     using (QuanLyKhoEntities db = new QuanLyKhoEntities())
     {
         if (txtTkHN.Text == " " || string.IsNullOrEmpty(txtTkHN.Text))
         {
             LoadHangNhap();
         }
         else
         {
             var tkHN = db.HANGNHAPs.Where(x => x.Spnhap == txtTkHN.Text).ToList();
             LoadHangNhap(tkHN);
         }
     }
 }
コード例 #20
0
 private void btnTkPN_Click(object sender, EventArgs e)
 {
     using (QuanLyKhoEntities db = new QuanLyKhoEntities())
     {
         if (txtTkPN.Text == " " || string.IsNullOrEmpty(txtTkPN.Text))
         {
             LoadPhieuNhap();
         }
         else
         {
             var lsPN = db.PHIEUNHAPs.Where(x => x.Spnhap == txtTkPN.Text).ToList();
             LoadPhieuNhap(lsPN);
         }
     }
 }
コード例 #21
0
 private void btnTkHX_Click(object sender, EventArgs e)
 {
     using (QuanLyKhoEntities db = new QuanLyKhoEntities())
     {
         if (txtTkHX.Text == " " || string.IsNullOrEmpty(txtTkHX.Text))
         {
             LoadHangXuat();
         }
         else
         {
             var tkXH = db.HANGXUATs.Where(x => x.Spxuat == txtTkHX.Text).ToList();
             LoadHangXuat(tkXH);
         }
     }
 }
コード例 #22
0
 private void btnPXx_Click(object sender, EventArgs e)
 {
     using (QuanLyKhoEntities db = new QuanLyKhoEntities())
     {
         var px = pHIEUXUATBindingSource.Current as PHIEUXUAT;
         var PX = db.PHIEUXUATs.SingleOrDefault(x => x.Spxuat == px.Spxuat);
         if (PX != null)
         {
             db.PHIEUXUATs.Remove(PX);
             db.SaveChanges();
         }
         else
         {
             return;
         }
         LoadPhieuXuat();
     }
 }
コード例 #23
0
 private void btnPxT_Click(object sender, EventArgs e)
 {
     using (QuanLyKhoEntities db = new QuanLyKhoEntities())
     {
         var px = pHIEUXUATBindingSource.Current as PHIEUXUAT;
         if (db.PHIEUXUATs.SingleOrDefault(x => x.Spxuat == px.Spxuat) == null)
         {
             db.PHIEUXUATs.Add(px);
             db.SaveChanges();
         }
         else
         {
             MetroMessageBox.Show(this, "Sản phẩm đã tồn tại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
             return;
         }
         LoadPhieuXuat();
     }
 }
コード例 #24
0
 private void btnXoaPN_Click(object sender, EventArgs e)
 {
     using (QuanLyKhoEntities db = new QuanLyKhoEntities())
     {
         var pn = pHIEUNHAPBindingSource.Current as PHIEUNHAP;
         var PN = db.PHIEUNHAPs.SingleOrDefault(x => x.Spnhap == pn.Spnhap);
         if (PN != null)
         {
             db.PHIEUNHAPs.Remove(PN);
             db.SaveChanges();
         }
         else
         {
             return;
         }
         LoadPhieuNhap();
     }
 }
コード例 #25
0
 private void btnNhapPN_Click(object sender, EventArgs e)
 {
     using (QuanLyKhoEntities db = new QuanLyKhoEntities())
     {
         var pn = pHIEUNHAPBindingSource.Current as PHIEUNHAP;
         if (db.PHIEUNHAPs.SingleOrDefault(x => x.Spnhap == pn.Spnhap) == null)
         {
             db.PHIEUNHAPs.Add(pn);
             db.SaveChanges();
         }
         else
         {
             MetroMessageBox.Show(this, "Sản phẩm đã tồn tại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
             return;
         }
         LoadPhieuNhap();
     }
 }
コード例 #26
0
ファイル: ManagerLogin.cs プロジェクト: tuyet96/quanLyKhoMoi
        public static List <User> GetListUser()
        {
            List <User> listUser = new List <User>();

            using (QuanLyKhoEntities db = new QuanLyKhoEntities())
            {
                foreach (var item in db.Table_User)
                {
                    User _user = new User
                    {
                        UserName = item.UserName,
                        Name     = item.UserProfile.Name,
                        Role     = item.UserRoles.FirstOrDefault().RoleId
                    };
                    listUser.Add(_user);
                }
            }
            return(listUser);
        }
コード例 #27
0
        private void btnSuaDonVi_Click(object sender, EventArgs e)
        {
            using (QuanLyKhoEntities db = new QuanLyKhoEntities())
            {
                var dv  = dONVIBindingSource1.Current as DONVI;
                var Dvd = db.DONVIs.SingleOrDefault(x => x.ma == dv.ma);

                if (Dvd != null)
                {
                    Dvd.tendonvi = dv.tendonvi;
                    Dvd.chucnang = dv.chucnang;

                    db.DONVIs.Attach(Dvd);
                    db.Entry(Dvd).State = EntityState.Modified;
                    db.SaveChanges();
                    LoadDonVi();
                }
            }
        }
コード例 #28
0
        private void btnHxX_Click(object sender, EventArgs e)
        {
            using (QuanLyKhoEntities db = new QuanLyKhoEntities())
            {
                var xHX = hANGXUATBindingSource.Current as HANGXUAT;
                var xhx = db.HANGXUATs.SingleOrDefault(x => x.Spxuat == xHX.Spxuat);

                if (xhx != null)
                {
                    if (MetroMessageBox.Show(this, "Bạn chắc có muốn xóa?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        db.HANGXUATs.Attach(xhx);
                        db.HANGXUATs.Remove(xhx);
                        db.SaveChanges();
                        LoadHangXuat();
                    }
                }
            }
        }
コード例 #29
0
        private void btnXoaHN_Click(object sender, EventArgs e)
        {
            using (QuanLyKhoEntities db = new QuanLyKhoEntities())
            {
                var xHN = hANGNHAPBindingSource.Current as HANGNHAP;
                var xhn = db.HANGNHAPs.SingleOrDefault(x => x.Spnhap == xHN.Spnhap);

                if (xhn != null)
                {
                    if (MetroMessageBox.Show(this, "Bạn chắc có muốn xóa?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        db.HANGNHAPs.Attach(xhn);
                        db.HANGNHAPs.Remove(xhn);
                        db.SaveChanges();
                        LoadHangNhap();
                    }
                }
            }
        }
コード例 #30
0
        public bool ThemPhieuNhapHH(int ma_phieu, Phieu_Nhap_Json pn)
        {
            using (QuanLyKhoEntities db = new QuanLyKhoEntities())
            {
                using (var tran = db.Database.BeginTransaction())
                {
                    try
                    {
                        var pnhh = new Phieu_Nhap_Hang_Hoa();
                        pnhh.Phieu_Nhap_Id = ma_phieu;
                        pnhh.Don_gia       = pn.Don_gia;
                        pnhh.So_Luong      = pn.So_Luong;
                        pnhh.Hang_Hoa_id   = pn.Hang_Hoa_id;
                        db.Phieu_Nhap_Hang_Hoa.Add(pnhh);
                        var kho = db.Kho_Chua.Find(pnhh.Hang_Hoa_id);
                        if (kho != null)
                        {
                            kho.So_Luong       += pnhh.So_Luong;
                            db.Entry(kho).State = System.Data.Entity.EntityState.Modified;
                        }
                        else
                        {
                            kho                 = new Kho_Chua();
                            kho.Hang_Hoa_Id     = pnhh.Hang_Hoa_id;
                            kho.So_Luong        = pnhh.So_Luong;
                            db.Entry(kho).State = System.Data.Entity.EntityState.Added;
                        }



                        db.SaveChanges();
                        tran.Commit();

                        return(true);
                    }catch (Exception)
                    {
                        tran.Rollback();
                        return(false);
                    }
                }
            }
        }