/// <summary> /// 打印预览 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnPrintView_Click(object sender, EventArgs e) { // 呐喊 491035839这个qq提出来不要重复打印一个单号,这样浪费纸,打印前检查单号有没有打印了,打印了就弹出提醒让用户确认 _list.Clear(); _list.Add(BuildPrintEntity()); if (_list == null || _list.Count == 0) { MessageUtil.ShowWarning("请认真填写好发件人和收件人的姓名、电话、省市区、地址"); return; } ZtoPrintBillManager printBillManager = new ZtoPrintBillManager(BillPrintHelper.BackupDbHelper); var tempResult = printBillManager.Exists(new KeyValuePair <string, object>(ZtoPrintBillEntity.FieldBillCode, txtBillCode.Text)); if (tempResult) { if (MessageUtil.ConfirmYesNo("当前单号已经打印过了,是否再次打印?")) { GreatReport(); _report.PrintPreview(false); } } else { GreatReport(); _report.PrintPreview(false); } }
/// <summary> /// 确定保存新的发件人的 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnOk_Click(object sender, EventArgs e) { if (this.Tag != null) { var sendManEntity = this.Tag as ZtoUserEntity; if (sendManEntity != null) { var printBillManager = new ZtoPrintBillManager(BillPrintHelper.DbHelper); var count = 0; foreach (ZtoPrintBillEntity ztoPrintBillEntity in ZtoPrintBillEntities) { var updateParameters = new List <KeyValuePair <string, object> > { new KeyValuePair <string, object>(ZtoPrintBillEntity.FieldSendMan, sendManEntity.Realname), new KeyValuePair <string, object>(ZtoPrintBillEntity.FieldSendPhone, sendManEntity.Mobile + " " + sendManEntity.TelePhone), new KeyValuePair <string, object>(ZtoPrintBillEntity.FieldSendAddress, sendManEntity.Address), new KeyValuePair <string, object>(ZtoPrintBillEntity.FieldSendProvince, sendManEntity.Province), new KeyValuePair <string, object>(ZtoPrintBillEntity.FieldSendCity, sendManEntity.City), new KeyValuePair <string, object>(ZtoPrintBillEntity.FieldSendCounty, sendManEntity.County), new KeyValuePair <string, object>(ZtoPrintBillEntity.FieldSendCompany, sendManEntity.Company), new KeyValuePair <string, object>(ZtoPrintBillEntity.FieldSendPostcode, sendManEntity.Postcode) }; printBillManager.SetProperty(new KeyValuePair <string, object>(ZtoPrintBillEntity.FieldId, ztoPrintBillEntity.Id), updateParameters); ++count; } if (count > 0) { _isUpdate = true; string content = string.Format("成功更新条{0}记录,已经改成了新发件人:【{1},{2}】", ZtoPrintBillEntities.Count, sendManEntity.Realname, sendManEntity.Mobile); MessageUtil.ShowTips(content); Close(); } } } }
/// <summary> /// 直接打印 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnPrint_Click(object sender, EventArgs e) { if (CheckInput()) { _list.Clear(); _list.Add(BuildPrintEntity()); if (_list == null || _list.Count == 0) { MessageUtil.ShowWarning("请认真填写好发件人和收件人的姓名、电话、省市区、地址"); return; } ZtoPrintBillManager printBillManager = new ZtoPrintBillManager(BillPrintHelper.BackupDbHelper); var tempResult = printBillManager.Exists(new KeyValuePair <string, object>(ZtoPrintBillEntity.FieldBillCode, txtBillCode.Text)); if (tempResult) { if (MessageUtil.ConfirmYesNo("当前单号已经打印过了,是否再次打印?")) { GreatReport(); _report.PrintEx(GRPrintGenerateStyle.grpgsPreviewAll, false); } } else { GreatReport(); _report.PrintEx(GRPrintGenerateStyle.grpgsPreviewAll, false); } } }
/// <summary> /// 打印任务结束 /// </summary> void ReportPrintEnd() { var t = new Task(() => { var frmExportBillImage = new FrmExportBillImage(_list); frmExportBillImage.BuildImage(); }); t.Start(); // 还需要加入备份库(打印历史记录表中,重复的数据打印不要重复创建到历史记录中) var filePath = BillPrintHelper.GetDefaultTemplatePath(); var templateManager = new BaseTemplateManager(BillPrintHelper.DbHelper); var templateList = templateManager.GetList <BaseTemplateEntity>(new KeyValuePair <string, object>(BaseTemplateEntity.FieldFilePath, filePath)); var printBillManager = new ZtoPrintBillManager(BillPrintHelper.BackupDbHelper); var resultCount = printBillManager.AddHistory(_list, templateList.FirstOrDefault()); if (resultCount > 0) { alertPrintInfo.Show(this.ParentForm, "提醒消息", string.Format("打印结束,可以在历史记录中查询打印数据,新增{0}条打印记录。", resultCount)); } else { alertPrintInfo.Show(this.ParentForm, "提醒消息", string.Format("打印结束,新增{0}条打印记录,请检查单号是否都存在,否则不会新增到历史记录中。", resultCount)); } }
/// <summary> /// 刷新界面消息,最后执行导入 /// </summary> /// <param name="id"></param> private void Refresh(object id) { if (!splashScreenManagerImportExcel.IsSplashFormVisible) { splashScreenManagerImportExcel.ShowWaitForm(); } splashScreenManagerImportExcel.SetWaitFormCaption("请稍后......"); splashScreenManagerImportExcel.SetWaitFormDescription(string.Format("导入{0}条,成功:{1},失败:{2}", BillCodeCount, PrintBillEntities.Count, 0)); if (BillCodeCount == BillCodeIndex) { marqueeProgressBarControl1.Properties.Stopped = true; marqueeProgressBarControl1.BeginInvoke(new Action(() => { marqueeProgressBarControl1.Text = "获取结束,开始导入,请稍后..."; })); if (!splashScreenManagerImportExcel.IsSplashFormVisible) { splashScreenManagerImportExcel.ShowWaitForm(); } Application.DoEvents(); splashScreenManagerImportExcel.SetWaitFormCaption("请稍后"); splashScreenManagerImportExcel.SetWaitFormDescription(string.Format("保存{0}条记录到本地.....", PrintBillEntities.Count)); if (PrintBillEntities.Any()) { ZtoPrintBillManager printBillManager = new ZtoPrintBillManager(BillPrintHelper.DbHelper); if (PrintSourceBillList.Count == PrintBillEntities.Count) { PrintBillEntities.Clear(); PrintBillEntities.AddRange(PrintSourceBillList); } foreach (ZtoPrintBillEntity ztoPrintBillEntity in PrintBillEntities) { if (ztoPrintBillEntity != null) { printBillManager.Add(ztoPrintBillEntity, true); } } GridDataBind(); } Thread.Sleep(1500); splashScreenManagerImportExcel.CloseWaitForm(); var ts = DateTime.Now - StartDt; lblTime.Text += string.Format(" 耗时:{0}时{1}分{2}秒{3}毫秒", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds); Close(); } }
/// <summary> /// 保存 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSaveBill_Click(object sender, EventArgs e) { if (this.PrintBillEntities.Any()) { var start = BaseBusinessLogic.ConvertToLong(txtStartBill.Text); var end = BaseBusinessLogic.ConvertToLong(txtEndBill.Text); var count = end - start; if (count.ToString() == cmbPrintBillCount.Text) { for (int i = 0; i < PrintBillEntities.Count; i++) { var billCode = BaseBusinessLogic.ConvertToLong(txtStartBill.Text) + i; PrintBillEntities[i].BillCode = billCode.ToString(); } if (MessageUtil.ConfirmYesNo(string.Format("确定保存{0}条单号吗?", PrintBillEntities.Count))) { using (IDbHelper dbHelper = DbHelperFactory.GetHelper(CurrentDbType.SQLite, BillPrintHelper.BillPrintConnectionString)) { try { dbHelper.BeginTransaction(); var manager = new ZtoPrintBillManager(dbHelper); foreach (var itemBill in PrintBillEntities) { manager.SetProperty(new KeyValuePair <string, object>(ZtoPrintBillEntity.FieldId, itemBill.Id), new KeyValuePair <string, object>(ZtoPrintBillEntity.FieldBillCode, itemBill.BillCode)); } dbHelper.CommitTransaction(); MessageUtil.ShowTips("保存成功"); } catch (Exception ex) { dbHelper.RollbackTransaction(); LogUtil.WriteException(ex); } } } } else { string error = string.Format("需要打印{0},结束单号-开始单号和需要打印数据不相等,不能保存", PrintBillEntities.Count); MessageUtil.ShowError(error); } } }
private ZtoPrintBillEntity BuildPrintEntity() { //构建实体 ZtoPrintBillEntity printBillEntity = new ZtoPrintBillEntity(); if (!string.IsNullOrEmpty(PrintBillId)) { printBillEntity = new ZtoPrintBillManager(BillPrintHelper.DbHelper).GetObject(PrintBillId); } printBillEntity.SendMan = txtSendMan.Text; printBillEntity.SendPhone = txtSendPhone.Text; printBillEntity.SendCompany = txtSendCompany.Text; printBillEntity.SendAddress = txtSendAddress.Text; printBillEntity.SendDate = string.IsNullOrEmpty(txtSendDate.Text) ? DateTime.Now.ToString(BaseSystemInfo.DateFormat) : txtSendDate.Text; if (!string.IsNullOrEmpty(dgvSendArea.Text)) { var sendAreaArray = dgvSendArea.Text.Split('-'); printBillEntity.SendProvince = sendAreaArray[0]; printBillEntity.SendCity = sendAreaArray[1]; printBillEntity.SendCounty = sendAreaArray[2]; } printBillEntity.ReceiveMan = txtReceiveMan.Text; printBillEntity.ReceivePhone = txtReceivePhone.Text; printBillEntity.ReceiveCompany = txtReceiveCompany.Text; printBillEntity.ReceiveAddress = txtReceiveAddress.Text; if (!string.IsNullOrEmpty(dgvReceiveArea.Text)) { var receiveAreaArray = dgvReceiveArea.Text.Split('-'); printBillEntity.ReceiveProvince = receiveAreaArray[0]; printBillEntity.ReceiveCity = receiveAreaArray[1]; printBillEntity.ReceiveCounty = receiveAreaArray[2]; } printBillEntity.GoodsName = cmbGoodsName.Text; printBillEntity.Weight = txtGoodsWeight.Text; printBillEntity.GOODS_PAYMENT = string.IsNullOrEmpty(txtGoodsPayment.Text) ? 0 : decimal.Parse(txtGoodsPayment.Text); printBillEntity.TOPAYMENT = string.IsNullOrEmpty(txtToPayMent.Text) ? 0 : decimal.Parse(txtToPayMent.Text); printBillEntity.Remark = txtRemark.Text; printBillEntity.BigPen = txtBigPen.Text; // 2016年6月18日11:19:58 杨恒连加上 printBillEntity.OrderNumber = txtOrderNumber.Text; printBillEntity.BillCode = txtBillCode.Text; return(printBillEntity); }
/// <summary> /// 更新大头笔和单号 /// </summary> /// <param name="list"></param> /// <returns></returns> public static int UpdateBillCodeAndBigPen(List <ZtoPrintBillEntity> list) { int result = 0; var printBillManager = new ZtoPrintBillManager(BillPrintHelper.DbHelper); foreach (var billEntity in list) { // 进行更新选中记录的(收件)省市区(包括省市区的ID) var updateParameters = new List <KeyValuePair <string, object> > { new KeyValuePair <string, object>(ZtoPrintBillEntity.FieldBigPen, billEntity.BigPen), new KeyValuePair <string, object>(ZtoPrintBillEntity.FieldOrderNumber, billEntity.OrderNumber), new KeyValuePair <string, object>(ZtoPrintBillEntity.FieldBillCode, billEntity.BillCode), new KeyValuePair <string, object>(ZtoPrintBillEntity.FieldModifiedOn, DateTime.Now) }; var whereParameters = new List <KeyValuePair <string, object> > { new KeyValuePair <string, object>(ZtoPrintBillEntity.FieldId, billEntity.Id) }; var tempResult = printBillManager.SetProperty(whereParameters, updateParameters); result += tempResult; } return(result); }
/// <summary> /// 保存本地 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSave_Click(object sender, EventArgs e) { if (_list.Any()) { var printBillEntities = new List <ZtoPrintBillEntity>(); foreach (ZtoPrintBillEntity ztoPrintBillEntity in _list) { ztoPrintBillEntity.OrderNumber = ""; ztoPrintBillEntity.BillCode = ""; printBillEntities.Add(ztoPrintBillEntity); } var printAddEntities = new List <ZtoPrintBillEntity>(); for (int i = 0; i < int.Parse(cmbPrintNumber.Text); i++) { printAddEntities.AddRange(printBillEntities); } if (printAddEntities.Any()) { var ztoPrintBillManager = new ZtoPrintBillManager(BillPrintHelper.DbHelper); if (!IsAddToPrintData) { ztoPrintBillManager.DbHelper = BillPrintHelper.BackupDbHelper; } int result = 0; foreach (ZtoPrintBillEntity ztoPrintBillEntity in printAddEntities) { ztoPrintBillEntity.OrderNumber = Guid.NewGuid().ToString("N").ToLower(); ztoPrintBillManager.Add(ztoPrintBillEntity, true); ++result; } _isAdd = result > 0; MessageBox.Show(string.Format("新增成功{0}条记录", result), DotNet.Utilities.AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
/// <summary> /// 保存本地 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSaveBill_Click(object sender, EventArgs e) { //构建实体 ZtoPrintBillEntity printBillEntity = BuildPrintEntity(); //if (!string.IsNullOrEmpty(PrintBillId)) //{ // printBillEntity = new ZtoPrintBillManager(BillPrintHelper.DbHelper).GetObject(PrintBillId); //} //printBillEntity.SendMan = txtSendMan.Text; //printBillEntity.SendPhone = txtSendPhone.Text; //printBillEntity.SendCompany = txtSendCompany.Text; //printBillEntity.SendAddress = txtSendAddress.Text; //printBillEntity.SendDate = string.IsNullOrEmpty(txtSendDate.Text) ? DateTime.Now.ToString(BaseSystemInfo.DateFormat) : txtSendDate.Text; //if (!string.IsNullOrEmpty(dgvSendArea.Text)) //{ // var sendAreaArray = dgvSendArea.Text.Split('-'); // printBillEntity.SendProvince = sendAreaArray[0]; // printBillEntity.SendCity = sendAreaArray[1]; // printBillEntity.SendCounty = sendAreaArray[2]; //} //printBillEntity.ReceiveMan = txtReceiveMan.Text; //printBillEntity.ReceivePhone = txtReceivePhone.Text; //printBillEntity.ReceiveCompany = txtReceiveCompany.Text; //printBillEntity.ReceiveAddress = txtReceiveAddress.Text; //if (!string.IsNullOrEmpty(dgvReceiveArea.Text)) //{ // var receiveAreaArray = dgvReceiveArea.Text.Split('-'); // printBillEntity.ReceiveProvince = receiveAreaArray[0]; // printBillEntity.ReceiveCity = receiveAreaArray[1]; // printBillEntity.ReceiveCounty = receiveAreaArray[2]; //} //printBillEntity.GoodsName = cmbGoodsName.Text; //printBillEntity.Weight = txtGoodsWeight.Text; //printBillEntity.GOODS_PAYMENT = string.IsNullOrEmpty(txtGoodsPayment.Text) ? 0 : decimal.Parse(txtGoodsPayment.Text); //printBillEntity.TOPAYMENT = string.IsNullOrEmpty(txtToPayMent.Text) ? 0 : decimal.Parse(txtToPayMent.Text); //printBillEntity.Remark = txtRemark.Text; //printBillEntity.BigPen = txtBigPen.Text; var ztoPrintBillManager = new ZtoPrintBillManager(BillPrintHelper.DbHelper); // 表示更新 if (!string.IsNullOrEmpty(PrintBillId)) { printBillEntity.Id = BaseBusinessLogic.ConvertToDecimal(PrintBillId); ztoPrintBillManager.Update(printBillEntity); XtraMessageBox.Show("更新成功", AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { _list.Clear(); var saveCount = int.Parse(cmbPrintNumber.Text); if (saveCount == 0) { cmbPrintNumber.Text = "1"; saveCount = 1; } // 这里要有订单号可以输入,不能系统生成,这样不科学,2016年6月15日22:33:11,杨恒连 // 如果他大于1条的话,后面的订单号要系统生成了 // 最好检查这个订单号有么有重复使用,重复使用就不好了,这样获取到用过的单号是要罚款的 if (!string.IsNullOrEmpty(txtOrderNumber.Text)) { saveCount = saveCount - 1; printBillEntity.OrderNumber = txtOrderNumber.Text; ztoPrintBillManager.Add(printBillEntity, true); _list.Add(printBillEntity); } for (int i = 0; i < saveCount; i++) { printBillEntity.OrderNumber = Guid.NewGuid().ToString("N").ToLower(); ztoPrintBillManager.Add(printBillEntity, true); _list.Add(printBillEntity); } XtraMessageBox.Show(string.Format("新增成功{0}条记录", cmbPrintNumber.Text), AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information); } }
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(@"请选择录单模板", 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); }
/// <summary> /// 获取申通电子面单 /// </summary> /// <param name="ztoPrintBillEntities">打印实体泛型集合</param> /// <param name="ztoElecUserInfoEntity">电子面单线下商家ID实体信息</param> /// <returns></returns> public static List <ZtoPrintBillEntity> BindElecBillByCustomerId(List <ZtoPrintBillEntity> ztoPrintBillEntities, ZtoElecUserInfoEntity ztoElecUserInfoEntity) { var errorList = new List <object>(); // 全部生成订单号,然后重复获取都没关系了不怕 var printBillManager = new ZtoPrintBillManager(BillPrintHelper.DbHelper); foreach (var ztoPrintBillEntity in ztoPrintBillEntities) { // 订单号 特殊处理,如果没有填写需要生成一个唯一订单号给接口 if (string.IsNullOrEmpty(ztoPrintBillEntity.OrderNumber)) { var orderNumber = Guid.NewGuid().ToString("N").ToLower(); ztoPrintBillEntity.OrderNumber = orderNumber; var updateParameters = new List <KeyValuePair <string, object> > { new KeyValuePair <string, object>(ZtoPrintBillEntity.FieldOrderNumber, ztoPrintBillEntity.OrderNumber), new KeyValuePair <string, object>(ZtoPrintBillEntity.FieldModifiedOn, DateTime.Now) }; var whereParameters = new List <KeyValuePair <string, object> > { new KeyValuePair <string, object>(ZtoPrintBillEntity.FieldId, ztoPrintBillEntity.Id) }; printBillManager.SetProperty(whereParameters, updateParameters); } } // 需要提交接口次数 var submitCount = Math.Ceiling(ztoPrintBillEntities.Count / 10.0); // 如果提交的记录数超过10条,需要分几批提交接口,10条一次最好,防止接口挂了 if (submitCount > 1) { var list = new List <ZtoPrintBillEntity>(); for (int i = 0; i < submitCount; i++) { List <ZtoPrintBillEntity> t = ztoPrintBillEntities.Skip(10 * i).Take(10).ToList(); List <ZtoPrintBillEntity> tempList = Request(t, ztoElecUserInfoEntity, ref errorList); if (tempList == null) { if (list.Any()) { return(list); } return(null); } list.AddRange(tempList); } if (errorList.Any()) { var frmImportError = new FrmImportError() { errorList = errorList }; frmImportError.ShowDialog(); } return(list); } // 提交一次接口就可以了 var resultList = Request(ztoPrintBillEntities, ztoElecUserInfoEntity, ref errorList); if (errorList.Any()) { var frmImportError = new FrmImportError() { errorList = errorList }; frmImportError.ShowDialog(); } return(resultList); }
/// <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="ztoPrintBillEntities"></param> /// <param name="ztoElecUserInfoEntity"></param> /// <returns></returns> public static List <ZtoPrintBillEntity> Request(List <ZtoPrintBillEntity> ztoPrintBillEntities, ZtoElecUserInfoEntity ztoElecUserInfoEntity) { // http://testpartner.zto.cn/ 接口文档 List <ZtoOrderBatchEntity> orderBatchEntities = new List <ZtoOrderBatchEntity>(); // {"id":"778718821067/10/9","type":"","tradeid":"","mailno":"","seller":"王先生","buyer":"深圳机场vip","sender":{"id":"","name":"1000043696","company":"75578","mobile":null,"phone":"13726273582","area":"","city":"广东省,深圳市,宝安区","address":"广东省深圳市宝安区沙井街道","zipcode":"","email":"","im":"","starttime":"","endtime":"","isremark":"true"},"receiver":{"id":"","name":"陈小姐","company":"","mobile":"0755-27263516","phone":"0755-27263516","area":"","city":"广东省,深圳市,宝安区","address":"沙井街道南环路马鞍山耗三工业区第三栋(凯强电子)","zipcode":"","email":"","im":""},"items":null} ZtoPrintBillManager printBillManager = new ZtoPrintBillManager(BillPrintHelper.DbHelper); foreach (var ztoPrintEntity in ztoPrintBillEntities) { ZtoOrderBatchEntity orderBatchEntity = new ZtoOrderBatchEntity(); // 订单号 特殊处理,如果没有填写需要生成一个唯一订单号给接口 if (!string.IsNullOrEmpty(ztoPrintEntity.OrderNumber)) { orderBatchEntity.Id = ztoPrintEntity.OrderNumber; } else { orderBatchEntity.Id = Guid.NewGuid().ToString("N").ToLower(); ztoPrintEntity.OrderNumber = orderBatchEntity.Id; printBillManager.SetProperty(ztoPrintEntity.OrderNumber, new KeyValuePair <string, object>(ZtoPrintBillEntity.FieldId, ztoPrintEntity.Id)); } ztoPrintEntity.CreateSite = orderBatchEntity.Id; orderBatchEntity.Seller = ztoPrintEntity.SendMan; orderBatchEntity.Buyer = ztoPrintEntity.ReceiveMan; Sender sender1 = new Sender { Name = ztoPrintEntity.SendMan, Mobile = ztoPrintEntity.SendPhone, Phone = ztoPrintEntity.SendPhone, City = string.Format("{0},{1},{2}", ztoPrintEntity.SendProvince, ztoPrintEntity.SendCity, ztoPrintEntity.SendCounty), Address = ztoPrintEntity.SendAddress, Isremark = "true" }; Receiver receiver = new Receiver { Name = ztoPrintEntity.ReceiveMan, Phone = ztoPrintEntity.ReceivePhone, Mobile = ztoPrintEntity.ReceivePhone, City = string.Format("{0},{1},{2}", ztoPrintEntity.ReceiveProvince, ztoPrintEntity.ReceiveCity, ztoPrintEntity.ReceiveCounty), Address = ztoPrintEntity.ReceiveAddress }; orderBatchEntity.Sender = sender1; orderBatchEntity.Receiver = receiver; orderBatchEntities.Add(orderBatchEntity); } // 实体构建完成了,下面开始请求动作 string content = SecretUtil.EncodeBase64("UTF-8", JsonConvert.SerializeObject(orderBatchEntities).ToLower()); // 正式地址 http://partner.zto.cn//client/interface.php // 测试地址 http://testpartner.zto.cn/client/interface.php WebClient webClient = new WebClient(); string date = DateTime.Now.ToString(BaseSystemInfo.DateTimeFormat); NameValueCollection postValues = new NameValueCollection { { "style", "json" }, { "func", "order.batch_submit" }, { "content", content }, { "partner", ztoElecUserInfoEntity.Kehuid }, { "datetime", date }, { "verify", System.Web.HttpUtility.UrlEncode(SecretUtil.md5(ztoElecUserInfoEntity.Kehuid + date + content + ztoElecUserInfoEntity.Pwd).ToLower()) } }; byte[] responseArray = webClient.UploadValues("http://partner.zto.cn//client/interface.php", postValues); string response = Encoding.UTF8.GetString(responseArray); if (response.Contains("s51") || response.Contains("可用单号不足")) { XtraMessageBox.Show("可用单号不足,请在中通物料系统购买电子面单,点击确定跳转到物料系统。", AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information); ToolHelper.OpenIe("https://sso.zt-express.com/?SystemCode=WULIAO&openId=false"); return(null); } // {"result": "true","keys": [{"result":"true","id": "ztaa6c6dc3db3044b2b78844b73ec2013e","orderid": "ztaa6c6dc3db3044b2b78844b73ec2013e","mailno": "530253938633","mark":"长沙转常德","sitecode":"61201","sitename":"苏州园区六部"}]} ZtoOrderBatchResponseEntity orderBatchResponseEntity = JsonConvert.DeserializeObject <ZtoOrderBatchResponseEntity>(response); if (orderBatchResponseEntity != null) { // 绑定大头笔和单号 if (orderBatchResponseEntity.Result.ToUpper() == "TRUE") { List <ZtoPrintBillEntity> backZtoPrintBillEntities = new List <ZtoPrintBillEntity>(); foreach (ZtoPrintBillEntity ztoPrintBillEntity in ztoPrintBillEntities) { foreach (var keyse in orderBatchResponseEntity.Keys) { if (keyse.Id == ztoPrintBillEntity.OrderNumber) { ztoPrintBillEntity.BigPen = keyse.Mark; ztoPrintBillEntity.BillCode = keyse.Mailno; backZtoPrintBillEntities.Add(ztoPrintBillEntity); break; } } } return(backZtoPrintBillEntities); } ZtoCustomerErrorEntity customerErrorEntity = JsonConvert.DeserializeObject <ZtoCustomerErrorEntity>(response); if (customerErrorEntity != null) { XtraMessageBox.Show(customerErrorEntity.Keys + customerErrorEntity.Remark + Environment.NewLine + "请在确认默认发件人的商家ID和密码是否正确。", AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { XtraMessageBox.Show(response, AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { XtraMessageBox.Show(response, AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information); } return(null); }
/// <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); }