/// <summary> /// 保存本地 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSave_Click(object sender, EventArgs e) { var entity = BuildPrintBillEntity(); if (entity != null) { string result; if (!string.IsNullOrEmpty(SelectedId)) { entity.Id = Convert.ToDecimal(SelectedId); // 更新 result = _printBillManager.Update(entity).ToString(); } else { result = _printBillManager.Add(entity, true); } if (!string.IsNullOrEmpty(result)) { XtraMessageBox.Show(@"保存成功", AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information); if (string.IsNullOrEmpty(SelectedId)) { if (ckKeep.Checked) { ClearText(); } } if (ckGetDefaultSendMan.Checked) { txtReceiveMan.Focus(); txtReceiveMan.Select(); } else { txtSendMan.Focus(); } } else { XtraMessageBox.Show("保存失败", AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
/// <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(); } } }