protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["Login"] == null || Session["Package"] == null)
            {
                Response.Redirect("/Authorization/Login");
            }

            package_login = (Base_Companys)Session["Package"];
            acc_lgn       = (Account_Login)Session["Login"];

            if (acc_lgn.acc_lv.level_access < 7)
            {
                Save_Btn.Visible = false;
            }

            if (!IsPostBack)
            {
                if (Request.Params["code"] != null)
                {
                    string[] code       = Request.Params["code"].Split('U');
                    string   leasing_id = code[1];
                    string   bill_no    = code[2];
                    string   idcard     = (string)Session["ctm_leasing_payment"];

                    if (Request.Params["mode"] == "e")
                    {
                        Close_Leasing_Lbl.Visible = false;

                        _loadLeasingDetails(leasing_id, idcard, bill_no);
                    }
                    else if (Request.Params["mode"] == "r")
                    {
                        Car_Leasings_Payment_Manager cls_pay_mng = new Car_Leasings_Payment_Manager();

                        cls_pay_mng.removePayment(leasing_id, bill_no);

                        /// Acticity Logs System
                        ///

                        string message = Messages_Logs._messageLogsNormal(acc_lgn.Account_F_name, " ลบข้อมูลการจ่ายเงิน เลขที่ใบเสร็จ : " + bill_no, acc_lgn.resu, package_login.Company_N_name);

                        new Activity_Log_Manager().addActivityLogs(message, acc_lgn.Account_id, package_login.Company_id);

                        /// Acticity Logs System

                        string ogn_code = CryptographyCode.GenerateSHA512String(leasing_id);

                        Response.Redirect("/Form_Leasings/Leasing_Payment?code=" + CryptographyCode.EncodeTOAddressBar(ogn_code, leasing_id, idcard));
                    }
                }
            }
        }
        private void _CheckLeasingPayment(string Leasing_id)
        {
            Car_Leasings_Manager         cls_mng      = new Car_Leasings_Manager();
            Car_Leasings_Payment_Manager cls_pay_mng  = new Car_Leasings_Payment_Manager();
            List <Car_Leasings_Payment>  list_cls_pay = cls_pay_mng.getPaymentSchedule(Leasing_id);

            if (list_cls_pay.Count > 0)
            {
                Car_Leasings_Payment cls_pay = list_cls_pay[0];

                if (string.IsNullOrEmpty(cls_pay.Real_payment_date))
                {
                    Payment_Schedule_DDL.Enabled   = true;
                    First_Payment_Date_TBx.Enabled = true;
                    Total_Require_TBx.Enabled      = true;
                    Interest_Rate_TBx.Enabled      = true;
                    Total_Period_TBx.Enabled       = true;
                    Vat_TBx.Enabled       = true;
                    Calculate_Btn.Enabled = true;
                }
                else
                {
                    Payment_Schedule_DDL.Enabled   = false;
                    First_Payment_Date_TBx.Enabled = false;
                    Total_Require_TBx.Enabled      = false;
                    Interest_Rate_TBx.Enabled      = false;
                    Total_Period_TBx.Enabled       = false;
                    Vat_TBx.Enabled       = false;
                    Calculate_Btn.Enabled = false;
                }
            }
            else
            {
                Payment_Schedule_DDL.Enabled   = true;
                First_Payment_Date_TBx.Enabled = true;
                Total_Require_TBx.Enabled      = true;
                Interest_Rate_TBx.Enabled      = true;
                Total_Period_TBx.Enabled       = true;
                Vat_TBx.Enabled       = true;
                Calculate_Btn.Enabled = true;
            }
        }