public JsonResult GetAuthorityGroup() { try { BLL.gigade.Model.Vendor vendorModel = new BLL.gigade.Model.Vendor(); vendorModel = (BLL.gigade.Model.Vendor)Session["vendor"]; _vendor = new VendorMgr(connectionString); string callId = _vendor.GetSingle(vendorModel).vendor_email; AuthorityQuery query = new AuthorityQuery { Type = 1, CallId = callId }; functionGroupMgr = new FunctionVGroupMgr(connectionString); List<Function> functions = functionGroupMgr.CallerAuthorityQuery(query); var result = from f in functions group f by f.FunctionGroup into fgroup select new { Id = fgroup.Min(m => m.RowId), Text = fgroup.Key }; return Json(result); } 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); } return Json("[]"); }
public DataOperation(List<Model.MigrationDataSet> mds, MainForm form) { this.mds = mds; this.connectionString = System.Configuration.ConfigurationSettings.AppSettings["MySqlConnectionString"]; prod = new Product(); pItem = new ProductItem(); pM = new PriceMaster(); iPrice = new ItemPrice(); categorySet = new ProductCategorySet(); pMap = new ProductMigrationMap(); _prodMgr = new ProductMgr(this.connectionString); _priceMgr = new PriceMasterMgr(this.connectionString); _prodItemMgr = new ProductItemMgr(this.connectionString); _itemPriceMgr = new ItemPriceMgr(this.connectionString); _vendorBrandMgr = new VendorBrandMgr(this.connectionString); _vendorMgr = new VendorMgr(this.connectionString); _pMap = new ProductMigrationMgr(this.connectionString); _productCategorySetMgr = new ProductCategorySetMgr(this.connectionString); _productNoticeSetMgr = new ProductNoticeSetMgr(this.connectionString); _productTagSetMgr = new ProductTagSetMgr(this.connectionString); _productPictureMgr = new ProductPictureMgr(this.connectionString); _proStatusHistoryMgr = new ProductStatusHistoryMgr(connectionString); _proSpecMgr = new ProductSpecMgr(connectionString); _siteMgr = new SiteMgr(connectionString); this.form = form; }
public ActionResult Index() { HttpCookie cookies = Request.Cookies["vendor"]; if (cookies != null) { ViewBag.LoginEmail = cookies["email"]; } else { ViewBag.LoginEmail = null; } if (Session["vendor"] != null) { return RedirectToAction("", "home"); } else { string vendorid = Request.QueryString["vendor_id"]; string key = Request.QueryString["key"]; string keysec = string.Empty; if (!string.IsNullOrEmpty(vendorid) && !string.IsNullOrEmpty(key)) { int vendor_id = Convert.ToInt32(vendorid); _vendorImp = new VendorMgr(connectionString); string str = _vendorImp.GetLoginId(vendor_id); HashEncrypt hmd5 = new HashEncrypt(); string mdlogin_id = hmd5.Md5Encrypt(str, "MD5"); keysec = hmd5.Md5Encrypt(mdlogin_id + str, "MD5"); if (key.ToString().Trim() != keysec.ToString().Trim()) { return View(); } else { BLL.gigade.Model.Vendor vendor = new BLL.gigade.Model.Vendor(); BLL.gigade.Model.Vendor ven = new BLL.gigade.Model.Vendor(); vendor.vendor_id = Convert.ToUInt32(vendorid); _vendorImp = new VendorMgr(connectionString); ven = _vendorImp.GetSingle(vendor); ven.vendor_password = ""; Session["vendor"] = ven; Session["lgnName"] = ven.vendor_name_simple; return RedirectToAction("", "home"); } } else { return View(); } } }
public HttpResponseBase GetAuthorityFun(string id) { string json = string.Empty; try { BLL.gigade.Model.Vendor vendorModel = new BLL.gigade.Model.Vendor(); vendorModel = (BLL.gigade.Model.Vendor)Session["vendor"]; _vendor = new VendorMgr(connectionString); string callId = _vendor.GetSingle(vendorModel).vendor_email; AuthorityQuery query = new AuthorityQuery { Type = 1, CallId = callId }; if (!string.IsNullOrEmpty(id)) { query.RowId = Convert.ToInt32(id); } functionGroupMgr = new FunctionVGroupMgr(connectionString); List<Function> functions = functionGroupMgr.CallerAuthorityQuery(query); StringBuilder strJson = new StringBuilder("["); foreach (Function fun in functions) { strJson.Append("{"); strJson.AppendFormat("text:\"{0}\",url:\"{1}\",id:\"{2}\",iconCls:\"{3}\",leaf:true", fun.FunctionName, fun.FunctionCode, fun.RowId, fun.IconCls); strJson.Append("}"); } strJson.Append("]"); json = strJson.ToString().Replace("}{", "},{"); } catch (Exception ex) { json = "[]"; 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); } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
/// <summary> /// 匯出csv /// </summary> /// <returns></returns> public HttpResponseBase VendorExportCsv() { string newCsvName = string.Empty; string json = string.Empty; _vendorMgr = new VendorMgr(connectionString); string sqlwhere = string.Empty; string type = string.Empty; string content = string.Empty; if (!string.IsNullOrEmpty(Request.Params["dateType"])) { type = Request.Params["dateType"]; } if (!string.IsNullOrEmpty(Request.Params["dateCon"])) { content = Request.Params["dateCon"]; } // string status = Request.Params["dateStatus"]; string agreementStart = string.Empty; string agreementEnd = string.Empty; if (!string.IsNullOrEmpty(Request.Params["dateOne"])) { // agreementStart = Convert.ToDateTime(Request.Params["dateOne"]).ToString("yyyy-MM-dd 00:00:00"); agreementStart = CommonFunction.DateTimeToString(Convert.ToDateTime(Request.Params["dateOne"])); } if (!string.IsNullOrEmpty(Request.Params["dateTwo"])) { // agreementEnd = Convert.ToDateTime(Request.Params["dateTwo"]).ToString("yyyy-MM-dd 23:59:59"); agreementEnd = CommonFunction.DateTimeToString(Convert.ToDateTime(Request.Params["dateTwo"])); } //匯出不需要查詢狀態 if (!string.IsNullOrEmpty(content) && !string.IsNullOrEmpty(type) && type != "0") { switch (type) { case "1": sqlwhere += " AND vendor_email LIKE '%" + content + "%'"; break; case "2": sqlwhere += " AND vendor_name_simple LIKE '%" + content + "%'"; break; case "3": sqlwhere += " AND vendor_name_full LIKE '%" + content + "%'"; break; case "4": sqlwhere += " AND vendor_invoice LIKE '%" + content + "%'"; break; case "5": sqlwhere += " AND vendor.erp_id LIKE '%" + content + "%'"; break; case "6": uint isTranUint = 0; if (uint.TryParse(content, out isTranUint)) { if (content != "0") { sqlwhere += " AND vendor_id = '" + content + "'"; } } break; case "7": sqlwhere += " AND vendor_code LIKE '%" + content + "%'"; break; default: sqlwhere += ""; break; } } else { if (!string.IsNullOrEmpty(Request.Params["vendortype"]))//供应商类型 { string vondertype = Request.Params["vendortype"].ToString(); sqlwhere += " and ("; string[] checks = vondertype.Substring(0, vondertype.Length - 1).Split(','); int num = 0; for (int i = 0; i < checks.Length; i++) { if (num == 0) { sqlwhere += " vendor_type like '%" + checks[i] + "%'"; num++; } else { sqlwhere += " or vendor_type like '%" + checks[i] + "%'"; num++; } } sqlwhere += " ) "; } if (!string.IsNullOrEmpty(agreementStart)) { sqlwhere += " AND agreement_createdate >=" + CommonFunction.GetPHPTime(agreementStart); } if (!string.IsNullOrEmpty(agreementEnd)) { sqlwhere += " AND agreement_createdate <=" + CommonFunction.GetPHPTime(agreementEnd); } } DataTable dt = new DataTable(); dt = _vendorMgr.GetVendorDetail(sqlwhere); DataTable dtHZ = new DataTable(); dtHZ.Columns.Add("供應商編號", typeof(String)); dtHZ.Columns.Add("供應商編碼", typeof(String)); dtHZ.Columns.Add("狀態", typeof(String)); dtHZ.Columns.Add("供應商名稱", typeof(String)); dtHZ.Columns.Add("供應商簡稱", typeof(String)); dtHZ.Columns.Add("統一編號", typeof(String)); dtHZ.Columns.Add("傳真", typeof(String)); dtHZ.Columns.Add("負責人", typeof(String)); dtHZ.Columns.Add("公司地址", typeof(String)); dtHZ.Columns.Add("發票地址", typeof(String)); dtHZ.Columns.Add("成本百分比", typeof(String)); dtHZ.Columns.Add("信用卡一期百分比", typeof(String)); dtHZ.Columns.Add("信用卡三期百分比", typeof(String)); dtHZ.Columns.Add("合約簽定日", typeof(String)); dtHZ.Columns.Add("合約期間", typeof(String)); dtHZ.Columns.Add("結帳方式", typeof(String)); dtHZ.Columns.Add("銀行代碼", typeof(String)); dtHZ.Columns.Add("銀行名稱", typeof(String)); dtHZ.Columns.Add("銀行帳號", typeof(String)); dtHZ.Columns.Add("銀行戶名", typeof(String)); dtHZ.Columns.Add("常溫運費", typeof(String)); dtHZ.Columns.Add("常溫運費門檻", typeof(String)); dtHZ.Columns.Add("常溫逆物流費", typeof(String)); dtHZ.Columns.Add("低溫運費", typeof(String)); dtHZ.Columns.Add("低溫運費門檻", typeof(String)); dtHZ.Columns.Add("低溫逆物流費", typeof(String)); dtHZ.Columns.Add("負責PM", typeof(String)); dtHZ.Columns.Add("業績獎金門檻", typeof(String)); dtHZ.Columns.Add("獎金百分比", typeof(String)); dtHZ.Columns.Add("採購天數", typeof(String)); dtHZ.Columns.Add("自出出貨天數", typeof(String)); dtHZ.Columns.Add("寄倉出貨天數", typeof(String)); dtHZ.Columns.Add("調度出貨天數", typeof(String)); dtHZ.Columns.Add("調度倉模式", typeof(String)); dtHZ.Columns.Add("出貨窗口聯絡人", typeof(String)); dtHZ.Columns.Add("連絡電話", typeof(String)); dtHZ.Columns.Add("聯絡手機", typeof(String)); dtHZ.Columns.Add("聯絡Mail", typeof(String)); dtHZ.Columns.Add("第二聯絡人類型", typeof(String)); dtHZ.Columns.Add("第二聯絡人姓名", typeof(String)); dtHZ.Columns.Add("第二連絡電話", typeof(String)); dtHZ.Columns.Add("第二聯絡手機", typeof(String)); dtHZ.Columns.Add("第二聯絡Mail", typeof(String)); dtHZ.Columns.Add("第三聯絡人類型", typeof(String)); dtHZ.Columns.Add("第三聯絡人姓名", typeof(String)); dtHZ.Columns.Add("第三連絡電話", typeof(String)); dtHZ.Columns.Add("第三聯絡手機", typeof(String)); dtHZ.Columns.Add("第三聯絡Mail", typeof(String)); dtHZ.Columns.Add("第四聯絡人類型", typeof(String)); dtHZ.Columns.Add("第四聯絡人姓名", typeof(String)); dtHZ.Columns.Add("第四連絡電話", typeof(String)); dtHZ.Columns.Add("第四聯絡手機", typeof(String)); dtHZ.Columns.Add("第四聯絡Mail", typeof(String)); dtHZ.Columns.Add("第五聯絡人類型", typeof(String)); dtHZ.Columns.Add("第五聯絡人姓名", typeof(String)); dtHZ.Columns.Add("第五連絡電話", typeof(String)); dtHZ.Columns.Add("第五聯絡手機", typeof(String)); dtHZ.Columns.Add("第五聯絡Mail", typeof(String)); dtHZ.Columns.Add("備註", typeof(String)); try { //"電話" "電子信箱", //string[] colname ={"供應商編號","供應商編碼","狀態","供應商名稱","供應商簡稱","統一編號","傳真","負責人", // "公司地址","發票地址","成本百分比","信用卡一期百分比","信用卡三期百分比", // "合約簽定日","合約期間","結帳方式","銀行代碼","銀行名稱","銀行帳號","銀行戶名", // "常溫運費","常溫運費門檻","常溫逆物流費","低溫運費","低溫運費門檻","低溫逆物流費", // "負責PM","出貨窗口聯絡人","連絡電話","聯絡手機","聯絡Mail","業績獎金門檻","獎金百分比","採購天數" // ,"自出出貨天數","寄倉出貨天數","調度出貨天數","調度倉模式","備註" // }; string filename = "供應商列表_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls"; newCsvName = Server.MapPath(excelPath) + filename; foreach (DataRow dr in dt.Rows) { dr["company_address"] = CommonFunction.ZipAddress(dr["company_zip"].ToString()) + " " + dr["company_address"].ToString(); dr["invoice_address"] = CommonFunction.ZipAddress(dr["invoice_zip"].ToString()) + " " + dr["invoice_address"].ToString(); if (string.IsNullOrEmpty(dr["user_username"].ToString())) { dr["user_username"] = "******"; } string temp = string.Empty; if (Convert.ToInt32(dr["self_send_days"]) == 0) { if (Convert.ToInt32(dr["stuff_ware_days"]) == 0) { if (Convert.ToInt32(dr["dispatch_days"]) == 0) { temp = ""; } else { temp = "調度"; } } else { if (Convert.ToInt32(dr["dispatch_days"]) == 0) { temp = "寄倉"; } else { temp = "寄倉,調度"; } } } else { if (Convert.ToInt32(dr["stuff_ware_days"]) == 0) { if (Convert.ToInt32(dr["dispatch_days"]) == 0) { temp = "自出"; } else { temp = "自出,調度"; } } else { if (Convert.ToInt32(dr["dispatch_days"]) == 0) { temp = "自出,寄倉"; } else { temp = "自出,寄倉,調度"; } } } dr["vendor_mode"] = temp; dr["vendor_note"] = dr["vendor_note"].ToString().Replace(',', ',').Replace("\r", "").Replace("\n", ""); } foreach (DataRow dr_v in dt.Rows) { DataRow dr = dtHZ.NewRow(); dr[0] = dr_v["vendor_id"].ToString(); dr[1] = dr_v["vendor_code"].ToString(); dr[2] = dr_v["case vendor_status when 1 then '啟用' when 2 then '停用' when 3 then '失格' end"].ToString(); dr[3] = dr_v["vendor_name_full"].ToString(); dr[4] = dr_v["vendor_name_simple"].ToString(); dr[5] = dr_v["vendor_invoice"].ToString(); dr[6] = dr_v["company_fax"].ToString(); dr[7] = dr_v["company_person"].ToString(); dr[8] = dr_v["company_address"].ToString(); dr[9] = dr_v["invoice_address"].ToString(); dr[10] = dr_v["cost_percent"].ToString(); dr[11] = dr_v["creditcard_1_percent"].ToString(); dr[12] = dr_v["creditcard_3_percent"].ToString(); dr[13] = dr_v["FROM_UNIXTIME(agreement_createdate,'%Y/%m/%d')"].ToString(); dr[14] = dr_v["agreement_duration"].ToString(); dr[15] = dr_v["checkout_type"].ToString(); dr[16] = dr_v["bank_code"].ToString(); dr[17] = dr_v["bank_name"].ToString(); dr[18] = dr_v["bank_number"].ToString(); dr[19] = dr_v["bank_account"].ToString(); dr[20] = dr_v["freight_normal_money"].ToString(); dr[21] = dr_v["freight_normal_limit"].ToString(); dr[22] = dr_v["freight_return_normal_money"].ToString(); dr[23] = dr_v["freight_low_money"].ToString(); dr[24] = dr_v["freight_low_limit"].ToString(); dr[25] = dr_v["freight_return_low_money"].ToString(); dr[26] = dr_v["user_username"].ToString(); dr[27] = dr_v["gigade_bunus_threshold"].ToString(); dr[28] = dr_v["gigade_bunus_percent"].ToString(); dr[29] = dr_v["procurement_days"].ToString(); dr[30] = dr_v["self_send_days"].ToString(); dr[31] = dr_v["stuff_ware_days"].ToString(); dr[32] = dr_v["dispatch_days"].ToString(); dr[33] = dr_v["vendor_mode"].ToString(); dr[34] = dr_v["contact_name_1"].ToString(); dr[35] = dr_v["contact_phone_1_1"].ToString(); dr[36] = dr_v["contact_mobile_1"].ToString(); dr[37] = dr_v["contact_email_1"].ToString(); //dr[31] = dr_v["contact_type_2"].ToString(); dr[38] = ContactTypeToStr(dr_v["contact_type_2"].ToString()); dr[39] = dr_v["contact_name_2"].ToString(); dr[40] = dr_v["contact_phone_1_2"].ToString(); dr[41] = dr_v["contact_mobile_2"].ToString(); dr[42] = dr_v["contact_email_2"].ToString(); dr[43] = ContactTypeToStr(dr_v["contact_type_3"].ToString()); dr[44] = dr_v["contact_name_3"].ToString(); dr[45] = dr_v["contact_phone_1_3"].ToString(); dr[46] = dr_v["contact_mobile_3"].ToString(); dr[47] = dr_v["contact_email_3"].ToString(); dr[48] = ContactTypeToStr(dr_v["contact_type_4"].ToString()); dr[49] = dr_v["contact_name_4"].ToString(); dr[50] = dr_v["contact_phone_1_4"].ToString(); dr[51] = dr_v["contact_mobile_4"].ToString(); dr[52] = dr_v["contact_email_4"].ToString(); dr[53] = ContactTypeToStr(dr_v["contact_type_5"].ToString()); dr[54] = dr_v["contact_name_5"].ToString(); dr[55] = dr_v["contact_phone_1_5"].ToString(); dr[56] = dr_v["contact_mobile_5"].ToString(); dr[57] = dr_v["contact_email_5"].ToString(); dr[58] = dr_v["vendor_note"].ToString(); dtHZ.Rows.Add(dr); } dt.Columns.Remove("company_zip"); dt.Columns.Remove("invoice_zip"); dt.Columns.Remove("product_manage"); dt.Columns.Remove("company_phone");//電話 dt.Columns.Remove("vendor_email");//郵箱 if (System.IO.File.Exists(newCsvName)) { //設置文件的屬性,以防刪除文件的時候因為文件的屬性造成無法刪除 System.IO.File.SetAttributes(newCsvName, FileAttributes.Normal); System.IO.File.Delete(newCsvName); } ExcelHelperXhf.ExportDataTabletoExcel(dtHZ, "", newCsvName); json = "true," + filename; //if (System.IO.File.Exists(newCsvName)) //{ // Response.AddHeader("Content-Disposition", string.Format("attachment; filename={0}", filename)); // Response.ContentType = "application/ms-excel"; // //Response.WriteFile(newCsvName); // Response.Flush(); // Response.End(); //} } 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); json = "false, "; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
public HttpResponseBase VendorEdit(VendorQuery venQuery, List<TableChangeLog> list) { string jsonStr = "{success:false}"; _vendorMgr = new VendorMgr(connectionString); _productMgr = new ProductMgr(connectionString); try { if (_vendorMgr.Update(venQuery, list) > 0) { //變更商品可販售狀態 if (_productMgr.UpdateSaleStatusByCondition(new Product { Vendor_Id = venQuery.vendor_id })) { jsonStr = "{success:true}"; } } } 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; }
public ActionResult DoForget() { object notice = new object(); if (!string.IsNullOrEmpty(Request.Params["txtEmail"])) { string _email = Request.Params["txtEmail"].Trim().ToLower(); if (!Regex.IsMatch(_email, @"^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$")) { notice = "{result:'Notice',msg:'" + Resources.Login.NOTICE_EMAIL_FORMAT_ERROR + "'}"; ViewBag.notice = notice; return View("Forget"); } _vendorImp = new VendorMgr(connectionString); //Caller caller = null; BLL.gigade.Model.Vendor vendor = null; ICallerImplMgr callerMgr = new CallerMgr(connectionString); BLL.gigade.Model.Vendor query = new BLL.gigade.Model.Vendor(); try { query.vendor_email = _email; vendor = _vendorImp.Login(query); } 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); } if (vendor == null) { notice = "{result:'Error',msg:'" + Resources.Login.ERROR_EMIAL_NOT_MATCH + "'}"; ViewBag.notice = notice; return View("Forget"); } if (vendor.vendor_status >= 2) { notice = "{result:'Error',msg:'" + Resources.Login.ERROR_EMAIL_STATUS_INACTIVE + "'}"; ViewBag.notice = notice; return View("Forget"); } string sUser_Confirm_Code = BLL.gigade.Common.CommonFunction.Generate_Rand_String(8); BLL.gigade.Common.HashEncrypt hash = new BLL.gigade.Common.HashEncrypt(); try { _vendorImp.Modify_Vendor_Confirm_Code(Convert.ToInt32(vendor.vendor_id), hash.SHA256Encrypt(sUser_Confirm_Code)); } 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); } /////////////////////// //發郵件 /////////////////////// //return Redirect("/Login/ChangePasswd?uid=" + caller.user_id + "&code=" + sUser_Confirm_Code); ViewBag.ConfirmSend = "請檢查您的E-mail信箱,以取得密碼的相關資訊!"; return View("NoticeShow"); } else { notice = "{result:'Notice',msg:'登錄信箱不能為空!'}"; ViewBag.notice = notice; return View("Forget"); } }
public HttpResponseBase GetOrderDetailList() { List<OrderDetailQuery> stores = new List<OrderDetailQuery>(); string json = string.Empty; try { OrderDetailQuery query = new OrderDetailQuery(); query.Start = Convert.ToInt32(Request.Params["start"] ?? "0");//用於分頁的變量 query.Limit = Convert.ToInt32(Request.Params["limit"] ?? "25");//用於分頁的變量 //付款單號 query.Order_Id = Convert.ToUInt32(Request.Params["OrderId"].ToString()); query.isChildItem = 0; _orderDetailMgr = new OrderDetailMgr(mySqlConnectionString); int totalCount = 0; stores = _orderDetailMgr.GetOrderDetailList(query, out totalCount); IsoDateTimeConverter timeConverter = new IsoDateTimeConverter(); //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式 timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss"; //listUser是准备转换的对象 //獲取供應商後臺登陸的vendorMd5加密 _vendorImp = new VendorMgr(mySqlConnectionString); foreach (OrderDetailQuery item in stores) { string str = _vendorImp.GetLoginId(Convert.ToInt32(item.Vendor_Id)); if (str != "") { HashEncrypt hmd5 = new HashEncrypt(); string mdlogin_id = hmd5.Md5Encrypt(str, "MD5"); item.VendorMd5 = hmd5.Md5Encrypt(mdlogin_id + str, "MD5"); } if (item.item_mode == 2) { item.subtotal = (item.Single_Money * item.parent_num)-uint.Parse(item.Deduct_Happygo_Money.ToString())-item.Deduct_Welfare-item.Deduct_Bonus; } else { item.subtotal = (item.Single_Money * item.Buy_Num) -uint.Parse( item.Deduct_Happygo_Money.ToString()) - item.Deduct_Welfare - item.Deduct_Bonus; } } json = "{success:true,totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(stores, Formatting.Indented, timeConverter) + "}";//返回json數據 } 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); json = "{success:true,totalCount:0,data:[]}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
public HttpResponseBase EditPass() { string jsonStr = "{success:false}"; try { _vendorMgr = new VendorMgr(connectionString); string newPass = string.Empty; string vendorId = string.Empty; if (!string.IsNullOrEmpty(Request.Params["vendorId"])) { vendorId = Request.Params["vendorId"].ToString(); } if (!string.IsNullOrEmpty(Request.Params["newPass"])) { BLL.gigade.Common.HashEncrypt hash = new BLL.gigade.Common.HashEncrypt(); newPass = hash.SHA256Encrypt(Request.Params["newPass"].ToString()); } if (_vendorMgr.EditPass(vendorId, newPass) > 0) { jsonStr = "{success:true}"; } else { jsonStr = "{success:false}"; } } 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; }
public HttpResponseBase ImportVendorBank() { string json = "{success:false}"; try { if (Request.Files["importFile"] != null && Request.Files["importFile"].ContentLength > 0) { HttpPostedFileBase excelFile = Request.Files["importFile"]; FileManagement fileManagement = new FileManagement(); string i = excelFile.FileName; string newExcelName = Server.MapPath(excelPath_export) + "供應商銀行代碼" + fileManagement.NewFileName(excelFile.FileName);//處理文件名,獲取新的文件名 string oldExcelName = excelFile.FileName.Split('\\').LastOrDefault(); excelFile.SaveAs(newExcelName);//上傳文件 DataTable dt = new DataTable(); NPOI4ExcelHelper helper = new NPOI4ExcelHelper(newExcelName); dt = helper.SheetData(); string s = dt.Rows[0][0].ToString(); if (dt != null && dt.Rows.Count > 0) { _vendorMgr = new VendorMgr(connectionString); string result = _vendorMgr.ImportVendorBank(dt); if (result == "") { json = "{success:true,error:\"0\"}"; } else { json = "{success:true,error:\"" + result + "\"}"; } } FileInfo file = new FileInfo(newExcelName); file.Delete(); } } 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); json = "{success:false,error:\"" + BLL.gigade.Common.CommonFunction.MySqlException(ex) + "\"}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
/// <summary> /// 根據供應商查看未失格商品的個數 /// </summary> /// <returns>數據庫操作結果</returns> public JsonResult GetOffGradeCount() { try { string vendor_id = Request.Params["vendor_id"].ToString(); _vendorMgr = new VendorMgr(connectionString); int count = _vendorMgr.GetOffGradeCount(vendor_id); return Json(new { success = "true", count = count }); } 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); return Json(new { success = "false" }); } }
/// <summary> /// 匯出pdf文檔 /// </summary> //public void WritePdf() //{ // string newName = string.Empty; // string json = string.Empty; // IpodQuery ipod = new IpodQuery(); // IpoQuery ipo = new IpoQuery(); // if (!string.IsNullOrEmpty(Request.Params["Poid"])) // { // ipo.po_id = Request.Params["Poid"]; // } // if (!string.IsNullOrEmpty(Request.Params["Potype"])) // { // ipo.po_type = Request.Params["Potype"]; // } // List<IpodQuery> ipodStore = new List<IpodQuery>(); // List<IpoQuery> ipoStore = new List<IpoQuery>(); // _ipoMgr = new IpoMgr(mySqlConnectionString); // int totalCount = 0; // ipo.IsPage = false; // ipoStore = _ipoMgr.GetIpoList(ipo, out totalCount); // try // { // #region 採購單匯出 // BaseFont bf = BaseFont.CreateFont("C:\\WINDOWS\\Fonts\\simsun.ttc,1", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED); // iTextSharp.text.Font fontChinese = new iTextSharp.text.Font(bf, 8, iTextSharp.text.Font.UNDERLINE, iTextSharp.text.BaseColor.RED); // iTextSharp.text.Font font = new iTextSharp.text.Font(bf, 12, iTextSharp.text.Font.BOLD, new iTextSharp.text.BaseColor(0, 0, 0));//黑 // string filename = "採購單"+ DateTime.Now.ToString("yyyyMMddHHmmss") +".pdf"; // Document document = new Document(PageSize.A4, (float)5, (float)5, (float)20, (float)0.5); // string newPDFName = Server.MapPath(excelPath) + filename; // PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(newPDFName, FileMode.Create)); // document.Open(); // //運送方式 // _paraMgr = new ParameterMgr(mySqlConnectionString); // List<Parametersrc> parameterStore = new List<Parametersrc>(); // parameterStore = _paraMgr.GetElementType("product_freight"); // for (int a = 0; a < ipoStore.Count; a++)//循環單頭 // { // //GetIpodListExprot // _ipodMgr = new IpodMgr(mySqlConnectionString); // ipod = new IpodQuery(); // ipod.po_id = ipoStore[a].po_id; // ipodStore = new List<IpodQuery>(); // ipodStore = _ipodMgr.GetIpodListExprot(ipod); // Dictionary<int, List<IpodQuery>> product_freight_set_mapping = new Dictionary<int, List<IpodQuery>>(); // #region 通過運送方式把採購單分開--一張採購單,分成常溫,冷凍等採購單 // for (int i = 0; i < ipodStore.Count; i++)//通過運送方式保存到字典里 // { // ipodStore[i].spec = GetProductSpec(ipodStore[i].item_id.ToString()); // IupcQuery upc = new IupcQuery(); // upc.item_id = ipodStore[i].item_id; // List<IupcQuery> upcStore = new List<IupcQuery>(); // _IiupcMgr = new IupcMgr(mySqlConnectionString); // upcStore = _IiupcMgr.GetIupcByItemID(upc); // if (upcStore.Count > 0) // { // ipodStore[i].upc_id = upcStore[0].upc_id; // } // int freiset = ipodStore[i].product_freight_set; // if (!product_freight_set_mapping.Keys.Contains(freiset)) // { // List<IpodQuery> s = new List<IpodQuery>(); // product_freight_set_mapping.Add(freiset, s); // } // product_freight_set_mapping[freiset].Add(ipodStore[i]); // } // #endregion // #region 針對匯出一個而無商品的pdf // if (ipodStore.Count == 0) // { // #region 獲取供應商信息 // Vendor vendor = new Vendor(); // _vendorMgr = new VendorMgr(mySqlConnectionString); // vendor.erp_id = ipoStore[a].vend_id; // vendor = _vendorMgr.GetSingle(vendor); // #endregion // #region 採購單標題 // PdfContentByte cb = writer.DirectContent; // cb.BeginText(); // cb.SetFontAndSize(bf, 15); // cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "吉甲地好市集股份有限公司", 220, 790, 0); // font = new iTextSharp.text.Font(bf, 12, iTextSharp.text.Font.NORMAL, new iTextSharp.text.BaseColor(0, 0, 0));//黑 // cb.SetFontAndSize(bf, 12); // cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "採購單" + "-" + ipoStore[a].po_type_desc, 280, 770, 0); // cb.SetFontAndSize(bf, 8); // cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "公司電話:", 60, 760, 0); // cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "公司傳真:", 470, 760, 0); // cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "製造日期:" + DateTime.Now.ToString("yyyy/MM/dd"), 60, 750, 0); // cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "頁", 510, 750, 0); // cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "次", 530, 750, 0); // #endregion // PdfPTable ptable = new PdfPTable(6); // ptable.WidthPercentage = 150;//表格寬度 // font = new iTextSharp.text.Font(bf, 10, iTextSharp.text.Font.NORMAL, new iTextSharp.text.BaseColor(0, 0, 0));//黑 // ptable.SetTotalWidth(new float[] { 82, 50, 100, 90, 110, 71 }); // PdfPCell cell = new PdfPCell(); // cell.UseAscender = true; // cell.HorizontalAlignment = Element.ALIGN_CENTER;//字體垂直居中 // cell.VerticalAlignment = Element.ALIGN_MIDDLE;//字體水平居中 // cell.BorderWidth = 0.1f; // cell.BorderColor = new BaseColor(0, 0, 0); // #region 上部分 // cell = new PdfPCell(new Phrase("採購單別:" + ipoStore[a].po_type, font)); // cell.DisableBorderSide(2); // cell.DisableBorderSide(8); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("交易幣別:" + "世界貨幣", font)); // cell.Colspan = 2; // cell.DisableBorderSide(2); // cell.DisableBorderSide(4); // cell.DisableBorderSide(8); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("匯率:" + "浮動", font)); // cell.DisableBorderSide(2); // cell.DisableBorderSide(4); // cell.DisableBorderSide(8); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("運輸方式:" , font)); // cell.Colspan = 2; // cell.DisableBorderSide(2); // cell.DisableBorderSide(4); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("商品是新品么?:", font));//新品 // cell.Colspan = 2; // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // cell.DisableBorderSide(8); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("所在層:", font)); // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // cell.DisableBorderSide(4); // cell.DisableBorderSide(8); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("採購單(" + ipoStore[a].po_type_desc + ")", font)); // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // cell.DisableBorderSide(4); // cell.DisableBorderSide(8); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("預約到貨日期:", font)); // cell.Colspan = 2; // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // cell.DisableBorderSide(4); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("採購單號:" + ipoStore[a].po_id, font)); // cell.Colspan = 2; // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // cell.DisableBorderSide(8); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("課稅別:", font)); // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // cell.DisableBorderSide(4); // cell.DisableBorderSide(8); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("營業稅率:", font)); // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // cell.DisableBorderSide(4); // cell.DisableBorderSide(8); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("價格條件:", font)); // cell.Colspan = 2; // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // cell.DisableBorderSide(4); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("單據日期:" + DateTime.Now.ToString("yyyy/MM/dd"), font)); // cell.Colspan = 2; // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // cell.DisableBorderSide(8); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("採購人員:" + ipoStore[a].buyer, font)); // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // cell.DisableBorderSide(4); // cell.DisableBorderSide(8); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase((System.Web.HttpContext.Current.Session["caller"] as Caller).user_username, font)); // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // cell.DisableBorderSide(4); // cell.DisableBorderSide(8); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("廠別代號:", font)); // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // cell.DisableBorderSide(4); // cell.DisableBorderSide(8); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("gigade(讀取)", font)); // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // cell.DisableBorderSide(4); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("廠商代號:" + ipoStore[a].vend_id, font)); // cell.Colspan = 2; // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // cell.DisableBorderSide(8); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("", font)); // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // cell.DisableBorderSide(4); // cell.DisableBorderSide(8); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("付款條件(讀取)", font)); // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // cell.DisableBorderSide(4); // cell.DisableBorderSide(8); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("月結N天(讀取):", font)); // cell.Colspan = 3; // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // cell.DisableBorderSide(4); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("廠商全名(讀取):" , font)); // cell.Colspan = 4; // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // cell.DisableBorderSide(8); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("備註:", font)); // cell.Colspan = 2; // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // cell.DisableBorderSide(4); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("廠商地址:", font)); // cell.Colspan = 6; // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase(" ", font)); // cell.Colspan = 6; // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("聯絡人(讀取):", font)); // cell.Colspan = 2; // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // cell.DisableBorderSide(8); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("廠商電話:" , font)); // cell.Colspan = 2; // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // cell.DisableBorderSide(4); // cell.DisableBorderSide(8); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("廠商傳真:" , font)); // cell.Colspan = 2; // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // cell.DisableBorderSide(4); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("送貨地址(讀取):", font)); // cell.Colspan = 6; // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase(" ", font)); // cell.Colspan = 6; // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("預計送貨日期(讀取):", font)); // cell.Colspan = 6; // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("配送聯絡人(讀取):", font)); // cell.Colspan = 2; // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // cell.DisableBorderSide(8); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("配送電話(讀取):", font)); // cell.Colspan = 2; // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // cell.DisableBorderSide(4); // cell.DisableBorderSide(8); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("配送傳真(讀取):", font)); // cell.Colspan = 2; // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // cell.DisableBorderSide(4); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("處理備註:", font)); // cell.Colspan = 6; // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("運送備註:", font)); // cell.Colspan = 6; // cell.DisableBorderSide(1); // ptable.AddCell(cell); // #endregion // ptable.WriteSelectedRows(0, -1, 46, 740, writer.DirectContent);//顯示的開始行,結束航(-1為所有)x坐標,y坐標 // PdfPTable nulltable = new PdfPTable(2); // nulltable.SetWidths(new int[] { 20, 20 }); // nulltable.DefaultCell.DisableBorderSide(1); // nulltable.DefaultCell.DisableBorderSide(2); // nulltable.DefaultCell.DisableBorderSide(4); // nulltable.DefaultCell.DisableBorderSide(8); // nulltable.AddCell(""); // nulltable.AddCell(""); // nulltable.SpacingAfter = 292; // document.Add(nulltable); // ptable = new PdfPTable(6); // ptable.WidthPercentage = 86;//表格寬度 // font = new iTextSharp.text.Font(bf, 9, iTextSharp.text.Font.NORMAL, new iTextSharp.text.BaseColor(0, 0, 0));//黑 // ptable.SetTotalWidth(new float[] { 90, 130, 50, 50, 60, 120 }); // cell = new PdfPCell(new Phrase("此採購單商品不存在!", font)); // cell.Colspan = 6; // ptable.AddCell(cell); // cb.EndText(); // document.Add(ptable); // document.NewPage(); // } // #endregion // foreach (int key in product_freight_set_mapping.Keys) // { // #region 取出運送方式 // string procduct_freight = ""; // for (int i = 0; i < parameterStore.Count; i++) // { // if (key.ToString() == parameterStore[i].ParameterCode) // { // procduct_freight = parameterStore[i].parameterName; // } // } // #endregion // #region 獲取供應商信息 // Vendor vendor = new Vendor(); // _vendorMgr = new VendorMgr(mySqlConnectionString); // vendor.erp_id = ipoStore[a].vend_id; // vendor = _vendorMgr.GetSingle(vendor); // #endregion // #region 採購單標題 // PdfContentByte cb = writer.DirectContent; // cb.BeginText(); // cb.SetFontAndSize(bf, 15); // cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "吉甲地好市集股份有限公司", 220, 790, 0); // font = new iTextSharp.text.Font(bf, 12, iTextSharp.text.Font.NORMAL, new iTextSharp.text.BaseColor(0, 0, 0));//黑 // cb.SetFontAndSize(bf, 12); // cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "採購單" + "-" + ipoStore[a].po_type_desc, 280, 770, 0); // cb.SetFontAndSize(bf, 8); // cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "公司電話:", 60, 760, 0); // cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "公司傳真:", 470, 760, 0); // cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "製造日期:" + DateTime.Now.ToString("yyyy/MM/dd"), 60, 750, 0); // cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "頁", 510, 750, 0); // cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "次", 530, 750, 0); // #endregion // PdfPTable ptable = new PdfPTable(6); // ptable.WidthPercentage = 150;//表格寬度 // font = new iTextSharp.text.Font(bf, 10, iTextSharp.text.Font.NORMAL, new iTextSharp.text.BaseColor(0, 0, 0));//黑 // ptable.SetTotalWidth(new float[] { 82, 50, 100, 90, 110, 71 }); // PdfPCell cell = new PdfPCell(); // cell.UseAscender = true; // cell.HorizontalAlignment = Element.ALIGN_CENTER;//字體垂直居中 // cell.VerticalAlignment = Element.ALIGN_MIDDLE;//字體水平居中 // cell.BorderWidth = 0.1f; // cell.BorderColor = new BaseColor(0, 0, 0); // #region 上部分 // cell = new PdfPCell(new Phrase("採購單別:" + ipoStore[a].po_type, font)); // cell.DisableBorderSide(2); // cell.DisableBorderSide(8); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("交易幣別:" + "世界貨幣", font)); // cell.Colspan = 2; // cell.DisableBorderSide(2); // cell.DisableBorderSide(4); // cell.DisableBorderSide(8); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("匯率:" + "浮動", font)); // cell.DisableBorderSide(2); // cell.DisableBorderSide(4); // cell.DisableBorderSide(8); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("運輸方式:" + procduct_freight, font)); // cell.Colspan = 2; // cell.DisableBorderSide(2); // cell.DisableBorderSide(4); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("商品是新品么?:", font));//新品 // cell.Colspan = 2; // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // cell.DisableBorderSide(8); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("所在層:", font)); // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // cell.DisableBorderSide(4); // cell.DisableBorderSide(8); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("採購單(" + ipoStore[a].po_type_desc + ")", font)); // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // cell.DisableBorderSide(4); // cell.DisableBorderSide(8); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("預約到貨日期:", font)); // cell.Colspan = 2; // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // cell.DisableBorderSide(4); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("採購單號:" + ipoStore[a].po_id, font)); // cell.Colspan = 2; // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // cell.DisableBorderSide(8); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("課稅別:", font)); // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // cell.DisableBorderSide(4); // cell.DisableBorderSide(8); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("營業稅率:", font)); // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // cell.DisableBorderSide(4); // cell.DisableBorderSide(8); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("價格條件:", font)); // cell.Colspan = 2; // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // cell.DisableBorderSide(4); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("單據日期:" + DateTime.Now.ToString("yyyy/MM/dd"), font)); // cell.Colspan = 2; // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // cell.DisableBorderSide(8); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("採購人員:" + ipoStore[a].buyer, font)); // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // cell.DisableBorderSide(4); // cell.DisableBorderSide(8); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase((System.Web.HttpContext.Current.Session["caller"] as Caller).user_username, font)); // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // cell.DisableBorderSide(4); // cell.DisableBorderSide(8); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("廠別代號:" , font)); // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // cell.DisableBorderSide(4); // cell.DisableBorderSide(8); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("gigade(讀取)", font)); // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // cell.DisableBorderSide(4); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("廠商代號:" + ipoStore[a].vend_id, font)); // cell.Colspan = 2; // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // cell.DisableBorderSide(8); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase(vendor == null ? "暫無此信息" : vendor.vendor_name_simple, font)); // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // cell.DisableBorderSide(4); // cell.DisableBorderSide(8); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("付款條件(讀取)", font)); // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // cell.DisableBorderSide(4); // cell.DisableBorderSide(8); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("月結N天(讀取):", font)); // cell.Colspan = 3; // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // cell.DisableBorderSide(4); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase(vendor == null ? "廠商全名(讀取):暫無此信息" :"廠商全名:"+ vendor.vendor_name_full, font)); // cell.Colspan = 4; // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // cell.DisableBorderSide(8); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("備註:", font)); // cell.Colspan = 2; // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // cell.DisableBorderSide(4); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase(vendor == null ? "廠商地址:暫無此信息" : "廠商地址:"+vendor.company_address, font)); // cell.Colspan = 6; // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase(" ", font)); // cell.Colspan = 6; // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("聯絡人(讀取):", font)); // cell.Colspan = 2; // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // cell.DisableBorderSide(8); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase(vendor == null?"廠商電話:暫無此信息" :"廠商電話:"+ vendor.company_phone, font)); // cell.Colspan = 2; // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // cell.DisableBorderSide(4); // cell.DisableBorderSide(8); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase(vendor == null? "廠商傳真:暫無此信息" :"廠商傳真:"+ vendor.company_fax, font)); // cell.Colspan = 2; // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // cell.DisableBorderSide(4); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("送貨地址(讀取):", font)); // cell.Colspan = 6; // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase(" ", font)); // cell.Colspan = 6; // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("預計送貨日期(讀取):", font)); // cell.Colspan = 6; // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("配送聯絡人(讀取):", font)); // cell.Colspan = 2; // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // cell.DisableBorderSide(8); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("配送電話(讀取):", font)); // cell.Colspan = 2; // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // cell.DisableBorderSide(4); // cell.DisableBorderSide(8); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("配送傳真(讀取):", font)); // cell.Colspan = 2; // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // cell.DisableBorderSide(4); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("處理備註:", font)); // cell.Colspan = 6; // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("運送備註:", font)); // cell.Colspan = 6; // cell.DisableBorderSide(1); // ptable.AddCell(cell); // #endregion // ptable.WriteSelectedRows(0, -1, 46, 740, writer.DirectContent);//顯示的開始行,結束航(-1為所有)x坐標,y坐標 // PdfPTable nulltable = new PdfPTable(2); // nulltable.SetWidths(new int[] { 20, 20 }); // nulltable.DefaultCell.DisableBorderSide(1); // nulltable.DefaultCell.DisableBorderSide(2); // nulltable.DefaultCell.DisableBorderSide(4); // nulltable.DefaultCell.DisableBorderSide(8); // nulltable.AddCell(""); // nulltable.AddCell(""); // nulltable.SpacingAfter = 292; // document.Add(nulltable); // ptable = new PdfPTable(6); // ptable.WidthPercentage = 86;//表格寬度 // font = new iTextSharp.text.Font(bf, 9, iTextSharp.text.Font.NORMAL, new iTextSharp.text.BaseColor(0, 0, 0));//黑 // ptable.SetTotalWidth(new float[] { 90, 130, 50, 50, 60, 120 }); // #region 下面表格頭部 // cell = new PdfPCell(new Phrase("條碼", font)); // cell.Rowspan = 2; // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("品號", font)); // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // cell.DisableBorderSide(4); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("採購數量", font)); // cell.HorizontalAlignment = Element.ALIGN_RIGHT;//.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // cell.DisableBorderSide(4); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("允收天數", font)); // cell.HorizontalAlignment = Element.ALIGN_RIGHT; // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // cell.DisableBorderSide(4); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("製造日期", font)); // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // cell.DisableBorderSide(4); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("備註", font)); // cell.Rowspan = 3; // cell.DisableBorderSide(1); // cell.DisableBorderSide(4); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("品名", font)); // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // cell.DisableBorderSide(4); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("允收數量", font)); // cell.HorizontalAlignment = Element.ALIGN_RIGHT;//.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // cell.DisableBorderSide(4); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("允出天數", font)); // cell.HorizontalAlignment = Element.ALIGN_RIGHT;//.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // cell.DisableBorderSide(4); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("有效日期", font)); // cell.DisableBorderSide(1); // cell.DisableBorderSide(4); // cell.Rowspan = 2; // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("料位", font)); // cell.DisableBorderSide(1); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("規格", font)); // cell.DisableBorderSide(1); // cell.DisableBorderSide(4); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("不允收數量", font)); // cell.HorizontalAlignment = Element.ALIGN_RIGHT; // cell.DisableBorderSide(1); // cell.DisableBorderSide(4); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("有效期天數", font)); // cell.HorizontalAlignment = Element.ALIGN_RIGHT;//.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.DisableBorderSide(1); // cell.DisableBorderSide(4); // ptable.AddCell(cell); // #endregion // _ipodMgr = new IpodMgr(mySqlConnectionString); // ipod = new IpodQuery(); // ipod.po_id = ipoStore[a].po_id; // ipod.IsPage = false; // ipodStore = new List<IpodQuery>(); // ipodStore = _ipodMgr.GetIpodList(ipod, out totalCount); // List<IpodQuery> Ipodleibie = new List<IpodQuery>(); // Ipodleibie.AddRange(product_freight_set_mapping[key]); // #region 循環讀取數據填入表格 // for (int i = 0; i < Ipodleibie.Count; i++) // { // //string sResult = ""; // //if (ipodStore[i].pod_id.ToString().Length < 4) // //{ // // for (int n = 0; n < 4 - (ipodStore[i].pod_id.ToString().Length); n++) // // { // // sResult += "0"; // // } // //} // cell = new PdfPCell(new Phrase(Ipodleibie[i].upc_id, font));//條碼 // cell.Rowspan = 2; // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase(Ipodleibie[i].Erp_Id.ToString(), font));//品號 // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // cell.DisableBorderSide(4); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase(Ipodleibie[i].qty_ord.ToString(), font));//採購數量qty_ord // cell.HorizontalAlignment = Element.ALIGN_RIGHT;//.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // cell.DisableBorderSide(4); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase(Ipodleibie[i].cde_dt_var.ToString(), font));//允收天數cde_dt_var // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // cell.DisableBorderSide(4); // cell.HorizontalAlignment = Element.ALIGN_RIGHT;//.setHorizontalAlignment(Element.ALIGN_CENTER); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("", font));//製造日期 // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // cell.DisableBorderSide(4); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("", font));//備註 // cell.Rowspan = 3; // cell.DisableBorderSide(1); // cell.DisableBorderSide(4); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase(Ipodleibie[i].product_name, font));//品名 // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // cell.DisableBorderSide(4); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase(Ipodleibie[i].qty_claimed.ToString(), font));//允收數量 // cell.HorizontalAlignment = Element.ALIGN_RIGHT;//.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // cell.DisableBorderSide(4); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase(Ipodleibie[i].cde_dt_shp.ToString(), font));//允出天數 // cell.HorizontalAlignment = Element.ALIGN_RIGHT;//.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.DisableBorderSide(1); // cell.DisableBorderSide(2); // cell.DisableBorderSide(4); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase("", font));//有效日期 // cell.DisableBorderSide(1); // cell.DisableBorderSide(4); // cell.Rowspan = 2; // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase(Ipodleibie[i].loc_id, font));//料位 // cell.DisableBorderSide(1); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase(Ipodleibie[i].spec, font));//規格 // cell.DisableBorderSide(1); // cell.DisableBorderSide(4); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase(Ipodleibie[i].qty_damaged.ToString(), font));//不允收數量 // cell.HorizontalAlignment = Element.ALIGN_RIGHT; // cell.DisableBorderSide(1); // cell.DisableBorderSide(4); // ptable.AddCell(cell); // cell = new PdfPCell(new Phrase(Ipodleibie[i].cde_dt_incr.ToString(), font));//有效期天數 // cell.HorizontalAlignment = Element.ALIGN_RIGHT; // cell.DisableBorderSide(1); // cell.DisableBorderSide(4); // ptable.AddCell(cell); // } // #endregion // //cell = new PdfPCell(new Phrase(" 數量合計:" + 5, font)); // //cell.Colspan = 2; // //cell.DisableBorderSide(1); // //cell.DisableBorderSide(8); // //cell.HorizontalAlignment = Element.ALIGN_CENTER; // //ptable.AddCell(cell); // //cell = new PdfPCell(new Phrase(" 採購金額:", font)); // //cell.Colspan = 2; // //cell.HorizontalAlignment = Element.ALIGN_CENTER; // //cell.DisableBorderSide(1); // //cell.DisableBorderSide(4); // //cell.DisableBorderSide(8); // //ptable.AddCell(cell); // //cell = new PdfPCell(new Phrase(" 稅額:", font)); // //cell.Colspan = 2; // //cell.HorizontalAlignment = Element.ALIGN_CENTER; // //cell.DisableBorderSide(1); // //cell.DisableBorderSide(4); // //ptable.AddCell(cell); // //cell = new PdfPCell(new Phrase(" 金額合計:", font)); // //cell.Colspan = 2; // //cell.DisableBorderSide(1); // //cell.DisableBorderSide(4); // //ptable.AddCell(cell); // //Sumtable.AddCell(ptable); // cb.EndText(); // // Sumtable.SpacingAfter = 0; // ptable.SpacingAfter = 250; // //Sumtable.WriteSelectedRows(0, -1, 60, 740, writer.DirectContent);//顯示的開始行,結束航(-1為所有)x坐標,y坐標 // document.Add(ptable); // document.NewPage(); // } // } // document.Close(); // writer.Resume(); // Response.Clear(); // Response.Charset = "gb2312"; // Response.ContentEncoding = System.Text.Encoding.UTF8; // Response.AddHeader("Content-Disposition", "attach-ment;filename=" + filename); // Response.WriteFile(newPDFName); // //} // #endregion // //} // } // catch (Exception ex) // { // //cb.EndText(); // //writer.Resume(); // //Response.Clear(); // } //} public void WritePdf() { PdfHelper pdf = new PdfHelper(); List<string> pdfList = new List<string>(); //float[] arrColWidth_pftable = new float[] { 30,100, 80, 60, 60, 60, 60 }; float[] arrColWidth = new float[] { 30, 100, 80, 60, 60, 60, 60 }; int index = 0; string newFileName = string.Empty; string newName = string.Empty; string json = string.Empty; IpodQuery ipod = new IpodQuery(); IpoQuery ipo = new IpoQuery(); if (!string.IsNullOrEmpty(Request.Params["Poid"])) { ipo.po_id = Request.Params["Poid"]; } if (!string.IsNullOrEmpty(Request.Params["Potype"])) { ipo.po_type = Request.Params["Potype"]; } if (!string.IsNullOrEmpty(Request.Params["start_time"])) { ipo.start_time = Convert.ToDateTime(Request.Params["start_time"].ToString()); } if (!string.IsNullOrEmpty(Request.Params["end_time"])) { ipo.end_time = Convert.ToDateTime(Request.Params["end_time"].ToString()); } if (!string.IsNullOrEmpty(Request.Params["freight"])) { ipo.freight = Convert.ToInt32(Request.Params["freight"].ToString()); } List<IpodQuery> ipodStore = new List<IpodQuery>(); List<IpoQuery> ipoStore = new List<IpoQuery>(); _ipoMgr = new IpoMgr(mySqlConnectionString); int totalCount = 0; ipo.IsPage = false; ipoStore = _ipoMgr.GetIpoList(ipo, out totalCount); //if (!string.IsNullOrEmpty(Request.Params["freight"])) //{ // if (Request.Params["freight"].ToString() != "0") // { // _ipodMgr = new IpodMgr(mySqlConnectionString); // List<IpoQuery> newstore = new List<IpoQuery>(); // foreach (IpoQuery item in ipoStore) // { // if (!string.IsNullOrEmpty(item.po_id)) // { // if (_ipodMgr.GetIpodfreight(item.po_id, Convert.ToInt32(Request.Params["freight"].ToString()))) // { // newstore.Add(item); // } // } // } // ipoStore = newstore; // } //} try { #region 採購單匯出 BaseFont bf = BaseFont.CreateFont("C:\\WINDOWS\\Fonts\\simsun.ttc,1", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED); iTextSharp.text.Font fontChinese = new iTextSharp.text.Font(bf, 8, iTextSharp.text.Font.UNDERLINE, iTextSharp.text.BaseColor.RED); iTextSharp.text.Font font = new iTextSharp.text.Font(bf, 12, iTextSharp.text.Font.BOLD, new iTextSharp.text.BaseColor(0, 0, 0));//黑 string filename = "採購單" + DateTime.Now.ToString("yyyyMMddHHmmss"); Document document = new Document(PageSize.A4); string newPDFName = Server.MapPath(excelPath) + filename; PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(newPDFName, FileMode.Create)); document.Open(); //運送方式 _paraMgr = new ParameterMgr(mySqlConnectionString); List<Parametersrc> parameterStore = new List<Parametersrc>(); parameterStore = _paraMgr.GetElementType("product_freight"); if (ipoStore.Count == 0) { } for (int a = 0; a < ipoStore.Count; a++)//循環單頭 { _ipodMgr = new IpodMgr(mySqlConnectionString); ipod = new IpodQuery(); ipod.po_id = ipoStore[a].po_id; ipodStore = new List<IpodQuery>(); ipodStore = _ipodMgr.GetIpodListExprot(ipod); Dictionary<int, List<IpodQuery>> product_freight_set_mapping = new Dictionary<int, List<IpodQuery>>(); #region 通過運送方式把採購單分開--一張採購單,分成常溫,冷凍等採購單 for (int i = 0; i < ipodStore.Count; i++)//通過運送方式保存到字典里 { ipodStore[i].spec = GetProductSpec(ipodStore[i].prod_id.ToString());//--------取值出錯了item_id----------- IupcQuery upc = new IupcQuery(); _IiupcMgr = new IupcMgr(mySqlConnectionString); upc.item_id = uint.Parse(ipodStore[i].prod_id);//--------取值出錯了item_id----------- //獲取國際條碼 List<IupcQuery> upcInternationalStore = new List<IupcQuery>(); upc.upc_type_flg = "1"; upcInternationalStore = _IiupcMgr.GetIupcByType(upc); //獲取店內條碼 List<IupcQuery> upcShopStore = new List<IupcQuery>(); upc.upc_type_flg = "3"; upcShopStore = _IiupcMgr.GetIupcByType(upc); if (upcInternationalStore.Count > 0) { ipodStore[i].upc_id_international = upcInternationalStore[0].upc_id; } if (upcShopStore.Count > 0) { ipodStore[i].upc_id_shop = upcShopStore[0].upc_id; } int freiset = ipodStore[i].product_freight_set; if (!product_freight_set_mapping.Keys.Contains(freiset)) { List<IpodQuery> s = new List<IpodQuery>(); product_freight_set_mapping.Add(freiset, s); } product_freight_set_mapping[freiset].Add(ipodStore[i]); } #endregion #region 針對匯出一個而無商品的pdf if (ipodStore.Count == 0) { #region 獲取供應商信息 Vendor vendor = new Vendor(); _vendorMgr = new VendorMgr(mySqlConnectionString); vendor.erp_id = ipoStore[a].vend_id; vendor = _vendorMgr.GetSingle(vendor); #endregion #region 採購單標題 PdfPTable ptable = new PdfPTable(7); ptable.WidthPercentage = 100;//表格寬度 font = new iTextSharp.text.Font(bf, 10, iTextSharp.text.Font.NORMAL, new iTextSharp.text.BaseColor(0, 0, 0));//黑 ptable.SetTotalWidth(arrColWidth); PdfPCell cell = new PdfPCell(); cell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(bf, 15))); cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左 cell.Colspan = 2; cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(4); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase(" 吉甲地好市集股份有限公司", new iTextSharp.text.Font(bf, 15))); cell.VerticalAlignment = Element.ALIGN_CENTER;//字體水平居左 cell.Colspan = 5; cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(4); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(bf, 12))); cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左 cell.Colspan = 3; cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(4); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("採購單" + "-" + ipoStore[a].po_type_desc, new iTextSharp.text.Font(bf, 12))); cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左 cell.Colspan = 4; cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(4); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("公司電話:", new iTextSharp.text.Font(bf, 8))); cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左 cell.Colspan = 6; cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(4); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("公司傳真:", new iTextSharp.text.Font(bf, 8))); cell.VerticalAlignment = Element.ALIGN_RIGHT;//字體水平居右 cell.Colspan = 1; cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(4); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("製造日期:" + DateTime.Now.ToString("yyyy/MM/dd"), new iTextSharp.text.Font(bf, 8))); cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左 cell.Colspan = 3; cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(4); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(bf, 8))); cell.VerticalAlignment = Element.ALIGN_RIGHT;//字體水平居右 cell.Colspan = 4; cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(4); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(bf, 8))); cell.VerticalAlignment = Element.ALIGN_RIGHT;//字體水平居右 cell.Colspan = 7; cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(4); cell.DisableBorderSide(8); ptable.AddCell(cell); cell.UseAscender = true; cell.HorizontalAlignment = Element.ALIGN_CENTER;//字體垂直居中 cell.VerticalAlignment = Element.ALIGN_MIDDLE;//字體水平居中 cell.BorderWidth = 0.1f; cell.BorderColor = new BaseColor(0, 0, 0); #endregion #region 上部分 cell = new PdfPCell(new Phrase("採購單別:" + ipoStore[a].po_type, font)); cell.Colspan = 2; cell.DisableBorderSide(2); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("交易幣別:" + "世界貨幣", font)); cell.Colspan = 1; cell.DisableBorderSide(2); cell.DisableBorderSide(4); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("匯率:" + "浮動", font)); cell.Colspan = 2; cell.DisableBorderSide(2); cell.DisableBorderSide(4); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("運輸方式:", font)); cell.Colspan = 2; cell.DisableBorderSide(2); cell.DisableBorderSide(4); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("商品是新品么?:", font));//新品 cell.Colspan = 2; cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("所在層:", font)); cell.Colspan = 1; cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(4); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("採購單(" + ipoStore[a].po_type_desc + ")", font)); cell.Colspan = 2; cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(4); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("預約到貨日期:", font)); cell.Colspan = 2; cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(4); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("採購單號:" + ipoStore[a].po_id, font)); cell.Colspan = 2; cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("課稅別:", font)); cell.Colspan = 1; cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(4); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("營業稅率:", font)); cell.Colspan = 2; cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(4); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("價格條件:", font)); cell.Colspan = 2; cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(4); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("單據日期:" + DateTime.Now.ToString("yyyy/MM/dd"), font)); cell.Colspan = 2; cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("採購人員:" + ipoStore[a].buyer, font)); cell.Colspan = 1; cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(4); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase((System.Web.HttpContext.Current.Session["caller"] as Caller).user_username, font)); cell.Colspan = 2; cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(4); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("廠別代號:", font)); cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(4); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("gigade(讀取)", font)); cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(4); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("廠商代號:" + ipoStore[a].vend_id, font)); cell.Colspan = 2; cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("", font)); cell.Colspan = 1; cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(4); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("付款條件(讀取)", font)); cell.Colspan = 2; cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(4); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("月結N天(讀取):", font)); cell.Colspan = 2; cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(4); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("廠商全名(讀取):", font)); cell.Colspan = 5; cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("備註:", font)); cell.Colspan = 2; cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(4); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("廠商地址:", font)); cell.Colspan = 7; cell.DisableBorderSide(1); cell.DisableBorderSide(2); ptable.AddCell(cell); cell = new PdfPCell(new Phrase(" ", font)); cell.Colspan = 7; cell.DisableBorderSide(1); cell.DisableBorderSide(2); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("聯絡人(讀取):", font)); cell.Colspan = 2; cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("廠商電話:", font)); cell.Colspan = 1; cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(4); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("廠商傳真:", font)); cell.Colspan = 4; cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(4); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("送貨地址(讀取):", font)); cell.Colspan = 7; cell.DisableBorderSide(1); cell.DisableBorderSide(2); ptable.AddCell(cell); cell = new PdfPCell(new Phrase(" ", font)); cell.Colspan = 7; cell.DisableBorderSide(1); cell.DisableBorderSide(2); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("預計送貨日期(讀取):", font)); cell.Colspan = 7; cell.DisableBorderSide(1); cell.DisableBorderSide(2); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("配送聯絡人(讀取):", font)); cell.Colspan = 2; cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("配送電話(讀取):", font)); cell.Colspan = 1; cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(4); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("配送傳真(讀取):", font)); cell.Colspan = 4; cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(4); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("處理備註:", font)); cell.Colspan = 7; cell.DisableBorderSide(1); cell.DisableBorderSide(2); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("運送備註:", font)); cell.Colspan = 7; cell.DisableBorderSide(1); ptable.AddCell(cell); #endregion cell = new PdfPCell(new Phrase("此採購單商品不存在!", font)); cell.Colspan = 7; ptable.AddCell(cell); newFileName = newPDFName + "_part" + index++ + "." + "pdf"; pdf.ExportDataTableToPDF(newFileName, ptable, "", ""); pdfList.Add(newFileName); document.Add(ptable); document.NewPage(); } #endregion foreach (int key in product_freight_set_mapping.Keys) { #region 取出運送方式 string procduct_freight = ""; for (int i = 0; i < parameterStore.Count; i++) { if (key.ToString() == parameterStore[i].ParameterCode) { procduct_freight = parameterStore[i].parameterName; } } #endregion #region 獲取供應商信息 Vendor vendor = new Vendor(); _vendorMgr = new VendorMgr(mySqlConnectionString); vendor.erp_id = ipoStore[a].vend_id; vendor = _vendorMgr.GetSingle(vendor); #endregion #region 採購單標題 PdfPTable ptable = new PdfPTable(7); ptable.WidthPercentage = 100;//表格寬度 font = new iTextSharp.text.Font(bf, 10, iTextSharp.text.Font.NORMAL, new iTextSharp.text.BaseColor(0, 0, 0));//黑 ptable.SetTotalWidth(arrColWidth); PdfPCell cell = new PdfPCell(); cell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(bf, 15))); cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左 cell.Colspan = 2; cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(4); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase(" 吉甲地好市集股份有限公司", new iTextSharp.text.Font(bf, 15))); cell.VerticalAlignment = Element.ALIGN_CENTER;//字體水平居左 cell.Colspan = 5; cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(4); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(bf, 12))); cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左 cell.Colspan = 3; cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(4); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase(" 採購單" + "-" + ipoStore[a].po_type_desc, new iTextSharp.text.Font(bf, 12))); cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左 cell.Colspan = 4; cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(4); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("公司電話:", new iTextSharp.text.Font(bf, 8))); cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左 cell.Colspan = 6; cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(4); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("公司傳真:", new iTextSharp.text.Font(bf, 8))); cell.VerticalAlignment = Element.ALIGN_RIGHT;//字體水平居右 cell.Colspan = 1; cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(4); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("製造日期:" + DateTime.Now.ToString("yyyy/MM/dd"), new iTextSharp.text.Font(bf, 8))); cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左 cell.Colspan = 3; cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(4); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(bf, 8))); cell.VerticalAlignment = Element.ALIGN_RIGHT;//字體水平居右 cell.Colspan = 4; cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(4); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(bf, 8))); cell.VerticalAlignment = Element.ALIGN_RIGHT;//字體水平居右 cell.Colspan = 7; cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(4); cell.DisableBorderSide(8); ptable.AddCell(cell); cell.UseAscender = true; cell.HorizontalAlignment = Element.ALIGN_CENTER;//字體垂直居中 cell.VerticalAlignment = Element.ALIGN_MIDDLE;//字體水平居中 cell.BorderWidth = 0.1f; cell.BorderColor = new BaseColor(0, 0, 0); #endregion #region 上部分 cell = new PdfPCell(new Phrase("採購單別:" + ipoStore[a].po_type, font)); cell.Colspan = 2; cell.DisableBorderSide(2); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("交易幣別:" + "世界貨幣", font)); cell.Colspan = 1; cell.DisableBorderSide(2); cell.DisableBorderSide(4); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("匯率:" + "浮動", font)); cell.Colspan = 2; cell.DisableBorderSide(2); cell.DisableBorderSide(4); cell.DisableBorderSide(8); ptable.AddCell(cell); if (procduct_freight != "常溫" && procduct_freight != "冷凍") { ; } cell = new PdfPCell(new Phrase("運輸方式:" + procduct_freight, font)); cell.Colspan = 2; cell.DisableBorderSide(2); cell.DisableBorderSide(4); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("商品是新品么?:", font));//新品 cell.Colspan = 2; cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("所在層:", font)); cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(4); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("採購單(" + ipoStore[a].po_type_desc + ")", font)); cell.Colspan = 2; cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(4); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("預約到貨日期:", font)); cell.Colspan = 2; cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(4); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("採購單號:" + ipoStore[a].po_id, font)); cell.Colspan = 2; cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("課稅別:", font)); cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(4); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("營業稅率:", font)); cell.Colspan = 2; cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(4); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("價格條件:", font)); cell.Colspan = 2; cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(4); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("單據日期:" + DateTime.Now.ToString("yyyy/MM/dd"), font)); cell.Colspan = 2; cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("採購人員:", font)); //cell = new PdfPCell(new Phrase("採購人員:" + ipoStore[a].buyer, font)); cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(4); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase((System.Web.HttpContext.Current.Session["caller"] as Caller).user_username, font)); cell.Colspan = 2; cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(4); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("廠別代號:", font)); cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(4); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("gigade(讀取)", font)); cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(4); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("廠商代號:" + ipoStore[a].vend_id, font)); cell.Colspan = 2; cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase(vendor == null ? "暫無此信息" : vendor.vendor_name_simple, font)); cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(4); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("付款條件(讀取)", font)); cell.Colspan = 2; cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(4); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("月結N天(讀取):", font)); cell.Colspan = 2; cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(4); ptable.AddCell(cell); cell = new PdfPCell(new Phrase(vendor == null ? "廠商全名(讀取):暫無此信息" : "廠商全名:" + vendor.vendor_name_full, font)); cell.Colspan = 5; cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("備註:", font)); cell.Colspan = 2; cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(4); ptable.AddCell(cell); cell = new PdfPCell(new Phrase(vendor == null ? "廠商地址:暫無此信息" : "廠商地址:" + vendor.company_address, font)); cell.Colspan = 7; cell.DisableBorderSide(1); cell.DisableBorderSide(2); ptable.AddCell(cell); cell = new PdfPCell(new Phrase(" ", font)); cell.Colspan = 7; cell.DisableBorderSide(1); cell.DisableBorderSide(2); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("聯絡人(讀取):", font)); cell.Colspan = 2; cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase(vendor == null ? "廠商電話:暫無此信息" : "廠商電話:" + vendor.company_phone, font)); cell.Colspan = 1; cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(4); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase(vendor == null ? "廠商傳真:暫無此信息" : "廠商傳真:" + vendor.company_fax, font)); cell.Colspan = 4; cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(4); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("送貨地址(讀取):", font)); cell.Colspan = 7; cell.DisableBorderSide(1); cell.DisableBorderSide(2); ptable.AddCell(cell); cell = new PdfPCell(new Phrase(" ", font)); cell.Colspan = 7; cell.DisableBorderSide(1); cell.DisableBorderSide(2); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("預計送貨日期(讀取):", font)); cell.Colspan = 7; cell.DisableBorderSide(1); cell.DisableBorderSide(2); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("配送聯絡人(讀取):", font)); cell.Colspan = 2; cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("配送電話(讀取):", font)); cell.Colspan = 1; cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(4); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("配送傳真(讀取):", font)); cell.Colspan = 4; cell.DisableBorderSide(1); cell.DisableBorderSide(2); cell.DisableBorderSide(4); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("處理備註:", font)); cell.Colspan = 7; cell.DisableBorderSide(1); cell.DisableBorderSide(2); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("運送備註:", font)); cell.Colspan = 7; cell.DisableBorderSide(1); ptable.AddCell(cell); #endregion #region 下面表格頭部 cell = new PdfPCell(new Phrase("序號", font)); cell.VerticalAlignment = Element.ALIGN_MIDDLE; //cell.DisableBorderSide(2); cell.Rowspan = 3; ptable.AddCell(cell); cell = new PdfPCell(new Phrase("國際條碼", font)); cell.DisableBorderSide(2); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("品號", font)); cell.DisableBorderSide(2); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("採購數量", font)); cell.DisableBorderSide(2); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("允收天數", font)); cell.DisableBorderSide(2); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("製造日期", font)); cell.DisableBorderSide(2); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("備註", font)); cell.DisableBorderSide(2); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("供應商店內碼", font)); cell.DisableBorderSide(1); cell.DisableBorderSide(2); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("品名", font)); cell.DisableBorderSide(1); cell.DisableBorderSide(2); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("允收數量", font)); cell.DisableBorderSide(1); cell.DisableBorderSide(2); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("允出天數", font)); cell.DisableBorderSide(1); cell.DisableBorderSide(2); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("有效日期", font)); cell.DisableBorderSide(1); cell.DisableBorderSide(2); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("", font)); cell.DisableBorderSide(1); cell.DisableBorderSide(2); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("料位", font)); cell.DisableBorderSide(1); cell.DisableBorderSide(2); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("規格", font)); cell.DisableBorderSide(1); cell.DisableBorderSide(2); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("不允收數量", font)); cell.DisableBorderSide(1); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("有效期天數", font)); cell.DisableBorderSide(1); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("", font)); cell.DisableBorderSide(1); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("", font)); cell.DisableBorderSide(1); ptable.AddCell(cell); #endregion _ipodMgr = new IpodMgr(mySqlConnectionString); ipod = new IpodQuery(); ipod.po_id = ipoStore[a].po_id; ipod.IsPage = false; ipodStore = new List<IpodQuery>(); ipodStore = _ipodMgr.GetIpodList(ipod, out totalCount); List<IpodQuery> Ipodleibie = new List<IpodQuery>(); Ipodleibie.AddRange(product_freight_set_mapping[key]); #region 循環讀取數據填入表格 DataTable Ipod_dt = new DataTable(); Ipod_dt.Columns.Add("序號", typeof(string)); Ipod_dt.Columns.Add("國際條碼", typeof(string)); Ipod_dt.Columns.Add("品號", typeof(string)); Ipod_dt.Columns.Add("採購數量", typeof(string)); Ipod_dt.Columns.Add("允收天數", typeof(string)); Ipod_dt.Columns.Add("製造日期", typeof(string)); Ipod_dt.Columns.Add("備註", typeof(string)); Ipod_dt.Columns.Add("Empty_1", typeof(string)); Ipod_dt.Columns.Add("供應商店內碼", typeof(string)); Ipod_dt.Columns.Add("品名", typeof(string)); Ipod_dt.Columns.Add("允收數量", typeof(string)); Ipod_dt.Columns.Add("允出天數", typeof(string)); Ipod_dt.Columns.Add("有效日期", typeof(string)); Ipod_dt.Columns.Add("Empty_3", typeof(string)); Ipod_dt.Columns.Add("Empty_4", typeof(string)); Ipod_dt.Columns.Add("料位", typeof(string)); Ipod_dt.Columns.Add("規格", typeof(string)); Ipod_dt.Columns.Add("不允收數量", typeof(string)); Ipod_dt.Columns.Add("有效期天數", typeof(string)); Ipod_dt.Columns.Add("Empty_5", typeof(string)); Ipod_dt.Columns.Add("Empty_6", typeof(string)); for (int i = 0; i < Ipodleibie.Count; i++) { DataRow newRow = Ipod_dt.NewRow(); newRow["國際條碼"] = Ipodleibie[i].upc_id_international; newRow["品號"] = Ipodleibie[i].Erp_Id.ToString(); newRow["採購數量"] = Ipodleibie[i].qty_ord.ToString(); newRow["允收天數"] = Ipodleibie[i].cde_dt_var.ToString(); newRow["製造日期"] = ""; newRow["備註"] = ""; newRow["Empty_1"] = (i + 1).ToString(); //序號 newRow["供應商店內碼"] = Ipodleibie[i].upc_id_shop; newRow["品名"] = Ipodleibie[i].product_name; newRow["允收數量"] = Ipodleibie[i].qty_claimed.ToString(); newRow["允出天數"] = Ipodleibie[i].cde_dt_shp.ToString(); newRow["有效日期"] = ""; newRow["Empty_3"] = ""; newRow["Empty_4"] = ""; newRow["料位"] = Ipodleibie[i].loc_id; newRow["規格"] = Ipodleibie[i].spec; newRow["不允收數量"] = Ipodleibie[i].qty_damaged.ToString(); newRow["有效期天數"] = Ipodleibie[i].cde_dt_incr.ToString(); newRow["Empty_5"] = ""; newRow["Empty_6"] = ""; Ipod_dt.Rows.Add(newRow); } #endregion //////// newFileName = newPDFName + "_part" + index++ + "." + "pdf"; pdf.ExportDataTableToPDF(Ipod_dt, false, newFileName, arrColWidth, ptable, "", "", 7, 7);/*第一7是列,第二個是行*/ pdfList.Add(newFileName); } } newFileName = newPDFName + "." + "pdf"; pdf.MergePDF(pdfList, newFileName); Response.Clear(); Response.Charset = "gb2312"; Response.ContentEncoding = System.Text.Encoding.UTF8; Response.AddHeader("Content-Disposition", "attach-ment;filename=" + filename + ".pdf"); Response.WriteFile(newFileName); //} #endregion } catch (Exception ex) { //cb.EndText(); //writer.Resume(); //Response.Clear(); } }
public void PrepareData(List<CombinationExcel> source) { if (source != null) { source.ForEach(m => m.Validate()); var parents = source.Where(m => m.combination.Trim() != "299" && string.IsNullOrEmpty(m.msg)); _productMgr = new ProductMgr(strConn); _productItemMgr = new ProductItemMgr(strConn); _vendorMgr = new VendorMgr(strConn); _vendorBrandMgr = new VendorBrandMgr(strConn); _siteMgr = new SiteMgr(strConn); _productMigrationMgr = new ProductMigrationMgr(strConn); _productComboMgr = new ProductComboMgr(strConn); _cateMgr = new ProductCategoryMgr(strConn); _productCategorySetMgr = new ProductCategorySetMgr(strConn); _productNoticeSetMgr = new ProductNoticeSetMgr(strConn); _productTagSetMgr = new ProductTagSetMgr(strConn); _productPictureMgr = new ProductPictureMgr(strConn); _productStatusHistoryMgr = new ProductStatusHistoryMgr(strConn); foreach (var parent in parents) { form.change(1); uint product_id = uint.Parse(parent.product_id); #region Product ProductMigrationMap prodMigra = _productMigrationMgr.GetSingle(new ProductMigrationMap { temp_id = parent.is_exist.ToUpper().Trim().Equals("OLD") ? parent.product_id : parent.temp_id }); if (prodMigra != null) { parent.msg = "此記錄暫時編號(temp_id)已經存在;"; continue; } Product newPro = parent.is_exist.ToUpper().Trim() == "OLD" ? _productMgr.Query(new Product { Product_Id = product_id }).FirstOrDefault() : new Product(); if (newPro == null) { parent.msg = "商品不存在"; continue; } newPro.Product_Name = parent.product_name.Trim(); VendorBrand brand = _vendorBrandMgr.GetProductBrand(new VendorBrand { Brand_Name = parent.brand_name.Trim() }); if (brand == null) { parent.msg = "品牌不存在"; continue; } newPro.Brand_Id = brand.Brand_Id; switch (parent.combination.Trim()) { case "2": newPro.Combination = 2; break; case "3": newPro.Combination = 3; break; case "4": newPro.Combination = 4; break; default: break; } switch (parent.status.Trim().ToUpper()) { case "SAME": break; case "ON": newPro.Product_Status = 5; break; case "OFF": newPro.Product_Status = 6; break; case "NEW": newPro.Product_Status = 0; break; default: break; } newPro.Price_type = 1; newPro.Product_Spec = 0; newPro.Spec_Title_1 = string.Empty; newPro.Spec_Title_2 = string.Empty; newPro.Ignore_Stock = 0;// parent.ignore_stock.ToUpper().Trim() == "Y" ? 1 : 0; newPro.Shortage = 0;// parent.shortage.ToUpper().Trim() == "Y" ? 1 : 0; newPro.Cate_Id = parent.cate_id.Trim(); var vendor = _vendorMgr.GetSingle(new Vendor { vendor_id = brand.Vendor_Id }); if (vendor == null) { parent.msg = "供應商不存在"; continue; } newPro.user_id = vendor.product_manage; if (!string.IsNullOrEmpty(parent.service_fee)) { uint bag_check_money=0; uint.TryParse(parent.service_fee,out bag_check_money); newPro.Bag_Check_Money = bag_check_money; } #endregion bool result = true; ArrayList sqls = new ArrayList(); #region PriceMaster Site site = _siteMgr.Query(new Site { Site_Name = parent.site.Trim() }).FirstOrDefault(); if (site == null) { parent.msg = "價格檔站臺不存在"; result = false; break; } List<PriceMaster> priceMasters = new List<PriceMaster>(); //首先默認加入一筆吉甲地站臺 PriceMaster newPriceMaster = new PriceMaster { site_id = 1, user_level = 1, same_price = 1, accumulated_bonus = 1, default_bonus_percent = 1, bonus_percent = 1 }; newPriceMaster.product_name = newPro.Product_Name; newPriceMaster.price_status = 1; var item = _productItemMgr.Query(new ProductItem { Product_Id = newPro.Product_Id }).FirstOrDefault(); if (item == null) { parent.msg = "商品細項不存在"; continue; } #region 成本 int cost = 0; if (!string.IsNullOrEmpty(parent.cost)) { int.TryParse(parent.cost, out cost); } else { cost = Convert.ToInt32(item.Item_Cost); } newPriceMaster.cost = cost; #endregion #region 售價 int price = 0; if (!string.IsNullOrEmpty(parent.price)) { int.TryParse(parent.price, out price); } else { price = Convert.ToInt32(item.Item_Money); } newPriceMaster.price = price; #endregion newPriceMaster.event_price = Convert.ToInt32(item.Event_Item_Money); newPriceMaster.event_start = item.Event_Product_Start; newPriceMaster.event_end = item.Event_Product_End; priceMasters.Add(newPriceMaster); if (site.Site_Id != 1) { //如果站臺不是吉甲地就把吉甲地站臺的價格狀態改為4(下架) priceMasters[0].price_status = 4; //再加入非吉甲地站臺 newPriceMaster = new PriceMaster { site_id = site.Site_Id, user_level = 1, same_price = 1, accumulated_bonus = 1, default_bonus_percent = 1, bonus_percent = 1 }; newPriceMaster.product_name = newPro.Product_Name; newPriceMaster.price_status = 1; #region 成本 cost = 0; if (!string.IsNullOrEmpty(parent.cost)) { int.TryParse(parent.cost, out cost); } else { cost = Convert.ToInt32(item.Item_Cost); } newPriceMaster.cost = cost; #endregion #region 售價 price = 0; if (!string.IsNullOrEmpty(parent.price)) { int.TryParse(parent.price, out price); } else { price = Convert.ToInt32(item.Item_Money); } newPriceMaster.price = price; #endregion newPriceMaster.event_price = Convert.ToInt32(item.Event_Item_Money); newPriceMaster.event_start = item.Event_Product_Start; newPriceMaster.event_end = item.Event_Product_End; priceMasters.Add(newPriceMaster); } #region 其他站臺價格 var child = source.Where(m => m.combination.Trim() == "299" && m.formula.ToUpper().Trim() == parent.temp_id.ToUpper().Trim() && string.IsNullOrEmpty(m.msg) && m.new_old.ToUpper().Trim() == "NEW" && m.formula.ToUpper().Trim().StartsWith("P")); if (child != null) { foreach (var c in child) { item = _productItemMgr.Query(new ProductItem { Product_Id = uint.Parse(c.product_id) }).FirstOrDefault(); if (item == null) { c.msg = "價格檔商品細項不存在"; result = false; break; } site = _siteMgr.Query(new Site { Site_Name = c.site.Trim() }).FirstOrDefault(); if (site == null) { c.msg = "站臺不存在"; result = false; break; } if (priceMasters.Exists(m => m.site_id == site.Site_Id)) { c.msg = "站臺重複"; result = false; break; } newPriceMaster = new PriceMaster { user_level = 1, same_price = 1, accumulated_bonus = 1, default_bonus_percent = 1, bonus_percent = 1 }; newPriceMaster.product_name = c.product_name.Trim(); newPriceMaster.site_id = site.Site_Id; newPriceMaster.price_status = 1; #region 成本 cost = 0; if (!string.IsNullOrEmpty(c.cost)) { int.TryParse(c.cost, out cost); } else { cost = Convert.ToInt32(item.Item_Cost); } newPriceMaster.cost = cost; #endregion #region 售價 price = 0; if (!string.IsNullOrEmpty(c.price)) { int.TryParse(c.price, out price); } else { price = Convert.ToInt32(item.Item_Money); } newPriceMaster.price = price; #endregion newPriceMaster.event_price = Convert.ToInt32(item.Event_Item_Money); newPriceMaster.event_start = item.Event_Product_Start; newPriceMaster.event_end = item.Event_Product_End; priceMasters.Add(newPriceMaster); if (site.Site_Name.Trim().ToLower() == "chinatrust") { ArrayList category_set = CategorySet(c, brand.Brand_Id); if (category_set == null) { result = false; break; } else { sqls.AddRange(category_set); } } } if (!result) continue; } #endregion #endregion #region ProductCombo string[] strIds = parent.formula.IndexOf(",") != -1 ? parent.formula.Trim().Split(',') : new string[] { parent.formula.Trim() }; string[] nums = parent.number.IndexOf(",") != -1 ? parent.number.Trim().Split(',') : new string[] { parent.number.Trim() }; List<Product> children = new List<Product>(); ProductCombo tmp; for (int i = 0; i < strIds.Length; i++) { tmp = new ProductCombo(); if (parent.combination.Trim() != "2") { tmp.Buy_Limit = parent.buylimit.Trim().ToUpper() == "Y" ? 1 : 0; } else { tmp.S_Must_Buy = int.Parse(i >= nums.Length ? nums[nums.Length - 1] : nums[i]); } if (parent.combination.Trim() == "3")//為3任選時 數量為G_Must_Buy { tmp.G_Must_Buy = int.Parse(nums[0]); } switch (parent.new_old.Trim().ToUpper()) { case "NEW": var map = _productMigrationMgr.GetSingle(new ProductMigrationMap { temp_id = strIds[i] }); if (map == null) { parent.msg = "原料編號未找到對應"; break; } tmp.Child_Id = Convert.ToInt32(map.product_id); break; case "OLD": tmp.Child_Id = int.Parse(strIds[i]); break; case "BOTH": if (strIds[i].ToUpper().Trim().StartsWith("P")) { var tMap = _productMigrationMgr.GetSingle(new ProductMigrationMap { temp_id = strIds[i] }); if (tMap == null) { parent.msg = "原料編號未找到對應"; break; } tmp.Child_Id = Convert.ToInt32(tMap.product_id); } else { tmp.Child_Id = int.Parse(strIds[i]); } break; } if (tmp.Child_Id == 0) { result = false; break; } else { Product tmpPro = _productMgr.Query(new Product { Product_Id = Convert.ToUInt32(tmp.Child_Id) }).FirstOrDefault(); if (tmpPro == null) { parent.msg = strIds[i] + "不存在"; result = false; break; } if (tmpPro.Product_Status == 0 || tmpPro.Product_Status ==1) { parent.msg = strIds[i] + "商品状态不為新增、申請審核"; result = false; break; } if (tmpPro.Combination != 0 && tmpPro.Combination != 1) { parent.msg = strIds[i] + "不是單一商品"; result = false; break; } switch (newPro.Product_Freight_Set) { case 1: case 3: if (tmpPro.Product_Freight_Set != 1 && tmpPro.Product_Freight_Set != 3) { parent.msg = strIds[i] + "运费模式与主商品不匹配"; result = false; } break; case 2: case 4: if (tmpPro.Product_Freight_Set != 2 && tmpPro.Product_Freight_Set != 4) { parent.msg = strIds[i] + "运费模式与主商品不匹配"; result = false; } break; case 5: case 6: if (tmpPro.Product_Freight_Set != 5 && tmpPro.Product_Freight_Set != 6) { parent.msg = strIds[i] + "运费模式与主商品不匹配"; result = false; } break; default: break; } if (!result) break; children.Add(tmpPro); } sqls.Add(_productComboMgr.Save(tmp)); } if (!result) continue; #endregion #region product_category_set if (!string.IsNullOrEmpty(parent.display)) { ArrayList category_set = CategorySet(parent, brand.Brand_Id); if (category_set == null) continue; else { foreach (var set in category_set) { if (!sqls.Contains(set)) { sqls.Add(set); } } } } else { sqls.Add(_productCategorySetMgr.SaveFromOtherPro(new ProductCategorySet { Product_Id = product_id })); } #endregion #region product_migration_map ProductMigrationMap pMap = new ProductMigrationMap(); if (parent.is_exist.ToUpper().Equals("OLD")) { pMap.temp_id = parent.product_id; } else if (parent.is_exist.ToUpper().Equals("NEW")) { pMap.temp_id = parent.temp_id; } sqls.Add(_productMigrationMgr.SaveNoPrid(pMap)); #endregion #region notice tag picture sqls.Add(_productNoticeSetMgr.SaveFromOtherPro(new ProductNoticeSet { product_id = product_id })); sqls.Add(_productTagSetMgr.SaveFromOtherPro(new ProductTagSet { product_id = product_id })); sqls.Add(_productPictureMgr.SaveFromOtherPro(new ProductPicture { product_id = Convert.ToInt32(product_id) })); sqls.Add(_productStatusHistoryMgr.SaveNoProductId(new ProductStatusHistory { type = 7, product_status = Convert.ToInt32(newPro.Product_Status) })); #endregion string str = string.Empty; if (_productMgr.ProductMigration(newPro, priceMasters, null, null, sqls, null)) { str = "匯入成功"; } else { str = "保存至數據庫失敗"; } parent.msg = str; source.FindAll(m => m.combination.Trim() == "299" && m.formula.ToUpper().Trim() == parent.temp_id.ToUpper().Trim() && string.IsNullOrEmpty(m.msg) && m.new_old.ToUpper().Trim() == "NEW" && m.formula.ToUpper().Trim().StartsWith("P")).ForEach(m => m.msg = str); } #region 其他站臺價格 var pChild = source.Where(m => m.combination.Trim() == "299" && m.new_old.ToUpper().Trim() == "OLD" && string.IsNullOrEmpty(m.msg)); if (pChild != null) { ProductItem item; PriceMaster newPriceMaster; Site site; _priceMasterMgr = new PriceMasterMgr(strConn); foreach (var c in pChild) { ProductMigrationMap prodMigra = _productMigrationMgr.GetSingle(new ProductMigrationMap { temp_id = c.formula.Trim() }); if (prodMigra == null) { c.msg = "原料編號對照不存在"; continue; } item = _productItemMgr.Query(new ProductItem { Product_Id = uint.Parse(c.product_id) }).FirstOrDefault(); if (item == null) { c.msg = "價格檔商品細項不存在"; continue; } site = _siteMgr.Query(new Site { Site_Name = c.site.Trim() }).FirstOrDefault(); if (site == null) { c.msg = "站臺不存在"; continue; } newPriceMaster = new PriceMaster { user_level = 1, same_price = 1, accumulated_bonus = 1, default_bonus_percent = 1, bonus_percent = 1 }; newPriceMaster.product_name = c.product_name.Trim(); newPriceMaster.product_id = prodMigra.product_id; newPriceMaster.child_id = Convert.ToInt32(prodMigra.product_id); newPriceMaster.site_id = site.Site_Id; newPriceMaster.price_status = 1; #region 成本 int cost = 0; if (!string.IsNullOrEmpty(c.cost)) { int.TryParse(c.cost, out cost); } else { cost = Convert.ToInt32(item.Item_Cost); } newPriceMaster.cost = cost; #endregion #region 售價 int price = 0; if (!string.IsNullOrEmpty(c.price)) { int.TryParse(c.price, out price); } else { price = Convert.ToInt32(item.Item_Money); } newPriceMaster.price = price; #endregion newPriceMaster.event_price = Convert.ToInt32(item.Event_Item_Money); newPriceMaster.event_start = item.Event_Product_Start; newPriceMaster.event_end = item.Event_Product_End; ArrayList category_set = new ArrayList(); if (site.Site_Name.Trim().ToLower() == "chinatrust") { Product pro= _productMgr.Query(new Product { Product_Id = item.Product_Id }).FirstOrDefault(); if (pro == null) { c.msg = "商品不存在"; continue; } #region 更新該站臺商品的 product_category_set bool result = true; System.Text.RegularExpressions.Regex regx = new System.Text.RegularExpressions.Regex("^[0-9]*$"); string[] cateArray = c.display.Split(','); foreach (string strcate in cateArray) { if (!string.IsNullOrEmpty(strcate)) { if (regx.IsMatch(strcate)) { ProductCategory query = _cateMgr.QueryAll(new ProductCategory { category_id = uint.Parse(strcate) }).FirstOrDefault(); if (query == null || strcate.Equals("0")) { c.msg = "display:" + strcate + " 不存在;"; result = false; break; } else { ProductCategorySet category = new ProductCategorySet { Brand_Id = pro.Brand_Id, Category_Id = uint.Parse(strcate), Product_Id = prodMigra.product_id }; if (_productCategorySetMgr.Query(category).FirstOrDefault() == null) { category_set.Add(_productCategorySetMgr.Save(category)); } else { c.msg = "display:" + strcate + " 已存在;"; result = false; break; } } } else { c.msg = "display:" + strcate + " 格式不正確 "; result = false; break; } } } if (!result) continue; #endregion } string str = string.Empty; if (_priceMasterMgr.Save(newPriceMaster, null, category_set, ref str) > 0) { c.msg = "匯入成功"; } else { c.msg = string.IsNullOrEmpty(str) ? "保存至數據庫失敗" : str; } } } #endregion } }
public ActionResult Login() { string code = string.Empty; string challenge_id = string.Empty; string challenge_key = string.Empty; object notice = new object(); if (string.IsNullOrEmpty(Request.Params["txtEmail"])) { notice = "{result:'Notice',msg:'" + Resources.Login.NOTICE_NO_EMAIL + "'}"; ViewBag.notice = notice; return View("Index"); } string IsRemember = Request.Params["chkRememberEmail"] != null ? Request.Params["chkRememberEmail"] : "false"; string email = Request.Params["txtEmail"].Trim(); string passwd = Request.Params["passwd"].Trim(); int CookieExpireTime = 10; ViewBag.LoginEmail = null; _vendorImp = new VendorMgr(connectionString); //Caller caller = null; BLL.gigade.Model.Vendor vendor = null; //記錄/清空cookie BLL.gigade.Common.CommonFunction.Cookie_Set("vendor", "email", email, IsRemember, CookieExpireTime); UserLoginAttemptsMgr ulaMgr = new UserLoginAttemptsMgr(connectionString); //if (!Regex.IsMatch(email, @"^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$")) if (!Regex.IsMatch(email, @"[\w|-]+@[-|\w]*[-|\.|\w]*\.\w")) { notice = "{result:'Notice',msg:'" + Resources.Login.NOTICE_EMAIL_FORMAT_ERROR + "'}"; ViewBag.notice = notice; if (IsRemember == "true") { ViewBag.LoginEmail = email; } return View("Index"); } if (passwd == "") { notice = "{result:'Notice',msg:'" + Resources.Login.NOTICE_NO_PASSWD + "'}"; ViewBag.notice = notice; if (IsRemember == "true") { ViewBag.LoginEmail = email; } return View("Index"); } if (!string.IsNullOrEmpty(Request.Params["CheckCode"])) { code = Request.Params["CheckCode"].ToString().Trim(); } if (Session["code"] != null) { if (Session["code"].ToString() != code) { string message = "{result:'Notice',msg:'驗證碼輸入錯誤'}"; ViewBag.notice = message; ViewBag.Email = Request.Params["txtEmail"]; ViewBag.Password = Request.Params["passwd"]; return View("Index"); } } try { BLL.gigade.Model.Vendor query = new BLL.gigade.Model.Vendor(); query.vendor_email = email; vendor = _vendorImp.Login(query); } 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); } if (vendor == null) { notice = "{result:'Error',msg:'" + Resources.Login.ERROR_EMAIL_PASSWD_ERROR + "'}"; ViewBag.notice = notice; if (IsRemember == "true") { ViewBag.LoginEmail = email; } UserLoginAttempts ula = new UserLoginAttempts(); ula.login_mail = email; ula.login_ipfrom = CommonFunction.GetIP4Address(Request.UserHostAddress.ToString()); ula.login_type = 5; ulaMgr.Insert(ula); return View("Index"); } else { if (vendor.vendor_status == 2) { notice = "{result:'Error',msg:'" + Resources.Login.NOTICE_EMAIL_STOP + "'}"; ViewBag.notice = notice; if (IsRemember == "true") { ViewBag.LoginEmail = email; } UserLoginAttempts ula = new UserLoginAttempts(); ula.login_mail = email; ula.login_ipfrom = CommonFunction.GetIP4Address(Request.UserHostAddress.ToString()); ula.login_type = 5; ulaMgr.Insert(ula); ViewBag.Email = Request.Params["txtEmail"]; return View("Index"); } //if (caller.user_status == 3) //{ // notice = "{result:'Error',msg:'" + Resources.Login.NOTICE_EMAIL_DELETE + "'}"; // ViewBag.notice = notice; // if (IsRemember == "true") // { // ViewBag.LoginEmail = email; // } // return View("Index"); //} try { challenge_id = callerMgr.Add_Challenge(); challenge_key = callerMgr.Get_Challenge_Key(challenge_id); callerMgr.Kill_Challenge_Id(challenge_id); } 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); } BLL.gigade.Common.HashEncrypt hash = new BLL.gigade.Common.HashEncrypt(); string inputpasswd = hash.SHA256Encrypt(hash.SHA256Encrypt(passwd) + challenge_key); string newpasswd = hash.SHA256Encrypt(vendor.vendor_password+ challenge_key); if (inputpasswd != newpasswd) { try { _vendorImp.Add_Login_Attempts(Convert.ToInt32(vendor.vendor_id)); //callerMgr.Add_Login_Attempts(caller.user_id); } 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); } vendor.vendor_login_attempts++; string tempStr = string.Format(Resources.Login.ERROR_PASSWD_ERROR_TIMES, vendor.vendor_login_attempts, 6); notice = "{result:'Error',msg:'" + tempStr + "'}"; UserLoginAttempts ula = new UserLoginAttempts(); ula.login_mail = email; ula.login_ipfrom = CommonFunction.GetIP4Address(Request.UserHostAddress.ToString()); ula.login_type = 5; ulaMgr.Insert(ula); ViewBag.notice = notice; ViewBag.Email = Request.Params["txtEmail"]; ViewBag.challenge_id = callerMgr.Add_Challenge(); ViewBag.challenge_key = callerMgr.Get_Challenge_Key(ViewBag.challenge_id); if (vendor.vendor_login_attempts >= 6) { try { _vendorImp.Modify_Vendor_Status(Convert.ToInt32(vendor.vendor_id), 2); } 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); } } if (IsRemember == "true") { ViewBag.LoginEmail = email; } return View("Index"); } //if (caller.user_status == 0) //{ // notice = "{result:'Notice',msg:'" + Resources.Login.NOTICE_FIRST_LOGIN + "'}"; // ViewBag.notice = notice; // ViewBag.isFirst = 1; // ViewBag.uid = caller.user_id; // ViewBag.email = caller.user_email; // return View("ChangePasswd"); //} //try //{ // //添加登錄記錄 // callerMgr.Add_Manage_Login(caller.user_id); // //修改登入數據 // callerMgr.Modify_User_Login_Data(caller.user_id); //} //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); //} //caller.user_password = ""; //Session["caller"] = caller; vendor.vendor_password = ""; Session["vendor"] = vendor; Session["lgnName"] = vendor.vendor_name_simple; return Redirect("../home"); } }
public string QueryContact() { _vendorMgr = new VendorMgr(connectionString); string json = string.Empty; json = "[]"; try { if (!string.IsNullOrEmpty(Request.QueryString["vendor_id"])) { Vendor ven = new Vendor(); ven.vendor_id = Convert.ToUInt32(Request.QueryString["vendor_id"]); json = _vendorMgr.QueryContanct(ven); } } 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); json = "[]"; } return json; }
public HttpResponseBase QueryContactTable() { _vendorMgr = new VendorMgr(connectionString); DataTable _dt = new DataTable(); _dt.Columns.Add("contact_type", typeof(string)); _dt.Columns.Add("contact_name", typeof(string)); _dt.Columns.Add("contact_phone1", typeof(string)); _dt.Columns.Add("contact_phone2", typeof(string)); _dt.Columns.Add("contact_mobile", typeof(string)); _dt.Columns.Add("contact_email", typeof(string)); string json = string.Empty; #region 字典保存出貨窗口 Dictionary<uint, string> ContactType = new Dictionary<uint, string>(); ContactType.Add(1, "負責人"); ContactType.Add(2, "業務窗口"); ContactType.Add(3, "圖/文窗口"); ContactType.Add(4, "出貨負責窗口"); ContactType.Add(5, "帳務連絡窗口"); ContactType.Add(6, "客服窗口"); #endregion Vendor ven = new Vendor(); try { if (!string.IsNullOrEmpty(Request.Params["vendor_id"])) { ven.vendor_id = Convert.ToUInt32(Request.QueryString["vendor_id"]); ven = _vendorMgr.GetSingle(ven); } if (ContactType.Keys.Contains(ven.contact_type_1)) { DataRow row = _dt.NewRow(); row["contact_type"] = "出貨窗口"; row["contact_name"] = ven.contact_name_1; row["contact_phone1"] = ven.contact_phone_1_1; row["contact_phone2"] = ven.contact_phone_2_1; row["contact_mobile"] = ven.contact_mobile_1; row["contact_email"] = ven.contact_email_1; _dt.Rows.Add(row); } if (ContactType.Keys.Contains(ven.contact_type_2)) { DataRow row = _dt.NewRow(); row["contact_type"] = ContactType[ven.contact_type_2]; row["contact_name"] = ven.contact_name_2; row["contact_phone1"] = ven.contact_phone_1_2; row["contact_phone2"] = ven.contact_phone_2_2; row["contact_mobile"] = ven.contact_mobile_2; row["contact_email"] = ven.contact_email_2; _dt.Rows.Add(row); } if (ContactType.Keys.Contains(ven.contact_type_3)) { DataRow row = _dt.NewRow(); row["contact_type"] = ContactType[ven.contact_type_3]; row["contact_name"] = ven.contact_name_3; row["contact_phone1"] = ven.contact_phone_1_3; row["contact_phone2"] = ven.contact_phone_2_3; row["contact_mobile"] = ven.contact_mobile_3; row["contact_email"] = ven.contact_email_3; _dt.Rows.Add(row); } if (ContactType.Keys.Contains(ven.contact_type_4)) { DataRow row = _dt.NewRow(); row["contact_type"] = ContactType[ven.contact_type_4]; row["contact_name"] = ven.contact_name_4; row["contact_phone1"] = ven.contact_phone_1_4; row["contact_phone2"] = ven.contact_phone_2_4; row["contact_mobile"] = ven.contact_mobile_4; row["contact_email"] = ven.contact_email_4; _dt.Rows.Add(row); } if (ContactType.Keys.Contains(ven.contact_type_5)) { DataRow row = _dt.NewRow(); row["contact_type"] = ContactType[ven.contact_type_5]; row["contact_name"] = ven.contact_name_5; row["contact_phone1"] = ven.contact_phone_1_5; row["contact_phone2"] = ven.contact_phone_2_5; row["contact_mobile"] = ven.contact_mobile_5; row["contact_email"] = ven.contact_email_5; _dt.Rows.Add(row); } IsoDateTimeConverter timeConverter = new IsoDateTimeConverter(); //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式 timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss"; json = "{success:true,'msg':'user',data:" + JsonConvert.SerializeObject(_dt, Formatting.Indented, timeConverter) + "}";//返回json數據 } 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); json = "{success:false,totalCount:0,data:[]}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
/// <summary> /// 供應商後台:訂單管理>供應商調度出貨>要出的貨物信息 /// </summary> /// <returns></returns> public HttpResponseBase AllOrderDeliver() { uint Normal_Subtotal = 0;//常溫商品總額-- uint Hypothermia_Subtotal = 0;//低溫商品總額--- uint All_Normal_Subtotal = 0;//當日常溫運費總額 uint All_Hypothermia_Subtotal = 0;//當日低溫運費總額 uint Order_Freight_Normal = 0;//常溫運費 uint Order_Freight_Low = 0;//低溫運費 uint All_Order_Freight_Normal = 0;//當日常溫運費-- uint All_Order_Freight_Low = 0;//當日低溫運費-- string json = string.Empty; try { string detail_id = ""; if (!string.IsNullOrEmpty(Request.Params["rowIDs"])) { detail_id = Request.Params["rowIDs"]; } detail_id = detail_id.TrimEnd(',');//去掉最後一個分割符號 string[] Sid_Row = detail_id.Split(',');//拆分 string Sid = Sid_Row[Sid_Row.Length - 1];//獲取最後一個計算出出貨時間 //通過sid去order_slave查詢order_id; //通過order_id查詢在order_master中order_date_pay。 OrderSlaveQuery query = new OrderSlaveQuery(); query.Slave_Id = uint.Parse(Sid); _IOrderSlaveMgr = new OrderSlaveMgr(mySqlConnectionString); DateTime time = _IOrderSlaveMgr.GetOrderDatePay(query).order_date_pay; long endtime = CommonFunction.GetPHPTime(time.ToString("yyyy/MM/dd 23:59:59")); uint vendor_id = (Session["vendor"] as BLL.gigade.Model.Vendor).vendor_id; //(計算這些數據參照自vendor.gigade100.com/order/all_order_deliver.php 第209~266行) #region 計算供應商當天的常溫和冷凍的總運費 List<OrderDetailQuery> query1 = new List<OrderDetailQuery>(); _OrderDetailMgr = new OrderDetailMgr(mySqlConnectionString); query1 = _OrderDetailMgr.GetOrderDetailToSum(vendor_id, endtime); foreach (var item in query1) { if (item.item_mode == 1) continue; if (item.Product_Freight_Set == PRODUCT_FREIGHT_NORMAL || item.Product_Freight_Set == PRODUCT_FREIGHT_NO_NORMAL)//常溫,常溫免運 { if (item.item_mode == 2)//組合商品 { All_Normal_Subtotal += item.Single_Price * item.parent_num; } else { All_Normal_Subtotal += item.Single_Price * item.Buy_Num; } } else if (item.Product_Freight_Set == PRODUCT_FREIGHT_LOW || item.Product_Freight_Set == PRODUCT_FREIGHT_NO_LOW) //冷凍,冷凍免運 { if (item.item_mode == 2)//組合商品 { All_Hypothermia_Subtotal += item.Single_Price * item.parent_num; } else { All_Hypothermia_Subtotal += item.Single_Price * item.Buy_Num; } } } #endregion #region 計算運費 OrderDetailQuery oddquery = new OrderDetailQuery(); oddquery.Vendor_Id = vendor_id; _OrderDetailMgr = new OrderDetailMgr(mySqlConnectionString); int total = 0; string sq = string.Format(" AND os.slave_id in ({0}) ORDER BY od.slave_id ASC ,od. combined_mode ASC , od.item_mode ASC ", detail_id); List<OrderDetailQuery> query2 = new List<OrderDetailQuery>(); oddquery.Start = Convert.ToInt32(Request.Params["start"] ?? "0");//用於分頁的變量 oddquery.Limit = Convert.ToInt32(Request.Params["limit"] ?? "10");//用於分頁的變量 query1 = _OrderDetailMgr.AllOrderDeliver(oddquery, out total, sq); //uint Normal_Subtotal = 0;//常溫商品總額-- //uint Hypothermia_Subtotal = 0;//低溫商品總額--- //uint All_Normal_Subtotal = 0;//當日常溫運費總額 //uint All_Hypothermia_Subtotal = 0;//當日低溫運費總額 //uint Order_Freight_Normal = 0;//常溫運費 //uint Order_Freight_Low = 0;//低溫運費 //uint All_Order_Freight_Normal = 0;//當日常溫運費-- //uint All_Order_Freight_Low = 0;//當日低溫運費-- foreach (var item in query1) { if (item.item_mode == 1) continue; //商品總額計算(當下出貨金額與運費) if (item.Product_Freight_Set == PRODUCT_FREIGHT_NORMAL || item.Product_Freight_Set == PRODUCT_FREIGHT_NO_NORMAL)//常溫,常溫免運 { if (item.item_mode == 2) { Normal_Subtotal += item.Single_Price * item.parent_num; item.Buy_Num = item.Buy_Num * item.parent_num; item.Single_Price = item.Single_Price * item.parent_num; //Normal_Subtotal += item.Single_Price * item.parent_num;//--- //item.Buy_Num = item.Buy_Num * item.parent_num;//------- //item.Single_Money = item.Single_Price * item.Buy_Num;//--------- } else { Normal_Subtotal += item.Single_Price * item.Buy_Num; item.Single_Money = item.Single_Price * item.Buy_Num; } } else if (item.Product_Freight_Set == PRODUCT_FREIGHT_LOW || item.Product_Freight_Set == PRODUCT_FREIGHT_NO_LOW)//低溫,低溫免運 { if (item.item_mode == 2) { Hypothermia_Subtotal += item.Single_Price * item.parent_num; item.Buy_Num = item.Buy_Num * item.parent_num; item.Single_Price = item.Single_Price * item.parent_num; //Hypothermia_Subtotal += item.Single_Price * item.parent_num;//-------- //item.Buy_Num = item.Buy_Num * item.parent_num;//------------ //item.Single_Money = item.Single_Price * item.Buy_Num;//--------- } else { Hypothermia_Subtotal += item.Single_Price * item.Buy_Num; item.Single_Money = item.Single_Price * item.Buy_Num; } } query2.Add(item); } _VendorMgr = new VendorMgr(mySqlConnectionString); BLL.gigade.Model.Vendor vendor = new BLL.gigade.Model.Vendor(); vendor.vendor_id = vendor_id; vendor = _VendorMgr.GetSingle(vendor); //當下運費計算 if (Normal_Subtotal != 0) { if (vendor.freight_normal_limit > Normal_Subtotal) { Order_Freight_Normal = vendor.freight_normal_money; } } if (Hypothermia_Subtotal != 0) { if (vendor.freight_low_limit > Hypothermia_Subtotal && Hypothermia_Subtotal > 0) { Order_Freight_Low = vendor.freight_low_money; } } //批次單總額運費 if (All_Normal_Subtotal != 0) { if (vendor.freight_normal_limit > All_Normal_Subtotal) { All_Order_Freight_Normal = vendor.freight_normal_money; } } if (All_Hypothermia_Subtotal != 0) { if (vendor.freight_low_limit > All_Order_Freight_Low) { All_Order_Freight_Low = vendor.freight_low_money; } } #endregion IsoDateTimeConverter timeConverter = new IsoDateTimeConverter(); //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式 timeConverter.DateTimeFormat = "yyyy-MM-dd"; json = "{success:true,Normal_Subtotal:" + Normal_Subtotal + ",Hypothermia_Subtotal:" + Hypothermia_Subtotal + ",Order_Freight_Normal:" + Order_Freight_Normal + ",Order_Freight_Low:" + Order_Freight_Low; json += ",All_Order_Freight_Normal:" + All_Order_Freight_Normal + ",All_Order_Freight_Low:" + All_Order_Freight_Low + ",data:" + JsonConvert.SerializeObject(query2, Formatting.Indented, timeConverter) + "}";//返回json數據 } 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); json = "{success:false,msg:0}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
/// <summary> /// 根據供應商解除失格 /// </summary> /// <returns>數據庫操作結果</returns> public JsonResult UnGrade() { try { string vendor_id = Request.Params["vendor_id"].ToString(); string active = Request.Params["active"].ToString(); StringBuilder update_log = new StringBuilder(); _vendorMgr = new VendorMgr(connectionString); //update_log.AppendFormat("vendor_status:{0}:{1}:供應商狀態", 3, active); List<TableChangeLog> list = new List<TableChangeLog>(); list.Add(new TableChangeLog() { change_field = "vendor_status", old_value = "3", new_value = active, field_ch_name = "供應商狀態" }); if (_vendorMgr.UnGrade(vendor_id, active, list) > 0) { return Json(new { success = "true" }); } else { return Json(new { success = "false" }); } } 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); return Json(new { success = "false" }); } }
/// <summary> /// 人員管理 /// </summary> /// <returns></returns> public HttpResponseBase AddCallid()//modify by mengjuan0826j 2015/6/8 處理供應商pm設定 增加條件設置:若pm存在于供應商,則不能執行刪除動作! { gcMgr = new GroupCallerMgr(mySqlConnectionString); venMgr = new VendorMgr(mySqlConnectionString); string json = string.Empty; bool delete = true; try { if (!string.IsNullOrEmpty(Request.Form["groupId"])) { gc.groupId = Int32.Parse(Request.Form["groupId"]); } if (!string.IsNullOrEmpty(Request.Form["callid"])) { string[] callid = Request.Form["callid"].IndexOf(",") != -1 ? Request.Form["callid"].Split(',') : new string[] { Request.Form["callid"] }; if (gc.groupId == GetVebdorPMGroup())//判定是否為供應商群組管理員 { List<ManageUser> muStore = venMgr.GetVendorPM();//獲取供應商pm if (muStore.Count != 0) { foreach (var item in muStore)//遍歷供應商pm,若該人員存在于供應商pm,則不能刪除,直接提示! { if (!callid.Contains(item.user_email)) { delete = false; json = "{success:false,msg:\"人員 " + item.user_username + " 為現有供應商PM,不能移除\"}"; break; } } } } if (delete) { gcMgr.Delete(gc); foreach (string id in callid) { if (!string.IsNullOrEmpty(id)) { gc.callid = id; gcMgr.Save(gc); } } json = "{success:true,msg:\"新增成功\"}"; } } else { json = "{success:true,msg:\"新增失敗\"}"; } } 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); json = "{success:true,msg:\"新增失败\"}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
/// <summary> /// 根據bankcode獲取bankname /// </summary> /// <returns></returns> public JsonResult GetBankName() { try { string code = Request.Params["bankCode"].ToString(); _vendorMgr = new VendorMgr(connectionString); return Json(new { success = "true", name = _vendorMgr.GetVendorBank(code) }); } 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); return Json(new { success = "false" }); } }
/// <summary> /// 供應商出貨單 /// </summary> /// <returns></returns> public HttpResponseBase OrderWaitDeliverList() { string jsonStr = String.Empty; StringBuilder sb = new StringBuilder(); HashEncrypt hmd5 = new HashEncrypt(); _IOrderSlaveMgr = new OrderSlaveMgr(mySqlConnectionString); _OrderPaymentNcccMgr = new OrderPaymentNcccMgr(mySqlConnectionString); _SinopacMgr = new SinopacDetailMgr(mySqlConnectionString); _vendorImp = new VendorMgr(mySqlConnectionString); try { #region 前提查詢條件 if (!string.IsNullOrEmpty(Request.Params["search_type"]))//查詢條件 { int search_type = int.Parse(Request.Params["search_type"]); string searchcontent = ""; if (!string.IsNullOrEmpty(Request.Params["searchcontent"])) { searchcontent = Request.Params["searchcontent"]; } switch (search_type) { case 1: sb.AppendFormat(" and om.order_id LIKE '%{0}%' ", searchcontent); break; case 2: sb.AppendFormat(" AND om.order_name LIKE '%{0}%' ", searchcontent); break; case 3: sb.AppendFormat(" AND u.user_email LIKE '%{0}%' ", searchcontent); break; case 4: sb.AppendFormat(" AND om.delivery_name LIKE '%{0}%' ", searchcontent); break; case 5: sb.AppendFormat(" AND om.source_trace LIKE '%{0}%' ", searchcontent); break; default: sb.Append(" "); break; } } if (!string.IsNullOrEmpty(Request.Params["search_vendor"]))//供應商條件 { if (int.Parse(Request.Params["search_vendor"]) != 0) { sb.AppendFormat(" AND os.vendor_id = '{0}' ", Request.Params["search_vendor"]); } } #endregion List<OrderSlaveQuery> store = new List<OrderSlaveQuery>(); OrderSlaveQuery query = new OrderSlaveQuery(); query.Start = Convert.ToInt32(Request.Params["start"] ?? "0");//用於分頁的變量 query.Limit = Convert.ToInt32(Request.Params["limit"] ?? "25");//用於分頁的變量 int totalCount = 0; store = _IOrderSlaveMgr.GetOrderWaitDeliver(query, sb.ToString(), out totalCount);//查询出供應商出貨單 int vendor_id = 0; string loginIdStr = string.Empty; string mdlogin_id = string.Empty; StringBuilder Order_id_store = new StringBuilder(); foreach (var item in store) { Order_id_store.AppendFormat("{0},", item.order_id); } string dtSql = "and order_id in(" + Order_id_store.ToString().TrimEnd(',') + ") ";//去查詢DataTable DataTable _dtNccc = _OrderPaymentNcccMgr.OrderPaymentNccc(null, dtSql); DataTable _dtSino = _SinopacMgr.GetSinopacDetai(null, dtSql); // String Sql = "123"; foreach (var item in store) { //組裝用於登錄到供應商後臺的金鑰 vendor_id = Convert.ToInt32(item.vendor_id); loginIdStr = _vendorImp.GetLoginId(vendor_id); mdlogin_id = hmd5.Md5Encrypt(loginIdStr, "MD5"); //http://localhost:32088/?vendor_id=2&key=f32bef1b57de24330d8bf900cee4ba5e item.key = vendorServerPath + "?vendor_id=" + item.vendor_id + "&key=" + hmd5.Md5Encrypt(mdlogin_id + loginIdStr, "MD5"); item.status = "待出貨"; if (item.order_payment == 1)//付款方式为ATM { DataRow[] rows = _dtSino.Select("order_id='" + item.order_id + "'"); if (rows.Count() != 0) { item.pay_time = DateTime.Parse(rows[0]["pay_time"].ToString()).ToString("yyyy/MM/dd HH:mm:ss"); } else { item.pay_time = ""; } } else { DataRow[] rows = _dtNccc.Select("order_id='" + item.order_id + "'"); if (rows.Count() != 0) { item.pay_time = DateTime.Parse(rows[0]["pay_time"].ToString()).ToString("yyyy/MM/dd HH:mm:ss"); } else { item.pay_time = ""; } } } IsoDateTimeConverter timeConverter = new IsoDateTimeConverter(); //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式 timeConverter.DateTimeFormat = "yyyy-MM-dd"; jsonStr = "{success:true,totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(store, Formatting.Indented, timeConverter) + "}";//返回json數據 } 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; }
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; }
/// <summary> /// 獲取供應商列表數據 /// </summary> /// <returns></returns> public HttpResponseBase GetVendorList() { List<VendorQuery> stores = new List<VendorQuery>(); string json = string.Empty; try { _vendorMgr = new VendorMgr(connectionString); #region 搜索條件 VendorQuery query = new VendorQuery(); query.Start = Convert.ToInt32(Request.Params["start"] ?? "0");//用於分頁的變量 query.Limit = Convert.ToInt32(Request.Params["limit"] ?? "25");//用於分頁的變量 if (!string.IsNullOrEmpty(Request.Params["relation_id"])) { query.vendor_id = Convert.ToUInt32(Request.Params["relation_id"].ToString()); } if (!string.IsNullOrEmpty(Request.Params["VendorId"])) { query.vendor_id = Convert.ToUInt32(Request.Params["VendorId"].ToString()); } string type = string.Empty; string con = string.Empty; if (!string.IsNullOrEmpty(Request.Params["dateType"])) { type = Request.Params["dateType"].ToString(); } if (!string.IsNullOrEmpty(Request.Params["dateCon"])) { con = Request.Params["dateCon"].ToString(); } int totalCount = 0; if (!string.IsNullOrEmpty(type) && !string.IsNullOrEmpty(con) && type != "0") {//當查詢條件和查詢內容都有值時執行 switch (type) { case "0": break; case "1": query.searchEmail = con.ToLower(); break; case "2": query.searchName = con; break; case "3": query.vendor_name_full = con; break; case "4": query.searchInvoice = con; break; case "5": query.erp_id = con; break; case "6": uint isTranUint = 0; if (uint.TryParse(con, out isTranUint)) { query.vendor_id = Convert.ToUInt32(con); } break; case "7": query.vendor_code = con; break; } if (!string.IsNullOrEmpty(Request.Params["vendortype"]))//供应商类型 { query.vendor_type = Request.Params["vendortype"].ToString(); query.vendor_type = query.vendor_type.TrimEnd(','); } if (!string.IsNullOrEmpty(Request.Params["dateOne"])) { // query.create_dateOne = (uint)CommonFunction.GetPHPTime(Convert.ToDateTime(Request.Params["dateOne"]).ToString("yyyy-MM-dd 00:00:00")); query.create_dateOne = (uint)CommonFunction.GetPHPTime(Request.Params["dateOne"]); } if (!string.IsNullOrEmpty(Request.Params["dateTwo"])) { //query.create_dateTwo = (uint)CommonFunction.GetPHPTime(Convert.ToDateTime(Request.Params["dateTwo"]).ToString("yyyy-MM-dd 23:59:59")); query.create_dateTwo = (uint)CommonFunction.GetPHPTime(Request.Params["dateTwo"]); } stores = _vendorMgr.Query(query, ref totalCount); } else { //當查詢條件和查詢內容都沒有值時執行 if (!string.IsNullOrEmpty(Request.Params["vendortype"]))//供应商类型 { query.vendor_type = Request.Params["vendortype"].ToString(); query.vendor_type = query.vendor_type.TrimEnd(','); } if (!string.IsNullOrEmpty(Request.Params["dateOne"])) { //query.create_dateOne = (uint)CommonFunction.GetPHPTime(Convert.ToDateTime(Request.Params["dateOne"]).ToString("yyyy-MM-dd 00:00:00")); query.create_dateOne = (uint)CommonFunction.GetPHPTime(Request.Params["dateOne"]); } if (!string.IsNullOrEmpty(Request.Params["dateTwo"])) { //query.create_dateTwo = (uint)CommonFunction.GetPHPTime(Convert.ToDateTime(Request.Params["dateTwo"]).ToString("yyyy-MM-dd 23:59:59")); query.create_dateTwo = (uint)CommonFunction.GetPHPTime(Request.Params["dateTwo"]); } stores = _vendorMgr.Query(query, ref totalCount); } #endregion #region 供應商類型參數 List<Parametersrc> list = new List<Parametersrc>(); paraMgr = new ParameterMgr(connectionString); string types = "vendor_type"; list = paraMgr.GetElementType(types); #endregion foreach (var item in stores) { item.vendor_name_full = Server.HtmlDecode(Server.HtmlDecode(item.vendor_name_full)); item.vendor_name_simple = Server.HtmlDecode(Server.HtmlDecode(item.vendor_name_simple)); string temp = string.Empty; #region 供應商類型關聯參數表 if (!string.IsNullOrEmpty(item.vendor_type) && item.vendor_type != null) { string[] vendor_types = item.vendor_type.Split(','); for (int i = 0; i < vendor_types.Length; i++) { for (int j = 0; j < list.Count; j++) { if (list[j].ParameterCode == vendor_types[i].ToString()) { item.vendor_type_name += list[j].parameterName + ","; } } } item.vendor_type_name = item.vendor_type_name.Substring(0, item.vendor_type_name.Length - 1); } #endregion if (item.self_send_days == 0) { if (item.stuff_ware_days == 0) { if (item.dispatch_days == 0) { temp = ""; } else { temp = "調度"; } } else { if (item.dispatch_days == 0) { temp = "寄倉"; } else { temp = "寄倉,調度"; } } } else { if (item.stuff_ware_days == 0) { if (item.dispatch_days == 0) { temp = "自出"; } else { temp = "自出,調度"; } } else { if (item.dispatch_days == 0) { temp = "自出,寄倉"; } else { temp = "自出,寄倉,調度"; } } } item.vendor_mode = temp; if (Convert.ToBoolean(Request.Params["isSecret"])) { if (!string.IsNullOrEmpty(item.vendor_name_full)) { item.vendor_name_full = item.vendor_name_full.Substring(0, 1) + "**"; } // if (!string.IsNullOrEmpty(item.vendor_name_simple)) { item.vendor_name_simple = item.vendor_name_simple.Substring(0, 1) + "**"; }//vendor_company_address if (item.vendor_company_address.ToString().Length > 3) { item.vendor_company_address = item.vendor_company_address.Substring(0, 3) + "***"; } else { item.vendor_company_address = item.vendor_company_address + "***"; } if (!string.IsNullOrEmpty(item.contact_email_1)) { item.contact_email_1 = item.contact_email_1.Split('@')[0] + "@***"; } if (!string.IsNullOrEmpty(item.contact_email_2)) { item.contact_email_2 = item.contact_email_2.Split('@')[0] + "@***"; } if (!string.IsNullOrEmpty(item.contact_email_3)) { item.contact_email_3 = item.contact_email_3.Split('@')[0] + "@***"; } if (!string.IsNullOrEmpty(item.contact_email_4)) { item.contact_email_4 = item.contact_email_4.Split('@')[0] + "@***"; } if (!string.IsNullOrEmpty(item.contact_email_5)) { item.contact_email_5 = item.contact_email_5.Split('@')[0] + "@***"; } if (item.contact_mobile_1.ToString().Length > 3) { item.contact_mobile_1 = item.contact_mobile_1.Substring(0, 3) + "***"; } else { item.contact_mobile_1 = item.contact_mobile_1 + "***"; } if (item.contact_mobile_2.ToString().Length > 3) { item.contact_mobile_2 = item.contact_mobile_2.Substring(0, 3) + "***"; } else { item.contact_mobile_2 = item.contact_mobile_2 + "***"; } if (item.contact_mobile_3.ToString().Length > 3) { item.contact_mobile_3 = item.contact_mobile_3.Substring(0, 3) + "***"; } else { item.contact_mobile_3 = item.contact_mobile_3 + "***"; } if (item.contact_mobile_4.ToString().Length > 3) { item.contact_mobile_4 = item.contact_mobile_4.Substring(0, 3) + "***"; } else { item.contact_mobile_4 = item.contact_mobile_4 + "***"; } if (item.contact_mobile_5.ToString().Length > 3) { item.contact_mobile_5 = item.contact_mobile_5.Substring(0, 3) + "***"; } else { item.contact_mobile_5 = item.contact_mobile_5 + "***"; } if (item.contact_phone_1_1.ToString().Length > 3) { item.contact_phone_1_1 = item.contact_phone_1_1.Substring(0, 3) + "***"; } else { item.contact_phone_1_1 = item.contact_phone_1_1 + "***"; } if (item.contact_phone_1_2.ToString().Length > 3) { item.contact_phone_1_2 = item.contact_phone_1_2.Substring(0, 3) + "***"; } else { item.contact_phone_1_2 = item.contact_phone_1_2 + "***"; } if (item.contact_phone_1_3.ToString().Length > 3) { item.contact_phone_1_3 = item.contact_phone_1_3.Substring(0, 3) + "***"; } else { item.contact_phone_1_3 = item.contact_phone_1_3 + "***"; } if (item.contact_phone_1_4.ToString().Length > 3) { item.contact_phone_1_4 = item.contact_phone_1_4.Substring(0, 3) + "***"; } else { item.contact_phone_1_4 = item.contact_phone_1_4 + "***"; } if (item.contact_phone_1_5.ToString().Length > 3) { item.contact_phone_1_5 = item.contact_phone_1_5.Substring(0, 3) + "***"; } else { item.contact_phone_1_5 = item.contact_phone_1_5 + "***"; } if (item.contact_phone_2_1.ToString().Length > 3) { item.contact_phone_2_1 = item.contact_phone_2_1.Substring(0, 3) + "***"; } else { item.contact_phone_2_1 = item.contact_phone_2_1 + "***"; } if (item.contact_phone_2_2.ToString().Length > 3) { item.contact_phone_2_2 = item.contact_phone_2_2.Substring(0, 3) + "***"; } else { item.contact_phone_2_2 = item.contact_phone_2_2 + "***"; } if (item.contact_phone_2_3.ToString().Length > 3) { item.contact_phone_2_3 = item.contact_phone_2_3.Substring(0, 3) + "***"; } else { item.contact_phone_2_3 = item.contact_phone_2_3 + "***"; } if (item.contact_phone_2_4.ToString().Length > 3) { item.contact_phone_2_4 = item.contact_phone_2_4.Substring(0, 3) + "***"; } else { item.contact_phone_2_4 = item.contact_phone_2_4 + "***"; } if (item.contact_phone_2_5.ToString().Length > 3) { item.contact_phone_2_5 = item.contact_phone_2_5.Substring(0, 3) + "***"; } else { item.contact_phone_2_5 = item.contact_phone_2_5 + "***"; } if (!string.IsNullOrEmpty(item.contact_name_1)) { item.contact_name_1 = item.contact_name_1.Substring(0, 1) + "**"; } if (!string.IsNullOrEmpty(item.contact_name_2)) { item.contact_name_2 = item.contact_name_2.Substring(0, 1) + "**"; } if (!string.IsNullOrEmpty(item.contact_name_3)) { item.contact_name_3 = item.contact_name_3.Substring(0, 1) + "**"; } if (!string.IsNullOrEmpty(item.contact_name_4)) { item.contact_name_4 = item.contact_name_4.Substring(0, 1) + "**"; } if (!string.IsNullOrEmpty(item.contact_name_5)) { item.contact_name_5 = item.contact_name_5.Substring(0, 1) + "**"; } if (!string.IsNullOrEmpty(item.manage_name)) { item.manage_name = item.manage_name.Substring(0, 1) + "**"; } if (!string.IsNullOrEmpty(item.manage_email)) { item.manage_email = item.manage_email.Split('@')[0] + "@***"; } if (!string.IsNullOrEmpty(item.vendor_email)) { item.vendor_email = item.vendor_email.Split('@')[0] + "@***"; } if (!string.IsNullOrEmpty(item.company_person)) { item.company_person = item.company_person.Substring(0, 1) + "**"; } if (item.company_address.ToString().Length > 3) { item.company_address = item.company_address.Substring(0, 3) + "***"; } else { item.company_address = item.company_address + "***"; } if (item.invoice_address.ToString().Length > 3) { item.invoice_address = item.invoice_address.Substring(0, 3) + "***"; } else { item.invoice_address = item.invoice_address + "***"; } } } IsoDateTimeConverter timeConverter = new IsoDateTimeConverter(); //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式 timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss"; json = "{success:true,totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(stores, Formatting.Indented, timeConverter) + "}";//返回json數據 } 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); json = "{success:false,totalCount:0,data:[]}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
/// <summary> /// 獲取所有的供應商名稱 /// </summary> /// <returns></returns> public HttpResponseBase GetVendor() { _vendorMgr = new VendorMgr(mySqlConnectionString); List<BLL.gigade.Model.Vendor> stores = new List<BLL.gigade.Model.Vendor>(); string json = string.Empty; try { int totalCount = 0; stores = _vendorMgr.VendorQueryAll(new BLL.gigade.Model.Vendor()); json = "{success:true,totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(stores) + "}";//返回json數據 } 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); json = "{success:true,totalCount:0,data:[]}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
public HttpResponseBase VendorAdd(VendorQuery venQuery) { string jsonStr = "{success:false}"; try { _vendorMgr = new VendorMgr(connectionString); if (!string.IsNullOrEmpty(Request.Params["pm"])) { venQuery.product_manage = Convert.ToUInt32(Request.Params["pm"]); } int result = _vendorMgr.Add(venQuery); if (result > 0) { jsonStr = "{success:true}"; } else if (result == -1) { jsonStr = "{success:false,msg:-1}"; } } 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; }