예제 #1
0
        private void btnRemarkBillNumber_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            if (lvwNingboOrders.SelectedItems.Count <= 0)
            {
                return;
            }

            // Search order first.
            btnSearchTaobaoOrder_Click(btnSearchTaobaoOrder, EventArgs.Empty);

            NingboOrder ningboOrder = ((NingboOrderListViewItem)lvwNingboOrders.SelectedItems[0]).NingboOrder;

            Clipboard.SetText(ningboOrder.MailNumber);
            Order taobaoOrder = MainForm.Instance.GetOrder(ningboOrder.TaobaoOrderId);

            if (null == taobaoOrder)
            {
                return;
            }

            UpdateSellMemoForm usmf = new UpdateSellMemoForm(taobaoOrder.Remark, string.Format("stockout: [{0}]{1}", GetLogisticsShortName(ningboOrder.LogisticsCompany), ningboOrder.MailNumber));
            DialogResult       dr   = usmf.ShowDialog(this.FindForm());

            if (DialogResult.Cancel == dr)
            {
                return;
            }

            WebBrowserForms.UpdateSellMemoWebBrowserForm usmbf = new UpdateSellMemoWebBrowserForm(taobaoOrder, usmf.AppendMemo, true);
            usmbf.ShowDialog(this.FindForm());

            Cursor.Current = Cursors.Default;
        }
예제 #2
0
            // productIndex: 如果该NingboOrder中包含多个product, 此参数指明使用第几个product.
            // productIndex不校验, 需在合理范围内.
            public NingboOrderListViewItem(NingboOrder o, int productIndex, Color backColor)
            {
                _ningboOrder  = o;
                _productIndex = productIndex;

                this.BackColor = backColor;
                this.Text      = o.LogisticsCompany;
                this.SubItems.Add(o.MailNumber);
                this.SubItems.Add(o.TaobaoOrderId);
                this.SubItems.Add(o.RecipientName);
                this.SubItems.Add(o.Mobile);
                this.SubItems.Add(o.Province);
                this.SubItems.Add(o.City);
                this.SubItems.Add(o.District);
                this.SubItems.Add(o.StreetAddr);

                if (null != o.SoldProducts && o.SoldProducts.Count > productIndex)
                {
                    this.SubItems.Add(o.SoldProducts[productIndex].ShortName);                     // product
                    this.SubItems.Add(o.SoldProducts[productIndex].Count.ToString());
                }
                else
                {
                    this.SubItems.Add(string.Empty);
                    this.SubItems.Add(string.Empty);
                }

                this.SubItems.Add(o.IdInfo);
            }
