public ProductItemMapExcelMgr(string connectionString)
 {
     _productItemMapMgr = new ProductItemMapMgr(connectionString);
     _productItemMapDao = new ProductItemMapDao(connectionString);
     _productItemMgr = new ProductItemMgr(connectionString);
     _productItemDao = new ProductItemDao(connectionString);
     _callerMgr = new CallerMgr(connectionString);
     _priceMasterMgr = new PriceMasterMgr(connectionString);
     _access = DBAccess.DBFactory.getDBAccess(DBType.MySql, connectionString);
 }
Esempio n. 2
0
        public HttpResponseBase SaveVendor()
        {
            string jsonStr = String.Empty;
            try
            {
                VendorQuery venQuery = new VendorQuery();

                venQuery.user_type = 2;//變更者類型1.供應商2.管理員
                if (Request.Params["vendor_id"].ToString() == "")
                {
                    #region 獲取供應商數據
                    if (!string.IsNullOrEmpty(Request.Params["vendor_status"].ToString()))
                    {
                        venQuery.vendor_status = Convert.ToUInt32(Request.Params["vendor_status"].ToString());
                    }
                    else
                    {
                        venQuery.vendor_status = 1;
                    }

                    _vendorMgr = new VendorMgr(connectionString);
                    if (!string.IsNullOrEmpty(Request.Params["vendor_email"].ToString()))
                    {
                        try
                        {
                            if (_vendorMgr.IsExitEmail(Request.Params["vendor_email"].ToString().ToLower()) != 0)
                            {
                                jsonStr = "{success:true,msg:0}";//返回json數據
                                this.Response.Clear();
                                this.Response.Write(jsonStr);
                                this.Response.End();
                                return this.Response;
                            }
                            else
                            {
                                venQuery.vendor_email = Request.Params["vendor_email"].Trim().ToLower();
                            }
                        }
                        catch (Exception ex)
                        {
                            Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                            logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                            logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                            log.Error(logMessage);
                            jsonStr = "{success:false,msg:1}";
                            this.Response.Clear();
                            this.Response.Write(jsonStr);
                            this.Response.End();
                            return this.Response;
                        }
                    }
                    else
                    {
                        venQuery.vendor_email = "";
                    }

                    BLL.gigade.Common.HashEncrypt hash = new BLL.gigade.Common.HashEncrypt();
                    if (!string.IsNullOrEmpty(Request.Params["vendor_password"].ToString()))
                    {
                        venQuery.vendor_password = hash.SHA256Encrypt(Request.Params["vendor_password"].ToString());
                    }
                    else
                    {
                        //新增供應商時如果未設置密碼則將統一編號進行加密作為密碼進行保存
                        venQuery.vendor_password = hash.SHA256Encrypt(Request.Params["vendor_invoice"]);
                    }

                    if (!string.IsNullOrEmpty(Request.Params["vendor_name_full"].ToString()))
                    {
                        venQuery.vendor_name_full = Request.Params["vendor_name_full"].ToString().Trim();
                    }
                    else
                    {
                        venQuery.vendor_name_full = "";
                    }
                    if (!string.IsNullOrEmpty(Request.Params["vendor_name_simple"].ToString()))
                    {
                        venQuery.vendor_name_simple = Request.Params["vendor_name_simple"].ToString().Trim();
                    }
                    else
                    {
                        venQuery.vendor_name_simple = "";
                    }
                    if (!string.IsNullOrEmpty(Request.Params["vendor_invoice"].ToString()))
                    {
                        venQuery.vendor_invoice = Request.Params["vendor_invoice"].ToString();
                    }
                    else
                    {
                        venQuery.vendor_invoice = "";
                    }
                    if (!string.IsNullOrEmpty(Request.Params["company_phone"].ToString()))
                    {
                        venQuery.company_phone = Request.Params["company_phone"].ToString();
                    }
                    else
                    {
                        venQuery.company_phone = "";
                    }
                    if (!string.IsNullOrEmpty(Request.Params["company_fax"].ToString()))
                    {
                        venQuery.company_fax = Request.Params["company_fax"].ToString();
                    }
                    else
                    {
                        venQuery.company_fax = "";
                    }
                    if (!string.IsNullOrEmpty(Request.Params["company_person"].ToString()))
                    {
                        venQuery.company_person = Request.Params["company_person"].ToString();
                    }
                    else
                    {
                        venQuery.company_person = "";
                    }
                    if (!string.IsNullOrEmpty(Request.Params["company_zip"].ToString()))
                    {
                        venQuery.company_zip = Convert.ToUInt32(Request.Params["company_zip"].ToString());
                    }
                    else
                    {
                        venQuery.company_zip = 0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["company_address"].ToString()))
                    {
                        venQuery.company_address = Request.Params["company_address"].ToString();
                    }
                    else
                    {
                        venQuery.company_address = "";
                    }
                    if (!string.IsNullOrEmpty(Request.Params["invoice_zip"].ToString()))
                    {
                        venQuery.invoice_zip = Convert.ToUInt32(Request.Params["invoice_zip"].ToString());
                    }
                    else
                    {
                        venQuery.invoice_zip = 0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["invoice_address"].ToString()))
                    {
                        venQuery.invoice_address = Request.Params["invoice_address"].ToString();
                    }
                    else
                    {
                        venQuery.invoice_address = "";
                    }

                    if (!string.IsNullOrEmpty(Request.Params["pm"].ToString()))
                    {
                        venQuery.product_manage = Convert.ToUInt32(Request.Params["pm"].ToString());
                    }
                    else
                    {
                        venQuery.product_manage = 0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["cost_percent"].ToString()))
                    {
                        venQuery.cost_percent = Convert.ToUInt32(Request.Params["cost_percent"].ToString());
                    }
                    else
                    {
                        venQuery.cost_percent = 0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["creditcard_1_percent"].ToString()))
                    {
                        venQuery.creditcard_1_percent = Convert.ToUInt32(Request.Params["creditcard_1_percent"].ToString());
                    }
                    else
                    {
                        venQuery.creditcard_1_percent = 0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["creditcard_3_percent"].ToString()))
                    {
                        venQuery.creditcard_3_percent = Request.Params["creditcard_3_percent"].ToString();
                    }
                    else
                    {
                        venQuery.creditcard_3_percent = "0";
                    }
                    if (!string.IsNullOrEmpty(Request.Params["agreement_createdate"].ToString()))
                    {
                        venQuery.agreement_createdate = Convert.ToUInt32(CommonFunction.GetPHPTime(Request.Params["agreement_createdate"].ToString()));

                    }
                    else
                    {
                        venQuery.agreement_createdate = 0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["agreement_start"].ToString()))
                    {
                        venQuery.agreement_start = Convert.ToUInt32(CommonFunction.GetPHPTime(Request.Params["agreement_start"].ToString()));
                    }
                    else
                    {
                        venQuery.agreement_start = 0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["agreement_end"].ToString()))
                    {
                        venQuery.agreement_end = Convert.ToUInt32(CommonFunction.GetPHPTime(Request.Params["agreement_end"].ToString()));
                    }
                    else
                    {
                        venQuery.agreement_end = 0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["checkout_type"].ToString()))
                    {
                        venQuery.checkout_type = Convert.ToUInt32(Request.Params["checkout_type"].ToString());
                    }
                    else
                    {
                        venQuery.checkout_type = 1;
                    }
                    if (venQuery.checkout_type == 3)
                    {
                        if (!string.IsNullOrEmpty(Request.Params["checkout_other"].ToString()))
                        {
                            venQuery.checkout_other = Request.Params["checkout_other"].ToString();
                        }
                        else
                        {
                            venQuery.checkout_other = "";
                        }
                    }
                    if (!string.IsNullOrEmpty(Request.Params["bank_code"].ToString()))
                    {
                        venQuery.bank_code = Request.Params["bank_code"].ToString();
                    }
                    else
                    {
                        venQuery.bank_code = "";
                    }
                    if (!string.IsNullOrEmpty(Request.Params["bank_name"].ToString()))
                    {
                        venQuery.bank_name = Request.Params["bank_name"].ToString();
                    }
                    else
                    {
                        venQuery.bank_name = "";
                    }
                    if (!string.IsNullOrEmpty(Request.Params["bank_number"].ToString()))
                    {
                        venQuery.bank_number = Request.Params["bank_number"].ToString();
                    }
                    else
                    {
                        venQuery.bank_number = "";
                    }
                    if (!string.IsNullOrEmpty(Request.Params["bank_account"].ToString()))
                    {
                        venQuery.bank_account = Request.Params["bank_account"].ToString();
                    }
                    else
                    {
                        venQuery.bank_account = "";
                    }
                    if (!string.IsNullOrEmpty(Request.Params["bank_number"].ToString()))
                    {
                        venQuery.bank_number = Request.Params["bank_number"].ToString();
                    }
                    else
                    {
                        venQuery.bank_number = "";
                    }
                    if (!string.IsNullOrEmpty(Request.Params["freight_low_limit"].ToString()))
                    {
                        venQuery.freight_low_limit = Convert.ToUInt32(Request.Params["freight_low_limit"].ToString());
                    }
                    else
                    {
                        venQuery.freight_low_limit = 0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["freight_low_money"].ToString()))
                    {
                        venQuery.freight_low_money = Convert.ToUInt32(Request.Params["freight_low_money"].ToString());
                    }
                    else
                    {
                        venQuery.freight_low_money = 0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["freight_return_low_money"].ToString()))
                    {
                        venQuery.freight_return_low_money = Convert.ToUInt32(Request.Params["freight_return_low_money"].ToString());
                    }
                    else
                    {
                        venQuery.freight_return_low_money = 0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["freight_normal_limit"].ToString()))
                    {
                        venQuery.freight_normal_limit = Convert.ToUInt32(Request.Params["freight_normal_limit"].ToString());
                    }
                    else
                    {
                        venQuery.freight_normal_limit = 0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["freight_normal_money"].ToString()))
                    {
                        venQuery.freight_normal_money = Convert.ToUInt32(Request.Params["freight_normal_money"].ToString());
                    }
                    else
                    {
                        venQuery.freight_normal_money = 0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["freight_return_normal_money"].ToString()))
                    {
                        venQuery.freight_return_normal_money = Convert.ToUInt32(Request.Params["freight_return_normal_money"].ToString());
                    }
                    else
                    {
                        venQuery.freight_return_normal_money = 0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["assist"].ToString()))
                    {
                        venQuery.assist = Convert.ToUInt32(Request.Params["assist"].ToString());
                    }
                    else
                    {
                        venQuery.assist = 0;
                    }
                    //if (!string.IsNullOrEmpty(Request.Params["dispatch"].ToString()))
                    //{
                    //    venQuery.dispatch = Convert.ToUInt32(Request.Params["dispatch"].ToString());
                    //}
                    //else
                    //{
                    //    venQuery.dispatch = 0;
                    //}
                    //if (!string.IsNullOrEmpty(Request.Params["product_mode"].ToString()))
                    //{
                    //    venQuery.product_mode = Convert.ToUInt32(Request.Params["product_mode"].ToString());
                    //}
                    //else
                    //{
                    //    venQuery.product_mode = 1;
                    //}
                    if (!string.IsNullOrEmpty(Request.Params["procurement_days"].ToString()))
                    {
                        venQuery.procurement_days = Convert.ToInt32(Request.Params["procurement_days"].ToString());
                    }
                    else
                    {
                        venQuery.procurement_days = 0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["self_send_days"].ToString()))
                    {
                        venQuery.self_send_days = Convert.ToInt32(Request.Params["self_send_days"].ToString());
                    }
                    else
                    {
                        venQuery.self_send_days = 0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["stuff_ware_days"].ToString()))
                    {
                        venQuery.stuff_ware_days = Convert.ToInt32(Request.Params["stuff_ware_days"].ToString());
                    }
                    else
                    {
                        venQuery.stuff_ware_days = 0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["dispatch_days"].ToString()))
                    {
                        venQuery.dispatch_days = Convert.ToInt32(Request.Params["dispatch_days"].ToString());
                    }
                    else
                    {
                        venQuery.dispatch_days = 0;
                    }

                    if (!string.IsNullOrEmpty(Request.Params["gigade_bunus_percent"].ToString()))
                    {
                        venQuery.gigade_bunus_percent = Convert.ToUInt32(Request.Params["gigade_bunus_percent"].ToString());
                    }
                    else
                    {
                        venQuery.gigade_bunus_percent = 0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["gigade_bunus_threshold"].ToString()))
                    {
                        venQuery.gigade_bunus_threshold = Convert.ToUInt32(Request.Params["gigade_bunus_threshold"].ToString());
                    }
                    else
                    {
                        venQuery.gigade_bunus_threshold = 0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["vendor_note"].ToString()))
                    {
                        venQuery.vendor_note = Request.Params["vendor_note"].ToString();
                    }
                    else
                    {
                        venQuery.vendor_note = "";
                    }

                    if (!string.IsNullOrEmpty(Request.Params["prod_cate"].ToString()))
                    {
                        venQuery.prod_cate = Request.Params["prod_cate"].ToString();
                    }
                    else
                    {
                        venQuery.prod_cate = "";
                    }
                    if (!string.IsNullOrEmpty(Request.Params["buy_cate"].ToString()))
                    {
                        venQuery.buy_cate = Request.Params["buy_cate"].ToString();
                    }
                    else
                    {
                        venQuery.buy_cate = "";
                    }
                    if (!string.IsNullOrEmpty(Request.Params["tax_type"].ToString()))
                    {
                        venQuery.tax_type = Request.Params["tax_type"].ToString();
                    }
                    else
                    {
                        venQuery.tax_type = "";
                    }
                    #endregion

                    #region   //對聯絡人的 信息處理


                    if (!string.IsNullOrEmpty(Request.Params["conactValues"].ToString()))
                    {
                        string contact = Request.Params["conactValues"].ToString();
                        string[] contactarr = contact.Split('|');
                        string[] contact1;
                        for (int i = 0; i < contactarr.Length - 1; i++)
                        {
                            contact1 = contactarr[i].Split(',');
                            if (i == 0)
                            {
                                venQuery.contact_type_1 = 4;
                                venQuery.contact_name_1 = contact1[1];
                                venQuery.contact_phone_1_1 = contact1[2];
                                venQuery.contact_phone_2_1 = contact1[3];
                                venQuery.contact_mobile_1 = contact1[4];
                                venQuery.contact_email_1 = contact1[5].ToLower();
                            }
                            else if (i == 1)
                            {
                                venQuery.contact_type_2 = Convert.ToUInt32(ContactType(contact1[0].ToString()));
                                venQuery.contact_name_2 = contact1[1];
                                venQuery.contact_phone_1_2 = contact1[2];
                                venQuery.contact_phone_2_2 = contact1[3];
                                venQuery.contact_mobile_2 = contact1[4];
                                venQuery.contact_email_2 = contact1[5].ToLower().ToLower();
                            }
                            else if (i == 2)
                            {
                                venQuery.contact_type_3 = Convert.ToUInt32(ContactType(contact1[0].ToString()));
                                venQuery.contact_name_3 = contact1[1];
                                venQuery.contact_phone_1_3 = contact1[2];
                                venQuery.contact_phone_2_3 = contact1[3];
                                venQuery.contact_mobile_3 = contact1[4];
                                venQuery.contact_email_3 = contact1[5].ToLower();
                            }
                            else if (i == 3)
                            {
                                venQuery.contact_type_4 = Convert.ToUInt32(ContactType(contact1[0].ToString()));
                                venQuery.contact_name_4 = contact1[1];
                                venQuery.contact_phone_1_4 = contact1[2];
                                venQuery.contact_phone_2_4 = contact1[3];
                                venQuery.contact_mobile_4 = contact1[4];
                                venQuery.contact_email_4 = contact1[5].ToLower();
                            }
                            else if (i == 4)
                            {
                                venQuery.contact_type_5 = Convert.ToUInt32(ContactType(contact1[0].ToString()));
                                venQuery.contact_name_5 = contact1[1];
                                venQuery.contact_phone_1_5 = contact1[2];
                                venQuery.contact_phone_2_5 = contact1[3];
                                venQuery.contact_mobile_5 = contact1[4];
                                venQuery.contact_email_5 = contact1[5].ToLower();
                            }

                        }


                    }
                    #endregion
                    venQuery.ip = Request.UserHostAddress;
                    venQuery.file_name = "VendorList.chtml";
                    venQuery.created = DateTime.Now;
                    venQuery.kuser_id = Convert.ToUInt32((System.Web.HttpContext.Current.Session["caller"] as Caller).user_id.ToString());
                    venQuery.export_flag = 1;
                    venQuery.kuser = (int)venQuery.kuser_id;
                    venQuery.kdate = venQuery.created;
                    //供應商類型
                    if (!string.IsNullOrEmpty(Request.Params["gigade_vendor_type"]))
                    {
                        venQuery.vendor_type = Request.Params["gigade_vendor_type"].ToString();
                    }
                    mgr = new CallerMgr(connectionString);
                    Caller caller = new Caller();
                    caller = mgr.GetUserById(Convert.ToInt32(venQuery.kuser_id));
                    venQuery.kuser_name = caller.user_username;

                    return VendorAdd(venQuery);
                }
                else
                {
                    venQuery.vendor_id = Convert.ToUInt32(Request.Params["vendor_id"].ToString());
                    venQuery.vendor_code = Request.Params["vendor_code"].ToString();
                    _vendorMgr = new VendorMgr(connectionString);
                    _configMgr = new ConfigMgr(connectionString);
                    Vendor oldven = _vendorMgr.GetSingle(venQuery);
                    StringBuilder update_log = new StringBuilder();
                    List<TableChangeLog> list = new List<TableChangeLog>();

                    #region 獲取供應商數據
                    uint isUint = 0;//判斷字符串是否能夠轉換為uint類型
                    if (uint.TryParse(Request.Params["vendor_status"].ToString(), out isUint))
                    {
                        venQuery.vendor_status = Convert.ToUInt32(Request.Params["vendor_status"].ToString());
                        if (oldven.vendor_status != venQuery.vendor_status)
                        {//1:啟用2:停用3:失格
                            // update_log.AppendFormat("vendor_status:{0}:{1}:供應商狀態#", oldven.vendor_status, venQuery.vendor_status);
                            TableChangeLog item = new TableChangeLog();
                            item.change_field = "vendor_status";
                            item.old_value = oldven.vendor_status.ToString();
                            item.new_value = venQuery.vendor_status.ToString();
                            item.field_ch_name = "供應商狀態";
                            list.Add(item);
                        }
                    }
                    else
                    {
                        venQuery.vendor_status = oldven.vendor_status;
                    }
                    //供應商類型
                    if (!string.IsNullOrEmpty(Request.Params["gigade_vendor_type"]))
                    {
                        venQuery.vendor_type = Request.Params["gigade_vendor_type"].ToString();

                    }
                    int tmp = 0;
                    string[] strs = venQuery.vendor_type.Split(',');
                    for (int i = 0; i < strs.Length; i++)
                    {
                        if (!int.TryParse(strs[i], out tmp))
                        {
                            venQuery.vendor_type = oldven.vendor_type;
                            break;
                        }
                    }
                    if (oldven.vendor_type != venQuery.vendor_type)
                    {
                        // update_log.AppendFormat("vendor_type:{0}:{1}:供應商類型#", oldven.vendor_type, venQuery.vendor_type);
                        TableChangeLog item = new TableChangeLog();
                        item.change_field = "vendor_type";
                        item.old_value = oldven.vendor_type;
                        item.new_value = venQuery.vendor_type;
                        item.field_ch_name = "供應商類型";
                        list.Add(item);
                    }
                    if (!string.IsNullOrEmpty(Request.Params["vendor_email"].ToString()))
                    {
                        int total = _vendorMgr.IsExitEmail(Request.Params["vendor_email"].ToString().ToLower());
                        try
                        {
                            if (total > 1)
                            {
                                jsonStr = "{success:true,msg:0}";//返回json數據
                                this.Response.Clear();
                                this.Response.Write(jsonStr);
                                this.Response.End();
                                return this.Response;
                            }
                            else
                            {
                                if (total == 1)
                                {
                                    if (Request.Params["vendor_email"].ToString().ToLower() == oldven.vendor_email.ToLower())
                                    {
                                        venQuery.vendor_email = oldven.vendor_email.ToLower();
                                    }
                                    else
                                    {
                                        jsonStr = "{success:true,msg:0}";//返回json數據rue
                                        this.Response.Clear();
                                        this.Response.Write(jsonStr);
                                        this.Response.End();
                                        return this.Response;
                                    }
                                }
                                else if (total == 0)
                                {
                                    venQuery.vendor_email = Request.Params["vendor_email"].ToString().ToLower();
                                    if (oldven.vendor_email != venQuery.vendor_email)
                                    {
                                        // update_log.AppendFormat("vendor_email:{0}:{1}:公司Email#", oldven.vendor_email, venQuery.vendor_email);
                                        TableChangeLog item = new TableChangeLog();
                                        item.change_field = "vendor_email";
                                        item.old_value = oldven.vendor_email;
                                        item.new_value = venQuery.vendor_email;
                                        item.field_ch_name = "公司Email";
                                        list.Add(item);
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                            logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                            logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                            log.Error(logMessage);
                            jsonStr = "{success:false,msg:1}";
                            this.Response.Clear();
                            this.Response.Write(jsonStr);
                            this.Response.End();
                            return this.Response;
                        }
                    }
                    else
                    {
                        venQuery.vendor_email = oldven.vendor_email;
                    }
                    //if (!string.IsNullOrEmpty(Request.Params["vendor_password"].ToString()))
                    //{
                    //    BLL.gigade.Common.HashEncrypt hash = new BLL.gigade.Common.HashEncrypt();
                    //    venQuery.vendor_password = hash.SHA256Encrypt(Request.Params["vendor_password"].ToString());
                    //}
                    //else
                    //{
                    //    venQuery.vendor_password = oldven.vendor_password;
                    //}
                    if (!string.IsNullOrEmpty(Request.Params["vendor_name_full"].ToString()))
                    {
                        venQuery.vendor_name_full = Request.Params["vendor_name_full"].ToString().Trim();
                    }
                    else
                    {
                        venQuery.vendor_name_full = oldven.vendor_name_full;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["vendor_name_simple"].ToString()))
                    {
                        venQuery.vendor_name_simple = Request.Params["vendor_name_simple"].ToString().Trim();
                    }
                    else
                    {
                        venQuery.vendor_name_simple = oldven.vendor_name_simple;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["vendor_invoice"].ToString()))
                    {
                        venQuery.vendor_invoice = Request.Params["vendor_invoice"].ToString();
                        if (oldven.vendor_invoice != venQuery.vendor_invoice)
                        {
                            // update_log.AppendFormat("vendor_invoice:{0}:{1}:統一編號#", oldven.vendor_invoice, venQuery.vendor_invoice);
                            TableChangeLog item = new TableChangeLog();
                            item.change_field = "vendor_invoice";
                            item.old_value = oldven.vendor_invoice;
                            item.new_value = venQuery.vendor_invoice;
                            item.field_ch_name = "統一編號";
                            list.Add(item);
                        }
                    }
                    else
                    {
                        venQuery.vendor_invoice = oldven.vendor_invoice;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["company_phone"].ToString()))
                    {
                        venQuery.company_phone = Request.Params["company_phone"].ToString();
                        if (oldven.company_phone != venQuery.company_phone)
                        {
                            //update_log.AppendFormat("company_phone:{0}:{1}:公司電話#", oldven.company_phone, venQuery.company_phone);
                            TableChangeLog item = new TableChangeLog();
                            item.change_field = "company_phone";
                            item.old_value = oldven.company_phone;
                            item.new_value = venQuery.company_phone;
                            item.field_ch_name = "公司電話";
                            list.Add(item);
                        }
                    }
                    else
                    {
                        venQuery.company_phone = oldven.company_phone;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["company_fax"].ToString()))
                    {
                        venQuery.company_fax = Request.Params["company_fax"].ToString();
                        if (oldven.company_fax != venQuery.company_fax)
                        {
                            // update_log.AppendFormat("company_fax:{0}:{1}:公司傳真#", oldven.company_fax, venQuery.company_fax);
                            TableChangeLog item = new TableChangeLog();
                            item.change_field = "company_fax";
                            item.old_value = oldven.company_fax;
                            item.new_value = venQuery.company_fax;
                            item.field_ch_name = "公司傳真";
                            list.Add(item);
                        }
                    }


                    if (!string.IsNullOrEmpty(Request.Params["company_person"].ToString()))
                    {
                        venQuery.company_person = Request.Params["company_person"].ToString();
                        if (oldven.company_person != venQuery.company_person)
                        {
                            //update_log.AppendFormat("company_person:{0}:{1}:公司負責人#", oldven.company_person, venQuery.company_person);
                            TableChangeLog item = new TableChangeLog();
                            item.change_field = "company_person";
                            item.old_value = oldven.company_person;
                            item.new_value = venQuery.company_person;
                            item.field_ch_name = "公司負責人";
                            list.Add(item);
                        }
                    }

                    if (!string.IsNullOrEmpty(Request.Params["company_zip"].ToString()))
                    {

                        venQuery.company_zip = Convert.ToUInt32(Request.Params["company_zip"].ToString());

                    }

                    venQuery.company_address = Request.Params["company_address"].ToString();
                    if (oldven.company_zip != venQuery.company_zip || oldven.company_address != venQuery.company_address)
                    {
                        //update_log.AppendFormat("company_address:{0}:{1}:公司地址#", oldven.company_zip + "&" + oldven.company_address, venQuery.company_zip + "&" + venQuery.company_address);
                        TableChangeLog item = new TableChangeLog();
                        item.change_field = "company_address";
                        item.old_value = oldven.company_zip + "&" + oldven.company_address;
                        item.new_value = venQuery.company_zip + "&" + venQuery.company_address;
                        item.field_ch_name = "公司地址";
                        list.Add(item);
                    }
                    if (!string.IsNullOrEmpty(Request.Params["invoice_zip"].ToString()))
                    {
                        venQuery.invoice_zip = Convert.ToUInt32(Request.Params["invoice_zip"].ToString());
                    }

                    venQuery.invoice_address = Request.Params["invoice_address"].ToString();

                    if (oldven.invoice_zip != venQuery.invoice_zip || oldven.invoice_address != venQuery.invoice_address)
                    {
                        //update_log.AppendFormat("invoice_address:{0}:{1}:發票地址#", oldven.invoice_zip + "&" + oldven.invoice_address, venQuery.invoice_zip + "&" + venQuery.invoice_address);
                        TableChangeLog item = new TableChangeLog();
                        item.change_field = "invoice_address";
                        item.old_value = oldven.invoice_zip + "&" + oldven.invoice_address;
                        item.new_value = venQuery.invoice_zip + "&" + venQuery.invoice_address;
                        item.field_ch_name = "發票地址";
                        list.Add(item);
                    }
                    venQuery.erp_id = oldven.erp_id;
                    if (uint.TryParse(Request.Params["cost_percent"].ToString(), out isUint))
                    {
                        venQuery.cost_percent = Convert.ToUInt32(Request.Params["cost_percent"].ToString());
                        if (oldven.cost_percent != venQuery.cost_percent)
                        {
                            //update_log.AppendFormat("cost_percent:{0}:{1}:成本百分比#", oldven.cost_percent, venQuery.cost_percent);
                            TableChangeLog item = new TableChangeLog();
                            item.change_field = "cost_percent";
                            item.old_value = oldven.cost_percent.ToString();
                            item.new_value = venQuery.cost_percent.ToString();
                            item.field_ch_name = "成本百分比";
                            list.Add(item);
                        }
                    }
                    else
                    {
                        venQuery.cost_percent = 0;
                    }


                    if (uint.TryParse(Request.Params["creditcard_1_percent"].ToString(), out isUint))
                    {
                        venQuery.creditcard_1_percent = Convert.ToUInt32(Request.Params["creditcard_1_percent"].ToString());
                    }
                    else
                    {
                        venQuery.creditcard_1_percent = 0;
                    }

                    if (!string.IsNullOrEmpty(Request.Params["creditcard_3_percent"].ToString()))
                    {
                        venQuery.creditcard_3_percent = Request.Params["creditcard_3_percent"].ToString();
                    }
                    else
                    {
                        venQuery.creditcard_3_percent = "0";
                    }
                    if (!string.IsNullOrEmpty(Request.Params["agreement_createdate"].ToString()))
                    {
                        venQuery.agreement_createdate = Convert.ToUInt32(CommonFunction.GetPHPTime(Request.Params["agreement_createdate"].ToString()));
                        if (oldven.agreement_createdate != venQuery.agreement_createdate)
                        {

                            //update_log.AppendFormat("agreement_createdate:{0}:{1}:合約簽訂日期#", CommonFunction.GetNetTime(oldven.agreement_createdate).ToShortDateString(), CommonFunction.GetNetTime(venQuery.agreement_createdate).ToShortDateString());
                            TableChangeLog item = new TableChangeLog();
                            item.change_field = "agreement_createdate";
                            item.old_value = CommonFunction.GetNetTime(oldven.agreement_createdate).ToShortDateString();
                            item.new_value = CommonFunction.GetNetTime(venQuery.agreement_createdate).ToShortDateString();
                            item.field_ch_name = "合約簽訂日期";
                            list.Add(item);
                        }
                    }
                    else
                    {
                        venQuery.agreement_createdate = oldven.agreement_createdate;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["agreement_start"].ToString()))
                    {
                        venQuery.agreement_start = Convert.ToUInt32(CommonFunction.GetPHPTime(Request.Params["agreement_start"].ToString()));
                        if (oldven.agreement_start != venQuery.agreement_start)
                        {
                            // update_log.AppendFormat("agreement_start:{0}:{1}:合約開始日#", CommonFunction.GetNetTime(oldven.agreement_start).ToShortDateString(), CommonFunction.GetNetTime(venQuery.agreement_start).ToShortDateString());
                            TableChangeLog item = new TableChangeLog();
                            item.change_field = "agreement_start";
                            item.old_value = CommonFunction.GetNetTime(oldven.agreement_start).ToShortDateString();
                            item.new_value = CommonFunction.GetNetTime(venQuery.agreement_start).ToShortDateString();
                            item.field_ch_name = "合約開始日";
                            list.Add(item);
                        }
                    }
                    else
                    {
                        venQuery.agreement_start = oldven.agreement_start;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["agreement_end"].ToString()))
                    {
                        venQuery.agreement_end = Convert.ToUInt32(CommonFunction.GetPHPTime(Request.Params["agreement_end"].ToString()));
                        if (oldven.agreement_end != venQuery.agreement_end)
                        {
                            // update_log.AppendFormat("agreement_end:{0}:{1}:合約結束日#", CommonFunction.GetNetTime(oldven.agreement_end).ToShortDateString(), CommonFunction.GetNetTime(venQuery.agreement_end).ToShortDateString());
                            TableChangeLog item = new TableChangeLog();
                            item.change_field = "agreement_end";
                            item.old_value = CommonFunction.GetNetTime(oldven.agreement_end).ToShortDateString();
                            item.new_value = CommonFunction.GetNetTime(venQuery.agreement_end).ToShortDateString();
                            item.field_ch_name = "合約結束日";
                            list.Add(item);
                        }
                    }
                    else
                    {
                        venQuery.agreement_end = oldven.agreement_end;
                    }
                    if (uint.TryParse(Request.Params["checkout_type"].ToString(), out isUint))
                    {
                        venQuery.checkout_type = Convert.ToUInt32(Request.Params["checkout_type"].ToString());
                    }
                    else
                    {
                        venQuery.checkout_type = oldven.checkout_type;
                    }
                    if (venQuery.checkout_type == 3)
                    {
                        if (!string.IsNullOrEmpty(Request.Params["checkout_other"].ToString()))
                        {
                            venQuery.checkout_other = Request.Params["checkout_other"].ToString();
                        }
                        else
                        {
                            venQuery.checkout_other = oldven.checkout_other;
                        }
                    }
                    if (!string.IsNullOrEmpty(Request.Params["bank_code"].ToString()))
                    {
                        venQuery.bank_code = Request.Params["bank_code"].ToString();
                        if (oldven.bank_code != venQuery.bank_code)
                        {
                            //update_log.AppendFormat("bank_code:{0}:{1}:銀行代碼#", oldven.bank_code, venQuery.bank_code);
                            TableChangeLog item = new TableChangeLog();
                            item.change_field = "bank_code";
                            item.old_value = oldven.bank_code;
                            item.new_value = venQuery.bank_code;
                            item.field_ch_name = "銀行代碼";
                            list.Add(item);
                        }
                    }
                    else
                    {
                        venQuery.bank_code = oldven.bank_code;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["bank_name"].ToString()))
                    {
                        venQuery.bank_name = Request.Params["bank_name"].ToString();
                        if (oldven.bank_name != venQuery.bank_name)
                        {
                            //update_log.AppendFormat("bank_name:{0}:{1}:銀行名稱#", oldven.bank_name, venQuery.bank_name);
                            TableChangeLog item = new TableChangeLog();
                            item.change_field = "bank_name";
                            item.old_value = oldven.bank_name;
                            item.new_value = venQuery.bank_name;
                            item.field_ch_name = "銀行名稱";
                            list.Add(item);
                        }
                    }
                    else
                    {
                        venQuery.bank_name = oldven.bank_name;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["bank_number"].ToString()))
                    {
                        venQuery.bank_number = Request.Params["bank_number"].ToString();
                        if (oldven.bank_number != venQuery.bank_number)
                        {
                            // update_log.AppendFormat("bank_number:{0}:{1}:銀行賬號#", oldven.bank_number, venQuery.bank_number);
                            TableChangeLog item = new TableChangeLog();
                            item.change_field = "bank_number";
                            item.old_value = oldven.bank_number;
                            item.new_value = venQuery.bank_number;
                            item.field_ch_name = "銀行賬號";
                            list.Add(item);
                        }
                    }
                    else
                    {
                        venQuery.bank_number = oldven.bank_number;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["bank_account"].ToString()))
                    {
                        venQuery.bank_account = Request.Params["bank_account"].ToString();
                        if (oldven.bank_account != venQuery.bank_account)
                        {
                            //update_log.AppendFormat("bank_account:{0}:{1}:銀行戶名#", oldven.bank_account, venQuery.bank_account);
                            TableChangeLog item = new TableChangeLog();
                            item.change_field = "bank_account";
                            item.old_value = oldven.bank_account;
                            item.new_value = venQuery.bank_account;
                            item.field_ch_name = "銀行戶名";
                            list.Add(item);
                        }
                    }
                    else
                    {
                        venQuery.bank_account = oldven.bank_account;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["bank_number"].ToString()))
                    {
                        venQuery.bank_number = Request.Params["bank_number"].ToString();
                    }
                    else
                    {
                        venQuery.bank_number = oldven.bank_number;
                    }

                    if (uint.TryParse(Request.Params["freight_low_limit"].ToString(), out isUint))
                    {
                        venQuery.freight_low_limit = Convert.ToUInt32(Request.Params["freight_low_limit"].ToString());
                    }
                    else
                    {
                        venQuery.freight_low_limit = 0;
                    }
                    if (uint.TryParse(Request.Params["freight_low_money"].ToString(), out isUint))
                    {
                        venQuery.freight_low_money = Convert.ToUInt32(Request.Params["freight_low_money"].ToString());
                    }
                    else
                    {
                        venQuery.freight_low_money = 0;
                    }
                    if (uint.TryParse(Request.Params["freight_return_low_money"].ToString(), out isUint))
                    {
                        venQuery.freight_return_low_money = Convert.ToUInt32(Request.Params["freight_return_low_money"].ToString());
                    }
                    else
                    {
                        venQuery.freight_return_low_money = 0;
                    }
                    if (uint.TryParse(Request.Params["freight_normal_limit"].ToString(), out isUint))
                    {
                        venQuery.freight_normal_limit = Convert.ToUInt32(Request.Params["freight_normal_limit"].ToString());
                    }
                    else
                    {
                        venQuery.freight_normal_limit = 0;
                    }
                    if (uint.TryParse(Request.Params["freight_normal_money"].ToString(), out isUint))
                    {
                        venQuery.freight_normal_money = Convert.ToUInt32(Request.Params["freight_normal_money"].ToString());
                    }
                    else
                    {
                        venQuery.freight_normal_money = 0;
                    }
                    if (uint.TryParse(Request.Params["freight_return_normal_money"].ToString(), out isUint))
                    {
                        venQuery.freight_return_normal_money = Convert.ToUInt32(Request.Params["freight_return_normal_money"].ToString());
                    }
                    else
                    {
                        venQuery.freight_return_normal_money = 0;
                    }
                    if (uint.TryParse(Request.Params["assist"].ToString(), out isUint))
                    {
                        venQuery.assist = Convert.ToUInt32(Request.Params["assist"].ToString());
                    }
                    else
                    {
                        venQuery.assist = venQuery.assist;
                    }
                    //if (uint.TryParse(Request.Params["dispatch"].ToString(), out isUint))
                    //{
                    //    venQuery.dispatch = Convert.ToUInt32(Request.Params["dispatch"].ToString());
                    //}
                    //else
                    //{
                    //    venQuery.dispatch = 0;
                    //}
                    //if (uint.TryParse(Request.Params["product_mode"].ToString(), out isUint))
                    //{
                    //    venQuery.product_mode = Convert.ToUInt32(Request.Params["product_mode"].ToString());
                    //}
                    //else
                    //{
                    //    venQuery.product_mode = 0;
                    //}
                    //try
                    //{
                    //    //Regex email = new System.Text.RegularExpressions.Regex("(([a-z0-9]{1})([\\.a-z0-9_-]*)@([a-z0-9]+)(\\.([a-z0-9]+)){1,3})");
                    //    //Regex name = new System.Text.RegularExpressions.Regex("[\u4e00-\u9fa5]");
                    //    //if (email.IsMatch(Request.Params["pm"].ToString()))
                    //    //{
                    //    //    venQuery.product_manage = _configMgr.QueryByEmail(Request.Params["pm"].ToString());
                    //    //}
                    //    //else if (name.IsMatch(Request.Params["pm"].ToString()))
                    //    //{
                    //    //    venQuery.product_manage = _configMgr.QueryByName(Request.Params["pm"].ToString());
                    //    //}
                    //}
                    //catch (Exception ex)
                    //{
                    //    Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                    //    logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                    //    logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                    //    log.Error(logMessage);
                    //    venQuery.product_manage = 0;
                    //}
                    if (!string.IsNullOrEmpty(Request.Params["procurement_days"].ToString()))
                    {
                        venQuery.procurement_days = Convert.ToInt32(Request.Params["procurement_days"].ToString());
                    }
                    else
                    {
                        venQuery.procurement_days = 0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["self_send_days"].ToString()))
                    {
                        venQuery.self_send_days = Convert.ToInt32(Request.Params["self_send_days"].ToString());
                        if (oldven.self_send_days != venQuery.self_send_days)
                        {
                            //update_log.AppendFormat("self_send_days:{0}:{1}:自出出貨天數#", oldven.self_send_days, venQuery.self_send_days);
                            TableChangeLog item = new TableChangeLog();
                            item.change_field = "self_send_days";
                            item.old_value = oldven.self_send_days.ToString();
                            item.new_value = venQuery.self_send_days.ToString();
                            item.field_ch_name = "自出出貨天數";
                            list.Add(item);
                        }
                    }
                    else
                    {
                        venQuery.self_send_days = 0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["stuff_ware_days"].ToString()))
                    {
                        venQuery.stuff_ware_days = Convert.ToInt32(Request.Params["stuff_ware_days"].ToString());
                        if (oldven.stuff_ware_days != venQuery.stuff_ware_days)
                        {
                            // update_log.AppendFormat("stuff_ware_days:{0}:{1}:寄倉出貨天數#", oldven.stuff_ware_days, venQuery.stuff_ware_days);
                            TableChangeLog item = new TableChangeLog();
                            item.change_field = "stuff_ware_days";
                            item.old_value = oldven.stuff_ware_days.ToString();
                            item.new_value = venQuery.stuff_ware_days.ToString();
                            item.field_ch_name = "寄倉出貨天數";
                            list.Add(item);
                        }
                    }
                    else
                    {
                        venQuery.stuff_ware_days = 0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["dispatch_days"].ToString()))
                    {
                        venQuery.dispatch_days = Convert.ToInt32(Request.Params["dispatch_days"].ToString());
                        if (oldven.dispatch_days != venQuery.dispatch_days)
                        {
                            // update_log.AppendFormat("dispatch_days:{0}:{1}:調度出貨天數#", oldven.dispatch_days, venQuery.dispatch_days);
                            TableChangeLog item = new TableChangeLog();
                            item.change_field = "dispatch_days";
                            item.old_value = oldven.dispatch_days.ToString();
                            item.new_value = venQuery.dispatch_days.ToString();
                            item.field_ch_name = "調度出貨天數";
                            list.Add(item);
                        }
                    }
                    else
                    {
                        venQuery.dispatch_days = 0;
                    }
                    if (Request.Params["pm"].ToString() == "")
                    {
                        venQuery.product_manage = 0;
                    }
                    else
                    {
                        if (uint.TryParse(Request.Params["pm"].ToString(), out isUint))
                        {
                            venQuery.product_manage = Convert.ToUInt32(Request.Params["pm"].ToString());
                        }
                        else
                        {
                            venQuery.product_manage = oldven.product_manage;
                        }
                    }
                    if (oldven.product_manage != venQuery.product_manage)
                    {
                        // update_log.AppendFormat("product_manage:{0}:{1}:管理人員#", oldven.product_manage, venQuery.product_manage);
                        TableChangeLog item = new TableChangeLog();
                        item.change_field = "product_manage";
                        item.old_value = oldven.product_manage.ToString();
                        item.new_value = venQuery.product_manage.ToString();
                        item.field_ch_name = "管理人員";
                        list.Add(item);
                    }
                    if (uint.TryParse(Request.Params["gigade_bunus_percent"].ToString(), out isUint))
                    {
                        venQuery.gigade_bunus_percent = Convert.ToUInt32(Request.Params["gigade_bunus_percent"].ToString());
                    }
                    else
                    {
                        venQuery.gigade_bunus_percent = 0;
                    }
                    if (uint.TryParse(Request.Params["gigade_bunus_threshold"].ToString(), out isUint))
                    {
                        venQuery.gigade_bunus_threshold = Convert.ToUInt32(Request.Params["gigade_bunus_threshold"].ToString());
                    }
                    else
                    {
                        venQuery.gigade_bunus_threshold = 0;
                    }
                    venQuery.vendor_note = Request.Params["vendor_note"].ToString();
                    #endregion

                    #region 對聯絡人的 信息處理
                    string delcon = string.Empty;

                    if (!string.IsNullOrEmpty(Request.Params["delconnect"].ToString()))
                    {
                        delcon = Request.Params["delconnect"].ToString().TrimEnd(',');
                        var delArr = delcon.Split(',');
                        int re_1 = 0, re_2 = 0, re_3 = 0;
                        if (delArr.Length == 4)
                        {
                            //update_log.AppendFormat("contact_type_2:{0}:{1}:原第二聯絡人類型#", oldven.contact_type_2, 7);                           
                            //update_log.AppendFormat("contact_name_2:{0}:{1}:原第二聯絡人姓名#", oldven.contact_name_2, "刪除");                          
                            //update_log.AppendFormat("contact_phone_1_2:{0}:{1}:原第二聯絡人電話一#", oldven.contact_phone_1_2, "刪除");
                            //update_log.AppendFormat("contact_phone_2_2:{0}:{1}:原第二聯絡人電話二#", oldven.contact_phone_2_2, "刪除");
                            //update_log.AppendFormat("contact_mobile_2:{0}:{1}:原第二聯絡人手機號碼#", oldven.contact_mobile_2, "刪除");
                            //update_log.AppendFormat("contact_email_2:{0}:{1}:原第二聯絡人郵箱#", oldven.contact_email_2, "刪除");
                            //update_log.AppendFormat("contact_type_3:{0}:{1}:原第三聯絡人類型#", oldven.contact_type_3, 7);
                            //update_log.AppendFormat("contact_name_3:{0}:{1}:原第三聯絡人姓名#", oldven.contact_name_3, "刪除");
                            //update_log.AppendFormat("contact_phone_1_3:{0}:{1}:原第三聯絡人電話一#", oldven.contact_phone_1_3, "刪除");
                            //update_log.AppendFormat("contact_phone_2_3:{0}:{1}:原第三聯絡人電話二#", oldven.contact_phone_2_3, "刪除");
                            //update_log.AppendFormat("contact_mobile_3:{0}:{1}:原第三聯絡人手機號碼#", oldven.contact_mobile_3, "刪除");
                            //update_log.AppendFormat("contact_email_3:{0}:{1}:原第三聯絡人郵箱#", oldven.contact_email_3, "刪除");
                            //update_log.AppendFormat("contact_type_4:{0}:{1}:原第四聯絡人類型#", oldven.contact_type_4, 7);
                            //update_log.AppendFormat("contact_name_4:{0}:{1}:原第四聯絡人姓名#", oldven.contact_name_4, "刪除");
                            //update_log.AppendFormat("contact_phone_1_4:{0}:{1}:原第四聯絡人電話一#", oldven.contact_phone_1_4, "刪除");
                            //update_log.AppendFormat("contact_phone_2_4:{0}:{1}:原第四聯絡人電話二#", oldven.contact_phone_2_4, "刪除");
                            //update_log.AppendFormat("contact_mobile_4:{0}:{1}:原第四聯絡人手機號碼#", oldven.contact_mobile_4, "刪除");
                            //update_log.AppendFormat("contact_email_4:{0}:{1}:原第四聯絡人郵箱#", oldven.contact_email_4, "刪除");
                            //update_log.AppendFormat("contact_type_5:{0}:{1}:第五聯絡人類型#", oldven.contact_type_5, 7);
                            //update_log.AppendFormat("contact_name_5:{0}:{1}:第五聯絡人姓名#", oldven.contact_name_5, "刪除");
                            //update_log.AppendFormat("contact_phone_1_5:{0}:{1}:第五聯絡人電話一#", oldven.contact_phone_1_5, "刪除");
                            //update_log.AppendFormat("contact_phone_2_5:{0}:{1}:第五聯絡人電話二#", oldven.contact_phone_2_5, "刪除");
                            //update_log.AppendFormat("contact_mobile_5:{0}:{1}:第五聯絡人手機號碼#", oldven.contact_mobile_5, "刪除");
                            //update_log.AppendFormat("contact_email_5:{0}:{1}:第五聯絡人郵箱#", oldven.contact_email_5, "刪除");

                            list.Add(new TableChangeLog() { change_field = "contact_type_2", old_value = oldven.contact_type_2.ToString(), new_value = "7", field_ch_name = "原第二聯絡人類型" });
                            list.Add(new TableChangeLog() { change_field = "contact_name_2", old_value = oldven.contact_name_2, new_value = "刪除", field_ch_name = "原第二聯絡人姓名" });
                            list.Add(new TableChangeLog() { change_field = "contact_phone_1_2", old_value = oldven.contact_phone_1_2, new_value = "刪除", field_ch_name = "原第二聯絡人電話一" });
                            list.Add(new TableChangeLog() { change_field = "contact_phone_2_2", old_value = oldven.contact_phone_2_2, new_value = "刪除", field_ch_name = "原第二聯絡人電話二" });
                            list.Add(new TableChangeLog() { change_field = "contact_mobile_2", old_value = oldven.contact_mobile_2, new_value = "刪除", field_ch_name = "原第二聯絡人手機號碼" });
                            list.Add(new TableChangeLog() { change_field = "contact_email_2", old_value = oldven.contact_email_2, new_value = "刪除", field_ch_name = "原第二聯絡人郵箱" });
                            list.Add(new TableChangeLog() { change_field = "contact_type_3", old_value = oldven.contact_type_3.ToString(), new_value = "7", field_ch_name = "原第三聯絡人類型" });
                            list.Add(new TableChangeLog() { change_field = "contact_name_3", old_value = oldven.contact_name_3, new_value = "刪除", field_ch_name = "原第三聯絡人姓名" });
                            list.Add(new TableChangeLog() { change_field = "contact_phone_1_3", old_value = oldven.contact_phone_1_3, new_value = "刪除", field_ch_name = "原第三聯絡人電話一" });
                            list.Add(new TableChangeLog() { change_field = "contact_phone_2_3", old_value = oldven.contact_phone_2_3, new_value = "刪除", field_ch_name = "原第三聯絡人電話二" });
                            list.Add(new TableChangeLog() { change_field = "contact_mobile_3", old_value = oldven.contact_mobile_3, new_value = "刪除", field_ch_name = "原第三聯絡人手機號碼" });
                            list.Add(new TableChangeLog() { change_field = "contact_email_3", old_value = oldven.contact_email_3, new_value = "刪除", field_ch_name = "原第三聯絡人郵箱" });
                            list.Add(new TableChangeLog() { change_field = "contact_type_4", old_value = oldven.contact_type_4.ToString(), new_value = "7", field_ch_name = "原第四聯絡人類型" });
                            list.Add(new TableChangeLog() { change_field = "contact_name_4", old_value = oldven.contact_name_4, new_value = "刪除", field_ch_name = "原第四聯絡人姓名" });
                            list.Add(new TableChangeLog() { change_field = "contact_phone_1_4", old_value = oldven.contact_phone_1_4, new_value = "刪除", field_ch_name = "原第四聯絡人電話一" });
                            list.Add(new TableChangeLog() { change_field = "contact_phone_2_4", old_value = oldven.contact_phone_2_4, new_value = "刪除", field_ch_name = "原第四聯絡人電話二" });
                            list.Add(new TableChangeLog() { change_field = "contact_mobile_4", old_value = oldven.contact_mobile_4, new_value = "刪除", field_ch_name = "原第四聯絡人手機號碼" });
                            list.Add(new TableChangeLog() { change_field = "contact_email_4", old_value = oldven.contact_email_4, new_value = "刪除", field_ch_name = "原第四聯絡人郵箱" });
                            list.Add(new TableChangeLog() { change_field = "contact_type_5", old_value = oldven.contact_type_5.ToString(), new_value = "7", field_ch_name = "第五聯絡人類型" });
                            list.Add(new TableChangeLog() { change_field = "contact_name_5", old_value = oldven.contact_name_5, new_value = "刪除", field_ch_name = "第五聯絡人姓名" });
                            list.Add(new TableChangeLog() { change_field = "contact_phone_1_5", old_value = oldven.contact_phone_1_5, new_value = "刪除", field_ch_name = "第五聯絡人電話一" });
                            list.Add(new TableChangeLog() { change_field = "contact_phone_2_5", old_value = oldven.contact_phone_2_5, new_value = "刪除", field_ch_name = "第五聯絡人電話二" });
                            list.Add(new TableChangeLog() { change_field = "contact_mobile_5", old_value = oldven.contact_mobile_5, new_value = "刪除", field_ch_name = "第五聯絡人手機號碼" });
                            list.Add(new TableChangeLog() { change_field = "contact_email_5", old_value = oldven.contact_email_5, new_value = "刪除", field_ch_name = "第五聯絡人郵箱" });
                        }
                        else
                        {
                            for (int i = 0; i < delArr.Length; i++)
                            {
                                int del = Convert.ToInt32(delArr[i]);

                                if (del == 1 && re_1 == 0 && oldven.contact_type_2 != 0)
                                {
                                    re_1++;
                                    //update_log.AppendFormat("contact_type_2:{0}:{1}:原第二聯絡人類型#", oldven.contact_type_2, 7);
                                    //update_log.AppendFormat("contact_name_2:{0}:{1}:原第二聯絡人姓名#", oldven.contact_name_2, "刪除");
                                    //update_log.AppendFormat("contact_phone_1_2:{0}:{1}:原第二聯絡人電話一#", oldven.contact_phone_1_2, "刪除");
                                    //update_log.AppendFormat("contact_phone_2_2:{0}:{1}:原第二聯絡人電話二#", oldven.contact_phone_2_2, "刪除");
                                    //update_log.AppendFormat("contact_mobile_2:{0}:{1}:原第二聯絡人手機號碼#", oldven.contact_mobile_2, "刪除");
                                    //update_log.AppendFormat("contact_email_2:{0}:{1}:原第二聯絡人郵箱#", oldven.contact_email_2, "刪除");

                                    list.Add(new TableChangeLog() { change_field = "contact_type_2", old_value = oldven.contact_type_2.ToString(), new_value = "7", field_ch_name = "原第二聯絡人類型" });
                                    list.Add(new TableChangeLog() { change_field = "contact_name_2", old_value = oldven.contact_name_2, new_value = "刪除", field_ch_name = "原第二聯絡人姓名" });
                                    list.Add(new TableChangeLog() { change_field = "contact_phone_1_2", old_value = oldven.contact_phone_1_2, new_value = "刪除", field_ch_name = "原第二聯絡人電話一" });
                                    list.Add(new TableChangeLog() { change_field = "contact_phone_2_2", old_value = oldven.contact_phone_2_2, new_value = "刪除", field_ch_name = "原第二聯絡人電話二" });
                                    list.Add(new TableChangeLog() { change_field = "contact_mobile_2", old_value = oldven.contact_mobile_2, new_value = "刪除", field_ch_name = "原第二聯絡人手機號碼" });
                                    list.Add(new TableChangeLog() { change_field = "contact_email_2", old_value = oldven.contact_email_2, new_value = "刪除", field_ch_name = "原第二聯絡人郵箱" });

                                }
                                else if (((del == 2 && re_2 == 0) || re_1 == 1) && oldven.contact_type_3 != 0)
                                {
                                    if (re_1 == 1)
                                    {
                                        re_1++;
                                    }
                                    else
                                    {
                                        re_2++;
                                    }
                                    //update_log.AppendFormat("contact_type_3:{0}:{1}:原第三聯絡人類型#", oldven.contact_type_3, 7);
                                    //update_log.AppendFormat("contact_name_3:{0}:{1}:原第三聯絡人姓名#", oldven.contact_name_3, "刪除");
                                    //update_log.AppendFormat("contact_phone_1_3:{0}:{1}:原第三聯絡人電話一#", oldven.contact_phone_1_3, "刪除");
                                    //update_log.AppendFormat("contact_phone_2_3:{0}:{1}:原第三聯絡人電話二#", oldven.contact_phone_2_3, "刪除");
                                    //update_log.AppendFormat("contact_mobile_3:{0}:{1}:原第三聯絡人手機號碼#", oldven.contact_mobile_3, "刪除");
                                    //update_log.AppendFormat("contact_email_3:{0}:{1}:原第三聯絡人郵箱#", oldven.contact_email_3, "刪除");
                                    list.Add(new TableChangeLog() { change_field = "contact_type_3", old_value = oldven.contact_type_3.ToString(), new_value = "7", field_ch_name = "原第三聯絡人類型" });
                                    list.Add(new TableChangeLog() { change_field = "contact_name_3", old_value = oldven.contact_name_3, new_value = "刪除", field_ch_name = "原第三聯絡人姓名" });
                                    list.Add(new TableChangeLog() { change_field = "contact_phone_1_3", old_value = oldven.contact_phone_1_3, new_value = "刪除", field_ch_name = "原第三聯絡人電話一" });
                                    list.Add(new TableChangeLog() { change_field = "contact_phone_2_3", old_value = oldven.contact_phone_2_3, new_value = "刪除", field_ch_name = "原第三聯絡人電話二" });
                                    list.Add(new TableChangeLog() { change_field = "contact_mobile_3", old_value = oldven.contact_mobile_3, new_value = "刪除", field_ch_name = "原第三聯絡人手機號碼" });
                                    list.Add(new TableChangeLog() { change_field = "contact_email_3", old_value = oldven.contact_email_3, new_value = "刪除", field_ch_name = "原第三聯絡人郵箱" });
                                }
                                else if (((del == 3 && re_3 == 0) || re_1 == 2 || re_2 == 1) && oldven.contact_type_4 != 0)
                                {
                                    if (re_1 == 2)
                                    {
                                        re_1++;
                                    }
                                    else if (re_2 == 1)
                                    {
                                        re_2++;
                                    }
                                    else
                                    {
                                        re_3++;
                                    }
                                    //update_log.AppendFormat("contact_type_4:{0}:{1}:原第四聯絡人類型#", oldven.contact_type_4, 7);
                                    //update_log.AppendFormat("contact_name_4:{0}:{1}:原第四聯絡人姓名#", oldven.contact_name_4, "刪除");
                                    //update_log.AppendFormat("contact_phone_1_4:{0}:{1}:原第四聯絡人電話一#", oldven.contact_phone_1_4, "刪除");
                                    //update_log.AppendFormat("contact_phone_2_4:{0}:{1}:原第四聯絡人電話二#", oldven.contact_phone_2_4, "刪除");
                                    //update_log.AppendFormat("contact_mobile_4:{0}:{1}:原第四聯絡人手機號碼#", oldven.contact_mobile_4, "刪除");
                                    //update_log.AppendFormat("contact_email_4:{0}:{1}:原第四聯絡人郵箱#", oldven.contact_email_4, "刪除");
                                    list.Add(new TableChangeLog() { change_field = "contact_type_4", old_value = oldven.contact_type_4.ToString(), new_value = "7", field_ch_name = "原第四聯絡人類型" });
                                    list.Add(new TableChangeLog() { change_field = "contact_name_4", old_value = oldven.contact_name_4, new_value = "刪除", field_ch_name = "原第四聯絡人姓名" });
                                    list.Add(new TableChangeLog() { change_field = "contact_phone_1_4", old_value = oldven.contact_phone_1_4, new_value = "刪除", field_ch_name = "原第四聯絡人電話一" });
                                    list.Add(new TableChangeLog() { change_field = "contact_phone_2_4", old_value = oldven.contact_phone_2_4, new_value = "刪除", field_ch_name = "原第四聯絡人電話二" });
                                    list.Add(new TableChangeLog() { change_field = "contact_mobile_4", old_value = oldven.contact_mobile_4, new_value = "刪除", field_ch_name = "原第四聯絡人手機號碼" });
                                    list.Add(new TableChangeLog() { change_field = "contact_email_4", old_value = oldven.contact_email_4, new_value = "刪除", field_ch_name = "原第四聯絡人郵箱" });
                                }
                                else if ((del == 4 || re_1 == 3 || re_2 == 2 || re_3 == 1) && oldven.contact_type_5 != 0)
                                {


                                    //update_log.AppendFormat("contact_type_5:{0}:{1}:第五聯絡人類型#", oldven.contact_type_5, 7);
                                    //update_log.AppendFormat("contact_name_5:{0}:{1}:第五聯絡人姓名#", oldven.contact_name_5, "刪除");
                                    //update_log.AppendFormat("contact_phone_1_5:{0}:{1}:第五聯絡人電話一#", oldven.contact_phone_1_5, "刪除");
                                    //update_log.AppendFormat("contact_phone_2_5:{0}:{1}:第五聯絡人電話二#", oldven.contact_phone_2_5, "刪除");
                                    //update_log.AppendFormat("contact_mobile_5:{0}:{1}:第五聯絡人手機號碼#", oldven.contact_mobile_5, "刪除");
                                    //update_log.AppendFormat("contact_email_5:{0}:{1}:第五聯絡人郵箱#", oldven.contact_email_5, "刪除");
                                    list.Add(new TableChangeLog() { change_field = "contact_type_5", old_value = oldven.contact_type_5.ToString(), new_value = "7", field_ch_name = "第五聯絡人類型" });
                                    list.Add(new TableChangeLog() { change_field = "contact_name_5", old_value = oldven.contact_name_5, new_value = "刪除", field_ch_name = "第五聯絡人姓名" });
                                    list.Add(new TableChangeLog() { change_field = "contact_phone_1_5", old_value = oldven.contact_phone_1_5, new_value = "刪除", field_ch_name = "第五聯絡人電話一" });
                                    list.Add(new TableChangeLog() { change_field = "contact_phone_2_5", old_value = oldven.contact_phone_2_5, new_value = "刪除", field_ch_name = "第五聯絡人電話二" });
                                    list.Add(new TableChangeLog() { change_field = "contact_mobile_5", old_value = oldven.contact_mobile_5, new_value = "刪除", field_ch_name = "第五聯絡人手機號碼" });
                                    list.Add(new TableChangeLog() { change_field = "contact_email_5", old_value = oldven.contact_email_5, new_value = "刪除", field_ch_name = "第五聯絡人郵箱" });
                                }
                            }
                        }
                    }


                    string[] contactarr = null;
                    if (!string.IsNullOrEmpty(Request.Params["conactValues"].ToString()))
                    {

                        string contact = Request.Params["conactValues"].ToString();
                        contactarr = contact.Split('|');
                    }
                    for (int i = 0; i < 5; i++)
                    {
                        string[] contact1 = null;
                        if (contactarr != null && contactarr.Length > i + 1)
                        {
                            contact1 = contactarr[i].Split(',');
                        }
                        if (i == 0)
                        {
                            if (contact1 != null)
                            {
                                venQuery.contact_type_1 = 4;
                                venQuery.contact_name_1 = contact1[1];
                                venQuery.contact_phone_1_1 = contact1[2];
                                venQuery.contact_phone_2_1 = contact1[3];
                                venQuery.contact_mobile_1 = contact1[4];
                                venQuery.contact_email_1 = contact1[5].ToLower();

                                if (oldven.contact_type_1 != venQuery.contact_type_1)
                                {
                                    // update_log.AppendFormat("contact_type_1:{0}:{1}:第一聯絡人類型#", oldven.contact_type_1, venQuery.contact_type_1);
                                    list.Add(new TableChangeLog() { change_field = "contact_type_1", old_value = oldven.contact_type_1.ToString(), new_value = venQuery.contact_type_1.ToString(), field_ch_name = "第一聯絡人類型" });
                                }
                                if (oldven.contact_name_1 != venQuery.contact_name_1)
                                {
                                    // update_log.AppendFormat("contact_name_1:{0}:{1}:第一聯絡人姓名#", oldven.contact_name_1, venQuery.contact_name_1);
                                    list.Add(new TableChangeLog() { change_field = "contact_name_1", old_value = oldven.contact_name_1, new_value = venQuery.contact_name_1, field_ch_name = "第一聯絡人姓名" });
                                }
                                if (oldven.contact_phone_1_1 != venQuery.contact_phone_1_1)
                                {
                                    //update_log.AppendFormat("contact_phone_1_1:{0}:{1}:第一聯絡人電話一#", oldven.contact_phone_1_1, venQuery.contact_phone_1_1);
                                    list.Add(new TableChangeLog() { change_field = "contact_phone_1_1", old_value = oldven.contact_phone_1_1, new_value = venQuery.contact_phone_1_1, field_ch_name = "第一聯絡人電話一" });
                                }
                                if (oldven.contact_phone_2_1 != venQuery.contact_phone_2_1)
                                {
                                    // update_log.AppendFormat("contact_phone_2_1:{0}:{1}:第一聯絡人電話二#", oldven.contact_phone_2_1, venQuery.contact_phone_2_1);
                                    list.Add(new TableChangeLog() { change_field = "contact_phone_2_1", old_value = oldven.contact_phone_2_1, new_value = venQuery.contact_phone_2_1, field_ch_name = "第一聯絡人電話二" });
                                }
                                if (oldven.contact_mobile_1 != venQuery.contact_mobile_1)
                                {
                                    // update_log.AppendFormat("contact_mobile_1:{0}:{1}:第一聯絡人手機號碼#", oldven.contact_mobile_1, venQuery.contact_mobile_1);
                                    list.Add(new TableChangeLog() { change_field = "contact_mobile_1", old_value = oldven.contact_mobile_1, new_value = venQuery.contact_mobile_1, field_ch_name = "第一聯絡人手機號碼" });
                                }
                                if (oldven.contact_email_1 != venQuery.contact_email_1)
                                {
                                    //update_log.AppendFormat("contact_email_1:{0}:{1}:第一聯絡人郵箱#", oldven.contact_email_1, venQuery.contact_email_1);
                                    list.Add(new TableChangeLog() { change_field = "contact_email_1", old_value = oldven.contact_email_1, new_value = venQuery.contact_email_1, field_ch_name = "第一聯絡人郵箱" });
                                }

                            }
                        }
                        else if (i == 1)
                        {


                            if (contact1 != null)
                            {
                                venQuery.contact_type_2 = Convert.ToUInt32(ContactType(contact1[0].ToString()));
                                venQuery.contact_name_2 = contact1[1];
                                venQuery.contact_phone_1_2 = contact1[2];
                                venQuery.contact_phone_2_2 = contact1[3];
                                venQuery.contact_mobile_2 = contact1[4];
                                venQuery.contact_email_2 = contact1[5].ToLower().ToLower();

                                if (oldven.contact_type_2 != venQuery.contact_type_2)
                                {
                                    // update_log.AppendFormat("contact_type_2:{0}:{1}:第二聯絡人類型#", oldven.contact_type_2, venQuery.contact_type_2);
                                    list.Add(new TableChangeLog() { change_field = "contact_type_2", old_value = oldven.contact_type_2.ToString(), new_value = venQuery.contact_type_2.ToString(), field_ch_name = "第二聯絡人類型" });
                                }
                                if (oldven.contact_name_2 != venQuery.contact_name_2)
                                {
                                    //update_log.AppendFormat("contact_name_2:{0}:{1}:第二聯絡人姓名#", oldven.contact_name_2, venQuery.contact_name_2);
                                    list.Add(new TableChangeLog() { change_field = "contact_name_2", old_value = oldven.contact_name_2, new_value = venQuery.contact_name_2, field_ch_name = "第二聯絡人姓名" });
                                }
                                if (oldven.contact_phone_1_2 != venQuery.contact_phone_1_2)
                                {
                                    //update_log.AppendFormat("contact_phone_1_2:{0}:{1}:第二聯絡人電話一#", oldven.contact_phone_1_2, venQuery.contact_phone_1_2);
                                    list.Add(new TableChangeLog() { change_field = "contact_phone_1_2", old_value = oldven.contact_phone_1_2, new_value = venQuery.contact_phone_1_2, field_ch_name = "第二聯絡人電話一" });
                                }
                                if (oldven.contact_phone_2_2 != venQuery.contact_phone_2_2)
                                {
                                    //update_log.AppendFormat("contact_phone_2_2:{0}:{1}:第二聯絡人電話二#", oldven.contact_phone_2_2, venQuery.contact_phone_2_2);
                                    list.Add(new TableChangeLog() { change_field = "contact_phone_2_2", old_value = oldven.contact_phone_2_2, new_value = venQuery.contact_phone_2_2, field_ch_name = "第二聯絡人電話二" });
                                }
                                if (oldven.contact_mobile_2 != venQuery.contact_mobile_2)
                                {
                                    // update_log.AppendFormat("contact_mobile_2:{0}:{1}:第二聯絡人手機號碼#", oldven.contact_mobile_2, venQuery.contact_mobile_2);
                                    list.Add(new TableChangeLog() { change_field = "contact_mobile_2", old_value = oldven.contact_mobile_2, new_value = venQuery.contact_mobile_2, field_ch_name = "第二聯絡人手機號碼" });
                                }
                                if (oldven.contact_email_2 != venQuery.contact_email_2)
                                {
                                    // update_log.AppendFormat("contact_email_2:{0}:{1}:第二聯絡人郵箱#", oldven.contact_email_2, venQuery.contact_email_2);
                                    list.Add(new TableChangeLog() { change_field = "contact_email_2", old_value = oldven.contact_email_2, new_value = venQuery.contact_email_2, field_ch_name = "第二聯絡人郵箱" });
                                }
                            }
                        }
                        else if (i == 2)
                        {


                            if (contact1 != null)
                            {
                                venQuery.contact_type_3 = Convert.ToUInt32(ContactType(contact1[0].ToString()));
                                venQuery.contact_name_3 = contact1[1];
                                venQuery.contact_phone_1_3 = contact1[2];
                                venQuery.contact_phone_2_3 = contact1[3];
                                venQuery.contact_mobile_3 = contact1[4];
                                venQuery.contact_email_3 = contact1[5].ToLower();
                                if (oldven.contact_type_3 != venQuery.contact_type_3)
                                {
                                    //update_log.AppendFormat("contact_type_3:{0}:{1}:第三聯絡人類型#", oldven.contact_type_3, venQuery.contact_type_3);
                                    list.Add(new TableChangeLog() { change_field = "contact_type_3", old_value = oldven.contact_type_3.ToString(), new_value = venQuery.contact_type_3.ToString(), field_ch_name = "第三聯絡人類型" });
                                }
                                if (oldven.contact_name_3 != venQuery.contact_name_3)
                                {
                                    //update_log.AppendFormat("contact_name_3:{0}:{1}:第三聯絡人姓名#", oldven.contact_name_3, venQuery.contact_name_3);
                                    list.Add(new TableChangeLog() { change_field = "contact_name_3", old_value = oldven.contact_name_3, new_value = venQuery.contact_name_3, field_ch_name = "第三聯絡人姓名" });
                                }
                                if (oldven.contact_phone_1_3 != venQuery.contact_phone_1_3)
                                {
                                    // update_log.AppendFormat("contact_phone_1_3:{0}:{1}:第三聯絡人電話一#", oldven.contact_phone_1_3, venQuery.contact_phone_1_3);
                                    list.Add(new TableChangeLog() { change_field = "contact_phone_1_3", old_value = oldven.contact_phone_1_3, new_value = venQuery.contact_phone_1_3, field_ch_name = "第三聯絡人電話一" });
                                }
                                if (oldven.contact_phone_2_3 != venQuery.contact_phone_2_3)
                                {
                                    // update_log.AppendFormat("contact_phone_2_3:{0}:{1}:第三聯絡人電話二#", oldven.contact_phone_2_3, venQuery.contact_phone_2_3);
                                    list.Add(new TableChangeLog() { change_field = "contact_phone_2_3", old_value = oldven.contact_phone_2_3, new_value = venQuery.contact_phone_2_3, field_ch_name = "第三聯絡人電話二" });
                                }
                                if (oldven.contact_mobile_3 != venQuery.contact_mobile_3)
                                {
                                    //  update_log.AppendFormat("contact_mobile_3:{0}:{1}:第三聯絡人手機號碼#", oldven.contact_mobile_3, venQuery.contact_mobile_3);
                                    list.Add(new TableChangeLog() { change_field = "contact_mobile_3", old_value = oldven.contact_mobile_3, new_value = venQuery.contact_mobile_3, field_ch_name = "第三聯絡人手機號碼" });
                                }
                                if (oldven.contact_email_3 != venQuery.contact_email_3)
                                {
                                    // update_log.AppendFormat("contact_email_3:{0}:{1}:第三聯絡人郵箱#", oldven.contact_email_3, venQuery.contact_email_3);
                                    list.Add(new TableChangeLog() { change_field = "contact_email_3", old_value = oldven.contact_email_3, new_value = venQuery.contact_email_3, field_ch_name = "第三聯絡人郵箱" });
                                }
                            }
                        }
                        else if (i == 3)
                        {


                            if (contact1 != null)
                            {
                                venQuery.contact_type_4 = Convert.ToUInt32(ContactType(contact1[0].ToString()));
                                venQuery.contact_name_4 = contact1[1];
                                venQuery.contact_phone_1_4 = contact1[2];
                                venQuery.contact_phone_2_4 = contact1[3];
                                venQuery.contact_mobile_4 = contact1[4];
                                venQuery.contact_email_4 = contact1[5].ToLower();
                                if (oldven.contact_type_4 != venQuery.contact_type_4)
                                {
                                    //update_log.AppendFormat("contact_type_4:{0}:{1}:第四聯絡人類型#", oldven.contact_type_4, venQuery.contact_type_4);
                                    list.Add(new TableChangeLog() { change_field = "contact_type_4", old_value = oldven.contact_type_4.ToString(), new_value = venQuery.contact_type_4.ToString(), field_ch_name = "原第四聯絡人類型" });
                                }
                                if (oldven.contact_name_4 != venQuery.contact_name_4)
                                {
                                    // update_log.AppendFormat("contact_name_4:{0}:{1}:第四聯絡人姓名#", oldven.contact_name_4, venQuery.contact_name_4);
                                    list.Add(new TableChangeLog() { change_field = "contact_name_4", old_value = oldven.contact_name_4, new_value = venQuery.contact_name_4, field_ch_name = "第四聯絡人姓名" });
                                }
                                if (oldven.contact_phone_1_4 != venQuery.contact_phone_1_4)
                                {
                                    //update_log.AppendFormat("contact_phone_1_4:{0}:{1}:第四聯絡人電話一#", oldven.contact_phone_1_4, venQuery.contact_phone_1_4);
                                    list.Add(new TableChangeLog() { change_field = "contact_phone_1_4", old_value = oldven.contact_phone_1_4, new_value = venQuery.contact_phone_1_4, field_ch_name = "第四聯絡人電話一" });
                                }
                                if (oldven.contact_phone_2_4 != venQuery.contact_phone_2_4)
                                {
                                    // update_log.AppendFormat("contact_phone_2_4:{0}:{1}:第四聯絡人電話二#", oldven.contact_phone_2_4, venQuery.contact_phone_2_4);
                                    list.Add(new TableChangeLog() { change_field = "contact_phone_2_4", old_value = oldven.contact_phone_2_4, new_value = venQuery.contact_phone_2_4, field_ch_name = "第四聯絡人電話二" });
                                }
                                if (oldven.contact_mobile_4 != venQuery.contact_mobile_4)
                                {
                                    // update_log.AppendFormat("contact_mobile_4:{0}:{1}:第四聯絡人手機號碼#", oldven.contact_mobile_4, venQuery.contact_mobile_4);
                                    list.Add(new TableChangeLog() { change_field = "contact_mobile_4", old_value = oldven.contact_mobile_4, new_value = venQuery.contact_mobile_4, field_ch_name = "第四聯絡人手機號碼" });
                                }
                                if (oldven.contact_email_4 != venQuery.contact_email_4)
                                {
                                    // update_log.AppendFormat("contact_email_4:{0}:{1}:第四聯絡人郵箱#", oldven.contact_email_4, venQuery.contact_email_4);
                                    list.Add(new TableChangeLog() { change_field = "contact_email_4", old_value = oldven.contact_email_4, new_value = venQuery.contact_email_4, field_ch_name = "第四聯絡人郵箱" });
                                }
                            }
                        }
                        else if (i == 4)
                        {


                            if (contact1 != null)
                            {
                                venQuery.contact_type_5 = Convert.ToUInt32(ContactType(contact1[0].ToString()));
                                venQuery.contact_name_5 = contact1[1];
                                venQuery.contact_phone_1_5 = contact1[2];
                                venQuery.contact_phone_2_5 = contact1[3];
                                venQuery.contact_mobile_5 = contact1[4];
                                venQuery.contact_email_5 = contact1[5].ToLower();
                                if (oldven.contact_type_5 != venQuery.contact_type_5)
                                {
                                    //update_log.AppendFormat("contact_type_5:{0}:{1}:第五聯絡人類型#", oldven.contact_type_5, venQuery.contact_type_5);
                                    list.Add(new TableChangeLog() { change_field = "contact_type_5", old_value = oldven.contact_type_5.ToString(), new_value = venQuery.contact_type_5.ToString(), field_ch_name = "第五聯絡人類型" });
                                }
                                if (oldven.contact_name_5 != venQuery.contact_name_5)
                                {
                                    // update_log.AppendFormat("contact_name_5:{0}:{1}:第五聯絡人姓名#", oldven.contact_name_5, venQuery.contact_name_5);
                                    list.Add(new TableChangeLog() { change_field = "contact_name_5", old_value = oldven.contact_name_5, new_value = venQuery.contact_name_5, field_ch_name = "第五聯絡人姓名" });
                                }
                                if (oldven.contact_phone_1_5 != venQuery.contact_phone_1_5)
                                {
                                    // update_log.AppendFormat("contact_phone_1_5:{0}:{1}:第五聯絡人電話一#", oldven.contact_phone_1_5, venQuery.contact_phone_1_5);
                                    list.Add(new TableChangeLog() { change_field = "contact_phone_1_5", old_value = oldven.contact_phone_1_5, new_value = venQuery.contact_phone_1_5, field_ch_name = "第五聯絡人電話一" });
                                }
                                if (oldven.contact_phone_2_5 != venQuery.contact_phone_2_5)
                                {
                                    // update_log.AppendFormat("contact_phone_2_5:{0}:{1}:第五聯絡人電話二#", oldven.contact_phone_2_5, venQuery.contact_phone_2_5);
                                    list.Add(new TableChangeLog() { change_field = "contact_phone_2_5", old_value = oldven.contact_phone_2_5, new_value = venQuery.contact_phone_2_5, field_ch_name = "第五聯絡人電話二" });
                                }
                                if (oldven.contact_mobile_5 != venQuery.contact_mobile_5)
                                {
                                    //update_log.AppendFormat("contact_mobile_5:{0}:{1}:第五聯絡人手機號碼#", oldven.contact_mobile_5, venQuery.contact_mobile_5);
                                    list.Add(new TableChangeLog() { change_field = "contact_mobile_5", old_value = oldven.contact_mobile_5, new_value = venQuery.contact_mobile_5, field_ch_name = "第五聯絡人手機號碼" });
                                }
                                if (oldven.contact_email_5 != venQuery.contact_email_5)
                                {
                                    //update_log.AppendFormat("contact_email_5:{0}:{1}:第五聯絡人郵箱#", oldven.contact_email_5, venQuery.contact_email_5);
                                    list.Add(new TableChangeLog() { change_field = "contact_email_5", old_value = oldven.contact_email_5, new_value = venQuery.contact_email_5, field_ch_name = "第五聯絡人郵箱" });
                                }
                            }
                        }
                    }

                    #endregion


                    venQuery.ip = Request.UserHostAddress;
                    venQuery.file_name = "VendorList.chtml";
                    venQuery.created = DateTime.Now;
                    venQuery.kuser_id = Convert.ToUInt32((System.Web.HttpContext.Current.Session["caller"] as Caller).user_id.ToString());
                    venQuery.export_flag = 1;
                    mgr = new CallerMgr(connectionString);
                    Caller caller = new Caller();
                    caller = mgr.GetUserById(Convert.ToInt32(venQuery.kuser_id));
                    venQuery.kuser_name = caller.user_username;
                    return VendorEdit(venQuery, list);
                }
            }
            catch (Exception ex)
            {
                Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                log.Error(logMessage);
                jsonStr = "{success:false}";
            }

            this.Response.Clear();
            this.Response.Write(jsonStr.ToString());
            this.Response.End();
            return this.Response;
        }
