예제 #1
0
        public object Run(YiTian.db.Dao dao, YtService.data.OptData data, out string msg)
        {
            if (data.Sql == null)
            {
                msg = "缺省SQL参数,无法继续进行操作!";
                return("ok");
            }
            if (data.Sql.Equals("ModifyOrAddZhu"))
            {
                //只有当新增主表的时候才需要生成对应的recipecode
                if (data.Param["RECIPECODE"] == null || data.Param["RECIPECODE"].ToString() == "")
                {
                    DataTable dt = DaoTool.FindDT(dao, OptContent.get("GetRecipeCodeInEQOutInfo"), data);
                    if (dt.Rows.Count <= 0 || dt == null)
                    {
                        throw new Exception("无法查找到单据前缀" + dao.ErrMsg);
                    }
                    DataRow row = dt.Rows[0];
                    data.Param["RECIPECODE"] = Recipecode(row["RECIPECODE"].ToString(), Convert.ToInt32(row["RECIPEYEAR"]), Convert.ToInt32(row["RECIPEMONTH"]), Convert.ToInt32(row["RECIPELENGTH"]));
                    data.Param.Add("RECIPECODEHelp", data.Param["RECIPECODE"].ToString() + "%");
                    data.Param["RECIPECODE"] = data.Param["RECIPECODE"] + DaoTool.ExecuteScalar(dao, OptContent.get("GetrecipeCodeNo"), data).ToInt().ToString("D2");
                }
                if (data.Param["OUTID"] == null || data.Param["OUTID"].ToString() == "")
                {
                    data.Param["OUTID"] = DaoTool.Seq(dao, "LKEQ.SEQEQOut");
                    OutIdHelp           = data.Param["OUTID"].ToString();

                    if (DaoTool.Save(dao, OptContent.get("ModifyOutMainInfo"), data) < 0)
                    {
                        msg = "执行失败!";
                        throw new Exception("新增设备领用的主表信息失败!" + dao.ErrMsg);
                    }
                    msg = "执行成功!";
                    return("ok");
                }
                if (DaoTool.Update(dao, OptContent.get("ModifyOutMainInfo"), data) < 0)
                {
                    msg = "执行失败!";
                    throw new Exception("修改设备领用的出库主表信息失败!" + dao.ErrMsg);
                }
                msg = "执行成功!";
                return("ok");
            }


            if (data.Sql.Equals("ModifyOrAddXi"))
            {
                //如果出库Id为空的话,肯定操作为新增,肯定都是新增的细表行。 首先获取生成的主表OUTID
                if (data.Param["OUTID"] == null || data.Param["OUTID"].ToString() == "")
                {
                    data.Param["OUTID"]    = OutIdHelp;
                    data.Param["DETAILNO"] = DaoTool.Seq(dao, "LKEQ.SEQEQOutDetail");
                    if (DaoTool.Save(dao, OptContent.get("ModifyOutXiBiaoInfo"), data) < 0)
                    {
                        msg = "执行失败!";
                        throw new Exception("修改设备领用的出库细表失败!" + dao.ErrMsg);
                    }
                    msg = "执行成功!";
                    return("ok");
                }
                else//操作为修改
                {
                    if (data.Param["DETAILNO"] == null || data.Param["DETAILNO"].ToString().Trim() == "")
                    {
                        //为新增的数据  新增完之后返回
                        data.Param["DETAILNO"] = DaoTool.Seq(dao, "LKEQ.SEQEQOutDetail");
                        if (DaoTool.Save(dao, OptContent.get("ModifyOutXiBiaoInfo"), data) < 0)
                        {
                            msg = "执行失败!";
                            throw new Exception("修改设备领用的出库细表失败!" + dao.ErrMsg);
                        }
                        msg = "执行成功!";
                        return("ok");
                    }
                    if (DaoTool.Update(dao, OptContent.get("ModifyOutXiBiaoInfo"), data) < 0)
                    {
                        msg = "执行失败!";
                        throw new Exception("修改设备领用的出库细表失败!" + dao.ErrMsg);
                    }
                    msg = "执行成功!";
                    //能够retrun ok 说明 要么是前面新增的对了,要么是后面的修改正确,不然都是throw出去
                    return("ok");
                }
            }

            if (data.Sql.Equals("SHOutMainInfo"))
            {
                if (DaoTool.ExecuteNonQuery(dao, OptContent.get("UpdateStatusInLingYong"), data) < 0)
                {
                    msg = "执行失败!";
                    throw new Exception("更新审核状态失败!" + dao.ErrMsg);
                }
                msg = "执行成功!";
                return("ok");
            }

            //===================================审核部分=====================================
            //入库主表
            if (data.Sql.Equals("InsertInMain"))
            {
                data.Param["INID"] = DaoTool.Seq(dao, "LKEQ.SEQEQIN");

                InIdHelp = data.Param["INID"].ToString();

                DataTable dt = DaoTool.FindDT(dao, OptContent.get("GetRecipeCodeInEQOutInfo"), data);
                if (dt.Rows.Count <= 0 || dt == null)
                {
                    throw new Exception("无法查找到单据前缀" + dao.ErrMsg);
                }
                DataRow row = dt.Rows[0];
                data.Param["RECIPECODE"] = Recipecode(row["RECIPECODE"].ToString(), Convert.ToInt32(row["RECIPEYEAR"]), Convert.ToInt32(row["RECIPEMONTH"]), Convert.ToInt32(row["RECIPELENGTH"]));
                data.Param.Add("RECIPECODEHelp", data.Param["RECIPECODE"].ToString() + "%");
                data.Param["RECIPECODE"] = data.Param["RECIPECODE"] + DaoTool.ExecuteScalar(dao, OptContent.get("GetrecipeCodeNo"), data).ToInt().ToString("D2");

                RecipeCodeInMain = data.Param["RECIPECODE"].ToString();

                SHDHHelp       = data.Param["SHDH"];
                SUPPLYIDHelp   = data.Param["SUPPLYID"];
                SUPPLYNAMEHelp = data.Param["SUPPLYNAME"];

                if (DaoTool.Save(dao, OptContent.get("SaveEQInMainInfoCX"), data) < 0)
                {
                    msg = "执行失败!";
                    throw new Exception("入库主表的信息插入失败!" + dao.ErrMsg);
                }
                //更新对应生成的INID至当前的出库主表
                dao.ExecuteNonQuery("UPDATE LKEQ.EQOUTMAIN SET INID=" + data.Param["INID"].ToString() + " WHERE CHOSCODE=" + data.Param["CHOSCODE"] + "  AND OUTID=" + data.Param["OUTID"].ToString());
                msg = "执行成功!";
                return("ok");
            }


            //入库细表
            if (data.Sql != null && data.Sql.Equals("InsertEQInDetail"))
            {
                data.Param["DETAILNO"] = DaoTool.Seq(dao, "LKEQ.SEQEQINDETAIL");
                InDetailNoHelp         = data.Param["DETAILNO"].ToString();
                data.Param["INID"]     = InIdHelp;
                if (DaoTool.Save(dao, OptContent.get("SaveEQInDetail"), data) < 0)
                {
                    msg = "执行失败!";
                    throw new Exception("入库细表信息执行失败!" + dao.ErrMsg);
                }
                msg = "执行成功!";
                return("ok");
            }

            //库存主表   可能不会执行  【只有在库存主表,不存在该设备的信息】
            if (data.Sql != null && data.Sql.Equals("InsertStockMain"))
            {
                data.Param["STOCKID"] = DaoTool.Seq(dao, "LKEQ.SEQEQSTOCK");
                //在每执行一次对库存总表的插入,都会更新一次stockid,否则,就是针对   一个stockid的插入流水
                StockIdHelp = data.Param["STOCKID"].ToString();
                if (DaoTool.Save(dao, OptContent.get("SaveEQStock"), data) < 0)
                {
                    msg = "执行失败!";
                    throw new Exception("库存主表信息执行失败!" + dao.ErrMsg);
                }
                msg = "执行成功!";
                return("ok");
            }
            //库存流水
            if (data.Sql != null && data.Sql.Equals("InsertStockDetail"))
            {
                data.Param["FLOWNO"] = DaoTool.Seq(dao, "LKEQ.SEQEQSTOCKDETAIL");

                data.Param["INID"]         = InIdHelp;
                data.Param["RECIPECODE"]   = RecipeCodeInMain;
                data.Param["SHDH"]         = SHDHHelp;
                data.Param["GHSUPPLYID"]   = SUPPLYIDHelp;
                data.Param["GHSUPPLYNAME"] = SUPPLYNAMEHelp;

                if (data.Param["STOCKID"] == null || data.Param["STOCKID"].ToString() == "")
                {
                    data.Param["STOCKID"] = StockIdHelp;
                }
                if (DaoTool.Save(dao, OptContent.get("SaveEQStockDetail"), data) < 0)
                {
                    msg = "执行失败!";
                    throw new Exception("库存流水信息执行失败!" + dao.ErrMsg);
                }
                //更新至入库细表
                dao.ExecuteNonQuery("UPDATE LKEQ.EQINDETAIL SET STOCKFLOWNO=" + data.Param["FLOWNO"].ToString() + " WHERE CHOSCODE=" + data.Param["CHOSCODE"] + "  AND DETAILNO=" + InDetailNoHelp);
                msg = "执行成功!";
                return("ok");
            }

            //冲销操作=================================================================================
            if (data.Sql != null && data.Sql.Equals("ChongXiaoRuChu"))
            {
                if (DaoTool.ExecuteNonQuery(dao, OptContent.get("ChongXiaoChuKuStatusChange"), data) < 0)
                {
                    msg = "执行失败!";
                    throw new Exception("修改出库主表冲销状态失败!" + dao.ErrMsg);
                }

                if (DaoTool.ExecuteNonQuery(dao, OptContent.get("ChongXiaoRuKuStatusChange"), data) < 0)
                {
                    msg = "执行失败!";
                    throw new Exception("修改入库主表冲销状态失败!" + dao.ErrMsg);
                }
                msg = "执行成功!";
                return("ok");
            }

            //插入出库主表
            if (data.Sql != null && data.Sql.Equals("ChongXiaoZhuChuKu"))
            {
                data.Param["OUTID"] = DaoTool.Seq(dao, "LKEQ.SEQEQOut");
                OutIdCXHelp         = data.Param["OUTID"].ToString();
                if (DaoTool.Save(dao, OptContent.get("ModifyOutMainInfo"), data) < 0)
                {
                    msg = "执行失败!";
                    throw new Exception("插入冲销出库主表失败!" + dao.ErrMsg);
                }
                msg = "执行成功!";
                return("ok");
            }

            //出库细表
            if (data.Sql != null && data.Sql.Equals("ChongXiaoXiChuKu"))
            {
                data.Param["DETAILNO"] = DaoTool.Seq(dao, "LKEQ.SEQEQOutDetail");
                data.Param["OUTID"]    = OutIdCXHelp;
                if (DaoTool.Save(dao, OptContent.get("ModifyOutXiBiaoInfo"), data) < 0)
                {
                    msg = "执行失败!";
                    throw new Exception("插入冲销出库细表失败!" + dao.ErrMsg);
                }
                msg = "执行成功!";
                return("ok");
            }


            //入库主表
            if (data.Sql != null && data.Sql.Equals("ChongXiaoZhuRuKu"))
            {
                data.Param["INID"] = DaoTool.Seq(dao, "LKEQ.SEQEQIN");
                InIdCXHelp         = data.Param["INID"].ToString();
                if (DaoTool.Save(dao, OptContent.get("SaveEQInMainInfoCX"), data) < 0)
                {
                    throw new Exception("插入冲销入库主表失败!" + dao.ErrMsg);
                }

                dao.ExecuteNonQuery("UPDATE LKEQ.EQOUTMAIN SET INID=" + data.Param["INID"].ToString() + "  WHERE CHOSCODE= " + data.Param["CHOSCODE"].ToString() + "  AND OUTID=" + OutIdCXHelp);
                msg = "执行成功!";
                return("ok");
            }

            //入库细表
            if (data.Sql != null && data.Sql.Equals("ChongXiaoXiRuKu"))
            {
                data.Param["DETAILNO"] = DaoTool.Seq(dao, "LKEQ.SEQEQINDETAIL");
                data.Param["INID"]     = InIdCXHelp;
                if (DaoTool.Save(dao, OptContent.get("SaveEQInDetail"), data) < 0)
                {
                    throw new Exception("插入冲销细表失败!" + dao.ErrMsg);
                }
                msg = "执行成功!";
                return("ok");
            }



            else
            {
                msg = "系统出错,请与管理人员联系!";
                return("ok");
            }
        }
