private void UcRawImported_Loaded(object sender, RoutedEventArgs e) { NhaCungCapController nhaCungCap = new NhaCungCapController(); NguyenLieuController nguyenLieu = new NguyenLieuController(); PhieuNhapController phieuNhap = new PhieuNhapController(); cbbNhaCungCap.ItemsSource = nhaCungCap.GetName(); cbbTenNguyenLieu.ItemsSource = nguyenLieu.GetName(); cbbNhaCungCap.SelectedIndex = 0; btnLuu.IsEnabled = false; btnHuy.IsEnabled = false; cbbTenNguyenLieu.IsEnabled = false; txtSoLuongNhap.IsEnabled = false; dtpHanSuDung.IsEnabled = false; txtGia.IsEnabled = false; txtGhiChu.IsEnabled = false; LoadDSPhieuNhap(); dgvPhieuNhap.Columns[0].Header = "Tên nguyên liệu"; dgvPhieuNhap.Columns[1].Header = "Số lượng"; dgvPhieuNhap.Columns[2].Header = "Hạn sử dụng"; dgvPhieuNhap.Columns[3].Header = "Giá"; dgvPhieuNhap.Columns[4].Header = "Ghi chú"; dgvPhieuNhap.Columns[5].Header = "Tổng tiền"; }
private void SearchNhaCungCap() { NhaCungCapController ncc = new NhaCungCapController(); dgvNhaCungCap.ItemsSource = ncc.Search(txtTimKiem.Text).DefaultView; dgvNhaCungCap.Columns[0].Visibility = Visibility.Collapsed; dgvNhaCungCap.SelectedIndex = 0; }
private void LoadNhaCungCap() { NhaCungCapController ncc = new NhaCungCapController(); dgvNhaCungCap.ItemsSource = ncc.GetData().DefaultView; dgvNhaCungCap.Columns[0].Visibility = Visibility.Collapsed; dgvNhaCungCap.SelectedIndex = 0; }
private void BtnLuuPhieuNhap_Click(object sender, RoutedEventArgs e) { if (ctpn.Count > 0) { NhaCungCapController nhaCungCap = new NhaCungCapController(); PhieuNhapController phieuNhap = new PhieuNhapController(); NguyenLieuController nguyenLieu = new NguyenLieuController(); int mancc = nhaCungCap.NameToId(cbbNhaCungCap.Text); DateTime ngayNhap = DateTime.Now; int tongTien = Convert.ToInt32(txtTongTien.Text); try { phieuNhap.Create(manv, mancc, ngayNhap, txtGhiChuPN.Text, tongTien); int maPN = phieuNhap.GetLastId(); foreach (var item in ctpn) { int maNL = nguyenLieu.NameToId(item.TenNL); DateTime hsd = Convert.ToDateTime(item.HanSuDung); phieuNhap.CreateDetails(maPN, maNL, hsd, item.SoLuongNhap, item.Gia, item.GhiChu); } MessageBox.Show("Lưu phiếu nhập thành công!", "Thông báo!", MessageBoxButton.OK, MessageBoxImage.Information); ctpn.Clear(); cbbTenNguyenLieu.IsEnabled = false; cbbTenNguyenLieu.SelectedIndex = 0; txtSoLuongNhap.IsEnabled = false; txtSoLuongNhap.Text = ""; dtpHanSuDung.IsEnabled = false; dtpHanSuDung.SelectedDate = DateTime.Now; txtGia.IsEnabled = false; txtGia.Text = ""; txtGhiChu.IsEnabled = false; txtGhiChu.Text = ""; LoadDSPhieuNhap(); txtGhiChuPN.Text = ""; tongTien = 0; txtTongTien.Text = tongTien.ToString(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Lỗi", MessageBoxButton.OK, MessageBoxImage.Error); } } }
public ucImportedDetails(int id) { InitializeComponent(); PhieuNhapController phieuNhap = new PhieuNhapController(); NhaCungCapController ncc = new NhaCungCapController(); dgvPhieuNhapDetails.ItemsSource = phieuNhap.GetDetails(id).DefaultView; int nccid = phieuNhap.GetDistributorId(id); txtNhaCungCap.Text = ncc.IdToName(nccid); txtGhiChuPN.Text = phieuNhap.GetNote(id); txtTongTien.Text = phieuNhap.GetTotal(id); btnClose.Click += BtnClose_Click; }
private void BtnLuu_Click(object sender, RoutedEventArgs e) { NhaCungCapController ncc = new NhaCungCapController(); if (txtTenNCC.Text == "") { MessageBox.Show("Bạn phải nhập tên nhà cung cấp!", "Lỗi!", MessageBoxButton.OK, MessageBoxImage.Error); txtTenNCC.Focus(); } else if (txtDiaChi.Text == "") { MessageBox.Show("Bạn phải nhập địa chỉ nhà cung cấp!", "Lỗi!", MessageBoxButton.OK, MessageBoxImage.Error); txtDiaChi.Focus(); } else if (txtSoDienThoai.Text == "") { MessageBox.Show("Bạn phải nhập số điện thoại nhà cung cấp!", "Lỗi!", MessageBoxButton.OK, MessageBoxImage.Error); txtSoDienThoai.Focus(); } else { if (isEditing) { ncc.Edit(nccId, txtTenNCC.Text, txtDiaChi.Text, txtSoDienThoai.Text); isEditing = false; dgvNhaCungCap.IsEnabled = true; } else { ncc.Create(txtTenNCC.Text, txtDiaChi.Text, txtSoDienThoai.Text); } dgvNhaCungCap.IsEnabled = true; LoadNhaCungCap(); btnThem.IsEnabled = true; btnSua.IsEnabled = true; btnXoa.IsEnabled = true; btnReload.IsEnabled = true; btnLuu.IsEnabled = false; btnHuy.IsEnabled = false; txtTenNCC.IsEnabled = false; txtDiaChi.IsEnabled = false; txtSoDienThoai.IsEnabled = false; } }
private void BtnXoa_Click(object sender, RoutedEventArgs e) { MessageBoxResult result = MessageBox.Show("Bạn có chắc muốn xóa nhà cung cấp này?", "Xác nhận!", MessageBoxButton.OKCancel, MessageBoxImage.Question); if (result == MessageBoxResult.OK) { NhaCungCapController ncc = new NhaCungCapController(); try { ncc.Delete(nccId); MessageBox.Show("Xóa thành công!", "Thông báo!", MessageBoxButton.OK, MessageBoxImage.Information); LoadNhaCungCap(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Lỗi!", MessageBoxButton.OK, MessageBoxImage.Error); } } }