/// <summary> /// 得到明细 /// </summary> /// <param name="ChargeCode">操作员代码</param> /// <param name="feeType"></param> /// <returns></returns> public DataTable GetDetailCharge(string ChargeCode, string feeType) { try { IchargeListDao icLD = DaoFactory.GetObject <IchargeListDao>(typeof(ChargeListDao)); IcostDao icD = DaoFactory.GetObject <IcostDao>(typeof(CostDao)); icLD.oleDb = oleDb; icD.oleDb = oleDb; if (feeType.Trim() == "正常") { return(icLD.GetDetailCharge(ChargeCode, 0)); } else if (feeType.Trim() == "退费") { return(icLD.GetDetailCharge(ChargeCode, 1)); } else if (feeType.Trim() == "结补") { return(icD.GetDetailCharge(ChargeCode, 0)); } else if (feeType.Trim() == "结退") { return(icD.GetDetailCharge(ChargeCode, 1)); } return(null); } catch (System.Exception e) { throw new Exception(e.Message); } }
/// <summary> /// 得到病人的大项目分类项目费用 /// </summary> /// <param name="patlistid">病人入院ID</param> /// <returns></returns> public DataTable GetPatBigItemOrderFee() { try { IcostDao icD = DaoFactory.GetObject <IcostDao>(typeof(CostDao)); icD.oleDb = oleDb; return(icD.GetPatBigItemOrderFee(PatListID)); } catch (System.Exception e) { throw new Exception(e.Message); } }
/// <summary> /// 根据结算ID数组得到发票汇总数据(交款表汇总-打印结算交款表用) /// </summary> /// <param name="AccountIDs"></param> /// <returns></returns> public DataTable GetTicketTotle(int[] AccountIDs) { try { IcostDao icD = DaoFactory.GetObject <IcostDao>(typeof(CostDao)); icD.oleDb = oleDb; return(icD.GetTicketTotle(AccountIDs)); } catch (System.Exception e) { throw new Exception(e.Message); } }
/// <summary> /// 得到应收金额(医疗收入、药品收入、其他收入) /// </summary> /// <param name="AccountID">交款ID</param> /// <returns></returns> public decimal[] GetTotleType(int AccountID) { try { //IchargeListDao icLD = DaoFactory.GetObject<IchargeListDao>(typeof(ChargeListDao)); IcostDao icD = DaoFactory.GetObject <IcostDao>(typeof(CostDao)); //icLD.oleDb = oleDb; icD.oleDb = oleDb; return(icD.GetTotleType(AccountID)); } catch (System.Exception e) { throw new Exception(e.Message); } }
/// <summary> /// 病人结算费用 /// </summary> /// <param name="patlistid"></param> /// <returns></returns> public PatFee GetPatCostFee() { try { PatFee patFee = new PatFee(); IchargeListDao icLD = DaoFactory.GetObject <IchargeListDao>(typeof(ChargeListDao)); icLD.oleDb = oleDb; IpresDao ipD = DaoFactory.GetObject <IpresDao>(typeof(PresDao)); ipD.oleDb = oleDb; IcostDao icD = DaoFactory.GetObject <IcostDao>(typeof(CostDao)); icD.oleDb = oleDb; //得到中结后的累计预交金 patFee.chargeFee = Convert.ToDecimal(icLD.GetNoCostAll_Fee(this.PatListID).ToString("0.00")); //得到所有记账处方未结算的费用 patFee.costFee = Convert.ToDecimal(ipD.GetNoCostAll_Fee(this.PatListID).ToString("0.00")); //string patientCode = OP_PatientObject.GetPatInfo(patlistid).PatientCode; //优惠 patFee.faoverFee = 0;//Convert.ToDecimal(zy_chargelist.ZY_PresMaster_GetfaoverAll_Fee(patlistid, patientCode, patFee.costFee).ToString("0.00")); //农合 patFee.villageFee = Convert.ToDecimal(icD.GetvillageAll_Fee(this.PatListID).ToString("0.00")); //自付 patFee.selfFee = patFee.costFee - (patFee.faoverFee + patFee.villageFee); //余额 patFee.surplusFee = patFee.chargeFee - patFee.selfFee; //补收 patFee.receiveFee = patFee.surplusFee < 0 ? (0 - patFee.surplusFee) : 0; //应退 patFee.retreatFee = patFee.surplusFee >= 0 ? patFee.surplusFee : 0; patFee.surplusFee = Convert.ToDecimal(patFee.surplusFee.ToString("0.00")); patFee.receiveFee = Convert.ToDecimal(patFee.receiveFee.ToString("0.00")); patFee.retreatFee = Convert.ToDecimal(patFee.retreatFee.ToString("0.00")); return(patFee); } catch (System.Exception e) { throw new Exception(e.Message); } }
/// <summary> /// 得到现金和pos金额分别多少 /// </summary> /// <param name="ChargeCode">操作员代码</param> /// <param name="type">类别(0,全部.1,预交金.2,结算.)</param> /// <returns></returns> public decimal[] GetMenoyAndPosFee(string ChargeCode, int type) { IchargeListDao icLD = DaoFactory.GetObject <IchargeListDao>(typeof(ChargeListDao)); IcostDao icD = DaoFactory.GetObject <IcostDao>(typeof(CostDao)); icLD.oleDb = oleDb; icD.oleDb = oleDb; try { if (type == 0) { decimal[] dec = new decimal[5]; decimal[] dec1 = new decimal[5]; dec = icLD.GetMenoyAndPosFee(ChargeCode); dec1 = icD.GetMenoyAndPosFee(ChargeCode); dec[0] += dec1[0]; dec[1] += dec1[1]; dec[2] += dec1[2]; dec[3] += dec1[3]; dec[4] += dec1[4]; return(dec); } else if (type == 1) { return(icLD.GetMenoyAndPosFee(ChargeCode)); } else if (type == 2) { return(icD.GetMenoyAndPosFee(ChargeCode)); } return(null); } catch (System.Exception e) { throw new Exception(e.Message); } }
/// <summary> /// 加载上面数据 /// </summary> public void LoadData() { this.UserName = BaseNameFactory.GetName(baseNameType.用户名称, this.ChargeCode);//HIS.SYSTEM.BussinessLogicLayer.Classes.BaseData.GetUserName(this.ChargeCode); this.CureNo = HIS.SYSTEM.BussinessLogicLayer.Classes.BaseData.GetCureNo(this.PatListID); this.PatName = HIS.SYSTEM.BussinessLogicLayer.Classes.BaseData.GetPatName(this.PatID); // this.DeptName = HIS.SYSTEM.BussinessLogicLayer.Classes.BaseData.GetPatDept(this.PatListID); IcostDao costdao = DaoFactory.GetObject <IcostDao>(typeof(CostDao)); //显示病人当前在院科室 costdao.oleDb = oleDb; this.DeptName = costdao.GetDeptName(this.PatListID); if (this.Ntype == 1) { this.CostType = "中途"; } else if (this.Ntype == 2) { this.CostType = "出院"; } else { this.CostType = "欠费"; } }
/// <summary> /// 得到新的发票流水号 /// </summary> /// <param name="date">当前服务器时间</param> /// <returns></returns> public string GetNewTicketNO(DateTime date) { try { IcostDao icD = DaoFactory.GetObject <IcostDao>(typeof(CostDao)); icD.oleDb = oleDb; string datestr = date.ToString("yyyyMMdd"); string datestr2 = icD.GetNewTicketNo(date); if (datestr2.Length == 1) { datestr2 = "00" + datestr2; } else if (datestr2.Length == 2) { datestr2 = "0" + datestr2; } return(datestr + datestr2); } catch (System.Exception e) { throw new Exception(e.Message); } }
/// <summary> /// 重打发票 /// </summary> /// <param name="CostMasterID">结算ID</param> /// <param name="TicketNO">发票号</param> /// <param name="CostCode">结算人代码</param> /// <param name="CostDate">结算日期</param> /// <returns></returns> public int Again_Ticket(int CostMasterID, string TicketNO, string CostCode, DateTime CostDate) { IcostDao icD = DaoFactory.GetObject <IcostDao>(typeof(CostDao)); icD.oleDb = oleDb; IpresDao ipD = DaoFactory.GetObject <IpresDao>(typeof(PresDao)); ipD.oleDb = oleDb; try { oleDb.BeginTransaction(); ZY_CostMaster zyCostM = BindEntity <ZY_CostMaster> .CreateInstanceDAL(oleDb).GetModel(CostMasterID); ZY_CostMaster zyCostMM = new ZY_CostMaster(); //1Copy zyCostMM = (ZY_CostMaster)zyCostM.Clone(); //zy_CostM.Update(zyCostM.CostMasterID, 1); string strwhere = "COSTMASTERID =" + CostMasterID; string fieldvalue = "RECORD_FLAG = 1"; BindEntity <ZY_CostMaster> .CreateInstanceDAL(oleDb).Update(strwhere, fieldvalue); //3add冲帐记录 zyCostM.Total_Fee = 0 - zyCostM.Total_Fee; zyCostM.Deptosit_Fee = 0 - zyCostM.Deptosit_Fee; zyCostM.Self_Fee = 0 - zyCostM.Self_Fee; zyCostM.Village_Fee = 0 - zyCostM.Village_Fee; zyCostM.Village_Fee = 0 - zyCostM.Village_Fee; zyCostM.Reality_Fee = 0 - zyCostM.Reality_Fee; zyCostM.Pos_Fee = 0 - zyCostM.Pos_Fee; zyCostM.Money_Fee = 0 - zyCostM.Money_Fee; zyCostM.Record_Flag = 2; zyCostM.OldID = zyCostM.CostMasterID; zyCostM.AccountID = 0;//add zenghao //zy_CostM.Add(zyCostM); BindEntity <ZY_CostMaster> .CreateInstanceDAL(oleDb).Add(zyCostM); //4add新的重打记录 zyCostMM.TicketNum = GetNewTicketNO(CostDate); zyCostMM.TicketCode = TicketNO; zyCostMM.ChargeCode = CostCode; zyCostMM.CostDate = CostDate; zyCostMM.AccountID = 0;//add zenghao BindEntity <ZY_CostMaster> .CreateInstanceDAL(oleDb).Add(zyCostMM); //更改处方结算标志 ipD.AlterCostID(CostMasterID, zyCostMM.CostMasterID); //5update 结算汇总记录 icD.UpdateCostMID(CostMasterID, zyCostMM.CostMasterID); oleDb.CommitTransaction(); return(zyCostMM.CostMasterID); } catch (System.Exception e) { oleDb.RollbackTransaction(); return(0); throw new Exception(e.Message); } }
/// <summary> /// 取消结算 /// </summary> /// <param name="zyCostM"></param> /// <returns></returns> public void CanelCostPat(ZY_CostMaster zyCostM) { try { oleDb.BeginTransaction(); //更改处方结算标志 IpresDao ipD = DaoFactory.GetObject <IpresDao>(typeof(PresDao)); ipD.oleDb = oleDb; IcostDao icD = DaoFactory.GetObject <IcostDao>(typeof(CostDao)); icD.oleDb = oleDb; IpatListDao ipLD = DaoFactory.GetObject <IpatListDao>(typeof(PatListDao)); ipLD.oleDb = oleDb; ipD.AlterCostID(zyCostM.CostMasterID, 0); //修改结算表的记录标识1,为被退(外面添加收费人代码和取消结算时间) icD.UpdateRecord_Flag(zyCostM.CostMasterID, 1); //删除所有结算汇总表的记录||update 新增对应多的付记录,不然在交款表按发票项目分类金额不对 string strWhere = "COSTID =" + zyCostM.CostMasterID; //BindEntity<ZY_CostOrder>.CreateInstanceDAL(oleDb).Delete(strWhere); update zenghao 20090826 List <ZY_CostOrder> zy_coList = BindEntity <ZY_CostOrder> .CreateInstanceDAL(oleDb).GetListArray(strWhere); //如果为取消中途结算,预交金的处理 //if (zyCostM.Ntype == 1)//? 出院结算取消也把ID修改回去 //{ strWhere = "DELETE_FLAG =" + zyCostM.CostMasterID; //string str1 = Tables.zy_chargelist.RECORD_FLAG + oleDb.EuqalTo() + "3"; string str2 = "DELETE_FLAG = 0"; BindEntity <ZY_ChargeList> .CreateInstanceDAL(oleDb).Update(strWhere, str2); //} //添加一条红冲记录,记录标识为2,红冲 zyCostM.Total_Fee = 0 - zyCostM.Total_Fee; zyCostM.Deptosit_Fee = 0 - zyCostM.Deptosit_Fee; zyCostM.Self_Fee = 0 - zyCostM.Self_Fee; zyCostM.Village_Fee = 0 - zyCostM.Village_Fee; zyCostM.Favor_Fee = 0 - zyCostM.Favor_Fee; zyCostM.Reality_Fee = 0 - zyCostM.Reality_Fee; zyCostM.Pos_Fee = 0 - zyCostM.Pos_Fee; zyCostM.Money_Fee = 0 - zyCostM.Money_Fee; zyCostM.WorkUnit_Fee = 0 - zyCostM.WorkUnit_Fee; zyCostM.NotWorkUnit_Fee = 0 - zyCostM.NotWorkUnit_Fee; zyCostM.Record_Flag = 2; zyCostM.OldID = zyCostM.CostMasterID; zyCostM.AccountID = 0; //add zenghao zyCostM.CostDate = HIS.SYSTEM.PubicBaseClasses.XcDate.ServerDateTime; BindEntity <ZY_CostMaster> .CreateInstanceDAL(oleDb).Add(zyCostM); //取消结算,结算明细表插付记录 for (int i = 0; i < zy_coList.Count; i++) { zy_coList[i].CostID = zyCostM.CostMasterID; zy_coList[i].Total_Fee = 0 - zy_coList[i].Total_Fee; BindEntity <ZY_CostOrder> .CreateInstanceDAL(oleDb).Add(zy_coList[i]); } //更改住院病人登记表病人类型为3,出院未结算 if (zyCostM.Ntype == 1)//如果是中途结算 { ipLD.AlterPatType(zyCostM.PatListID, 2); } else { ipLD.AlterPatType(zyCostM.PatListID, 3); } oleDb.CommitTransaction(); } catch (System.Exception e) { oleDb.RollbackTransaction(); throw new Exception(e.Message); } }
/// <summary> /// 交款 /// </summary> /// <param name="type">交款类型(1预交金,2结算费用,3全部)</param> /// <param name="empID">交款人ID</param> /// <returns></returns> public int[] SaveAccount(int type, string empID) { try { int[] AccountsID = new int[2]; AccountsID[0] = -1; AccountsID[1] = -1; oleDb.BeginTransaction(); IchargeListDao icLD = DaoFactory.GetObject <IchargeListDao>(typeof(ChargeListDao)); IcostDao icD = DaoFactory.GetObject <IcostDao>(typeof(CostDao)); icLD.oleDb = oleDb; icD.oleDb = oleDb; if (type == 1) { ZY_Account zyAccount = new ZY_Account(); zyAccount.AccountType = 0;//预交金 zyAccount.AccountCode = empID; zyAccount.LastDate = GetLastTime(); DataTable dt = GetAllCharge(empID); for (int i = 0; i < dt.Rows.Count; i++) { if (dt.Rows[i]["typename"].ToString() == "正常") { zyAccount.WTicketFee = Convert.ToDecimal(dt.Rows[i]["tol_fee"]); zyAccount.WTicketNum = Convert.ToInt32(dt.Rows[i]["count"]); } else if (dt.Rows[i]["typename"].ToString() == "退费") { zyAccount.BTicketFee = Convert.ToDecimal(dt.Rows[i]["tol_fee"]); zyAccount.BTicketNum = Convert.ToInt32(dt.Rows[i]["count"]); } } decimal[] dec = GetMenoyAndPosFee(empID, type); zyAccount.Total_Fee = dec[0] + dec[1]; zyAccount.Cash_Fee = dec[0]; zyAccount.POS_Fee = dec[1]; zyAccount.AccountCode = empID; zyAccount.AccountDate = HIS.SYSTEM.PubicBaseClasses.XcDate.ServerDateTime; BindEntity <ZY_Account> .CreateInstanceDAL(oleDb).Add(zyAccount); AccountsID[0] = zyAccount.AccountID; icLD.UpdateAccount(zyAccount.AccountCode, zyAccount.AccountID); } else if (type == 2) { ZY_Account zyAccount = new ZY_Account(); zyAccount.AccountType = 1;//结算 zyAccount.AccountCode = empID; zyAccount.LastDate = GetLastTime(); DataTable dt = GetAllCost(empID); for (int i = 0; i < dt.Rows.Count; i++) { if (dt.Rows[i]["typename"].ToString() == "结补") { zyAccount.WTicketFee = Convert.ToDecimal(dt.Rows[i]["tol_fee"]); zyAccount.WTicketNum = Convert.ToInt32(dt.Rows[i]["count"]); } else if (dt.Rows[i]["typename"].ToString() == "结退") { zyAccount.BTicketFee = Convert.ToDecimal(dt.Rows[i]["tol_fee"]); zyAccount.BTicketNum = Convert.ToInt32(dt.Rows[i]["count"]); } } decimal[] dec = GetMenoyAndPosFee(empID, type); zyAccount.Total_Fee = dec[0] + dec[1]; zyAccount.Cash_Fee = dec[0]; zyAccount.POS_Fee = dec[1]; zyAccount.AccountCode = empID; zyAccount.AccountDate = HIS.SYSTEM.PubicBaseClasses.XcDate.ServerDateTime; zyAccount.CostFee = dec[2]; zyAccount.FaoverFee = dec[3]; BindEntity <ZY_Account> .CreateInstanceDAL(oleDb).Add(zyAccount); AccountsID[1] = zyAccount.AccountID; icD.UpdateAccount(zyAccount.AccountCode, zyAccount.AccountID); } else { ZY_Account zyAccount = new ZY_Account(); zyAccount.AccountType = 0;//预交金 zyAccount.AccountCode = empID; zyAccount.LastDate = GetLastTime(); DataTable dt = GetAllCharge(empID); for (int i = 0; i < dt.Rows.Count; i++) { if (dt.Rows[i]["typename"].ToString() == "正常") { zyAccount.WTicketFee = Convert.ToDecimal(dt.Rows[i]["tol_fee"]); zyAccount.WTicketNum = Convert.ToInt32(dt.Rows[i]["count"]); } else if (dt.Rows[i]["typename"].ToString() == "退费") { zyAccount.BTicketFee = Convert.ToDecimal(dt.Rows[i]["tol_fee"]); zyAccount.BTicketNum = Convert.ToInt32(dt.Rows[i]["count"]); } } decimal[] dec = GetMenoyAndPosFee(empID, 1); zyAccount.Total_Fee = dec[0] + dec[1]; zyAccount.Cash_Fee = dec[0]; zyAccount.POS_Fee = dec[1]; zyAccount.AccountCode = empID; zyAccount.AccountDate = HIS.SYSTEM.PubicBaseClasses.XcDate.ServerDateTime; BindEntity <ZY_Account> .CreateInstanceDAL(oleDb).Add(zyAccount); AccountsID[0] = zyAccount.AccountID; icLD.UpdateAccount(zyAccount.AccountCode, zyAccount.AccountID); zyAccount = new ZY_Account(); zyAccount.AccountType = 1;//结算 zyAccount.AccountCode = empID; zyAccount.LastDate = GetLastTime(); dt = GetAllCost(empID); for (int i = 0; i < dt.Rows.Count; i++) { if (dt.Rows[i]["typename"].ToString() == "结补") { zyAccount.WTicketFee = Convert.ToDecimal(dt.Rows[i]["tol_fee"]); zyAccount.WTicketNum = Convert.ToInt32(dt.Rows[i]["count"]); } else if (dt.Rows[i]["typename"].ToString() == "结退") { zyAccount.BTicketFee = Convert.ToDecimal(dt.Rows[i]["tol_fee"]); zyAccount.BTicketNum = Convert.ToInt32(dt.Rows[i]["count"]); } } dec = GetMenoyAndPosFee(empID, 2); zyAccount.Total_Fee = dec[0] + dec[1]; zyAccount.Cash_Fee = dec[0]; zyAccount.POS_Fee = dec[1]; zyAccount.AccountCode = empID; zyAccount.AccountDate = HIS.SYSTEM.PubicBaseClasses.XcDate.ServerDateTime; zyAccount.CostFee = dec[2]; zyAccount.FaoverFee = dec[3]; BindEntity <ZY_Account> .CreateInstanceDAL(oleDb).Add(zyAccount); AccountsID[1] = zyAccount.AccountID; icD.UpdateAccount(zyAccount.AccountCode, zyAccount.AccountID); } //oleDb.StoreProcedureName = ""; //oleDb.Coding = ""; oleDb.CommitTransaction(); return(AccountsID); } catch (System.Exception e) { oleDb.RollbackTransaction(); throw new Exception(e.Message); } }