Exemplo n.º 1
0
        // 根据给定的名字在给定的集合中查找对应值.
        // recipientName可以是中文, 也可以是拼音名字, 最终都转化为拼音进行匹配.
        // 匹配时, 删除拼音名字中的所有空格, 忽略大小写.
        public static PdfPacketInfoEx GetItemByRecipientName(string recipientName, List <PdfPacketInfoEx> pdfPackets, bool ignoreMatched)
        {
            if (string.IsNullOrEmpty(recipientName))
            {
                return(null);
            }
            if (null == pdfPackets || pdfPackets.Count <= 0)
            {
                return(null);
            }

            foreach (PdfPacketInfoEx ppi in pdfPackets)
            {
                if (ignoreMatched && !string.IsNullOrEmpty(ppi.MatchedRecipientName))
                {
                    continue;
                }

                string pinyin1 = HanZiToPinYin.Convert(recipientName).Replace(" ", string.Empty).Trim().ToLower();
                string pinyin2 = HanZiToPinYin.Convert(ppi.RecipientName).Replace(" ", string.Empty).Trim().ToLower();

                if (pinyin1.Equals(pinyin2))
                {
                    return(ppi);
                }
            }
            return(null);
        }
Exemplo n.º 2
0
        private bool ContainInvalidChar(string recipientName)
        {
            if (string.IsNullOrEmpty(recipientName))
            {
                return(false);
            }

            if (recipientName.Contains("先生"))
            {
                return(true);
            }
            if (recipientName.Contains("小姐"))
            {
                return(true);
            }
            if (HanZiToPinYin.Convert(recipientName).Contains("Zuo"))
            {
                return(true);
            }

            Regex r = new Regex("[A-Za-z]");
            Match m = r.Match(recipientName);

            if (m.Success)
            {
                return(true);
            }

            return(false);
        }
Exemplo n.º 3
0
 private void txtStreetAddress_TextChanged(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(txtStreetAddress.Text))
     {
         txtPinyinStreetAddress.Text = string.Empty;
     }
     else
     {
         txtPinyinStreetAddress.Text = HanZiToPinYin.Convert(txtStreetAddress.Text);
     }
 }
Exemplo n.º 4
0
 private void txtProvinceCity_TextChanged(object sender, EventArgs e)
 {
     txtPinyinProvinceCity.Text = string.Empty;
     if (!string.IsNullOrEmpty(txtProvinceCity.Text))
     {
         string[] infos = txtProvinceCity.Text.Split(' ');
         foreach (string info in infos)
         {
             txtPinyinProvinceCity.Text += " " + HanZiToPinYin.Convert(info);
         }
         txtPinyinProvinceCity.Text = txtPinyinProvinceCity.Text.Trim();
     }
 }
Exemplo n.º 5
0
 private void txtRecipientName_TextChanged(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(txtRecipientName.Text))
     {
         txtPinyinRecipientName.Text = string.Empty;
     }
     else
     {
         txtPinyinRecipientName.Text = string.Format(
             "{0} {1}",
             HanZiToPinYin.Convert(txtRecipientName.Text.Substring(0, 1)),
             HanZiToPinYin.Convert(txtRecipientName.Text.Substring(1, txtRecipientName.Text.Length - 1)));
     }
 }
Exemplo n.º 6
0
        private void txtRecipientName_TextChanged(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtRecipientName.Text))
            {
                txtPinyinRecipientName.Text = string.Empty;
            }
            else
            {
                txtPinyinRecipientName.Text = string.Format(
                    "{0} {1}",
                    HanZiToPinYin.Convert(txtRecipientName.Text.Substring(0, 1)),
                    HanZiToPinYin.Convert(txtRecipientName.Text.Substring(1, txtRecipientName.Text.Length - 1)));
            }

            txtRecipientName.BackColor = ContainInvalidChar(txtRecipientName.Text.Trim()) ? Color.Tomato : Color.White;
        }
