示例#1
0
 /// <summary>
 /// 选择发件人
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void CkChooseSendManCheckedChanged(object sender, EventArgs e)
 {
     if (ckChooseSendMan.Checked)
     {
         var chooseSendMan = new FrmChooseSendMan();
         if (chooseSendMan.ShowDialog() == DialogResult.OK)
         {
             if (!string.IsNullOrEmpty(chooseSendMan.sendManControl1.ChooseId))
             {
                 var           userManager = new ZtoUserManager(BillPrintHelper.DbHelper);
                 ZtoUserEntity userEntity  = userManager.GetObject(chooseSendMan.sendManControl1.ChooseId);
                 if (userEntity != null)
                 {
                     var parentForm = ParentForm;
                     if (parentForm is BaseForm)
                     {
                         // 设置发件人
                         (parentForm as BaseForm).SendManEntity = userEntity;
                     }
                 }
             }
         }
         chooseSendMan.Dispose();
     }
 }
示例#2
0
 /// <summary>
 /// 加载默认发件人
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ckGetDefaultSendMan_CheckedChanged(object sender, EventArgs e)
 {
     if (ckGetDefaultSendMan.Checked)
     {
         // 加载默认发件人
         ZtoUserManager userManager = new ZtoUserManager(BillPrintHelper.DbHelper);
         var            userList    = userManager.GetList <ZtoUserEntity>(new KeyValuePair <string, object>(ZtoUserEntity.FieldIsDefault, 1), new KeyValuePair <string, object>(ZtoUserEntity.FieldIssendorreceive, 1));
         if (userList.Any())
         {
             var userEntity = userList.First();
             txtSendMan.Text     = userEntity.Realname;
             dgvSendArea.Text    = string.Format("{0}-{1}-{2}", userEntity.Province, userEntity.City, userEntity.County);
             txtSendAddress.Text = userEntity.Address;
             txtSendPhone.Text   = userEntity.Mobile + " " + userEntity.TelePhone;
             txtSendCompany.Text = userEntity.Company;
             txtReceiveMan.Focus();
             txtReceiveMan.Select();
             BillPrintHelper.SetLoadDefaultSendMan();
         }
         else
         {
             if (XtraMessageBox.Show(@"未添加默认发件人信息,是否添加?", AppMessage.MSG0000, MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
             {
                 FrmAddSendMan addSendMan = new FrmAddSendMan();
                 addSendMan.ShowDialog();
                 addSendMan.Dispose();
             }
         }
     }
     else
     {
         BillPrintHelper.SetLoadDefaultSendMan(false);
     }
 }
示例#3
0
 /// <summary>
 /// 选择发件人
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ckChooseSendMan_CheckedChanged(object sender, EventArgs e)
 {
     if (ckChooseSendMan.Checked)
     {
         var chooseSendMan = new FrmChooseSendMan();
         if (chooseSendMan.ShowDialog() == DialogResult.OK)
         {
             if (!string.IsNullOrEmpty(chooseSendMan.sendManControl1.ChooseId))
             {
                 var           userManager = new ZtoUserManager(BillPrintHelper.DbHelper);
                 ZtoUserEntity userEntity  = userManager.GetObject(chooseSendMan.sendManControl1.ChooseId);
                 if (userEntity != null)
                 {
                     txtSendMan.Text     = userEntity.Realname;
                     dgvSendArea.Text    = string.Format("{0}-{1}-{2}", userEntity.Province, userEntity.City, userEntity.County);
                     txtSendAddress.Text = userEntity.Address;
                     txtSendPhone.Text   = userEntity.Mobile + " " + userEntity.TelePhone;
                     txtSendCompany.Text = userEntity.Company;
                     txtReceiveMan.Focus();
                     txtReceiveMan.Select();
                     BillPrintHelper.SetLoadDefaultSendMan();
                 }
             }
         }
         chooseSendMan.Dispose();
     }
 }
示例#4
0
 /// <summary>
 /// 选择收件人
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ckChooseReceiveMan_CheckedChanged(object sender, EventArgs e)
 {
     if (ckChooseReceiveMan.Checked)
     {
         FrmChooseReceiveMan chooseReceiveMan = new FrmChooseReceiveMan();
         if (chooseReceiveMan.ShowDialog() == DialogResult.OK)
         {
             if (!string.IsNullOrEmpty(chooseReceiveMan.receiveManControl1.ChooseId))
             {
                 ZtoUserManager userManager = new ZtoUserManager(BillPrintHelper.DbHelper);
                 ZtoUserEntity  userEntity  = userManager.GetObject(chooseReceiveMan.receiveManControl1.ChooseId);
                 if (userEntity != null)
                 {
                     // 赋值
                     txtReceiveMan.Text = userEntity.Realname;
                     // 湖北省-荆州市-公安县
                     dgvReceiveArea.Text    = string.Format("{0}-{1}-{2}", userEntity.Province, userEntity.City, userEntity.County).Replace(" ", "");
                     txtReceiveAddress.Text = userEntity.Address;
                     txtReceivePhone.Text   = string.Format("{0} {1}", userEntity.Mobile, userEntity.TelePhone);
                     txtReceiveCompany.Text = userEntity.Company;
                     txtReceiveAddress_Leave(this, null);
                 }
             }
         }
         chooseReceiveMan.Dispose();
     }
 }
 private void CkChooseReceiveManCheckedChanged(object sender, EventArgs e)
 {
     if (ckChooseReceiveMan.Checked)
     {
         FrmChooseReceiveMan chooseReceiveMan = new FrmChooseReceiveMan();
         if (chooseReceiveMan.ShowDialog() == DialogResult.OK)
         {
             if (!string.IsNullOrEmpty(chooseReceiveMan.receiveManControl1.ChooseId))
             {
                 ZtoUserManager userManager = new ZtoUserManager(BillPrintHelper.DbHelper);
                 ZtoUserEntity  userEntity  = userManager.GetObject(chooseReceiveMan.receiveManControl1.ChooseId);
                 if (userEntity != null)
                 {
                     var parentForm = ParentForm;
                     if (parentForm is BaseForm)
                     {
                         // 设置收件人
                         (parentForm as BaseForm).ReceiveManEntity = userEntity;
                         /// (parentForm as BaseForm).Controls["txtReceiveMan"].Text = userEntity.Realname;
                     }
                 }
             }
         }
         chooseReceiveMan.Dispose();
     }
 }
示例#6
0
        /// <summary>
        /// 窗体加载
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FrmSendMan_Load(object sender, EventArgs e)
        {
            splitContainerControl1.Panel1.Height = Convert.ToInt32(this.Height * 0.8);
            splitContainerControl1.Panel2.Height = Convert.ToInt32(this.Height * 0.2);
            var userManager = new ZtoUserManager(BillPrintHelper.DbHelper);
            var userList    = userManager.GetList <ZtoUserEntity>(new KeyValuePair <string, object>(ZtoUserEntity.FieldIsDefault, 1), new KeyValuePair <string, object>(ZtoUserEntity.FieldIssendorreceive, 1));

            if (!userList.Any())
            {
                ckDefault.Checked = true;
            }
            else
            {
                ckDefault.Checked = false;
            }
            if (IsReceiveForm)
            {
                Text = @"收件人";
                this.tabPageSendMan.Text    = "收件人信息";
                ckDefault.Text              = "是否默认收件人";
                lblCustomerID.Visible       = false;
                txtCustomerID.Visible       = false;
                lblCustomerPassword.Visible = false;
                txtCustomerPassword.Visible = false;
                linkLabel1.Visible          = false;
                ckProclaimText.Visible      = false;
                txtCustomerID.Enabled       = false;
                txtCustomerPassword.Enabled = false;
                btnGetElecCount.Enabled     = false;
            }
            BindArea();
            if (!string.IsNullOrEmpty(Id))
            {
                ZtoUserEntity userEntity = new ZtoUserManager(BillPrintHelper.DbHelper).GetObject(Id);
                if (userEntity != null)
                {
                    txtRealName.Text       = userEntity.Realname;
                    dgvSearchSendArea.Text = string.Format("{0}-{1}-{2}", userEntity.Province, userEntity.City, userEntity.County);
                    txtSendAddress.Text    = userEntity.Address;
                    txtCompanyName.Text    = userEntity.Company;
                    txtMobile.Text         = userEntity.Mobile;
                    txtTelePhone.Text      = userEntity.TelePhone;
                    txtPostCode.Text       = userEntity.Postcode;
                    txtRemark.Text         = userEntity.Remark;
                    ckDefault.Checked      = userEntity.IsDefault == "1";
                }
            }
            // 发件人的情况下
            if (!IsReceiveForm)
            {
                ZtoElecUserInfoEntity elecUserInfoEntity = BillPrintHelper.GetElecUserInfoEntity();
                if (elecUserInfoEntity != null)
                {
                    txtCustomerID.Text       = elecUserInfoEntity.Kehuid;
                    txtCustomerPassword.Text = elecUserInfoEntity.Pwd;
                }
            }
            txtRealName.Focus();
            txtRealName.Select();
        }
示例#7
0
 private bool AddEntity()
 {
     if (CheckInput())
     {
         ZtoUserManager userManager = new ZtoUserManager(BillPrintHelper.DbHelper);
         ZtoUserEntity  userEntity  = new ZtoUserEntity();
         userEntity.Realname = txtRealName.Text.Trim();
         var areaArray = dgvSearchSendArea.Text.Split('-');
         if (areaArray.Length > 0 && areaArray.Length == 3)
         {
             userEntity.Province = areaArray[0];
             userEntity.City     = areaArray[1];
             userEntity.County   = areaArray[2];
         }
         userEntity.Address         = txtSendAddress.Text.Trim();
         userEntity.Company         = txtCompanyName.Text.Trim();
         userEntity.TelePhone       = txtTelePhone.Text.Trim();
         userEntity.Mobile          = txtMobile.Text.Trim();
         userEntity.Postcode        = txtPostCode.Text.Trim();
         userEntity.Remark          = txtRemark.Text;
         userEntity.IsDefault       = ckDefault.Checked ? "1" : "0";
         userEntity.Issendorreceive = IsReceiveForm ? "0" : "1";
         string result;
         if (ckDefault.Checked)
         {
             if (IsReceiveForm)
             {
                 userManager.SetProperty(new KeyValuePair <string, object>(ZtoUserEntity.FieldIssendorreceive, 0), new KeyValuePair <string, object>(ZtoUserEntity.FieldIsDefault, 0));
             }
             else
             {
                 userManager.SetProperty(new KeyValuePair <string, object>(ZtoUserEntity.FieldIssendorreceive, 1), new KeyValuePair <string, object>(ZtoUserEntity.FieldIsDefault, 0));
             }
         }
         // 更新(发件人或者收件人)
         if (!string.IsNullOrEmpty(Id))
         {
             userEntity.Id = Convert.ToDecimal(Id);
             result        = userManager.Update(userEntity).ToString();
         }
         else
         {
             // 新增
             result = userManager.Add(userEntity, true);
         }
         if (!string.IsNullOrEmpty(result))
         {
             MessageBox.Show(@"保存成功。", AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
             return(true);
         }
         MessageBox.Show(@"保存失败。", AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
         return(false);
     }
     return(false);
 }
示例#8
0
        /// <summary>
        /// 窗体加载事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MainFormLoad(object sender, EventArgs e)
        {
            try
            {
                ribbonControl1.Minimized = true;
                // 加载一些默认皮肤
                SkinHelper.InitSkinGallery(rbSkin, true);
                // ChildFormManagementHelper.Navigate(this, "http://yd.zt-express.com/Help/Index2", "帮助");
                ChildFormManagementHelper.LoadMdiForm(this, "FrmPrintData");
                // ChildFormManagementHelper.Navigate(this, "http://zto.com", "申通官网");
                // radialMenu1.ShowPopup(Control.MousePosition, true);
                //ChildFormManagement.LoadMdiForm(this, "FrmSendManData");
                //ChildFormManagement.LoadMdiForm(this, "FrmReceiveManData");
                if (xtraTabbedMdiManager1.Pages.Count > 1)
                {
                    xtraTabbedMdiManager1.SelectedPage = xtraTabbedMdiManager1.Pages[1];
                }

                #region 底部一些基本信息绑定
                barItemsUser.Visibility   = DevExpress.XtraBars.BarItemVisibility.Never;
                barItemWeather.Visibility = DevExpress.XtraBars.BarItemVisibility.Never;
                var version = Assembly.GetExecutingAssembly().GetName().Version;
                barItemWelcome.Caption = string.Format("欢迎使用{1}-当前版本:{0}", version, BaseSystemInfo.SoftFullName);
                // 得到数据库的版本
                BaseParameterManager parameterManager = new BaseParameterManager(BillPrintHelper.DbHelper, BaseSystemInfo.UserInfo, BaseParameterEntity.TableName);
                var synchronous = parameterManager.GetParameter("Bill", "DBVersion", "Synchronous");
                if (!string.IsNullOrEmpty(synchronous))
                {
                    barItemWelcome.Caption += " 主库版本:" + synchronous;
                }
                this.Text           = string.Format("{0}-当前版本:{1}", this.Text, version);
                barItemTime.Caption = string.Format("登录时间:{0}  {1}", DateTime.Now.ToString(BaseSystemInfo.DateTimeFormat), DateUtil.GetDayOfWeek(DateTime.Now.DayOfWeek.ToString(), true) + " " + DateHelper.GetChineseDateTime(DateTime.Now));

                #endregion

                var userManager = new ZtoUserManager(BillPrintHelper.DbHelper);
                var userList    = userManager.GetList <ZtoUserEntity>(new KeyValuePair <string, object>(ZtoUserEntity.FieldIsDefault, 1), new KeyValuePair <string, object>(ZtoUserEntity.FieldIssendorreceive, 1));
                if (!userList.Any())
                {
                    if (XtraMessageBox.Show(@"未添加默认发件人信息,请添加默认发件人信息,有利于提取申通大头笔", AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information) == DialogResult.OK)
                    {
                        var addSendMan = new FrmAddSendMan();
                        addSendMan.ShowDialog();
                        addSendMan.Dispose();
                    }
                }
                timerUpdate.Start();
                //FrmChatMessage chatMessage = new FrmChatMessage();
                //chatMessage.Show();
            }
            catch (Exception ex)
            {
                ProcessException(ex);
            }
        }
示例#9
0
        private void BindPrintMark()
        {
            if (dgvSearchSendArea.Text.Trim().Length == 0)
            {
                // 获取系统默认发件人的省市区信息绑定就可以了,网点提供解决方案
                ZtoUserManager userManager = new ZtoUserManager(BillPrintHelper.DbHelper);
                var            userList    = userManager.GetList <ZtoUserEntity>(new KeyValuePair <string, object>(ZtoUserEntity.FieldIsDefault, 1), new KeyValuePair <string, object>(ZtoUserEntity.FieldIssendorreceive, 1));
                if (userList.Any())
                {
                    dgvSearchSendArea.Text = string.Format("{0}-{1}-{2}", userList.First().Province, userList.First().City, userList.First().County);
                }
                else
                {
                    XtraMessageBox.Show(@"发件区域填写不正确,请重新填写", AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            if (dgvSearchReceiveArea.Text.Trim().Length == 0)
            {
                return;
            }
            var sendAreaArray = dgvSearchSendArea.Text.Split('-');

            if (sendAreaArray.Length != 3)
            {
                sendAreaArray = new[] { "", "", "" };
            }
            var receiveAreaArray = dgvSearchReceiveArea.Text.Split('-');

            if (receiveAreaArray.Length != 3)
            {
                XtraMessageBox.Show(@"收件区域填写不正确,请重新填写", AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Error);
                dgvSearchReceiveArea.Focus();
                return;
            }
            var selectedRemark = new List <string>()
            {
                sendAreaArray[0], sendAreaArray[1], sendAreaArray[2]
            };
            var selectedReceiveMark = new List <string>()
            {
                receiveAreaArray[0], receiveAreaArray[1], receiveAreaArray[2]
            };
            var printMarkEntity = BillPrintHelper.GetZtoPrintMark(string.Join(",", selectedRemark), null, string.Join(",", selectedReceiveMark), null);

            if (printMarkEntity != null)
            {
                txtPrint.Text     = printMarkEntity.Result.Mark;
                txtPrintMark.Text = printMarkEntity.Result.PrintMark;
            }
            else
            {
                XtraMessageBox.Show(@"未提取到大头笔信息", AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
示例#10
0
        /// <summary>
        /// 设为默认发件人
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tspSetDefaultSendMan_Click(object sender, EventArgs e)
        {
            if (gvSendMan.RowCount > 0)
            {
                for (var rowIndex = 0; rowIndex < gvSendMan.RowCount; rowIndex++)
                {
                    var objValue = gvSendMan.GetRowCellValue(rowIndex, gvSendMan.Columns["Check"]);
                    if (objValue == null)
                    {
                        continue;
                    }
                    bool isCheck;
                    bool.TryParse(objValue.ToString(), out isCheck);
                    if (isCheck)
                    {
                        var            selectedId  = BaseBusinessLogic.ConvertToDecimal(gvSendMan.GetRowCellValue(rowIndex, "Id").ToString());
                        ZtoUserManager userManager = new ZtoUserManager(BillPrintHelper.DbHelper);
                        userManager.SetProperty(new KeyValuePair <string, object>(ZtoUserEntity.FieldIssendorreceive, 1),
                                                new KeyValuePair <string, object>(ZtoUserEntity.FieldIsDefault, 0));
                        var result = userManager.SetProperty(new KeyValuePair <string, object>(ZtoUserEntity.FieldId, selectedId),
                                                             new KeyValuePair <string, object>(ZtoUserEntity.FieldIsDefault, 1));
                        if (result > 0)
                        {
                            SendManDataBind();
                            XtraMessageBox.Show("设置成功", AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            XtraMessageBox.Show("设置失败", AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        break;
                    }
                }
            }
            //var list = GetCheckedUserRecord(gvSendMan);
            //if (list.Any())
            //{
            //    if (list.Count > 1)
            //    {
            //        XtraMessageBox.Show(@"请勿选择多条发件人记录。", AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
            //        return;
            //    }
            //    ZtoUserManager userManager = new ZtoUserManager(BillPrintHelper.DbHelper);
            //    userManager.SetProperty(new KeyValuePair<string, object>(ZtoUserEntity.FieldId, list.First().Id),
            //                            new KeyValuePair<string, object>(ZtoUserEntity.FieldIsDefault, 1));
            //    var selectedId = gvSendMan.GetRowCellValue(rowIndex, gvSendMan.Columns["Id"]).ToString();

            //}
            //else
            //{
            //    XtraMessageBox.Show(@"请添加发件人数据。", AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
            //}
        }
示例#11
0
        /// <summary>
        /// 删除收件人
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnDeleteSendMan_Click(object sender, EventArgs e)
        {
            if (gvReceiveMan.RowCount == 0)
            {
                XtraMessageBox.Show(@"请添加收件人数据。", AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            var list = GetCheckedUserRecord(gvReceiveMan);

            if (list.Any())
            {
                if (XtraMessageBox.Show(string.Format("确定删除选中的{0}条收件人记录吗?", list.Count), AppMessage.MSG0000, MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.Cancel)
                {
                    return;
                }
                using (IDbHelper dbHelper = DbHelperFactory.GetHelper(CurrentDbType.SQLite, BillPrintHelper.BillPrintConnectionString))
                {
                    try
                    {
                        dbHelper.BeginTransaction();
                        var userManager = new ZtoUserManager(dbHelper);
                        var idArray     = (from p in list select p.Id.ToString()).ToArray();
                        var result      = userManager.Delete(idArray);
                        if (result > 0)
                        {
                            dbHelper.CommitTransaction();
                            ReceiveManDataBind();
                            XtraMessageBox.Show(string.Format("成功删除{0}条收件人记录。", result), AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            dbHelper.RollbackTransaction();
                            XtraMessageBox.Show(@"删除失败", AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                    catch
                    {
                        dbHelper.RollbackTransaction();
                    }
                }
            }
        }
示例#12
0
 /// <summary>
 /// 选择发件人作为发件人来打印,网点不想总是切换默认发件人来打印,这种不好
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ckChooseSendMan_CheckedChanged(object sender, EventArgs e)
 {
     if (ckChooseSendMan.Checked)
     {
         FrmChooseSendMan chooseSendMan = new FrmChooseSendMan();
         if (chooseSendMan.ShowDialog() == DialogResult.OK)
         {
             if (!string.IsNullOrEmpty(chooseSendMan.sendManControl1.ChooseId))
             {
                 var           userManager = new ZtoUserManager(BillPrintHelper.DbHelper);
                 ZtoUserEntity userEntity  = userManager.GetObject(chooseSendMan.sendManControl1.ChooseId);
                 if (userEntity != null)
                 {
                     this.Tag  = userEntity;
                     this.Text = this.Text + string.Format(" 正在使用({0}-{1}-{2})作为发件人来进行导入", userEntity.Realname, userEntity.Mobile, userEntity.TelePhone);
                 }
             }
         }
         chooseSendMan.Dispose();
     }
 }
示例#13
0
 /// <summary>
 /// 选择发件人
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ckChooseSendMan_CheckedChanged(object sender, System.EventArgs e)
 {
     if (ckChooseSendMan.Checked)
     {
         var chooseReceiveMan = new FrmChooseSendMan();
         if (chooseReceiveMan.ShowDialog() == DialogResult.OK)
         {
             if (!string.IsNullOrEmpty(chooseReceiveMan.sendManControl1.ChooseId))
             {
                 ZtoUserManager userManager = new ZtoUserManager(BillPrintHelper.DbHelper);
                 ZtoUserEntity  userEntity  = userManager.GetObject(chooseReceiveMan.sendManControl1.ChooseId);
                 if (userEntity != null)
                 {
                     this.Tag        = userEntity;
                     txtSendMan.Text = "发件人姓名为:" + userEntity.Realname + Environment.NewLine + "发件人电话为:" + userEntity.Mobile + userEntity.TelePhone + Environment.NewLine + "发件人地址为:" + userEntity.Address;
                 }
             }
         }
         chooseReceiveMan.Dispose();
     }
 }
示例#14
0
 /// <summary>
 /// 保存联系人
 /// </summary>
 /// <param name="isSendMan"></param>
 void AddMan(bool isSendMan)
 {
     try
     {
         ZtoUserManager userManager = new ZtoUserManager(BillPrintHelper.DbHelper);
         ZtoUserEntity  userEntity  = BuildUser(isSendMan);
         // 新增
         var result = userManager.Add(userEntity, true);
         if (!string.IsNullOrEmpty(result))
         {
             XtraMessageBox.Show(@"保存成功。", AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         else
         {
             XtraMessageBox.Show(@"保存失败。", AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     catch (Exception ex)
     {
         XtraMessageBox.Show(ex.Message, AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
示例#15
0
        /// <summary>
        /// 打印多份
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnPrintMore_Click(object sender, EventArgs e)
        {
            try
            {
                int printNumber;
                if (string.IsNullOrEmpty(cmbPrintNumber.Text.Trim()))
                {
                    printNumber = 1;
                }
                else
                {
                    var result = int.TryParse(cmbPrintNumber.Text, out printNumber);
                    if (!result)
                    {
                        printNumber = 1;
                    }
                }
                if (gvReceiveMan.RowCount > 0)
                {
                    ZtoUserEntity defaultSendManEntity = new ZtoUserEntity();
                    if (ckUserDefaultSendMan.Checked)
                    {
                        ZtoUserManager userManager = new ZtoUserManager(BillPrintHelper.DbHelper);
                        var            userList    = userManager.GetList <ZtoUserEntity>(new KeyValuePair <string, object>(ZtoUserEntity.FieldIsDefault, 1), new KeyValuePair <string, object>(ZtoUserEntity.FieldIssendorreceive, 1));
                        defaultSendManEntity = userList.FirstOrDefault();
                    }
                    if (defaultSendManEntity == null)
                    {
                        if (XtraMessageBox.Show(@"未添加默认发件人信息,请添加默认发件人信息", AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information) == DialogResult.OK)
                        {
                            var addSendMan = new FrmAddSendMan();
                            addSendMan.ShowDialog();
                            addSendMan.Dispose();
                        }
                        return;
                    }
                    var list = GetCheckedUserRecord(gvReceiveMan);
                    if (list.Any())
                    {
                        _list = new List <ZtoPrintBillEntity>();
                        foreach (ZtoUserEntity userEntity in list)
                        {
                            ZtoPrintBillEntity printBillEntity = new ZtoPrintBillEntity
                            {
                                ReceiveMan      = userEntity.Realname,
                                ReceiveProvince = userEntity.Province,
                                ReceiveCity     = userEntity.City,
                                ReceiveCounty   = userEntity.County,
                                ReceivePhone    = userEntity.Mobile,
                                ReceiveAddress  = userEntity.Address,
                                SendDate        = DateTime.Now.ToString(BaseSystemInfo.DateFormat)
                            };
                            var tempAddress = printBillEntity.ReceiveAddress;
                            if (!string.IsNullOrEmpty(tempAddress))
                            {
                                if (!string.IsNullOrEmpty(printBillEntity.ReceiveProvince))
                                {
                                    tempAddress = tempAddress.Replace(printBillEntity.ReceiveProvince, "");
                                }
                                if (!string.IsNullOrEmpty(printBillEntity.ReceiveCity))
                                {
                                    tempAddress = tempAddress.Replace(printBillEntity.ReceiveCity, "");
                                }
                                if (!string.IsNullOrEmpty(printBillEntity.ReceiveCounty))
                                {
                                    tempAddress = tempAddress.Replace(printBillEntity.ReceiveCounty, "");
                                }
                            }
                            printBillEntity.ReceiveAddress = printBillEntity.ReceiveProvince +
                                                             printBillEntity.ReceiveCity + printBillEntity.ReceiveCounty +
                                                             tempAddress;
                            printBillEntity.ReceiveCompany  = userEntity.Company;
                            printBillEntity.ReceivePostcode = userEntity.Postcode;
                            if (string.IsNullOrEmpty(printBillEntity.ReceivePhone))
                            {
                                printBillEntity.ReceivePhone = userEntity.TelePhone;
                            }
                            if (ckUserDefaultSendMan.Checked)
                            {
                                printBillEntity.SendMan        = defaultSendManEntity.Realname;
                                printBillEntity.SendPhone      = defaultSendManEntity.Mobile + " " + defaultSendManEntity.TelePhone;
                                printBillEntity.SendProvince   = defaultSendManEntity.Province;
                                printBillEntity.SendCity       = defaultSendManEntity.City;
                                printBillEntity.SendCounty     = defaultSendManEntity.County;
                                printBillEntity.SendAddress    = defaultSendManEntity.Address;
                                printBillEntity.SendSite       = "";
                                printBillEntity.SendDate       = DateTime.Now.ToString(BaseSystemInfo.DateFormat);
                                printBillEntity.SendDeparture  = defaultSendManEntity.Province;
                                printBillEntity.SendCompany    = defaultSendManEntity.Company;
                                printBillEntity.SendDepartment = defaultSendManEntity.Department;
                                printBillEntity.SendPostcode   = defaultSendManEntity.Postcode;
                                var selectedRemark = new List <string> {
                                    printBillEntity.SendProvince, printBillEntity.SendCity, printBillEntity.SendCounty
                                };
                                var selectedReceiveMark = new List <string> {
                                    printBillEntity.ReceiveProvince, printBillEntity.ReceiveCity, printBillEntity.ReceiveCounty
                                };
                                var printMark = BillPrintHelper.GetRemaike(string.Join(",", selectedRemark), printBillEntity.SendAddress, string.Join(",", selectedReceiveMark), printBillEntity.ReceiveAddress);
                                printBillEntity.BigPen = printMark;
                            }

                            for (int i = 0; i < printNumber; i++)
                            {
                                _list.Add(printBillEntity);
                            }
                        }
                        GreatReport();
                        _report.PrintPreview(true);
                    }
                    else
                    {
                        XtraMessageBox.Show(@"请选择收件人数据。", AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else
                {
                    XtraMessageBox.Show(@"请添加收件人数据。", AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception exception)
            {
                XtraMessageBox.Show(exception.StackTrace, AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#16
0
        /// <summary>
        /// 取消订单
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnBackBill_Click(object sender, EventArgs e)
        {
            ZtoElecUserInfoEntity elecUserInfoEntity = BillPrintHelper.GetElecUserInfoEntity();

            if (elecUserInfoEntity != null)
            {
                List <object> stateList = new List <object>();
                //输入单号字符串集合
                var orderNumberList = DotNet.Utilities.StringUtil.SplitMobile(txtOrderNumbers.Text, false).ToList();
                if (!orderNumberList.Any())
                {
                    XtraMessageBox.Show("没有任何的订单信息,请在左侧填写订单号进行回收");
                    return;
                }
                ZtoPrintCancelManager cancelManager = new ZtoPrintCancelManager(BillPrintHelper.DbHelper);
                foreach (var orderNumber in orderNumberList)
                {
                    string msg    = "";
                    var    result = ZtoElecBillHelper.BackZtoElecBill(orderNumber, elecUserInfoEntity, ref msg);
                    stateList.Add(new
                    {
                        订单号 = orderNumber,
                        状态  = msg
                    });
                    // 取消成功了可以把订单号和单号都清空一下
                    if (result)
                    {
                        string commandText = string.Format("UPDATE ZTO_PRINT_BILL SET ORDER_NUMBER = '', BILL_CODE = '' WHERE ORDER_NUMBER = '" + orderNumber + "'");
                        if (IsUpdateBackUpData)
                        {
                            // 同时把单号的订单取消掉,备份库的订单号和单号也要取消掉
                            BillPrintHelper.BackupDbHelper.ExecuteNonQuery(commandText);
                        }
                        else
                        {
                            // 同时把单号的订单取消掉,打印数据的取消掉就行了
                            BillPrintHelper.DbHelper.ExecuteNonQuery(commandText);
                        }
                        var temp = _printBillEntities.Find(p => p.OrderNumber.Replace(" ", "").Replace("\t", "") == orderNumber.Replace(" ", ""));
                        if (temp != null)
                        {
                            cancelManager.Add(new ZtoPrintCancelEntity()
                            {
                                OrderNumber    = temp.OrderNumber,
                                BillCode       = temp.BillCode,
                                SendMan        = temp.SendMan,
                                SendPhone      = temp.SendPhone,
                                SendAddress    = temp.SendAddress,
                                ReceiveMan     = temp.ReceiveMan,
                                ReceivePhone   = temp.ReceivePhone,
                                ReceiveAddress = temp.ReceiveAddress,
                                Remark         = "取消时间点是:" + DateTime.Now.ToString(BaseSystemInfo.DateTimeFormat)
                            });
                        }
                        else
                        {
                            cancelManager.Add(new ZtoPrintCancelEntity()
                            {
                                OrderNumber = orderNumber,
                                Remark      = "取消时间点是:" + DateTime.Now.ToString(BaseSystemInfo.DateTimeFormat)
                            });
                        }
                    }
                }
                if (stateList.Any())
                {
                    gcStatus.DataSource = stateList;
                }
            }
            else
            {
                // 获取系统是否有默认发件人,如果有救修改,如果没有就新增
                ZtoUserManager userManager = new ZtoUserManager(BillPrintHelper.DbHelper);
                var            userList    = userManager.GetList <ZtoUserEntity>(new KeyValuePair <string, object>(ZtoUserEntity.FieldIsDefault, 1), new KeyValuePair <string, object>(ZtoUserEntity.FieldIssendorreceive, 1));
                if (!userList.Any())
                {
                    XtraMessageBox.Show("系统未绑定默认发件人和商家ID,请进行绑定", AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    FrmAddSendMan addSendMan = new FrmAddSendMan();
                    addSendMan.ShowDialog();
                    addSendMan.Dispose();
                }
                else
                {
                    XtraMessageBox.Show("默认发件人未绑定商家ID,请进行绑定", AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    FrmAddSendMan frmSendMan = new FrmAddSendMan {
                        Id = userList.First().Id.ToString()
                    };
                    frmSendMan.ShowDialog();
                    frmSendMan.Dispose();
                }
            }
        }
示例#17
0
        /// <summary>
        /// 导入Excel数据到本地数据库
        /// </summary>
        public bool Import()
        {
            if (string.IsNullOrEmpty(txtFileFullPath.Text.Trim()))
            {
                XtraMessageBox.Show(@"请选择录单模板", AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
                btnOpenExcel_Click(this, null);
                return(false);
            }
            if (!File.Exists(txtFileFullPath.Text))
            {
                XtraMessageBox.Show(@"选中文件不存在,请重新选择导入Excel文件", AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
                btnOpenExcel_Click(this, null);
                return(false);
            }
            var startDateTime = DateTime.Now;

            StartDt = startDateTime;
            if (!splashScreenManagerImportExcel.IsSplashFormVisible)
            {
                splashScreenManagerImportExcel.ShowWaitForm();
            }
            Application.DoEvents();
            splashScreenManagerImportExcel.SetWaitFormCaption("请稍后");
            splashScreenManagerImportExcel.SetWaitFormDescription("开始导入Excel数据...");
            try
            {
                DataTable chooseDt = ExcelHelper.ExcelToDataTable(txtFileFullPath.Text.Trim(), 38, 0, 3);
                if (chooseDt != null && chooseDt.Rows.Count > 0)
                {
                    var           list              = new List <ZtoPrintBillEntity>();
                    int           temp              = 0;
                    var           defaultUserList   = new ZtoUserManager(BillPrintHelper.DbHelper).GetList <ZtoUserEntity>(new KeyValuePair <string, object>(ZtoUserEntity.FieldIsDefault, 1), new KeyValuePair <string, object>(ZtoUserEntity.FieldIssendorreceive, 1));
                    ZtoUserEntity defaultUserEntity = null;
                    if (defaultUserList.Any())
                    {
                        defaultUserEntity = defaultUserList.First();
                    }
                    foreach (DataRow dr in chooseDt.Rows)
                    {
                        ++temp;
                        splashScreenManagerImportExcel.SetWaitFormDescription(string.Format("正在导入Excel数据:{0}/{1}", temp, chooseDt.Rows.Count));
                        ZtoPrintBillEntity entity = new ZtoPrintBillEntity();
                        if (ckTodaySend.Checked)
                        {
                            entity.SendDate = DateTime.Now.ToString(BaseSystemInfo.DateFormat);
                        }
                        if (ckUserDefaultSendMan.Checked)
                        {
                            if (defaultUserEntity != null)
                            {
                                entity.SendMan        = defaultUserEntity.Realname;
                                entity.SendPhone      = defaultUserEntity.Mobile + " " + defaultUserEntity.TelePhone;
                                entity.SendProvince   = defaultUserEntity.Province;
                                entity.SendCity       = defaultUserEntity.City;
                                entity.SendCounty     = defaultUserEntity.County;
                                entity.SendAddress    = defaultUserEntity.Address;
                                entity.SendSite       = "";
                                entity.SendDeparture  = entity.SendProvince;
                                entity.SendCompany    = defaultUserEntity.Company;
                                entity.SendDepartment = defaultUserEntity.Department;
                                entity.SendPostcode   = defaultUserEntity.Postcode;
                            }
                        }
                        else
                        {
                            if (this.Tag != null)
                            {
                                var sendUserEntity = this.Tag as ZtoUserEntity;
                                // 表示选择了一个发件人的信息,这样也不用读取Excel里面的发件人了
                                if (sendUserEntity != null)
                                {
                                    entity.SendMan        = sendUserEntity.Realname;
                                    entity.SendPhone      = sendUserEntity.Mobile + " " + sendUserEntity.TelePhone;
                                    entity.SendProvince   = sendUserEntity.Province;
                                    entity.SendCity       = sendUserEntity.City;
                                    entity.SendCounty     = sendUserEntity.County;
                                    entity.SendAddress    = sendUserEntity.Address;
                                    entity.SendSite       = "";
                                    entity.SendDeparture  = sendUserEntity.Province;
                                    entity.SendCompany    = sendUserEntity.Company;
                                    entity.SendDepartment = sendUserEntity.Department;
                                    entity.SendPostcode   = sendUserEntity.Postcode;
                                }
                            }
                            else
                            {
                                entity.SendMan       = BaseBusinessLogic.ConvertToString(dr[2]);
                                entity.SendPhone     = BaseBusinessLogic.ConvertToString(dr[3]);
                                entity.SendProvince  = BaseBusinessLogic.ConvertToString(dr[4]);
                                entity.SendCity      = BaseBusinessLogic.ConvertToString(dr[5]);
                                entity.SendCounty    = BaseBusinessLogic.ConvertToString(dr[6]);
                                entity.SendAddress   = BaseBusinessLogic.ConvertToString(dr[7]);
                                entity.SendSite      = "";
                                entity.SendDeparture = BaseBusinessLogic.ConvertToString(dr[26]);
                                if (string.IsNullOrEmpty(entity.SendDeparture))
                                {
                                    entity.SendDeparture = entity.SendProvince;
                                }
                                entity.SendCompany    = BaseBusinessLogic.ConvertToString(dr[27]);
                                entity.SendDepartment = BaseBusinessLogic.ConvertToString(dr[28]);
                                entity.SendPostcode   = BaseBusinessLogic.ConvertToString(dr[29]);
                            }
                        }
                        entity.ReceiveMan         = BaseBusinessLogic.ConvertToString(dr[8]);
                        entity.ReceivePhone       = BaseBusinessLogic.ConvertToString(dr[9]);
                        entity.ReceiveProvince    = BaseBusinessLogic.ConvertToString(dr[10]);
                        entity.ReceiveCity        = BaseBusinessLogic.ConvertToString(dr[11]);
                        entity.ReceiveCounty      = BaseBusinessLogic.ConvertToString(dr[12]);
                        entity.ReceiveAddress     = BaseBusinessLogic.ConvertToString(dr[13]);
                        entity.ReceiveDestination = BaseBusinessLogic.ConvertToString(dr[30]);
                        if (string.IsNullOrEmpty(entity.ReceiveDestination))
                        {
                            entity.ReceiveDestination = entity.ReceiveProvince;
                        }
                        entity.ReceiveCompany  = BaseBusinessLogic.ConvertToString(dr[31]);
                        entity.ReceivePostcode = BaseBusinessLogic.ConvertToString(dr[32]);
                        entity.GoodsName       = BaseBusinessLogic.ConvertToString(dr[14]);
                        entity.Weight          = BaseBusinessLogic.ConvertToString(dr[15]);
                        entity.TranFee         = BaseBusinessLogic.ConvertToString(dr[16]);
                        entity.GOODS_PAYMENT   = BaseBusinessLogic.ConvertToDecimal(dr[17]);
                        entity.TOPAYMENT       = BaseBusinessLogic.ConvertToDecimal(dr[18]);
                        entity.Length          = BaseBusinessLogic.ConvertToString(dr[33]);
                        entity.Width           = BaseBusinessLogic.ConvertToString(dr[34]);
                        entity.Height          = BaseBusinessLogic.ConvertToString(dr[35]);
                        entity.TotalNumber     = BaseBusinessLogic.ConvertToString(dr[36]);
                        entity.OrderNumber     = BaseBusinessLogic.ConvertToString(dr[37]);
                        entity.Remark          = BaseBusinessLogic.ConvertToString(dr[22]);
                        entity.CreateUserName  = "";
                        entity.CreateSite      = "";
                        entity.CreateOn        = DateTime.Now;
                        entity.PaymentType     = "现金";
                        // 如果Excel里面没有填写订单号系统自动生成一个订单号,这样提取电子面单单号就不用怕了,2016-1-23 14:07:12
                        if (string.IsNullOrEmpty(entity.OrderNumber))
                        {
                            // 导入自动生成订单号(电子面单)79170-南昌昌南  18779176845 这个qq提供的思路,2016-1-20 20:08:50
                            entity.OrderNumber = Guid.NewGuid().ToString("N").ToLower();
                        }
                        if (!ckGetServerPrintMark.Checked)
                        {
                            entity.BigPen = string.Format("{0} {1} {2}", entity.ReceiveProvince, entity.ReceiveCity, entity.ReceiveCounty);
                        }
                        else
                        {
                            entity.BigPen = "";
                        }
                        list.Add(entity);
                    }
                    if (!ckGetServerPrintMark.Checked)
                    {
                        var manager = new ZtoPrintBillManager(BillPrintHelper.DbHelper);
                        foreach (ZtoPrintBillEntity ztoPrintBillEntity in list)
                        {
                            manager.Add(ztoPrintBillEntity, true);
                        }
                        if (splashScreenManagerImportExcel != null && splashScreenManagerImportExcel.IsSplashFormVisible)
                        {
                            splashScreenManagerImportExcel.CloseWaitForm();
                        }
                        GridDataBind();
                        var ts = DateTime.Now - startDateTime;
                        lblTime.Text = string.Format("耗时:{0}时{1}分{2}秒{3}毫秒", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds);
                        Close();
                    }
                    else
                    {
                        splashScreenManagerImportExcel.SetWaitFormDescription("正在联网获取大头笔信息,请稍后......");
                        // 开线程去读取大头笔的
                        CheckBillCode(list);
                    }
                }
                else
                {
                    XtraMessageBox.Show(@"模板没有填写任何数据,导入失败", AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(false);
                }
            }
            catch (Exception ex)
            {
                ProcessException(ex);
                return(false);
            }
            finally
            {
                if (splashScreenManagerImportExcel != null && splashScreenManagerImportExcel.IsSplashFormVisible)
                {
                    splashScreenManagerImportExcel.CloseWaitForm();
                }
            }
            return(true);
        }
示例#18
0
        private void CheckZtoElecInfo()
        {
            ZtoElecUserInfoEntity elecUserInfoEntity = BillPrintHelper.GetElecUserInfoEntity();

            if (elecUserInfoEntity != null)
            {
                if (_list == null || _list.Count == 0)
                {
                    MessageUtil.ShowWarning("请认真填写好发件人和收件人的姓名、电话、省市区、地址");
                    return;
                }
                var list = ZtoElecBillHelper.BindElecBillByCustomerId(_list, elecUserInfoEntity);
                if (list != null && list.Any())
                {
                    txtBillCode.Text = list.First().BillCode;
                    txtBigPen.Text   = list.First().BigPen;
                    _list.First().BillCode = txtBillCode.Text;
                    _list.First().BigPen   = txtBigPen.Text;
                    var printBillManager   = new ZtoPrintBillManager(BillPrintHelper.DbHelper);
                    // 表示更新
                    if (!string.IsNullOrEmpty(PrintBillId))
                    {
                        list.First().Id = BaseBusinessLogic.ConvertToDecimal(PrintBillId);
                        printBillManager.Update(list.First());
                        MessageUtil.ShowTips("获取成功,已更新本地");
                    }
                    else
                    {
                        // 新增
                        printBillManager.Add(list.First(), true);
                        MessageUtil.ShowTips("获取成功,已保存本地");
                    }
                }
                else
                {
                    MessageUtil.ShowError("全部获取电子面单单号失败");
                }
            }
            else
            {
                // 在默认发件人那边修改个人的商家ID信息
                // 获取系统是否有默认发件人,如果有救修改,如果没有就新增
                ZtoUserManager userManager = new ZtoUserManager(BillPrintHelper.DbHelper);
                var            userList    = userManager.GetList <ZtoUserEntity>(new KeyValuePair <string, object>(ZtoUserEntity.FieldIsDefault, 1), new KeyValuePair <string, object>(ZtoUserEntity.FieldIssendorreceive, 1));
                if (!userList.Any())
                {
                    XtraMessageBox.Show("系统未绑定默认发件人和商家ID,请进行绑定", AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    FrmAddSendMan addSendMan = new FrmAddSendMan();
                    addSendMan.ShowDialog();
                    addSendMan.Dispose();
                }
                else
                {
                    XtraMessageBox.Show("默认发件人未绑定商家ID,请进行绑定", AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    FrmAddSendMan frmSendMan = new FrmAddSendMan {
                        Id = userList.First().Id.ToString()
                    };
                    frmSendMan.ShowDialog();
                    frmSendMan.Dispose();
                }
            }
        }
 /// <summary>
 /// 导入Excel数据到本地数据库
 /// </summary>
 public bool Import()
 {
     if (string.IsNullOrEmpty(txtFileFullPath.Text.Trim()))
     {
         XtraMessageBox.Show(@"请选择淘宝订单Excel", AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
         btnOpenExcel_Click(this, null);
         return(false);
     }
     if (!File.Exists(txtFileFullPath.Text))
     {
         XtraMessageBox.Show(@"选中文件不存在,请重新选择导入Excel文件", AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
         btnOpenExcel_Click(this, null);
         return(false);
     }
     #region 检查是否选择了发件人
     ZtoUserEntity defaultUserEntity = null;
     if (ckUserDefaultSendMan.Checked)
     {
         // 获取到默认的发件人
         var defaultUserList = new ZtoUserManager(BillPrintHelper.DbHelper).GetList <ZtoUserEntity>(new KeyValuePair <string, object>(ZtoUserEntity.FieldIsDefault, 1), new KeyValuePair <string, object>(ZtoUserEntity.FieldIssendorreceive, 1));
         if (defaultUserList.Any())
         {
             defaultUserEntity = defaultUserList.FirstOrDefault();
             if (defaultUserEntity == null)
             {
                 XtraMessageBox.Show(@"请添加一个默认的发件人,然后再导入订单数据", AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
                 return(false);
             }
         }
         else
         {
             XtraMessageBox.Show(@"请添加一个默认的发件人,然后再导入订单数据", AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
             return(false);
         }
     }
     else
     {
         if (this.Tag != null)
         {
             defaultUserEntity = this.Tag as ZtoUserEntity;
             // 表示选择了一个发件人的信息,这样也不用读取Excel里面的发件人了
             if (defaultUserEntity == null)
             {
                 XtraMessageBox.Show(@"请重新选择一个发件人,然后再导入订单数据", AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
                 ckChooseSendMan.Checked = true;
                 Import();
             }
         }
         else
         {
             XtraMessageBox.Show(@"请选择一个发件人,然后再导入订单数据", AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
             ckChooseSendMan.Checked = true;
             Import();
         }
     }
     #endregion
     var startDateTime = DateTime.Now;
     StartDt = startDateTime;
     if (!splashScreenManagerImportExcel.IsSplashFormVisible)
     {
         splashScreenManagerImportExcel.ShowWaitForm();
     }
     Application.DoEvents();
     splashScreenManagerImportExcel.SetWaitFormCaption("请稍后");
     splashScreenManagerImportExcel.SetWaitFormDescription("开始导入淘宝订单Excel数据...");
     try
     {
         DataTable chooseDt;
         if (Path.GetExtension(txtFileFullPath.Text) == ".csv")
         {
             var readCsv = new ReadCsvHelper(txtFileFullPath.Text);
             readCsv.CreateTable();
             chooseDt = readCsv.GetResoultTable();
         }
         else
         {
             chooseDt = ExcelHelper.ExcelToDataTable(txtFileFullPath.Text, 0, null);
         }
         if (chooseDt != null && chooseDt.Rows.Count > 0)
         {
             var list = new List <ZtoPrintBillEntity>();
             int temp = 0;
             foreach (DataRow dr in chooseDt.Rows)
             {
                 ++temp;
                 splashScreenManagerImportExcel.SetWaitFormDescription(string.Format("正在导入Excel数据:{0}/{1}", temp, chooseDt.Rows.Count));
                 var entity = new ZtoPrintBillEntity();
                 if (ckTodaySend.Checked)
                 {
                     entity.SendDate = DateTime.Now.ToString(BaseSystemInfo.DateFormat);
                 }
                 if (defaultUserEntity != null)
                 {
                     entity.SendMan        = defaultUserEntity.Realname;
                     entity.SendPhone      = defaultUserEntity.Mobile + " " + defaultUserEntity.TelePhone;
                     entity.SendProvince   = defaultUserEntity.Province;
                     entity.SendCity       = defaultUserEntity.City;
                     entity.SendCounty     = defaultUserEntity.County;
                     entity.SendAddress    = defaultUserEntity.Address;
                     entity.SendCompany    = defaultUserEntity.Company;
                     entity.SendDepartment = defaultUserEntity.Department;
                     entity.SendPostcode   = defaultUserEntity.Postcode;
                 }
                 entity.SendSite        = "";
                 entity.SendDeparture   = entity.SendProvince;
                 entity.ReceiveMan      = BaseBusinessLogic.ConvertToString(dr[12]);
                 entity.ReceivePhone    = BaseBusinessLogic.ConvertToString(dr[16]);
                 entity.ReceiveProvince = "";
                 entity.ReceiveCity     = "";
                 entity.ReceiveCounty   = "";
                 entity.ReceiveAddress  = BaseBusinessLogic.ConvertToString(dr[13]).Replace(" ", "");
                 // 目的地
                 entity.ReceiveDestination = "";
                 if (string.IsNullOrEmpty(entity.ReceiveDestination))
                 {
                     entity.ReceiveDestination = entity.ReceiveProvince;
                 }
                 entity.ReceiveCompany  = "";
                 entity.ReceivePostcode = "";
                 entity.GoodsName       = BaseBusinessLogic.ConvertToString(dr[19]);
                 entity.Weight          = "";
                 entity.TranFee         = "";
                 entity.GOODS_PAYMENT   = 0;
                 entity.TOPAYMENT       = 0;
                 entity.Length          = "";
                 entity.Width           = "";
                 entity.Height          = "";
                 entity.TotalNumber     = "";
                 entity.OrderNumber     = BaseBusinessLogic.ConvertToString(dr[0]);
                 entity.Remark          = BaseBusinessLogic.ConvertToString(dr[23]);
                 entity.CreateUserName  = "";
                 entity.CreateSite      = "";
                 entity.CreateOn        = DateTime.Now;
                 entity.PaymentType     = "";
                 // 如果Excel里面没有填写订单号系统自动生成一个订单号,这样提取电子面单单号就不用怕了,2016-1-23 14:07:12
                 if (string.IsNullOrEmpty(entity.OrderNumber))
                 {
                     // 导入自动生成订单号(电子面单)79170-南昌昌南  18779176845 这个qq提供的思路,2016-1-20 20:08:50
                     entity.OrderNumber = Guid.NewGuid().ToString("N").ToLower();
                 }
                 if (!ckGetServerPrintMark.Checked)
                 {
                     entity.BigPen = string.Format("{0} {1} {2}", entity.ReceiveProvince, entity.ReceiveCity, entity.ReceiveCounty);
                 }
                 else
                 {
                     entity.BigPen = "";
                 }
                 list.Add(entity);
             }
             if (!ckGetServerPrintMark.Checked)
             {
                 var manager = new ZtoPrintBillManager(BillPrintHelper.DbHelper);
                 foreach (ZtoPrintBillEntity ztoPrintBillEntity in list)
                 {
                     manager.Add(ztoPrintBillEntity, true);
                 }
                 if (splashScreenManagerImportExcel != null && splashScreenManagerImportExcel.IsSplashFormVisible)
                 {
                     splashScreenManagerImportExcel.CloseWaitForm();
                 }
                 GridDataBind();
                 Close();
             }
             else
             {
                 splashScreenManagerImportExcel.SetWaitFormDescription("正在联网获取大头笔信息,请稍后......");
                 // 开线程去读取大头笔的
                 CheckBillCode(list);
             }
         }
         else
         {
             XtraMessageBox.Show(@"模板没有填写任何数据,导入失败", AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Error);
             return(false);
         }
     }
     catch (Exception ex)
     {
         ProcessException(ex);
         return(false);
     }
     finally
     {
         if (splashScreenManagerImportExcel != null && splashScreenManagerImportExcel.IsSplashFormVisible)
         {
             splashScreenManagerImportExcel.CloseWaitForm();
         }
     }
     return(true);
 }
 /// <summary>
 /// 导入
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ImprnBut_Click(object sender, EventArgs e)
 {
     try
     {
         ImprnBut.Enabled = false;
         DateTime start = DateTime.Now;
         if (lbOpposite.Items.Count > 0)
         {
             var keyValuePairs = new List <KeyValuePair <string, string> >();
             foreach (var item in lbOpposite.Items)
             {
                 var tempArray = item.ToString().Split('-');
                 keyValuePairs.Add(new KeyValuePair <string, string>(tempArray[0], tempArray[1]));
             }
             if (keyValuePairs.Count > 0)
             {
                 var listField                 = new List <string>();
                 var listValue                 = new List <string>();
                 var listCommandText           = new List <string>();
                 List <ZtoUserEntity> userList = null;
                 if (ckUseDefaultSendMan.Checked)
                 {
                     var userManager = new ZtoUserManager(BillPrintHelper.DbHelper);
                     // 获取默认发件人
                     userList = userManager.GetList <ZtoUserEntity>(new KeyValuePair <string, object>(ZtoUserEntity.FieldIsDefault, 1), new KeyValuePair <string, object>(ZtoUserEntity.FieldIssendorreceive, 1));
                 }
                 foreach (DataRow data in _execldt.Rows)
                 {
                     foreach (var keyValuePair in keyValuePairs)
                     {
                         // Excel每一列的值
                         var value = data[keyValuePair.Key].ToString();
                         // Excel的值要特殊处理一些符号(不然插入数据库有问题的)
                         if (!string.IsNullOrEmpty(value))
                         {
                             value = value.Replace("'", "").Replace("\"", "").Replace("=", "").Replace(" ", "");
                         }
                         // 获取到实际的数据库列名称
                         var dataField = BillPrintHelper.GetFieldByName(keyValuePair.Value);
                         listField.Add(dataField);
                         //if (dataField == ZtoPrintBillEntity.FieldOrderNumber)
                         //{
                         //    if (string.IsNullOrEmpty(value))
                         //    {
                         //        value = Guid.NewGuid().ToString("N");
                         //    }
                         //}
                         listValue.Add(value);
                     }
                     // 使用默认发件人
                     if (ckUseDefaultSendMan.Checked)
                     {
                         if (userList.Any())
                         {
                             var userEntity = userList.FirstOrDefault();
                             listField.Add(ZtoPrintBillEntity.FieldSendMan);
                             listValue.Add(userEntity.Realname);
                             if (!string.IsNullOrEmpty(userEntity.Mobile) && string.IsNullOrEmpty(userEntity.TelePhone))
                             {
                                 listField.Add(ZtoPrintBillEntity.FieldSendPhone);
                                 listValue.Add(userEntity.Mobile);
                             }
                             if (string.IsNullOrEmpty(userEntity.Mobile) && !string.IsNullOrEmpty(userEntity.TelePhone))
                             {
                                 listField.Add(ZtoPrintBillEntity.FieldSendPhone);
                                 listValue.Add(userEntity.TelePhone);
                             }
                             if (!string.IsNullOrEmpty(userEntity.Mobile) && !string.IsNullOrEmpty(userEntity.TelePhone))
                             {
                                 listField.Add(ZtoPrintBillEntity.FieldSendPhone);
                                 listValue.Add(userEntity.Mobile);
                             }
                             listField.Add(ZtoPrintBillEntity.FieldSendProvince);
                             listValue.Add(userEntity.Province);
                             listField.Add(ZtoPrintBillEntity.FieldSendCity);
                             listValue.Add(userEntity.City);
                             listField.Add(ZtoPrintBillEntity.FieldSendCounty);
                             listValue.Add(userEntity.County);
                             listField.Add(ZtoPrintBillEntity.FieldSendDeparture);
                             listValue.Add(userEntity.Province);
                             listField.Add(ZtoPrintBillEntity.FieldSendAddress);
                             listValue.Add(userEntity.Address);
                             listField.Add(ZtoPrintBillEntity.FieldSendPostcode);
                             listValue.Add(userEntity.Postcode);
                             listField.Add(ZtoPrintBillEntity.FieldSendDate);
                             listValue.Add(DateTime.Now.ToString(BaseSystemInfo.DateFormat));
                             listField.Add(ZtoPrintBillEntity.FieldCreateOn);
                             listValue.Add(DateTime.Now.ToString(BaseSystemInfo.DateTimeFormat));
                         }
                     }
                     // 如果没有导入订单号这个字段就要手动导入了,因为这个很重要
                     if (listField.All(p => p != ZtoPrintBillEntity.FieldOrderNumber))
                     {
                         listField.Add(ZtoPrintBillEntity.FieldOrderNumber);
                         listValue.Add(Guid.NewGuid().ToString("N"));
                     }
                     // 到付
                     if (listField.All(p => p != ZtoPrintBillEntity.FieldToPayMent))
                     {
                         listField.Add(ZtoPrintBillEntity.FieldToPayMent);
                         listValue.Add("0");
                     }
                     // 代收
                     if (listField.All(p => p != ZtoPrintBillEntity.FieldGoodsPayMent))
                     {
                         listField.Add(ZtoPrintBillEntity.FieldGoodsPayMent);
                         listValue.Add("0");
                     }
                     string tempCommandText = string.Format("INSERT INTO {0} ({1}) VALUES({2})", ZtoPrintBillEntity.TableName, string.Join(",", listField), "'" + string.Join("','", listValue) + "'");
                     listCommandText.Add(tempCommandText);
                     listField.Clear();
                     listValue.Clear();
                 }
                 if (listCommandText.Count > 0)
                 {
                     var resultCount = 0;
                     // 用事务插入最快还有删除
                     using (IDbHelper dbHelper = DbHelperFactory.GetHelper(CurrentDbType.SQLite, BillPrintHelper.BillPrintConnectionString))
                     {
                         dbHelper.BeginTransaction();
                         foreach (var commandText in listCommandText)
                         {
                             try
                             {
                                 resultCount = resultCount + (dbHelper.ExecuteNonQuery(commandText));
                             }
                             catch (Exception ex)
                             {
                                 dbHelper.RollbackTransaction();
                             }
                         }
                         dbHelper.CommitTransaction();
                     }
                     TimeSpan ts = DateTime.Now - start;
                     XtraMessageBox.Show(string.Format("成功导入{0}条,耗时:{1}", resultCount, string.Format("{0}分{1}秒", ts.Minutes, ts.Seconds)), AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
                     Close();
                 }
                 else
                 {
                     XtraMessageBox.Show("导入失败", AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
                 }
             }
         }
         else
         {
             XtraMessageBox.Show("请从左边选择对应的导入关系列", AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     catch (Exception exception)
     {
         XtraMessageBox.Show(exception.Message, AppMessage.MSG0000);
     }
     finally
     {
         ImprnBut.Enabled = true;
     }
 }
 /// <summary>
 /// 导入Excel数据到本地数据库
 /// </summary>
 public bool Import()
 {
     if (string.IsNullOrEmpty(txtFileFullPath.Text.Trim()))
     {
         XtraMessageBox.Show(@"请选择录单模板", AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
         btnOpenExcel_Click(this, null);
         return(false);
     }
     if (!File.Exists(txtFileFullPath.Text))
     {
         XtraMessageBox.Show(@"选中文件不存在,请重新选择导入Excel文件", AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
         btnOpenExcel_Click(this, null);
         return(false);
     }
     if (!splashScreenManagerImportExcel.IsSplashFormVisible)
     {
         splashScreenManagerImportExcel.ShowWaitForm();
     }
     Application.DoEvents();
     splashScreenManagerImportExcel.SetWaitFormCaption("请稍后");
     splashScreenManagerImportExcel.SetWaitFormDescription("开始导入Excel数据...");
     try
     {
         int crossRow = int.Parse(cmbPrintNumber.Text) - 1;
         if (crossRow < 0)
         {
             crossRow = 1;
         }
         DataTable chooseDt = ExcelHelper.ExcelToDataTable(txtFileFullPath.Text.Trim(), 38, 0, crossRow);
         if (chooseDt != null && chooseDt.Rows.Count > 0)
         {
             var list = new List <ZtoUserEntity>();
             int temp = 0;
             foreach (DataRow dr in chooseDt.Rows)
             {
                 ++temp;
                 splashScreenManagerImportExcel.SetWaitFormDescription(string.Format("正在导入Excel数据:{0}/{1}", temp, chooseDt.Rows.Count));
                 var userEntity = new ZtoUserEntity {
                     Realname = BaseBusinessLogic.ConvertToString(dr[8])
                 };
                 if (ValidateUtil.IsMobile(BaseBusinessLogic.ConvertToString(dr[9])))
                 {
                     userEntity.Mobile = BaseBusinessLogic.ConvertToString(dr[9]);
                 }
                 else
                 {
                     userEntity.TelePhone = BaseBusinessLogic.ConvertToString(dr[9]);
                 }
                 var tempProvince = BaseBusinessLogic.ConvertToString(dr[10]);
                 // 收件人地址(有可能用户不填写收件省市区)
                 userEntity.Address = BaseBusinessLogic.ConvertToString(dr[13]);
                 if (tempProvince != null)
                 {
                     userEntity.Province = tempProvince.Trim();
                 }
                 var tempCity = BaseBusinessLogic.ConvertToString(dr[11]);
                 if (tempCity != null)
                 {
                     userEntity.City = tempCity.Trim();
                 }
                 var tempCounty = BaseBusinessLogic.ConvertToString(dr[12]);
                 if (tempCounty != null)
                 {
                     userEntity.County = tempCounty.Trim();
                 }
                 if (string.IsNullOrEmpty(userEntity.Province) && string.IsNullOrEmpty(userEntity.City) && string.IsNullOrEmpty(userEntity.County))
                 {
                     if (!string.IsNullOrEmpty(userEntity.Address))
                     {
                         var result = BaiduMapHelper.GetProvCityDistFromBaiduMap(userEntity.Address);
                         if (result != null)
                         {
                             userEntity.Province = result.Result.AddressComponent.Province;
                             userEntity.City     = result.Result.AddressComponent.City;
                             userEntity.County   = result.Result.AddressComponent.District;
                         }
                     }
                 }
                 userEntity.Company         = BaseBusinessLogic.ConvertToString(dr[31]);
                 userEntity.Postcode        = BaseBusinessLogic.ConvertToString(dr[32]);
                 userEntity.Issendorreceive = "0";
                 if (string.IsNullOrEmpty(userEntity.Postcode))
                 {
                     if (!string.IsNullOrEmpty(userEntity.City) && !string.IsNullOrEmpty(userEntity.County))
                     {
                         userEntity.Postcode = NetworkHelper.GetPostCodeByAddress(userEntity.City, userEntity.County);
                     }
                 }
                 if (!string.IsNullOrEmpty(userEntity.Province))
                 {
                     var areaEntity = _areaManager.GetList <BaseAreaEntity>(new KeyValuePair <string, object>(BaseAreaEntity.FieldFullName, userEntity.Province)).FirstOrDefault();
                     if (areaEntity != null)
                     {
                         userEntity.ProvinceId = areaEntity.Id;
                     }
                 }
                 if (!string.IsNullOrEmpty(userEntity.City))
                 {
                     var areaEntity = _areaManager.GetList <BaseAreaEntity>(new KeyValuePair <string, object>(BaseAreaEntity.FieldFullName, userEntity.City)).FirstOrDefault();
                     if (areaEntity != null)
                     {
                         userEntity.CityId = areaEntity.Id;
                     }
                 }
                 if (!string.IsNullOrEmpty(userEntity.County))
                 {
                     var areaEntity = _areaManager.GetList <BaseAreaEntity>(new KeyValuePair <string, object>(BaseAreaEntity.FieldFullName, userEntity.County)).FirstOrDefault();
                     if (areaEntity != null)
                     {
                         userEntity.CountyId = areaEntity.Id;
                     }
                 }
                 userEntity.CreateOn = DateTime.Now;
                 list.Add(userEntity);
             }
             using (IDbHelper dbHelper = DbHelperFactory.GetHelper(CurrentDbType.SQLite, BillPrintHelper.BillPrintConnectionString))
             {
                 try
                 {
                     dbHelper.BeginTransaction();
                     var manager = new ZtoUserManager(dbHelper);
                     foreach (ZtoUserEntity ztoUserEntity in list)
                     {
                         manager.Add(ztoUserEntity, true);
                     }
                     dbHelper.CommitTransaction();
                     GridDataBind();
                 }
                 catch (Exception ex)
                 {
                     dbHelper.RollbackTransaction();
                     ProcessException(ex);
                 }
             }
             if (splashScreenManagerImportExcel != null && splashScreenManagerImportExcel.IsSplashFormVisible)
             {
                 splashScreenManagerImportExcel.CloseWaitForm();
             }
             Close();
         }
         else
         {
             XtraMessageBox.Show(@"模板没有填写任何数据,导入失败", AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Error);
             return(false);
         }
     }
     catch (Exception ex)
     {
         ProcessException(ex);
         return(false);
     }
     finally
     {
         if (splashScreenManagerImportExcel != null && splashScreenManagerImportExcel.IsSplashFormVisible)
         {
             splashScreenManagerImportExcel.CloseWaitForm();
         }
     }
     return(true);
 }
示例#22
0
        /// <summary>
        /// 导入Excel数据到本地数据库
        /// </summary>
        public bool Import()
        {
            if (string.IsNullOrEmpty(txtFileFullPath.Text.Trim()))
            {
                XtraMessageBox.Show(@"请选择录单模板", AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
                btnOpenExcel_Click(this, null);
                return(false);
            }
            if (!File.Exists(txtFileFullPath.Text))
            {
                XtraMessageBox.Show(@"选中文件不存在,请重新选择导入Excel文件", AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
                btnOpenExcel_Click(this, null);
                return(false);
            }
            var startDateTime = DateTime.Now;

            StartDt = startDateTime;
            if (!splashScreenManagerImportExcel.IsSplashFormVisible)
            {
                splashScreenManagerImportExcel.ShowWaitForm();
            }
            Application.DoEvents();
            splashScreenManagerImportExcel.SetWaitFormCaption("请稍后");
            splashScreenManagerImportExcel.SetWaitFormDescription("开始导入Excel数据...");
            try
            {
                DataTable chooseDt = ExcelHelper.ExcelToDataTable(txtFileFullPath.Text.Trim(), 11, 0, 1);
                if (chooseDt != null && chooseDt.Rows.Count > 0)
                {
                    var           list              = new List <ZtoPrintBillEntity>();
                    int           temp              = 0;
                    var           defaultUserList   = new ZtoUserManager(BillPrintHelper.DbHelper).GetList <ZtoUserEntity>(new KeyValuePair <string, object>(ZtoUserEntity.FieldIsDefault, 1), new KeyValuePair <string, object>(ZtoUserEntity.FieldIssendorreceive, 1));
                    ZtoUserEntity defaultUserEntity = null;
                    if (defaultUserList.Any())
                    {
                        defaultUserEntity = defaultUserList.First();
                    }
                    foreach (DataRow dr in chooseDt.Rows)
                    {
                        ++temp;
                        splashScreenManagerImportExcel.SetWaitFormDescription(string.Format("正在导入Excel数据:{0}/{1}", temp, chooseDt.Rows.Count));
                        ZtoPrintBillEntity entity = new ZtoPrintBillEntity();
                        if (ckTodaySend.Checked)
                        {
                            entity.SendDate = DateTime.Now.ToString(BaseSystemInfo.DateFormat);
                        }
                        if (ckUserDefaultSendMan.Checked)
                        {
                            if (defaultUserEntity != null)
                            {
                                entity.SendMan        = defaultUserEntity.Realname;
                                entity.SendPhone      = defaultUserEntity.Mobile + " " + defaultUserEntity.TelePhone;
                                entity.SendProvince   = defaultUserEntity.Province;
                                entity.SendCity       = defaultUserEntity.City;
                                entity.SendCounty     = defaultUserEntity.County;
                                entity.SendAddress    = defaultUserEntity.Address;
                                entity.SendDeparture  = entity.SendProvince;
                                entity.SendCompany    = defaultUserEntity.Company;
                                entity.SendDepartment = defaultUserEntity.Department;
                                entity.SendPostcode   = defaultUserEntity.Postcode;
                            }
                        }
                        else
                        {
                            // 使用Excel里面的发件人
                            entity.SendMan     = BaseBusinessLogic.ConvertToString(dr[6]);
                            entity.SendPhone   = BaseBusinessLogic.ConvertToString(dr[7]);
                            entity.SendAddress = BaseBusinessLogic.ConvertToString(dr[8]);
                            if (string.IsNullOrEmpty(entity.SendProvince) && string.IsNullOrEmpty(entity.SendCity) && string.IsNullOrEmpty(entity.SendCounty))
                            {
                                if (!string.IsNullOrEmpty(entity.SendAddress))
                                {
                                    var baiAddressEntity = BaiduMapHelper.GetProvCityDistFromBaiduMap(entity.SendAddress);
                                    if (baiAddressEntity != null)
                                    {
                                        entity.SendProvince = baiAddressEntity.Result.AddressComponent.Province;
                                        entity.SendCity     = baiAddressEntity.Result.AddressComponent.City;
                                        entity.SendCounty   = baiAddressEntity.Result.AddressComponent.District;
                                    }
                                }
                            }
                            entity.SendDeparture = entity.SendProvince;
                            if (string.IsNullOrEmpty(entity.SendDeparture))
                            {
                                entity.SendDeparture = entity.SendProvince;
                            }
                            entity.SendCompany    = BaseBusinessLogic.ConvertToString(dr[10]);
                            entity.SendDepartment = BaseBusinessLogic.ConvertToString(dr[11]);
                            entity.SendPostcode   = BaseBusinessLogic.ConvertToString(dr[9]);
                        }
                        entity.ReceiveMan     = BaseBusinessLogic.ConvertToString(dr[0]);
                        entity.ReceivePhone   = BaseBusinessLogic.ConvertToString(dr[1]);
                        entity.ReceiveAddress = BaseBusinessLogic.ConvertToString(dr[2]);
                        //if (string.IsNullOrEmpty(entity.ReceiveProvince) && string.IsNullOrEmpty(entity.ReceiveCity) && string.IsNullOrEmpty(entity.ReceiveCounty))
                        //{
                        //    if (!string.IsNullOrEmpty(entity.ReceiveAddress))
                        //    {
                        //        var baiAddressEntity = BaiduHelper.GetProvCityDistFromBaiduMap(entity.ReceiveAddress);
                        //        if (baiAddressEntity != null)
                        //        {
                        //            entity.ReceiveProvince = baiAddressEntity.Result.AddressComponent.Province;
                        //            entity.ReceiveCity = baiAddressEntity.Result.AddressComponent.City;
                        //            entity.ReceiveCounty = baiAddressEntity.Result.AddressComponent.District;
                        //        }
                        //    }
                        //}
                        entity.ReceiveDestination = entity.ReceiveProvince;
                        if (string.IsNullOrEmpty(entity.ReceiveDestination))
                        {
                            entity.ReceiveDestination = entity.ReceiveProvince;
                        }
                        //entity.ReceiveCompany = BaseBusinessLogic.ConvertToString(dr[31]);
                        //entity.ReceivePostcode = BaseBusinessLogic.ConvertToString(dr[32]);
                        //entity.GoodsName = BaseBusinessLogic.ConvertToString(dr[14]);
                        //entity.Weight = BaseBusinessLogic.ConvertToString(dr[15]);
                        //entity.TranFee = BaseBusinessLogic.ConvertToString(dr[16]);
                        //entity.Length = BaseBusinessLogic.ConvertToString(dr[33]);
                        //entity.Width = BaseBusinessLogic.ConvertToString(dr[34]);
                        //entity.Height = BaseBusinessLogic.ConvertToString(dr[35]);
                        //entity.TotalNumber = BaseBusinessLogic.ConvertToString(dr[36]);
                        entity.Remark      = BaseBusinessLogic.ConvertToString(dr[4]);
                        entity.OrderNumber = BaseBusinessLogic.ConvertToString(dr[3]);
                        entity.TranFee     = BaseBusinessLogic.ConvertToString(dr[5]);
                        entity.CreateOn    = DateTime.Now;
                        if (!ckGetServerPrintMark.Checked)
                        {
                            entity.BigPen = string.Format("{0} {1} {2}", entity.ReceiveProvince, entity.ReceiveCity, entity.ReceiveCounty);
                        }
                        else
                        {
                            entity.BigPen = "";
                        }
                        list.Add(entity);
                    }
                    if (!ckGetServerPrintMark.Checked)
                    {
                        var manager = new ZtoPrintBillManager(BillPrintHelper.DbHelper);
                        foreach (ZtoPrintBillEntity ztoPrintBillEntity in list)
                        {
                            manager.Add(ztoPrintBillEntity, true);
                        }
                        if (splashScreenManagerImportExcel != null && splashScreenManagerImportExcel.IsSplashFormVisible)
                        {
                            splashScreenManagerImportExcel.CloseWaitForm();
                        }
                        GridDataBind();
                        var ts = DateTime.Now - startDateTime;
                        lblTime.Text = string.Format("耗时:{0}时{1}分{2}秒{3}毫秒", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds);
                        Close();
                    }
                    else
                    {
                        splashScreenManagerImportExcel.SetWaitFormDescription("正在联网获取大头笔信息");
                        if (splashScreenManagerImportExcel != null && splashScreenManagerImportExcel.IsSplashFormVisible)
                        {
                            splashScreenManagerImportExcel.CloseWaitForm();
                        }
                        // 开线程去读取大头笔的
                        CheckBillCode(list);
                    }
                }
                else
                {
                    XtraMessageBox.Show(@"模板没有填写任何数据,导入失败", AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(false);
                }
            }
            catch (Exception ex)
            {
                ProcessException(ex);
                return(false);
            }
            finally
            {
                if (splashScreenManagerImportExcel != null && splashScreenManagerImportExcel.IsSplashFormVisible)
                {
                    splashScreenManagerImportExcel.CloseWaitForm();
                }
            }
            return(true);
        }