private void btnAddProductImportDetail_Click(object sender, EventArgs e) { try { if (cmbIDBillImportDetail.Text == "" || cmbIDProductDetailStore.Text == "" || txtAmountOfProductImportDetail.Text == "") { XtraMessageBox.Show("Bạn phải điền đầy đủ thông tin !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } ChiTietHoaDonNhap_DTO phieunhap = new ChiTietHoaDonNhap_DTO(); phieunhap.MaHDN = cmbIDBillImportDetail.Text; phieunhap.MaSPDL = cmbIDProductDetailStore.Text; phieunhap.SoLuong = Convert.ToInt32(txtAmountOfProductImportDetail.Text.ToString()); if (ChiTietHoaDonNhap_BUS.ThemChiTietPHNhap(phieunhap)) { LoadPhieuNhapHang(); LoadChiTietPhieuNhapHang(); XtraMessageBox.Show("Thêm chi tiết phiếu nhập hàng thành công !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); uctSanPhamCH.uctSPCH.LoadSanPhamCH1(); ClearDisplay1(); return; } }catch { XtraMessageBox.Show("Sản phẩm đã tồn tại trong Hóa đơn", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } }
public bool ThemCTHDNhap(ChiTietHoaDonNhap_DTO cthd_nhap) { SqlConnection con = DataProvider.TaoKetNoi(); string query = "ThemCTHDNhap"; SqlCommand cm = new SqlCommand(query, con); cm.CommandType = CommandType.StoredProcedure; cm.Parameters.AddWithValue("@idHoaDonNhap", cthd_nhap.idHoaDonNhap); cm.Parameters.AddWithValue("@idGiay", cthd_nhap.idGiay); cm.Parameters.AddWithValue("@sizeGiay", cthd_nhap.size); cm.Parameters.AddWithValue("@soLuong", cthd_nhap.soLuong); cm.Parameters.AddWithValue("@donGia", cthd_nhap.donGia); int NumOfRow = cm.ExecuteNonQuery(); con.Close(); if (NumOfRow > 0) { return(true); } else { return(false); } }
public static bool SuaChiTietPhieuHangNhap(ChiTietHoaDonNhap_DTO phieuhang) { SqlConnection con = DataProvider.KetNoi(); try { cmd = new SqlCommand("SuaChiTietPHNhap", con); cmd.CommandType = CommandType.StoredProcedure; SqlParameter p = new SqlParameter("@MaHDN", phieuhang.MaHDN); cmd.Parameters.Add(p); p = new SqlParameter("@MaSPDL", phieuhang.MaSPDL); cmd.Parameters.Add(p); p = new SqlParameter("@SoLuong", phieuhang.SoLuong); cmd.Parameters.Add(p); cmd.ExecuteNonQuery(); DataProvider.DongKetNoi(con); return(true); } catch (Exception ex) { MessageBox.Show(ex.Message, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); DataProvider.DongKetNoi(con); return(false); } }
public static bool ThemChiTietPHNhapHang(ChiTietHoaDonNhap_DTO phieu) { SqlConnection con = DataProvider.KetNoi(); cmd = new SqlCommand("ThemChiTietPHNhap", con); try { cmd.CommandType = System.Data.CommandType.StoredProcedure; SqlParameter p = new SqlParameter("@MaHDN", phieu.MaHDN); cmd.Parameters.Add(p); p = new SqlParameter("@MaSPDL", phieu.MaSPDL); cmd.Parameters.Add(p); p = new SqlParameter("@SoLuong", phieu.SoLuong); cmd.Parameters.Add(p); cmd.ExecuteNonQuery(); DataProvider.DongKetNoi(con); return(true); } catch { DataProvider.DongKetNoi(con); return(false); } }
private void btnDeleteProductImportDetail_Click(object sender, EventArgs e) { if (cmbIDBillImportDetail.Text == "" || txtAmountOfProductImportDetail.Text == "" || cmbIDProductDetailStore.Text == "") { MessageBox.Show("Bạn phải chọn chi tiết phiếu cần xóa", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } ChiTietHoaDonNhap_DTO phieunhap = new ChiTietHoaDonNhap_DTO(); phieunhap.MaHDN = (string)dtgvListOfDetailProductImport.CurrentRow.Cells["MaSPDL"].Value; if (ChiTietHoaDonNhap_BUS.XoaChiTietPHNhap(phieunhap)) { LoadPhieuNhapHang(); LoadChiTietPhieuNhapHang(); MessageBox.Show("Chi tiết hóa đơn xóa thành công !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); ClearDisplay1(); return; } MessageBox.Show("Xóa chi tiết hóa đơn thất bại ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); return; }
private void btnUpdateProductImportDetail_Click(object sender, EventArgs e) { if (cmbIDBillImportDetail.Text == "") { MessageBox.Show("Bạn phải chọn chi tiết phiếu cần chỉnh sửa", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } ChiTietHoaDonNhap_DTO phieunhap = new ChiTietHoaDonNhap_DTO(); phieunhap.MaHDN = (string)dtgvListOfDetailProductImport.CurrentRow.Cells["MaHDN1"].Value; phieunhap.MaSPDL = cmbIDProductDetailStore.Text; phieunhap.SoLuong = Convert.ToInt32(txtAmountOfProductImportDetail.Text.ToString()); if (ChiTietHoaDonNhap_BUS.SuaChiTietPHNhap(phieunhap)) { LoadPhieuNhapHang(); LoadChiTietPhieuNhapHang(); MessageBox.Show("Chi tiết phiếu nhập hàng cập nhật thành công !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); ClearDisplay1(); return; } MessageBox.Show("Cập nhật Chi tiết hóa đơn thất bại ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); return; }
public List <ChiTietHoaDonNhap_DTO> LayDanhSach() { List <ChiTietHoaDonNhap_DTO> dsCTHDN = new List <ChiTietHoaDonNhap_DTO>(); // 1. Tạo đối tượng kết nối SqlConnection conn = DataProvider.TaoKetNoi(); SqlDataReader dr = null; try { // 2. mở kết nối // 3. tạo đối tượng command SqlCommand cmd = new SqlCommand(); cmd.CommandText = "SELECT * FROM [dbo].[CHITIETHOADONNHAP] WHERE TRANGTHAI = 1"; cmd.Connection = conn; // 4. thực thi cmd và xử lý kết quả dr = cmd.ExecuteReader(); while (dr.Read()) { ChiTietHoaDonNhap_DTO cTHDN = new ChiTietHoaDonNhap_DTO(); // đọc từng dòng dữ liệu if (!dr.IsDBNull(0)) { cTHDN.MaHDN = (string)dr[0]; } if (!dr.IsDBNull(1)) { cTHDN.MaHH = (string)dr[1]; } if (!dr.IsDBNull(2)) { cTHDN.SoLuong = (int)dr[2]; } if (!dr.IsDBNull(3)) { cTHDN.GiamGia = (double)dr[3]; } if (!dr.IsDBNull(4)) { cTHDN.ThanhTien = (double)dr[4]; } dsCTHDN.Add(cTHDN); } } finally { dr.Close(); // 5. đóng kết nối conn.Close(); } return(dsCTHDN); }
private void btnDeleteProductImportDetail_Click(object sender, EventArgs e) { try { if (cmbIDBillImportDetail.Text == "" || txtAmountOfProductImportDetail.Text == "" || cmbIDProductDetailStore.Text == "") { XtraMessageBox.Show("Bạn phải chọn chi tiết phiếu cần xóa", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } ChiTietHoaDonNhap_DTO phieunhap = new ChiTietHoaDonNhap_DTO(); phieunhap.MaHDN = (string)dtgvListOfDetailProductImport.CurrentRow.Cells["MaHDN1"].Value; phieunhap.MaSPDL = cmbIDProductDetailStore.Text; if (ChiTietHoaDonNhap_BUS.XoaChiTietPHNhap(phieunhap)) { LoadPhieuNhapHang(); LoadChiTietPhieuNhapHang(); uctSanPhamCH.uctSPCH.LoadSanPhamCH1(); XtraMessageBox.Show("Chi tiết hóa đơn xóa thành công !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); ClearDisplay1(); if (dtgvListOfDetailProductImport.Rows.Count == 0) { dtgvListOfDetailProductImport.ColumnCount = 3; dtgvListOfDetailProductImport.ColumnHeadersVisible = true; dtgvListOfDetailProductImport.Columns[0].Name = "MaHDN1"; dtgvListOfDetailProductImport.Columns[1].Name = "MaSPDL"; dtgvListOfDetailProductImport.Columns[2].Name = "SoLuong"; dtgvListOfDetailProductImport.Columns[0].DataPropertyName = "MaHDN"; dtgvListOfDetailProductImport.Columns[1].DataPropertyName = "MaSPDL"; dtgvListOfDetailProductImport.Columns[2].DataPropertyName = "SoLuong"; dtgvListOfDetailProductImport.Columns[0].HeaderText = "Mã HD nhập"; dtgvListOfDetailProductImport.Columns[1].HeaderText = "Mã SP Đại lí"; dtgvListOfDetailProductImport.Columns[2].HeaderText = "Số lượng"; dtgvListOfDetailProductImport.Columns[0].Width = 140; dtgvListOfDetailProductImport.Columns[1].Width = 140; dtgvListOfDetailProductImport.Columns[2].Width = 125; } return; } }catch { XtraMessageBox.Show("Xóa chi tiết hóa đơn thất bại ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } }
public static List <ChiTietHoaDonNhap_DTO> LoadChiTietPhieuNhap() { SqlConnection con = DataProvider.KetNoi(); try { cmd = new SqlCommand("DSChiTietPhieuNhap", con); cmd.CommandType = CommandType.StoredProcedure; cmd.ExecuteNonQuery(); da = new SqlDataAdapter(); da.SelectCommand = cmd; dt = new DataTable(); da.Fill(dt); } catch { return(null); } if (dt.Rows.Count == 0) { return(null); } List <ChiTietHoaDonNhap_DTO> dsChiTietPhieuNhap = new List <ChiTietHoaDonNhap_DTO>(); for (int i = 0; i < dt.Rows.Count; i++) { ChiTietHoaDonNhap_DTO phieuhang = new ChiTietHoaDonNhap_DTO(); phieuhang.MaHDN = dt.Rows[i]["MaHDN"].ToString(); phieuhang.MaSPDL = dt.Rows[i]["MaSPDL"].ToString(); phieuhang.SoLuong = Convert.ToInt32(dt.Rows[i]["SoLuong"].ToString()); dsChiTietPhieuNhap.Add(phieuhang); } DataProvider.DongKetNoi(con); return(dsChiTietPhieuNhap); }
public static bool XoaChiTietPhieuHangNhap(ChiTietHoaDonNhap_DTO phieuhang) { SqlConnection con = DataProvider.KetNoi(); try { cmd = new SqlCommand("XoaChiTietPHNhap", con); cmd.CommandType = CommandType.StoredProcedure; SqlParameter p = new SqlParameter("@MaSPDL", phieuhang.MaHDN); cmd.Parameters.Add(p); cmd.ExecuteNonQuery(); DataProvider.DongKetNoi(con); return(true); } catch { DataProvider.DongKetNoi(con); return(false); } }
private void btnThemSP_Click(object sender, EventArgs e) { if (txtTenGiay.Text != "") { txtMaNCC.Enabled = false; HoaDonNhap_BUS hdnhap_bus = new HoaDonNhap_BUS(); ChiTietHoaDonNhap_BUS cthdnhap_bus = new ChiTietHoaDonNhap_BUS(); HoaDonNhap_DTO hd_nhap = new HoaDonNhap_DTO(); hd_nhap = hdnhap_bus.LayHoaDonChuaNhapTheoMaNCC(txtMaNCC.Text); if (hd_nhap.id == -1) { HoaDonNhap_DTO hdnhap_moi = new HoaDonNhap_DTO(-1, BienToanCuc.nvDangNhap.idNhanVien, txtMaNCC.Text, DateTime.Now, 0, 0); if (hdnhap_bus.Them(hdnhap_moi)) { ChiTietHoaDonNhap_DTO cthd_nhap = new ChiTietHoaDonNhap_DTO(hdnhap_bus.LastID(), idGiay, cbSize.Text, int.Parse(txtSoLuongNhap.Text), int.Parse(txtGiaNhap.Text)); cthdnhap_bus.Them(cthd_nhap); HienThiCTHoaDonNhap(hdnhap_bus.LastID()); lvHoaDon.Tag = hdnhap_bus.LayHoaDonChuaNhapTheoMaNCC(txtMaNCC.Text); LoadHDNhap(); } } else { ChiTietHoaDonNhap_DTO cthd_nhap = new ChiTietHoaDonNhap_DTO(hd_nhap.id, idGiay, cbSize.Text, int.Parse(txtSoLuongNhap.Text), int.Parse(txtGiaNhap.Text)); cthdnhap_bus.Them(cthd_nhap); HienThiCTHoaDonNhap(hd_nhap.id); lvHoaDon.Tag = hd_nhap; LoadHDNhap(); } ResetSP(); } else { MessageBox.Show("Vui lòng chọn sản phẩm !!", "Cảnh Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
public bool Them(ChiTietHoaDonNhap_DTO cthd_nhap) { ChiTietHoaDonNhap_DAO objChiTietHoaDonNhap_DAO = new ChiTietHoaDonNhap_DAO(); return(objChiTietHoaDonNhap_DAO.ThemCTHDNhap(cthd_nhap)); }
public static bool SuaChiTietPHNhap(ChiTietHoaDonNhap_DTO phieu) { return(ChiTietHoaDonNhap_DAL.SuaChiTietPhieuHangNhap(phieu)); }
public static bool XoaChiTietPHNhap(ChiTietHoaDonNhap_DTO phieunhap) { return(ChiTietHoaDonNhap_DAL.XoaChiTietPhieuHangNhap(phieunhap)); }
public static bool ThemChiTietPHNhap(ChiTietHoaDonNhap_DTO phieu) { return(ChiTietHoaDonNhap_DAL.ThemChiTietPHNhapHang(phieu)); }