/// <summary> /// 加载默认发件人 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ckGetDefaultSendMan_CheckedChanged(object sender, EventArgs e) { if (ckGetDefaultSendMan.Checked) { // 加载默认发件人 ZtoUserManager userManager = new ZtoUserManager(BillPrintHelper.DbHelper); var userList = userManager.GetList <ZtoUserEntity>(new KeyValuePair <string, object>(ZtoUserEntity.FieldIsDefault, 1), new KeyValuePair <string, object>(ZtoUserEntity.FieldIssendorreceive, 1)); if (userList.Any()) { var userEntity = userList.First(); txtSendMan.Text = userEntity.Realname; dgvSendArea.Text = string.Format("{0}-{1}-{2}", userEntity.Province, userEntity.City, userEntity.County); txtSendAddress.Text = userEntity.Address; txtSendPhone.Text = userEntity.Mobile + " " + userEntity.TelePhone; txtSendCompany.Text = userEntity.Company; txtReceiveMan.Focus(); txtReceiveMan.Select(); BillPrintHelper.SetLoadDefaultSendMan(); } else { if (XtraMessageBox.Show(@"未添加默认发件人信息,是否添加?", AppMessage.MSG0000, MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { FrmAddSendMan addSendMan = new FrmAddSendMan(); addSendMan.ShowDialog(); addSendMan.Dispose(); } } } else { BillPrintHelper.SetLoadDefaultSendMan(false); } }
/// <summary> /// 更新收件人 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnEditSendMan_Click(object sender, EventArgs e) { var list = GetCheckedUserRecord(gvReceiveMan); if (list.Any()) { if (list.Count > 1) { XtraMessageBox.Show(@"请勿选择多条收件人记录。", AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } FrmAddSendMan frmSendMan = new FrmAddSendMan { Id = list.First().Id.ToString(), IsReceiveForm = true }; if (frmSendMan.ShowDialog() == DialogResult.OK) { ReceiveManDataBind(); } frmSendMan.Dispose(); } else { XtraMessageBox.Show(@"请添加收件人数据。", AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// 新增发件人 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAddSendMan_Click(object sender, EventArgs e) { FrmAddSendMan frmSendMan = new FrmAddSendMan(); frmSendMan.IsReceiveForm = false; if (frmSendMan.ShowDialog() == DialogResult.OK) { SendManDataBind(); } frmSendMan.Dispose(); }
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> /// 打印多份 /// </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); } }