예제 #2
0
        public object Run(YiTian.db.Dao dao, YtService.data.OptData data, out string msg)
        {
            //SysValueManag
            if (data.Sql == null)
            {
                throw new Exception("Sql内容为空!");
            }
            else if (data.Sql.Equals("Del"))
            {
                int count = DaoTool.ExecuteScalar(dao, OptContent.get("InOutIsSy"), data).ToInt();
                if (count > 0)
                {
                    // throw new Exception("此入出类型已经被系统使用,不能删除!");
                    msg = "此入出类型已经被系统使用,不能删除!";
                    return("ok");
                }

                if (DaoTool.ExecuteNonQuery(dao, OptContent.get("DelInOutInfo"), data) < 0)
                {
                    throw new Exception("删除此入出类型失败!");
                }
                msg = "此入出类型已删除!";
                return("ok");
            }
            else if (data.Sql.Equals("Add"))
            {
                Opt op = OptContent.get("SaveInOutInfo");
                data.Param["IOID"]    = DaoTool.Seq(dao, "LKWZ.SEQWZIO");;
                data.Param["RECDATE"] = DateTime.Now;
                if (data.Param["IFDEFAULT"] != null && data.Param["IFDEFAULT"].ToString() == "1")
                {
                    dao.ExecuteNonQuery("update LKWZ.DICTWZINOUT set IFDEFAULT=0 where CHOSCODE='" + data.Param["CHOSCODE"].ToString() + "' and IOFALG=" + data.Param["IOFLAG"].ToString() + " and OPFLAG=" + data.Param["OPFLAG"].ToString());
                }
                if (DaoTool.Save(dao, op, data) > -1)
                {
                    msg = "统计类别添加成功!";
                    return("ok");
                }
                else
                {
                    throw new Exception("统计类别添加失败!" + dao.ErrMsg);
                }
            }
            else if (data.Sql.Equals("Update"))
            {
                Opt op = OptContent.get("SaveInOutInfo");
                data.Param["RECDATE"] = DateTime.Now;
                if (data.Param["IFDEFAULT"] != null && data.Param["IFDEFAULT"].ToString() == "1")
                {
                    dao.ExecuteNonQuery("update LKWZ.DICTWZINOUT set IFDEFAULT=0 where CHOSCODE='" + data.Param["CHOSCODE"].ToString() + "'");
                }
                if (DaoTool.Update(dao, op, data) > -1)
                {
                    msg = "统计类别更新成功!";
                    return("ok");
                }
                else
                {
                    throw new Exception("统计类别更新失败!" + dao.ErrMsg);
                }
            }
            else if (data.Sql.Equals("TingYong"))
            {
                Opt op = OptContent.get("SetInOutUnUsed");
                if (DaoTool.ExecuteNonQuery(dao, op, data) != 1)
                {
                    throw new Exception("停用失败!" + dao.ErrMsg);
                }

                msg = "此入出类型停用成功!";
                return("ok");
            }
            else if (data.Sql.Equals("QiYong"))
            {
                Opt op = OptContent.get("SetInOutUsed");
                if (DaoTool.ExecuteNonQuery(dao, op, data) != 1)
                {
                    throw new Exception("启用失败!" + dao.ErrMsg);
                }

                msg = "此入出类型启用成功!";
                return("ok");
            }
            else if (data.Sql.Equals("Copy"))
            {
                int count = DaoTool.ExecuteScalar(dao, OptContent.get("CheckInOutIsNull"), data).ToInt();
                if (count == 0)
                {
                    DataTable dt = DaoTool.FindDT(dao, OptContent.get("FindInOutCcode0"), data);
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        foreach (DataRow r in dt.Rows)
                        {
                            data.Param["IOID"]         = DaoTool.Seq(dao, "LKWZ.SEQWZIO");
                            data.Param["IONAME"]       = r["IONAME"];
                            data.Param["PYCODE"]       = r["PYCODE"];
                            data.Param["WBCODE"]       = r["WBCODE"];
                            data.Param["IFUSE"]        = r["IFUSE"];
                            data.Param["RECIPECODE"]   = r["RECIPECODE"];
                            data.Param["RECIPELENGTH"] = r["RECIPELENGTH"];
                            data.Param["RECIPEYEAR"]   = r["RECIPEYEAR"];
                            data.Param["RECIPEMONTH"]  = r["RECIPEMONTH"];
                            data.Param["MEMO"]         = r["MEMO"];
                            data.Param["IOFLAG"]       = r["IOFLAG"];
                            data.Param["USEST"]        = r["USEST"];
                            data.Param["USEND"]        = r["USEND"];
                            data.Param["USERD"]        = r["USERD"];
                            data.Param["OPFLAG"]       = r["OPFLAG"];
                            data.Param["IFDEFAULT"]    = r["IFDEFAULT"];
                            data.Param["RECDATE"]      = DateTime.Now;
                            if (DaoTool.Save(dao, OptContent.get("SaveInOutInfo"), data) != 1)
                            {
                                throw new Exception("复制失败,!" + dao.ErrMsg);
                            }
                        }
                    }

                    msg = "复制成功!";
                    return("ok");
                }
                else
                {
                    msg = "已存在本医疗结构的出入类型,复制失败!";
                    return("ok");
                }
            }
            else if (data.Sql.Equals("Find"))
            {
                msg = "查找成功!";
                return("ok");
            }
            msg = "成功!";
            return("ok");
        }
