private void btnThu_Click(object sender, EventArgs e)
 {
     if (int.Parse(txtTongNo.Text) < int.Parse(txtTienThu.Text))
     {
         MessageBox.Show("Số tiền thu phải nhỏ hơn hoặc bằng tiền nợ!!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else
     {
         En_ThuTienPhat thu = new En_ThuTienPhat(maPTT, cbMaThe.Text, int.Parse(txtTienThu.Text), int.Parse(txtConLai.Text), DateTime.Today);
         Bus_ThuTienPhat.ThuTienPhat(thu);                            // Tạo phiếu thu
         Sql_TraSach.TaiKhoanNo_update(cbMaThe.Text, txtConLai.Text); // Cập nhật lại tài khoản nợ sau khi thu tiền.
         MessageBox.Show("Đã thu thành công!!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     rpPhieuThuTien.RefreshReport();
     btInPhieu.Enabled = true;
     btnThu.Enabled    = false;
 }
        public static void ThuTienPhat(En_ThuTienPhat s)
        {
            SqlConnection conn = sqlConnectionData.KetNoi();
            SqlCommand    cmd  = new SqlCommand("PHIEUTHUTIENPHAT_insert", conn);

            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.Add("@MaPTT", SqlDbType.Char, 5);
            cmd.Parameters.Add("@MaThe", SqlDbType.Char, 5);
            cmd.Parameters.Add("@SoTienThu", SqlDbType.Int);
            cmd.Parameters.Add("@ConLai", SqlDbType.Int);
            cmd.Parameters.Add("@NgayThu", SqlDbType.SmallDateTime);

            cmd.Parameters["@MaPTT"].Value     = s.MaPTT;
            cmd.Parameters["@MaThe"].Value     = s.MaDG;
            cmd.Parameters["@SoTienThu"].Value = s.SoTienThu;
            cmd.Parameters["@ConLai"].Value    = s.ConLai;
            cmd.Parameters["@NgayThu"].Value   = s.NgayThu;

            conn.Open();
            cmd.ExecuteNonQuery();
            conn.Close();
        }
 public static void ThuTienPhat(En_ThuTienPhat s)
 {
     Sql_ThuTienPhat.ThuTienPhat(s);
 }