Example #1
0
        /// <summary>
        /// 识别发/收件人
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnRecognitionAddress_Click(object sender, EventArgs e)
        {
            FrmRecognitionAddress recognitionTaoBaoFrm = new FrmRecognitionAddress()
            {
                Owner = this
            };

            if (recognitionTaoBaoFrm.ShowDialog() == DialogResult.OK)
            {
                //实现绑定
                ZtoUserEntity userEntity = this.Tag as ZtoUserEntity;
                if (userEntity != null)
                {
                    //赋值
                    if (userEntity.Issendorreceive == "1")
                    {
                        InitSendMan(userEntity);
                    }
                    else
                    {
                        InitReceiveMan(userEntity);
                    }
                    this.Tag = null;
                }
            }
            recognitionTaoBaoFrm.Dispose();
        }
Example #2
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();
     }
 }
Example #3
0
        /// <summary>
        /// 更新修改记录
        /// </summary>
        /// <param name="oldShow"> </param>
        /// <param name="newShow"> </param>

        public void UpdateModifyRecord(ZtoUserEntity oldShow, ZtoUserEntity newShow, string tableName = null)
        {
            if (string.IsNullOrEmpty(tableName))
            {
                tableName = this.CurrentTableName + "_LOG";
            }
            BaseModifyRecordManager manager = new BaseModifyRecordManager(DbHelper, this.UserInfo, tableName);

            foreach (var property in typeof(ZtoUserEntity).GetProperties())
            {
                var fieldDescription = property.GetCustomAttributes(typeof(FieldDescription), false).FirstOrDefault() as FieldDescription;
                var oldValue         = Convert.ToString(property.GetValue(oldShow, null));
                var newValue         = Convert.ToString(property.GetValue(newShow, null));

                if (!fieldDescription.NeedLog || oldValue == newValue)
                {
                    continue;
                }
                var record = new BaseModifyRecordEntity();
                record.ColumnCode        = property.Name.ToUpper();
                record.ColumnDescription = fieldDescription.Text;
                record.NewValue          = newValue;
                record.OldValue          = oldValue;
                record.TableCode         = ZtoUserEntity.TableName.ToUpper();
                record.TableDescription  = FieldExtensions.ToDescription(typeof(ZtoUserEntity), "TableName");
                record.RecordKey         = oldShow.Id.ToString();
                record.IPAddress         = DotNet.Business.Utilities.GetIPAddress(true);
                record.CreateBy          = UserInfo.RealName;
                record.CreateOn          = DateTime.Now;
                manager.Add(record, true, false);
            }
        }
 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();
     }
 }
 /// <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();
     }
 }
 /// <summary>
 /// 识别发/收件人
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ckRecognitionAddress_CheckedChanged(object sender, EventArgs e)
 {
     if (ckRecognitionAddress.Checked)
     {
         FrmRecognitionAddress recognitionTaoBaoFrm = new FrmRecognitionAddress()
         {
             Owner = this.ParentForm
         };
         if (recognitionTaoBaoFrm.ShowDialog() == DialogResult.OK)
         {
             //实现绑定
             var parentForm = this.ParentForm;
             if (parentForm != null && parentForm.Tag != null)
             {
                 ZtoUserEntity userEntity = parentForm.Tag as ZtoUserEntity;
                 if (userEntity != null)
                 {
                     //赋值
                     if (userEntity.Issendorreceive == "1")
                     {
                         InitSendMan(userEntity);
                     }
                     else
                     {
                         InitReceiveMan(userEntity);
                     }
                     parentForm.Tag = null;
                 }
             }
         }
         recognitionTaoBaoFrm.Dispose();
     }
 }
 /// <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();
     }
 }
 void InitSendMan(ZtoUserEntity userEntity)
 {
     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;
     txtRemark.Text      = userEntity.Remark;
 }
