Esempio n. 1
0
        public object Run(YiTian.db.Dao dao, YtService.data.OptData data, out string msg)
        {
            string A = data.Sql;

            msg = "";
            if ("Del".Equals(A))
            {
                object p = dao.ExecuteScalar("select count(*) num from 用户表 where fixedflag=0 and cHosCode = '" + data.Param["choscode"] + "'");
                if (p != null && int.Parse(p.ToString()) > 0)
                {
                    throw new Exception("当前医疗机构已被使用,不能删除!");
                }

                object p2 = dao.ExecuteScalar("select count(*) num from sysdicthospital where parenthoscode = '" + data.Param["choscode"] + "'");
                if (p2 != null && int.Parse(p2.ToString()) > 0)
                {
                    throw new Exception("当前医疗机构还有子机构,不能删除!");
                }

                if (dao.ExecuteNonQuery("DELETE FROM sysdicthospital WHERE cHosCode='" + data.Param["choscode"] + "'") < 0)
                {
                    throw new Exception("删除医疗机构失败!");
                }

                //msg = "删除成功完成!";
            }
            else if ("SaveNHFare".Equals(A))  //保存农合诊疗及药品字典
            {
                List <Dictionary <string, object> > mxli = ObjConvert.GetParamsByStr(StringZip.Decompress(data.Param["nhdatamx"].ToString()));
                Opt NhZLData = OptContent.get("nh_FareZLDict");
                Opt NhYPData = OptContent.get("nh_FareYPDict");
                if (mxli == null || mxli.Count == 0)
                {
                    throw new Exception("无农合费用字典明细!");
                }

                string vchoscode = data.Param["cHosCode"].ToString();
                int    rank      = int.Parse(data.Param["rank"].ToString());

                if (dao.ExecuteNonQuery("DELETE FROM 农合药品表 WHERE cHosCode='" + vchoscode + "' and RANK=" + rank) < 0)
                {
                    throw new Exception("删除农合药品数据出错!");
                }
                if (dao.ExecuteNonQuery("DELETE FROM 农合项目表 WHERE cHosCode='" + vchoscode + "' and RANK=" + rank) < 0)
                {
                    throw new Exception("删除农合项目数据出错!");
                }

                foreach (Dictionary <string, object> pa in mxli)
                {
                    pa["rank"]     = rank;
                    pa["cHosCode"] = vchoscode;
                    if (pa["农合类别"].ToString().Equals("02") || pa["农合类别"].ToString().Equals("09"))
                    {
                        if (DaoTool.Save(dao, NhYPData, pa) < 0)
                        {
                            throw new Exception("保存农合费用字典药品明细失败!");
                        }
                    }
                    else
                    {
                        if (pa["农合类别"].ToString().Equals("05") || pa["农合类别"].ToString().Equals("10"))
                        {
                            if (DaoTool.Save(dao, NhYPData, pa) < 0)
                            {
                                throw new Exception("保存农合费用字典药品明细失败!");
                            }
                        }

                        if (DaoTool.Save(dao, NhZLData, pa) < 0)
                        {
                            throw new Exception("保存农合费用字典诊疗明细失败!");
                        }
                    }
                }
            }
            else if ("SaveICD10".Equals(A))  //保存农合疾病字典
            {
                List <Dictionary <string, object> > mxli = ObjConvert.GetParamsByStr(StringZip.Decompress(data.Param["icd10"].ToString()));
                Opt NhicdData = OptContent.get("nh_saveICDDict");
                if (mxli == null || mxli.Count == 0)
                {
                    throw new Exception("无农合疾病字典明细!");
                }

                dao.ExecuteNonQuery("truncate table 农合疾病表");  //永远返回-1

                foreach (Dictionary <string, object> pa in mxli)
                {
                    if (DaoTool.Save(dao, NhicdData, pa) < 0)
                    {
                        throw new Exception("保存农合疾病字典失败!");
                    }
                }
                dao.ExecuteNonQuery("update 农合疾病表 t set t.orderid=(select ordid from jb where 编码=t.农合编码) where exists(select * from jb where 编码=t.农合编码)");
            }

            else if ("SaveSS".Equals(A))  //保存农合手术字典
            {
                List <Dictionary <string, object> > mxli = ObjConvert.GetParamsByStr(StringZip.Decompress(data.Param["SS"].ToString()));
                Opt NhicdData = OptContent.get("nh_saveSSDict");
                if (mxli == null || mxli.Count == 0)
                {
                    throw new Exception("无农合手术字典明细!");
                }
                dao.ExecuteNonQuery("truncate table 农合手术表");

                foreach (Dictionary <string, object> pa in mxli)
                {
                    if (DaoTool.Save(dao, NhicdData, pa) < 0)
                    {
                        throw new Exception("保存农合手术字典失败!");
                    }
                }
            }

            else if ("CheckNHFare".Equals(A))  //保存并进行核对农合费用项目
            {
                List <Dictionary <string, object> > mxli = ObjConvert.GetParamsByStr(StringZip.Decompress(data.Param["nhdatamx"].ToString()));
                Opt NhZLData = OptContent.get("nh_FareZLDict");
                Opt NhYPData = OptContent.get("nh_FareYPDict");
                if (mxli == null || mxli.Count == 0)
                {
                    throw new Exception("无农合费用字典明细!");
                }

                string vchoscode = data.Param["cHosCode"].ToString();
                int    rank      = int.Parse(data.Param["rank"].ToString());

                if (dao.ExecuteNonQuery("DELETE FROM 农合药品表BK WHERE cHosCode='" + vchoscode + "' and RANK=" + rank) < 0)
                {
                    throw new Exception("删除农合药品BK数据出错!");
                }

                if (dao.ExecuteNonQuery("DELETE FROM 农合项目表BK WHERE cHosCode='" + vchoscode + "' and RANK=" + rank) < 0)
                {
                    throw new Exception("删除农合项目BK数据出错!");
                }

                if (dao.ExecuteNonQuery("Insert into 农合药品表BK(农合编码,农合名称,农合类别,保内外,报补比例,单位,rank,updatetime,基药标志,cHosCode) " +
                                        "Select 农合编码,农合名称,农合类别,保内外,报补比例,单位,rank,updatetime,基药标志,cHosCode from 农合药品表 WHERE cHosCode='" + vchoscode + "' and RANK=" + rank) < 0)
                {
                    throw new Exception("插入农合药品BK数据出错!");
                }

                if (dao.ExecuteNonQuery("Insert into 农合项目表BK(农合编码,农合名称,农合类别,保内外,报补比例,单位,rank,updatetime,基药标志,cHosCode) " +
                                        "Select 农合编码,农合名称,农合类别,保内外,报补比例,单位,rank,updatetime,基药标志,cHosCode from 农合项目表 WHERE cHosCode='" + vchoscode + "' and RANK=" + rank) < 0)
                {
                    throw new Exception("插入农合项目BK数据出错!");
                }

                if (dao.ExecuteNonQuery("DELETE FROM 农合药品表 WHERE cHosCode='" + vchoscode + "' and RANK=" + rank) < 0)
                {
                    throw new Exception("删除农合药品数据出错!");
                }
                if (dao.ExecuteNonQuery("DELETE FROM 农合项目表 WHERE cHosCode='" + vchoscode + "' and RANK=" + rank) < 0)
                {
                    throw new Exception("删除农合项目数据出错!");
                }

                foreach (Dictionary <string, object> pa in mxli)
                {
                    pa["rank"]     = rank;
                    pa["cHosCode"] = vchoscode;
                    if (pa["农合类别"].ToString().Equals("02") || pa["农合类别"].ToString().Equals("09"))
                    {
                        if (DaoTool.Save(dao, NhYPData, pa) < 0)
                        {
                            throw new Exception("保存农合费用字典药品明细失败!");
                        }
                    }
                    else
                    {
                        if (pa["农合类别"].ToString().Equals("05") || pa["农合类别"].ToString().Equals("10"))
                        {
                            if (DaoTool.Save(dao, NhYPData, pa) < 0)
                            {
                                throw new Exception("保存农合费用字典药品明细失败!");
                            }
                        }

                        if (DaoTool.Save(dao, NhZLData, pa) < 0)
                        {
                            throw new Exception("保存农合费用字典诊疗明细失败!");
                        }
                    }
                }
            }

            else if ("getLog".Equals(A))  //生成日志数据
            {
                dao.ExecuteNonQuery(" begin PCK_HisCommUse.sp_SaveNHChangeFareLog('" + data.Param["cHosCode"].ToString() + "' ," + data.Param["rank"].ToString() + "); end;");

                dao.ExecuteNonQuery(" begin PCK_HisCommUse.sp_CheckNHFareDict('" + data.Param["cHosCode"].ToString() + "' ," + data.Param["rank"].ToString() + "); end;");
                //   throw new Exception("生成农合更新日志失败!");
            }

            else if ("SavejmFare".Equals(A))  //保存安顺地区城镇医保费用目录
            {
                List <Dictionary <string, object> > mxli = ObjConvert.GetParamsByStr(StringZip.Decompress(data.Param["datamx"].ToString()));
                Opt fareData = OptContent.get("jm_savefareDict");
                if (mxli == null || mxli.Count == 0)
                {
                    throw new Exception("无居保目录明细!");
                }
                if (dao.ExecuteNonQuery("delete 地区居保目录 where choscode='" + data.Param["cHosCode"].ToString() + "'") < 0)
                {
                    throw new Exception("保存费用目录失败del!");
                }

                string bm;
                foreach (Dictionary <string, object> pa in mxli)
                {
                    bm = pa["大类编码"].ToString();
                    if (bm.Equals("81"))
                    {
                        pa["ypflag"] = 1;
                    }
                    else if (bm.Equals("11") || bm.Equals("12") || bm.Equals("13"))
                    {
                        pa["ypflag"] = 2;
                    }
                    else
                    {
                        pa["ypflag"] = 0;
                    }

                    pa["拼音码"]      = pa["拼音码"].ToString().ToLower();
                    pa["choscode"] = data.Param["cHosCode"].ToString();
                    if (DaoTool.Save(dao, fareData, pa) < 0)
                    {
                        throw new Exception("保存居保目录明细失败!");
                    }
                }
            }
            else if ("dictcopy".Equals(A))  //机构字典相互复制
            {
                if (dao.ExecuteNonQuery(" begin PCK_HisCommUse.sp_jgDictCopy('" +
                                        data.Param["fromHosCode"].ToString() + "' ,'" + data.Param["toHosCode"].ToString() + "' ,'" +
                                        data.Param["ypflag"].ToString() + "' ,'" + data.Param["nhcode"].ToString() + "'); end;") < 0)
                {
                    if (dao.ErrMsg != null)
                    {
                        throw new Exception(dao.ErrMsg);
                    }
                }
            }
            else if ("delyw".Equals(A))  //业务数据删除
            {
                if (dao.ExecuteNonQuery(" begin PCK_HisCommUse.sp_clearData('" + data.Param["choscode"].ToString() + "'," +
                                        data.Param["flag"].ToString() + "); end;") < 0)
                {
                    if (dao.ErrMsg != null)
                    {
                        throw new Exception(dao.ErrMsg);
                    }
                }
            }
            else if ("delypdict".Equals(A))  //药品字典删除
            {
                object p = dao.ExecuteScalar("select count(*) num from 库存药品 where cHosCode = " + data.Param["choscode"].ToString());
                if (p != null && int.Parse(p.ToString()) > 0)
                {
                    throw new Exception("当前医疗还有库存药品业务数据,不能直接删除字典!");
                }

                if (dao.ExecuteNonQuery("delete 药品字典表 where choscode='" + data.Param["choscode"].ToString() + "'") < 0)
                {
                    throw new Exception("药品字典删除失败!");
                }
            }
            else if ("setFlag".Equals(A))  //设置机构提示信息
            {
                if (dao.ExecuteNonQuery(" update sysdicthospital set flag=" + data.Param["flag"].ToString() + ",LICENCE='" +
                                        data.Param["info"].ToString() + "' where CHOSCODE='" + data.Param["cHosCode"].ToString() + "'") < 0)
                {
                    if (dao.ErrMsg != null)
                    {
                        throw new Exception(dao.ErrMsg);
                    }
                }
            }


            return("ok");
        }
Esempio n. 2
0
        public object Run(YiTian.db.Dao dao, YtService.data.OptData data, out string msg)
        {
            msg = "ok";
            string A        = data.Sql;
            string choscode = data.Param["cHosCode"].ToString();

            if ("Find".Equals(A))
            {
                object[] objs = new object[1];
                objs[0] = dao.find("select ID,sysvalue,choscode,sysexplain from 系统参数 t where (choscode is null or choscode=?) and not exists" +
                                   "(select * from 系统参数 where choscode=? and t.id=id and t.choscode is null)",
                                   new object[] { choscode, choscode });
                return(objs);
            }
            else if ("Save".Equals(A))
            {
                if (data.Param.ContainsKey("密码"))
                {
                    string pwd = data.Param["密码"].ToString();
                    object p   = dao.ExecuteScalar("select passwd from 密码 where id=3");
                    if (p != null)
                    {
                        if (!p.ToString().Equals(pwd))
                        {
                            throw new Exception("输入的密码无效请重新输入!");
                        }
                    }
                    else
                    {
                        throw new Exception("输入的密码无效请重新输入!");
                    }
                }

                string sql = "", edsql = "", insql = "";
                int    num = int.Parse(data.Param["num"].ToString());
                for (int i = 1; i <= num; i++)
                {
                    if (data.Param.ContainsKey("ID" + i.ToString()))
                    {
                        if (data.Param.ContainsKey("note" + i.ToString()))
                        {
                            insql = "'" + data.Param["note" + i.ToString()].ToString() + "'";
                            edsql = ",sysexplain=" + insql;
                        }
                        else
                        {
                            edsql = "";
                            insql = "''";
                        }

                        if (!data.Param.ContainsKey("TYPE" + i.ToString()))
                        {
                            if (!choscode.Equals(""))
                            {
                                sql = "UPDATE 系统参数 SET sysvalue='" + data.Param["ID" + i.ToString()].ToString() + "'" + edsql + " WHERE ID=" + i.ToString() + " and choscode='" + choscode + "'";
                            }
                            else
                            {
                                sql = "UPDATE 系统参数 SET sysvalue='" + data.Param["ID" + i.ToString()].ToString() + "' WHERE ID=" + i.ToString() + " and choscode is null ";
                            }
                        }
                        else
                        {
                            sql = "insert into 系统参数 values(" + i.ToString() + ",'" + data.Param["TYPE" + i.ToString()].ToString() + "','" +
                                  data.Param["ID" + i.ToString()].ToString() + "'," + insql + ",'" + choscode + "')";
                        }

                        if (dao.ExecuteNonQuery(sql, new object[] {}) < 0)
                        {
                            throw new Exception("更新系统参数失败!");
                        }
                    }
                }
            }
            return("ok");
        }
Esempio n. 3
0
        public object Run(YiTian.db.Dao dao, YtService.data.OptData data, out string msg)
        {
            string ac = data.Sql;

            msg = "";
            if ("EditPwd".Equals(ac))
            {
                DataTable dt = dao.find("select a.userpassword from 用户表 a where   a.userid=? and a.choscode=? "
                                        , new object[] { data.Param["UserId"], data.Param["cHosCode"] }
                                        );
                if (dt == null || dt.Rows.Count == 0)
                {
                    throw new Exception("用户无效!");
                }
                string pd = "";
                if (dt.Rows[0][0] != null)
                {
                    pd = dt.Rows[0][0].ToString();
                }

                if (!data.Param["oldPwd"].ToString().Equals(pd))
                {
                    throw new Exception("原密码错误!");
                }
                if (data.Param.ContainsKey("sjh"))
                {
                    object obj1 = dao.ExecuteScalar("select count(*) from 用户表 a where a.mobilephone=?"
                                                    , new object[] { data.Param["sjh"] }
                                                    );
                    if (int.Parse(obj1.ToString()) > 0)
                    {
                        throw new Exception("您输入的手机号已被其他用户绑定,请重新输入!");
                    }
                    int i = dao.ExecuteNonQuery("update  用户表 set mobilephone=? where  userid=? and choscode=?"
                                                , new object[] { data.Param["sjh"], data.Param["UserId"], data.Param["cHosCode"] }
                                                );
                    if (i < 0)
                    {
                        throw new Exception("帮定手机号失败!");
                    }
                }
                int b = dao.ExecuteNonQuery("update  用户表 set userpassword=? where  userid=? and choscode=?"
                                            , new object[] { data.Param["Pwd"], data.Param["UserId"], data.Param["cHosCode"] }
                                            );
                if (b < 0)
                {
                    throw new Exception("修改用户密码失败!");
                }
                msg = "修改密码成功!";
            }
            else if ("RegCardSet".Equals(ac))
            {
                if (!data.Param.ContainsKey("密码"))
                {
                    throw new Exception("输入的密码无效请重新输入!");
                }
                string pwd = data.Param["密码"].ToString();
                object p   = dao.ExecuteScalar("select passwd from 密码 where id=4");
                if (p != null)
                {
                    if (!p.ToString().Equals(pwd))
                    {
                        throw new Exception("输入的密码无效请重新输入!");
                    }
                }
                else
                {
                    throw new Exception("输入的密码无效请重新输入!");
                }

                DataTable dt = dao.find("select 1 from 就诊卡范围表 where (开始号 between ? and ? or 结束号 between ? and ?) and length(开始号)=?"
                                        , new object[] { data.Param["开始号"], data.Param["结束号"], data.Param["开始号"], data.Param["结束号"], data.Param["长度"] }
                                        );
                if (dt != null && dt.Rows.Count > 0)
                {
                    throw new Exception("输入的就诊卡号已被领用过,请重新录入号码");
                }

                Opt op = OptContent.get("sys_SaveRegCard");
                if (DaoTool.Save(dao, op, data) > -1)
                {
                    msg = "保存就诊卡数据成功!";
                }
                else
                {
                    throw new Exception("就诊卡领用失败");
                }
            }
            else if ("SaveOpLog".Equals(ac))
            {
                if (dao.ExecuteNonQuery("insert into 特殊操作日志(choscode,chosname,操作功能,操作员,操作机器,辅助说明) values('" +
                                        data.Param["choscode"].ToString() + "','" + data.Param["chosname"].ToString() + "'," +
                                        data.Param["funID"].ToString() + ",'" + data.Param["username"].ToString() + "','" +
                                        data.Param["hostinfo"].ToString() + "','" + data.Param["说明"].ToString() + "')") < 0)
                {
                    throw new Exception("保存操作日志错误." + dao.ErrMsg);
                }
                else
                {
                    msg = "ok";
                }
            }


            return("ok");
        }
Esempio n. 4
0
        public object Run(YiTian.db.Dao dao, YtService.data.OptData data, out string msg)
        {
            string A = data.Sql;

            if ("Del".Equals(A))
            {
                object p = dao.ExecuteScalar("select count(*) num from 票据领用表 where 领用序号 = " +
                                             data.Param["serialno"].ToString() + " and 领用张数>剩余张数");
                if (p != null && int.Parse(p.ToString()) > 0)
                {
                    throw new Exception("当前领用的票据已经被使用,不能再删除!");
                }

                if (dao.ExecuteNonQuery("delete 票据领用表 where 领用序号=" + data.Param["serialno"].ToString()) < 0)
                {
                    throw new Exception("领用票据删除失败!");
                }
            }
            else if ("PDinvoice".Equals(A))
            {
                object p = dao.ExecuteScalar("select 领用序号 from 票据领用表 where choscode ='" +
                                             data.Param["choscode"].ToString() + "' and 剩余张数>=1 and 票据类型=" +
                                             data.Param["kind"].ToString() + " and length(开始票号)=" + data.Param["fpcode"].ToString().Length +
                                             " and '" + data.Param["fpcode"].ToString() + "' between 开始票号 and 结束票号 and " +
                                             "((使用模式=1) or (使用模式=0 and 领用人员=" + data.Param["userid"].ToString() + "))");
                if (p == null || p.ToString().Equals(""))
                {
                    throw new Exception(data.Param["fpcode"].ToString() + "票据号未领用过,不能被使用!");
                }

                object x = dao.ExecuteScalar("select count(*) cn from 票据使用表 where choscode ='" +
                                             data.Param["choscode"].ToString() + "' and 票据类型=" +
                                             data.Param["kind"].ToString() + " and 票号='" + data.Param["fpcode"].ToString() + "'");
                if (x != null && int.Parse(x.ToString()) > 0)
                {
                    throw new Exception(data.Param["fpcode"].ToString() + "票据号已经被使用过,不能重复使用!");
                }

                msg = "ok";
                return(p.ToString());
            }
            else if ("SaveNewFP".Equals(A))
            {
                if (data.Param["kind"].ToString().Equals("1")) //门诊
                {
                    if (dao.ExecuteNonQuery("update 门诊处方表 set 发票号=? where choscode=? and 处方号=?"
                                            , new object[] { data.Param["newfp"], data.Param["choscode"], data.Param["code"] }) < 0)
                    {
                        throw new Exception("改写门诊处方发票号错误!");
                    }
                }
                else if (data.Param["kind"].ToString().Equals("2"))//住院
                {
                    if (dao.ExecuteNonQuery("update 住院登记表 set 发票号=? where choscode=? and 住院号=?"
                                            , new object[] { data.Param["newfp"], data.Param["choscode"], data.Param["code"] }) < 0)
                    {
                        throw new Exception("改写住院发票号错误!");
                    }
                }
                else //预交款票据
                {
                    if (dao.ExecuteNonQuery("update 押金表 set 发票号=? where choscode=? and 住院号=? and 发票号=?"
                                            , new object[] { data.Param["newfp"], data.Param["choscode"], data.Param["code"],
                                                             data.Param["oldfp"].ToString() }) < 0)
                    {
                        throw new Exception("改写预交款票号错误!");
                    }
                }

                if (dao.ExecuteNonQuery("insert into 票据使用表(领用序号,票据类型,票号,操作员,choscode,code) values(" +
                                        data.Param["sno"].ToString() + "," + data.Param["kind"].ToString() + ",'" +
                                        data.Param["newfp"].ToString() + "'," + data.Param["userid"].ToString() + ",'" +
                                        data.Param["choscode"].ToString() + "','" + data.Param["code"].ToString() + "')") < 0)
                {
                    throw new Exception("补打发票时票据使用表写入错误!");
                }

                if (dao.ExecuteNonQuery("update 票据使用表 set 票据状态=1 where 领用序号=" +
                                        data.Param["sno"].ToString() + " and choscode='" + data.Param["choscode"].ToString() +
                                        "' and 票号='" + data.Param["oldfp"].ToString() + "'") < 0)
                {
                    throw new Exception("补打发票时更改票据使用表状态错误!");
                }

                if (dao.ExecuteNonQuery("insert into 作废票据表(票号,票据类型,更换新票号,操作员,choscode) values('" +
                                        data.Param["oldfp"].ToString() + "'," + data.Param["kind"].ToString() + ",'" +
                                        data.Param["newfp"].ToString() + "'," + data.Param["userid"].ToString() + ",'" +
                                        data.Param["choscode"].ToString() + "')") < 0)
                {
                    throw new Exception("作废票据写入错误!");
                }
            }

            msg = "ok";
            return("ok");
        }