Example #1
0
 /// <summary>
 /// 将中文地址转换为拼音
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void btn_to_pinyin_Click(object sender, EventArgs e)
 {
     txt_receive_addr_contact.Text  = PinYinHelpers.ToPinYin(replaceChar(txt_receive_addr_contact.Text));
     txt_receive_addr_contact.Text  = PinYinHelpers.ToPinYin(replaceChar(txt_receive_addr_contact.Text));
     txt_receive_addr_company.Text  = PinYinHelpers.ToPinYin(replaceChar(txt_receive_addr_company.Text));
     txt_receive_addr_line1.Text    = PinYinHelpers.ToPinYin(replaceChar(txt_receive_addr_line1.Text));
     txt_receive_addr_line2.Text    = PinYinHelpers.ToPinYin(replaceChar(txt_receive_addr_line2.Text));
     txt_receive_addr_line3.Text    = PinYinHelpers.ToPinYin(replaceChar(txt_receive_addr_line3.Text));
     txt_receive_addr_city.Text     = PinYinHelpers.ToPinYin(replaceChar(txt_receive_addr_city.Text));
     txt_receive_addr_postcode.Text = PinYinHelpers.ToPinYin(replaceChar(txt_receive_addr_postcode.Text));
     txt_receive_addr_country.Text  = PinYinHelpers.ToPinYin(replaceChar(txt_receive_addr_country.Text));
     txt_receive_addr_phone.Text    = PinYinHelpers.ToPinYin(replaceChar(txt_receive_addr_phone.Text));
     txt_receive_addr_email.Text    = PinYinHelpers.ToPinYin(replaceChar(txt_receive_addr_email.Text));
 }
Example #2
0
        /// <summary>
        /// 去购物车结算
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btn_step_two_Click(object sender, EventArgs e)
        {
            string insurance     = Request.Form["select_insurance"];
            string delivery_time = Request.Form["collection_time"];

            //获取包裹信息
            ArrayList packages    = new ArrayList();
            string    description = Request.Form["description"];
            string    values      = Request.Form["package_value"];

            string[] description_array = description.Split(',');
            string[] value_array       = values.Split(',');

            int    j           = 0;
            string destination = Session["to"].ToString();
            string postway     = Session["postname"].ToString().Trim();

            string receive_company      = txt_receive_addr_company.Text.Replace("'", "");
            string receive_name         = txt_receive_addr_contact.Text.Replace("'", "");
            string receive_address_line = txt_receive_addr_line1.Text.Replace("'", "") + txt_receive_addr_line2.Text.Replace("'", "") + txt_receive_addr_line3.Text.Replace("'", "");
            string receive_city         = txt_receive_addr_city.Text.Replace("'", "");
            string receive_postcode     = txt_receive_addr_postcode.Text.Replace("'", "");
            string receive_phone        = txt_receive_addr_phone.Text.Replace("'", "");

            string send_company     = txt_send_addr_company.Text.Replace("'", "");
            string send_name        = txt_send_addr_contact.Text.Replace("'", "");
            string send_addressline = txt_send_addr_line1.Text.Replace("'", "") + txt_send_addr_line2.Text.Replace("'", "") + txt_send_addr_line3.Text.Replace("'", "");
            string send_city        = txt_send_addr_city.Text.Replace("'", "");
            string send_postcode    = txt_send_addr_postcode.Text.Replace("'", "");
            string send_phone       = txt_send_addr_phone.Text.Replace("'", "");

            // 判断
            if (receive_addr.Checked == true && receive_addr_dropdown_list.SelectedValue == "-1")
            {
                Address address = new Address();

                address.User_name    = Session["name"].ToString();
                address.Addr_contact = receive_name;
                address.Company_name = receive_company;
                address.City         = receive_city;
                address.Addr_line1   = txt_receive_addr_line1.Text.Replace("'", "");
                address.Addr_line2   = txt_receive_addr_line2.Text.Replace("'", "");
                address.Addr_line3   = txt_receive_addr_line3.Text.Replace("'", "");
                address.Email        = txt_receive_addr_email.Text.Replace("'", "");
                address.Phone        = receive_phone.Replace("'", "");
                address.Post_code    = receive_postcode.Replace("'", "");
                address.Country      = txt_receive_addr_country.Text;
                address.Is_default   = "0";
                address.Time         = DateTime.Now;
                address.Addr_type    = "R";

                //向地址簿中添加地址
                new AddressDAO().addAddress(address);
            }

            if (send_addr.Checked == true && send_addr_dropdown_list.SelectedValue == "-1")
            {
                Address address = new Address();

                address.User_name    = Session["name"].ToString();
                address.Company_name = send_company.Replace("'", "");
                address.Addr_contact = send_name.Replace("'", "");
                address.City         = send_city.Replace("'", "");
                address.Addr_line1   = txt_send_addr_line1.Text.Replace("'", "");
                address.Addr_line2   = txt_send_addr_line2.Text.Replace("'", "");
                address.Addr_line3   = txt_send_addr_line3.Text.Replace("'", "");
                address.Email        = txt_send_addr_email.Text.Replace("'", "");
                address.Post_code    = send_postcode.Replace("'", "");
                address.Country      = txt_send_addr_country.Text.Replace("'", "");
                address.Phone        = send_phone.Replace("'", "");

                address.Addr_type  = "S";
                address.Time       = DateTime.Now;
                address.Is_default = "0";
                //添加发件地址
                new AddressDAO().addAddress(address);
            }

            if (postway.ToLower() != "ems" && postway.ToLower() != "postnl")
            {
                {
                    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_phone        = send_phone.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("。", "");
                    send_phone       = send_phone.Replace("。", "");

                    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_phone        = send_phone.Replace("(", "");
                    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_phone        = send_phone.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("(", "");
                    send_phone       = send_phone.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(")", "");
                    send_phone       = send_phone.Replace(")", "");

                    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_phone = receive_phone.Replace("-", "");
                    receive_phone = receive_phone.Replace("-", "");
                    receive_phone = receive_phone.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("-", "");

                    send_phone = send_phone.Replace("-", "");
                    send_phone = send_phone.Replace("-", "");
                    send_phone = send_phone.Replace("—", "");

                    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("—", "");


                    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("—", "");



                    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_phone        = receive_phone.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("'", "");
                    send_phone       = send_phone.Replace("'", "");
                    description      = description.Replace("'", "");
                }



                if ((PinYinHelpers.ToPinYin(send_company)).Length > 24)
                {
                    alert("发件公司英文名长度或中文转换为拼音后长度超过了24个字符,请更改!!");
                    return;
                }
                if ((PinYinHelpers.ToPinYin(send_name)).Length > 24)
                {
                    alert("发件人英文名长度或者中文名转化为拼音后超过了24字符,请更改!!");
                    return;
                }
                if ((PinYinHelpers.ToPinYin(send_phone)).Length > 15)
                {
                    alert("发件人电话长度超过了15字符,ParcelForce 不能处理,请缩短!!");
                    return;
                }
                if ((PinYinHelpers.ToPinYin(send_addressline)).Length > 67)
                {
                    alert("英文发件地址或者中文收件地址转化为拼音后长度超过了67字节,ParcelForce 不能处理,请缩短!!");
                    return;
                }
                if ((PinYinHelpers.ToPinYin(send_city)).Length > 24)
                {
                    alert("发件 City 英文长度或中文转换为拼音后长度超过了24字符,ParcelForce 不能处理,请缩短!!");
                    return;
                }
                if ((PinYinHelpers.ToPinYin(send_postcode)).Length > 16)
                {
                    alert("第个包裹的发件邮编长度超过了16字符,ParcelForce 不能处理,请缩短!!");
                    return;
                }


                if ((PinYinHelpers.ToPinYin(receive_company)).Length > 67)
                {
                    alert("抱歉,英文收件地址长度或者中文收件地址转化为拼音后长度超过66个字符,ParcelForce 不能处理,请缩短地址,请更改!!");
                    return;
                }
                if ((PinYinHelpers.ToPinYin(receive_name)).Length > 24)
                {
                    alert("发件人英文名长度或者中文名转化为拼音后超过了24字符,请更改!!");
                    return;
                }
                if ((PinYinHelpers.ToPinYin(receive_phone)).Length > 15)
                {
                    alert("收件人电话长度超过了15字符,ParcelForce 不能处理,请缩短!!");
                    return;
                }
                if ((PinYinHelpers.ToPinYin(receive_address_line)).Length > 67)
                {
                    alert("英文收件地址或者中文收件地址转化为拼音后长度超过了67字节,ParcelForce 不能处理,请缩短!!");
                    return;
                }
                if ((PinYinHelpers.ToPinYin(receive_city)).Length > 24)
                {
                    alert("收件人 City 长度超过了24个字符,ParcelForce 不能处理,请缩短!!");
                    return;
                }
                if (receive_postcode.Length != 6)
                {
                    alert("收件人 邮编 有误,请修改 !!");
                    return;
                }



                receive_company      = PinYinHelpers.ToPinYin(receive_company);
                receive_name         = PinYinHelpers.ToPinYin(receive_name);
                receive_address_line = PinYinHelpers.ToPinYin(receive_address_line);
                receive_city         = PinYinHelpers.ToPinYin(receive_city);
                receive_postcode     = PinYinHelpers.ToPinYin(receive_postcode);
                receive_phone        = PinYinHelpers.ToPinYin(receive_phone);

                send_company     = PinYinHelpers.ToPinYin(send_company);
                send_name        = PinYinHelpers.ToPinYin(send_name);
                send_addressline = PinYinHelpers.ToPinYin(send_addressline);
                send_city        = PinYinHelpers.ToPinYin(send_city);
                send_postcode    = PinYinHelpers.ToPinYin(send_postcode);
                send_phone       = PinYinHelpers.ToPinYin(send_phone);
            }


            ArrayList good_arrays = (ArrayList)Session["package_array"];

            for (int i = 0; i < good_arrays.Count; i++)
            {
                PackageMeasure good = (PackageMeasure)good_arrays[i];

                for (int k = 0; k < good.Count; k++)
                {
                    Package package = new Package();
                    package.Name          = Session["name"].ToString();
                    package.Description   = description_array[j];
                    package.Package_value = Convert.ToSingle(value_array[j]);
                    package.Weight        = good.Weight;
                    package.Height        = good.Height;
                    package.Length        = good.Length;
                    package.Width         = good.Width;
                    package.Pay           = new InterFaceQuote().getQuote(package.Name, destination, good.Weight, good.Length, good.Width, good.Height, postway);
                    package.Departure     = "UK";
                    package.Destination   = destination;

                    if (postway.ToLower() == "postnl")
                    {
                        if (package.Description.Contains("推车") || package.Description.Contains("trolly") || package.Description.Contains("坐椅"))
                        {
                            package.Volumetric = package.Length * package.Width * package.Height / 6000.0f;
                        }
                        else
                        {
                            package.Volumetric = package.Weight;
                        }

                        if (package.Weight >= package.Volumetric)
                        {
                            package.Chargeable = package.Weight;
                        }
                        else
                        {
                            package.Chargeable = package.Volumetric;
                        }
                    }
                    else
                    {
                        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.Post_way = postway;
                    j++;
                    packages.Add(package);
                }
            }

            //处理订单
            Order order = new Order();


            Application.Lock();
            string interfaceOrderNo = Application["orderNo"].ToString();

            Application["orderNo"] = (int)Application["orderNo"] + 1;
            Application.UnLock();

            DateTime time         = DateTime.Now;
            string   order_number = "WM" + time.ToString("yyMMddHHmm") + interfaceOrderNo.PadLeft(8, '0');

            order.Order_number = order_number;
            order.Name         = Session["name"].ToString();

            order.CollectionContactName = send_name;
            order.CollectionCompanyName = send_company;
            order.CollectionPhone       = send_phone;
            order.CollectionAddressLine = send_addressline;
            order.CollectionTown        = send_city;
            order.CollectionPostCode    = send_postcode;
            order.CollectionCountry     = "UK";

            order.RecipientCompanyName = receive_company;
            order.RecipientContactName = receive_name;
            order.RecipientAddressLine = receive_address_line;
            order.RecipientCountry     = Session["to"].ToString();
            order.RecipientPhone       = receive_phone;
            order.RecipientPostCode    = receive_postcode;
            order.RecipientTown        = receive_city;

            if (Session["delivery_way"] == null)
            {
                order.Delivery_way = "Collection";
            }
            else
            {
                order.Delivery_way = Session["delivery_way"].ToString();
            }

            order.Delivery_date = delivery_time;

            order.Insurance = Convert.ToSingle(insurance);

            order.Post_way    = Session["postname"].ToString();
            order.Quantity    = packages.Count;
            order.Order_time  = time;
            order.Is_pay      = "unpay";
            order.Is_show     = "true";
            order.Wp_track_no = "";

            // 向数据库中添加包裹
            for (int i = 0; i < packages.Count; i++)
            {
                Package temp_package = (Package)packages[i];

                Application.Lock();
                string wm_track_no = Application["packageNo"].ToString();
                Application["packageNo"] = (int)Application["packageNo"] + 1;
                Application.UnLock();

                temp_package.Wp_track_no  = "WP" + DateTime.Now.ToString("yyMMddHHmm") + wm_track_no.PadLeft(8, '0');
                temp_package.Order_number = order.Order_number;
                temp_package.Name         = order.Name;
                temp_package.Is_pay       = "unpay";

                order.Weight             += temp_package.Weight;
                order.Pay_after_discount += temp_package.Pay;

                if (order.Wp_track_no != "")
                {
                    order.Wp_track_no = order.Wp_track_no + "," + temp_package.Wp_track_no;
                }
                else
                {
                    order.Wp_track_no = temp_package.Wp_track_no;
                }

                new PackageDAO().addPackage(temp_package);
            }

            order.Pay_before_discount = order.Pay_after_discount;
            order.Discount            = 0;

            new OrderDAO().addOrder(order);



            Response.Redirect("my-shopping-cart.aspx?flag=interface");
        }