/* * public static string getNextDJHId(string id) * { * if (id.Length != 12) * { * return null; * } * string t = id.Substring(0, 2); * id = id.Substring(2); * * long num = long.Parse(id); * string next = (num + 1) + ""; * StringBuilder sbf = new StringBuilder(); * for (int i = 0; i < (10 - next.Length); i++) * { * sbf.Append("0"); * } * sbf.Append(next); * * return t+ sbf.ToString(); * } * * public static string getNextId2(string id,int l) * { * if (id.Length <2) * { * return null; * } * string t = id.Substring(0, 2); * id = id.Substring(2); * * long num = long.Parse(id); * string next = (num + 1) + ""; * StringBuilder sbf = new StringBuilder(); * for (int i = 0; i < (l-2 - next.Length); i++) * { * sbf.Append("0"); * } * sbf.Append(next); * * return t + sbf.ToString(); * } */ /// <summary> /// 获取住院号 /// </summary> /// <param name="dao"></param> /// <param name="data"></param> /// <returns></returns> public static string getZyNextNum(Dao dao, YtService.data.OptData data) { Dictionary <string, object> gz = DaoTool.Get(dao, OptContent.get("ZY_GetDJHGZ"), data); if (gz == null) { gz = new Dictionary <string, object>(); gz["前缀规则"] = "YYYYMM"; gz["主体是否补零"] = "0"; gz["主体长度"] = "5"; gz["起始号"] = null; } string d = ""; try { string qz = getPrestring(gz["前缀规则"].ToString()); string qsh = ""; if (gz["起始号"] != null) { qsh = gz["起始号"].ToString(); } qsh = qsh.Trim(); int ztlength = new ObjItem(gz["主体长度"]).ToInt(); if (ztlength == 0) { ztlength = 5; } data.Param["住院号"] = qz + "%"; data.Param["length"] = qz.Length + ztlength; d = DaoTool.ExecuteScalar(dao, OptContent.get("ZY_GetMaxDJH"), data).ToString(); if (d == null) { d = qz + getBegin(qsh, gz["前缀规则"].ToString(), ztlength, gz["主体是否补零"].ToString()); } else { if (isLowBegin(d, qsh, gz["前缀规则"].ToString())) { d = qz + getBegin(qsh, gz["前缀规则"].ToString(), ztlength, gz["主体是否补零"].ToString()); } else { d = qz + getMaxpre(d, gz["前缀规则"].ToString(), ztlength, gz["主体是否补零"].ToString()); } } } catch { d = ""; } return(d); }
/// <summary> /// 保存员工持款信息 /// </summary> /// <param name="dao"></param> /// <param name="data"></param> /// <param name="cklx">持款类型 1 挂号 2 门诊 3 住院 4 其他</param> /// <param name="je">收款金额</param> /// <param name="lsh">流水号 或就诊好</param> /// <param name="lx">类型</param> /// <param name="allowNull">是否允许持款为空</param> public static void SaveYgCk(Dao dao, OptData data, int cklx, decimal je, string lsh, string lx, bool allowNull) { Dictionary <string, object> param = DaoTool.Get(dao, OptContent.get("MZ_HaveCKList"), data); if (param == null) { if (!allowNull) { throw new Exception("员工持款信息无效!"); } data.Param["收款日期"] = DateTime.Now; data.Param["累计持款额"] = je; data.Param["累计交款额"] = 0; if (cklx == 1) { data.Param["挂号人数"] = 1; } if (cklx == 2) { data.Param["门诊人数"] = 1; } if (DaoTool.Save(dao, OptContent.get("MZ_SaveYGCK"), data) < 0) { throw new Exception("保存员工持款信息失败!"); } } else { param["收款日期"] = DateTime.Now; param["累计持款额"] = (new ObjItem(param["累计持款额"]).ToDecimal() + je); if (je > 0) { if (cklx == 1) { param["挂号人数"] = (new ObjItem(param["挂号人数"]).ToInt() + 1); } if (cklx == 2) { param["门诊人数"] = (new ObjItem(param["门诊人数"]).ToInt() + 1); } } else { if (cklx == 1) { param["挂号人数"] = (new ObjItem(param["挂号人数"]).ToInt() - 1); } if (cklx == 2) { param["门诊人数"] = (new ObjItem(param["门诊人数"]).ToInt() - 1); } decimal ck = new ObjItem(param["累计持款额"]).ToDecimal() + je; // if (ck < 0) //throw new Exception("员工持款额不足于支付退款"); } param["cHosCode"] = data.Param["cHosCode"]; if (DaoTool.ExecuteNonQuery(dao, OptContent.get("MZ_UpdateYGCKINFO"), param) < 0) { throw new Exception("更新员工持款信息失败!"); } } data.Param["发生金额"] = je; data.Param["发生时间"] = DateTime.Now; data.Param["类型"] = lx; data.Param["就诊号"] = lsh; if (DaoTool.Save(dao, OptContent.get("MZ_SaveYGZJL"), data) < 0) { throw new Exception("保存员工资金流信息失败!"); } }
public object Run(YiTian.db.Dao dao, YtService.data.OptData data, out string msg) { if (data.Sql != null && data.Sql.Equals("UpdateEQStock")) { if (DaoTool.Update(dao, OptContent.get("SaveEQStockInfo"), data) > -1) { msg = "保存库存信息成功!"; return("ok"); } else { throw new Exception("保存库存信息失败!" + dao.ErrMsg); } } if (data.Sql != null && data.Sql.Equals("SaveEQStock")) { data.Param["STOCKID"] = DaoTool.Seq(dao, "LKEQ.SEQEQStock");; if (DaoTool.Save(dao, OptContent.get("SaveEQStockInfo"), data) < 0) { // msg = flowno+'+'+DETAILNO; throw new Exception("添加物资库存总表信息失败!" + dao.ErrMsg); } } if (data.Sql != null && data.Sql.Equals("RuKuDanEQdelete")) { if (DaoTool.ExecuteNonQuery(dao, OptContent.get("DeleteEQInDetailInfo"), data) < 0) { throw new Exception("删除入库物资信息失败!"); } if (DaoTool.Update(dao, OptContent.get("SaveEQInMainInfo"), data) < 0) { throw new Exception("保存入库信息失败!" + dao.ErrMsg); } msg = "删除入库物资信息成功!"; return("ok"); } if (data.Sql != null && data.Sql.Equals("RuKuDanDelete")) { data.Param["STATUS"] = 0; if (DaoTool.Update(dao, OptContent.get("SaveEQInMainInfo"), data) > -1) { msg = "删除入库信息成功!"; return("ok"); } else { throw new Exception("删除入库信息失败!" + dao.ErrMsg); } } if (data.Sql != null && data.Sql.Equals("RuKuDanUpdate")) { Opt op = OptContent.get("SaveEQInMainInfo"); if (data.Param.ContainsKey(op.Key)) { if (DaoTool.Update(dao, op, data) > -1) { // saveRunDetail(dao, data); if (data.Param["STATUS"].ToString() == "2") { msg = "审核信息成功!"; } else if (data.Param["STATUS"].ToString() == "1") { msg = "提交审核入库信息成功!"; } else if (data.Param["STATUS"].ToString() == "6") { msg = "审核入库信息成功!"; } else { msg = "入库成功!"; } return("ok"); } else { throw new Exception("保存入库信息失败!" + dao.ErrMsg); } } } if (data.Sql != null && data.Sql.Equals("CXData")) { Opt op = OptContent.get("SaveEQInMainInfo"); if (data.Param.ContainsKey(op.Key)) { if (DaoTool.Update(dao, op, data) > -1) { msg = "冲销成功!"; } else { throw new Exception("保存入库信息失败!" + dao.ErrMsg); } } Dictionary <string, object> dic1 = new Dictionary <string, object>(); dic1["INID"] = data.Param["INID"].ToString(); dic1["CHOSCODE"] = data.Param["CHOSCODE"].ToString(); Opt op1 = OptContent.get("EQInMainInfo_CX"); Dictionary <string, object> dic = DaoTool.Get(dao, op1, dic1); dic["INID"] = DaoTool.Seq(dao, "LKEQ.SEQEQIn"); dic["STATUS"] = 7; dic["TOTALMONEY"] = "-" + dic["TOTALMONEY"].ToString(); dic["INVOICEMONEY"] = "-" + dic["INVOICEMONEY"].ToString(); dic["OTHERMONEY"] = "-" + dic["OTHERMONEY"].ToString(); Opt op2 = OptContent.get("SaveEQInMainInfo"); if (DaoTool.Save(dao, OptContent.get("SaveEQInMainInfo"), dic) > -1)//生成入库主表 { Opt op3 = OptContent.get("EQInDetailInfo_CX"); List <Dictionary <string, object> > lst = DaoTool.Find(dao, op3, data); if (lst != null) { foreach (Dictionary <string, object> dc in lst) { dc["NUM"] = "-" + dc["NUM"].ToString(); dc["MONEY"] = "-" + dc["MONEY"].ToString(); dc["OTHERMONEY"] = "-" + dc["OTHERMONEY"].ToString(); dc["TOTALPRICE"] = "-" + dc["TOTALPRICE"].ToString(); dc["TOTALMONEY"] = "-" + dc["TOTALMONEY"].ToString(); dc["DETAILNO"] = DaoTool.Seq(dao, "LKEQ.SEQEQInDetail"); dc["INID"] = dic["INID"]; Opt opt4 = OptContent.get("SaveEQInDetailInfo"); if (DaoTool.Save(dao, opt4, dc) < 0) //生成入库细表 { throw new Exception("保存单据明细失败!"); } Dictionary <string, object> dic2 = new Dictionary <string, object>(); Opt op5 = OptContent.get("EQIn_SearchEQStockNum"); Dictionary <string, object> dic3 = new Dictionary <string, object>(); dic3 = DaoTool.Get(dao, op5, dc); dic2["NUM"] = Convert.ToInt32(dic3["NUM"].ToString()) + Convert.ToInt32(dc["NUM"].ToString()); dic2["STOCKID"] = dic3["STOCKID"].ToString(); if (DaoTool.Update(dao, OptContent.get("SaveEQStockInfo"), dic2) > -1)//修改库存总表 { Dictionary <string, object> dic4 = new Dictionary <string, object>(); dic4["FLOWNO"] = dc["STOCKFLOWNO"]; dic4["NUM"] = dc["NUM"]; Opt op6 = OptContent.get("SaveEQStockDetailInfo"); if (DaoTool.Update(dao, op6, dic4) > -1)//修改库存细表 { } else { throw new Exception("保存设备库存流水信息失败!" + dao.ErrMsg); } } else { throw new Exception("保存库存信息失败!" + dao.ErrMsg); } } } } else { throw new Exception("保存入库单据失败!"); } msg = "冲销成功!"; return(msg); } if (data.Sql != null && data.Sql.Equals("SaveEQStockDetail")) { Opt op = OptContent.get("SaveEQStockDetailInfo"); if (data.Param.ContainsKey(op.Key)) { if (DaoTool.Update(dao, op, data) > -1) { msg = "保存设备库存流水信息成功!"; return("ok"); } else { throw new Exception("保存设备库存流水信息失败!" + dao.ErrMsg); } } else { data.Param["FLOWNO"] = DaoTool.Seq(dao, "LKEQ.SEQEQStockDetail"); string flowno = data.Param["FLOWNO"].ToString(); string DETAILNO = data.Param["DETAILNO"].ToString(); if (DaoTool.Save(dao, op, data) < 0) { // msg = flowno+'+'+DETAILNO; throw new Exception("保存物资库存流水信息失败!" + dao.ErrMsg); } //更新入库细表中的对应库存流水号 //YtService.data.OptData d = new YtService.data.OptData(); //d.Param["STOCKFLOWNO"] = data.Param["FLOWNO"]; //d.Param["DETAILNO"] = data.Param["DETAILNO"]; //if (DaoTool.Update(dao, OptContent.get("SaveWZInDetailInfo"), d) < 0) //{ // throw new Exception("更新入库细表信息失败!" + dao.ErrMsg); //} return(msg = flowno + '+' + DETAILNO); } } if (data.Sql != null && data.Sql.Equals("UpdateEQInDetailInfo")) { if (DaoTool.Update(dao, OptContent.get("SaveEQInDetailInfo"), data) < 0) { throw new Exception("更新入库细表信息失败!" + dao.ErrMsg); } msg = "保存成功!"; return("ok"); } if (data.Sql != null && data.Sql.Equals("RuKuDanSave")) { Opt op = OptContent.get("SaveEQInMainInfo"); if (data.Param.ContainsKey(op.Key)) { if (DaoTool.Update(dao, op, data) > -1) { saveRunDetail(dao, data); msg = "保存入库信息成功!"; return("ok"); } else { throw new Exception("保存入库信息失败!" + dao.ErrMsg); } } else { DataTable dt = dao.Fd(OptContent.get("EQSearchDicEQInOut").Sql, new object[] { data.Param["IOID"].ToString() }); data.Param["OPFLAG"] = dt.Rows[0]["OPFLAG"].ToString(); data.Param["INID"] = DaoTool.Seq(dao, "LKEQ.SEQEQIn"); string recipe = dt.Rows[0]["RECIPECODE"].ToString(); if (Convert.ToDecimal(dt.Rows[0]["RECIPEYEAR"]) == 1) { recipe += DateTime.Now.Year.ToString(); } if (Convert.ToDecimal(dt.Rows[0]["RECIPEMONTH"]) == 1) { if (DateTime.Now.Month < 10) { recipe = recipe + "0" + DateTime.Now.Month.ToString(); } else { recipe += DateTime.Now.Month.ToString(); } } decimal recipeno = Convert.ToDecimal(dao.ExecuteScalar(OptContent.get("EQGetRecipeNo").Sql, new object[] { recipe + '%' })) + 1; if (recipeno > 0 && recipeno < 10) { recipe = recipe + "0" + recipeno.ToString(); } else { recipe = recipe + recipeno.ToString(); } data.Param["RECIPECODE"] = recipe; data.Param["INDATE"] = DateTime.Now; data.Param["STATUS"] = 1; if (DaoTool.Save(dao, OptContent.get("SaveEQInMainInfo"), data) > -1) { saveRunDetail(dao, data); } else { throw new Exception("保存入库单据失败!"); } } } msg = "保存成功!"; return("ok"); }