Ejemplo n.º 1
0
 private void _GetAgentCommission(Agents_Commission cag_com)
 {
     Agent_commission_TBx.Text = cag_com.Agent_commission.ToString("#,###.00");
     Agent_percen_TBx.Text     = cag_com.Agent_percen.ToString("#,###.00");
     Agent_cash_TBx.Text       = cag_com.Agent_cash.ToString("#,###.00");
     Agent_net_com_TBx.Text    = cag_com.Agent_net_com.ToString("#,###.00");
     Agent_com_code_TBx.Text   = cag_com.Agent_num_code;
     Agent_bookcode_TBx.Text   = cag_com.Agent_book_code;
     Agent_date_print_TBx.Text = DateTimeUtility.convertDateToPageRealServer(cag_com.Agent_value_save_date);
 }
Ejemplo n.º 2
0
        public bool editAgentCommission(Agents_Commission cag_com)
        {
            MySqlConnection con = MySQLConnection.connectionMySQL();

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

                cmd.Parameters.AddWithValue("@i_Leasing_id", cag_com.Leasing_id);
                cmd.Parameters.AddWithValue("@i_Agent_id", cag_com.cag.Agent_id);
                cmd.Parameters.AddWithValue("@i_Agent_commission", cag_com.Agent_commission);
                cmd.Parameters.AddWithValue("@i_Agent_percen", cag_com.Agent_percen);
                cmd.Parameters.AddWithValue("@i_Agent_cash", cag_com.Agent_cash);
                cmd.Parameters.AddWithValue("@i_Agent_net_com", cag_com.Agent_net_com);
                cmd.Parameters.AddWithValue("@i_Agent_num_code", cag_com.Agent_num_code);
                cmd.Parameters.AddWithValue("@i_Agent_book_code", cag_com.Agent_book_code);
                cmd.Parameters.AddWithValue("@i_Agent_date_print", cag_com.Agent_date_print);
                cmd.Parameters.AddWithValue("@i_Agent_value_save_date", cag_com.Agent_value_save_date);

                cmd.ExecuteNonQuery();

                return(true);
            }
            catch (MySqlException ex)
            {
                error = "MysqlException ==> Managers_Agents --> Car_Agents_Manager --> editAgentCommission() ";
                Log_Error._writeErrorFile(error, ex);
                return(false);
            }
            catch (Exception ex)
            {
                error = "Exception ==> Managers_Agents --> Car_Agents_Manager --> editAgentCommission() ";
                Log_Error._writeErrorFile(error, ex);
                return(false);
            }
            finally
            {
                con.Close();
            }
        }
Ejemplo n.º 3
0
        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)
            {
                Agent_Add_Save_Btn.Visible = false;
            }

            if (acc_lgn.acc_lv.level_access == 2)
            {
                Agent_Add_Save_Btn.Visible = true;
            }

            if (!IsPostBack)
            {
                _loadThaiProvinces();
                _loadAgentStatus();

                if (Session["Agents_Leasing"] == null)
                {
                    Response.Redirect("/Form_Leasings/Leasing_Add_Agent");
                }

                Agents_Commission cag_com = (Agents_Commission)Session["Agents_Leasing"];

                _GetAgent(cag_com.cag);

                _GetAgentCommission(cag_com);

                Session["chk_agent_leasing"] = cag_com.cag;
            }
        }