Esempio n. 3
0
        public HttpResponseBase SavePhone()
        {
            string jsonStr = string.Empty;
            UserQuery user = new UserQuery();
            HashEncrypt hmd5 = new HashEncrypt();
            try
            {
                if (!string.IsNullOrEmpty(Request.Params["name"]))
                {
                    user.user_name = Request.Params["name"].ToString();
                }
                else
                {
                    user.user_name = "";
                }
                if (!string.IsNullOrEmpty(Request.Params["tel"]))
                {
                    if (!CommonFunction.isMobile(Request.Params["tel"].ToString()))
                    {
                        jsonStr = "{success:false,msg:0}";
                        this.Response.Clear();
                        this.Response.Write(jsonStr.ToString());
                        this.Response.End();
                        return this.Response;
                    }
                    else
                    {
                        //user.user_mobile = EncryptComputer.EncryptDecryptTextByApi(Request.Params["tel"].ToString());
                        user.user_mobile = Request.Params["tel"].ToString();
                    }
                    //if (user.user_mobile.Length < 10 || user.user_mobile.Substring(0, 2).ToString() != "09")
                    //{
                    //    for (int i = user.user_mobile.Length; i < 10; i++)
                    //    {
                    //        user.user_mobile = "0" + user.user_mobile;
                    //    }
                    //}
                }
                else
                {
                    user.user_mobile = "";
                }

                user.user_email = Request.Params["tel"] + "@user.gigade.com.tw";
                #region 獲取生日的年月日
                try
                {
                    DateTime birth = Convert.ToDateTime(Request.Params["birth"].ToString());
                    user.user_birthday_year = Convert.ToUInt32(birth.Year);
                    user.user_birthday_month = Convert.ToUInt32(birth.Month);
                    user.user_birthday_day = Convert.ToUInt32(birth.Day);
                }
                catch (Exception)
                {
                    user.user_birthday_year = 1970;
                    user.user_birthday_month = 0;
                    user.user_birthday_day = 0;
                }
                #endregion
                #region 密碼
                user.user_password = "******" + user.user_birthday_year;
                if (user.user_birthday_month.ToString().Length == 1)
                {
                    user.user_password += "0" + user.user_birthday_month;
                }
                else
                {
                    user.user_password += user.user_birthday_month;
                }
                if (user.user_birthday_day.ToString().Length == 1)
                {
                    user.user_password += "0" + user.user_birthday_day;
                }
                else
                {
                    user.user_password += user.user_birthday_day;
                }
                user.user_password = hmd5.SHA256Encrypt(user.user_password);
                #endregion
                if (!string.IsNullOrEmpty(Request.Params["zip"]))
                {
                    user.user_zip = Convert.ToUInt32(Request.Params["zip"].ToString());
                }
                else
                {
                    user.user_zip = 0;
                }
                if (!string.IsNullOrEmpty(Request.Params["address"]))
                {
                    user.user_address = Request.Params["address"].ToString();
                }
                else
                {
                    user.user_address = "";
                }
                if (!string.IsNullOrEmpty(Request.Params["IsAcceptAd"]))
                {
                    if (Request.Params["IsAcceptAd"].ToString() == "on")
                    {
                        user.send_sms_ad = true;
                    }
                }
                else
                {
                    user.send_sms_ad = false;
                }
                if (!string.IsNullOrEmpty(Request.Params["Remark"]))
                {
                    user.adm_note = Request.Params["Remark"].ToString();
                }
                else
                {
                    user.adm_note = "";
                }

                user.ip = Request.UserHostAddress;
                user.file_name = "UserPhone.chtml";

                user.created = DateTime.Now;
                user.kuser_id = Convert.ToUInt32((System.Web.HttpContext.Current.Session["caller"] as Caller).user_id.ToString());
                mgr = new CallerMgr(mySqlConnectionString);
                Caller caller = new Caller();
                caller = mgr.GetUserById(Convert.ToInt32(user.kuser_id));
                user.kuser_name = caller.user_username;

                user.content = "user_email:" + user.user_email + ",user_mobile:" + user.user_mobile + ",user_birthday_year" + user.user_birthday_year + ",user_birthday_month" + user.user_birthday_month + ",user_birthday_day" + user.user_birthday_day + ",user_zip" + user.user_zip + ",user_address" + user.user_address + ",send_sms_ad" + user.send_sms_ad + ",adm_note" + user.adm_note;

                user.user_status = 1;
                user.user_source = "電話會員";
                user.user_login_attempts = 0;
                user.user_reg_date = Convert.ToUInt32(CommonFunction.GetPHPTime(DateTime.Now.ToString()));
                user.user_updatedate = Convert.ToUInt32(CommonFunction.GetPHPTime(DateTime.Now.ToString()));
                user.user_type = 2;

                _usmpgr = new UsersMgr(mySqlConnectionString);//實現方法
                if (_usmpgr.QueryByUserMobile(user.user_mobile).Rows.Count == 0)
                {
                    _usmpgr = new UsersMgr(mySqlConnectionString);
                    if (_usmpgr.SaveUserPhone(user) > 0)
                    {
                        jsonStr = "{success:true,msg:1}";
                    }
                    else
                    {
                        jsonStr = "{success:false,msg:2 }";
                    }
                }
                else
                {
                    jsonStr = "{success:false,msg:3 }";
                }
            }
            catch (Exception ex)
            {
                Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                log.Error(logMessage);
                jsonStr = "{success:false,msg:0}";
            }
            this.Response.Clear();
            this.Response.Write(jsonStr.ToString());
            this.Response.End();
            return this.Response;
        }