예제 #3
0
        public object Run(YiTian.db.Dao dao, YtService.data.OptData data, out string msg)
        {
            #region 前期的一些绑定
            if (data.Sql == null)
            {
                msg = "缺省SQL参数,无法再服务端进行操作!";
                return("ok");
            }
            if (data.Sql != null && data.Sql.Equals("BindWareName"))
            {
                msg = "绑定成功";
                return(DaoTool.FindDT(dao, OptContent.get("FindWareNameInEQDiaoBo"), data));
            }

            if (data.Sql != null && data.Sql.Equals("BindOutName"))
            {
                msg = "绑定成功";
                return(DaoTool.FindDT(dao, OptContent.get("FindOutNameInEQDiaoBo"), data));
            }
            if (data.Sql != null && data.Sql.Equals("BindUnitCode"))
            {
                msg = "绑定成功";
                return(DaoTool.FindDT(dao, OptContent.get("FindUnitNameInEQDiaoBo"), data));
            }
            if (data.Sql != null && data.Sql.Equals("BindEQIDInfo"))
            {
                msg = "绑定成功";
                return(DaoTool.FindDT(dao, OptContent.get("FindEQIdNameInEQDiaoBo"), data));
            }

            //包含 提交审核与软删除
            if (data.Sql != null && data.Sql == "SubmitShenHeOrDel")
            {
                if (DaoTool.ExecuteNonQuery(dao, OptContent.get("submitShenHeInfo"), data) < 0)
                {
                    throw new Exception("更改设备调拨的审核状态信息失败!");
                }
                msg = "执行成功!";
                return("ok");
            }

            #endregion

            //对主表的操作
            if (data.Sql != null && data.Sql.Equals("ModifyZhuOrAdd"))
            {
                //1、对OUTMAIN进行更新操作
                if (data.Param["RECIPECODE"] == null || data.Param["RECIPECODE"].ToString() == "")
                {
                    DataTable dt = DaoTool.FindDT(dao, OptContent.get("GetRecipeCodeInEQOutInfo"), data);
                    if (dt.Rows.Count <= 0 || dt == null)
                    {
                        throw new Exception("无法查找到单据前缀,是否调拨方式数据错误" + dao.ErrMsg);
                    }
                    DataRow row = dt.Rows[0];
                    data.Param["RECIPECODE"] = Recipecode(row["RECIPECODE"].ToString(), Convert.ToInt32(row["RECIPEYEAR"]), Convert.ToInt32(row["RECIPEMONTH"]), Convert.ToInt32(row["RECIPELENGTH"]));
                    data.Param.Add("RECIPECODEHelp", data.Param["RECIPECODE"].ToString() + "%");
                    data.Param["RECIPECODE"] = data.Param["RECIPECODE"] + DaoTool.ExecuteScalar(dao, OptContent.get("GetrecipeCodeNo"), data).ToInt().ToString("D2");
                }

                if (data.Param["OUTID"] == null || data.Param["OUTID"].ToString() == "")
                {
                    data.Param["OUTID"] = DaoTool.Seq(dao, "LKEQ.SEQEQOut");
                    OutIdHelp           = data.Param["OUTID"].ToString();
                    if (DaoTool.Save(dao, OptContent.get("ModifyOutMainInfo"), data) < 0)
                    {
                        msg = "执行失败!";
                        throw new Exception("新增设备调拨的主表信息失败!" + dao.ErrMsg);
                    }
                    SaveDiaoBoXiInfo(dao, data);
                    msg = "执行成功!";
                    return("ok");
                }
                if (DaoTool.Update(dao, OptContent.get("ModifyOutMainInfo"), data) < 0)
                {
                    msg = "执行失败!";
                    throw new Exception("修改设备调拨的主表信息失败!" + dao.ErrMsg);
                }
                SaveDiaoBoXiInfo(dao, data);
                msg = "执行成功!";
                return("ok");
            }



            // ModifyOrAddXi
            if (data.Sql.Equals("ModifyOrAddXi"))
            {
                //如果出库ID为空的话  肯定是新增操作
                if (data.Param["OUTID"].ToString().Trim() == "" || data.Param["OUTID"] == null)
                {
                    data.Param["OUTID"]    = OutIdHelp;
                    data.Param["DETAILNO"] = DaoTool.Seq(dao, "LKEQ.SEQEQOutDetail");
                    if (DaoTool.Save(dao, OptContent.get("ModifyOutXiBiaoInfo"), data) < 0)
                    {
                        throw new Exception("修改设备调拨的出库细表失败!" + dao.ErrMsg);
                    }
                    msg = "执行成功!";
                    return("ok");
                }
                else
                {
                    if (data.Param["DETAILNO"] == null || data.Param["DETAILNO"].ToString().Trim() == "")
                    {
                        //该行为新增的数据  新增完之后返回
                        data.Param["DETAILNO"] = DaoTool.Seq(dao, "LKEQ.SEQEQOutDetail");
                        if (DaoTool.Save(dao, OptContent.get("ModifyOutXiBiaoInfo"), data) < 0)
                        {
                            msg = "执行失败!";
                            throw new Exception("修改设备调拨的出库细表失败!" + dao.ErrMsg);
                        }
                        msg = "执行成功!";
                        return("ok");
                    }
                    if (DaoTool.Update(dao, OptContent.get("ModifyOutXiBiaoInfo"), data) < 0)
                    {
                        msg = "执行失败!";
                        throw new Exception("修改设备调拨的出库细表失败!" + dao.ErrMsg);
                    }
                    msg = "执行成功!";
                    //能够retrun ok 说明 要么是前面新增的对了,要么是后面的修改正确,不然都是throw出去
                    return("ok");
                }
            }

            if (data.Sql != null && data.Sql.Equals("ShenHeOutEQInfo"))
            {
                if (DaoTool.ExecuteNonQuery(dao, OptContent.get("ShenHeEQOutAndDetailInfo"), data) > 0)
                {
                    msg = "执行成功!";
                    return("ok");
                }
                else
                {
                    msg = "执行失败!";
                    throw new Exception("审核过程中,数据库操作失败!" + dao.ErrMsg);
                }
            }

            if (data.Sql.Equals("SendOutId"))
            {
                OutId = data.Param["OUTID"].ToString();
                msg   = "执行成功!";
                return("ok");
            }



            //===================================审核部分===============================

            //入库主表
            if (data.Sql != null && data.Sql.Equals("InsertInMain"))
            {
                data.Param["INID"] = DaoTool.Seq(dao, "LKEQ.SEQEQIN");

                InIdHelp = data.Param["INID"].ToString();
                DataTable dt = DaoTool.FindDT(dao, OptContent.get("GetRecipeCodeInEQOutInfo"), data);
                if (dt.Rows.Count <= 0 || dt == null)
                {
                    throw new Exception("无法查找到单据前缀,是否调拨方式数据错误" + dao.ErrMsg);
                }
                DataRow row = dt.Rows[0];
                data.Param["RECIPECODE"] = Recipecode(row["RECIPECODE"].ToString(), Convert.ToInt32(row["RECIPEYEAR"]), Convert.ToInt32(row["RECIPEMONTH"]), Convert.ToInt32(row["RECIPELENGTH"]));
                data.Param.Add("RECIPECODEHelp", data.Param["RECIPECODE"].ToString() + "%");
                data.Param["RECIPECODE"] = data.Param["RECIPECODE"] + DaoTool.ExecuteScalar(dao, OptContent.get("GetrecipeCodeNo"), data).ToInt().ToString("D2");

                //一次审核,只生成一次入库主表的单据号
                RecipeCodeInMain = data.Param["RECIPECODE"].ToString();

                if (DaoTool.Save(dao, OptContent.get("SaveEQInMainInfoCX"), data) < 0)
                {
                    throw new Exception("入库主表信息执行失败" + dao.ErrMsg);
                }
                //记得更新对应出库主表的INID
                dao.ExecuteNonQuery("UPDATE LKEQ.EQOUTMAIN SET INID=" + data.Param["INID"].ToString() + " WHERE CHOSCODE=" + data.Param["CHOSCODE"] + "  AND OUTID=" + OutId);
                msg = "执行成功!";
                return("ok");
            }


            //库存主表   可能不会执行  【只有在库存主表,不存在该设备的信息】
            if (data.Sql != null && data.Sql.Equals("InsertStockMain"))
            {
                data.Param["STOCKID"] = DaoTool.Seq(dao, "LKEQ.SEQEQSTOCK");
                //在每执行一次对库存总表的插入,都会更新一次stockid,否则,就是针对一个stockid的插入流水了
                StockId = data.Param["STOCKID"].ToString();

                if (DaoTool.Save(dao, OptContent.get("SaveEQStock"), data) < 0)
                {
                    throw new Exception("库存主表信息执行失败!" + dao.ErrMsg);
                }
                msg = "执行成功!";
                return("ok");
            }

            //库存流水
            if (data.Sql != null && data.Sql.Equals("InsertStockDetail"))
            {
                data.Param["FLOWNO"]     = DaoTool.Seq(dao, "LKEQ.SEQEQSTOCKDETAIL");
                StockFlowNo              = data.Param["FLOWNO"].ToString();
                data.Param["RECIPECODE"] = RecipeCodeInMain;
                if (data.Param["STOCKID"] == null || data.Param["STOCKID"].ToString() == "")
                {
                    data.Param["STOCKID"] = StockId;//在客户端已经经过了判断,要么存在,要么不存在就是库存总表进行了新的插入,直接获取
                }

                if (DaoTool.Save(dao, OptContent.get("SaveEQStockDetail"), data) < 0)
                {
                    throw new Exception("库存流水信息执行失败!" + dao.ErrMsg);
                }
                msg = "执行成功!";
                return("ok");
            }

            //入库细表
            if (data.Sql != null && data.Sql.Equals("InsertEQInDetail"))
            {
                data.Param["DETAILNO"]    = DaoTool.Seq(dao, "LKEQ.SEQEQINDETAIL");
                data.Param["STOCKFLOWNO"] = StockFlowNo.ToString();
                data.Param["INID"]        = InIdHelp;
                if (DaoTool.Save(dao, OptContent.get("SaveEQInDetail"), data) < 0)
                {
                    throw new Exception("入库细表信息执行失败!" + dao.ErrMsg);
                }
                msg = "执行成功!";
                return("ok");
            }



            //=================================关于冲销的操作==========================

            //原始数据的状态更改
            if (data.Sql != null && data.Sql.Equals("ChongXiaoRuChu"))
            {
                if (DaoTool.ExecuteNonQuery(dao, OptContent.get("ChongXiaoChuKuStatusChange"), data) < 0)
                {
                    throw new Exception("修改出库主表冲销状态失败!" + dao.ErrMsg);
                }
                data.Param.Add("INID", dao.Es("SELECT INID FROM LKEQ.EQOUTMAIN WHERE OUTID=" + data.Param["OUTID"].ToString()).ToString());
                if (DaoTool.ExecuteNonQuery(dao, OptContent.get("ChongXiaoRuKuStatusChange"), data) < 0)
                {
                    throw new Exception("修改入库主表冲销状态失败!" + dao.ErrMsg);
                }
                msg = "执行成功!";
                return("ok");
            }

            //插入出库主表
            if (data.Sql != null && data.Sql.Equals("ChongXiaoZhuChuKu"))
            {
                data.Param["OUTID"] = DaoTool.Seq(dao, "LKEQ.SEQEQOut");
                OutIdCX             = data.Param["OUTID"].ToString();
                if (DaoTool.Save(dao, OptContent.get("ModifyOutMainInfo"), data) < 0)
                {
                    throw new Exception("插入冲销出库主表失败!" + dao.ErrMsg);
                }
                msg = "执行成功!";
                return("ok");
            }

            //出库细表
            if (data.Sql != null && data.Sql.Equals("ChongXiaoXiChuKu"))
            {
                data.Param["DETAILNO"] = DaoTool.Seq(dao, "LKEQ.SEQEQOutDetail");
                data.Param["OUTID"]    = OutIdCX;
                if (DaoTool.Save(dao, OptContent.get("ModifyOutXiBiaoInfo"), data) < 0)
                {
                    throw new Exception("插入冲销出库细表失败!" + dao.ErrMsg);
                }
                msg = "执行成功!";
                return("ok");
            }

            //入库主表
            if (data.Sql != null && data.Sql.Equals("ChongXiaoZhuRuKu"))
            {
                data.Param["INID"] = DaoTool.Seq(dao, "LKEQ.SEQEQIN");
                InIdCX             = data.Param["INID"].ToString();
                if (DaoTool.Save(dao, OptContent.get("SaveEQInMainInfoCX"), data) < 0)
                {
                    throw new Exception("插入冲销入库主表失败!" + dao.ErrMsg);
                }

                dao.ExecuteNonQuery("UPDATE LKEQ.EQOUTMAIN SET INID=" + data.Param["INID"].ToString() + "  WHERE CHOSCODE= " + data.Param["CHOSCODE"].ToString() + "  AND OUTID=" + OutIdCX);
                msg = "执行成功!";
                return("ok");
            }

            //入库细表

            if (data.Sql != null && data.Sql.Equals("ChongXiaoXiRuKu"))
            {
                data.Param["DETAILNO"] = DaoTool.Seq(dao, "LKEQ.SEQEQINDETAIL");
                data.Param["INID"]     = InIdCX;
                if (DaoTool.Save(dao, OptContent.get("SaveEQInDetail"), data) < 0)
                {
                    throw new Exception("插入冲销细表失败!" + dao.ErrMsg);
                }
                msg = "执行成功!";
                return("ok");
            }

            else
            {
                msg = "系统错误,请与管理员进行联系!";
                return("ok");
            }
        }