Ejemplo n.º 4
0
        public Agents_Commission getAgentCommission(string Agent_id, string Leasing_id)
        {
            MySqlConnection con = MySQLConnection.connectionMySQL();

            try
            {
                con.Open();
                MySqlCommand cmd = new MySqlCommand("g_car_agents_commission", con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@i_Agent_id", Agent_id);
                cmd.Parameters.AddWithValue("@i_Leasing_id", Leasing_id);

                MySqlDataReader reader = cmd.ExecuteReader();

                Agents_Commission cag_com = new Agents_Commission();

                if (reader.Read())
                {
                    int    defaultNum    = 0;
                    string defaultString = "";

                    cag_com.cag                   = new Agents();
                    cag_com.cag.Agent_id          = reader.IsDBNull(0) ? defaultString : reader.GetString(0);
                    cag_com.cag.Agent_Fname       = reader.IsDBNull(1) ? defaultString : reader.GetString(1);
                    cag_com.cag.Agent_Lname       = reader.IsDBNull(2) ? defaultString : reader.GetString(2);
                    cag_com.cag.Agent_Idcard      = reader.IsDBNull(3) ? defaultString : reader.GetString(3);
                    cag_com.cag.Agent_Address_no  = reader.IsDBNull(4) ? defaultString : reader.GetString(4);
                    cag_com.cag.Agent_Vilage      = reader.IsDBNull(5) ? defaultString : reader.GetString(5);
                    cag_com.cag.Agent_Vilage_no   = reader.IsDBNull(6) ? defaultString : reader.GetString(6);
                    cag_com.cag.Agent_Alley       = reader.IsDBNull(7) ? defaultString : reader.GetString(7);
                    cag_com.cag.Agent_Road        = reader.IsDBNull(8) ? defaultString : reader.GetString(8);
                    cag_com.cag.Agent_Subdistrict = reader.IsDBNull(9) ? defaultString : reader.GetString(9);
                    cag_com.cag.Agent_District    = reader.IsDBNull(10) ? defaultString : reader.GetString(10);
                    cag_com.cag.Agent_Province    = reader.IsDBNull(11) ? defaultString : reader.GetString(11);
                    cag_com.cag.Agent_Country     = reader.IsDBNull(12) ? defaultString : reader.GetString(12);
                    cag_com.cag.Agent_Zipcode     = reader.IsDBNull(13) ? defaultString : reader.GetString(13);
                    cag_com.cag.Agent_Status      = reader.IsDBNull(14) ? defaultNum : reader.GetInt32(14);
                    cag_com.cag.Agent_Status_name = reader.IsDBNull(15) ? defaultString : reader.GetString(15);
                    cag_com.cag.Agent_save_date   = reader.IsDBNull(16) ? defaultString : reader.GetString(16);

                    cag_com.Leasing_id            = reader.IsDBNull(17) ? defaultString : reader.GetString(17);
                    cag_com.Agent_commission      = reader.IsDBNull(18) ? defaultNum : reader.GetDouble(18);
                    cag_com.Agent_percen          = reader.IsDBNull(19) ? defaultNum : reader.GetDouble(19);
                    cag_com.Agent_cash            = reader.IsDBNull(20) ? defaultNum : reader.GetDouble(20);
                    cag_com.Agent_net_com         = reader.IsDBNull(21) ? defaultNum : reader.GetDouble(21);
                    cag_com.Agent_num_code        = reader.IsDBNull(22) ? defaultString : reader.GetString(22);
                    cag_com.Agent_book_code       = reader.IsDBNull(23) ? defaultString : reader.GetString(23);
                    cag_com.Agent_date_print      = reader.IsDBNull(24) ? defaultString : reader.GetString(24);
                    cag_com.Agent_value_save_date = reader.IsDBNull(25) ? defaultString : reader.GetString(25);
                }

                return(cag_com);
            }
            catch (MySqlException ex)
            {
                error = "MysqlException ==> Managers_Agents --> Car_Agents_Manager --> getAgentCommission() ";
                Log_Error._writeErrorFile(error, ex);
                return(null);
            }
            catch (Exception ex)
            {
                error = "Exception ==> Managers_Agents --> Car_Agents_Manager --> getAgentCommission() ";
                Log_Error._writeErrorFile(error, ex);
                return(null);
            }
            finally
            {
                con.Close();
                con.Dispose();
            }
        }
Ejemplo n.º 5
0
        /*******************************************************************************************************************************************************************************
        ****************************************************                               Add Data Function                    ********************************************************
        ****************************************************                                                                    ********************************************************
        *******************************************************************************************************************************************************************************/

        private void _EditAgent()
        {
            Agents_Manager cag_mng = new Agents_Manager();
            Agents         cag     = new Agents();

            bool past_page = false;

            if (Session["chk_agent_leasing"] != null)
            {
                Agents cag_tmp = (Agents)Session["chk_agent_leasing"];

                cag.Agent_id          = cag_tmp.Agent_id;
                cag.Agent_Fname       = string.IsNullOrEmpty(Agent_fname_TBx.Text) ? "" : Agent_fname_TBx.Text;
                cag.Agent_Lname       = string.IsNullOrEmpty(Agent_lname_TBx.Text) ? "" : Agent_lname_TBx.Text;
                cag.Agent_Idcard      = string.IsNullOrEmpty(Agent_idcard_TBx.Text) ? "" : Agent_idcard_TBx.Text;
                cag.Agent_Address_no  = string.IsNullOrEmpty(Agent_address_no_TBx.Text) ? "" : Agent_address_no_TBx.Text;
                cag.Agent_Vilage      = string.IsNullOrEmpty(Agent_vilage_TBx.Text) ? "บ.-" : "บ." + Agent_vilage_TBx.Text;
                cag.Agent_Vilage_no   = string.IsNullOrEmpty(Agent_vilage_no_TBx.Text) ? "ม.-" : "ม." + Agent_vilage_no_TBx.Text;
                cag.Agent_Alley       = string.IsNullOrEmpty(Agent_alley_TBx.Text) ? "ซ.-" : "ซ." + Agent_alley_TBx.Text;
                cag.Agent_Road        = string.IsNullOrEmpty(Agent_road_TBx.Text) ? "ถ.-" : "ถ." + Agent_road_TBx.Text;
                cag.Agent_Subdistrict = string.IsNullOrEmpty(Agent_subdistrict_TBx.Text) ? "ต.-" : "ต." + Agent_subdistrict_TBx.Text;
                cag.Agent_District    = string.IsNullOrEmpty(Agent_district_TBx.Text) ? "อ.-" : "อ." + Agent_district_TBx.Text;
                cag.Agent_Province    = Agent_province_DDL.SelectedIndex <= 0 ? "จ.-" : "จ." + Agent_province_DDL.SelectedItem.Text;
                cag.Agent_Country     = string.IsNullOrEmpty(Agent_country_TBx.Text) ? "" : Agent_country_TBx.Text;
                cag.Agent_Zipcode     = string.IsNullOrEmpty(Agent_zipcode_TBx.Text) ? "" : Agent_zipcode_TBx.Text;

                past_page = cag_mng.editAgent(cag);
            }
            else
            {
                cag.Agent_id          = cag_mng.generateAgentID();
                cag.Agent_Fname       = string.IsNullOrEmpty(Agent_fname_TBx.Text) ? "" : Agent_fname_TBx.Text;
                cag.Agent_Lname       = string.IsNullOrEmpty(Agent_lname_TBx.Text) ? "" : Agent_lname_TBx.Text;
                cag.Agent_Idcard      = string.IsNullOrEmpty(Agent_idcard_TBx.Text) ? "" : Agent_idcard_TBx.Text;
                cag.Agent_Address_no  = string.IsNullOrEmpty(Agent_address_no_TBx.Text) ? "" : Agent_address_no_TBx.Text;
                cag.Agent_Vilage      = string.IsNullOrEmpty(Agent_vilage_TBx.Text) ? "บ.-" : "บ." + Agent_vilage_TBx.Text;
                cag.Agent_Vilage_no   = string.IsNullOrEmpty(Agent_vilage_no_TBx.Text) ? "ม.-" : "ม." + Agent_vilage_no_TBx.Text;
                cag.Agent_Alley       = string.IsNullOrEmpty(Agent_alley_TBx.Text) ? "ซ.-" : "ซ." + Agent_alley_TBx.Text;
                cag.Agent_Road        = string.IsNullOrEmpty(Agent_road_TBx.Text) ? "ถ.-" : "ถ." + Agent_road_TBx.Text;
                cag.Agent_Subdistrict = string.IsNullOrEmpty(Agent_subdistrict_TBx.Text) ? "ต.-" : "ต." + Agent_subdistrict_TBx.Text;
                cag.Agent_District    = string.IsNullOrEmpty(Agent_district_TBx.Text) ? "อ.-" : "อ." + Agent_district_TBx.Text;
                cag.Agent_Province    = Agent_province_DDL.SelectedIndex <= 0 ? "จ.-" : "จ." + Agent_province_DDL.SelectedItem.Text;
                cag.Agent_Country     = string.IsNullOrEmpty(Agent_country_TBx.Text) ? "" : Agent_country_TBx.Text;
                cag.Agent_Zipcode     = string.IsNullOrEmpty(Agent_zipcode_TBx.Text) ? "" : Agent_zipcode_TBx.Text;

                past_page = cag_mng.addAgent(cag);
            }

            Car_Leasings cls_tmp = (Car_Leasings)Session["Leasings"];

            Agents_Commission cag_com = new Agents_Commission();

            cag_com.Leasing_id = cls_tmp.Leasing_id;

            cag_com.cag = new Agents();
            cag_com.cag = cag;

            cag_com.Agent_commission = string.IsNullOrEmpty(Agent_commission_TBx.Text) ? 0 : Convert.ToDouble(Agent_commission_TBx.Text);
            cag_com.Agent_percen     = string.IsNullOrEmpty(Agent_percen_TBx.Text) ? 0 : Convert.ToDouble(Agent_percen_TBx.Text);
            cag_com.Agent_cash       = string.IsNullOrEmpty(Agent_cash_TBx.Text) ? 0 : Convert.ToDouble(Agent_cash_TBx.Text);
            cag_com.Agent_net_com    = string.IsNullOrEmpty(Agent_net_com_TBx.Text) ? 0 : Convert.ToDouble(Agent_net_com_TBx.Text);
            cag_com.Agent_num_code   = string.IsNullOrEmpty(Agent_com_code_TBx.Text) ? "" : Agent_com_code_TBx.Text;
            cag_com.Agent_book_code  = string.IsNullOrEmpty(Agent_bookcode_TBx.Text) ? "" : Agent_bookcode_TBx.Text;
            cag_com.Agent_date_print = string.IsNullOrEmpty(Agent_date_print_TBx.Text) ? DateTimeUtility._dateNOWForServer() : DateTimeUtility.convertDateToMYSQL(Agent_date_print_TBx.Text);

            if (cag_mng.editAgentCommission(cag_com) && past_page)
            {
                cag_com = cag_mng.getAgentCommission(cag_com.cag.Agent_id, cls_tmp.Leasing_id);

                Session["Agents_Leasing"] = string.IsNullOrEmpty(cag_com.cag.Agent_id) ? null : cag_com;

                /// Acticity Logs System
                ///

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

                string message = Messages_Logs._messageLogsNormal(acc_lgn.Account_F_name, " แก้ไขข้อมูลนายหน้า ในสัญญา : " + cls_tmp.Leasing_no + " เลขที่ฝาก : " + cls_tmp.Deps_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
                ///

                Session.Remove("chk_agent_leasing");

                Session["Class_Active"] = 4;

                Session["Number_Of_Guarantor"] = "1";

                if (Session["Guarantor_1"] == null)
                {
                    Response.Redirect("/Form_Leasings/Leasing_Add_Guarantor");
                }
                else
                {
                    Response.Redirect("/Form_Leasings/Leasing_Edit_Guarantor");
                }
            }
            else
            {
                Alert_Danger_Panel.Visible   = true;
                alert_header_danger_Lbl.Text = "แจ้งเตือน!!";
                alert_danger_Lbl.Text        = "กรุณาตรวจสอบ ข้อมูลอีกครั้ง";

                Alert_Danger_Panel.Focus();
            }
        }
        private void _loadLeasingDetails(string leasing_id, string idcard, string bill_no)
        {
            cls = cls_mng.getCarLeasingById(leasing_id);

            Leasing_Date_TBx.Text = DateTimeUtility.convertDateToPageRealServer(cls.Leasing_date);
            Deps_No_TBx.Text      = cls.Deps_no;
            Leasing_No_TBx.Text   = cls.Leasing_no;

            Leasing_Comments_Lbl.Text = cls.Leasing_Comment;

            bs_cpn = bs_cpn_mng.getCompanysById(cls.bs_cpn.Company_id.ToString());

            Company_N_Name_TBx.Text = bs_cpn.Company_N_name;
            Company_F_Name_TBx.Text = bs_cpn.Company_F_name;

            bs_zn = bs_zn_mng.getZoneById(cls.bs_zn.Zone_id);

            Zone_Name_TBx.Text = bs_zn.Zone_code + " " + bs_zn.Zone_name;

            ctm = cls_ctm_mng.getCustomersLeasing(leasing_id, idcard);

            if (ctm != null)
            {
                Customer_Name_TBx.Text   = ctm.Cust_Fname + " " + ctm.Cust_LName;
                Customer_Idcard_TBx.Text = ctm.Cust_Idcard.Length == 13 ? ctm.Cust_Idcard.Substring(0, 1) + "-" + ctm.Cust_Idcard.Substring(1, 4) + "-" + ctm.Cust_Idcard.Substring(5, 5) + "-" + ctm.Cust_Idcard.Substring(10, 2) + "-" + ctm.Cust_Idcard.Substring(12) : ctm.Cust_Idcard;
                //Customer_B_Date_TBx.Text = DateTimeUtility.convertDateToPage(ctm.Cust_B_date);
                //Customer_Age_TBx.Text = ctm.Cust_Age.ToString();

                Customer_H_Address_TBx.Text  = string.IsNullOrEmpty(ctm.Cust_Home_address_no) ? "" : ctm.Cust_Home_address_no;
                Customer_H_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Home_vilage_no) ? "" : ctm.Cust_Home_vilage_no.IndexOf('.') >= 1 ? ctm.Cust_Home_vilage_no.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Home_vilage_no : "";
                Customer_H_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Home_vilage) ? "" : ctm.Cust_Home_vilage.IndexOf('.') >= 1 ? ctm.Cust_Home_vilage.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Home_vilage : "";
                Customer_H_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Home_alley) ? "" : ctm.Cust_Home_alley.IndexOf('.') >= 1 ? ctm.Cust_Home_alley.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Home_alley : "";
                Customer_H_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Home_road) ? "" : ctm.Cust_Home_road.IndexOf('.') >= 1 ? ctm.Cust_Home_road.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Home_road : "";
                Customer_H_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Home_subdistrict) ? "" : ctm.Cust_Home_subdistrict.IndexOf('.') >= 1 ? ctm.Cust_Home_subdistrict.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Home_subdistrict : "";
                Customer_H_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Home_district) ? "" : ctm.Cust_Home_district.IndexOf('.') >= 1 ? ctm.Cust_Home_district.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Home_district : "";
                Customer_H_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Home_province) ? "" : ctm.Cust_Home_province.IndexOf('.') >= 1 ? ctm.Cust_Home_province.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Home_province : "";

                Customer_C_Address_TBx.Text  = string.IsNullOrEmpty(ctm.Cust_Current_address_no) ? "" : ctm.Cust_Current_address_no;
                Customer_C_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Current_vilage_no) ? "" : ctm.Cust_Current_vilage_no.IndexOf('.') >= 1 ? ctm.Cust_Current_vilage_no.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Current_vilage_no : "";
                Customer_C_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Current_vilage) ? "" : ctm.Cust_Current_vilage.IndexOf('.') >= 1 ? ctm.Cust_Current_vilage.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Current_vilage : "";
                Customer_C_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Current_alley) ? "" : ctm.Cust_Current_alley.IndexOf('.') >= 1 ? ctm.Cust_Current_alley.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Current_alley : "";
                Customer_C_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Current_road) ? "" : ctm.Cust_Current_road.IndexOf('.') >= 1 ? ctm.Cust_Current_road.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Current_road : "";
                Customer_C_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Current_subdistrict) ? "" : ctm.Cust_Current_subdistrict.IndexOf('.') >= 1 ? ctm.Cust_Current_subdistrict.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Current_subdistrict : "";
                Customer_C_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Current_district) ? "" : ctm.Cust_Current_district.IndexOf('.') >= 1 ? ctm.Cust_Current_district.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Current_district : "";
                Customer_C_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Current_province) ? "" : ctm.Cust_Current_province.IndexOf('.') >= 1 ? ctm.Cust_Current_province.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Current_province : "";
            }

            Car_Type_TBx.Text = cls.Car_type;

            bs_cbrn = cbrn_mng.getCarBrandById(cls.bs_cbrn.car_brand_id);

            if (bs_cbrn != null)
            {
                Car_Brand_TBx.Text = bs_cbrn.car_brand_name_th + " ( " + bs_cbrn.car_brand_name_eng + " )";
            }

            Car_Plate_TBx.Text = cls.Car_license_plate + " " + cls.Car_license_plate_province;

            Car_Chassis_No_TBx.Text = cls.Car_chassis_no;
            Car_Engine_No_TBx.Text  = cls.Car_engine_no;

            cag_com = cag_mng.getAgentCommission("", leasing_id);

            Agent_Commission_TBx.Text = cag_com.Agent_commission.ToString("#,###.00");

            Finance_Cost_TBx.Text       = cls.Total_require.ToString("#,###.00");
            Finance_Value_TBx.Text      = cls.Total_sum.ToString("#,###.00");
            Leasing_Cost_TBx.Text       = cls.Total_Net_leasing.ToString("#,###.00");
            Period_Amount_TBx.Text      = cls.Total_period.ToString();
            Period_Payment_TBx.Text     = cls.Period_payment.ToString("#,###.00");
            Payment_Schedule_TBx.Text   = cls.Payment_schedule.ToString();
            Frist_Payment_Date_TBx.Text = DateTimeUtility.convertDateToPageRealServer(cls.First_payment_date);

            Bill_No_TBx.Text = bill_no;

            Period_fee_TBx.Text   = "0.00";
            Period_track_TBx.Text = "0.00";

            List <Car_Leasings_Payment> list_cls_pay = cls_pay_mng.getRealPaymentInfo(leasing_id);

            double total_payment_left = 0.00;
            double total_payment_fine = 0.00;

            double total_fee              = 0.00;
            double total_track            = 0.00;
            double total_real_payment     = 0.00;
            double total_rea_payment_fine = 0.00;
            double total_discount         = 0.00;

            for (int i = 0; i < list_cls_pay.Count; i++)
            {
                Car_Leasings_Payment cls_pay = list_cls_pay[i];

                if (cls_pay.Bill_no == bill_no)
                {
                    Payment_Date_TBx.Text = DateTimeUtility.convertDateToPageRealServer(cls_pay.Real_payment_date);

                    total_fee              += cls_pay.Period_fee;
                    total_track            += cls_pay.Period_track;
                    total_real_payment     += cls_pay.Real_payment;
                    total_rea_payment_fine += cls_pay.Real_payment_fine;
                    total_discount         += cls_pay.Discount;

                    total_payment_left = cls_pay.Total_payment_left;
                    total_payment_fine = cls_pay.Total_payment_fine;

                    Bill_No_Manual_Ref_TBx.Text = cls_pay.Bill_no_manual_ref;

                    Session["old_company"] = cls_pay.bs_cpn.Company_id;
                }
            }

            Total_payment_left_TBx.Text = total_payment_left.ToString("#,###.00");
            Total_payment_fine_TBx.Text = total_payment_fine.ToString("#,###.00");

            Old_Period_fee_TBx.Text        = total_fee.ToString("#,###.00");
            Old_Period_track_TBx.Text      = total_track.ToString("#,###.00");
            Old_Real_Payment_TBx.Text      = total_real_payment.ToString("#,###.00");
            Old_Real_Payment_Fine_TBx.Text = total_rea_payment_fine.ToString("#,###.00");
            Old_Real_Discount_TBx.Text     = total_discount.ToString("#,###.00");

            Session["list_cls_pay"] = list_cls_pay;

            Real_Payment_TBx.Focus();
        }
