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