//Chi tiết private void btnXemChiTiet_Click(object sender, RoutedEventArgs e) { PhieuNhapPublic _phieuNhap = (dgDsPhieuNhap.SelectedItem as PhieuNhapPublic); ChiTietPhieuNhapPresentation wpf = new ChiTietPhieuNhapPresentation(); wpf._phieuNhap = _phieuNhap; wpf.ShowDialog(); }
//Thêm phiếu nhập hàng mới private static void ThemPhieuNhap(PhieuNhapPublic _phieunhap) { SqlCommand _cmd = new SqlCommand(); _cmd.CommandType = CommandType.StoredProcedure; _cmd.CommandText = "[Thêm phiếu nhập hàng]"; _cmd.Parameters.AddWithValue("@SoPhieu_PN", _phieunhap.SoPhieu_PN); _cmd.Parameters.AddWithValue("@NgayNhap_PN", _phieunhap.NgayNhap_PN); _cmd.Parameters.AddWithValue("@NguoiNhap_PN", _phieunhap.NguoiNhap_PN.MaNV_NV); _cmd.Parameters.AddWithValue("@GhiChu_PN", _phieunhap.GhiChu_PN); conn.Execute(_cmd); }
void TaoPhieuNhap() { //PHIẾU NHẬP: Số phiếu, ngày nhập , người lập, ghi chú _phieuNhap = new PhieuNhapPublic(); _phieuNhap.NguoiNhap_PN = _nhanVien; _phieuNhap.SoPhieu_PN = UntilitiesBusiness.GetNextID("tbl_PHIEUNHAP", "SoPhieu_PN", "PH.", 10); lbSoPhieu.Content = _phieuNhap.SoPhieu_PN; _phieuNhap.NgayNhap_PN = DateTime.Today; dtNgayNhap.SelectedDate = DateTime.Today; _phieuNhap.GhiChu_PN = ""; rtxtGhiChu.Document.Blocks.Clear(); //CHI TIẾT HÀNG NHẬP: Thông tin sản phẩm, số lượng, thành tiền _ListSpNhap = new List <SanPhamPublic>(); _ListSpNhap.Clear(); lbTongTien.Content = "0"; lbTongSP.Content = "0"; }
//Nhập Hàng public static void NhapHang(PhieuNhapPublic _phieunhap, List <SanPhamPublic> _ListSPNhap) { //Thêm phiếu nhập ThemPhieuNhap(_phieunhap); //Thêm chi tiết hàng nhập HangNhapPublic _hangNhap = new HangNhapPublic(); _hangNhap.PhieuNhap_HN.SoPhieu_PN = _phieunhap.SoPhieu_PN; foreach (SanPhamPublic _spNhap in _ListSPNhap) { if (_spNhap.SoLuong_SP <= 0) { continue; } _hangNhap.SanPham_HN.MaSP_SP = _spNhap.MaSP_SP; _hangNhap.SoLuong_HN = _spNhap.SoLuong_SP; ThemHangNhap(_hangNhap); ThemSoLuongSPVaoKho(_spNhap); } }
//PHIẾU NHẬP public static List <PhieuNhapPublic> LayPhieuNhapTheoNgay(DateTime _dtTuNgay, DateTime _dtDenNgay) { DateTime _dtNgayBatDau = new DateTime(_dtTuNgay.Year, _dtTuNgay.Month, _dtTuNgay.Day, 0, 0, 0); DateTime _dtNgayKetThuc = new DateTime(_dtDenNgay.Year, _dtDenNgay.Month, _dtDenNgay.Day, 23, 59, 59); //Lấy danh sách phiếu nhập trong khoảng thời gian List <PhieuNhapPublic> _lstPhieuNhap = new List <PhieuNhapPublic>(); PhieuNhapPublic _phieuNhap; SqlCommand _cmd = new SqlCommand(); _cmd.CommandType = CommandType.StoredProcedure; _cmd.CommandText = "[Lấy danh sách phiếu nhập]"; _cmd.Parameters.AddWithValue("@TuNgay", _dtNgayBatDau); _cmd.Parameters.AddWithValue("@DenNgay", _dtNgayKetThuc); DataTable _dtPhieuNhap = conn.GetDataSet2(_cmd).Tables[0]; if (_dtPhieuNhap.Rows.Count > 0) { for (int i = 0; i < _dtPhieuNhap.Rows.Count; i++) { _phieuNhap = new PhieuNhapPublic(); _phieuNhap.SoPhieu_PN = _dtPhieuNhap.Rows[i]["SoPhieu_PN"].ToString(); _phieuNhap.NgayNhap_PN = Convert.ToDateTime(_dtPhieuNhap.Rows[i]["NgayNhap_PN"].ToString()); _phieuNhap.NguoiNhap_PN.MaNV_NV = _dtPhieuNhap.Rows[i]["NguoiNhap_PN"].ToString(); _phieuNhap.NguoiNhap_PN.HoTen_NV = _dtPhieuNhap.Rows[i]["HoTen_NV"].ToString(); _phieuNhap.GhiChu_PN = _dtPhieuNhap.Rows[i]["GhiChu_PN"].ToString(); _lstPhieuNhap.Add(_phieuNhap); } } return(_lstPhieuNhap); }
//Nhập Hàng public static void NhapHang(PhieuNhapPublic _phieunhap, List <SanPhamPublic> _ListSPNhap) { NhapMuaDataAccess.NhapHang(_phieunhap, _ListSPNhap); }