Ejemplo n.º 7
0
        private void _loadLeasingDetails(string leasing_id, string idcard)
        {
            cls = cls_mng.getCarLeasingById(leasing_id);

            Leasing_Comments_Lbl.Text = cls.Leasing_Comment;

            if (cls.Total_payment_left == 0)
            {
                Close_Leasing_Lbl.Visible = true;
                Cal_Status_Lbl.Visible    = false;

                Payment_Btn.Visible = false;
                Calculate_Close_Leasing_Btn.Visible = false;
                Back_Before_Page_Btn.Visible        = false;

                Leasing_Date_TBx.Text = DateTimeUtility.convertDateToPageRealServer(cls.Leasing_date);

                Deps_No_TBx.Text    = cls.Deps_no;
                Leasing_No_TBx.Text = cls.Leasing_no;

                bs_cpn = bs_cpn_mng.getCompanysById(cls.bs_cpn.Company_id.ToString());

                Company_N_Name_TBx.Text = bs_cpn.Company_N_name;
                Company_F_Name_TBx.Text = bs_cpn.Company_F_name;

                bs_zn = bs_zn_mng.getZoneById(cls.bs_zn.Zone_id);

                Zone_Name_TBx.Text = bs_zn.Zone_code + " " + bs_zn.Zone_name;

                ctm = cls_ctm_mng.getCustomersLeasing(leasing_id, idcard);

                if (ctm != null)
                {
                    Customer_Name_TBx.Text   = ctm.Cust_Fname + " " + ctm.Cust_LName;
                    Customer_Idcard_TBx.Text = ctm.Cust_Idcard.Length == 13 ? ctm.Cust_Idcard.Substring(0, 1) + "-" + ctm.Cust_Idcard.Substring(1, 4) + "-" + ctm.Cust_Idcard.Substring(5, 5) + "-" + ctm.Cust_Idcard.Substring(10, 2) + "-" + ctm.Cust_Idcard.Substring(12) : ctm.Cust_Idcard;
                    //Customer_B_Date_TBx.Text = DateTimeUtility.convertDateToPage(ctm.Cust_B_date);
                    //Customer_Age_TBx.Text = ctm.Cust_Age.ToString();

                    Customer_H_Address_TBx.Text  = string.IsNullOrEmpty(ctm.Cust_Home_address_no) ? "" : ctm.Cust_Home_address_no;
                    Customer_H_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Home_vilage_no) ? "" : ctm.Cust_Home_vilage_no.IndexOf('.') >= 1 ? ctm.Cust_Home_vilage_no.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Home_vilage_no : "";
                    Customer_H_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Home_vilage) ? "" : ctm.Cust_Home_vilage.IndexOf('.') >= 1 ? ctm.Cust_Home_vilage.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Home_vilage : "";
                    Customer_H_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Home_alley) ? "" : ctm.Cust_Home_alley.IndexOf('.') >= 1 ? ctm.Cust_Home_alley.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Home_alley : "";
                    Customer_H_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Home_road) ? "" : ctm.Cust_Home_road.IndexOf('.') >= 1 ? ctm.Cust_Home_road.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Home_road : "";
                    Customer_H_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Home_subdistrict) ? "" : ctm.Cust_Home_subdistrict.IndexOf('.') >= 1 ? ctm.Cust_Home_subdistrict.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Home_subdistrict : "";
                    Customer_H_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Home_district) ? "" : ctm.Cust_Home_district.IndexOf('.') >= 1 ? ctm.Cust_Home_district.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Home_district : "";
                    Customer_H_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Home_province) ? "" : ctm.Cust_Home_province.IndexOf('.') >= 1 ? ctm.Cust_Home_province.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Home_province : "";

                    Customer_C_Address_TBx.Text  = string.IsNullOrEmpty(ctm.Cust_Current_address_no) ? "" : ctm.Cust_Current_address_no;
                    Customer_C_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Current_vilage_no) ? "" : ctm.Cust_Current_vilage_no.IndexOf('.') >= 1 ? ctm.Cust_Current_vilage_no.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Current_vilage_no : "";
                    Customer_C_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Current_vilage) ? "" : ctm.Cust_Current_vilage.IndexOf('.') >= 1 ? ctm.Cust_Current_vilage.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Current_vilage : "";
                    Customer_C_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Current_alley) ? "" : ctm.Cust_Current_alley.IndexOf('.') >= 1 ? ctm.Cust_Current_alley.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Current_alley : "";
                    Customer_C_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Current_road) ? "" : ctm.Cust_Current_road.IndexOf('.') >= 1 ? ctm.Cust_Current_road.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Current_road : "";
                    Customer_C_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Current_subdistrict) ? "" : ctm.Cust_Current_subdistrict.IndexOf('.') >= 1 ? ctm.Cust_Current_subdistrict.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Current_subdistrict : "";
                    Customer_C_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Current_district) ? "" : ctm.Cust_Current_district.IndexOf('.') >= 1 ? ctm.Cust_Current_district.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Current_district : "";
                    Customer_C_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Current_province) ? "" : ctm.Cust_Current_province.IndexOf('.') >= 1 ? ctm.Cust_Current_province.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Current_province : "";
                }

                Car_Type_TBx.Text = cls.Car_type;

                bs_cbrn = cbrn_mng.getCarBrandById(cls.bs_cbrn.car_brand_id);

                if (bs_cbrn != null)
                {
                    Car_Brand_TBx.Text = bs_cbrn.car_brand_name_th + " ( " + bs_cbrn.car_brand_name_eng + " )";
                }

                Car_Plate_TBx.Text = cls.Car_license_plate + " " + cls.Car_license_plate_province;

                Car_Chassis_No_TBx.Text = cls.Car_chassis_no;
                Car_Engine_No_TBx.Text  = cls.Car_engine_no;

                cag_com = cag_mng.getAgentCommission("", leasing_id);

                Agent_Commission_TBx.Text = cag_com.Agent_commission.ToString("#,###.00");

                Finance_Cost_TBx.Text       = cls.Total_require.ToString("#,###.00");
                Finance_Value_TBx.Text      = cls.Total_sum.ToString("#,###.00");
                Leasing_Cost_TBx.Text       = cls.Total_Net_leasing.ToString("#,###.00");
                Period_Amount_TBx.Text      = cls.Total_period.ToString();
                Period_Payment_TBx.Text     = cls.Period_payment.ToString("#,###.00");
                Payment_Schedule_TBx.Text   = cls.Payment_schedule.ToString();
                Frist_Payment_Date_TBx.Text = DateTimeUtility.convertDateToPageRealServer(cls.First_payment_date);

                Payment_Date_TBx.Enabled = false;

                List <Car_Leasings_Payment> list_cls_pay = cls_pay_mng.getRealPaymentInfo(leasing_id);

                Session["list_cls_pay"] = list_cls_pay;

                Period_free_TBx.Enabled  = false;
                Period_track_TBx.Enabled = false;

                Real_Payment_TBx.Enabled      = false;
                Real_Payment_Fine_TBx.Enabled = false;
                Real_Discount_TBx.Enabled     = false;

                Payment_Date_TBx.Text = "";

                Period_No_TBx.Text            = "";
                Total_Payment_Period_TBx.Text = "";
                Total_payment_left_TBx.Text   = "";
                Period_free_TBx.Text          = "";
                Period_track_TBx.Text         = "";
                Discount_TBx.Text             = "";

                Total_payment_fine_TBx.Text = "";

                Total_period_left_TBx.Text  = "";
                Period_fine_TBx.Text        = "";
                Cal_Period_Payment_TBx.Text = "";
            }
            else
            {
                Leasing_Date_TBx.Text = DateTimeUtility.convertDateToPageRealServer(cls.Leasing_date);
                Deps_No_TBx.Text      = cls.Deps_no;
                Leasing_No_TBx.Text   = cls.Leasing_no;

                bs_cpn = bs_cpn_mng.getCompanysById(cls.bs_cpn.Company_id.ToString());

                Company_N_Name_TBx.Text = bs_cpn.Company_N_name;
                Company_F_Name_TBx.Text = bs_cpn.Company_F_name;

                bs_zn = bs_zn_mng.getZoneById(cls.bs_zn.Zone_id);

                Zone_Name_TBx.Text = bs_zn.Zone_code + " " + bs_zn.Zone_name;

                ctm = cls_ctm_mng.getCustomersLeasing(leasing_id, idcard);

                if (ctm != null)
                {
                    Customer_Name_TBx.Text   = ctm.Cust_Fname + " " + ctm.Cust_LName;
                    Customer_Idcard_TBx.Text = ctm.Cust_Idcard.Length == 13 ? ctm.Cust_Idcard.Substring(0, 1) + "-" + ctm.Cust_Idcard.Substring(1, 4) + "-" + ctm.Cust_Idcard.Substring(5, 5) + "-" + ctm.Cust_Idcard.Substring(10, 2) + "-" + ctm.Cust_Idcard.Substring(12) : ctm.Cust_Idcard;
                    //Customer_B_Date_TBx.Text = DateTimeUtility.convertDateToPage(ctm.Cust_B_date);
                    //Customer_Age_TBx.Text = ctm.Cust_Age.ToString();

                    Customer_H_Address_TBx.Text  = string.IsNullOrEmpty(ctm.Cust_Home_address_no) ? "" : ctm.Cust_Home_address_no;
                    Customer_H_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Home_vilage_no) ? "" : ctm.Cust_Home_vilage_no.IndexOf('.') >= 1 ? ctm.Cust_Home_vilage_no.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Home_vilage_no : "";
                    Customer_H_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Home_vilage) ? "" : ctm.Cust_Home_vilage.IndexOf('.') >= 1 ? ctm.Cust_Home_vilage.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Home_vilage : "";
                    Customer_H_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Home_alley) ? "" : ctm.Cust_Home_alley.IndexOf('.') >= 1 ? ctm.Cust_Home_alley.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Home_alley : "";
                    Customer_H_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Home_road) ? "" : ctm.Cust_Home_road.IndexOf('.') >= 1 ? ctm.Cust_Home_road.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Home_road : "";
                    Customer_H_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Home_subdistrict) ? "" : ctm.Cust_Home_subdistrict.IndexOf('.') >= 1 ? ctm.Cust_Home_subdistrict.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Home_subdistrict : "";
                    Customer_H_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Home_district) ? "" : ctm.Cust_Home_district.IndexOf('.') >= 1 ? ctm.Cust_Home_district.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Home_district : "";
                    Customer_H_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Home_province) ? "" : ctm.Cust_Home_province.IndexOf('.') >= 1 ? ctm.Cust_Home_province.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Home_province : "";

                    Customer_C_Address_TBx.Text  = string.IsNullOrEmpty(ctm.Cust_Current_address_no) ? "" : ctm.Cust_Current_address_no;
                    Customer_C_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Current_vilage_no) ? "" : ctm.Cust_Current_vilage_no.IndexOf('.') >= 1 ? ctm.Cust_Current_vilage_no.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Current_vilage_no : "";
                    Customer_C_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Current_vilage) ? "" : ctm.Cust_Current_vilage.IndexOf('.') >= 1 ? ctm.Cust_Current_vilage.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Current_vilage : "";
                    Customer_C_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Current_alley) ? "" : ctm.Cust_Current_alley.IndexOf('.') >= 1 ? ctm.Cust_Current_alley.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Current_alley : "";
                    Customer_C_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Current_road) ? "" : ctm.Cust_Current_road.IndexOf('.') >= 1 ? ctm.Cust_Current_road.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Current_road : "";
                    Customer_C_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Current_subdistrict) ? "" : ctm.Cust_Current_subdistrict.IndexOf('.') >= 1 ? ctm.Cust_Current_subdistrict.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Current_subdistrict : "";
                    Customer_C_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Current_district) ? "" : ctm.Cust_Current_district.IndexOf('.') >= 1 ? ctm.Cust_Current_district.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Current_district : "";
                    Customer_C_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Current_province) ? "" : ctm.Cust_Current_province.IndexOf('.') >= 1 ? ctm.Cust_Current_province.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Current_province : "";
                }

                Car_Type_TBx.Text = cls.Car_type;

                bs_cbrn = cbrn_mng.getCarBrandById(cls.bs_cbrn.car_brand_id);

                if (bs_cbrn != null)
                {
                    Car_Brand_TBx.Text = bs_cbrn.car_brand_name_th + " ( " + bs_cbrn.car_brand_name_eng + " )";
                }

                Car_Plate_TBx.Text = cls.Car_license_plate + " " + cls.Car_license_plate_province;

                Car_Chassis_No_TBx.Text = cls.Car_chassis_no;
                Car_Engine_No_TBx.Text  = cls.Car_engine_no;

                cag_com = cag_mng.getAgentCommission("", leasing_id);

                Agent_Commission_TBx.Text = cag_com.Agent_commission.ToString("#,###.00");

                Finance_Cost_TBx.Text       = cls.Total_require.ToString("#,###.00");
                Finance_Value_TBx.Text      = cls.Total_sum.ToString("#,###.00");
                Leasing_Cost_TBx.Text       = cls.Total_Net_leasing.ToString("#,###.00");
                Period_Amount_TBx.Text      = cls.Total_period.ToString();
                Period_Payment_TBx.Text     = cls.Period_payment.ToString("#,###.00");
                Payment_Schedule_TBx.Text   = cls.Payment_schedule.ToString();
                Frist_Payment_Date_TBx.Text = DateTimeUtility.convertDateToPageRealServer(cls.First_payment_date);

                Payment_Date_TBx.Text = DateTimeUtility.convertDateToPageRealServer(DateTime.Now.ToString());

                Period_No_TBx.Text            = cls.Total_period_length;
                Total_Payment_Period_TBx.Text = cls.Total_period_lose == 0 ? "1" : cls.Total_period_lose.ToString();
                Total_payment_left_TBx.Text   = cls.Total_payment_left.ToString("#,###.00");
                Period_free_TBx.Text          = "0.00";
                Period_track_TBx.Text         = "0.00";
                Discount_TBx.Text             = "0.00";

                List <Car_Leasings_Payment> list_cls_pay = cls_pay_mng.getRealPaymentInfo(leasing_id);

                double total_lost         = 0.00;
                double total_payment_fine = 0.00;
                double payment_fine       = 0.00;
                double real_payment_fine  = 0.00;
                double real_payment       = 0.00;
                double next_period_no     = 1;
                double duplicate_period   = 0;

                for (int i = 0; i < list_cls_pay.Count; i++)
                {
                    Car_Leasings_Payment cls_pay = list_cls_pay[i];

                    if (string.IsNullOrEmpty(cls.Total_period_length))
                    {
                        total_lost         = cls_pay.Period_current;
                        Period_No_TBx.Text = next_period_no.ToString();
                    }
                    else
                    {
                        int period_str = Convert.ToInt32(cls.Total_period_length.Split('-')[0].Trim());
                        int period_end = Convert.ToInt32(cls.Total_period_length.Split('-')[1].Trim());

                        if (cls_pay.Period_no >= period_str && cls_pay.Period_no <= period_end && cls_pay.Period_no != duplicate_period)
                        {
                            total_lost += cls_pay.Period_current;
                        }
                    }

                    if (cls_pay.Period_fine > 0 && cls_pay.Period_no != duplicate_period)
                    {
                        payment_fine += cls_pay.Period_fine;
                    }

                    if (cls_pay.Real_payment_fine > 0)
                    {
                        real_payment_fine += cls_pay.Real_payment_fine;
                    }

                    if (cls_pay.Real_payment > 0 && cls_pay.Period_payment_status != 9)
                    {
                        real_payment += cls_pay.Real_payment;
                    }

                    if (cls_pay.Period_payment_status == 9 && cls_pay.Period_no != duplicate_period)
                    {
                        next_period_no += 1;
                    }

                    duplicate_period = cls_pay.Period_no;
                }

                total_payment_fine = payment_fine - real_payment_fine;

                Total_payment_fine_TBx.Text = total_payment_fine > 0 ? total_payment_fine.ToString("#,###.00") : "0.00";

                Total_period_left_TBx.Text = string.IsNullOrEmpty(cls.Total_period_length) ? "0.00" : (total_lost - real_payment).ToString("#,###.00");

                Period_fine_TBx.Text = total_payment_fine < 0 ? "0.00" : total_payment_fine.ToString("#,###.00");

                Cal_Period_Payment_TBx.Text = (total_lost - real_payment).ToString("#,###.00");

                Session["list_cls_pay"] = list_cls_pay;

                Real_Payment_TBx.Focus();
            }
        }