Example #9
0
        /// <summary>
        /// 添加实体
        /// </summary>
        /// <param name="entity">实体</param>
        public string AddObject(ZtoUserEntity entity)
        {
            string key = string.Empty;

            if (entity.Id != null)
            {
                key = entity.Id.ToString();
            }
            SQLBuilder sqlBuilder = new SQLBuilder(DbHelper, this.Identity, this.ReturnId);

            sqlBuilder.BeginInsert(this.CurrentTableName, this.PrimaryKey);
            if (!this.Identity)
            {
                // 这里已经是指定了主键了,所以不需要返回主键了
                sqlBuilder.ReturnId = false;
                sqlBuilder.SetValue(this.PrimaryKey, entity.Id);
            }
            else
            {
                if (!this.ReturnId && (DbHelper.CurrentDbType == CurrentDbType.Oracle || DbHelper.CurrentDbType == CurrentDbType.DB2))
                {
                    if (DbHelper.CurrentDbType == CurrentDbType.Oracle)
                    {
                        sqlBuilder.SetFormula(this.PrimaryKey, "SEQ_" + this.CurrentTableName.ToUpper() + ".NEXTVAL ");
                    }
                    if (DbHelper.CurrentDbType == CurrentDbType.DB2)
                    {
                        sqlBuilder.SetFormula(this.PrimaryKey, "NEXT VALUE FOR SEQ_" + this.CurrentTableName.ToUpper());
                    }
                }
                else
                {
                    if (this.Identity && (DbHelper.CurrentDbType == CurrentDbType.Oracle || DbHelper.CurrentDbType == CurrentDbType.DB2))
                    {
                        BaseSequenceManager sequenceManager = new BaseSequenceManager(DbHelper);
                        //entity.Id = sequenceManager.Increment(this.CurrentTableName);
                        sqlBuilder.SetValue(this.PrimaryKey, entity.Id);
                    }
                }
            }
            this.SetObject(sqlBuilder, entity);
            sqlBuilder.SetDBNow(ZtoUserEntity.FieldCreateOn);
            sqlBuilder.SetDBNow(ZtoUserEntity.FieldModifiedOn);
            if (this.Identity && (DbHelper.CurrentDbType == CurrentDbType.SqlServer || DbHelper.CurrentDbType == CurrentDbType.Access))
            {
                key = sqlBuilder.EndInsert().ToString();
            }
            else
            {
                sqlBuilder.EndInsert();
            }
            if (this.Identity && (DbHelper.CurrentDbType == CurrentDbType.Oracle || DbHelper.CurrentDbType == CurrentDbType.DB2))
            {
                return(entity.Id.ToString());
            }
            return(key);
        }
Example #10
0
        /// <summary>
        /// 更新实体
        /// </summary>
        /// <param name="entity">实体</param>
        public int UpdateObject(ZtoUserEntity entity)
        {
            SQLBuilder sqlBuilder = new SQLBuilder(DbHelper);

            sqlBuilder.BeginUpdate(this.CurrentTableName);
            this.SetObject(sqlBuilder, entity);
            sqlBuilder.SetDBNow(ZtoUserEntity.FieldModifiedOn);
            sqlBuilder.SetWhere(this.PrimaryKey, entity.Id);
            return(sqlBuilder.EndUpdate());
        }
Example #11
0
 void InitReceiveMan(ZtoUserEntity userEntity)
 {
     txtReceiveMan.Text     = userEntity.Realname;
     dgvReceiveArea.Text    = string.Format("{0}-{1}-{2}", userEntity.Province, userEntity.City, userEntity.County);
     txtReceiveAddress.Text = userEntity.Address;
     txtReceivePhone.Text   = userEntity.Mobile + " " + userEntity.TelePhone;
     txtSendCompany.Text    = userEntity.Company;
     txtRemark.Text         = userEntity.Remark;
     txtReceiveAddress_Leave(this, null);
 }
Example #12
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);
 }
Example #13
0
        /// <summary>
        /// 粘贴为收件人
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnPasteReceiveMan_Click(object sender, EventArgs e)
        {
            ZtoUserEntity userEntity = BuildUser(false);

            if (this.Owner != null)
            {
                this.Owner.Tag = userEntity;
            }
            else
            {
                this.Tag = userEntity;
            }
            Close();
        }
Example #14
0
        ZtoUserEntity BuildUser(bool isSendMan)
        {
            ZtoUserEntity userEntity = new ZtoUserEntity();

            userEntity.Realname        = txtRealName.Text.Trim();
            userEntity.Province        = txtProvince.Text;
            userEntity.City            = txtCity.Text;
            userEntity.County          = txtCounty.Text;
            userEntity.Address         = txtAddress.Text;
            userEntity.Company         = txtCompany.Text;
            userEntity.TelePhone       = txtTelephone.Text;
            userEntity.Mobile          = txtMobile.Text.Trim();
            userEntity.Postcode        = txtPostCode.Text.Trim();
            userEntity.IsDefault       = "0";
            userEntity.Issendorreceive = isSendMan ? "1" : "0";
            return(userEntity);
        }
Example #15
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();
     }
 }
Example #16
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();
     }
 }
Example #17
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);
     }
 }