Exemplo n.º 7
0
        public void RefreshFullEditedAddress()
        {
            OrderDetailsPageWebBrowserForm odpf = new OrderDetailsPageWebBrowserForm(_order.OrderId);

            if (DialogResult.OK == odpf.ShowDialog(this.FindForm()))
            {
                string html = odpf.Html;
                Regex  r    = new Regex(@"<th>新收货地址:</th>\s*<td>(.*)</td>");
                Match  m    = r.Match(html);
                if (m.Success)
                {
                    string fullEditedAddress = m.Groups[1].Value.Trim();
                    fullEditedAddress             = fullEditedAddress.Replace(" ,", ",");
                    fullEditedAddress             = fullEditedAddress.Replace(",,", ",");
                    txtEditedAddress.Text         = fullEditedAddress;
                    _order.EditedRecipientAddress = fullEditedAddress;
                    _refreshedEditedAddr          = true;
                    wb.Navigate("about:blank");                                                       // cause reload html.

                    fullEditedAddress = fullEditedAddress.Substring(0, fullEditedAddress.Length - 6); // remove last post code to translate to pinyin.
                    if (fullEditedAddress.EndsWith(","))
                    {
                        fullEditedAddress = fullEditedAddress.Substring(0, fullEditedAddress.Length - 1);
                    }
                    txtPinyinAddress.Text         = HanZiToPinYin.Convert(fullEditedAddress);
                    lblPinyinAddressTitle.Visible = true;
                    txtPinyinAddress.Visible      = true;

                    txtEditedAddress.SelectionStart  = 0;
                    txtEditedAddress.SelectionLength = txtEditedAddress.Text.Length;
                    txtEditedAddress.Focus();

                    // autosize me.
                    this.Height = tblDetails.Top + tblPacket.Bottom + this.Padding.Bottom;
                }
            }
        }
Exemplo n.º 8
0
        public bool MatchKeyword(string[] keys)
        {
            if (null == keys || keys.Length <= 0)
            {
                return(false);
            }

            //StringBuilder sb = new StringBuilder();
            //sb.Append(_orderId);
            //sb.Append(_buyerAccount);
            //sb.Append(_alipayAccount);
            //sb.Append(_buyerRemark);
            //sb.Append(_recipientName);
            //sb.Append(HanZiToPinYin.Convert(_recipientName).ToLower());
            //sb.Append(_recipientAddress);
            //sb.Append(HanZiToPinYin.Convert(_recipientAddress).ToLower());
            //sb.Append(_phoneNumber);
            //sb.Append(_mobileNumber);
            //sb.Append(_dealTime.ToString());
            //sb.Append(_payingTime.ToString());
            //sb.Append(SimplifyItemSubject(_items));
            //sb.Append(_shipmentNumber);
            //sb.Append(_shipmentCompany);
            //sb.Append(_remark);
            //sb.Append(_closingReason);
            //sb.Append(_editedRecipientAddress);
            //if (!string.IsNullOrEmpty(_editedRecipientAddress))
            //    sb.Append(HanZiToPinYin.Convert(_editedRecipientAddress).ToLower());

            //string s = sb.ToString();

            foreach (string key in keys)
            {
                //if (s.Contains(key))
                //    return true;
                if (_buyerAccount.Contains(key))
                {
                    return(true);
                }
                if (_recipientName.Contains(key))
                {
                    return(true);
                }
                if (HanZiToPinYin.Convert(_recipientName).ToLower().Contains(key.ToLower()))
                {
                    return(true);
                }
                if (SimplifyItemSubject(_items).Contains(key))
                {
                    return(true);
                }
                if (_remark.Contains(key))
                {
                    return(true);
                }
                if (_shipmentNumber.Contains(key))
                {
                    return(true);
                }
                if (_mobileNumber.Contains(key))
                {
                    return(true);
                }
                if (_phoneNumber.Contains(key))
                {
                    return(true);
                }
                if (_buyerRemark.Contains(key))
                {
                    return(true);
                }
                if (_recipientAddress.Contains(key))
                {
                    return(true);
                }
                if (HanZiToPinYin.Convert(_recipientAddress).ToLower().Contains(key.ToLower()))
                {
                    return(true);
                }
                if (_editedRecipientAddress.Contains(key))
                {
                    return(true);
                }
                if (!string.IsNullOrEmpty(_editedRecipientAddress) && HanZiToPinYin.Convert(_editedRecipientAddress).ToLower().Contains(key.ToLower()))
                {
                    return(true);
                }
                if (_alipayAccount.Contains(key))
                {
                    return(true);
                }
                if (_orderId.Contains(key))
                {
                    return(true);
                }
                if (_dealTime.ToString().Contains(key))
                {
                    return(true);
                }
                if (_payingTime.ToString().Contains(key))
                {
                    return(true);
                }
                if (_shipmentCompany.Contains(key))
                {
                    return(true);
                }
                if (_closingReason.Contains(key))
                {
                    return(true);
                }
            }

            return(false);
        }
