//计算邮费 private void initPostages(ArrayList array) { postages = new float[array.Count]; for (int i = 0; i < array.Count; i++) { float total = 0; PackagesToSameAddress temp_package = (PackagesToSameAddress)array[i]; ArrayList package_measure_array = temp_package.Package_Array; string departure = temp_package.Departure; string destination = temp_package.Destination; string postway = temp_package.Postway; for (int j = 0; j < package_measure_array.Count; j++) { PackageMeasure package_measure = (PackageMeasure)package_measure_array[j]; total += package_measure.Count * new InterFaceQuote().getQuote(Session["name"].ToString(), destination, package_measure.Weight, package_measure.Length, package_measure.Width, package_measure.Height, postway); } postages[i] = (int)(100*total)/100.0f; } Session["postages"] = postages; }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Session["name"] == null) { alert("请先登录"); login_first.Visible = true; page_one.Visible = false; } else { string step = Request.QueryString["step"]; if (step == null) { page_one.Visible = true; } else if (step == "2") { page_two.Visible = true; ArrayList temppackageTOSameAddress = (ArrayList)Session["packageTOSameAddress"]; initPostages(temppackageTOSameAddress); for (int i = 0; i < temppackageTOSameAddress.Count; i++) { PackagesToSameAddress packagetosame = (PackagesToSameAddress)temppackageTOSameAddress[i]; PackagesToSameAddress newpackage = new PackagesToSameAddress(); newpackage.Departure = packagetosame.Departure; newpackage.Destination = packagetosame.Destination; newpackage.Package_Array = packagetosame.Package_Array; newpackage.Postway = getPostWay(packagetosame.Postway); packageTOSameAddress.Add(newpackage); } } } } }
protected void btn_BuyNow_Click(object sender, EventArgs e) { ArrayList array = (ArrayList)Session["packageTOSameAddress"]; int count = 0; for (int i = 0; i < array.Count; i++) { PackagesToSameAddress package = (PackagesToSameAddress)array[i]; if (package.Postway.ToLower().Contains("postnl") || package.Postway.ToLower().Contains("ems")) { count++; } } if (count != 0) { Response.Redirect("batch-uk-pick-up.aspx"); } else { Response.Redirect("batch-purchase-process.aspx"); } }
//填写完包裹详细信息后的下一步的实现 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"); }
//询价按钮 protected void btn_price_query_Click(object sender, EventArgs e) { packageTOSameAddress = new ArrayList(); string departure = Request.Form["departure"]; string destination = Request.Form["destination"]; string postway = Request.Form["postway"]; string count = Request.Form["count"]; string weight = Request.Form["weight"]; string length = Request.Form["length"]; string width = Request.Form["width"]; string height = Request.Form["height"]; string hidden = Request.Form["hidden"]; string[] departure_array = departure.Split(','); string[] destination_array = destination.Split(','); string[] postway_array = postway.Split(','); string[] count_array = count.Split(','); string[] weight_array = weight.Split(','); string[] length_array = length.Split(','); string[] width_array = width.Split(','); string[] height_array = height.Split(','); string[] hidden_array = hidden.Split(','); int k = 0; for (int i = 0; i < departure_array.Length; i++) { PackagesToSameAddress packages = new PackagesToSameAddress(); packages.Departure = departure_array[i]; packages.Destination = destination_array[i]; packages.Postway = postway_array[i]; ArrayList package_array = new ArrayList(); PackageMeasure packageMeasure; for (int j = 0; j < Convert.ToInt32(hidden_array[i]); j++) { packageMeasure = new PackageMeasure(); packageMeasure.Count = Convert.ToInt32(count_array[k]); packageMeasure.Weight = Convert.ToSingle(weight_array[k]); packageMeasure.Length = Convert.ToSingle(length_array[k]); packageMeasure.Width = Convert.ToSingle(width_array[k]); packageMeasure.Height = Convert.ToSingle(height_array[k]); k++; package_array.Add(packageMeasure); } packages.Package_Array = package_array; packageTOSameAddress.Add(packages); } Session["packageTOSameAddress"] = packageTOSameAddress; Response.Redirect("batch-order.aspx?step=2"); }