public static string getaddcont(string napecode)
        {
            string ret = "";

            if (Com.Session.userid == null)
            {
                ret = "expire";
            }
            else
            {
                retprompt retobj = new retprompt();
                if (napecode == "prd")//學段
                {
                    SchSystem.BLL.SysPer spBll = new SchSystem.BLL.SysPer();
                    DataTable            dt    = spBll.GetList("'0' pId,PerName name,PerCode id", "Stat=1 order by convert(int,PerCode)").Tables[0];
                    retobj.retxt  = napecode;
                    retobj.retobj = dt;
                    ret           = Newtonsoft.Json.JsonConvert.SerializeObject(retobj);
                }
                else if (napecode == "grd")//年級
                {
                    SchSystem.BLL.SysGrade spBll = new SchSystem.BLL.SysGrade();
                    DataTable dt = spBll.GetList("'0' pId,GradeName name,GradeCode id", "").Tables[0];
                    retobj.retxt  = napecode;
                    retobj.retobj = dt;
                    ret           = Newtonsoft.Json.JsonConvert.SerializeObject(retobj);
                }
                else if (napecode == "sub")//科目
                {
                    SchSystem.BLL.SysSub spBll = new SchSystem.BLL.SysSub();
                    DataTable            dt    = spBll.GetList("'0' pId,SubName name,SubCode id", "Stat=1 Order by SubCode").Tables[0];
                    retobj.retxt  = napecode;
                    retobj.retobj = dt;
                    ret           = Newtonsoft.Json.JsonConvert.SerializeObject(retobj);
                }
                else if (napecode == "utp")//角色
                {
                    SchSystem.BLL.SysUType spBll = new SchSystem.BLL.SysUType();
                    DataTable dt = spBll.GetList("'0' pId,UTypeName name,UTypeCOde id", "Stat=1").Tables[0];
                    retobj.retxt  = napecode;
                    retobj.retobj = dt;
                    ret           = Newtonsoft.Json.JsonConvert.SerializeObject(retobj);
                }
                else if (napecode == "mat")//教版
                {
                    SchSystem.BLL.SysMater spBll = new SchSystem.BLL.SysMater();
                    DataTable dt = spBll.GetList("'0' pId,MaterName name,MaterCode id", "Stat=1").Tables[0];
                    retobj.retxt  = napecode;
                    retobj.retobj = dt;
                    ret           = Newtonsoft.Json.JsonConvert.SerializeObject(retobj);
                }
                else
                {
                    retobj.retxt  = napecode;
                    retobj.retobj = "";
                    ret           = Newtonsoft.Json.JsonConvert.SerializeObject(retobj);
                }
            }
            return(ret);
        }