예제 #4
0
        public object Run(YiTian.db.Dao dao, YtService.data.OptData data, out string msg)
        {
            if (data.Sql != null && data.Sql.Equals("TingYong"))
            {
                if (DaoTool.ExecuteNonQuery(dao, OptContent.get("QiTingEQInOutInfo_EQInOutManag"), data) > 0)
                {
                    msg = "停用该条设备入出库记录成功!";
                    return("ok");
                }
                else
                {
                    throw new Exception("停用该条设备入出库信息失败!" + dao.ErrMsg);
                }
            }


            if (data.Sql != null && data.Sql.Equals("QiYong"))
            {
                if (DaoTool.ExecuteNonQuery(dao, OptContent.get("QiTingEQInOutInfo_EQInOutManag"), data) > 0)
                {
                    msg = "启用该条设备入出库记录成功!";
                    return("ok");
                }
                else
                {
                    throw new Exception("启用该条设备入出库记录失败!" + dao.ErrMsg);
                }
            }


            if (data.Sql != null && data.Sql.Equals("Del"))
            {
                if (DaoTool.ExecuteScalar(dao, OptContent.get("IfHaveUseEQInOut"), data).ToInt() > 0)
                {
                    msg = "该条设备入出库记录已被使用,无法删除!";
                    return("ok");
                }
                if (DaoTool.ExecuteNonQuery(dao, OptContent.get("DelEQInOutInfo_EQInOutManag"), data) > 0)
                {
                    msg = "删除该条设备入出库记录成功!";
                    return("ok");
                }
                else
                {
                    throw new Exception("删除该条设备入出库记录失败!" + dao.ErrMsg);
                }
            }


            //----------------------------------这里的代码有些重复,有时间再进行复用操作【关键是msg 这里怎么办?】-------------------------------


            if (data.Sql != null && data.Sql.Equals("Modify"))
            {
                //惯例: 名称是否重复 // 相同的医疗机构编码、入出标志、操作标志的记录里,只能有一条记录的该值为1
                if (DaoTool.ExecuteScalar(dao, OptContent.get("IsHaveRepeatInOutName"), data).ToInt() > 0)
                {
                    msg = "存在相同的设备入出库名称,请修改后再进行操作";
                    return("ok");
                }
                //MessageBox.Show("执行到修改2");
                if (data.Param["IFDEFAULT"].ToString() == "1" && DaoTool.ExecuteScalar(dao, OptContent.get("IsHaveMoreDefault_EQInOutManag"), data).ToInt() > 0)
                {
                    msg = "相同的医疗机构编码、入出标志、操作标志的记录里,只能有一条记录的默认值为是!";
                    return("ok");
                }
                //MessageBox.Show("执行到修改3");
                //验证:对于一个医疗机构来说,其操作类别为(1:调拨;2:申领;3:盘点)的出入库类型记录
                //其入库和出库的类型记录,分别各有且只能有一条记录;
                //如医疗机构甲,其调拨的入库方式,只能有一种方式,其调拨的出库方式,也只能有一种方式;
                if (data.Param["OPFLAG"].ToString() != "0" && DaoTool.ExecuteScalar(dao, OptContent.get("IsSingleInOutOfCHOS"), data).ToInt() > 0)
                {
                    //针对1,2,3
                    msg = "操作为调拨,申领,盘点的记录,其出库与入库的记录只能各有一条,请修改后再进行操作";
                    return("ok");
                }
                //MessageBox.Show("执行到修改4");

                if (DaoTool.Update(dao, OptContent.get("SaveEQInOutInfo"), data) < 0)
                {
                    throw new Exception("修改该条设备入出库记录失败!");
                }
                msg = "修改该条设备入出库记录成功!";
                return("ok");
            }



            if (data.Sql != null && data.Sql.Equals("Add"))
            {
                //首先设置好ID:
                data.Param["IOID"] = DaoTool.Seq(dao, "LKEQ.SEQEQIO");

                //验证是否重名
                if (DaoTool.ExecuteScalar(dao, OptContent.get("IsHaveRepeatInOutName"), data).ToInt() > 0)
                {
                    msg = "存在相同的设备入出库名称,请修改后再进行操作";
                    return("ok");
                }

                if (data.Param["IFDEFAULT"].ToString() == "1" && DaoTool.ExecuteScalar(dao, OptContent.get("IsHaveMoreDefault_EQInOutManag"), data).ToInt() > 0)
                {
                    msg = "相同的医疗机构编码、入出标志、操作标志的记录里,只能有一条记录的默认值为是!";
                    return("ok");
                }
                if (data.Param["OPFLAG"].ToString() != "0" && DaoTool.ExecuteScalar(dao, OptContent.get("IsSingleInOutOfCHOS"), data).ToInt() > 0)
                {
                    //针对1,2,3
                    msg = "操作为调拨,申领,盘点的记录,其出库与入库的记录只能各有一条,请修改后再进行操作";
                    return("ok");
                }
                if (DaoTool.Save(dao, OptContent.get("SaveEQInOutInfo"), data) < 0)
                {
                    throw new Exception("新增设备入出库记录失败!");
                }
                msg = "新增设备入出库记录成功!";
                return("ok");
            }

            if (data.Sql != null && data.Sql.Equals("CopyChoscodeData"))
            {
                //验证本机构是否包含数据
                int count = DaoTool.ExecuteScalar(dao, OptContent.get("IsHaveAnyDataEQInOut_EQInOutManag"), data).ToInt();
                if (count == 0)
                {
                    DataTable dt = DaoTool.FindDT(dao, OptContent.get("FindEQInOutcode0_EQInOutManag"), data);
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        foreach (DataRow r in dt.Rows)
                        {
                            int statuscode_int = DaoTool.ExecuteScalar(dao, OptContent.get("GetEQInOutIDMax"), data).ToInt() + 1;
                            data.Param["IOID"]         = DaoTool.Seq(dao, "LKEQ.SEQEQIO");
                            data.Param["IONAME"]       = r["IONAME"];
                            data.Param["PYCODE"]       = r["PYCODE"];
                            data.Param["WBCODE"]       = r["WBCODE"];
                            data.Param["IFUSE"]        = r["IFUSE"];
                            data.Param["RECIPECODE"]   = r["RECIPECODE"];
                            data.Param["RECIPELENGTH"] = r["RECIPELENGTH"];
                            data.Param["RECIPEYEAR"]   = r["RECIPEYEAR"];
                            data.Param["RECIPEMONTH"]  = r["RECIPEMONTH"];
                            data.Param["MEMO"]         = r["MEMO"];
                            data.Param["IOFLAG"]       = r["IOFLAG"];
                            data.Param["OPFLAG"]       = r["OPFLAG"];
                            data.Param["IFDEFAULT"]    = r["IFDEFAULT"];
                            data.Param["RECDATE"]      = DateTime.Now;
                            if (DaoTool.Save(dao, OptContent.get("SaveEQInOutInfo"), data) < 0)
                            {
                                throw new Exception("复制失败!" + dao.ErrMsg);
                            }
                        }
                    }
                    msg = "复制成功!";
                    return("ok");
                }
                else
                {
                    msg = "已存在本医疗结构的出入类型,复制失败!";
                    return("ok");
                }
            }
            else
            {
                msg = "系统故障,请与管理员联系!";
                return("ok");
            }
        }