Example #18
0
 /// <summary>
 /// 设置实体
 /// </summary>
 /// <param name="entity">实体</param>
 private void SetObject(SQLBuilder sqlBuilder, ZtoUserEntity entity)
 {
     SetObjectExpand(sqlBuilder, entity);
     sqlBuilder.SetValue(ZtoUserEntity.FieldPostcode, entity.Postcode);
     sqlBuilder.SetValue(ZtoUserEntity.FieldRealname, entity.Realname);
     sqlBuilder.SetValue(ZtoUserEntity.FieldCreateUserName, entity.CreateUserName);
     sqlBuilder.SetValue(ZtoUserEntity.FieldCityId, entity.CityId);
     sqlBuilder.SetValue(ZtoUserEntity.FieldModifiedUserName, entity.ModifiedUserName);
     sqlBuilder.SetValue(ZtoUserEntity.FieldDepartment, entity.Department);
     sqlBuilder.SetValue(ZtoUserEntity.FieldProvince, entity.Province);
     sqlBuilder.SetValue(ZtoUserEntity.FieldCounty, entity.County);
     sqlBuilder.SetValue(ZtoUserEntity.FieldCountyId, entity.CountyId);
     sqlBuilder.SetValue(ZtoUserEntity.FieldRemark, entity.Remark);
     sqlBuilder.SetValue(ZtoUserEntity.FieldProvinceId, entity.ProvinceId);
     sqlBuilder.SetValue(ZtoUserEntity.FieldCity, entity.City);
     sqlBuilder.SetValue(ZtoUserEntity.FieldAddress, entity.Address);
     sqlBuilder.SetValue(ZtoUserEntity.FieldIssendorreceive, entity.Issendorreceive);
     sqlBuilder.SetValue(ZtoUserEntity.FieldTelePhone, entity.TelePhone);
     sqlBuilder.SetValue(ZtoUserEntity.FieldMobile, entity.Mobile);
     sqlBuilder.SetValue(ZtoUserEntity.FieldCompany, entity.Company);
     sqlBuilder.SetValue(ZtoUserEntity.FieldIsDefault, entity.IsDefault);
 }
Example #19
0
        /// <summary>
        /// 获取到选择的收件人实体
        /// </summary>
        /// <param name="gridView"></param>
        /// <returns></returns>
        public List <ZtoUserEntity> GetCheckedUserRecord(GridView gridView)
        {
            var list = new List <ZtoUserEntity>();

            if (gridView.RowCount > 0)
            {
                for (var rowIndex = 0; rowIndex < gridView.RowCount; rowIndex++)
                {
                    var objValue = gridView.GetRowCellValue(rowIndex, gridView.Columns["Check"]);
                    if (objValue == null)
                    {
                        continue;
                    }
                    bool isCheck;
                    bool.TryParse(objValue.ToString(), out isCheck);
                    if (isCheck)
                    {
                        var entity = new ZtoUserEntity
                        {
                            Id         = BaseBusinessLogic.ConvertToDecimal(gridView.GetRowCellValue(rowIndex, "Id").ToString()),
                            Realname   = gridView.GetRowCellValue(rowIndex, "姓名").ToString(),
                            Province   = gridView.GetRowCellValue(rowIndex, "省份").ToString(),
                            City       = gridView.GetRowCellValue(rowIndex, "城市").ToString(),
                            County     = gridView.GetRowCellValue(rowIndex, "区县").ToString(),
                            Address    = gridView.GetRowCellValue(rowIndex, "详细地址").ToString(),
                            Company    = gridView.GetRowCellValue(rowIndex, "单位").ToString(),
                            Department = gridView.GetRowCellValue(rowIndex, "部门").ToString(),
                            TelePhone  = gridView.GetRowCellValue(rowIndex, "电话").ToString(),
                            Mobile     = gridView.GetRowCellValue(rowIndex, "手机").ToString(),
                            Postcode   = gridView.GetRowCellValue(rowIndex, "邮编").ToString()
                        };
                        list.Add(entity);
                    }
                }
            }
            return(list);
        }
Example #20
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);
            }
        }
Example #21
0
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="entity">实体</param>
 public int Update(ZtoUserEntity entity)
 {
     return(this.UpdateObject(entity));
 }
Example #22
0
 // 这个是声明扩展方法
 partial void SetObjectExpand(SQLBuilder sqlBuilder, ZtoUserEntity entity);
 /// <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>
 /// 导入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);
 }
Example #25
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);
        }
Example #26
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);
        }
Example #27
0
 /// <summary>
 /// 添加, 这里可以人工干预,提高程序的性能
 /// </summary>
 /// <param name="entity">实体</param>
 /// <param name="identity">自增量方式,表主键是否采用自增的策略</param>
 /// <param name="returnId">返回主键,不返回程序允许速度会快,主要是为了主细表批量插入数据优化用的</param>
 /// <returns>主键</returns>
 public string Add(ZtoUserEntity entity, bool identity = false, bool returnId = false)
 {
     this.Identity = identity;
     this.ReturnId = returnId;
     return(this.AddObject(entity));
 }