/// <summary> /// 添加制剂新成品 /// </summary> /// <returns>成功返回1 失败返回-1</returns> public int AddNewDrug() { Neusoft.HISFC.Models.Pharmacy.Item item = this.SelectDrug(); if (item == null) { return(-1); } if (this.hsPrescription.ContainsKey(item.ID)) { MessageBox.Show(Language.Msg("该药品已维护了配制处方"), "", MessageBoxButtons.OK, MessageBoxIcon.Information); return(-1); } this.hsPrescription.Add(item.ID, null); this.AddDrugToFp(item); this.fsDrug_Sheet1.ActiveRowIndex = this.fsDrug_Sheet1.Rows.Count - 1; this.fsDrug_Sheet1.AddSelection(this.fsDrug_Sheet1.Rows.Count - 1, 0, 1, -1); this.fsDrug_SelectionChanged(null, null); return(1); }
/// <summary> /// 添加成品信息到Fp内 /// </summary> /// <param name="item"></param> /// <returns></returns> protected int AddDrugToFp(Neusoft.HISFC.Models.Pharmacy.Item item) { try { int rowCount = this.fsDrug_Sheet1.Rows.Count; this.fsDrug_Sheet1.Rows.Add(rowCount, 1); this.fsDrug_Sheet1.Cells[rowCount, (int)DrugColumnSet.ColDrugID].Text = item.ID; this.fsDrug_Sheet1.Cells[rowCount, (int)DrugColumnSet.ColTradeName].Text = item.Name; this.fsDrug_Sheet1.Cells[rowCount, (int)DrugColumnSet.ColSpecs].Text = item.Specs; this.fsDrug_Sheet1.Cells[rowCount, (int)DrugColumnSet.ColPackQty].Text = item.PackQty.ToString(); this.fsDrug_Sheet1.Cells[rowCount, (int)DrugColumnSet.ColPackUnit].Text = item.PackUnit; this.fsDrug_Sheet1.Cells[rowCount, (int)DrugColumnSet.ColMinUnit].Text = item.MinUnit; this.fsDrug_Sheet1.Rows[rowCount].Tag = item; } catch (Exception ex) { MessageBox.Show(ex.Message); return(-1); } return(1); }
public int Save(Neusoft.HISFC.Models.Pharmacy.Item item, ref string information) { if (Neusoft.FrameWork.Management.PublicTrans.Trans != null) { this.preparationManager.SetTrans(Neusoft.FrameWork.Management.PublicTrans.Trans); } DateTime sysTime = this.preparationManager.GetDateTimeFromSysDateTime(); try { Neusoft.HISFC.Models.Preparation.Prescription info = null; #region 保存其他材料 for (int i = 0; i < this.fsWrapper_Sheet1.Rows.Count; i++) { if (this.fsWrapper_Sheet1.Cells[i, 0].Text == "") { continue; } info = new Neusoft.HISFC.Models.Preparation.Prescription(); info.Drug = item; info.Material = this.fsWrapper_Sheet1.Rows[i].Tag as Neusoft.FrameWork.Models.NeuObject; if (info.Material == null) { Neusoft.FrameWork.Management.PublicTrans.RollBack(); MessageBox.Show("类型转换错误"); return(-1); } info.Specs = this.fsWrapper_Sheet1.Cells[i, (int)MaterialColumnSet.ColMaterialSpecs].Text; info.Price = Neusoft.FrameWork.Function.NConvert.ToDecimal(this.fsWrapper_Sheet1.Cells[i, (int)MaterialColumnSet.ColPrice].Text); info.NormativeUnit = this.fsWrapper_Sheet1.Cells[i, (int)MaterialColumnSet.ColUnit].Text; info.MaterialType = Neusoft.HISFC.Models.Preparation.EnumMaterialType.Wrapper; info.NormativeQty = Neusoft.FrameWork.Function.NConvert.ToDecimal(this.fsWrapper_Sheet1.Cells[i, (int)MaterialColumnSet.ColQty].Text); info.Memo = this.fsWrapper_Sheet1.Cells[i, (int)MaterialColumnSet.ColMemo].Text; info.OperEnv.ID = this.preparationManager.Operator.ID; info.OperEnv.OperTime = sysTime; if (this.preparationManager.SetPrescription(info) == -1) { Neusoft.FrameWork.Management.PublicTrans.RollBack(); if (this.preparationManager.DBErrCode == 1) { MessageBox.Show(info.Material.Name + "不能重复添加"); } else { MessageBox.Show(Language.Msg("保存" + info.Drug.Name + "配制处方信息失败" + this.preparationManager.Err)); } return(-1); } } #endregion } catch (Exception ex) { Neusoft.FrameWork.Management.PublicTrans.RollBack(); MessageBox.Show(ex.Message); return(-1); } return(1); }
/// <summary> /// 保存配制处方信息 /// </summary> /// <returns>成功返回1 失败返回-1</returns> public int SavePrescription() { if (this.fsDrug_Sheet1.Rows.Count <= 0) { return(1); } if (this.fsMaterial_Sheet1.Rows.Count <= 0) { MessageBox.Show(Language.Msg("请维护制剂配制处方信息")); return(1); } for (int i = 0; i < this.fsMaterial_Sheet1.Rows.Count; i++) { if (this.fsMaterial_Sheet1.Cells[i, 0].Text == "") { continue; } if (Neusoft.FrameWork.Function.NConvert.ToDecimal(this.fsMaterial_Sheet1.Cells[i, (int)MaterialColumnSet.ColQty].Text) == 0) { MessageBox.Show(Language.Msg("标准处方量需大于零")); return(1); } } string drugCode = this.fsDrug_Sheet1.Cells[this.fsDrug_Sheet1.ActiveRowIndex, (int)DrugColumnSet.ColDrugID].Text; DateTime sysTime = this.preparationManager.GetDateTimeFromSysDateTime(); Neusoft.FrameWork.Management.PublicTrans.BeginTransaction(); //Neusoft.FrameWork.Management.Transaction t = new Neusoft.FrameWork.Management.Transaction(Neusoft.FrameWork.Management.Connection.Instance); //t.BeginTransaction(); this.preparationManager.SetTrans(Neusoft.FrameWork.Management.PublicTrans.Trans); try { if (this.preparationManager.DelPrescription(drugCode, Neusoft.HISFC.Models.Base.EnumItemType.Drug) == -1) { Neusoft.FrameWork.Management.PublicTrans.RollBack(); MessageBox.Show(Language.Msg("删除配制处方信息出错" + this.preparationManager.Err)); return(-1); } Neusoft.HISFC.Models.Pharmacy.Item drug = this.drugHelper.GetObjectFromID(drugCode) as Neusoft.HISFC.Models.Pharmacy.Item; Neusoft.HISFC.Models.Preparation.Prescription info = null; #region 保存生产原料 for (int i = 0; i < this.fsMaterial_Sheet1.Rows.Count; i++) { if (this.fsMaterial_Sheet1.Cells[i, 0].Text == "") { continue; } info = new Neusoft.HISFC.Models.Preparation.Prescription(); info.Material = this.fsMaterial_Sheet1.Rows[i].Tag as Neusoft.FrameWork.Models.NeuObject; if (info.Material == null) { Neusoft.FrameWork.Management.PublicTrans.RollBack(); MessageBox.Show("类型转换错误"); return(-1); } info.Drug = drug; info.Specs = this.fsMaterial_Sheet1.Cells[i, (int)MaterialColumnSet.ColMaterialSpecs].Text; info.Price = Neusoft.FrameWork.Function.NConvert.ToDecimal(this.fsMaterial_Sheet1.Cells[i, (int)MaterialColumnSet.ColPrice].Text); info.NormativeUnit = this.fsMaterial_Sheet1.Cells[i, (int)MaterialColumnSet.ColUnit].Text; info.MaterialType = Neusoft.HISFC.Models.Preparation.EnumMaterialType.Material; info.NormativeQty = Neusoft.FrameWork.Function.NConvert.ToDecimal(this.fsMaterial_Sheet1.Cells[i, (int)MaterialColumnSet.ColQty].Text); info.Memo = this.fsMaterial_Sheet1.Cells[i, (int)MaterialColumnSet.ColMemo].Text; info.OperEnv.ID = this.preparationManager.Operator.ID; info.OperEnv.OperTime = sysTime; info.MaterialPackQty = Neusoft.FrameWork.Function.NConvert.ToDecimal(this.fsMaterial_Sheet1.Cells[i, (int)MaterialColumnSet.ColPackQty].Text); if (this.preparationManager.SetPrescription(info) == -1) { Neusoft.FrameWork.Management.PublicTrans.RollBack(); if (this.preparationManager.DBErrCode == 1) { MessageBox.Show(info.Material.Name + "不能重复添加"); } else { MessageBox.Show(Language.Msg("保存" + info.Drug.Name + "配制处方信息失败" + this.preparationManager.Err)); } return(-1); } } #endregion #region 调用接口保存 if (this.wrapperInterface != null) { string information = ""; if (wrapperInterface.Save(drug, ref information) == -1) { Neusoft.FrameWork.Management.PublicTrans.RollBack(); return(-1); } } #endregion } catch (Exception ex) { Neusoft.FrameWork.Management.PublicTrans.RollBack(); MessageBox.Show(ex.Message); return(-1); } Neusoft.FrameWork.Management.PublicTrans.Commit(); MessageBox.Show(Language.Msg("保存成功")); return(1); }