예제 #5
0
파일: EQKind.cs 프로젝트: yuonceruyi/LKEQ
        public object Run(Dao dao, YtService.data.OptData data, out string msg)
        {
            msg = "设备信息";
            Dictionary <string, object> pa = new Dictionary <string, object>();
            string  ac = data.Sql;
            ObjItem obj;
            object  OBJ;

            if ("SaveEQKindInfo".Equals(ac))
            {
                pa["KINDNAME"] = data.Param["KINDNAME"].ToString();
                pa["USERNAME"] = data.Param["USERNAME"].ToString();
                pa["IFUSE"]    = Convert.ToDecimal(data.Param["IFUSE"]);
                pa["RECDATE"]  = DateTime.Now;
                pa["CHOSCODE"] = data.Param["CHOSCODE"].ToString();
                pa["USERID"]   = Convert.ToDecimal(data.Param["USERID"]);
                pa["IFEND"]    = Convert.ToDecimal(data.Param["IFEND"]);

                if (data.Param["PREFIX"] != null)
                {
                    pa["PREFIX"] = data.Param["PREFIX"].ToString();
                }
                else
                {
                    pa["PREFIX"] = null;
                }
                if (data.Param["MEMO"] != null)
                {
                    pa["MEMO"] = data.Param["MEMO"].ToString();
                }
                else
                {
                    pa["MEMO"] = null;
                }
                if (data.Param["PYCODE"] != null)
                {
                    pa["PYCODE"] = data.Param["PYCODE"].ToString();
                }
                else
                {
                    pa["PYCODE"] = null;
                }
                if (data.Param["WBCODE"] != null)
                {
                    pa["WBCODE"] = data.Param["WBCODE"].ToString();
                }
                else
                {
                    pa["WBCODE"] = null;
                }
                pa["SUPERCODE"] = data.Param["SUPERCODE"].ToString();
                pa["KINDCODE"]  = data.Param["KINDCODE"].ToString();

                Opt cfmx = OptContent.get("EQKindSave");

                Opt cop_Name = OptContent.get("CompareEQKindName");
                Opt cop_Code = OptContent.get("CompareEQKindCode");

                Opt changeUpCodesIfEnd = OptContent.get("changeUpCodesIfEnd");

                obj = DaoTool.ExecuteScalar(dao, cop_Name, pa);
                if (!obj.IsNull)
                {
                    msg = "名称重复!";
                    return("ok");
                }

                if (DaoTool.Save(dao, cfmx, pa) < 0)
                {
                    throw new Exception("添加设备信息失败!");
                }
                if (DaoTool.ExecuteNonQuery(dao, changeUpCodesIfEnd, pa) < 0)
                {
                    throw new Exception("修改上级是否末阶段失败!");
                }
                msg = "添加成功!";
                return("ok");
            }
            if ("UpdataEQKindInfo".Equals(ac))
            {
                pa["KINDNAME"] = data.Param["KINDNAME"].ToString();
                pa["USERNAME"] = data.Param["USERNAME"].ToString();
                pa["IFUSE"]    = Convert.ToDecimal(data.Param["IFUSE"]);
                pa["RECDATE"]  = DateTime.Now;
                pa["CHOSCODE"] = data.Param["CHOSCODE"].ToString();
                pa["USERID"]   = Convert.ToDecimal(data.Param["USERID"]);
                pa["IFEND"]    = Convert.ToDecimal(data.Param["IFEND"]);

                if (data.Param["PREFIX"] != null)
                {
                    pa["PREFIX"] = data.Param["PREFIX"].ToString();
                }
                else
                {
                    pa["PREFIX"] = null;
                }
                if (data.Param["MEMO"] != null)
                {
                    pa["MEMO"] = data.Param["MEMO"].ToString();
                }
                else
                {
                    pa["MEMO"] = null;
                }
                if (data.Param["PYCODE"] != null)
                {
                    pa["PYCODE"] = data.Param["PYCODE"].ToString();
                }
                else
                {
                    pa["PYCODE"] = null;
                }
                if (data.Param["WBCODE"] != null)
                {
                    pa["WBCODE"] = data.Param["WBCODE"].ToString();
                }
                else
                {
                    pa["WBCODE"] = null;
                }
                pa["SUPERCODE"]  = data.Param["SUPERCODE"].ToString();
                pa["KINDCODE"]   = data.Param["KINDCODE"].ToString();
                pa["SELECTCODE"] = data.Param["SELECTCODE"].ToString();
                Opt Updatacop_Name     = OptContent.get("UpdataCompareEQKindName");
                Opt Updatacop_Code     = OptContent.get("CompareEQKindCode");
                Opt Updatacop_UpCode   = OptContent.get("CompareEQKindUpCode");
                Opt WZKindUpdata       = OptContent.get("EQKindUpdata");
                Opt changeUpCodesIfEnd = OptContent.get("changeUpCodesIfEnd");

                obj = DaoTool.ExecuteScalar(dao, Updatacop_Name, pa);
                if (!obj.IsNull)
                {
                    msg = "名称重复!";
                    return("ok");
                }
                if (DaoTool.ExecuteNonQuery(dao, WZKindUpdata, pa) < 0)
                {
                    throw new Exception("修改设备信息失败!");
                }
                if (DaoTool.ExecuteNonQuery(dao, changeUpCodesIfEnd, pa) < 0)
                {
                    throw new Exception("修改上级末节点失败!");
                }
                msg = "修改成功!";
                return("ok");
            }

            if ("DelEQKindInfo".Equals(ac))
            {
                pa["CHOSCODE"]  = data.Param["CHOSCODE"].ToString();
                pa["KINDCODE"]  = data.Param["KINDCODE"].ToString();
                pa["SUPERCODE"] = data.Param["SUPERCODE"].ToString();

                Opt del      = OptContent.get("EQKinddel");
                Opt del_Find = OptContent.get("EQKinddel_Find");

                Opt ifhavechildren     = OptContent.get("ifhavechildren");
                Opt changeUpCodesIsEnd = OptContent.get("changeUpCodesIsEnd");
                //if (DaoTool.ExecuteNonQuery(dao, del_Find, pa) < 0)//是否使用过
                //   throw new Exception("使用过只能停用不能删除!");
                OBJ = DaoTool.ExecuteScalar(dao, del_Find, pa).Get();
                //if (Convert.ToInt32(OBJ) == 1)
                //    throw new Exception("使用过只能停用不能删除!");

                if (DaoTool.ExecuteNonQuery(dao, del, pa) < 0)
                {
                    throw new Exception("删除设备成功!");
                }

                if (DaoTool.ExecuteScalar(dao, ifhavechildren, pa).IsNull)
                {
                    if (DaoTool.ExecuteNonQuery(dao, changeUpCodesIsEnd, pa) < 0)
                    {
                        throw new Exception("修改上级末节点失败!");
                    }
                }

                msg = "删除成功!";
                return("ok");
            }
            if ("StartEQKindInfo".Equals(ac))
            {
                pa["CHOSCODE"] = data.Param["CHOSCODE"].ToString();
                pa["KINDCODE"] = data.Param["KINDCODE"].ToString();
                Opt stop = OptContent.get("StartorStopEQKindInfo");
                pa["IFUSE"] = 1;
                if (DaoTool.ExecuteNonQuery(dao, stop, pa) < 0)
                {
                    throw new Exception("启用设备失败!");
                }
                msg = "启用设备成功!";
                return("ok");
            }
            if ("StopEQKindInfo".Equals(ac))
            {
                pa["CHOSCODE"] = data.Param["CHOSCODE"].ToString();
                pa["KINDCODE"] = data.Param["KINDCODE"].ToString();
                Opt start   = OptContent.get("StartorStopEQKindInfo");
                Opt canstop = OptContent.get("CanStopEQKindInfo");
                pa["IFUSE"] = 0;
                //if (DaoTool.ExecuteNonQuery(dao, del_Find, pa) < 0)//是否使用过
                //    throw new Exception("使用过只能停用不能删除!");
                OBJ = DaoTool.ExecuteScalar(dao, canstop, pa).Get();
                if (Convert.ToInt32(OBJ) == 0)
                {
                    throw new Exception("不是末节点不能停用!");
                }
                if (DaoTool.ExecuteNonQuery(dao, start, pa) < 0)
                {
                    throw new Exception("启用设备失败!");
                }
                msg = "停用设备成功!";
                return("ok");
            }
            if ("CopyEQKindInfo".Equals(ac))
            {
                Opt       Copy = OptContent.get("CopyEQKindInfo");
                Opt       cfmx = OptContent.get("EQKindSave");
                DataTable dt   = DaoTool.FindDT(dao, Copy, data);
                foreach (DataRow dr in dt.Rows)
                {
                    if (dr["KINDNAME"] != null)
                    {
                        pa["KINDNAME"] = dr["KINDNAME"].ToString();
                    }
                    else
                    {
                        pa["KINDNAME"] = null;
                    }


                    if (dr["PYCODE"] != null)
                    {
                        pa["PYCODE"] = dr["PYCODE"].ToString();
                    }
                    else
                    {
                        pa["PYCODE"] = null;
                    }


                    if (dr["USERNAME"] != null)
                    {
                        pa["USERNAME"] = dr["USERNAME"].ToString();
                    }
                    else
                    {
                        pa["USERNAME"] = null;
                    }

                    if (dr["MEMO"] != null)
                    {
                        pa["MEMO"] = dr["MEMO"].ToString();
                    }
                    else
                    {
                        pa["MEMO"] = null;
                    }
                    pa["IFUSE"]    = Convert.ToDecimal(dr["IFUSE"]);
                    pa["RECDATE"]  = Convert.ToDateTime(dr["RECDATE"]);
                    pa["CHOSCODE"] = data.Param["CHOSCODE"].ToString();
                    pa["USERNAME"] = dr["USERNAME"].ToString();
                    pa["USERID"]   = dr["USERID"].ToString();
                    pa["IFEND"]    = Convert.ToDecimal(dr["IFEND"]);

                    pa["SUPERCODE"] = dr["SUPERCODE"].ToString();
                    pa["KINDCODE"]  = dr["KINDCODE"].ToString();
                    DaoTool.Save(dao, cfmx, pa);
                }
                msg = "复制成功!";
                return("ok");
            }
            return("ok");
        }