public void Execute(StringBuilder sb, string value) { foreach (char item in value) { sb.Append(Hz2Py.Convert(item.ToString()).Substring(0, 1)); } }
/// <summary> /// 组织设备查询单个检查的返回值 /// </summary> /// <returns></returns> private string FormatSelect(string id) { List <Command> CMDS = nx700.CMDS; if (!CMDS.Any(o => o.Id == id)) { return(string.Format("W,{0},{1},{2},{3}{4}", id, null, null, 0, (char)3)); } Command cmd = CMDS.First(o => o.Id == id); int count = 0; string names = cmd.Tag as string; if (!string.IsNullOrEmpty(names)) { count = names.Count(c => c == ','); } else { names = ""; } string sendstr = string.Format("W,{0},{1},{2},{3}{4}{5}", id, cmd.PetId, Hz2Py.ChineseToPinYin(cmd.PetName).ToLower(), count, names, (char)3); log.Msg("发送数据:" + sendstr); return(sendstr); //return string.Format("W,{0},{1},{2},{3}{4}{5}", id, cmd.PetId, cmd.PetName, count, names, (char)3); }
protected void btn_to_pinyin_Click(object sender, EventArgs e) { txt_receive_addr_contact.Text = Hz2Py.Convert(txt_receive_addr_contact.Text); txt_receive_addr_contact.Text = Hz2Py.Convert(txt_receive_addr_contact.Text); txt_receive_addr_company.Text = Hz2Py.Convert(txt_receive_addr_company.Text); txt_receive_addr_line1.Text = Hz2Py.Convert(txt_receive_addr_line1.Text); txt_receive_addr_line2.Text = Hz2Py.Convert(txt_receive_addr_line2.Text); txt_receive_addr_line3.Text = Hz2Py.Convert(txt_receive_addr_line3.Text); txt_receive_addr_city.Text = Hz2Py.Convert(txt_receive_addr_city.Text); txt_receive_addr_postcode.Text = Hz2Py.Convert(txt_receive_addr_postcode.Text); txt_receive_addr_country.Text = Hz2Py.Convert(txt_receive_addr_country.Text); txt_receive_addr_phone.Text = Hz2Py.Convert(txt_receive_addr_phone.Text); txt_receive_addr_email.Text = Hz2Py.Convert(txt_receive_addr_email.Text); }
public bool ImportExhibitors(DataTable table, int exhibitionID, string userid) { bool returnValue = false; if (table != null) { if (table.Columns.Contains("展商名称") && table.Columns.Contains("展位位置")) { StringBuilder strSql = new StringBuilder(); strSql.Append("DECLARE @key INT;"); foreach (DataRow dr in table.Rows) { strSql.AppendFormat(@"INSERT INTO dbo.M_Exhibition_Exhibitors( ExhibitionID ,ExhibitorName ,ExhibitorPinYin ,OBCustomerID ,OBCustomerTypeID ,IsHadBookList ,StateTypeID ,CreateUserID ,CreateTime) VALUES ( {0} ,'{1}' ,'{2}' ,0 ,0 , 0 ,1 , '{3}' , GETDATE()); select @key = @@IDENTITY;" , exhibitionID.ToString() , dr["展商名称"].ToString() , Hz2Py.GetWholePinyin(dr["展商名称"].ToString()) , userid); string[] locs = dr["展位位置"].ToString().Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); if (locs != null) { foreach (string loc in locs) { strSql.AppendFormat(@"INSERT INTO dbo.M_Exhibition_Exhibitor_Location( ExhibitorID ,ExhibitorLocation ,StateTypeID ,ExhibitiorLocationOrder ,CreateUserID ,CreateTime) VALUES ( @key ,'{0}' , 1 , 1000 ,'{1}' ,GETDATE());" , loc , userid); } } } try { SQlHelper.ExecuteNonQuery(SQlHelper.MyConnectStr, CommandType.Text, strSql.ToString(), null); returnValue = true; } catch (Exception ex) { LogUtil.WriteLog(ex); } } } return(returnValue); }
//上传Excel文件的实现 protected void btn_upload_Click(object sender, EventArgs e) { int line_count = 0; string username = ""; string path = upload_ems_excel.FileName; if (path == "") { alert("请选择文件!!"); return; } else { username = Session["name"].ToString(); string file_path = saveUploadFile(); if (file_path == "error") { return; } DataSet ds = new DataSet(); string strConn = "Provider=ACE.OLEDB.12.0;" + "Data Source=" + file_path + ";" + "Extended Properties='Excel 8.0;HDR=Yes;IMEX=1;'"; OleDbConnection conn = new OleDbConnection(strConn); conn.Open(); string strExcel = ""; OleDbDataAdapter myCommand = null; OleDbCommandBuilder cb = new OleDbCommandBuilder(myCommand); strExcel = "select * from [Sheet1$] "; myCommand = new OleDbDataAdapter(strExcel, strConn); myCommand.Fill(ds, "table1"); ArrayList order_array = new ArrayList(); ArrayList package_array = new ArrayList(); DateTime temp_time = DateTime.Now; AutoOrder order = new AutoOrder(); DateTime time = DateTime.Now; Application.Lock(); string autoOrderNo = Application["orderNo"].ToString(); Application["orderNo"] = (int)Application["orderNo"] + 1; Application.UnLock(); string auto_no = "AU" + time.ToString("yyMMddHHmm") + autoOrderNo.PadLeft(8, '0'); order.Auto_no = auto_no; order.Name = Session["name"].ToString(); order.Order_time = time.ToString("yyyy-MM-dd HH:mm"); order.Is_pay = "unpay"; order.Pay_before_discount = 0; order.Excel_path = intablename; for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { if (ds.Tables[0].Rows[i][4].ToString().Trim() != "" && (!ds.Tables[0].Rows[i][0].ToString().Trim().Contains("取件还是投送") && !ds.Tables[0].Rows[i][1].ToString().Trim().Contains("发件时间"))) { //判断Excel是否为空 string delivery_way = ds.Tables[0].Rows[i][0].ToString().Trim(); string delivery_time = ds.Tables[0].Rows[i][1].ToString().Trim(); string receive_company = ds.Tables[0].Rows[i][2].ToString().Trim(); string receive_name = ds.Tables[0].Rows[i][3].ToString().Trim(); string receive_phone = ds.Tables[0].Rows[i][4].ToString().Trim(); string receive_address_line = ds.Tables[0].Rows[i][5].ToString().Trim(); string receive_city = ds.Tables[0].Rows[i][6].ToString().Trim(); string receive_postcode = ds.Tables[0].Rows[i][7].ToString().Trim(); string receive_country = ds.Tables[0].Rows[i][8].ToString().Trim(); string send_company = ds.Tables[0].Rows[i][9].ToString().Trim(); string send_name = ds.Tables[0].Rows[i][10].ToString().Trim(); string send_phone = ds.Tables[0].Rows[i][11].ToString().Trim(); string send_addressline = ds.Tables[0].Rows[i][12].ToString().Trim(); string send_city = ds.Tables[0].Rows[i][13].ToString().Trim(); string send_postcode = ds.Tables[0].Rows[i][14].ToString().Trim(); string insurance = ds.Tables[0].Rows[i][15].ToString().Trim(); string comment = ds.Tables[0].Rows[i][16].ToString().Trim(); string parcel_number = ds.Tables[0].Rows[i][17].ToString().Trim(); string weight = ds.Tables[0].Rows[i][18].ToString().Trim(); string length = ds.Tables[0].Rows[i][19].ToString().Trim(); string width = ds.Tables[0].Rows[i][20].ToString().Trim(); string height = ds.Tables[0].Rows[i][21].ToString().Trim(); string description = ds.Tables[0].Rows[i][22].ToString().Trim(); string package_value = ds.Tables[0].Rows[i][23].ToString().Trim(); //判断重量、长、宽、高是否有效 { if (delivery_way == "") { alert("您好,包裹的取件方式不能为空,请仔细检查 Excel !!"); return; } else if (delivery_time == "") { alert("您好,包裹的取件时间不能为空,请仔细检查 Excel!!"); return; } else if (receive_company == "") { alert("您好,收件公司不能为空,如果没有收件公司,请写上收件人名 !!"); return; } else if (receive_name == "") { alert("您好,收件人名不能为空,请仔细检查 Excel!!"); return; } else if (receive_phone == "") { alert("您好,收件人 号码 不能为空,请仔细检查 Excel!!"); return; } else if (receive_address_line == "") { alert("您好,收件 地址 不能为空 ,请仔细检查 Excel!!"); return; } else if (receive_city == "") { alert("您好,收件人 城市 不能为空,请仔细检查 Excel!!"); return; } else if (receive_postcode == "") { alert("您好,收件人 邮编不能为空,请仔细检查 Excel !!"); return; } else if (receive_country == "") { alert("您好,收件人国家不能为空,必须是 China-NL 、 China-IPE 、 China-GPR , 请仔细检查 Excel !!"); return; } else if (send_company == "") { alert("您好,发件人公司不能为空,如果无发件人公司 就 填写发件人名 !!"); return; } else if (send_name == "") { alert("发件人名不能为空 , 请仔细检查 Excel!!"); return; } else if (send_phone == "") { alert("您好,发件人 电话 不能为空,请仔细检查!!"); return; } else if (send_addressline == "") { alert("您好,发件人地址不能为空,请仔细检查 !! "); return; } else if (send_city == "") { alert("您好,发件人城市不能为空,请仔细检查 !!"); return; } else if (send_postcode == "") { alert("您好,发件人 邮编不能为空, 请仔细检查 !! "); return; } else if (insurance == "") { alert("您好,是否购买保险字段不能为空,请填上 0 "); } else if (comment == "") { alert("您好,发货目的不能为空 , 请仔细检查 Excel!!"); return; } else if (weight == "") { alert("您好,包裹的重量不能为空 , 请仔细检查 Excel!!"); return; } else if (length == "") { alert("您好,包裹的长度不能为空 , 请仔细检查 Excel!!"); return; } else if (width == "") { alert("您好,包裹的宽度不能为空 , 请仔细检查 Excel!!"); return; } else if (height == "") { alert("您好,包裹的 高度不能为空,请仔细检查 !!"); return; } else if (description == "") { alert("您好,包裹的 描述不能为空,请仔细检查!!"); return; } else if (package_value == "") { alert("您好,包裹的价值不能为空,请仔细检查 !!"); return; } } //判断中文字符 。 { receive_company = receive_company.Replace('。', '.'); receive_name = receive_name.Replace('。', '.'); receive_address_line = receive_address_line.Replace('。', '.'); receive_city = receive_city.Replace('。', '.'); receive_postcode = receive_postcode.Replace('。', '.'); receive_country = receive_country.Replace('。', '.'); send_company = send_company.Replace('。', '.'); send_name = send_name.Replace('。', '.'); send_addressline = send_addressline.Replace('。', '.'); send_city = send_city.Replace('。', '.'); send_postcode = send_postcode.Replace('。', '.'); description = description.Replace('。', '.'); } try { Convert.ToSingle(weight); Convert.ToSingle(length); Convert.ToSingle(width); Convert.ToSingle(height); Convert.ToSingle(package_value); } catch (System.Exception ex) { alert("包裹的重量、长、宽、高、价值 信息必须位数字"); return; } if (receive_postcode.Length != 6) { alert("收件人邮编必须为 6 位!!"); return; } try { if (receive_phone.Contains("e") || send_phone.Contains("e")) { receive_phone = Convert.ToInt64(Convert.ToSingle(receive_phone)).ToString(); send_phone = Convert.ToInt64(Convert.ToSingle(send_phone)).ToString(); } } catch (System.Exception ex) { alert("收件人或者发件人电话格式错误"); return; } AutoOrderList package = new AutoOrderList(); //如果是 PostNL if (receive_country.ToLower().Equals("china-nl")) { line_count++; Application.Lock(); string orderNo = Application["packageNo"].ToString(); Application["packageNo"] = (int)Application["packageNo"] + 1; Application.UnLock(); package.Auto_no = auto_no; package.Order_no = "WA" + time.ToString("yyMMddHHmm") + orderNo.PadLeft(8, '0'); package.Name = Session["name"].ToString(); package.CollectionCompanyName = send_company; package.CollectionContactName = send_name; package.CollectionPhone = send_phone; package.CollectionAddressLine = send_addressline; package.CollectionTown = send_city; package.CollectionPostCode = send_postcode; package.CollectionCountry = "UK"; package.RecipientCompanyName = receive_company; package.RecipientContactName = receive_name; package.RecipientPhone = receive_phone; package.RecipientAddressLine = receive_address_line; package.RecipientTown = receive_city; package.RecipeintPostCode = receive_postcode; package.RecipientCountry = "China"; package.Shippingdate = delivery_time; package.Shippingtype = delivery_way; package.Shippingpurpose = comment; package.PackageDescription = description; package.PackageValue = Convert.ToSingle(package_value); package.Insurance = Convert.ToSingle(insurance); package.ServiceCode = "PostNL"; package.Weight = Convert.ToSingle(weight); package.Length = Convert.ToSingle(length); package.Width = Convert.ToSingle(width); package.Height = Convert.ToSingle(height); if (package.PackageDescription.Contains("推车") || package.PackageDescription.Contains("trolly") || package.PackageDescription.Contains("坐椅") || package.PackageDescription.Contains("baby sit") || package.PackageDescription.Contains("babysit") || package.PackageDescription.Contains("sit")) { package.Volumetric = package.Length * package.Width * package.Height / 6000; } else { package.Volumetric = package.Weight; } if (package.Weight >= package.Volumetric) { package.Chargeable = package.Weight; } else { package.Chargeable = package.Volumetric; } package.Pay_status = "unpay"; package.Pay_before_discount = new BatchQuoteDAO().getQuote(username, package.ServiceCode, package.Weight, package.Chargeable); package.Pay_before_discount += package.Insurance; package.Discount = 0; package.Pay_after_discount = package.Pay_before_discount; package.Order_time = order.Order_time; package.Less_pay = 0; package.Is_delivery = 0; order.Pay_before_discount += package.Pay_before_discount; package_array.Add(package); } //如果是 PF-IPE 类别 else if (receive_country.ToLower().Equals("china-ipe")) { line_count++; if ((Hz2Py.Convert(receive_company)).Length > 24) { alert("第" + line_count + "个包裹的收件公司长度超过了24字节,请更改!!"); return; } if ((Hz2Py.Convert(receive_name)).Length > 24) { alert("第" + line_count + "个包裹的收件人英文名长度或者中文名转化为拼音后超过了24字符,请更改!!"); return; } if ((Hz2Py.Convert(receive_phone)).Length > 15) { alert("第" + line_count + "个包裹的收件人电话长度超过了15字符,ParcelForce 不能处理,请缩短!!"); return; } if ((Hz2Py.Convert(receive_address_line)).Length > 67) { alert("抱歉,您的第 " + line_count + " 个订单由于英文收件地址或者中文收件地址转化为拼音后超过66个字符,ParcelForce 不能处理,请缩短地址,请更改!!"); return; } if ((Hz2Py.Convert(receive_city)).Length > 24) { alert("第" + line_count + "个包裹的收件人 City 长度超过了24个字符,ParcelForce 不能处理,请缩短!!"); return; } if ((Hz2Py.Convert(send_company)).Length > 24) { alert("第" + line_count + "个包裹的发件人公司英文长度或中文转换为拼音后长度超过了24字节,ParcelForce 不能处理,请缩短!!"); return; } if ((Hz2Py.Convert(send_name)).Length > 24) { alert("第" + line_count + "个包裹的发件人名长度超过了24字节,ParcelForce 不能处理,请缩短!!"); return; } if ((Hz2Py.Convert(send_phone)).Length > 15) { alert("第" + line_count + "个包裹的发件人手机号码长度超过了15个字符,ParcelForce 不能处理,请缩短!!"); return; } if ((Hz2Py.Convert(send_addressline)).Length > 67) { alert("第" + line_count + "个包裹的英文发件地址或者中文收件地址转化为拼音后长度超过了67字节,ParcelForce 不能处理,请缩短!!"); return; } if ((Hz2Py.Convert(send_city)).Length > 24) { alert("第" + line_count + "个包裹的发件 City 英文长度或中文转换为拼音后长度超过了24字符,ParcelForce 不能处理,请缩短!!"); return; } if ((Hz2Py.Convert(send_postcode)).Length > 16) { alert("第" + line_count + "个包裹的发件邮编长度超过了16字符,ParcelForce 不能处理,请缩短!!"); return; } if ((Hz2Py.Convert(description)).Length > 30) { alert("第" + line_count + "个包裹的 Description 字段 英文后中文转换为拼音后 长度超过了30字符,ParcelForce 不能处理,请缩短!!"); return; } if (weight.ToString().Length > 8) { alert("第" + line_count + "个包裹的重量 值 超过了 8 位,ParcelForce 不能处理,请缩短!!"); return; } if (height.ToString().Length > 8) { alert("第" + line_count + "个包裹的高度值超过了 8 位,ParcelForce 不能处理,请缩短!!"); return; } if (length.ToString().Length > 8) { alert("第" + line_count + "个包裹的长度值超过了 8 位,ParcelForce 不能处理,请缩短!!"); return; } if (package_value.ToString().Length > 8) { alert("第" + line_count + "个包裹的 包裹价值 长度超过了8位,ParcelForce 不能处理,请缩短!!"); return; } if (width.ToString().Length > 8) { alert("第" + line_count + "个包裹的 宽度 长度超过了 8 位,ParcelForce 不能处理,请缩短!!"); return; } if ((Hz2Py.Convert(comment)).Length > 16) { alert("第" + line_count + "个包裹的 Purpose Of Shipment 字段的英文长度或中文转换为英文后的长度超过了24字符,ParcelForce 不能处理,请缩短!!"); return; } string nowtime = DateTime.Now.ToString("yyyy-MM-dd"); Regex reg = new Regex(@"[0-9]{4}-[0-9]{2}-[0-9]{2}"); if (!reg.Match(delivery_time).Success) { alert("China-IPE 的发件时间格式必须为 YYYY-MM-DD,并且发件时间必须是明天以后"); return; } int k = (int)DateTime.Parse(delivery_time).DayOfWeek; if (delivery_time.CompareTo(nowtime) == -1) { alert("China-IPE 的发件时间格式必须为 YYYY-MM-DD,并且发件时间必须是第二天及以后"); return; } else if ((delivery_time.CompareTo(nowtime) == 0) && k != 6 && k != 0) { string nowminute = DateTime.Now.ToString("yyyy-MM-dd HH:mm"); string temp = nowtime + " 11:30"; if (nowminute.CompareTo(temp) == 1) { if (k == 5) { delivery_time = Convert.ToDateTime(delivery_time).AddDays(3).ToString("yyyy-MM-dd"); } else { delivery_time = Convert.ToDateTime(delivery_time).AddDays(1).ToString("yyyy-MM-dd"); } } } if (delivery_time.CompareTo(DateTime.Now.AddDays(21).ToString("yyyy-MM-dd")) >= 0) { alert("取件时间不能离现在太远,最好不要超过 两个星期!!"); return; } if (k == 6) { delivery_time = Convert.ToDateTime(delivery_time).AddDays(2).ToString("yyyy-MM-dd"); } else if (k == 0) { delivery_time = Convert.ToDateTime(delivery_time).AddDays(1).ToString("yyyy-MM-dd"); } Application.Lock(); string orderNo = Application["packageNo"].ToString(); Application["packageNo"] = (int)Application["packageNo"] + 1; Application.UnLock(); package.Auto_no = auto_no; package.Order_no = "WA" + time.ToString("yyMMddHHmm") + orderNo.PadLeft(8, '0'); package.Name = Session["name"].ToString(); package.CollectionCompanyName = send_company; package.CollectionContactName = send_name; package.CollectionPhone = send_phone; package.CollectionAddressLine = send_addressline; package.CollectionTown = send_city; package.CollectionPostCode = send_postcode; package.CollectionCountry = "UK"; package.RecipientCompanyName = receive_company; package.RecipientContactName = receive_name; package.RecipientPhone = receive_phone; package.RecipientAddressLine = receive_address_line; package.RecipientTown = receive_city; package.RecipeintPostCode = receive_postcode; package.RecipientCountry = "China"; package.Shippingdate = delivery_time; package.Shippingtype = delivery_way; package.Shippingpurpose = comment; package.PackageDescription = description; package.PackageValue = Convert.ToSingle(package_value); package.Insurance = Convert.ToSingle(insurance); if (package.Shippingtype.ToLower().Contains("ollec")) { package.ServiceCode = "PF-IPE-Collection"; } else if (package.Shippingtype.ToLower().Contains("epot")) { package.ServiceCode = "PF-IPE-Depot"; } else if (package.Shippingtype.ToLower().Contains("railer")) { package.ServiceCode = "PF-IPE-Trailer"; } else if (package.Shippingtype.ToLower().Contains("pol")) { package.ServiceCode = "PF-IPE-Pol"; } package.Weight = Convert.ToSingle(weight); package.Length = Convert.ToSingle(length); package.Width = Convert.ToSingle(width); package.Height = Convert.ToSingle(height); package.Volumetric = (float)((package.Length * package.Width * package.Height) / 5000.0); if (package.Weight >= package.Volumetric) { package.Chargeable = package.Weight; } else { package.Chargeable = package.Volumetric; } package.Pay_status = "unpay"; //此处Pay_before_discount设置为100,以后要计算价格 package.Pay_before_discount = new BatchQuoteDAO().getQuote(username, package.ServiceCode, package.Weight, package.Chargeable);// new Quote().getQuote("UK", "China", package.Weight, package.Chargeable, "PostNL", Session["name"].ToString()); package.Pay_before_discount += package.Insurance; package.Discount = 0; package.Pay_after_discount = package.Pay_before_discount; package.Order_time = order.Order_time; package.Less_pay = 0; package.Is_delivery = 0; order.Pay_before_discount += package.Pay_before_discount; package_array.Add(package); } // 如果是 PF-GPR类型 else if (receive_country.ToLower().Equals("china-gpr")) { line_count++; if ((Hz2Py.Convert(receive_company)).Length > 24) { alert("第" + line_count + "个包裹的收件公司长度超过了24字节,请更改!!"); return; } if ((Hz2Py.Convert(receive_name)).Length > 24) { alert("第" + line_count + "个包裹的收件人名长度超过了24字节,请更改!!"); return; } if ((Hz2Py.Convert(receive_phone)).Length > 15) { alert("第" + line_count + "个包裹的收件人电话长度超过了15字节,请更改!!"); return; } if ((Hz2Py.Convert(receive_address_line)).Length > 67) { alert("第" + line_count + "个包裹的收件人地址长度超过了67字节,请更改!!"); return; } if ((Hz2Py.Convert(receive_city)).Length > 24) { alert("第" + line_count + "个包裹的收件人 City 长度超过了24字节,请更改!!"); return; } if ((Hz2Py.Convert(send_company)).Length > 24) { alert("第" + line_count + "个包裹的发件人公司长度超过了24字节,请更改!!"); return; } if ((Hz2Py.Convert(send_name)).Length > 24) { alert("第" + line_count + "个包裹的发件人名长度超过了24字节,请更改!!"); return; } if ((Hz2Py.Convert(send_phone)).Length > 15) { alert("第" + line_count + "个包裹的发件人手机号码长度超过了15字节,请更改!!"); return; } if ((Hz2Py.Convert(send_addressline)).Length > 67) { alert("第" + line_count + "个包裹的收件公司长度超过了67字节,请更改!!"); return; } if ((Hz2Py.Convert(send_city)).Length > 24) { alert("第" + line_count + "个包裹的收件公司长度超过了24字节,请更改!!"); return; } if ((Hz2Py.Convert(send_postcode)).Length > 16) { alert("第" + line_count + "个包裹的收件公司长度超过了16字节,请更改!!"); return; } if ((Hz2Py.Convert(description)).Length > 30) { alert("第" + line_count + "个包裹的 Description字段 长度超过了30字节,请更改!!"); return; } if (weight.ToString().Length > 8) { alert("第" + line_count + "个包裹的重量 值 超过了 8 位,请更改!!"); return; } if (height.ToString().Length > 8) { alert("第" + line_count + "个包裹的高度值超过了 8 位,请更改!!"); return; } if (length.ToString().Length > 8) { alert("第" + line_count + "个包裹的长度值超过了 8 位,请更改!!"); return; } if (package_value.ToString().Length > 8) { alert("第" + line_count + "个包裹的 包裹价值 长度超过了8位,请更改!!"); return; } if (width.ToString().Length > 8) { alert("第" + line_count + "个包裹的 宽度 长度超过了 8 位,请更改!!"); return; } if ((Hz2Py.Convert(comment)).Length > 16) { alert("第" + line_count + "个包裹的Purpose Of Shipment长度超过了24字节,请更改!!"); return; } string nowtime = DateTime.Now.ToString("yyyy-MM-dd"); Regex reg = new Regex(@"[0-9]{4}-[0-9]{2}-[0-9]{2}"); if (!reg.Match(delivery_time).Success) { alert("China-IPE,China-GPR 的发件时间格式必须为 YYYY-MM-DD,并且发件时间必须是明天以后,请从 PostNL首页下载模板!!"); return; } int k = (int)DateTime.Parse(delivery_time).DayOfWeek; if (delivery_time.CompareTo(nowtime) == -1) { alert("China-IPE,China-GPR 的发件时间格式必须为 YYYY-MM-DD,并且发件时间必须是明天以后"); return; } else if (delivery_time.CompareTo(nowtime) == 0) { string nowminute = DateTime.Now.ToString("yyyy-MM-dd HH:mm"); string temp = nowtime + " 11:30"; if (nowminute.CompareTo(temp) == 1) { if (k == 5) { delivery_time = Convert.ToDateTime(delivery_time).AddDays(3).ToString("yyyy-MM-dd"); } } delivery_time = Convert.ToDateTime(delivery_time).AddDays(1).ToString("yyyy-MM-dd"); } if (delivery_time.CompareTo(DateTime.Now.AddDays(21).ToString("yyyy-MM-dd")) >= 0) { alert("取件时间不能离现在太远,最好不要超过 两个星期!!"); return; } if (k == 6) { delivery_time = Convert.ToDateTime(delivery_time).AddDays(2).ToString("yyyy-MM-dd"); } else if (k == 0) { delivery_time = Convert.ToDateTime(delivery_time).AddDays(1).ToString("yyyy-MM-dd"); } Application.Lock(); string orderNo = Application["packageNo"].ToString(); Application["packageNo"] = (int)Application["packageNo"] + 1; Application.UnLock(); package.Auto_no = auto_no; package.Order_no = "WA" + time.ToString("yyyyMMddHHmm") + orderNo.PadLeft(8, '0'); package.Name = Session["name"].ToString(); package.CollectionCompanyName = send_company; package.CollectionContactName = send_name; package.CollectionPhone = send_phone; package.CollectionAddressLine = send_addressline; package.CollectionTown = send_city; package.CollectionPostCode = send_postcode; package.CollectionCountry = "UK"; package.RecipientCompanyName = receive_company; package.RecipientContactName = receive_name; package.RecipientPhone = receive_phone; package.RecipientAddressLine = receive_address_line; package.RecipientTown = receive_city; package.RecipeintPostCode = receive_postcode; package.RecipientCountry = "China"; package.Shippingdate = delivery_time; package.Shippingtype = delivery_way; package.Shippingpurpose = comment; package.PackageDescription = description; package.PackageValue = Convert.ToSingle(package_value); package.Insurance = Convert.ToSingle(insurance); if (package.Shippingtype.ToLower().Contains("ollec")) { package.ServiceCode = "PF-GPR-Collection"; } else { package.ServiceCode = "PF-GPR-Delivery"; } package.Weight = Convert.ToSingle(weight); package.Length = Convert.ToSingle(length); package.Width = Convert.ToSingle(width); package.Height = Convert.ToSingle(height); package.Volumetric = (float)((package.Length * package.Width * package.Height) / 5000.0); if (package.Weight >= package.Volumetric) { package.Chargeable = package.Weight; } else { package.Chargeable = package.Volumetric; } package.Pay_status = "unpay"; //此处Pay_before_discount设置为100,以后要计算价格 package.Pay_before_discount = new BatchQuoteDAO().getQuote(username, package.ServiceCode, package.Weight, package.Chargeable);// new Quote().getQuote("UK", "China", package.Weight, package.Chargeable, "PostNL", Session["name"].ToString()); package.Pay_before_discount += package.Insurance; package.Discount = 0; package.Pay_after_discount = package.Pay_before_discount; package.Order_time = order.Order_time; package.Less_pay = 0; package.Is_delivery = 0; order.Pay_before_discount += package.Pay_before_discount; package_array.Add(package); } // 如果是 EMS else if (receive_country.ToLower().Equals("china-ems")) { line_count++; Application.Lock(); string orderNo = Application["packageNo"].ToString(); Application["packageNo"] = (int)Application["packageNo"] + 1; Application.UnLock(); package.Auto_no = auto_no; package.Order_no = "WA" + time.ToString("yyyyMMddHHmm") + orderNo.PadLeft(8, '0'); package.Name = Session["name"].ToString(); package.CollectionCompanyName = send_company; package.CollectionContactName = send_name; package.CollectionPhone = send_phone; package.CollectionAddressLine = send_addressline; package.CollectionTown = send_city; package.CollectionPostCode = send_postcode; package.CollectionCountry = "UK"; package.RecipientCompanyName = receive_company; package.RecipientContactName = receive_name; package.RecipientPhone = receive_phone; package.RecipientAddressLine = receive_address_line; package.RecipientTown = receive_city; package.RecipeintPostCode = receive_postcode; package.RecipientCountry = "China"; package.Shippingdate = delivery_time; package.Shippingtype = delivery_way; package.Shippingpurpose = comment; package.PackageDescription = description; package.PackageValue = Convert.ToSingle(package_value); package.Insurance = Convert.ToSingle(insurance); package.ServiceCode = "EMS"; package.Weight = Convert.ToSingle(weight); package.Length = Convert.ToSingle(length); package.Width = Convert.ToSingle(width); package.Height = Convert.ToSingle(height); package.Volumetric = (float)((package.Length * package.Width * package.Height) / 5000.0); if (package.Weight >= package.Volumetric) { package.Chargeable = package.Weight; } else { package.Chargeable = package.Volumetric; } package.Pay_status = "unpay"; //此处Pay_before_discount设置为100,以后要计算价格 package.Pay_before_discount = new BatchQuoteDAO().getQuote(username, package.ServiceCode, package.Weight, package.Chargeable);// new Quote().getQuote("UK", "China", package.Weight, package.Chargeable, "PostNL", Session["name"].ToString()); package.Pay_before_discount += package.Insurance; package.Discount = 0; package.Pay_after_discount = package.Pay_before_discount; package.Order_time = order.Order_time; package.Less_pay = 0; package.Is_delivery = 0; order.Pay_before_discount += package.Pay_before_discount; package_array.Add(package); } else { alert("收件国家必须是 China-NL、China-IPE、China-GPR 到 港澳台 也一样也是 China-NL、China-IPE、China-GPR "); return; } } } order.Discount = 0; order.Pay_after_discount = order.Pay_before_discount; order.Order_count = line_count; //确实有包裹 if (line_count != 0) { //添加订单的详细信息 for (int i = 0; i < package_array.Count; i++) { AutoOrderList temp_package = (AutoOrderList)package_array[i]; new AutoOrderListDAO().addAutoOrderList(temp_package); } //添加订单 new AutoOrderDAO().addAutoOrder(order); } } if (line_count == 0) { alert("Excel不能为空!!!"); } else { Response.Redirect("../my-shopping-cart.aspx?flag=excel"); } }
//填写完包裹详细信息后的下一步的实现 protected void btn_next_step_Click(object sender, EventArgs e) { //发件地址、收件地址 string sendAddr = Request.Form["txt_send"]; string receiveAddr = Request.Form["txt_receive"]; //购买保险、及取件日期 string insurance = Request.Form["insurance_select"]; string collectiondate = Request.Form["collection_date"]; //包裹描述及包裹价值 string description = Request.Form["content"]; string value = Request.Form["value"]; // 发件地址字符串数组、收件地址字符串数组、是否购买保险数组、取件日期数组 string[] sendAddr_array = sendAddr.Split(','); string[] receiveAddr_array = receiveAddr.Split(','); string[] insurance_array = insurance.Split(','); string[] collectiondate_array = collectiondate.Split(','); //包裹描述数组、包裹价值数组 string[] description_array = description.Split(','); string[] value_array = value.Split(','); order_array = new ArrayList(); package_array = new ArrayList(); int package_count = 0; packages_to_SameAddress = (ArrayList)Session["packageTOSameAddress"]; for (int i = 0; i < packages_to_SameAddress.Count; i++) { PackagesToSameAddress package_to_same_address = (PackagesToSameAddress)packages_to_SameAddress[i]; string departure = package_to_same_address.Departure; string destination = package_to_same_address.Destination; string postway = package_to_same_address.Postway; Order order = new Order(); DateTime temp_time = DateTime.Now; Application.Lock(); string interfaceOrderNo = Application["orderNo"].ToString(); Application["orderNo"] = (int)Application["orderNo"] + 1; Application.UnLock(); string order_number = "WM" + temp_time.ToString("yyMMddhhmm") + interfaceOrderNo.PadLeft(8, '0'); order.Order_number = order_number; order.Name = Session["name"].ToString(); order.Order_time = temp_time; order.Is_pay = "unpay"; order.Is_show = "true"; order.Post_way = postway; //订单的发件地址 string[] send_array = sendAddr_array[i].Split(';'); order.CollectionContactName = send_array[0]; order.CollectionCompanyName = send_array[1]; order.CollectionAddressLine = send_array[2]; order.CollectionTown = send_array[3]; order.CollectionPostCode = send_array[4]; order.CollectionCountry = send_array[5]; order.CollectionPhone = send_array[6]; //订单的收件地址 string[] receive_array = receiveAddr_array[i].Split(';'); order.RecipientContactName = receive_array[0]; order.RecipientCompanyName = receive_array[1]; order.RecipientAddressLine = receive_array[2]; order.RecipientTown = receive_array[3]; order.RecipientPostCode = receive_array[4]; order.RecipientCountry = receive_array[5]; order.RecipientPhone = receive_array[6]; //订单的保险 order.Insurance = Convert.ToSingle(insurance_array[i]); //订单的取件日期 order.Delivery_date = collectiondate_array[i]; if (Session["delivery_way"] != null) { order.Delivery_way = Session["delivery_way"].ToString(); } else { order.Delivery_way = "Collection"; } order.Weight = 0; order.Pay_after_discount = 0; int quantity = 0; string wp_track_no = ""; ArrayList package_measure_array = package_to_same_address.Package_Array; //处理订单中的包裹 for (int j = 0; j < package_measure_array.Count; j++) { PackageMeasure package_measure = (PackageMeasure)package_measure_array[j]; quantity += package_measure.Count; for (int k = 0; k < package_measure.Count; k++) { Package package = new Package(); Application.Lock(); string interfacepackageno = Application["packageNo"].ToString(); Application["packageNo"] = (int)Application["packageNo"] + 1; Application.UnLock(); package.Description = description_array[package_count]; package.Package_value = Convert.ToSingle(value_array[package_count]); package.Order_number = order_number; package.Wp_track_no = "WP" + temp_time.ToString("yyMMddhhmm") + interfacepackageno.PadLeft(8, '0'); package.Weight = package_measure.Weight; package.Length = package_measure.Length; package.Width = package_measure.Width; package.Height = package_measure.Height; package.Name = Session["name"].ToString(); package.Post_way = postway; package.Pay = new InterFaceQuote().getQuote(package.Name, destination, package.Weight, package.Length, package.Width, package.Height, postway); package.Departure = departure; package.Destination = destination; package.Is_pay = "unpay"; if (wp_track_no != "") { wp_track_no += "," + package.Wp_track_no; } else { wp_track_no += package.Wp_track_no; } //判断是不是PF,如果是PF则要进行中文转换 if (package.Post_way.ToUpper().Contains("PF")) { package.Description = Hz2Py.Convert(package.Description); if (package.Package_value.ToString().Length > 8) { alert("第" + (i + 1) + "个订单的第" + (j + 1) + "个包裹的报过价值长度超过了 8 位,Parcelforce 不能处理,请更改!!"); return; } } if (package.Post_way.ToUpper().Contains("POSTNL")) { if (package.Description.Contains("座椅") || package.Description.Contains("车座")) { package.Volumetric = (package.Length * package.Width * package.Height) / 6000.0f; } package.Chargeable = package.Weight > package.Volumetric ? package.Weight : package.Volumetric; } else { package.Volumetric = (package.Length * package.Width * package.Height) / 5000.0f; package.Chargeable = package.Weight > package.Volumetric ? package.Weight : package.Volumetric; } //订单中包裹的总重 order.Weight += package.Chargeable; order.Pay_after_discount += package.Pay; //包裹个数 ++ package_count++; package_array.Add(package); } } order.Quantity = quantity; order.Pay_before_discount = order.Pay_after_discount; order.Discount = 0; order.Wp_track_no = wp_track_no; if (order.Post_way.ToUpper().Contains("PF")) { { // 替换字符 // 替换手机号码中的 “—”、“-” order.RecipientPhone = order.RecipientPhone.Replace("-", ""); order.RecipientPhone = order.RecipientPhone.Replace("-", ""); order.RecipientPhone = order.RecipientPhone.Replace("—", ""); order.CollectionPhone = order.CollectionPhone.Replace("—", ""); order.CollectionPhone = order.CollectionPhone.Replace("-", ""); order.CollectionPhone = order.CollectionPhone.Replace("-", ""); order.CollectionCompanyName = order.CollectionCompanyName.Replace("。", ""); order.CollectionContactName = order.CollectionContactName.Replace("。", ""); order.CollectionAddressLine = order.CollectionAddressLine.Replace("。", ""); order.CollectionTown = order.CollectionTown.Replace("。", ""); order.CollectionPostCode = order.CollectionPostCode.Replace("。", ""); order.CollectionCountry = order.CollectionCountry.Replace("。", ""); order.RecipientContactName = order.RecipientContactName.Replace("。", ""); order.RecipientCompanyName = order.RecipientCompanyName.Replace("。", ""); order.RecipientAddressLine = order.RecipientAddressLine.Replace("。", ""); order.RecipientTown = order.RecipientTown.Replace("。", ""); order.RecipientPostCode = order.RecipientPostCode.Replace("。", ""); order.RecipientCountry = order.RecipientCountry.Replace("。", ""); order.CollectionCompanyName = order.CollectionCompanyName.Replace("—", ""); order.CollectionContactName = order.CollectionContactName.Replace("—", ""); order.CollectionAddressLine = order.CollectionAddressLine.Replace("—", ""); order.CollectionTown = order.CollectionTown.Replace("—", ""); order.CollectionPostCode = order.CollectionPostCode.Replace("—", ""); order.CollectionCountry = order.CollectionCountry.Replace("—", ""); order.RecipientContactName = order.RecipientContactName.Replace("—", ""); order.RecipientCompanyName = order.RecipientCompanyName.Replace("—", ""); order.RecipientAddressLine = order.RecipientAddressLine.Replace("—", ""); order.RecipientTown = order.RecipientTown.Replace("—", ""); order.RecipientPostCode = order.RecipientPostCode.Replace("—", ""); order.RecipientCountry = order.RecipientCountry.Replace("—", ""); order.CollectionCompanyName = order.CollectionCompanyName.Replace("-", ""); order.CollectionContactName = order.CollectionContactName.Replace("-", ""); order.CollectionAddressLine = order.CollectionAddressLine.Replace("-", ""); order.CollectionTown = order.CollectionTown.Replace("-", ""); order.CollectionPostCode = order.CollectionPostCode.Replace("-", ""); order.CollectionCountry = order.CollectionCountry.Replace("-", ""); order.RecipientContactName = order.RecipientContactName.Replace("-", ""); order.RecipientCompanyName = order.RecipientCompanyName.Replace("-", ""); order.RecipientAddressLine = order.RecipientAddressLine.Replace("-", ""); order.RecipientTown = order.RecipientTown.Replace("-", ""); order.RecipientPostCode = order.RecipientPostCode.Replace("-", ""); order.RecipientCountry = order.RecipientCountry.Replace("-", ""); order.CollectionCompanyName = order.CollectionCompanyName.Replace("(", ""); order.CollectionContactName = order.CollectionContactName.Replace("(", ""); order.CollectionAddressLine = order.CollectionAddressLine.Replace("(", ""); order.CollectionTown = order.CollectionTown.Replace("(", ""); order.CollectionPostCode = order.CollectionPostCode.Replace("(", ""); order.CollectionCountry = order.CollectionCountry.Replace("(", ""); order.CollectionPhone = order.CollectionPhone.Replace("(", ""); order.RecipientContactName = order.RecipientContactName.Replace("(", ""); order.RecipientCompanyName = order.RecipientCompanyName.Replace("(", ""); order.RecipientAddressLine = order.RecipientAddressLine.Replace("(", ""); order.RecipientTown = order.RecipientTown.Replace("(", ""); order.RecipientPostCode = order.RecipientPostCode.Replace("(", ""); order.RecipientCountry = order.RecipientCountry.Replace("(", ""); order.RecipientPhone = order.RecipientPhone.Replace("(", ""); order.CollectionCompanyName = order.CollectionCompanyName.Replace(")", ""); order.CollectionContactName = order.CollectionContactName.Replace(")", ""); order.CollectionAddressLine = order.CollectionAddressLine.Replace(")", ""); order.CollectionTown = order.CollectionTown.Replace(")", ""); order.CollectionPostCode = order.CollectionPostCode.Replace(")", ""); order.CollectionCountry = order.CollectionCountry.Replace(")", ""); order.CollectionPhone = order.CollectionPhone.Replace(")", ""); order.RecipientContactName = order.RecipientContactName.Replace(")", ""); order.RecipientCompanyName = order.RecipientCompanyName.Replace(")", ""); order.RecipientAddressLine = order.RecipientAddressLine.Replace(")", ""); order.RecipientTown = order.RecipientTown.Replace(")", ""); order.RecipientPostCode = order.RecipientPostCode.Replace(")", ""); order.RecipientCountry = order.RecipientCountry.Replace(")", ""); order.RecipientPhone = order.RecipientPhone.Replace(")", ""); } order.CollectionContactName = Hz2Py.Convert(order.RecipientCompanyName); order.CollectionCompanyName = Hz2Py.Convert(order.CollectionCompanyName); order.CollectionAddressLine = Hz2Py.Convert(order.CollectionAddressLine); order.CollectionCountry = Hz2Py.Convert(order.CollectionCountry); order.CollectionTown = Hz2Py.Convert(order.CollectionTown); order.CollectionPostCode = Hz2Py.Convert(order.CollectionPostCode); order.RecipientContactName = Hz2Py.Convert(order.RecipientContactName); order.RecipientCompanyName = Hz2Py.Convert(order.RecipientCompanyName); order.RecipientCountry = Hz2Py.Convert(order.RecipientCountry); order.RecipientTown = Hz2Py.Convert(order.RecipientTown); order.RecipientPhone = Hz2Py.Convert(order.RecipientPhone); order.RecipientPostCode = Hz2Py.Convert(order.RecipientPostCode); order.RecipientAddressLine = Hz2Py.Convert(order.RecipientAddressLine); if (order.RecipientCompanyName.Length > 24) { alert("第" + (i + 1) + "个订单的收件公司长度超过了24字节,请更改!!"); return; } if (order.RecipientContactName.Length > 24) { alert("第" + (i + 1) + "个订单的收件人英文名长度或者中文名转化为拼音后超过了24字符,请更改!!"); return; } if (order.RecipientPhone.Length > 15) { alert("第" + (i + 1) + "个订单的收件人电话长度超过了15字符,ParcelForce 不能处理,请缩短!!"); return; } if (order.RecipientAddressLine.Length > 67) { alert("抱歉,您的第 " + i + " 个订单由于英文收件地址或者中文收件地址转化为拼音后超过66个字符,ParcelForce 不能处理,请缩短地址,请更改!!"); return; } if (order.RecipientTown.Length > 24) { alert("第" + (i + 1) + "个订单的收件人 City 长度超过了24个字符,ParcelForce 不能处理,请缩短!!"); return; } if (order.CollectionCompanyName.Length > 24) { alert("第" + (i + 1) + "个订单的发件人公司英文长度或中文转换为拼音后长度超过了24字节,ParcelForce 不能处理,请缩短!!"); return; } if (order.CollectionContactName.Length > 24) { alert("第" + (i + 1) + "个订单的发件人名长度超过了24字节,ParcelForce 不能处理,请缩短!!"); return; } if (order.CollectionPhone.Length > 15) { alert("第" + (i + 1) + "个包裹的发件人手机号码长度超过了15个字符,ParcelForce 不能处理,请缩短!!"); return; } if (order.CollectionAddressLine.Length > 67) { alert("第" + (i + 1) + "个订单的英文发件地址或者中文收件地址转化为拼音后长度超过了67字节,ParcelForce 不能处理,请缩短!!"); return; } if (order.CollectionTown.Length > 24) { alert("第" + (i + 1) + "个订单的发件 City 英文长度或中文转换为拼音后长度超过了24字符,ParcelForce 不能处理,请缩短!!"); return; } if (order.CollectionPostCode.Length > 16) { alert("第" + (i + 1) + "个订单的发件邮编长度超过了16字符,ParcelForce 不能处理,请缩短!!"); return; } } order_array.Add(order); } //向数据库中添加包谷信息 for (int i = 0; i < package_array.Count; i++) { Package package = (Package)package_array[i]; new PackageDAO().addPackage(package); } //向数据库中添加订单信息 for (int i = 0; i < order_array.Count; i++) { Order order = (Order)order_array[i]; new OrderDAO().addOrder(order); } Response.Redirect("../my-shopping-cart.aspx?flag=interface"); }
/// <summary> /// 组织设备查询当前队例的返回值 /// </summary> /// <returns></returns> private string FormatSelectList() { List <Command> CMDS = nx700.CMDS; if (CMDS == null || CMDS.Count == 0) { return("I,0,,,,,," + (char)0x3); } //int count = CMDS.Count >= 4 ? 4 : CMDS.Count; int count = CMDS.Count; StringBuilder sb = new StringBuilder("I,"); sb.Append(CMDS.Count); lock (CMDS) { for (int i = 0; i < count; i++) { Command item = CMDS[i]; //检查号 if (i == 0) { sb.Append(","); } sb.Append(item.Id.PadRight(13, ' ')); //宠物ID sb.Append("," + item.PetId.PadRight(13, ' ')); //宠物名 string name = Hz2Py.ChineseToPinYin(item.PetName).ToLower(); if (name.Length > 13) { name = name.Remove(12); } sb.Append("," + name.PadRight(13, ' ')); ////结果集编码 //sb.Append("," + item.Code); //年龄 int age = 1; if (int.TryParse(item.Age, out age)) { age = age / 12; } //品种 int kindof = 14; switch (item.KindOf) { case KindOfType.犬: if (age < 1) { kindof = 21; } break; case KindOfType.猫: if (age < 1) { kindof = 22; } else { kindof = 15; } break; case KindOfType.兔: kindof = 16; break; case KindOfType.小鼠: case KindOfType.大鼠: kindof = 19; break; } sb.Append("," + kindof.ToString().PadRight(2, ' ')); //性别 0雄 1雌 int Gender = 0; if (item.Gender == GenderType.Male) { Gender = 1; } sb.Append("," + Gender); //添加年龄 sb.Append("," + age.ToString().PadRight(3, ' ')); //添加区块传输结束符 sb.Append((char)0x17); } } sb.Remove(sb.Length - 1, 1); //添加结束符 sb.Append((char)0x3); log.Msg("发送数据:" + sb.ToString()); return(sb.ToString()); }
////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// //填写包裹详细信息的实现 protected void btn_toMyShoopingCart_Click(object sender, EventArgs e) { ArrayList order_array = new ArrayList(); ArrayList package_array = new ArrayList(); // 发件地址 string sendAddr = Request.Form["txt_send_addr"]; //收件地址 string receiveStr = Request.Form["receiveAddr"]; //是否购买保险 string insuranceStr = Request.Form["insurance_select"]; //取件时间 string date = Request.Form["collection_date"]; //包裹描述 string content = Request.Form["content"]; //包裹价值 string value = Request.Form["value"]; //所有订单共一个发件地址 string[] sendaddress = sendAddr.Split(';'); //收件地址字符串数组 string[] receiveAddr_array = receiveStr.Split(','); //购买保险字符串数组 string[] insurance_array = insuranceStr.Split(','); //取件时间字符串数组 string[] date_array = date.Split(','); //下面的不一样 string[] content_array = content.Split(','); string[] value_array = value.Split(','); int description_count = 0; batchOrders = (ArrayList)Session["batch_orders"]; for (int i = 0; i < batchOrders.Count; i++) { BatchOrder batchorder = (BatchOrder)batchOrders[i]; Order order = new Order(); DateTime temp_time = DateTime.Now; Application.Lock(); string interfaceOrderNo = Application["orderNo"].ToString(); Application["orderNo"] = (int)Application["orderNo"] + 1; Application.UnLock(); string order_number = "WM" + temp_time.ToString("yyMMddhhmm") + interfaceOrderNo.PadLeft(8, '0'); order.Name = Session["name"].ToString(); order.Order_number = order_number; //发件地址 order.CollectionContactName = sendaddress[0]; order.CollectionCompanyName = sendaddress[1]; order.CollectionAddressLine = sendaddress[2]; order.CollectionTown = sendaddress[3]; order.CollectionPostCode = sendaddress[4]; order.CollectionCountry = sendaddress[5]; order.CollectionPhone = sendaddress[6]; //收件地址 string[] receiveaddress = receiveAddr_array[i].Split(';'); order.RecipientContactName = receiveaddress[0]; order.RecipientCompanyName = receiveaddress[1]; order.RecipientAddressLine = receiveaddress[2]; order.RecipientTown = receiveaddress[3]; order.RecipientPostCode = receiveaddress[4]; order.RecipientCountry = receiveaddress[5]; order.RecipientPhone = receiveaddress[6]; order.Order_time = temp_time; order.Is_pay = "unpay"; order.Is_show = "true"; order.Post_way = batchorder.PostWay; order.Quantity = batchorder.Count; //订单本地取件费用 order.Local_pick_pay = 100; order.Insurance = Convert.ToSingle(insurance_array[i]); order.Delivery_date = date_array[i]; if (Session["delivery_way"] != null) { order.Delivery_way = Session["delivery_way"].ToString(); } else { order.Delivery_way = "Collection"; } order.Weight = 0; order.Pay_before_discount = 0; //处理取件时间 { int k = (int)DateTime.Parse(order.Delivery_date).DayOfWeek; string nowtime = DateTime.Now.ToString("yyyy-MM-dd"); if ((order.Delivery_date.CompareTo(nowtime) <= 0) && k != 6 && k != 0) { string nowminute = DateTime.Now.ToString("yyyy-MM-dd HH:mm"); string temp = nowtime + " 11:30"; if (nowminute.CompareTo(temp) == 1) { if (k == 5) { order.Delivery_date = Convert.ToDateTime(order.Delivery_date).AddDays(3).ToString("yyyy-MM-dd"); } else { order.Delivery_date = Convert.ToDateTime(order.Delivery_date).AddDays(1).ToString("yyyy-MM-dd"); } } } if (k == 6) { order.Delivery_date = Convert.ToDateTime(order.Delivery_date).AddDays(2).ToString("yyyy-MM-dd"); } else if (k == 0) { order.Delivery_date = Convert.ToDateTime(order.Delivery_date).AddDays(1).ToString("yyyy-MM-dd"); } if (order.Delivery_date.CompareTo(DateTime.Now.AddDays(21).ToString("yyyy-MM-dd")) >= 0) { alert("取件时间不能离现在太远,最好不要超过 两个星期!!"); return; } } string order_wp_track_no = ""; for (int j = 0; j < batchorder.Count; j++) { Package package = new Package(); Application.Lock(); string interfacepackageno = Application["packageNo"].ToString(); Application["packageNo"] = (int)Application["packageNo"] + 1; Application.UnLock(); string wp_track_no = "WP" + temp_time.ToString("yyMMddhhmm") + interfacepackageno.PadLeft(8, '0'); package.Name = Session["name"].ToString(); package.Order_number = order_number; package.Wp_track_no = wp_track_no; package.Weight = batchorder.Weight; package.Length = batchorder.Length; package.Width = batchorder.Width; package.Height = batchorder.Height; package.Departure = batchorder.Departure; package.Destination = batchorder.Destination; package.Post_way = batchorder.PostWay; package.Pay = new InterFaceQuote().getQuote(package.Name, batchorder.Destination, batchorder.Weight, batchorder.Length, batchorder.Width, batchorder.Height, batchorder.PostWay); package.Description = content_array[description_count]; package.Package_value = Convert.ToSingle(value_array[description_count]); package.Is_pay = "unpay"; description_count++; if (order_wp_track_no != "") { order_wp_track_no += "," + wp_track_no; } else { order_wp_track_no += wp_track_no; } //判断是不是PF,如果是PF则要进行中文转换 if (package.Post_way.ToUpper().Contains("PF")) { package.Description = Hz2Py.Convert(package.Description); if (package.Package_value.ToString().Length > 8) { alert("第" + (i + 1) + "个订单的第" + (j + 1) + "个包裹的报过价值长度超过了 8 位,Parcelforce 不能处理,请更改!!"); return; } } if (package.Post_way.ToUpper().Contains("POSTNL")) { if (package.Description.Contains("座椅") || package.Description.Contains("车座")) { package.Volumetric = (package.Length * package.Width * package.Height) / 6000.0f; } package.Chargeable = package.Weight > package.Volumetric ? package.Weight : package.Volumetric; } else { package.Volumetric = (package.Length * package.Width * package.Height) / 5000.0f; package.Chargeable = package.Weight > package.Volumetric?package.Weight:package.Volumetric; } //订单总重量 order.Weight += package.Chargeable; //订单总共付款 order.Pay_before_discount += package.Pay; package_array.Add(package); } if (order.Post_way.ToUpper().Contains("PF")) { { // 替换字符 // 替换手机号码中的 “—”、“-” order.RecipientPhone = order.RecipientPhone.Replace("-", ""); order.RecipientPhone = order.RecipientPhone.Replace("-", ""); order.RecipientPhone = order.RecipientPhone.Replace("—", ""); order.CollectionPhone = order.CollectionPhone.Replace("—", ""); order.CollectionPhone = order.CollectionPhone.Replace("-", ""); order.CollectionPhone = order.CollectionPhone.Replace("-", ""); order.CollectionCompanyName = order.CollectionCompanyName.Replace("。", ""); order.CollectionContactName = order.CollectionContactName.Replace("。", ""); order.CollectionAddressLine = order.CollectionAddressLine.Replace("。", ""); order.CollectionTown = order.CollectionTown.Replace("。", ""); order.CollectionPostCode = order.CollectionPostCode.Replace("。", ""); order.CollectionCountry = order.CollectionCountry.Replace("。", ""); order.CollectionPhone = order.CollectionPhone.Replace("。", ""); order.RecipientContactName = order.RecipientContactName.Replace("。", ""); order.RecipientCompanyName = order.RecipientCompanyName.Replace("。", ""); order.RecipientAddressLine = order.RecipientAddressLine.Replace("。", ""); order.RecipientTown = order.RecipientTown.Replace("。", ""); order.RecipientPostCode = order.RecipientPostCode.Replace("。", ""); order.RecipientCountry = order.RecipientCountry.Replace("。", ""); order.RecipientPhone = order.RecipientPhone.Replace("。", ""); order.CollectionCompanyName = order.CollectionCompanyName.Replace("—", ""); order.CollectionContactName = order.CollectionContactName.Replace("—", ""); order.CollectionAddressLine = order.CollectionAddressLine.Replace("—", ""); order.CollectionTown = order.CollectionTown.Replace("—", ""); order.CollectionPostCode = order.CollectionPostCode.Replace("—", ""); order.CollectionCountry = order.CollectionCountry.Replace("—", ""); order.RecipientContactName = order.RecipientContactName.Replace("—", ""); order.RecipientCompanyName = order.RecipientCompanyName.Replace("—", ""); order.RecipientAddressLine = order.RecipientAddressLine.Replace("—", ""); order.RecipientTown = order.RecipientTown.Replace("—", ""); order.RecipientPostCode = order.RecipientPostCode.Replace("—", ""); order.RecipientCountry = order.RecipientCountry.Replace("—", ""); order.CollectionCompanyName = order.CollectionCompanyName.Replace("-", ""); order.CollectionContactName = order.CollectionContactName.Replace("-", ""); order.CollectionAddressLine = order.CollectionAddressLine.Replace("-", ""); order.CollectionTown = order.CollectionTown.Replace("-", ""); order.CollectionPostCode = order.CollectionPostCode.Replace("-", ""); order.CollectionCountry = order.CollectionCountry.Replace("-", ""); order.RecipientContactName = order.RecipientContactName.Replace("-", ""); order.RecipientCompanyName = order.RecipientCompanyName.Replace("-", ""); order.RecipientAddressLine = order.RecipientAddressLine.Replace("-", ""); order.RecipientTown = order.RecipientTown.Replace("-", ""); order.RecipientPostCode = order.RecipientPostCode.Replace("-", ""); order.RecipientCountry = order.RecipientCountry.Replace("-", ""); order.CollectionCompanyName = order.CollectionCompanyName.Replace("(", ""); order.CollectionContactName = order.CollectionContactName.Replace("(", ""); order.CollectionAddressLine = order.CollectionAddressLine.Replace("(", ""); order.CollectionTown = order.CollectionTown.Replace("(", ""); order.CollectionPostCode = order.CollectionPostCode.Replace("(", ""); order.CollectionCountry = order.CollectionCountry.Replace("(", ""); order.CollectionPhone = order.CollectionPhone.Replace("(", ""); order.RecipientContactName = order.RecipientContactName.Replace("(", ""); order.RecipientCompanyName = order.RecipientCompanyName.Replace("(", ""); order.RecipientAddressLine = order.RecipientAddressLine.Replace("(", ""); order.RecipientTown = order.RecipientTown.Replace("(", ""); order.RecipientPostCode = order.RecipientPostCode.Replace("(", ""); order.RecipientCountry = order.RecipientCountry.Replace("(", ""); order.RecipientPhone = order.RecipientPhone.Replace("(", ""); order.CollectionCompanyName = order.CollectionCompanyName.Replace(")", ""); order.CollectionContactName = order.CollectionContactName.Replace(")", ""); order.CollectionAddressLine = order.CollectionAddressLine.Replace(")", ""); order.CollectionTown = order.CollectionTown.Replace(")", ""); order.CollectionPostCode = order.CollectionPostCode.Replace(")", ""); order.CollectionCountry = order.CollectionCountry.Replace(")", ""); order.CollectionPhone = order.CollectionPhone.Replace(")", ""); order.RecipientContactName = order.RecipientContactName.Replace(")", ""); order.RecipientCompanyName = order.RecipientCompanyName.Replace(")", ""); order.RecipientAddressLine = order.RecipientAddressLine.Replace(")", ""); order.RecipientTown = order.RecipientTown.Replace(")", ""); order.RecipientPostCode = order.RecipientPostCode.Replace(")", ""); order.RecipientCountry = order.RecipientCountry.Replace(")", ""); order.RecipientPhone = order.RecipientPhone.Replace(")", ""); } order.CollectionContactName = Hz2Py.Convert(order.RecipientCompanyName); order.CollectionCompanyName = Hz2Py.Convert(order.CollectionCompanyName); order.CollectionAddressLine = Hz2Py.Convert(order.CollectionAddressLine); order.CollectionCountry = Hz2Py.Convert(order.CollectionCountry); order.CollectionTown = Hz2Py.Convert(order.CollectionTown); order.CollectionPostCode = Hz2Py.Convert(order.CollectionPostCode); order.RecipientContactName = Hz2Py.Convert(order.RecipientContactName); order.RecipientCompanyName = Hz2Py.Convert(order.RecipientCompanyName); order.RecipientCountry = Hz2Py.Convert(order.RecipientCountry); order.RecipientTown = Hz2Py.Convert(order.RecipientTown); order.RecipientPhone = Hz2Py.Convert(order.RecipientPhone); order.RecipientPostCode = Hz2Py.Convert(order.RecipientPostCode); order.RecipientAddressLine = Hz2Py.Convert(order.RecipientAddressLine); if (order.RecipientCompanyName.Length > 24) { alert("第" + (i + 1) + "个订单的收件公司长度超过了24字节,请更改!!"); return; } if (order.RecipientContactName.Length > 24) { alert("第" + (i + 1) + "个订单的收件人英文名长度或者中文名转化为拼音后超过了24字符,请更改!!"); return; } if (order.RecipientPhone.Length > 15) { alert("第" + (i + 1) + "个订单的收件人电话长度超过了15字符,ParcelForce 不能处理,请缩短!!"); return; } if (order.RecipientAddressLine.Length > 67) { alert("抱歉,您的第 " + i + " 个订单由于英文收件地址或者中文收件地址转化为拼音后超过66个字符,ParcelForce 不能处理,请缩短地址,请更改!!"); return; } if (order.RecipientTown.Length > 24) { alert("第" + (i + 1) + "个订单的收件人 City 长度超过了24个字符,ParcelForce 不能处理,请缩短!!"); return; } if (order.CollectionCompanyName.Length > 24) { alert("第" + (i + 1) + "个订单的发件人公司英文长度或中文转换为拼音后长度超过了24字节,ParcelForce 不能处理,请缩短!!"); return; } if (order.CollectionContactName.Length > 24) { alert("第" + (i + 1) + "个订单的发件人名长度超过了24字节,ParcelForce 不能处理,请缩短!!"); return; } if (order.CollectionPhone.Length > 15) { alert("第" + (i + 1) + "个包裹的发件人手机号码长度超过了15个字符,ParcelForce 不能处理,请缩短!!"); return; } if (order.CollectionAddressLine.Length > 67) { alert("第" + (i + 1) + "个订单的英文发件地址或者中文收件地址转化为拼音后长度超过了67字节,ParcelForce 不能处理,请缩短!!"); return; } if (order.CollectionTown.Length > 24) { alert("第" + (i + 1) + "个订单的发件 City 英文长度或中文转换为拼音后长度超过了24字符,ParcelForce 不能处理,请缩短!!"); return; } if (order.CollectionPostCode.Length > 16) { alert("第" + (i + 1) + "个订单的发件邮编长度超过了16字符,ParcelForce 不能处理,请缩短!!"); return; } } order.Wp_track_no = order_wp_track_no; order.Pay_after_discount = order.Pay_before_discount; order_array.Add(order); } //添加包裹 for (int j = 0; j < package_array.Count; j++) { Package package = (Package)package_array[j]; new PackageDAO().addPackage(package); } //添加订单 for (int k = 0; k < order_array.Count; k++) { Order addorder = (Order)order_array[k]; new OrderDAO().addOrder(addorder); } Response.Redirect("../my-shopping-cart.aspx?flag=interface"); }