protected void m_cmd_cap_nhat_du_toan_Click(object sender, EventArgs e)
    {
        try
        {
            if (hdf_id_gv.Value == "")
            {
                string someScript;
                someScript = "<script language='javascript'>alert('Bạn phải chọn thanh toán cần Cập nhật');</script>";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", someScript);
                return;
            }
            if (!check_exist_so_hop_dong(m_txt_so_hop_dong.Text.Trim()))
            {
                string Script;
                Script = "<script language='javascript'>alert('Số hợp đồng không tồn tại trong hệ thống');</script>";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "oncheck4", Script);
                return;
            }
            decimal v_dc_id_hop_dong_khung = get_id_hd_khung_by_so_hd(m_txt_so_hop_dong.Text.Trim());
            // Kiểm tra đơn vị thanh toán
            decimal v_dc_id_dv_tt = get_id_don_vi_thanh_toan_by_id_dot_tt(CIPConvert.ToDecimal(m_cbo_dot_thanh_toan.SelectedValue));
            if (!check_hop_dong_ung_voi_dv_thanh_toan(v_dc_id_dv_tt, v_dc_id_hop_dong_khung))
            {
                string Script;
                Script = "<script language='javascript'>alert('Hợp đồng này không do " + get_ten_dv_thanh_toan(v_dc_id_dv_tt) + " thanh toán');</script>";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "oncheck3", Script);
                //m_lbl_mess.Text = "";
                return;
            }

            // Nếu là thanh lý thì yêu cầu nhập nghiệm thu thực tế
            if (rdl_noi_dung_list.Items[0].Selected == true)
            {
                if (m_txt_gia_tri_nghiem_thu_thuc_te.Text.Trim().Equals(""))
                {
                    string soScript;
                    soScript = "<script language='javascript'>alert('Đây là lần thanh lý hợp đồng. Xin hãy nhập tổng giá trị nghiệm thu thực tế');</script>";
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "oncheck5", soScript);
                    return;
                }
            }

            if (!check_nghiem_thu_va_thanh_toan_update(v_dc_id_hop_dong_khung))
            {
                string soScript;
                soScript = "<script language='javascript'>alert('Giá trị nghiệm thu thực tế phải bằng tổng tiền thanh toán cộng số tiền đã thanh toán ');</script>";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "oncheck2", soScript);
                return;
            }

            form_2_us_obj(m_us_v_gd_thanh_toan);

            // Nếu đây là update thông tin bảng kê, kiểm tra trạng thái mới có phù hợp không?
            if (hdf_id_trang_thai_thanh_toan_cu.Value != "")
            {
                CValidatePaymentStates v_cvalidate_state = new CValidatePaymentStates();
                v_cvalidate_state.Trang_thai_thanh_toan_hien_tai = get_ma_trang_thai_thanh_toan_by_id(CIPConvert.ToDecimal(hdf_id_trang_thai_thanh_toan_cu.Value));
                v_cvalidate_state.set_trang_thai();
                if (!v_cvalidate_state.check_chuyen_trang_thai(get_ma_trang_thai_thanh_toan_by_id(m_us_v_gd_thanh_toan.dcID_TRANG_THAI_THANH_TOAN)))
                {
                    string someScript;
                    someScript = "<script language='javascript'>alert('Không chuyển từ trạng thái ban đầu của thanh toán về trạng thái này được!');</script>";
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "onload1", someScript);
                    return;
                }
            }
            m_us_v_gd_thanh_toan.dcID = CIPConvert.ToDecimal(hdf_id_gv.Value);
            m_us_v_gd_thanh_toan.Update();
            m_lbl_thong_bao.Visible = true;
            m_lbl_thong_bao.Text    = "Cập nhật bản ghi thành công";
            reset_controls();
            m_cbo_lan_so.Enabled      = true;
            m_cmd_luu_du_lieu.Enabled = true;
            m_txt_so_hop_dong.Enabled = true;
            m_cmd_check_so_hd.Visible = true;
            load_data_2_grid(get_ma_dot_tt_by_id_dot(CIPConvert.ToDecimal(m_cbo_dot_thanh_toan.SelectedValue)));
        }
        catch (Exception v_e)
        {
            CSystemLog_301.ExceptionHandle(this, v_e);
        }
    }
 protected void m_cmd_cap_nhat_du_toan_Click(object sender, EventArgs e)
 {
     try
     {
         if (hdf_id_gv.Value == "")
         {
             string someScript;
             someScript = "<script language='javascript'>alert('Bạn phải chọn thanh toán cần Cập nhật');</script>";
             Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", someScript);
             //m_lbl_mess.Text = "";
             return;
         }
         //if (hdf_check_click_kiem_tra_so_hd.Value == null)
         //{
         //    string someScript;
         //    someScript = "<script language='javascript'>alert('Bạn chưa kiểm tra lại số hợp đồng. Nhấn nút Kiểm tra HĐ để thực hiện việc đó.');</script>";
         //    Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", someScript);
         //    return;
         //}
         //if (hdf_check_click_kiem_tra_lop_mon.Value == null)
         //{
         //    string someScript;
         //    someScript = "<script language='javascript'>alert('Bạn chưa kiểm tra lại lớp môn. Nhấn nút Kiểm tra LM để thực hiện việc đó.');</script>";
         //    Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", someScript);
         //    return;
         //}
         if (!check_exist_so_hop_dong(m_txt_so_hop_dong.Text.Trim()))
         {
             string Script;
             Script = "<script language='javascript'>alert('Số hợp đồng không tồn tại trong hệ thống. Hãy kiểm tra lại số hợp đồng!');</script>";
             Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", Script);
             //m_lbl_mess.Text = "";
             return;
         }
         //if (!check_exist_ma_mon(m_txt_ma_lop_mon.Text.Trim()))
         //{
         //    string script;
         //    script = "<script language='javascript'>alert('Lớp môn này không tồn tại trong hệ thống')</script>";
         //    Page.ClientScript.RegisterStartupScript(this.GetType(), "oncheckmalop", script);
         //    return;
         //}
         form_2_us_obj(m_us_v_gd_thanh_toan);
         // Nếu đây là update thông tin bảng kê, kiểm tra trạng thái mới có phù hợp không?
         if (hdf_id_trang_thai_thanh_toan_cu.Value != "")
         {
             CValidatePaymentStates v_cvalidate_state = new CValidatePaymentStates();
             v_cvalidate_state.Trang_thai_thanh_toan_hien_tai = get_ma_trang_thai_thanh_toan_by_id(CIPConvert.ToDecimal(hdf_id_trang_thai_thanh_toan_cu.Value));
             v_cvalidate_state.set_trang_thai();
             if (!v_cvalidate_state.check_chuyen_trang_thai(get_ma_trang_thai_thanh_toan_by_id(m_us_v_gd_thanh_toan.dcID_TRANG_THAI_THANH_TOAN)))
             {
                 string someScript;
                 someScript = "<script language='javascript'>alert('Không chuyển từ trạng thái ban đầu của thanh toán về trạng thái này được!');</script>";
                 Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", someScript);
                 return;
             }
         }
         m_us_v_gd_thanh_toan.dcID = CIPConvert.ToDecimal(hdf_id_gv.Value);
         m_us_v_gd_thanh_toan.Update();
         m_lbl_thong_bao.Visible = true;
         m_lbl_thong_bao.Text    = "Cập nhật bản ghi thành công";
         reset_controls();
         m_cmd_luu_du_lieu.Enabled = true;
         load_data_2_grid(get_ma_dot_tt_by_id_dot(CIPConvert.ToDecimal(m_cbo_dot_thanh_toan.SelectedValue)));
         hdf_check_click_kiem_tra_so_hd.Value   = "";
         hdf_check_click_kiem_tra_lop_mon.Value = "";
     }
     catch (Exception v_e)
     {
         CSystemLog_301.ExceptionHandle(this, v_e);
     }
 }