예제 #3
0
        private void btnLoad_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            try
            {
                OpenFileDialog ofd = new OpenFileDialog();
                ofd.Filter = "Excel Files(*.xls)|*.xls|All Files(*.*)|*.*";
                if (DialogResult.OK == ofd.ShowDialog(this))
                {
                    Excel excel = new Excel(ofd.FileName, true, Excel.OledbVersions.OLEDB40);
                    try
                    {
                        List <string> tableNames = excel.GetTableNames();
                        if (null == tableNames || tableNames.Count <= 0)
                        {
                            MessageBox.Show(this, "Excel文件中未找到任何表.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            return;
                        }

                        Ningbo.NingboTableColumnSelectorForm colSelectorForm = new Egode.Ningbo.NingboTableColumnSelectorForm(excel);
                        if (DialogResult.OK == colSelectorForm.ShowDialog(this))
                        {
                            DataSet ds = excel.Get(tableNames[0], string.Empty);
                            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                            {
                                DataRow row = ds.Tables[0].Rows[i];
                                if (string.IsNullOrEmpty(row[colSelectorForm.ColumnInfo.LogisticsCompany].ToString()) && string.IsNullOrEmpty(row[colSelectorForm.ColumnInfo.MailNumber].ToString()))
                                {
                                    continue;
                                }

                                int count = int.Parse(row.ItemArray[colSelectorForm.ColumnInfo.Count].ToString());

                                List <SoldProductInfo> products = new List <SoldProductInfo>();
                                ProductInfo            pi       = null;
                                SoldProductInfo        spi      = null;
                                if (colSelectorForm.ColumnInfo.ProductNingboCode >= 0)
                                {
                                    pi = ProductInfo.GetProductByNingboCode(row.ItemArray[colSelectorForm.ColumnInfo.ProductNingboCode].ToString());
                                    if (null != pi)
                                    {
                                        spi       = new SoldProductInfo(pi);
                                        spi.Count = count;
                                        products.Add(spi);
                                    }
                                }

                                //NingboOrder no = new NingboOrder(
                                //    row.ItemArray[2].ToString().Trim(), row.ItemArray[3].ToString().Trim(),
                                //    row.ItemArray[4].ToString().Trim(), row.ItemArray[15].ToString().Trim(),
                                //    row.ItemArray[16].ToString().Trim(), row.ItemArray[18].ToString().Trim(), row.ItemArray[19].ToString().Trim(),
                                //    row.ItemArray[20].ToString().Trim(), row.ItemArray[21].ToString().Trim(),
                                //    products, row.ItemArray[35].ToString().Trim());
                                NingboOrder no = new NingboOrder(
                                    row.ItemArray[colSelectorForm.ColumnInfo.LogisticsCompany].ToString().Trim(), row.ItemArray[colSelectorForm.ColumnInfo.MailNumber].ToString().Trim(),
                                    row.ItemArray[colSelectorForm.ColumnInfo.OrderId].ToString().Trim(), row.ItemArray[colSelectorForm.ColumnInfo.RecipientName].ToString().Trim(),
                                    row.ItemArray[colSelectorForm.ColumnInfo.Mobile].ToString().Trim(), row.ItemArray[colSelectorForm.ColumnInfo.Province].ToString().Trim(), row.ItemArray[colSelectorForm.ColumnInfo.City].ToString().Trim(),
                                    row.ItemArray[colSelectorForm.ColumnInfo.District].ToString().Trim(), row.ItemArray[colSelectorForm.ColumnInfo.StreetAddr].ToString().Trim(),
                                    products, string.Empty, string.Empty);                                     // last arg is alipay number.
                                NingboOrderListViewItem item = new NingboOrderListViewItem(no, 0, lvwNingboOrders.BackColor);
                                lvwNingboOrders.Items.Add(item);

                                if (null == spi)
                                {
                                    if (colSelectorForm.ColumnInfo.ProductNingboCode >= 0)
                                    {
                                        item.SubItems[9].Text = row.ItemArray[colSelectorForm.ColumnInfo.ProductNingboCode].ToString();
                                    }
                                    if (colSelectorForm.ColumnInfo.Count >= 0)
                                    {
                                        item.SubItems[10].Text = row.ItemArray[colSelectorForm.ColumnInfo.Count].ToString();
                                    }
                                }
                            }
                        }

                        /* Removed by KK on 2016/07/15.
                         * // Get column index for shipment number return from higo.
                         * int logisticsCompanyColIndex = -1;
                         * int shipmentNumberColIndex = -1;
                         * int taobaoOrderIdColIndex = -1;
                         * int recipientNameColIndex = -1;
                         * int mobileColIndex = -1;
                         * int provinceColIndex = -1;
                         * int cityColIndex = -1;
                         * int districtColIndex = -1;
                         * int streetAddrColIndex = -1;
                         * int productNingboCodeColIndex = -1;
                         * int productCountColIndex = -1;
                         * for (int i = 0; i < ds.Tables[0].Columns.Count; i++)
                         * {
                         *      System.Diagnostics.Trace.WriteLine(string.Format("column {0}: {1}", i, ds.Tables[0].Rows[0].ItemArray[i]));
                         *      if (ds.Tables[0].Rows[0].ItemArray[i].ToString().Contains("快递公司"))
                         *              logisticsCompanyColIndex = i;
                         *      if (ds.Tables[0].Rows[0].ItemArray[i].ToString().Contains("运单号"))
                         *              shipmentNumberColIndex = i;
                         *      if (ds.Tables[0].Rows[0].ItemArray[i].ToString().Contains("网站订单编号"))
                         *              taobaoOrderIdColIndex = i;
                         *      if (ds.Tables[0].Rows[0].ItemArray[i].ToString().Contains("收货人"))
                         *              recipientNameColIndex = i;
                         *      if (ds.Tables[0].Rows[0].ItemArray[i].ToString().Contains("手机"))
                         *              mobileColIndex = i;
                         *      if (ds.Tables[0].Rows[0].ItemArray[i].ToString().Contains("省份"))
                         *              provinceColIndex = i;
                         *      if (ds.Tables[0].Rows[0].ItemArray[i].ToString().Contains("市"))
                         *              cityColIndex = i;
                         *      if (ds.Tables[0].Rows[0].ItemArray[i].ToString().Contains("区"))
                         *              districtColIndex = i;
                         *      if (ds.Tables[0].Rows[0].ItemArray[i].ToString().Contains("详细信息"))
                         *              streetAddrColIndex = i;
                         *      if (ds.Tables[0].Rows[0].ItemArray[i].ToString().Contains("商品编码"))
                         *              productNingboCodeColIndex = i;
                         *      if (ds.Tables[0].Rows[0].ItemArray[i].ToString().Trim().Equals("数量"))
                         *              productCountColIndex = i;
                         * }
                         *
                         * int idInfoColIndex = -1;
                         * if (ds.Tables[0].Rows.Count >= 2)
                         * {
                         *      Regex r = new Regex(@"\d{17}[\d|x|X]");
                         *      for (int i = 0; i < ds.Tables[0].Columns.Count; i++)
                         *      {
                         *              if (r.Match(ds.Tables[0].Rows[1].ItemArray[i].ToString()).Success)
                         *              {
                         *                      idInfoColIndex = i;
                         *                      break;
                         *              }
                         *      }
                         * }
                         *
                         * if (-1 == shipmentNumberColIndex)
                         * {
                         *      //MessageBox.Show(this, "没有找到\"运单号\"列, 请检查文件数据或联系KK~", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                         *      MessageBox.Show(this, "没有找到\"运单号\"列, 默认使用第4列(D列)作为运单号, 请自行确认数据无误!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                         *      shipmentNumberColIndex = 3;
                         *      //return;
                         * }
                         * if (-1 == taobaoOrderIdColIndex)
                         * {
                         *      MessageBox.Show(this, "没有找到\"网站订单编号\"列, 默认使用第5列(E列)作为订单编号, 请自行确认数据无误!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                         *      taobaoOrderIdColIndex = 4;
                         *      //return;
                         * }
                         *
                         * for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                         * {
                         *      DataRow row = ds.Tables[0].Rows[i];
                         *
                         *      ProductInfo pi = ProductInfo.GetProductByNingboCode(row.ItemArray[productNingboCodeColIndex].ToString());
                         *      int count = int.Parse(row.ItemArray[productCountColIndex].ToString());
                         *      SoldProductInfo spi = new SoldProductInfo(pi);
                         *      spi.Count = count;
                         *      List<SoldProductInfo> products = new List<SoldProductInfo>();
                         *      products.Add(spi);
                         *
                         *      //NingboOrder no = new NingboOrder(
                         *      //    row.ItemArray[2].ToString().Trim(), row.ItemArray[3].ToString().Trim(),
                         *      //    row.ItemArray[4].ToString().Trim(), row.ItemArray[15].ToString().Trim(),
                         *      //    row.ItemArray[16].ToString().Trim(), row.ItemArray[18].ToString().Trim(), row.ItemArray[19].ToString().Trim(),
                         *      //    row.ItemArray[20].ToString().Trim(), row.ItemArray[21].ToString().Trim(),
                         *      //    products, row.ItemArray[35].ToString().Trim());
                         *      NingboOrder no = new NingboOrder(
                         *              row.ItemArray[logisticsCompanyColIndex].ToString().Trim(), row.ItemArray[shipmentNumberColIndex].ToString().Trim(),
                         *              row.ItemArray[taobaoOrderIdColIndex].ToString().Trim(), row.ItemArray[recipientNameColIndex].ToString().Trim(),
                         *              row.ItemArray[mobileColIndex].ToString().Trim(), row.ItemArray[provinceColIndex].ToString().Trim(), row.ItemArray[19].ToString().Trim(),
                         *              row.ItemArray[cityColIndex].ToString().Trim(), row.ItemArray[districtColIndex].ToString().Trim(),
                         *              products, row.ItemArray[idInfoColIndex].ToString().Trim(), string.Empty); // last arg is alipay number.
                         *      NingboOrderListViewItem item = new NingboOrderListViewItem(no, 0, lvwNingboOrders.BackColor);
                         *      lvwNingboOrders.Items.Add(item);
                         * }
                         */
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(this, ex.Message, this.Text, MessageBoxButtons.OK);
                    }
                    finally
                    {
                        excel.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, this.Text, MessageBoxButtons.OK);
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }
예제 #4
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            try
            {
                if (string.IsNullOrEmpty(txtRecipientName.Text.Trim()))
                {
                    MessageBox.Show(this, "收件人姓名不能为空.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }
                if (string.IsNullOrEmpty(txtMobile.Text.Trim()))
                {
                    MessageBox.Show(this, "收件人电话能为空.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }
                if (string.IsNullOrEmpty(txtIdInfo.Text.Trim()))
                {
                    MessageBox.Show(this, "身份证信息不能为空.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }
                Regex r = new Regex(@"\d{17}[\d|x|X]");
                if (!r.Match(txtIdInfo.Text).Success)
                {
                    MessageBox.Show(this, "身份证信息格式不正确.\n身份证信息格式为: 张三,000000000000000000", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }
                if (!txtIdInfo.Text.Contains(",") && !txtIdInfo.Text.Contains(","))
                {
                    MessageBox.Show(this, "身份证信息格式不正确.\n身份证信息格式为: 张三,000000000000000000", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }
                if (txtIdInfo.Text.Length < 21)                 // 18位数字+逗号+至少2个字名字=21
                {
                    MessageBox.Show(this, "身份证信息格式不正确.\n身份证信息格式为: 张三,000000000000000000", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }
                if (string.IsNullOrEmpty(txtProvince.Text.Trim()))
                {
                    MessageBox.Show(this, "省份信息不能为空.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }
                if (string.IsNullOrEmpty(txtCity1.Text.Trim()))
                {
                    MessageBox.Show(this, "城市信息不能为空.\n直辖市填入省份名即可.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }
                if (string.IsNullOrEmpty(txtCity2.Text.Trim()) && string.IsNullOrEmpty(txtDistrict.Text.Trim()))
                {
                    MessageBox.Show(this, "区县信息不能为空.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }
                if (string.IsNullOrEmpty(txtStreetAddress.Text.Trim()))
                {
                    MessageBox.Show(this, "详细地址不能为空.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }
                if (pnlProductList.Controls.Count <= 1)
                {
                    MessageBox.Show(this, "产品信息不能为空.\n至少需要选择1个产品.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }

                List <SoldProductInfo> products = new List <SoldProductInfo>();
                foreach (Control c in pnlProductList.Controls)
                {
                    if (!(c is SoldProductInfoControl))
                    {
                        continue;
                    }
                    SoldProductInfoControl spic = c as SoldProductInfoControl;
                    SoldProductInfo        spi  = new SoldProductInfo(spic.SelectedProductInfo);
                    spi.Count = spic.Count;
                    products.Add(spi);
                }

                NingboOrder ningboOrder = new NingboOrder(
                    cboLogistics.SelectedItem.ToString(), string.Empty, _orders[0].OrderId,
                    txtRecipientName.Text, txtMobile.Text, txtProvince.Text, txtCity1.Text,
                    string.IsNullOrEmpty(txtDistrict.Text)?txtCity2.Text:txtDistrict.Text, txtStreetAddress.Text,
                    products, txtIdInfo.Text, _orders[0].AlipayNumber);

                if (_orders.Count > 1)
                {
                    string linkedOrderIds = string.Empty;
                    for (int i = 1; i < _orders.Count; i++)
                    {
                        linkedOrderIds += _orders[i].OrderId;
                        if (i < _orders.Count - 1)
                        {
                            linkedOrderIds += ",";
                        }
                    }
                    ningboOrder.LinkedTaobaoOrderIds = linkedOrderIds;
                }

                NingboOrder.Orders.Add(ningboOrder);
                //this.DialogResult = DialogResult.OK;
                //this.Close();

                // motion effect.
                ResourceManager rm    = new ResourceManager("Egode.Properties.Resources", System.Reflection.Assembly.GetExecutingAssembly());
                Image           imgNb = (Image)rm.GetObject("nb1");
                Point           p     = MainForm.Instance.NbStatusLocation;
                p.Offset(2, 8);
                FlyingForm flying = new FlyingForm(imgNb, p);
                flying.FlyingCompleted += new EventHandler(flying_FlyingCompleted);
                flying.Show();
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }