private void _loadReport()
        {
            cls     = (Car_Leasings)Session["Leasings"];
            cls.ctm = new Customers();
            cls.ctm = (Customers)Session["Customer_Leasing"];

            MySqlConnection con_cls   = MySQLConnection.connectionMySQL();
            MySqlConnection con_ctm   = MySQLConnection.connectionMySQL();
            MySqlConnection con_grt_1 = MySQLConnection.connectionMySQL();
            MySqlConnection con_grt_2 = MySQLConnection.connectionMySQL();
            MySqlConnection con_grt_3 = MySQLConnection.connectionMySQL();
            MySqlConnection con_grt_4 = MySQLConnection.connectionMySQL();
            MySqlConnection con_grt_5 = MySQLConnection.connectionMySQL();
            MySqlConnection con_cpn   = MySQLConnection.connectionMySQL();

            try
            {
                con_cls.Open();
                MySqlCommand cmd_cls = new MySqlCommand("rpt_leasings", con_cls);
                cmd_cls.CommandType = CommandType.StoredProcedure;
                cmd_cls.Parameters.AddWithValue("@i_Leasing_id", cls.Leasing_id);
                MySqlDataReader reader_cls = cmd_cls.ExecuteReader();

                con_ctm.Open();
                MySqlCommand cmd_ctm = new MySqlCommand("rpt_leasings_customers", con_ctm);
                cmd_ctm.CommandType = CommandType.StoredProcedure;
                cmd_ctm.Parameters.AddWithValue("@i_Leasing_id", cls.Leasing_id);
                cmd_ctm.Parameters.AddWithValue("@i_Cust_id", cls.ctm.Cust_id);
                MySqlDataReader reader_ctm = cmd_ctm.ExecuteReader();

                con_grt_1.Open();
                MySqlCommand cmd_grt_1 = new MySqlCommand("rpt_leasings_guarantors", con_grt_1);
                cmd_grt_1.CommandType = CommandType.StoredProcedure;
                cmd_grt_1.Parameters.AddWithValue("@i_Leasing_id", cls.Leasing_id);
                cmd_grt_1.Parameters.AddWithValue("@i_Guarantor_no", 1);
                MySqlDataReader reader_grt_1 = cmd_grt_1.ExecuteReader();

                con_grt_2.Open();
                MySqlCommand cmd_grt_2 = new MySqlCommand("rpt_leasings_guarantors", con_grt_2);
                cmd_grt_2.CommandType = CommandType.StoredProcedure;
                cmd_grt_2.Parameters.AddWithValue("@i_Leasing_id", cls.Leasing_id);
                cmd_grt_2.Parameters.AddWithValue("@i_Guarantor_no", 2);
                MySqlDataReader reader_grt_2 = cmd_grt_2.ExecuteReader();

                con_grt_3.Open();
                MySqlCommand cmd_grt_3 = new MySqlCommand("rpt_leasings_guarantors", con_grt_3);
                cmd_grt_3.CommandType = CommandType.StoredProcedure;
                cmd_grt_3.Parameters.AddWithValue("@i_Leasing_id", cls.Leasing_id);
                cmd_grt_3.Parameters.AddWithValue("@i_Guarantor_no", 3);
                MySqlDataReader reader_grt_3 = cmd_grt_3.ExecuteReader();

                con_grt_4.Open();
                MySqlCommand cmd_grt_4 = new MySqlCommand("rpt_leasings_guarantors", con_grt_4);
                cmd_grt_4.CommandType = CommandType.StoredProcedure;
                cmd_grt_4.Parameters.AddWithValue("@i_Leasing_id", cls.Leasing_id);
                cmd_grt_4.Parameters.AddWithValue("@i_Guarantor_no", 4);
                MySqlDataReader reader_grt_4 = cmd_grt_4.ExecuteReader();

                con_grt_5.Open();
                MySqlCommand cmd_grt_5 = new MySqlCommand("rpt_leasings_guarantors", con_grt_5);
                cmd_grt_5.CommandType = CommandType.StoredProcedure;
                cmd_grt_5.Parameters.AddWithValue("@i_Leasing_id", cls.Leasing_id);
                cmd_grt_5.Parameters.AddWithValue("@i_Guarantor_no", 5);
                MySqlDataReader reader_grt_5 = cmd_grt_5.ExecuteReader();

                con_cpn.Open();
                MySqlCommand cmd_cpn = new MySqlCommand("rpt_withholding_tax", con_cpn);
                cmd_cpn.CommandType = CommandType.StoredProcedure;
                cmd_cpn.Parameters.AddWithValue("@i_Leasing_id", cls.Leasing_id);
                MySqlDataReader reader_cpn = cmd_cpn.ExecuteReader();

                Leasing_Ds ls_ds = new Leasing_Ds();
                ls_ds.Clear();
                ls_ds.Tables["Leasings"].Load(reader_cls);
                ls_ds.Tables["Customers"].Load(reader_ctm);
                ls_ds.Tables["Guarantor_1"].Load(reader_grt_1);
                ls_ds.Tables["Guarantor_2"].Load(reader_grt_2);
                ls_ds.Tables["Guarantor_3"].Load(reader_grt_3);
                ls_ds.Tables["Guarantor_4"].Load(reader_grt_4);
                ls_ds.Tables["Guarantor_5"].Load(reader_grt_5);
                ls_ds.Tables["Agent_Commission"].Load(reader_cpn);

                Car_Leasing_KH2 rpt = new Car_Leasing_KH2();
                rpt.SetDataSource(ls_ds);

                CRV_Display_Report.ReportSource = rpt;

                /// Export Report to PDF File with Save As Mode
                /// rpt.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, true, "สัญญา_ข_2_" + cls.Deps_no);
                /// Response.End();

                ExportReport(rpt);
            }
            catch (MySqlException ex)
            {
                error = "MysqlException ==> Car_Leasing_KH11 : Page --> _loadReport() ";
                Log_Error._writeErrorFile(error, ex);
            }
            catch (Exception ex)
            {
                error = "Exception ==> Car_Leasing_KH11 : Page --> _loadReport() ";
                Log_Error._writeErrorFile(error, ex);
            }
            finally
            {
                con_cls.Close();
                con_ctm.Close();
                con_grt_1.Close();
                con_grt_2.Close();
                con_grt_3.Close();
                con_grt_4.Close();
                con_grt_5.Close();
                con_cpn.Close();

                con_cls.Dispose();
                con_ctm.Dispose();
                con_grt_1.Dispose();
                con_grt_2.Dispose();
                con_grt_3.Dispose();
                con_grt_4.Dispose();
                con_grt_5.Dispose();
                con_cpn.Dispose();
            }

            GC.Collect();
        }
        private void _loadReport_mod_I()
        {
            string month               = (string)Session["month"];
            string year                = (string)Session["year"];
            string Company_id_inline   = (string)Session["Company_id_inline_rpt"];
            string leasing_Code_inline = (string)Session["leasing_Code_inline_rpt"];
            string zone_id_inline      = (string)Session["zone_id_inline_rpt"];

            string report_header = "รายงานการชำระเงิน 1 ประจำเดือน " + DateTimeUtility.convertMonthToThai(month) + " " + (Convert.ToInt32(year) + 543);

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

            MySqlConnection con = MySQLConnection.connectionMySQL();

            try
            {
                con.Open();
                MySqlCommand cmd = new MySqlCommand("rpt_real_payment_monthly", con);
                cmd.CommandType    = CommandType.StoredProcedure;
                cmd.CommandTimeout = 0;

                cmd.Parameters.AddWithValue("@i_month", month);
                cmd.Parameters.AddWithValue("@i_year", year);
                cmd.Parameters.AddWithValue("@i_Leasing_code_id", leasing_Code_inline);
                cmd.Parameters.AddWithValue("@i_Company_id", Company_id_inline);
                cmd.Parameters.AddWithValue("@i_Zone_id", zone_id_inline);
                cmd.Parameters.AddWithValue("@i_row_str", 0);
                cmd.Parameters.AddWithValue("@i_row_limit", 0);

                MySqlDataReader reader = cmd.ExecuteReader();

                Leasing_Ds ls_ds = new Leasing_Ds();
                ls_ds.Clear();
                ls_ds.Tables["Report_Payments"].Load(reader);

                Payment_Summary_Monthly_mod_I_001 rpt = new Payment_Summary_Monthly_mod_I_001();
                rpt.SetDataSource(ls_ds);
                rpt.SetParameterValue("Reported_By_User", "ออกโดย : " + acc_lgn.Account_F_name);
                rpt.SetParameterValue("Reported_Print_Date", "วันที่พิมพ์ : " + DateTimeUtility.convertDateTimeToPage(DateTimeUtility._dateTimeNOWForServer()));
                rpt.SetParameterValue("Report_Header", report_header);


                CRV_Display_Report.ReportSource = rpt;

                /// Export Report to PDF File with Save As Mode
                /// rpt.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, true, "หน้าการ์ด_" + cls.Deps_no);
                /// Response.End();

                ExportReport_Mod_I(rpt);
            }
            catch (MySqlException ex)
            {
                error = "MysqlException ==> Payment_Summary_Monthly_Export --> _loadReport_mod_I() ";
                Log_Error._writeErrorFile(error, ex);
            }
            catch (Exception ex)
            {
                error = "Exception ==> Payment_Summary_Monthly_Export --> _loadReport_mod_I() ";
                Log_Error._writeErrorFile(error, ex);
            }
            finally
            {
                con.Close();
                con.Dispose();
            }

            /// Acticity Logs System
            ///

            string message = Messages_Logs._messageLogsNormal(acc_lgn.Account_F_name, " ออก" + report_header, 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

            GC.Collect();
        }
        private void _loadReport()
        {
            string deposit_no          = (string)Session["deposit_no_rpt"];
            string leasing_no          = (string)Session["leasing_no_rpt"];
            string idcard              = (string)Session["idcard_rpt"];
            string fname               = (string)Session["fname_rpt"];
            string lname               = (string)Session["lname_rpt"];
            string date_str            = (string)Session["date_str_rpt"];
            string date_end            = (string)Session["date_end_rpt"];
            string lost_str            = (string)Session["lost_str_rpt"];
            string lost_end            = (string)Session["lost_end_rpt"];
            string district            = (string)Session["district_rpt"];
            string province            = (string)Session["province_rpt"];
            string leasing_Code_inline = (string)Session["leasing_Code_inline_rpt"];
            string Company_id_inline   = (string)Session["Company_id_inline_rpt"];
            string zone_id_inline      = (string)Session["zone_id_inline_rpt"];

            string report_header = " รายงานลูกค้าขาดชำระค่างวด ";

            string report_case = "ค้นหา : ";

            if (!string.IsNullOrEmpty(lost_str) && string.IsNullOrEmpty(lost_end))
            {
                report_case = report_case + " [ ขาด " + lost_str + " ] ";
            }
            else if (string.IsNullOrEmpty(lost_str) && !string.IsNullOrEmpty(lost_end))
            {
                report_case = report_case + " [ ขาด " + lost_end + " ] ";
            }
            else if (!string.IsNullOrEmpty(lost_str) && !string.IsNullOrEmpty(lost_end))
            {
                report_case = report_case + " [ ขาด " + lost_str + " - " + lost_end + " ] ";
            }

            if (!string.IsNullOrEmpty(district))
            {
                report_case = report_case + " [ " + district + " ] ";
            }

            if (!string.IsNullOrEmpty(province))
            {
                report_case = report_case + " [ " + province + " ] ";
            }

            if (!string.IsNullOrEmpty(leasing_Code_inline))
            {
                string[] lsc = leasing_Code_inline.Split(',');

                List <Base_Leasing_Code> list_data = new Base_Leasing_Code_Manager().getLeasingCode();

                for (int lsc_index = 0; lsc_index < lsc.Length; lsc_index++)
                {
                    for (int i = 0; i < list_data.Count; i++)
                    {
                        if (lsc[lsc_index] == list_data[i].Leasing_code_id.ToString())
                        {
                            report_case = report_case + " [ " + list_data[i].Leasing_code_name + " ] ";
                        }
                    }
                }
            }

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

            MySqlConnection con = MySQLConnection.connectionMySQL();

            try
            {
                con.Open();
                MySqlCommand cmd = new MySqlCommand("rpt_generals_leasing", con);
                cmd.CommandType    = CommandType.StoredProcedure;
                cmd.CommandTimeout = 0;

                cmd.Parameters.AddWithValue("@i_Deps_no", deposit_no);
                cmd.Parameters.AddWithValue("@i_Leasing_no", leasing_no);
                cmd.Parameters.AddWithValue("@i_Cust_idcard", idcard);
                cmd.Parameters.AddWithValue("@i_Cust_Fname", fname);
                cmd.Parameters.AddWithValue("@i_Cust_LName", lname);
                cmd.Parameters.AddWithValue("@i_Leasing_date_str", date_str);
                cmd.Parameters.AddWithValue("@i_Leasing_date_end", date_end);
                cmd.Parameters.AddWithValue("@i_Leasing_code_id", leasing_Code_inline);
                cmd.Parameters.AddWithValue("@i_Company_id", Company_id_inline);
                cmd.Parameters.AddWithValue("@i_Zone_id", zone_id_inline);
                cmd.Parameters.AddWithValue("@i_lost_str", lost_str);
                cmd.Parameters.AddWithValue("@i_lost_end", lost_end);
                cmd.Parameters.AddWithValue("@i_district", district);
                cmd.Parameters.AddWithValue("@i_province", province);
                cmd.Parameters.AddWithValue("@i_row_str", 0);
                cmd.Parameters.AddWithValue("@i_row_limit", 0);

                MySqlDataReader reader = cmd.ExecuteReader();

                Leasing_Ds ls_ds = new Leasing_Ds();
                ls_ds.Clear();
                ls_ds.Tables["Report_General_Leasings"].Load(reader);

                Lost_Payment rpt = new Lost_Payment();
                rpt.SetDataSource(ls_ds);
                rpt.SetParameterValue("Reported_By_User", "ออกโดย : " + acc_lgn.Account_F_name);
                rpt.SetParameterValue("Reported_Print_Date", "วันที่พิมพ์ : " + DateTimeUtility.convertDateTimeToPage(DateTimeUtility._dateTimeNOWForServer()));
                rpt.SetParameterValue("Report_Header", report_header);
                rpt.SetParameterValue("Report_Case", report_case);

                CRV_Display_Report.ReportSource = rpt;

                /// Export Report to PDF File with Save As Mode
                /// rpt.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, true, "หน้าการ์ด_" + cls.Deps_no);
                /// Response.End();

                ExportReport_Mod_I(rpt);
            }
            catch (MySqlException ex)
            {
                error = "MysqlException ==> Lost_Payment_Hurry_Export --> _loadReport() ";
                Log_Error._writeErrorFile(error, ex);
            }
            catch (Exception ex)
            {
                error = "Exception ==> Lost_Payment_Hurry_Export --> _loadReport() ";
                Log_Error._writeErrorFile(error, ex);
            }
            finally
            {
                con.Close();
                con.Dispose();
            }

            /// Acticity Logs System
            ///

            string message = Messages_Logs._messageLogsNormal(acc_lgn.Account_F_name, " ออก" + report_header, 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

            GC.Collect();
        }
        private void _loadReport()
        {
            string deposit_no          = (string)Session["deposit_no_rpt"];
            string leasing_no          = (string)Session["leasing_no_rpt"];
            string idcard              = (string)Session["idcard_rpt"];
            string fname               = (string)Session["fname_rpt"];
            string lname               = (string)Session["lname_rpt"];
            string date_str            = (string)Session["date_str_rpt"];
            string date_end            = (string)Session["date_end_rpt"];
            string lost_str            = (string)Session["lost_str_rpt"];
            string lost_end            = (string)Session["lost_end_rpt"];
            string district            = (string)Session["district_rpt"];
            string province            = (string)Session["province_rpt"];
            string leasing_Code_inline = (string)Session["leasing_Code_inline_rpt"];
            string Company_id_inline   = (string)Session["Company_id_inline_rpt"];
            string zone_id_inline      = (string)Session["zone_id_inline_rpt"];

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

            MySqlConnection con = MySQLConnection.connectionMySQL();

            try
            {
                con.Open();
                MySqlCommand cmd = new MySqlCommand("rpt_notification_guarantor", con);
                cmd.CommandType    = CommandType.StoredProcedure;
                cmd.CommandTimeout = 0;

                cmd.Parameters.AddWithValue("@i_Deps_no", deposit_no);
                cmd.Parameters.AddWithValue("@i_Leasing_no", leasing_no);
                cmd.Parameters.AddWithValue("@i_Cust_idcard", idcard);
                cmd.Parameters.AddWithValue("@i_Cust_Fname", fname);
                cmd.Parameters.AddWithValue("@i_Cust_LName", lname);
                cmd.Parameters.AddWithValue("@i_Leasing_date_str", date_str);
                cmd.Parameters.AddWithValue("@i_Leasing_date_end", date_end);
                cmd.Parameters.AddWithValue("@i_Leasing_code_id", leasing_Code_inline);
                cmd.Parameters.AddWithValue("@i_Company_id", Company_id_inline);
                cmd.Parameters.AddWithValue("@i_Zone_id", zone_id_inline);
                cmd.Parameters.AddWithValue("@i_lost_str", lost_str);
                cmd.Parameters.AddWithValue("@i_lost_end", lost_end);
                cmd.Parameters.AddWithValue("@i_district", district);
                cmd.Parameters.AddWithValue("@i_province", province);
                cmd.Parameters.AddWithValue("@i_row_str", 0);
                cmd.Parameters.AddWithValue("@i_row_limit", 0);

                MySqlDataReader reader = cmd.ExecuteReader();

                Leasing_Ds ls_ds = new Leasing_Ds();
                ls_ds.Clear();
                ls_ds.Tables["Report_General_Leasings"].Load(reader);

                Notification_Payment_Guarantor rpt = new Notification_Payment_Guarantor();
                rpt.SetDataSource(ls_ds);


                CRV_Display_Report.ReportSource = rpt;

                /// Export Report to PDF File with Save As Mode
                /// rpt.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, true, "หน้าการ์ด_" + cls.Deps_no);
                /// Response.End();

                ExportReport_Mod_I(rpt);
            }
            catch (MySqlException ex)
            {
                error = "MysqlException ==> Notification_Payment_Export --> _loadReport() ";
                Log_Error._writeErrorFile(error, ex);
            }
            catch (Exception ex)
            {
                error = "Exception ==> Notification_Payment_Export --> _loadReport() ";
                Log_Error._writeErrorFile(error, ex);
            }
            finally
            {
                con.Close();
                con.Dispose();
            }

            /// Acticity Logs System
            ///

            string message = Messages_Logs._messageLogsNormal(acc_lgn.Account_F_name, " ออกรายงานแจ้งเตือนค้างวดผู้ค้ำ ", 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

            GC.Collect();
        }
Esempio n. 5
0
        private void _loadReport()
        {
            string deposit_no          = (string)Session["deposit_no_rpt"];
            string leasing_no          = (string)Session["leasing_no_rpt"];
            string idcard              = (string)Session["idcard_rpt"];
            string fname               = (string)Session["fname_rpt"];
            string lname               = (string)Session["lname_rpt"];
            string lost_str            = (string)Session["lost_str_rpt"];
            string lost_end            = (string)Session["lost_end_rpt"];
            string district            = (string)Session["district_rpt"];
            string province            = (string)Session["province_rpt"];
            string leasing_Code_inline = (string)Session["leasing_Code_inline_rpt"];
            string Company_id_inline   = (string)Session["Company_id_inline_rpt"];
            string zone_id_inline      = (string)Session["zone_id_inline_rpt"];
            string report_header       = " รายงานลูกหนี้คงเหลือ ";

            bool chk_all = false;

            if (leasing_Code_inline == "" && Company_id_inline == "" && zone_id_inline == "")
            {
                report_header = " รายงานลูกหนี้คงเหลือ (ทั้งหมด)";

                chk_all = true;
            }

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

            MySqlConnection con = MySQLConnection.connectionMySQL();

            try
            {
                con.Open();
                MySqlCommand cmd = new MySqlCommand("rpt_total_balance", con);
                cmd.CommandType    = CommandType.StoredProcedure;
                cmd.CommandTimeout = 0;

                cmd.Parameters.AddWithValue("@i_Deps_no", deposit_no);
                cmd.Parameters.AddWithValue("@i_Leasing_no", leasing_no);
                cmd.Parameters.AddWithValue("@i_Cust_idcard", idcard);
                cmd.Parameters.AddWithValue("@i_Cust_Fname", fname);
                cmd.Parameters.AddWithValue("@i_Cust_LName", lname);
                cmd.Parameters.AddWithValue("@i_Leasing_date_str", "");
                cmd.Parameters.AddWithValue("@i_Leasing_date_end", "");
                cmd.Parameters.AddWithValue("@i_Leasing_code_id", leasing_Code_inline);
                cmd.Parameters.AddWithValue("@i_Company_id", Company_id_inline);
                cmd.Parameters.AddWithValue("@i_Zone_id", zone_id_inline);
                cmd.Parameters.AddWithValue("@i_lost_str", lost_str);
                cmd.Parameters.AddWithValue("@i_lost_end", lost_end);
                cmd.Parameters.AddWithValue("@i_district", district);
                cmd.Parameters.AddWithValue("@i_province", province);
                cmd.Parameters.AddWithValue("@i_row_str", 0);
                cmd.Parameters.AddWithValue("@i_row_limit", 0);

                MySqlDataReader reader = cmd.ExecuteReader();

                Leasing_Ds ls_ds = new Leasing_Ds();
                ls_ds.Clear();
                ls_ds.Tables["Report_General_Leasings"].Load(reader);

                if (chk_all)
                {
                    Total_Balance_Payment_All rpt = new Total_Balance_Payment_All();
                    rpt.SetDataSource(ls_ds);
                    rpt.SetParameterValue("Reported_By_User", "ออกโดย : " + acc_lgn.Account_F_name);
                    rpt.SetParameterValue("Reported_Print_Date", "วันที่พิมพ์ : " + DateTimeUtility.convertDateTimeToPage(DateTimeUtility._dateTimeNOWForServer()));
                    rpt.SetParameterValue("Report_Header", report_header);


                    CRV_Display_Report.ReportSource = rpt;

                    /// Export Report to PDF File with Save As Mode
                    /// rpt.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, true, "หน้าการ์ด_" + cls.Deps_no);
                    /// Response.End();

                    ExportReport_Mod_II(rpt);
                }
                else
                {
                    Total_Balance_Payment rpt = new Total_Balance_Payment();
                    rpt.SetDataSource(ls_ds);
                    rpt.SetParameterValue("Reported_By_User", "ออกโดย : " + acc_lgn.Account_F_name);
                    rpt.SetParameterValue("Reported_Print_Date", "วันที่พิมพ์ : " + DateTimeUtility.convertDateTimeToPage(DateTimeUtility._dateTimeNOWForServer()));
                    rpt.SetParameterValue("Report_Header", report_header);


                    CRV_Display_Report.ReportSource = rpt;

                    /// Export Report to PDF File with Save As Mode
                    /// rpt.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, true, "หน้าการ์ด_" + cls.Deps_no);
                    /// Response.End();

                    ExportReport_Mod_I(rpt);
                }
            }
            catch (MySqlException ex)
            {
                error = "MysqlException ==> Total_Balance_Payment_Export --> _loadReport() ";
                Log_Error._writeErrorFile(error, ex);
            }
            catch (Exception ex)
            {
                error = "Exception ==> Total_Balance_Payment_Export --> _loadReport() ";
                Log_Error._writeErrorFile(error, ex);
            }
            finally
            {
                con.Close();
                con.Dispose();
            }

            /// Acticity Logs System
            ///

            string message = Messages_Logs._messageLogsNormal(acc_lgn.Account_F_name, " ออก" + report_header, 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

            GC.Collect();
        }
        private void _loadReport()
        {
            cls           = (Car_Leasings)Session["Leasings"];
            package_login = (Base_Companys)Session["Package"];
            acc_lgn       = (Account_Login)Session["Login"];

            MySqlConnection con_cls = MySQLConnection.connectionMySQL();
            MySqlConnection con_cpn = MySQLConnection.connectionMySQL();

            try
            {
                con_cls.Open();
                MySqlCommand cmd_cls = new MySqlCommand("rpt_leasings", con_cls);
                cmd_cls.CommandType = CommandType.StoredProcedure;
                cmd_cls.Parameters.AddWithValue("@i_Leasing_id", cls.Leasing_id);
                MySqlDataReader reader_cls = cmd_cls.ExecuteReader();

                con_cpn.Open();
                MySqlCommand cmd_cpn = new MySqlCommand("rpt_withholding_tax", con_cpn);
                cmd_cpn.CommandType = CommandType.StoredProcedure;
                cmd_cpn.Parameters.AddWithValue("@i_Leasing_id", cls.Leasing_id);
                MySqlDataReader reader_cpn = cmd_cpn.ExecuteReader();

                Leasing_Ds ls_ds = new Leasing_Ds();
                ls_ds.Clear();
                ls_ds.Tables["Leasings"].Load(reader_cls);
                ls_ds.Tables["Agent_Commission"].Load(reader_cpn);


                Withholding_Tax rpt = new Withholding_Tax();
                rpt.SetDataSource(ls_ds);

                CRV_Display_Report.ReportSource = rpt;

                /// Export Report to PDF File with Save As Mode
                /// rpt.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, true, "หนังสือรับรองหัก_ณ_ที่จ่าย_" + cls.Deps_no);
                /// Response.End();

                ExportReport(rpt);
            }
            catch (MySqlException ex)
            {
                error = "MysqlException ==> Car_Leasing_KH11 : Page --> _loadReport() ";
                Log_Error._writeErrorFile(error, ex);
            }
            catch (Exception ex)
            {
                error = "Exception ==> Car_Leasing_KH11 : Page --> _loadReport() ";
                Log_Error._writeErrorFile(error, ex);
            }
            finally
            {
                con_cls.Close();
                con_cpn.Close();

                con_cls.Dispose();
                con_cpn.Dispose();
            }

            /// Acticity Logs System
            ///

            string message = Messages_Logs._messageLogsNormal(acc_lgn.Account_F_name, " ออกรายงานลูกค้าคงเหลือ ", 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


            GC.Collect();
        }