Example #2
0
        public static string getServFunc(string ordpack)
        {
            string ret = "";

            if (Com.Session.userid == null)
            {
                ret = "expire";
            }
            else
            {
                retprompt retobj = new retprompt();
                //根據套餐代碼查詢功能代碼
                SchSystem.BLL.ServBus sbBll = new SchSystem.BLL.ServBus();
                string funcstr = sbBll.GetList("FuncStr", "ServiceId='" + ordpack + "'").Tables[0].Rows[0]["FuncStr"].ToString();
                string funcs   = "";
                if (!string.IsNullOrEmpty(funcstr))
                {
                    string[] funcstrarr = funcstr.Split(',');
                    foreach (string str in funcstrarr)
                    {
                        funcs += "'" + str + "',";
                    }
                }
                //根據功能代碼查詢功能名稱以及編號
                SchSystem.BLL.ServFunc sfBll = new SchSystem.BLL.ServFunc();
                DataTable dtServFunc         = sfBll.GetList("AutoId,FuncName,FuncCode", "FuncCode in (" + funcs.Substring(0, funcs.Length - 1) + ")").Tables[0];

                retobj.retxt  = "servfunc";
                retobj.retobj = dtServFunc;
                //根據功能AutoId查詢功能擴展數據
                SchSystem.BLL.ServFuncExt sfeBll = new SchSystem.BLL.ServFuncExt();
                DataTable dtServFuncExt          = sfeBll.GetList("FuncId,NapeCode,NapeCodes,NapeC,'' Title", "FuncId in(select AutoId from ServFunc where FuncCode in(" + funcs.Substring(0, funcs.Length - 1) + "))").Tables[0];
                retobj.servfuncext = dtServFuncExt;
                Dictionary <string, object> listDic = new Dictionary <string, object>();
                if (dtServFuncExt.Rows.Count > 0)
                {
                    for (int i = 0; i < dtServFuncExt.Rows.Count; i++)
                    {
                        for (int j = 0; j < dtServFunc.Rows.Count; j++)
                        {
                            if (dtServFuncExt.Rows[i]["FuncId"].ToString() == dtServFunc.Rows[j]["AutoId"].ToString())
                            {
                                SchSystem.BLL.ServUserForExt sufeBll = new SchSystem.BLL.ServUserForExt();
                                DataTable dtsufe = sufeBll.GetList("Fcode,NapeCode,NapeCodes", "UserForId in (select AutoId from ServUserFor where ServiceId='" + ordpack + "')").Tables[0];
                                if (dtServFuncExt.Rows[i]["NapeCode"].ToString() == "prd")
                                {
                                    SchSystem.BLL.SysPer spBll    = new SchSystem.BLL.SysPer();
                                    DataTable            dtSysPer = spBll.GetList("'0' pId,PerName name,PerCode id,'false' checked,'true' chkDisabled", "Stat=1 and PerCode in (" + dtServFuncExt.Rows[i]["NapeCodes"].ToString() + ") order by convert(int,PerCode)").Tables[0];
                                    dtServFuncExt.Rows[i]["Title"] = "学段";
                                    string prdtxt = "prd_" + dtServFuncExt.Rows[i]["FuncId"].ToString();
                                    //
                                    if (dtSysPer.Rows.Count > 0)
                                    {
                                        for (int y = 0; y < dtSysPer.Rows.Count; y++)
                                        {
                                            if (dtsufe.Rows.Count > 0)
                                            {
                                                for (int z = 0; z < dtsufe.Rows.Count; z++)
                                                {
                                                    if (dtsufe.Rows[z]["Fcode"].ToString() == dtServFunc.Rows[j]["FuncCode"].ToString() && dtServFuncExt.Rows[i]["NapeCode"].ToString() == dtsufe.Rows[z]["NapeCode"].ToString())
                                                    {
                                                        if (!string.IsNullOrEmpty(dtsufe.Rows[z]["NapeCodes"].ToString()))
                                                        {
                                                            string[] ncarr = dtsufe.Rows[z]["NapeCodes"].ToString().Split(',');
                                                            for (int x = 0; x < ncarr.Length; x++)
                                                            {
                                                                if (ncarr[x].ToString() == dtSysPer.Rows[y]["id"].ToString())
                                                                {
                                                                    dtSysPer.Rows[y]["checked"] = true;
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    //
                                    listDic.Add(prdtxt, dtSysPer);
                                }
                                if (dtServFuncExt.Rows[i]["NapeCode"].ToString() == "mat")
                                {
                                    SchSystem.BLL.SysMater smBll = new SchSystem.BLL.SysMater();
                                    DataTable dtSysMat           = smBll.GetList("'0' pId,MaterName name,MaterCode id,'false' checked,'true' chkDisabled", "Stat=1 and MaterCode in (" + dtServFuncExt.Rows[i]["NapeCodes"].ToString() + ")").Tables[0];
                                    dtServFuncExt.Rows[i]["Title"] = "教版";
                                    string prdtxt = "mat_" + dtServFuncExt.Rows[i]["FuncId"].ToString();
                                    //
                                    if (dtSysMat.Rows.Count > 0)
                                    {
                                        for (int y = 0; y < dtSysMat.Rows.Count; y++)
                                        {
                                            if (dtsufe.Rows.Count > 0)
                                            {
                                                for (int z = 0; z < dtsufe.Rows.Count; z++)
                                                {
                                                    if (dtsufe.Rows[z]["Fcode"].ToString() == dtServFunc.Rows[j]["FuncCode"].ToString() && dtServFuncExt.Rows[i]["NapeCode"].ToString() == dtsufe.Rows[z]["NapeCode"].ToString())
                                                    {
                                                        if (!string.IsNullOrEmpty(dtsufe.Rows[z]["NapeCodes"].ToString()))
                                                        {
                                                            string[] ncarr = dtsufe.Rows[z]["NapeCodes"].ToString().Split(',');
                                                            for (int x = 0; x < ncarr.Length; x++)
                                                            {
                                                                if (ncarr[x].ToString() == dtSysMat.Rows[y]["id"].ToString())
                                                                {
                                                                    dtSysMat.Rows[y]["checked"] = true;
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    //
                                    listDic.Add(prdtxt, dtSysMat);
                                }
                                if (dtServFuncExt.Rows[i]["NapeCode"].ToString() == "sub")
                                {
                                    SchSystem.BLL.SysSub ssBll    = new SchSystem.BLL.SysSub();
                                    DataTable            dtSysSub = ssBll.GetList("'0' pId,SubName name,SubCode id,'false' checked,'true' chkDisabled", "Stat=1 and SubCode in (" + dtServFuncExt.Rows[i]["NapeCodes"].ToString() + ")").Tables[0];
                                    dtServFuncExt.Rows[i]["Title"] = "科目";
                                    string prdtxt = "sub_" + dtServFuncExt.Rows[i]["FuncId"].ToString();
                                    //
                                    if (dtSysSub.Rows.Count > 0)
                                    {
                                        for (int y = 0; y < dtSysSub.Rows.Count; y++)
                                        {
                                            if (dtsufe.Rows.Count > 0)
                                            {
                                                for (int z = 0; z < dtsufe.Rows.Count; z++)
                                                {
                                                    if (dtsufe.Rows[z]["Fcode"].ToString() == dtServFunc.Rows[j]["FuncCode"].ToString() && dtServFuncExt.Rows[i]["NapeCode"].ToString() == dtsufe.Rows[z]["NapeCode"].ToString())
                                                    {
                                                        if (!string.IsNullOrEmpty(dtsufe.Rows[z]["NapeCodes"].ToString()))
                                                        {
                                                            string[] ncarr = dtsufe.Rows[z]["NapeCodes"].ToString().Split(',');
                                                            for (int x = 0; x < ncarr.Length; x++)
                                                            {
                                                                if (ncarr[x].ToString() == dtSysSub.Rows[y]["id"].ToString())
                                                                {
                                                                    dtSysSub.Rows[y]["checked"] = true;
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    //
                                    listDic.Add(prdtxt, dtSysSub);
                                }
                                if (dtServFuncExt.Rows[i]["NapeCode"].ToString() == "grd")
                                {
                                    SchSystem.BLL.SysGrade sgBll = new SchSystem.BLL.SysGrade();
                                    DataTable dtSysGrade         = sgBll.GetList("'0' pId,GradeName name,GradeCode id,'false' checked,'true' chkDisabled", "GradeCode in (" + dtServFuncExt.Rows[i]["NapeCodes"].ToString() + ")").Tables[0];
                                    dtServFuncExt.Rows[i]["Title"] = "年级";
                                    string prdtxt = "grd_" + dtServFuncExt.Rows[i]["FuncId"].ToString();
                                    //
                                    if (dtSysGrade.Rows.Count > 0)
                                    {
                                        for (int y = 0; y < dtSysGrade.Rows.Count; y++)
                                        {
                                            if (dtsufe.Rows.Count > 0)
                                            {
                                                for (int z = 0; z < dtsufe.Rows.Count; z++)
                                                {
                                                    if (dtsufe.Rows[z]["Fcode"].ToString() == dtServFunc.Rows[j]["FuncCode"].ToString() && dtServFuncExt.Rows[i]["NapeCode"].ToString() == dtsufe.Rows[z]["NapeCode"].ToString())
                                                    {
                                                        if (!string.IsNullOrEmpty(dtsufe.Rows[z]["NapeCodes"].ToString()))
                                                        {
                                                            string[] ncarr = dtsufe.Rows[z]["NapeCodes"].ToString().Split(',');
                                                            for (int x = 0; x < ncarr.Length; x++)
                                                            {
                                                                if (ncarr[x].ToString() == dtSysGrade.Rows[y]["id"].ToString())
                                                                {
                                                                    dtSysGrade.Rows[y]["checked"] = true;
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    //
                                    listDic.Add(prdtxt, dtSysGrade);
                                }
                                if (dtServFuncExt.Rows[i]["NapeCode"].ToString() == "utp")
                                {
                                    SchSystem.BLL.SysUType sutBll = new SchSystem.BLL.SysUType();
                                    DataTable dtSysUType          = sutBll.GetList("'0' pId,UTypeName name,UTypeCode id,'false' checked,'true' chkDisabled", "Stat=1 and UTypeCode in (" + dtServFuncExt.Rows[i]["NapeCodes"].ToString() + ")").Tables[0];
                                    dtServFuncExt.Rows[i]["Title"] = "角色";
                                    string prdtxt = "utp_" + dtServFuncExt.Rows[i]["FuncId"].ToString();
                                    //
                                    if (dtSysUType.Rows.Count > 0)
                                    {
                                        for (int y = 0; y < dtSysUType.Rows.Count; y++)
                                        {
                                            if (dtsufe.Rows.Count > 0)
                                            {
                                                for (int z = 0; z < dtsufe.Rows.Count; z++)
                                                {
                                                    if (dtsufe.Rows[z]["Fcode"].ToString() == dtServFunc.Rows[j]["FuncCode"].ToString() && dtServFuncExt.Rows[i]["NapeCode"].ToString() == dtsufe.Rows[z]["NapeCode"].ToString())
                                                    {
                                                        if (!string.IsNullOrEmpty(dtsufe.Rows[z]["NapeCodes"].ToString()))
                                                        {
                                                            string[] ncarr = dtsufe.Rows[z]["NapeCodes"].ToString().Split(',');
                                                            for (int x = 0; x < ncarr.Length; x++)
                                                            {
                                                                if (ncarr[x].ToString() == dtSysUType.Rows[y]["id"].ToString())
                                                                {
                                                                    dtSysUType.Rows[y]["checked"] = true;
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    //
                                    listDic.Add(prdtxt, dtSysUType);
                                }
                            }
                        }
                    }
                    retobj.sysext = listDic;
                }
                ret = Newtonsoft.Json.JsonConvert.SerializeObject(retobj);
            }
            return(ret);
        }
        public static string getaddcont(string napecode)
        {
            string ret = "";

            if (Com.Session.userid == null)
            {
                ret = "expire";
            }
            else
            {
                SchSystem.BLL.ServFuncExt sfeBll = new SchSystem.BLL.ServFuncExt();
                DataTable dtServFuncExt          = sfeBll.GetList("FuncId,NapeCode,NapeCodes,NapeC", "FuncId='" + funcid + "' and NapeCode='" + napecode + "'").Tables[0];
                retprompt retobj = new retprompt();
                if (napecode == "prd")//學段
                {
                    SchSystem.BLL.SysPer spBll = new SchSystem.BLL.SysPer();
                    DataTable            dt    = spBll.GetList("'0' pId,PerName name,PerCode id,'false' checked", "Stat=1 order by convert(int,PerCode)").Tables[0];
                    if (dt.Rows.Count > 0)
                    {
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            if (dtServFuncExt.Rows.Count > 0)
                            {
                                if (dtServFuncExt.Rows[0]["NapeCodes"].ToString() != "")
                                {
                                    string[] NapeCodesArr = dtServFuncExt.Rows[0]["NapeCodes"].ToString().Split(',');
                                    for (int j = 0; j < NapeCodesArr.Length; j++)
                                    {
                                        if (dt.Rows[i]["id"].ToString() == NapeCodesArr[j].ToString())
                                        {
                                            dt.Rows[i]["checked"] = "true";
                                        }
                                    }
                                }
                            }
                        }
                    }
                    retobj.retxt  = napecode;
                    retobj.retobj = dt;
                    ret           = Newtonsoft.Json.JsonConvert.SerializeObject(retobj);
                }
                else if (napecode == "grd")//年級
                {
                    SchSystem.BLL.SysGrade spBll = new SchSystem.BLL.SysGrade();
                    DataTable dt = spBll.GetList("'0' pId,GradeName name,GradeCode id,'false' checked", "").Tables[0];
                    if (dt.Rows.Count > 0)
                    {
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            if (dtServFuncExt.Rows.Count > 0)
                            {
                                if (dtServFuncExt.Rows[0]["NapeCodes"].ToString() != "")
                                {
                                    string[] NapeCodesArr = dtServFuncExt.Rows[0]["NapeCodes"].ToString().Split(',');
                                    for (int j = 0; j < NapeCodesArr.Length; j++)
                                    {
                                        if (dt.Rows[i]["id"].ToString() == NapeCodesArr[j].ToString())
                                        {
                                            dt.Rows[i]["checked"] = "true";
                                        }
                                    }
                                }
                            }
                        }
                    }
                    retobj.retxt  = napecode;
                    retobj.retobj = dt;
                    ret           = Newtonsoft.Json.JsonConvert.SerializeObject(retobj);
                }
                else if (napecode == "sub")//科目
                {
                    SchSystem.BLL.SysSub spBll = new SchSystem.BLL.SysSub();
                    DataTable            dt    = spBll.GetList("'0' pId,SubName name,SubCode id,'false' checked", "Stat=1 Order by SubCode").Tables[0];
                    if (dt.Rows.Count > 0)
                    {
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            if (dtServFuncExt.Rows.Count > 0)
                            {
                                if (dtServFuncExt.Rows[0]["NapeCodes"].ToString() != "")
                                {
                                    string[] NapeCodesArr = dtServFuncExt.Rows[0]["NapeCodes"].ToString().Split(',');
                                    for (int j = 0; j < NapeCodesArr.Length; j++)
                                    {
                                        if (dt.Rows[i]["id"].ToString() == NapeCodesArr[j].ToString())
                                        {
                                            dt.Rows[i]["checked"] = "true";
                                        }
                                    }
                                }
                            }
                        }
                    }
                    retobj.retxt  = napecode;
                    retobj.retobj = dt;
                    ret           = Newtonsoft.Json.JsonConvert.SerializeObject(retobj);
                }
                else if (napecode == "utp")//角色
                {
                    SchSystem.BLL.SysUType spBll = new SchSystem.BLL.SysUType();
                    DataTable dt = spBll.GetList("'0' pId,UTypeName name,UTypeCOde id,'false' checked", "Stat=1").Tables[0];
                    if (dt.Rows.Count > 0)
                    {
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            if (dtServFuncExt.Rows.Count > 0)
                            {
                                if (dtServFuncExt.Rows[0]["NapeCodes"].ToString() != "")
                                {
                                    string[] NapeCodesArr = dtServFuncExt.Rows[0]["NapeCodes"].ToString().Split(',');
                                    for (int j = 0; j < NapeCodesArr.Length; j++)
                                    {
                                        if (dt.Rows[i]["id"].ToString() == NapeCodesArr[j].ToString())
                                        {
                                            dt.Rows[i]["checked"] = "true";
                                        }
                                    }
                                }
                            }
                        }
                    }
                    retobj.retxt  = napecode;
                    retobj.retobj = dt;
                    ret           = Newtonsoft.Json.JsonConvert.SerializeObject(retobj);
                }
                else if (napecode == "mat")//教版
                {
                    SchSystem.BLL.SysMater spBll = new SchSystem.BLL.SysMater();
                    DataTable dt = spBll.GetList("'0' pId,MaterName name,MaterCode id,'false' checked", "Stat=1").Tables[0];
                    if (dt.Rows.Count > 0)
                    {
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            if (dtServFuncExt.Rows.Count > 0)
                            {
                                if (dtServFuncExt.Rows[0]["NapeCodes"].ToString() != "")
                                {
                                    string[] NapeCodesArr = dtServFuncExt.Rows[0]["NapeCodes"].ToString().Split(',');
                                    for (int j = 0; j < NapeCodesArr.Length; j++)
                                    {
                                        if (dt.Rows[i]["id"].ToString() == NapeCodesArr[j].ToString())
                                        {
                                            dt.Rows[i]["checked"] = "true";
                                        }
                                    }
                                }
                            }
                        }
                    }
                    retobj.retxt  = napecode;
                    retobj.retobj = dt;
                    ret           = Newtonsoft.Json.JsonConvert.SerializeObject(retobj);
                }
                else
                {
                    retobj.retxt  = napecode;
                    retobj.retobj = "";
                    ret           = Newtonsoft.Json.JsonConvert.SerializeObject(retobj);
                }
            }
            return(ret);
        }