Example #1
0
        private void btnXoa_Click(object sender, RoutedEventArgs e)
        {
            HANG_HOA temp = (HANG_HOA)lvHangHoa.SelectedItem;

            //Bắt lỗi chưa chọn hàng hoá trong listview
            if (lvHangHoa.SelectedIndex < 0)
            {
                MessageBox.Show("Bạn chưa chọn Nhà cung cấp!", "Thông báo");
                return;
            }

            if (MessageBox.Show("Bạn có chắc chắn muốn xoá không!", "Cảnh báo", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
            {
                using (QLKHOEntities db = new QLKHOEntities())
                {
                    var entry = db.Entry(temp);
                    if (entry.State == System.Data.Entity.EntityState.Detached)
                    {
                        db.HANG_HOA.Attach(temp);
                    }
                    db.HANG_HOA.Remove(temp);
                    db.SaveChanges();
                    MessageBox.Show("Xoá thành công!", "Thông báo");
                    LoadDuLieu();
                }
            }
            else
            {
                return;
            }
        }
Example #2
0
 private void LoadDuLieu()
 {
     using (QLKHOEntities db = new QLKHOEntities())
     {
         lvHangHoa.ItemsSource = db.HANG_HOA.ToList <HANG_HOA>();
     }
 }
Example #3
0
        private void btnTim_Click(object sender, RoutedEventArgs e)
        {
            if (txtTim.Text == "")
            {
                MessageBox.Show("Bạn chưa nhập thông tin tìm kiếm!", "Thông báo!");
            }

            using (QLKHOEntities db = new QLKHOEntities())
            {
                List <PHIEU_XUAT_HH> x = db.PHIEU_XUAT_HH.ToList();

                List <PHIEU_XUAT_HH> listFound = new List <PHIEU_XUAT_HH>();

                foreach (PHIEU_XUAT_HH y in x)
                {
                    if (txtTim.Text.Trim().Equals(y.NGAYXUAT.ToString(), StringComparison.OrdinalIgnoreCase) == true ||
                        txtTim.Text.Trim().Equals(y.MAHH, StringComparison.OrdinalIgnoreCase) == true ||
                        txtTim.Text.Trim().Equals(y.MANCC, StringComparison.OrdinalIgnoreCase) == true ||
                        Int32.Parse(txtTim.Text.Trim()) == y.GIA ||
                        Int32.Parse(txtTim.Text.Trim()) == y.TIEN ||
                        Int32.Parse(txtTim.Text.Trim()) == y.SOLUONG)
                    {
                        listFound.Add(y);
                    }
                }

                lvNhaCungCap.ItemsSource = listFound;
            }
        }
Example #4
0
        private void btnTim_Click(object sender, RoutedEventArgs e)
        {
            using (QLKHOEntities db = new QLKHOEntities())
            {
                List <NHA_CUNG_CAP> x = db.NHA_CUNG_CAP.ToList <NHA_CUNG_CAP>();

                List <NHA_CUNG_CAP> listFound = new List <NHA_CUNG_CAP>();

                foreach (NHA_CUNG_CAP y in x)
                {
                    if (txtTim.Text.Trim().Equals(y.MA_NCC, StringComparison.OrdinalIgnoreCase) == true ||
                        txtTim.Text.Trim().Equals(y.TEN_NCC, StringComparison.OrdinalIgnoreCase) == true ||
                        txtTim.Text.Trim().Equals(y.DIACHI, StringComparison.OrdinalIgnoreCase) == true ||
                        txtTim.Text.Trim().Equals(y.DIEN_THOAI, StringComparison.OrdinalIgnoreCase) == true ||
                        txtTim.Text.Trim().Equals(y.EMAIL, StringComparison.OrdinalIgnoreCase) == true ||
                        txtTim.Text.Trim().Equals(y.FAX, StringComparison.OrdinalIgnoreCase) == true ||
                        txtTim.Text.Trim().Equals(y.MA_SO_THUE, StringComparison.OrdinalIgnoreCase) == true ||
                        txtTim.Text.Trim().Equals(y.SO_TAI_KHOAN, StringComparison.OrdinalIgnoreCase) == true)
                    {
                        listFound.Add(y);
                    }
                }

                lvNhaCungCap.ItemsSource = listFound;
            }
        }
Example #5
0
 //Load dữ liệu lên listview
 private void LoadDuLieu()
 {
     using (QLKHOEntities db = new QLKHOEntities())
     {
         lvNhaCungCap.ItemsSource = db.PHIEU_NHAP_HH.ToList();
     }
     //lvNhaCungCap.SelectedIndex = 0;
 }
Example #6
0
 //Load dữ liệu lên listview
 private void LoadDuLieu()
 {
     using (QLKHOEntities db = new QLKHOEntities())
     {
         lvNhaCungCap.ItemsSource = db.NHA_CUNG_CAP.ToList <NHA_CUNG_CAP>();
     }
     //lvNhaCungCap.SelectedIndex = 0;
 }
Example #7
0
        private void btnThem_Click(object sender, RoutedEventArgs e)
        {
            //Biến tạm lưu dữ liệu nhập
            HANG_HOA temp = new HANG_HOA();

            //HANG_HOA temp = (HANG_HOA)AreaText.DataContext;


            //kiểm tra dữ liệu nhập
            if (CheckDataInput() == false)
            {
                return;
            }


            //Gán dữ liệu
            temp.MA_HH    = txtMa.Text.Trim();
            temp.TEN_HH   = txtTen.Text.Trim();
            temp.MA_NCC   = txtMaNCC.Text.Trim();
            temp.GIA_NHAP = Int32.Parse(txtGiaNhap.Text.Trim());
            temp.GIA_XUAT = Int32.Parse(txtGiaXuat.Text.Trim());
            temp.SO_LUONG = Int32.Parse(txtSoLuong.Text.Trim());


            // kiểm tra mã hàng hoá
            if (CheckID() == false)
            {
                return;
            }

            // kiểm tra mã nhà cung cấp không tồn tại
            if (CheckMaNCC() == false)
            {
                return;
            }


            //Nhắc nhở lưu đối tượng
            if (MessageBox.Show("Bạn muốn thêm mới?", "Thông báo", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
            {
                using (QLKHOEntities db = new QLKHOEntities())
                {
                    db.HANG_HOA.Add(temp);
                    db.SaveChanges();
                }
                MessageBox.Show("Thêm thành công!");
            }
            else
            {
                return;
            }

            //Load lại bảng
            LoadDuLieu();
        }
Example #8
0
        private void btnThem_Click(object sender, RoutedEventArgs e)
        {
            //Biến tạm lưu dữ liệu nhập
            NHA_CUNG_CAP test = new NHA_CUNG_CAP();

            //NHA_CUNG_CAP test = (NHA_CUNG_CAP)AreaText.DataContext;

            //Gán dữ liệu
            test.MA_NCC       = txtMa.Text.Trim();
            test.TEN_NCC      = txtTen.Text.Trim();
            test.DIACHI       = txtDiaChi.Text.Trim();
            test.MA_SO_THUE   = txtMaSoThue.Text.Trim();
            test.DIEN_THOAI   = txtDienThoai.Text.Trim();
            test.EMAIL        = txtEmail.Text.Trim();
            test.FAX          = txtFax.Text.Trim();
            test.SO_TAI_KHOAN = txtSoTaiKhoan.Text.Trim();

            //kiểm tra dữ liệu nhập
            if (CheckDataInput() == false)
            {
                return;
            }

            //
            if (CheckID() == false)
            {
                return;
            }

            //Nhắc nhở lưu đối tượng
            if (MessageBox.Show("Bạn muốn thêm nhà cung cấp mới?", "Thông báo", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
            {
                using (QLKHOEntities db = new QLKHOEntities())
                {
                    db.NHA_CUNG_CAP.Add(test);
                    db.SaveChanges();
                }
                MessageBox.Show("Thêm thành công!");
            }
            else
            {
                return;
            }

            //Load lại bảng
            LoadDuLieu();
        }
Example #9
0
        //kiểm tra mã nhà cung cấp
        private bool CheckMaNCC()
        {
            using (QLKHOEntities db = new QLKHOEntities())
            {
                List <NHA_CUNG_CAP> listNCC = db.NHA_CUNG_CAP.ToList <NHA_CUNG_CAP>();

                foreach (NHA_CUNG_CAP x in listNCC)
                {
                    if (txtMaNCC.Text.Equals(x.MA_NCC) == true)
                    {
                        return(true);
                    }
                }
            }
            MessageBox.Show("Mã hàng hoá không tồn tại!", "Cảnh báo", MessageBoxButton.OK, MessageBoxImage.Warning);
            return(false);
        }
Example #10
0
        private void btnAccept_Click(object sender, RoutedEventArgs e)
        {
            using (QLKHOEntities db = new QLKHOEntities())
            {
                List <Tai_Khoan> t = db.Tai_Khoan.ToList();

                foreach (Tai_Khoan y in t)
                {
                    if (txtTenDangNhap.Text.Equals(y.username.Trim()) == true && txtMatKhau.Password.Equals(y.username.Trim()) == true)
                    {
                        this.Hide();
                        new ViewBack().ShowDialog();
                        this.Close();
                    }
                    txtCanhBao.Visibility = Visibility.Visible;
                }
            }
        }
Example #11
0
        private void btnThem_Click(object sender, RoutedEventArgs e)
        {
            //Biến tạm lưu dữ liệu nhập
            PHIEU_NHAP_HH test = new PHIEU_NHAP_HH();

            //NHA_CUNG_CAP test = (NHA_CUNG_CAP)AreaText.DataContext;

            //Gán dữ liệu
            test.NGAYNHAP = DateTime.Parse(txtNgay.Text);
            test.MANCC    = txtMaNCC.Text.Trim();
            test.MAHH     = txtMaHH.Text.Trim();
            test.SOLUONG  = Int32.Parse(txtSL.Text.Trim());
            test.GIA      = Int32.Parse(txtGia.Text.Trim());
            test.TIEN     = Int32.Parse(txtSL.Text.Trim()) * Int32.Parse(txtGia.Text.Trim());
            test.DIENGIAI = txtDienGiai.Text.Trim();

            //kiểm tra dữ liệu nhập
            if (CheckDataInput() == false)
            {
                return;
            }

            //
            //if (CheckID() == false)
            //return;

            //Nhắc nhở lưu đối tượng
            if (MessageBox.Show("Bạn muốn thêm phiếu nhập mới?", "Thông báo", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
            {
                using (QLKHOEntities db = new QLKHOEntities())
                {
                    db.PHIEU_NHAP_HH.Add(test);
                    db.SaveChanges();
                }
                MessageBox.Show("Thêm thành công!");
            }
            else
            {
                return;
            }

            //Load lại bảng
            LoadDuLieu();
        }
Example #12
0
        //Kiểm tra mã trùng
        private bool CheckID()
        {
            using (QLKHOEntities db = new QLKHOEntities())
            {
                List <NHA_CUNG_CAP> x = db.NHA_CUNG_CAP.ToList <NHA_CUNG_CAP>();

                foreach (NHA_CUNG_CAP y in x)
                {
                    if (txtMa.Text == y.MA_NCC)
                    {
                        MessageBox.Show("Mã nhà cung cấp đã tồn tại!");
                        return(false);
                    }
                }
            }


            return(true);
        }
Example #13
0
        //Kiểm tra mã trùng
        private bool CheckID()
        {
            using (QLKHOEntities db = new QLKHOEntities())
            {
                List <HANG_HOA> x = db.HANG_HOA.ToList <HANG_HOA>();

                foreach (HANG_HOA y in x)
                {
                    if (txtMa.Text == y.MA_HH)
                    {
                        MessageBox.Show("Mã hàng hoá đã tồn tại!");
                        return(false);
                    }
                }
            }


            return(true);
        }
Example #14
0
        private void btnLuu_Click(object sender, RoutedEventArgs e)
        {
            //Tạm lưu dữ liệu nhập
            HANG_HOA temp = new HANG_HOA();

            //Gán dữ liệu
            temp.MA_HH    = txtMa.Text.Trim();
            temp.TEN_HH   = txtTen.Text.Trim();
            temp.MA_NCC   = txtMaNCC.Text.Trim();
            temp.GIA_NHAP = Int32.Parse(txtGiaNhap.Text.Trim());
            temp.GIA_XUAT = Int32.Parse(txtGiaXuat.Text.Trim());
            temp.SO_LUONG = Int32.Parse(txtSoLuong.Text.Trim());

            //kiểm tra dữ liệu nhập
            if (CheckDataInput() == false)
            {
                return;
            }

            //Bắt lỗi chưa chọn hang hoa trong listview
            if (lvHangHoa.SelectedIndex < 0)
            {
                MessageBox.Show("Bạn chưa chọn hàng hoá!", "Thông báo");
                return;
            }

            // kiểm tra mã nhà cung cấp không tồn tại
            if (CheckMaNCC() == false)
            {
                return;
            }

            if (MessageBox.Show("Bạn có chắc chắn muốn lưu không!", "Cảnh báo", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
            {
                using (QLKHOEntities db = new QLKHOEntities())
                {
                    db.Entry(temp).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();
                    MessageBox.Show("Lưu thành công!", "Thông báo");
                    LoadDuLieu();
                }
            }
        }
Example #15
0
        private void btnTim_Click(object sender, RoutedEventArgs e)
        {
            using (QLKHOEntities db = new QLKHOEntities())
            {
                List <HANG_HOA> x = db.HANG_HOA.ToList <HANG_HOA>();

                List <HANG_HOA> listFound = new List <HANG_HOA>();

                foreach (HANG_HOA y in x)
                {
                    if (txtTim.Text.Trim().Equals(y.MA_NCC, StringComparison.OrdinalIgnoreCase) == true ||
                        txtTim.Text.Trim().Equals(y.MA_HH, StringComparison.OrdinalIgnoreCase) == true ||
                        txtTim.Text.Trim().Equals(y.TEN_HH, StringComparison.OrdinalIgnoreCase) == true
                        )
                    {
                        listFound.Add(y);
                    }
                }

                lvHangHoa.ItemsSource = listFound;
            }
        }
Example #16
0
        private void btnLuu_Click(object sender, RoutedEventArgs e)
        {
            //Tạm lưu dữ liệu nhập
            NHA_CUNG_CAP temp = new NHA_CUNG_CAP();

            //Gán dữ liệu
            temp.MA_NCC       = txtMa.Text.Trim();
            temp.TEN_NCC      = txtTen.Text.Trim();
            temp.DIACHI       = txtDiaChi.Text.Trim();
            temp.MA_SO_THUE   = txtMaSoThue.Text.Trim();
            temp.DIEN_THOAI   = txtDienThoai.Text.Trim();
            temp.EMAIL        = txtEmail.Text.Trim();
            temp.FAX          = txtFax.Text.Trim();
            temp.SO_TAI_KHOAN = txtSoTaiKhoan.Text.Trim();

            //kiểm tra dữ liệu nhập
            if (CheckDataInput() == false)
            {
                return;
            }

            //Bắt lỗi chưa chọn nhà cung cấp trong listview
            if (lvNhaCungCap.SelectedIndex < 0)
            {
                MessageBox.Show("Bạn chưa chọn Nhà cung cấp!", "Thông báo");
                return;
            }

            if (MessageBox.Show("Bạn có chắc chắn muốn lưu không!", "Cảnh báo", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
            {
                using (QLKHOEntities db = new QLKHOEntities())
                {
                    db.Entry(temp).State = EntityState.Modified;
                    db.SaveChanges();
                    MessageBox.Show("Lưu thành công!", "Thông báo");
                    LoadDuLieu();
                }
            }
        }
Example #17
0
        private void btnLuu_Click(object sender, RoutedEventArgs e)
        {
            //Tạm lưu dữ liệu nhập
            PHIEU_NHAP_HH temp = (PHIEU_NHAP_HH)lvNhaCungCap.SelectedItem;

            //Gán dữ liệu
            temp.NGAYNHAP = DateTime.Parse(txtNgay.Text);
            temp.MANCC    = txtMaHH.Text.Trim();
            temp.MAHH     = txtMaHH.Text.Trim();
            temp.SOLUONG  = Int32.Parse(txtSL.Text.Trim());
            temp.GIA      = Int32.Parse(txtGia.Text.Trim());
            temp.TIEN     = Int32.Parse(txtSL.Text.Trim()) * Int32.Parse(txtGia.Text.Trim());
            temp.DIENGIAI = txtDienGiai.Text.Trim();

            //kiểm tra dữ liệu nhập
            if (CheckDataInput() == false)
            {
                return;
            }

            //Bắt lỗi chưa chọn nhà cung cấp trong listview
            if (lvNhaCungCap.SelectedIndex < 0)
            {
                MessageBox.Show("Bạn chưa chọn Nhà cung cấp!", "Thông báo");
                return;
            }

            if (MessageBox.Show("Bạn có chắc chắn muốn lưu không!", "Cảnh báo", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
            {
                using (QLKHOEntities db = new QLKHOEntities())
                {
                    db.Entry(temp).State = EntityState.Modified;
                    db.SaveChanges();
                    MessageBox.Show("Lưu thành công!", "Thông báo");
                    LoadDuLieu();
                }
            }
        }
Example #18
0
        private void btnTim_Click(object sender, RoutedEventArgs e)
        {
            using (QLKHOEntities db = new QLKHOEntities())
            {
                List <PHIEU_NHAP_HH> x = db.PHIEU_NHAP_HH.ToList();

                List <PHIEU_NHAP_HH> listFound = new List <PHIEU_NHAP_HH>();

                foreach (PHIEU_NHAP_HH y in x)
                {
                    if (txtTim.Text.Trim().Equals(y.NGAYNHAP.ToString(), StringComparison.OrdinalIgnoreCase) == true ||
                        txtTim.Text.Trim().Equals(y.MAHH, StringComparison.OrdinalIgnoreCase) == true ||
                        txtTim.Text.Trim().Equals(y.MANCC, StringComparison.OrdinalIgnoreCase) == true ||
                        Int32.Parse(txtTim.Text.Trim()) == y.GIA ||
                        Int32.Parse(txtTim.Text.Trim()) == y.TIEN ||
                        Int32.Parse(txtTim.Text.Trim()) == y.SOLUONG)
                    {
                        listFound.Add(y);
                    }
                }

                lvNhaCungCap.ItemsSource = listFound;
            }
        }