Exemplo n.º 9
0
        private void UpdateShipmentNumberInPackingList(string packingListExcel, List <PdfPacketInfoEx> pdfPackets)
        {
            Cursor.Current = Cursors.WaitCursor;

            Excel excel = null;

            try
            {
                excel = new Excel(packingListExcel, true);
            }
            catch
            {
                MessageBox.Show(
                    this,
                    "Open Excel file of packing list failed.\nMake sure the Excel file was not opened and try again.", this.Text,
                    MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            try
            {
                DataSet ds = excel.Get("Sheet1", string.Empty);
                if (null == ds)
                {
                    return;
                }

                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    DataRow dr = ds.Tables[0].Rows[i];
                    //Trace.WriteLine(dr.ItemArray[1].ToString());
                    string recipientNameCn = dr.ItemArray[1].ToString();
                    if (string.IsNullOrEmpty(recipientNameCn))
                    {
                        continue;
                    }
                    if (recipientNameCn.Equals("张秋兰"))
                    {
                        Trace.Write("");
                    }
                    string          recipientNamePinyin = HanZiToPinYin.Convert(recipientNameCn);
                    PdfPacketInfoEx ppi = PdfPacketInfoEx.GetItem(recipientNamePinyin, pdfPackets, true);
                    if (null == ppi)
                    {
                        PdfPacketInfoEx ppi1 = new PdfPacketInfoEx(string.Empty, PacketTypes.Unknown, string.Empty, string.Empty, 0);
                        ppi1.MatchedRecipientName = recipientNameCn;
                        pdfPackets.Add(ppi1);
                        continue;
                    }

                    ppi.MatchedRecipientName = recipientNameCn;

                    try
                    {
                        excel.Update(
                            "Sheet1",
                            "运单号", string.Format("{0}:{1}", ppi.RecipientName, ppi.ShipmentNumber),
                            "序号", dr.ItemArray[0].ToString());
                        //"收货人", recipientNameCn);
                        ppi.Updated = true;
                    }
                    catch (Exception ex)
                    {
                        Trace.WriteLine(ex);
                    }
                    //Trace.WriteLine(string.Format("Matched: {0}, {1}, {2}, {3}", recipientNameCn, ppi.RecipientName, ppi.ShipmentNumber, ppi.Weight));
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, "Error occured during udpate shipment number into excel file.\n" + ex.ToString(), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            finally
            {
                excel.Close();
                Cursor.Current = Cursors.Default;
            }
        }
Exemplo n.º 10
0
        public OrderDetailsControl(Order order, int buyerOrderCount)
        {
            InitializeComponent();

            _buyerOrderCount        = buyerOrderCount;
            _order                  = order;
            _order.OnStatusChanged += new EventHandler(_order_OnStatusChanged);

            //wb.Visible = false;
            wb.ScrollBarsEnabled  = false;
            wb.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(wb_DocumentCompleted);
            wb.Navigating        += new WebBrowserNavigatingEventHandler(wb_Navigating);
            InitializeHtmlView();

            // ...
            btnPreparePacket.Visible = false;

            if (_order.Remark.Contains("#直邮"))
            {
                tblHeaderInfo.BackColor = Color.FromArgb(0xff, 127, 191, 127);
            }
            else if (_order.Remark.Contains("#现货"))
            {
                tblHeaderInfo.BackColor = Color.FromArgb(0xff, 255, 127, 127);
            }
            else
            {
                tblHeaderInfo.BackColor = Color.FromArgb(0xe0, 0xe0, 0xe0);
            }

            // details.
            orderId.Order          = _order;
            orderId.ConsignVisible = _order.Status == (Order.OrderStatus.Paid);
            orderId.OnConsignSh   += new EventHandler(orderId_OnConsignSh);
            lblDealTime.Text       = string.Format("成交时间: {0}", _order.DealTime.ToString("yyyy-MM-dd HH:mm:ss"));
            lblPayingTime.Text     = string.Format("付款时间: {0}", _order.PayingTime.Equals(DateTime.MinValue) ? "<未付款>" : _order.PayingTime.ToString("yyyy-MM-dd HH:mm:ss"));
            buyerInfo.BuyerAccount = _order.BuyerAccount;
            buyerInfo.OrderAmount  = buyerOrderCount;
            orderMoney.Money       = _order.TotalMoney;
            orderMoney.Freight     = _order.Freight;
            txtBuyerRemark.Text    = _order.BuyerRemark;
            txtRemark.Text         = _order.Remark;
            txtAddress.Text        = _order.GetFullAddress();
            txtPinyinAddress.Text  = HanZiToPinYin.Convert(txtAddress.Text.Substring(0, txtAddress.Text.Length - 8));            // remove (123456) at the end of address.
            txtEditedAddress.Text  = _order.EditedRecipientAddress;

            if (string.IsNullOrEmpty(_order.BuyerRemark.Trim()))
            {
                lblBuyerRemarkTitle.Visible = false;
                txtBuyerRemark.Visible      = false;
            }

            //// title color.
            //switch (_order.Status)
            //{
            //    case Order.OrderStatus.Deal:
            //        tblHeaderInfo.BackColor = Color.FromArgb(248, 200, 113);
            //        break;

            //    case Order.OrderStatus.Paid:
            //        tblHeaderInfo.BackColor = Color.FromArgb(120, 222, 120);
            //        break;

            //    case Order.OrderStatus.Sent:
            //        tblHeaderInfo.BackColor = Color.FromArgb(199, 228, 255);
            //        break;

            //    case Order.OrderStatus.Succeeded:
            //        tblHeaderInfo.BackColor = Color.FromArgb(196, 196, 196);
            //        break;

            //    case Order.OrderStatus.Closed:
            //        tblHeaderInfo.BackColor = Color.FromArgb(196, 196, 196);
            //        break;
            //}

            // info about address.
            if (string.IsNullOrEmpty(_order.EditedRecipientAddress))
            {
                lblEditedAddressTitle.Visible   = false;
                txtEditedAddress.Visible        = false;
                btnGetFullEditedAddress.Visible = false;
            }
            else
            {
                // If edited address exists the address is not full address.
                // So, it is not necessary to show pinyin address.
                lblPinyinAddressTitle.Visible = false;
                txtPinyinAddress.Visible      = false;
            }

            // items.
            string[] items = _order.Items.Split('★');
            for (int i = 0; i < items.Length; i++)
            {
                string   item  = items[i];
                string[] infos = item.Split('☆');
                if (infos.Length < 3)
                {
                    continue;
                }

                if (string.IsNullOrEmpty(infos[0]))
                {
                    Trace.WriteLine("null product found!!!");
                }

                OrderParser.Order.OrderStatus status = Order.OrderStatus.Succeeded;
                if (infos.Length >= 4)
                {
                    status = ((Order.OrderStatus)Enum.Parse(typeof(Order.OrderStatus), infos[3]));
                }

                productList.AddProduct(
                    //Order.SimplifyItemSubject(infos[0]),
                    infos[0],
                    float.Parse(infos[1]), int.Parse(infos[2]), status);
            }

            // packet.
            float netWeight = _order.GetNetWeight();

            lblNetWeight.Text = string.Format("净重: {0}kg", (netWeight / 1000).ToString("0.0"));
            cboPackets.Items.Add(new Packet(PacketTypes.Unknown, 0, 0));
            cboPackets.Items.Add(new Packet(PacketTypes.Rainbow, 6000, 265));
            cboPackets.Items.Add(new Packet(PacketTypes.Rainbow, 8000, 275));
            cboPackets.Items.Add(new Packet(PacketTypes.Rainbow, 9000, 285));
            cboPackets.Items.Add(new Packet(PacketTypes.Rainbow, 10000, 300));
            cboPackets.Items.Add(new Packet(PacketTypes.Rainbow, 15000, 350));
            cboPackets.Items.Add(new Packet(PacketTypes.Rainbow, 20000, 420));
            cboPackets.Items.Add(new Packet(PacketTypes.Ouhua, 5000, 239));
            cboPackets.Items.Add(new Packet(PacketTypes.Ouhua, 5500, 245));
            cboPackets.Items.Add(new Packet(PacketTypes.Ouhua, 6000, 250));
            cboPackets.Items.Add(new Packet(PacketTypes.Ouhua, 6500, 255));
            cboPackets.Items.Add(new Packet(PacketTypes.Ouhua, 7000, 260));
            cboPackets.Items.Add(new Packet(PacketTypes.Ouhua, 7500, 265));
            cboPackets.Items.Add(new Packet(PacketTypes.Ouhua, 8000, 270));
            cboPackets.Items.Add(new Packet(PacketTypes.Ouhua, 8500, 275));
            cboPackets.Items.Add(new Packet(PacketTypes.Ouhua, 9000, 290));
            cboPackets.Items.Add(new Packet(PacketTypes.Ouhua, 9500, 295));
            cboPackets.Items.Add(new Packet(PacketTypes.Ouhua, 10000, 300));
            cboPackets.Items.Add(new Packet(PacketTypes.Ouhua, 10500, 310));
            cboPackets.Items.Add(new Packet(PacketTypes.Ouhua, 11000, 324));
            cboPackets.Items.Add(new Packet(PacketTypes.Ouhua, 11500, 334));
            cboPackets.Items.Add(new Packet(PacketTypes.Ouhua, 12000, 344));
            cboPackets.Items.Add(new Packet(PacketTypes.Ouhua, 12500, 354));
            cboPackets.Items.Add(new Packet(PacketTypes.Ouhua, 13000, 364));
            cboPackets.Items.Add(new Packet(PacketTypes.Ouhua, 14000, 374));
            cboPackets.Items.Add(new Packet(PacketTypes.Ouhua, 15000, 394));
            //cboPackets.Items.Add(new Packet(PacketTypes.Supermarket, 7000, 241));
            //cboPackets.Items.Add(new Packet(PacketTypes.Supermarket, 8000, 258));
            //cboPackets.Items.Add(new Packet(PacketTypes.Supermarket, 9000, 285));
            //cboPackets.Items.Add(new Packet(PacketTypes.Supermarket, 15000, 358));
            //cboPackets.Items.Add(new Packet(PacketTypes.Dealworthier, 5000, 246));
            //cboPackets.Items.Add(new Packet(PacketTypes.Dealworthier, 5500, 251));
            //cboPackets.Items.Add(new Packet(PacketTypes.Dealworthier, 6000, 258));
            //cboPackets.Items.Add(new Packet(PacketTypes.Dealworthier, 6500, 263));
            //cboPackets.Items.Add(new Packet(PacketTypes.Dealworthier, 7000, 268));
            //cboPackets.Items.Add(new Packet(PacketTypes.Dealworthier, 7500, 273));
            //cboPackets.Items.Add(new Packet(PacketTypes.Dealworthier, 8000, 278));
            //cboPackets.Items.Add(new Packet(PacketTypes.Dealworthier, 8500, 288));
            //cboPackets.Items.Add(new Packet(PacketTypes.Dealworthier, 9000, 298));
            //cboPackets.Items.Add(new Packet(PacketTypes.Dealworthier, 9500, 303));
            //cboPackets.Items.Add(new Packet(PacketTypes.Dealworthier, 10000, 308));
            //cboPackets.Items.Add(new Packet(PacketTypes.Dealworthier, 10500, 320));

            if (4800 == netWeight)
            {
                cboPackets.SelectedIndex = GetPacketIndex(PacketTypes.Supermarket, 7);
            }
            else if (6400 == netWeight)
            {
                cboPackets.SelectedIndex = GetPacketIndex(PacketTypes.Rainbow, 8);
            }
            else if (8000 == netWeight)
            {
                cboPackets.SelectedIndex = GetPacketIndex(PacketTypes.Rainbow, 10);
            }
            else if (8400 == netWeight)
            {
                cboPackets.SelectedIndex = GetPacketIndex(PacketTypes.Rainbow, 10);
            }
            else
            {
                cboPackets.SelectedIndex = 0;
            }

            // autosize me.
            //this.Height = tblDetails.Top + tblPacket.Bottom + this.Padding.Bottom;

            //Trace.WriteLine(_order.RecipientAddress);
            //AddressParser ap = new AddressParser(_order.RecipientAddress);
            //Trace.WriteLine(string.Format("{0}#{1}#{2}#{3}#{4}", ap.Province, ap.City1, ap.City2, ap.District, ap.StreetAddress));
            //Trace.WriteLine("");
        }
Exemplo n.º 11
0
 private void txtAddress_TextChanged(object sender, EventArgs e)
 {
     txtPinyinAddress.Text = HanZiToPinYin.Convert(txtAddress.Text);
 }