/// <summary> /// 插入支付明细表 /// </summary> /// <param name="invoices"></param> /// <returns></returns> private int InsertInvocePayMode(ArrayList invoices, DateTime feeTime, string operID, string invoiceUnion, ref string errText) { foreach (Balance b in invoices) { Neusoft.HISFC.Models.Fee.Outpatient.BalancePay payMod = new BalancePay(); payMod.Invoice = b.Invoice; payMod.PayType.ID = "YS"; payMod.CancelType = Neusoft.HISFC.Models.Base.CancelTypes.Valid; payMod.Squence = "1"; payMod.TransType = Neusoft.HISFC.Models.Base.TransTypes.Positive; payMod.IsDayBalanced = false; payMod.IsAuditing = false; payMod.IsChecked = false; payMod.InputOper.ID = operID; payMod.InputOper.OperTime = feeTime; payMod.FT.RealCost = b.FT.TotCost; payMod.FT.ReturnCost = 0; payMod.FT.TotCost = b.FT.TotCost; payMod.InvoiceCombNO = b.CombNO; payMod.InvoiceUnion = invoiceUnion; if (outpatientManager.InsertBalancePay(payMod) < 0) { errText = "插入支付方式信息失败!" + outpatientManager.Err; return(-1); } if (!listPay.ContainsKey(b.Patient.ID)) { ArrayList al = new ArrayList(); listPay.Add(b.Patient.ID, al); } listPay[b.Patient.ID].Add(payMod); } return(1); }
/// <summary> /// 获得更改后的支付方式 /// </summary> public void GetNewPayMode() { this.modfiedPayModes = new ArrayList(); for (int i = 0; i < this.fpSpead1_Sheet1.RowCount; i++) { if (this.fpSpead1_Sheet1.Rows[i].Tag != null) { if (this.fpSpead1_Sheet1.Rows[i].Tag is BalancePay) { BalancePay p = this.fpSpead1_Sheet1.Rows[i].Tag as BalancePay; p.PayType.ID = helpPayMode.GetID(this.fpSpead1_Sheet1.Cells[i, 2].Text); modfiedPayModes.Add(p); } } } }
/// <summary> /// 初始化冲帐支付方式列表 /// </summary> /// <returns>-1 失败 0 成功</returns> public int InitQuitPayModes() { if (quitPayModes == null) { return(-1); } lbQuitPayMode.AddItems(payModes); Controls.Add(lbQuitPayMode); lbQuitPayMode.Hide(); lbQuitPayMode.BorderStyle = BorderStyle.FixedSingle; lbQuitPayMode.BringToFront(); lbQuitPayMode.SelectItem += new Neusoft.FrameWork.WinForms.Controls.PopUpListBox.MyDelegate(lbQuitPayMode_SelectItem); BalancePay pTempMode = null; this.fpSpead1_Sheet1.RowCount = quitPayModes.Count; for (int i = 0; i < quitPayModes.Count; i++) { pTempMode = quitPayModes[i] as BalancePay; this.fpSpead1_Sheet1.Cells[i, 0].Text = helpPayMode.GetName(pTempMode.PayType.ID.ToString()); this.fpSpead1_Sheet1.Cells[i, 2].Text = helpPayMode.GetName(pTempMode.PayType.ID.ToString()); //现金必须现金冲帐,不允许修改成其他支付方式 //if (pTempMode.PayType.ID.ToString() == "CA") //{ // this.fpSpead1_Sheet1.Cells[i, 2].Locked = true; //} this.fpSpead1_Sheet1.Cells[i, 1].Text = pTempMode.FT.RealCost.ToString(); this.fpSpead1_Sheet1.Rows[i].Tag = pTempMode; this.fpSpead1_Sheet1.Cells[i, 0].Locked = true; this.fpSpead1_Sheet1.Cells[i, 1].Locked = true; } this.fpSpead1.Focus(); //找到第一个可以修改的支付方式,获得焦点 for (int i = 0; i < quitPayModes.Count; i++) { if (this.fpSpead1_Sheet1.Cells[i, 2].Locked == false) { this.fpSpead1_Sheet1.SetActiveCell(i, 2, false); return(1); } } return(1); }
public CommonPayModel(BalancePay model) { this.ParentId = model.BalanceId; this.BalanceId = model.BalanceId; this.OriginalPrice = model.OriginalPrice; this.BalancePrice = model.BalancePrice; this.RemovePrice = model.RemovePrice; this.Price = model.Price; this.AddTime = model.AddTime; this.Remark = model.Remark; this.Type = "BalancePay"; this.PayId = model.BalancePayId; this.TransferId = model.TransferId; }
public BalancePay GetBalancePay() { BalancePay model = new BalancePay(); model.BalancePayId = PayId; model.BalanceId = BalanceId ?? 0; model.BalancePrice = BalancePrice; model.OriginalPrice = OriginalPrice; model.RemovePrice = RemovePrice; model.Price = Price; model.AddTime = AddTime; model.Remark = Remark; model.TransferId = TransferId; return(model); }
/// <summary> /// 清除引用 /// </summary> /// <param name="model"></param> public static void ClearReferences(this BalancePay model) { model.tb_device = null; model.tb_admin = null; model.tb_balance = null; }
/// <summary> /// 保存 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void krpbSave_Click(object sender, EventArgs e) { double price = double.Parse(krptChangePrice.Text); if (price <= 0) { return; } string newBalanceName = krpcbNewBalanceName.SelectedItem.ToString(); if (Resources.GetRes().MainLangIndex == 0) { NewBalance = Resources.GetRes().Balances.Where(x => x.BalanceName0 == newBalanceName).FirstOrDefault(); } else if (Resources.GetRes().MainLangIndex == 1) { NewBalance = Resources.GetRes().Balances.Where(x => x.BalanceName1 == newBalanceName).FirstOrDefault(); } else if (Resources.GetRes().MainLangIndex == 2) { NewBalance = Resources.GetRes().Balances.Where(x => x.BalanceName2 == newBalanceName).FirstOrDefault(); } BalancePay balancePay1 = new BalancePay(); balancePay1.BalanceId = NewBalance.BalanceId; balancePay1.Price = price; BalancePay balancePay2 = new BalancePay(); balancePay2.BalanceId = OldBalance.BalanceId; balancePay2.Price = -price; StartLoad(this, null); Task.Factory.StartNew(() => { ResultModel result = new ResultModel(); try { BalancePay newBalancePay1; BalancePay newBalancePay2; Balance newBalance1; Balance newBalance2; result = OperatesService.GetOperates().ServiceTransferBalancePay(balancePay1, balancePay2, out newBalancePay1, out newBalance1, out newBalancePay2, out newBalance2); this.BeginInvoke(new Action(() => { if (result.Result) { KryptonMessageBox.Show(this, Resources.GetRes().GetString("SaveSuccess"), Resources.GetRes().GetString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information); ReturnValue = true; this.Close(); } else { if (result.IsDataHasRefrence) { KryptonMessageBox.Show(this, Resources.GetRes().GetString("PropertyUsed"), Resources.GetRes().GetString("Warn"), MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (result.UpdateModel) { KryptonMessageBox.Show(this, Resources.GetRes().GetString("PropertyUnSame"), Resources.GetRes().GetString("Warn"), MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { KryptonMessageBox.Show(this, Resources.GetRes().GetString("SaveFailt"), Resources.GetRes().GetString("Warn"), MessageBoxButtons.OK, MessageBoxIcon.Warning); } } })); } catch (Exception ex) { this.BeginInvoke(new Action(() => { ExceptionPro.ExpLog(ex, new Action <string>((message) => { KryptonMessageBox.Show(this, message, Resources.GetRes().GetString("Warn"), MessageBoxButtons.OK, MessageBoxIcon.Warning); }), false, Resources.GetRes().GetString("SaveFailt")); })); } StopLoad(this, null); }); }
/// <summary> /// 删除数据 /// </summary> private void Delete() { long Id = -1; try { //确认删除 var confirm = KryptonMessageBox.Show(this, Resources.GetRes().GetString("SureDelete"), Resources.GetRes().GetString("Warn"), MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (confirm != DialogResult.Yes) { return; } Id = long.Parse(krpdgList.SelectedRows[0].Cells["krpcmBalancePayId"].Value.ToString()); //如果是没添加过的记录,就直接删除 if (Id == -1) { KryptonMessageBox.Show(this, Resources.GetRes().GetString("DeleteSuccess"), Resources.GetRes().GetString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information); krpdgList.Rows.Remove(krpdgList.SelectedRows[0]); return; } } catch (Exception ex) { ExceptionPro.ExpLog(ex, new Action <string>((message) => { KryptonMessageBox.Show(this, message, Resources.GetRes().GetString("Warn"), MessageBoxButtons.OK, MessageBoxIcon.Warning); }), false, Resources.GetRes().GetString("DeleteFailt")); return; } StartLoad(this, null); Task.Factory.StartNew(() => { BalancePay balancePay = resultList.Where(x => x.BalanceId == Id).FirstOrDefault(); ResultModel result = new ResultModel(); try { result = OperatesService.GetOperates().ServiceDelBalancePay(balancePay); this.BeginInvoke(new Action(() => { if (result.Result) { KryptonMessageBox.Show(this, Resources.GetRes().GetString("DeleteSuccess"), Resources.GetRes().GetString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information); BalancePay oldModel = resultList.Where(x => x.BalancePayId == Id).FirstOrDefault(); krpdgList.Rows.Remove(krpdgList.SelectedRows[0]); resultList.Remove(oldModel); CommonPayModel oldCommonModel = this.commonPayList.Where(x => x.PayId == Id && x.Type == "BalancePay").FirstOrDefault(); commonPayList.Remove(oldCommonModel); } else { if (result.IsDataHasRefrence) { KryptonMessageBox.Show(this, Resources.GetRes().GetString("PropertyUsed"), Resources.GetRes().GetString("Warn"), MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (result.UpdateModel) { KryptonMessageBox.Show(this, Resources.GetRes().GetString("PropertyUnSame"), Resources.GetRes().GetString("Warn"), MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { KryptonMessageBox.Show(this, Resources.GetRes().GetString("DeleteFailt"), Resources.GetRes().GetString("Warn"), MessageBoxButtons.OK, MessageBoxIcon.Warning); } } })); } catch (Exception ex) { this.BeginInvoke(new Action(() => { ExceptionPro.ExpLog(ex, new Action <string>((message) => { KryptonMessageBox.Show(this, message, Resources.GetRes().GetString("Warn"), MessageBoxButtons.OK, MessageBoxIcon.Warning); }), false, Resources.GetRes().GetString("DeleteFailt")); })); } StopLoad(this, null); }); }
/// <summary> /// 保存新增或改动的数据 /// </summary> private void Save() { if (null != krpdgList.SelectedRows[0]) { //如果是插入 if (krpdgList.SelectedRows[0].Cells["krpcmBalancePayId"].Value.ToString().Equals("-1")) { BalancePay balancePay = new BalancePay(); try { balancePay.BalancePayId = long.Parse(krpdgList.SelectedRows[0].Cells["krpcmBalancePayId"].Value.ToString()); balancePay.Price = Math.Round(double.Parse(krpdgList.SelectedRows[0].Cells["krpcmPrice"].Value.ToString()), 2); balancePay.Remark = GetValueOrNull(krpdgList.SelectedRows[0].Cells["krpcmRemark"].Value.ToString()); balancePay.BalanceId = balance.BalanceId; } catch (Exception ex) { ExceptionPro.ExpLog(ex, new Action <string>((message) => { KryptonMessageBox.Show(this, message, Resources.GetRes().GetString("Warn"), MessageBoxButtons.OK, MessageBoxIcon.Warning); }), false, Resources.GetRes().GetString("SaveFailt")); return; } StartLoad(this, null); Task.Factory.StartNew(() => { ResultModel result = new ResultModel(); try { BalancePay newBalancePay; Balance balance; result = OperatesService.GetOperates().ServiceAddBalancePay(balancePay, out newBalancePay, out balance); this.BeginInvoke(new Action(() => { if (result.Result) { KryptonMessageBox.Show(this, Resources.GetRes().GetString("SaveSuccess"), Resources.GetRes().GetString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information); krpdgList.SelectedRows[0].Cells["krpcmBalancePayId"].Value = newBalancePay.BalancePayId; krpdgList.SelectedRows[0].Cells["krpcmEdit"].Value = ""; krpdgList.SelectedRows[0].Cells["krpcmAddTime"].Value = DateTime.ParseExact(newBalancePay.AddTime.ToString(), "yyyyMMddHHmmss", System.Globalization.CultureInfo.InvariantCulture).ToString("yyyy-MM-dd HH:mm"); this.balance = balance; this.ReturnValue = balance; this.resultList.Insert(0, newBalancePay); this.commonPayList.Insert(0, new CommonPayModel(newBalancePay)); krpdgList.SelectedRows[0].Cells["krpcmPrice"].ReadOnly = true; krpdgList.SelectedRows[0].Cells["krpcmBalanceType"].ReadOnly = true; krpdgList.SelectedRows[0].Cells["krpcmRemark"].ReadOnly = true; krptbEndTime.Text = DateTime.Now.AddMinutes(5).ToString("yyyyMMddHHmm"); } else { if (result.IsDataHasRefrence) { KryptonMessageBox.Show(this, Resources.GetRes().GetString("PropertyUsed"), Resources.GetRes().GetString("Warn"), MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (result.UpdateModel) { KryptonMessageBox.Show(this, Resources.GetRes().GetString("PropertyUnSame"), Resources.GetRes().GetString("Warn"), MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { KryptonMessageBox.Show(this, Resources.GetRes().GetString("SaveFailt"), Resources.GetRes().GetString("Warn"), MessageBoxButtons.OK, MessageBoxIcon.Warning); } } })); } catch (Exception ex) { this.BeginInvoke(new Action(() => { ExceptionPro.ExpLog(ex, new Action <string>((message) => { KryptonMessageBox.Show(this, message, Resources.GetRes().GetString("Warn"), MessageBoxButtons.OK, MessageBoxIcon.Warning); }), false, Resources.GetRes().GetString("SaveFailt")); })); } StopLoad(this, null); }); } //如果是编辑 else { // 没有编辑, 也不能编辑 } } }
/// <summary> /// 转账 /// </summary> private void TransferBalance(double price) { //确认 QueueMessageBoxNotification.Instance.ActionMessageBox(null, null, CommandTitles.Instance.Warn, string.Format(Resources.Instance.GetString("ConfirmOperate"), Resources.Instance.GetString("Change")), MessageBoxMode.Dialog, MessageBoxImageMode.Question, MessageBoxButtonMode.YesNo, async(string msg) => { if (msg == "NO") { return; } BalancePay balancePay1 = new BalancePay(); balancePay1.BalanceId = (SelectedNewBalance.Value as Balance).BalanceId; balancePay1.Price = price; if (!string.IsNullOrWhiteSpace(Remark)) { balancePay1.Remark = Remark; } BalancePay balancePay2 = new BalancePay(); balancePay2.BalanceId = (SelectedOldBalance.Value as Balance).BalanceId; balancePay2.Price = -price; if (!string.IsNullOrWhiteSpace(Remark)) { balancePay2.Remark = Remark; } IsLoading = true; try { var taskResult = await OperatesService.Instance.ServiceTransferBalancePay(balancePay1, balancePay2); ResultModel result = taskResult.resultModel; BalancePay newBalancePay1 = taskResult.newBalancePay1; BalancePay newBalancePay2 = taskResult.newBalancePay2; Balance newBalance1 = taskResult.newBalance1; Balance newBalance2 = taskResult.newBalance2; if (result.Result) { await Refresh(); QueueMessageBoxNotification.Instance.ActionMessageBox(null, null, CommandTitles.Instance.Information, string.Format(Resources.Instance.GetString("OperateSuccess"), Resources.Instance.GetString("Change")), MessageBoxMode.Dialog, MessageBoxImageMode.Information, MessageBoxButtonMode.OK, msg2 => { Init(false); }, null); } else { if (result.IsDataHasRefrence) { QueueMessageBoxNotification.Instance.ActionMessageBox(null, null, CommandTitles.Instance.Error, Resources.Instance.GetString("PropertyUsed"), MessageBoxMode.Dialog, MessageBoxImageMode.Warn, MessageBoxButtonMode.OK, null, null); } else if (result.UpdateModel) { QueueMessageBoxNotification.Instance.ActionMessageBox(null, null, CommandTitles.Instance.Error, Resources.Instance.GetString("PropertyUnSame"), MessageBoxMode.Dialog, MessageBoxImageMode.Warn, MessageBoxButtonMode.OK, null, null); } else { QueueMessageBoxNotification.Instance.ActionMessageBox(null, null, CommandTitles.Instance.Error, Resources.Instance.GetString("SaveFailt"), MessageBoxMode.Dialog, MessageBoxImageMode.Warn, MessageBoxButtonMode.OK, null, null); } } } catch (Exception ex) { ExceptionPro.ExpLog(ex, new Action <string>((message) => { QueueMessageBoxNotification.Instance.ActionMessageBox(null, null, CommandTitles.Instance.Error, message, MessageBoxMode.Dialog, MessageBoxImageMode.Error, MessageBoxButtonMode.OK, null, null); })); } IsLoading = false; }, null); }