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 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 #3
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 #4
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 #5
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 #6
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 #7
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();
                }
            }
        }