public int createGoodsReceipt(DTO.GoodsReceipt dto_PNH, DTO.GoodsReceiptDetails[] dto_CT, int so_nl) { if (MessageBox.Show("Bạn có chắc chắn muốn lưu phiếu nhập hàng?", "Xác nhận!", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { DAO.GoodsReceipt dao_PKH = new DAO.GoodsReceipt(); int maphieu = dao_PKH.createGoodsReceipt(dto_PNH); BUS.GoodsReceiptDetails bus = new BUS.GoodsReceiptDetails(); for (int i = 0; i < so_nl; i++) { bus.addGoodsReceiptDetails(dto_CT[i], maphieu); } MessageBox.Show("Lưu phiếu nhập hàng thành công!", "Thông báo!", MessageBoxButtons.OK, MessageBoxIcon.Information); return(1); } return(0); }
public int createGoodsReceipt(DTO.GoodsReceipt dto_PNH) { SqlConnection cn = DBConnection.connectDB(); SqlCommand cmd = new SqlCommand("sp_CreateGoodsReceipt", cn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@maphieudat", SqlDbType.Int); cmd.Parameters.Add("@manv", SqlDbType.Int); cmd.Parameters.Add("@ngaygio", SqlDbType.DateTime); cmd.Parameters.Add("@maphieu", SqlDbType.Int).Direction = ParameterDirection.Output; cmd.Parameters["@maphieudat"].Value = dto_PNH.Maphieudat; cmd.Parameters["@manv"].Value = dto_PNH.Manv; cmd.Parameters["@ngaygio"].Value = dto_PNH.Ngaygio; cmd.Parameters["@maphieu"].Value = -1; cmd.ExecuteNonQuery(); cn.Close(); return(Convert.ToInt32(cmd.Parameters["@maphieu"].Value)); }