public int AddDeliveryBillDetail(DtoDeliveryBillDetail data)
        {
            SqlParameter[] para =
            {
                new SqlParameter("@MaChiTietPhieuXuatKho", data.MaChiTietPhieuXuatKho),
                new SqlParameter("@MaPhieuXuatKho", data.MaPhieuXuatKho),
                new SqlParameter("@MaSanPham", data.MaSanPham),
                new SqlParameter("@SoLuong", data.SoLuong),
                new SqlParameter("@GhiChu", data.GhiChu),
            };

            try
            {
                return SqlHelper.ExecuteNonQuery(Constants.ConnectionString, CommandType.StoredProcedure,
                    "AddDeliveryBillDetail",
                    para);
            }
            catch (SqlException)
            {
                throw new ArgumentException(Constants.MsgExceptionSql);
            }
            catch (Exception)
            {
                throw new AggregateException(Constants.MsgExceptionError);
            }
        }
        private void btnThem_Click(object sender, EventArgs e)
        {
            List<DtoDeliveryBillDetail> list = new List<DtoDeliveryBillDetail>();
            DtoDeliveryBill DeliveryBill = new DtoDeliveryBill();
            DeliveryBill.MaPhieuXuatKho = txtMaPhieuXuatKho.Text;
            DeliveryBill.NgayLapPhieu = DateTime.Now;
            DeliveryBill.MaNguoiNhan = maNguoiNhanComboBox.SelectedValue.ToString();
            DeliveryBill.MaNguoiLapPhieu = nguoiLapPhieuComboBox.SelectedValue.ToString();
            DeliveryBill.GhiChu = txtGhiChu.Text;

            for (int i = 0; i < dgvDetailDeliveryBill.Rows.Count - 1; i++)
            {
                DtoDeliveryBillDetail detail = new DtoDeliveryBillDetail();
                detail.MaChiTietPhieuXuatKho = dgvDetailDeliveryBill.Rows[i].Cells[0].Value.ToString();
                detail.MaPhieuXuatKho = DeliveryBill.MaPhieuXuatKho;
                detail.MaSanPham = dgvDetailDeliveryBill.Rows[i].Cells[1].Value.ToString();
                detail.SoLuong = int.Parse(dgvDetailDeliveryBill.Rows[i].Cells[3].Value.ToString());
                detail.GhiChu = dgvDetailDeliveryBill.Rows[i].Cells[4].Value.ToString();
                list.Add(detail);
            }

            if (_bllDeliveryBill.AddDeliveryBillTran(DeliveryBill, list))
            {
                MessageBox.Show(Constants.MsgNotificationSuccessfuly);
                btnThoat.PerformClick();
            }
            else
            {
                MessageBox.Show(Constants.MsgExceptionError);
            }
        }