/// <summary> /// 打印统领单据 /// </summary> /// <param name="uniformMaster">统领单头表</param> private void PrintDispTL(YP_DispDeptHis uniformMaster) { try { this.Cursor = GWMHIS.BussinessLogicLayer.Classes.PublicStaticFun.WaitCursor(); string startPath = Application.StartupPath + "\\report\\统领发药单据.grf"; uniformMaster.PatientNames = CombineTotalMsg(cobSumWay.SelectedIndex, this.chkPrintNoPO.Checked); switch (cobSumWay.SelectedIndex) { case 0: uniformMaster.BillType = "长期医嘱"; break; case 1: uniformMaster.BillType = "临时医嘱"; break; default: uniformMaster.BillType = "全部医嘱"; break; } uniformMaster.BillType += chkPrintNoPO.Checked ? "针剂药品" : "全部药品"; PrintFactory.GetPrinter(ConfigManager.OP_YF_DISPENSE + "ZY_TL").PrintBill(uniformMaster, _totalOrder, startPath, (int)_currentUserId); } catch (Exception error) { throw error; } finally { this.Cursor = DefaultCursor; } }
/// <summary> /// 保存多张住院发药单(住院发药统领) /// </summary> /// <param name="masterList">发药单头表</param> /// <param name="deptId">药剂科室ID</param> /// <param name="dispDt"></param> /// <returns></returns> public override BillMaster SaveBills(List <BillMaster> masterList, long deptId, Hashtable dispDt) { try { YP_DispDeptHis dispDeptHis = new YP_DispDeptHis(); dispDeptHis.DispDept = (int)deptId; YP_DRMaster firstMaster = (YP_DRMaster)(masterList[0]); dispDeptHis.OpMan = firstMaster.OPPeopleID; dispDeptHis.OpTime = firstMaster.OPTime; dispDeptHis.TotalFee = 0; dispDeptHis.DeptId = firstMaster.DeptID; oleDb.BeginTransaction(); BindEntity <YP_DispDeptHis> .CreateInstanceDAL(oleDb).Add(dispDeptHis); foreach (YP_DRMaster dispMaster in masterList) { if (dispDt[dispMaster.InpatientID] == null) { break; } DataTable dispRecipeOrder = (DataTable)dispDt[dispMaster.InpatientID]; if (dispRecipeOrder.Rows.Count > 0) { DataTable dt = dispRecipeOrder.Clone(); dt.Clear(); DataRow[] rows = dispRecipeOrder.Select("group_id=" + dispMaster.RecipeID + ""); if (rows.Length > 0) { for (int index = 0; index < rows.Length; index++) { dt.Rows.Add(rows[index].ItemArray); } List <BillOrder> dispList = this.BuildNewDispOrder(dt, dispMaster, 2); dispMaster.UniFormId = dispDeptHis.Id; SingleDisp(dispList, dispMaster, dispDeptHis.Id); dispDeptHis.TotalFee += dispMaster.RetailFee; dispDeptHis.PatientNames += (dispMaster.PatientName + ","); } //List<BillOrder> dispList = this.BuildNewDispOrder(dispRecipeOrder, dispMaster, 2); //dispMaster.UniFormId = dispDeptHis.Id; //SingleDisp(dispList, dispMaster, dispDeptHis.Id); //dispDeptHis.TotalFee += dispMaster.RetailFee; //dispDeptHis.PatientNames += (dispMaster.PatientName + ","); } } BindEntity <YP_DispDeptHis> .CreateInstanceDAL(oleDb).Update(dispDeptHis); oleDb.CommitTransaction(); return(dispDeptHis); } catch (Exception error) { if (oleDb.IsInTransaction) { oleDb.RollbackTransaction(); } throw error; } }
/// <summary> /// 住院药品统领 /// </summary> /// <param name="masterList">发药单表头汇总</param> /// <param name="deptId">药剂科室ID</param> /// <param name="dispDt">记账明细信息</param> /// <returns>统领药品历史信息</returns> public override BillMaster SaveBills(List <BillMaster> masterList, long deptId, Hashtable dispDt) { try { if (masterList == null) { throw new Exception("发药汇总失败"); } if (masterList.Count < 1) { throw new Exception("没有药品被选中发送"); } noStoreList = new List <YP_StoreNum>(); YP_DispDeptHis dispDeptHis = new YP_DispDeptHis(); dispDeptHis.DispDept = (int)deptId; YP_DRMaster firstMaster = (YP_DRMaster)(masterList[0]); dispDeptHis.OpMan = firstMaster.OPPeopleID; dispDeptHis.OpTime = firstMaster.OPTime; dispDeptHis.TotalFee = 0; dispDeptHis.DeptId = firstMaster.DeptID; oleDb.BeginTransaction(); BindEntity <YP_DispDeptHis> .CreateInstanceDAL(oleDb).Add(dispDeptHis); foreach (YP_DRMaster dispMaster in masterList) { string hashKey = dispMaster.InpatientID + dispMaster.DrugOC_Flag.ToString(); if (dispDt[hashKey] == null) { break; } DataTable dispRecipeOrder = (DataTable)dispDt[hashKey]; if (dispRecipeOrder.Rows.Count > 0) { List <BillOrder> dispList = this.BuildNewDispOrder(dispRecipeOrder, dispMaster, 2); dispMaster.UniFormId = dispDeptHis.Id; SingleDisp(dispList, dispMaster, dispDeptHis.Id); dispDeptHis.TotalFee += dispMaster.RetailFee; dispDeptHis.PatientNames += (dispMaster.PatientName + ","); } } BindEntity <YP_DispDeptHis> .CreateInstanceDAL(oleDb).Update(dispDeptHis); if (noStoreList.Count > 0) { oleDb.RollbackTransaction(); return(null); } oleDb.CommitTransaction(); return(dispDeptHis); } catch (Exception error) { if (oleDb.IsInTransaction) { oleDb.RollbackTransaction(); } throw error; } }
//打印按钮 private void btnPrint_Click(object sender, EventArgs e) { try { this.Cursor = GWMHIS.BussinessLogicLayer.Classes.PublicStaticFun.WaitCursor(); if (tabMsgMaster.SelectedTab == tabDispHis) { if (_recipeOrder != null && treeDrugMsg.SelectedNode != null) { if (treeDrugMsg.SelectedNode.Level == 2) { DataRow selectDispHis = (DataRow)(treeDrugMsg.SelectedNode.Tag); YP_DispDeptHis dispMaster = new YP_DispDeptHis(); dispMaster.DeptId = Convert.ToInt32(selectDispHis["DEPTID"]); dispMaster.DispDept = Convert.ToInt32(selectDispHis["DISPDEPT"]); dispMaster.Id = Convert.ToInt32(selectDispHis["Id"]); dispMaster.OpMan = Convert.ToInt32(selectDispHis["OPMAN"]); dispMaster.OpTime = Convert.ToDateTime(selectDispHis["OPTIME"]); dispMaster.TotalFee = Convert.ToDecimal(selectDispHis["TOTALFEE"]); PrintDispTL(dispMaster); } } else { MessageBox.Show("请选中统领信息"); return; } } else { if (_recipeOrder != null) { YP_DispDeptHis dispMaster = new YP_DispDeptHis(); dispMaster.DeptId = Convert.ToInt32(_currentDeptId); dispMaster.DispDept = Convert.ToInt32(_selectDeptId); dispMaster.Id = 0; dispMaster.OpMan = Convert.ToInt32(_currentUserId); dispMaster.OpTime = HIS.SYSTEM.PubicBaseClasses.XcDate.ServerDateTime; dispMaster.TotalFee = 0; for (int index = 0; index < _recipeOrder.Rows.Count; index++) { dispMaster.TotalFee += Convert.ToDecimal(_recipeOrder.Rows[index]["RetailFee"]); } PrintDispTL(dispMaster); } } } catch (Exception error) { MessageBox.Show(error.Message); } finally { this.Cursor = DefaultCursor; } }
private void PrintDispTL(List <BillMaster> printList, YP_DispDeptHis uniformMaster) { string startPath = Application.StartupPath + "\\report\\统领发药单据(经管).grf"; PrintFactory.GetPrinter(ConfigManager.OP_YF_DISPENSE + "ZY_TL").PrintBill(uniformMaster, _recipeOrder, startPath, (int)_currentUserId); if (MessageBox.Show("发药成功,是否需要打印摆药单?", "发药成功", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { startPath = Application.StartupPath + "\\report\\住院摆药单(经管).grf"; foreach (YP_DRMaster printMaster in printList) { PrintFactory.GetPrinter(ConfigManager.OP_YF_DISPENSE + "ZY_BY").PrintBill(printMaster, null, startPath, (int)_currentUserId); } } }
private void PrintDispTL(List <BillMaster> printList, YP_DispDeptHis uniformMaster) { string startPath = Application.StartupPath + "\\report\\统领发药单据(经管).grf"; for (int i = 0; i < selectPat.Count; i++) { DataRow[] rows = _recipeOrder.Select("cureno=" + "'" + selectPat[i].CureNo.ToString() + "'"); if (rows == null || rows.Length == 0) { continue; } DataTable dt = _recipeOrder.Clone(); dt.Clear(); for (int j = 0; j < rows.Length; j++) { dt.Rows.Add(rows[j].ItemArray); } PrintFactory.GetPrinter(ConfigManager.OP_YF_DISPENSE + "ZY_TL").PrintBill(uniformMaster, dt, startPath, (int)_currentUserId); } }
private void btnDispense_Click(object sender, EventArgs e) { try { Decimal newDispFee = 0; this.Cursor = GWMHIS.BussinessLogicLayer.Classes.PublicStaticFun.WaitCursor(); if (ConfigManager.IsChecking(_currentDeptId) == true) { MessageBox.Show("药品正在盘点中......"); return; } if (this._recipeOrder == null) { MessageBox.Show("没有药品可发"); return; } if (this._recipeOrder.Rows.Count < 1) { MessageBox.Show("没有药品可发"); return; } if (_dispenseModel == 1) { if (_currentZYPat == null) { MessageBox.Show("没有病人需要发药"); return; } YP_DRMaster dispMaster = _billProcessor.BuildNewDispenseMaster(_currentZYPat, (int)_currentDeptId, (int)_currentUserId); newDispFee = IN_InterFace.QueryPatDispFee(_currentZYPat, (int)_currentDeptId); if (this.CompareFee(newDispFee) == false) { MessageBox.Show("该病人因费用冲账发药信息需要刷新,请重新刷新"); return; } if (_recipeOrder != null) { List <BillOrder> dispList = _billProcessor.BuildNewDispOrder(_recipeOrder, dispMaster, _dispenseModel); _billProcessor.SaveBill(dispMaster, dispList, _currentDeptId); MessageBox.Show("发药成功...", "发药成功", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); _recipeOrder = IN_InterFace.QueryRecipeOrder(_currentZYPat, (int)_currentDeptId); dgrdRecipeInfo.DataSource = _recipeOrder; } } //如果是住院统领 else { ZY_PatList dispPat; for (int index = 0; index < lstPatInfo.CheckedItems.Count; index++) { dispPat = (ZY_PatList)lstPatInfo.CheckedItems[index].Tag; newDispFee += IN_InterFace.QueryPatDispFee(dispPat, (int)_currentDeptId); } if (CompareFee(newDispFee) == false) { MessageBox.Show("有病人因费用冲账发药信息需要刷新,请重新刷新"); return; } List <BillMaster> dispList = new List <BillMaster>(); for (int index = 0; index < lstPatInfo.CheckedItems.Count; index++) { dispPat = (ZY_PatList)lstPatInfo.CheckedItems[index].Tag; YP_DRMaster dispMaster = _billProcessor.BuildNewDispenseMaster(dispPat, (int)_currentDeptId, (int)_currentUserId); dispList.Add(dispMaster); } YP_DispDeptHis newDispDept = (YP_DispDeptHis)(_billProcessor.SaveBills(dispList, _searchDeptId, _allDispPats)); MessageBox.Show("发药成功,开始打印统领发药单据...", "发药成功", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); PrintDispTL(dispList, newDispDept); LoadTLMessage(); } this.txtQueryNum.Focus(); } catch (Exception error) { MessageBox.Show(error.Message); } finally { this.Cursor = DefaultCursor; } }
/// <summary> /// 加载住院统领单据明细 /// </summary> /// <param name="billMaster">单据头表</param> /// <returns></returns> public override DataTable LoadOrder(BillMaster billMaster) { try { YP_Dal ypDal = new YP_Dal(); ypDal._oleDb = oleDb; YP_DispDeptHis deptDisp = (YP_DispDeptHis)billMaster; DataTable deptDispOrder = new DataTable(); deptDispOrder.Columns.Add("ITEMNAME"); deptDispOrder.Columns.Add("STANDARD"); deptDispOrder.Columns.Add("PRODUCTNAME"); deptDispOrder.Columns.Add("AMOUNT", Type.GetType("System.Decimal")); deptDispOrder.Columns.Add("MAKERDICID"); deptDispOrder.Columns.Add("SELL_PRICE", Type.GetType("System.Decimal")); deptDispOrder.Columns.Add("TOLAL_FEE", Type.GetType("System.Decimal")); deptDispOrder.Columns.Add("UNIT"); deptDispOrder.Columns.Add("DOSEDICID"); deptDispOrder.PrimaryKey = new DataColumn[] { deptDispOrder.Columns["MAKERDICID"] }; string strWhere = "A.UNIFORMID" + oleDb.EuqalTo() + deptDisp.Id + oleDb.And() + "A.UNIFORM_FLAG" + oleDb.EuqalTo() + "1"; DataTable drOrders = ypDal.YF_DispenseOrder_GetList(strWhere); //设置摆药人员姓名 List <YP_DRMaster> drMasters = BindEntity <YP_DRMaster> .CreateInstanceDAL(oleDb, BLL.Tables.YF_DRMASTER).GetListArray("UNIFORMID=" + deptDisp.Id.ToString()); foreach (YP_DRMaster drmaster in drMasters) { deptDisp.PatientNames += drmaster.PatientName + ","; } for (int index = 0; index < drOrders.Rows.Count; index++) { DataRow drOrder = drOrders.Rows[index]; DataRow findRow = deptDispOrder.Rows.Find(drOrder["MAKERDICID"]); if (findRow != null) { findRow["AMOUNT"] = Convert.ToDecimal(findRow["AMOUNT"]) + Convert.ToDecimal(drOrder["DRUGOCNUM"]); findRow["TOLAL_FEE"] = Convert.ToDecimal(findRow["TOLAL_FEE"]) + Convert.ToDecimal(drOrder["RETAILFEE"]); } else { DataRow deptDispRow = deptDispOrder.NewRow(); deptDispRow["ITEMNAME"] = drOrder["CHEMNAME"]; deptDispRow["STANDARD"] = drOrder["SPEC"]; deptDispRow["PRODUCTNAME"] = drOrder["PRODUCTNAME"]; deptDispRow["AMOUNT"] = drOrder["DRUGOCNUM"]; deptDispRow["MAKERDICID"] = drOrder["MAKERDICID"]; deptDispRow["SELL_PRICE"] = drOrder["RETAILPRICE"]; deptDispRow["TOLAL_FEE"] = drOrder["RETAILFEE"]; deptDispRow["UNIT"] = drOrder["UNITNAME"]; deptDispRow["DOSEDICID"] = drOrder["DOSEDICID"]; deptDispOrder.Rows.Add(deptDispRow); } } deptDispOrder.DefaultView.Sort = "DOSEDICID ASC"; deptDispOrder = deptDispOrder.DefaultView.ToTable(); return(deptDispOrder); } catch (Exception error) { throw error; } }
private void btnDispense_Click(object sender, EventArgs e) { try { Decimal newDispFee = 0; this.Cursor = GWMHIS.BussinessLogicLayer.Classes.PublicStaticFun.WaitCursor(); if (ConfigManager.IsChecking(_currentDeptId) == true) { MessageBox.Show("药品正在盘点中......"); return; } if (this._recipeOrder == null) { MessageBox.Show("没有药品可发"); return; } if (this._recipeOrder.Rows.Count < 1) { MessageBox.Show("没有药品可发"); return; } for (int index = 0; index < selectPat.Count; index++) { newDispFee += IN_InterFace.QueryPatDispFee(selectPat[index], (int)_currentDeptId); } if (CompareFee(newDispFee) == false) { MessageBox.Show("有病人因费用冲账发药信息需要刷新,请重新刷新"); return; } List <BillMaster> dispList = new List <BillMaster>(); for (int index = 0; index < selectPat.Count; index++) { DataTable dt = (DataTable)_allDispPats[selectPat[index].CureNo]; YP_DRMaster dispMaster = _billProcessor.BuildNewDispenseMaster(selectPat[index], (int)_currentDeptId, (int)_currentUserId, Convert.ToInt32(dt.Rows[0]["presamount"].ToString()), Convert.ToInt32(dt.Rows[0]["group_id"].ToString())); dispList.Add(dispMaster); for (int j = 1; j < dt.Rows.Count; j++) { if (dt.Rows[j]["group_id"].ToString().Trim() != dt.Rows[j - 1]["group_id"].ToString().Trim()) { dispMaster = _billProcessor.BuildNewDispenseMaster(selectPat[index], (int)_currentDeptId, (int)_currentUserId, Convert.ToInt32(dt.Rows[j]["presamount"].ToString()), Convert.ToInt32(dt.Rows[j]["group_id"].ToString())); dispList.Add(dispMaster); } } } YP_DispDeptHis newDispDept = (YP_DispDeptHis)(_billProcessor.SaveBills(dispList, _searchDeptId, _allDispPats)); MessageBox.Show("发药成功,开始打印摆药单...", "发药成功", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); PrintBy(); // PrintDispTL(dispList, newDispDept); dgrdRecipeInfo.DataSource = null; LoadMsgMaster(); } catch (Exception error) { MessageBox.Show(error.Message); } finally { this.Cursor = DefaultCursor; } }
//发药按钮 private void btnDispense_Click(object sender, EventArgs e) { try { this.Cursor = GWMHIS.BussinessLogicLayer.Classes.PublicStaticFun.WaitCursor(); if (ConfigManager.IsChecking(_currentDeptId) == true) { MessageBox.Show("药品正在盘点中......"); return; } if (this._recipeOrder == null) { MessageBox.Show("没有药品可发"); return; } if (this._recipeOrder.Rows.Count < 1) { MessageBox.Show("没有药品可发"); return; } //重新获取住院发药数量和金额 update by heyan 修改药房多次发药的问题 _zyInterFace.GetSendNumAndFee(_recipeOrder); bool isDurg = true; for (int i = 0; i < _recipeOrder.Rows.Count; i++) { if (Convert.ToInt32(_recipeOrder.Rows[i]["DRUGNUM"]) != 0) { isDurg = false; break; } } if (isDurg == true) { MessageBox.Show("该单据已经发药,请刷新列表!", "发药提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } List <BillMaster> dispList = PutDrugByOrder(_allDispPats); YP_DispDeptHis newDispDept = (YP_DispDeptHis)(_billProcessor.SaveBills(dispList, _selectDeptId, _allDispPats)); if (newDispDept != null) { MessageBox.Show("发药成功,开始打印统领发药单据...", "发药成功", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); PrintDispTL(newDispDept); //btnPutDrug_Click(null, null); LoadMsgMaster(); } else { if (MessageBox.Show("当前存在药品库存不足,需要系统帮您自动取消这些库存不足的药品么?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { foreach (YP_StoreNum noStoreInfo in ((ZY_DispProcessor)(_billProcessor)).noStoreList) { for (int index = 0; index < _recipeOrder.Rows.Count; index++) { DataRow currentRow = _recipeOrder.Rows[index]; if (currentRow["ORDERRECIPEID"].ToString() == noStoreInfo.queryKey && Convert.ToInt32(currentRow["MAKERDICID"]) == noStoreInfo.makerDicId) { currentRow["ISDISPENSE"] = 0; } } } } } } catch (Exception error) { MessageBox.Show(error.Message); } finally { this.Cursor = DefaultCursor; this.txtQueryNum.Focus(); } }