예제 #1
0
 public static Com.DataPack.DataRsp <string> existuser(string usertname, int schid)
 {
     Com.DataPack.DataRsp <string> rsp = new Com.DataPack.DataRsp <string>();
     if (Com.Session.userid == null)
     {
         rsp.code = "expire";
         rsp.msg  = "页面已经过期,请重新登录";
     }
     else
     {
         SchSystem.BLL.SchUserInfo suiBll = new SchSystem.BLL.SchUserInfo();
         if (suiBll.ExistsUserName(0, usertname))
         {
             rsp.code = "error";
             rsp.msg  = "管理员账号已被占用,请修改!";
         }
     }
     return(rsp);
 }
예제 #2
0
        public static string usersave(string dotype, string schid, string systype, string userid, string usercode, string usertname, string usertel, string userpst, string usertitle, string usermobile, string username, string userpw, string usersex, string userstat, string usersub, string userdpts, string userroles)
        {
            //解密 RSA
            RSACryptoService rsa = new RSACryptoService(PublicProperty.PrivateKey, PublicProperty.PublicKey);

            if (userpw != "")
            {
                userpw = Com.Public.SqlEncStr(rsa.Decrypt(userpw));
            }
            string ret = "";

            if (Com.Session.userid == null)
            {
                ret = "expire";
            }
            else
            {
                try
                {
                    if (string.IsNullOrEmpty(schid) || schid == "0")
                    {
                        ret += "非法的学校!";
                    }
                    SchSystem.BLL.SchUserInfo   userbll   = new SchSystem.BLL.SchUserInfo();
                    SchSystem.Model.SchUserInfo usermodel = new SchSystem.Model.SchUserInfo();
                    if (!Com.Public.isVa(schid, ""))
                    {
                        ret += "无跨界权限;";
                    }
                    //判断编号及账号是否有重复,生成密码加密
                    if (dotype == "e")
                    {
                        //if (userbll.ExistsUserCode(int.Parse(userid), usercode, int.Parse(schid)))
                        //{
                        //    ret += "用户编号重复!";
                        //}
                        if (username != "")
                        {
                            if (userbll.ExistsUserName(int.Parse(userid), username))
                            {
                                ret += "账号重复!";
                            }
                            else if (!userbll.ExistsUserName(0, username))
                            {
                                userbll.UpdateUserName(username, int.Parse(userid));
                            }
                        }
                    }
                    if (dotype == "a")
                    {
                        //if (userbll.ExistsUserCode(0, usercode, int.Parse(schid)))
                        //{
                        //    ret += "用户编号重复!";
                        //}
                        if (username != "")
                        {
                            /*if (userbll.ExistsUserName(0, username, int.Parse(schid)))
                             * {
                             *  ret += "账号重复!";
                             * }*/
                            StringBuilder sbExists = new StringBuilder();
                            string        utname   = "";
                            if (userbll.ExistsUserName(0, username))
                            {
                                SchSystem.BLL.SchUserDeptV bllusdpt = new SchSystem.BLL.SchUserDeptV();
                                DataTable dt = bllusdpt.GetList("DepartName,UserTname", "UserName='******'").Tables[0];
                                DataRow[] dr = dt.Select();
                                foreach (DataRow item in dr)
                                {
                                    sbExists.Append(item["DepartName"].ToString() + "、");
                                    utname = item["UserTname"].ToString();
                                }
                                //ret += "账号重复!";
                                ret += sbExists.ToString().Substring(0, sbExists.ToString().Length - 1);
                                ret += "," + utname;
                            }
                        }
                    }
                    if (ret == "")
                    {
                        usermodel.LastRecTime = DateTime.Now;
                        usermodel.LastRecUser = Com.Session.userid;
                        usermodel.Mobile      = usermobile;
                        usermodel.Postion     = userpst;
                        usermodel.Sex         = int.Parse(usersex);
                        if (!string.IsNullOrEmpty(userstat))
                        {
                            usermodel.AccStat = int.Parse(userstat);
                        }
                        else
                        {
                            usermodel.AccStat = 2;
                        }
                        usermodel.SubCode   = usersub;
                        usermodel.SysType   = int.Parse(systype);
                        usermodel.Telno     = usertel;
                        usermodel.Title     = usertitle;
                        usermodel.UserNo    = usercode;
                        usermodel.UserTname = usertname;
                        if (dotype == "e")
                        {
                            if (!string.IsNullOrEmpty(userpw) && !string.IsNullOrEmpty(username))
                            {
                                userpw = Com.Public.StrToMD5(userpw);
                                if (userpw == Com.Public.StrToMD5("123456"))//如果重置密码时保存
                                {
                                    userbll.UpdatePw(int.Parse(userid), userpw);
                                }
                            }
                            usermodel.UserId = int.Parse(userid);
                            userbll.UpdateUser(usermodel);
                        }
                        if (dotype == "a")
                        {
                            //必须有账号和密码
                            if (!string.IsNullOrEmpty(userpw) && !string.IsNullOrEmpty(username))
                            {
                                usermodel.PassWord = Com.Public.StrToMD5("123456"); //SchManagerInfoSystem.Common.DESEncrypt.Encrypt(userpw) ;添加时均为123456密码
                            }
                            usermodel.RecTime  = DateTime.Now;
                            usermodel.RecUser  = Com.Session.userid;
                            usermodel.SchId    = int.Parse(schid);
                            usermodel.UserName = username;
                            userid             = userbll.Add(usermodel).ToString();
                        }
                        //添加或更新关联部门
                        SchSystem.BLL.SchUserDept userdeptbll = new SchSystem.BLL.SchUserDept();
                        if (userdpts == null)
                        {
                            userdpts = "0";
                        }
                        userdeptbll.DoUserDept(userid, Com.Session.userid, schid, userdpts);
                        //添加或更新关联角色
                        SchSystem.BLL.SchUserRole userrolebll = new SchSystem.BLL.SchUserRole();
                        if (userroles == null)
                        {
                            userroles = "0";
                        }
                        userrolebll.DoUserRole(userid, Com.Session.userid, schid, userroles);
                        ret = "success";
                    }
                }
                catch (Exception ex)
                {
                    ret = ex.Message;
                }
            }
            return(ret);
        }
예제 #3
0
        public static Com.DataPack.DataRsp <string> schsave(List <string> arr)
        {
            int    schid = 0; string selgrades = ""; string selsubs = ""; string sonsys = ""; string schsonsysenabletime = ""; string resourcemodules = ""; string homschmodules = "";
            string kinderstr = ""; string primarystr = ""; string juniorstr = ""; string highstr = "";
            string homkinderstr = ""; string homprimarystr = ""; string homjuniorstr = ""; string homhighstr = "";

            Com.DataPack.DataRsp <string> rsp = new Com.DataPack.DataRsp <string>();
            if (Com.Session.userid == null)
            {
                rsp.code = "expire";
                rsp.msg  = "页面已经过期,请重新登录";
            }
            else
            {
                try
                {
                    SchSystem.Model.SchInfo schmodel = new SchSystem.Model.SchInfo();
                    SchSystem.BLL.SchInfo   schbll   = new SchSystem.BLL.SchInfo();
                    #region 收集前台传递过来的数据
                    foreach (string str in arr)
                    {
                        string[] strarr = str.Split('#');
                        if (strarr[0] == "schid")
                        {
                            schmodel.SchId = int.Parse(strarr[1]);
                        }
                        else if (strarr[0] == "schname")
                        {
                            schmodel.SchName = strarr[1];
                        }
                        else if (strarr[0] == "acoty")
                        {
                            if (((IList)strarr).Contains(strarr[1]))
                            {
                                schmodel.AreaNo = strarr[1];
                            }
                            else
                            {
                                schmodel.AreaNo = "";
                            }
                        }
                        else if (strarr[0] == "iscity")
                        {
                            if (((IList)strarr).Contains(strarr[1]))
                            {
                                schmodel.IsCity = int.Parse(strarr[1]);
                            }
                            else
                            {
                                schmodel.IsCity = 0;
                            }
                        }
                        else if (strarr[0] == "schaddr")
                        {
                            if (((IList)strarr).Contains(strarr[1]))
                            {
                                schmodel.SchAddr = strarr[1];
                            }
                            else
                            {
                                schmodel.SchAddr = "";
                            }
                        }
                        else if (strarr[0] == "schmaster")
                        {
                            if (((IList)strarr).Contains(strarr[1]))
                            {
                                schmodel.SchMaster = strarr[1];
                            }
                            else
                            {
                                schmodel.SchMaster = "";
                            }
                        }
                        else if (strarr[0] == "schmasterpst")
                        {
                            if (((IList)strarr).Contains(strarr[1]))
                            {
                                schmodel.MasterPostion = strarr[1];
                            }
                            else
                            {
                                schmodel.MasterPostion = "";
                            }
                        }
                        else if (strarr[0] == "schmastertel")
                        {
                            if (((IList)strarr).Contains(strarr[1]))
                            {
                                schmodel.SchTel = strarr[1];
                            }
                            else
                            {
                                schmodel.SchTel = "";
                            }
                        }
                        else if (strarr[0] == "frontlinetechni")
                        {
                            if (((IList)strarr).Contains(strarr[1]))
                            {
                                schmodel.Artisan = strarr[1];
                            }
                            else
                            {
                                schmodel.Artisan = "";
                            }
                        }
                        else if (strarr[0] == "principalname")
                        {
                            if (((IList)strarr).Contains(strarr[1]))
                            {
                                schmodel.PrincipalName = strarr[1];
                            }
                            else
                            {
                                schmodel.PrincipalName = "";
                            }
                        }
                        else if (strarr[0] == "principaltel")
                        {
                            if (((IList)strarr).Contains(strarr[1]))
                            {
                                schmodel.PrincipalTel = strarr[1];
                            }
                            else
                            {
                                schmodel.PrincipalTel = "";
                            }
                        }
                        else if (strarr[0] == "customerservicestaffname")
                        {
                            if (((IList)strarr).Contains(strarr[1]))
                            {
                                schmodel.ServiceName = strarr[1];
                            }
                            else
                            {
                                schmodel.ServiceName = "";
                            }
                        }
                        else if (strarr[0] == "customerservicestaffnametel")
                        {
                            if (((IList)strarr).Contains(strarr[1]))
                            {
                                schmodel.ServiceTel = strarr[1];
                            }
                            else
                            {
                                schmodel.ServiceTel = "";
                            }
                        }
                        else if (strarr[0] == "platformname")
                        {
                            if (((IList)strarr).Contains(strarr[1]))
                            {
                                schmodel.PlatformName = strarr[1];
                            }
                            else
                            {
                                schmodel.PlatformName = "";
                            }
                        }
                        else if (strarr[0] == "platformico")
                        {
                            if (((IList)strarr).Contains(strarr[1]))
                            {
                                schmodel.PlatformIco = strarr[1];
                            }
                            else
                            {
                                schmodel.PlatformIco = "";
                            }
                        }
                        else if (strarr[0] == "platformurl")
                        {
                            if (((IList)strarr).Contains(strarr[1]))
                            {
                                schmodel.PlatformUrl = strarr[1];
                            }
                            else
                            {
                                schmodel.PlatformUrl = "";
                            }
                        }
                        else if (strarr[0] == "ipaddress")
                        {
                            if (((IList)strarr).Contains(strarr[1]))
                            {
                                schmodel.PlatformIP = strarr[1];
                            }
                            else
                            {
                                schmodel.PlatformIP = "";
                            }
                        }
                        else if (strarr[0] == "manageracount")
                        {
                            if (((IList)strarr).Contains(strarr[1]))
                            {
                                schmodel.Manageracount = strarr[1];
                            }
                            else
                            {
                                schmodel.Manageracount = "";
                            }
                        }
                        else if (strarr[0] == "selgrades")
                        {
                            if (((IList)strarr).Contains(strarr[1]))
                            {
                                selgrades = strarr[1];
                            }
                            else
                            {
                                selgrades = "";
                            }
                        }
                        else if (strarr[0] == "selsubs")
                        {
                            if (((IList)strarr).Contains(strarr[1]))
                            {
                                selsubs = strarr[1];
                            }
                            else
                            {
                                selsubs = "";
                            }
                        }
                        else if (strarr[0] == "sonsys")
                        {
                            if (((IList)strarr).Contains(strarr[1]))
                            {
                                sonsys = strarr[1];
                            }
                            else
                            {
                                sonsys = "";
                            }
                        }
                        else if (strarr[0] == "resourceplatformname")
                        {
                            if (((IList)strarr).Contains(strarr[1]))
                            {
                                schmodel.ResourcePlatformName = strarr[1];
                            }
                            else
                            {
                                schmodel.ResourcePlatformName = "";
                            }
                        }
                        else if (strarr[0] == "resourceplatformico")
                        {
                            if (((IList)strarr).Contains(strarr[1]))
                            {
                                schmodel.ResourcePlatformIco = strarr[1];
                            }
                            else
                            {
                                schmodel.ResourcePlatformIco = "";
                            }
                        }
                        else if (strarr[0] == "resourceplatformurl")
                        {
                            if (((IList)strarr).Contains(strarr[1]))
                            {
                                schmodel.ResourcePlatformUrl = strarr[1];
                            }
                            else
                            {
                                schmodel.ResourcePlatformUrl = "";
                            }
                        }
                        else if (strarr[0] == "resourceplatformip")
                        {
                            if (((IList)strarr).Contains(strarr[1]))
                            {
                                schmodel.ResourcePlatformIP = strarr[1];
                            }
                            else
                            {
                                schmodel.ResourcePlatformIP = "";
                            }
                        }
                        else if (strarr[0] == "schoolsection")
                        {
                            if (((IList)strarr).Contains(strarr[1]))
                            {
                                schmodel.SchoolSection = strarr[1];
                            }
                            else
                            {
                                schmodel.SchoolSection = "";
                            }
                        }
                        else if (strarr[0] == "creator")
                        {
                            if (((IList)strarr).Contains(strarr[1]))
                            {
                                schmodel.SchCreator = strarr[1];
                            }
                            else
                            {
                                schmodel.SchCreator = "";
                            }
                        }
                        else if (strarr[0] == "resourcemodules")
                        {
                            if (((IList)strarr).Contains(strarr[1]))
                            {
                                resourcemodules = strarr[1];
                            }
                            else
                            {
                                resourcemodules = "";
                            }
                        }
                        //else if (strarr[0] == "sourceserverstat") { if (((IList)strarr).Contains(strarr[1])) { schmodel.Sourceserstat = int.Parse(strarr[1]); } else { schmodel.Sourceserstat = 0; } }
                        else if (strarr[0] == "kinderstr")
                        {
                            if (((IList)strarr).Contains(strarr[1]))
                            {
                                kinderstr = strarr[1];
                            }
                            else
                            {
                                kinderstr = "";
                            }
                        }
                        else if (strarr[0] == "primarystr")
                        {
                            if (((IList)strarr).Contains(strarr[1]))
                            {
                                primarystr = strarr[1];
                            }
                            else
                            {
                                primarystr = "";
                            }
                        }
                        else if (strarr[0] == "juniorstr")
                        {
                            if (((IList)strarr).Contains(strarr[1]))
                            {
                                juniorstr = strarr[1];
                            }
                            else
                            {
                                juniorstr = "";
                            }
                        }
                        else if (strarr[0] == "highstr")
                        {
                            if (((IList)strarr).Contains(strarr[1]))
                            {
                                highstr = strarr[1];
                            }
                            else
                            {
                                highstr = "";
                            }
                        }

                        else if (strarr[0] == "per")
                        {
                            if (((IList)strarr).Contains(strarr[1]))
                            {
                                schmodel.SchType = int.Parse(strarr[1]);
                            }
                            else
                            {
                                schmodel.SchType = 0;
                            }
                        }
                        else if (strarr[0] == "drpm")
                        {
                            if (((IList)strarr).Contains(strarr[1]))
                            {
                                schmodel.OpenMonth = int.Parse(strarr[1]);
                            }
                            else
                            {
                                schmodel.OpenMonth = 0;
                            }
                        }

                        //家校互通平台基础数据
                        else if (strarr[0] == "homeschoolingname")
                        {
                            if (((IList)strarr).Contains(strarr[1]))
                            {
                                schmodel.HomeSchPlatName = strarr[1];
                            }
                            else
                            {
                                schmodel.HomeSchPlatName = "";
                            }
                        }
                        else if (strarr[0] == "homeschoolingico")
                        {
                            if (((IList)strarr).Contains(strarr[1]))
                            {
                                schmodel.HomeSchPlatIco = strarr[1];
                            }
                            else
                            {
                                schmodel.HomeSchPlatIco = "";
                            }
                        }
                        else if (strarr[0] == "homeschoolingurl")
                        {
                            if (((IList)strarr).Contains(strarr[1]))
                            {
                                schmodel.HomeSchPlatUrl = strarr[1];
                            }
                            else
                            {
                                schmodel.HomeSchPlatUrl = "";
                            }
                        }
                        else if (strarr[0] == "homeschoolingip")
                        {
                            if (((IList)strarr).Contains(strarr[1]))
                            {
                                schmodel.HomeSchPlatIP = strarr[1];
                            }
                            else
                            {
                                schmodel.HomeSchPlatIP = "";
                            }
                        }
                        else if (strarr[0] == "homeschoolbaxicstat")
                        {
                            if (((IList)strarr).Contains(strarr[1]))
                            {
                                schmodel.HomeSchBasicStat = int.Parse(strarr[1]);
                            }
                            else
                            {
                                schmodel.HomeSchBasicStat = 0;
                            }
                        }
                        else if (strarr[0] == "homeschoolservstat")
                        {
                            if (((IList)strarr).Contains(strarr[1]))
                            {
                                schmodel.HomeschServStat = int.Parse(strarr[1]);
                            }
                            else
                            {
                                schmodel.HomeschServStat = 0;
                            }
                        }
                        //家校互通平台学段、科目及教版
                        else if (strarr[0] == "homschkinderstr")
                        {
                            if (((IList)strarr).Contains(strarr[1]))
                            {
                                homkinderstr = strarr[1];
                            }
                            else
                            {
                                homkinderstr = "";
                            }
                        }
                        else if (strarr[0] == "homschprimarystr")
                        {
                            if (((IList)strarr).Contains(strarr[1]))
                            {
                                homprimarystr = strarr[1];
                            }
                            else
                            {
                                homprimarystr = "";
                            }
                        }
                        else if (strarr[0] == "homschjuniorstr")
                        {
                            if (((IList)strarr).Contains(strarr[1]))
                            {
                                homjuniorstr = strarr[1];
                            }
                            else
                            {
                                homjuniorstr = "";
                            }
                        }
                        else if (strarr[0] == "homschhighstr")
                        {
                            if (((IList)strarr).Contains(strarr[1]))
                            {
                                homhighstr = strarr[1];
                            }
                            else
                            {
                                homhighstr = "";
                            }
                        }
                        //家校互通平台子模块
                        else if (strarr[0] == "homschmodules")
                        {
                            if (((IList)strarr).Contains(strarr[1]))
                            {
                                homschmodules = strarr[1];
                            }
                            else
                            {
                                homschmodules = "";
                            }
                        }
                    }
                    #endregion
                    schmodel.RecTime           = DateTime.Now;
                    schmodel.RecUser           = schmodel.SchCreator;
                    schmodel.SonSysStat        = 1; //子系统状态,缺省值为1,表示启用
                    schmodel.Stat              = 1; //0代表废弃;1代表正常;2代表删除
                    schmodel.SourceSerStat     = 0;
                    schmodel.HomeSchCreateTime = DateTime.Now;
                    string msusername  = schmodel.Manageracount;
                    string msusertname = schmodel.SchMaster;
                    string errorstr    = "";
                    SchSystem.BLL.SchUserInfo suiBll = new SchSystem.BLL.SchUserInfo();
                    if (string.IsNullOrEmpty(msusername) || string.IsNullOrEmpty(msusertname))
                    {
                        errorstr += "管理员账号或管理员姓名为空;";
                    }
                    if (msusername != "" && suiBll.ExistsUserName(0, msusername))//判断管理账号是否存在
                    {
                        errorstr += "管理员账号已经被使用,请修改;";
                    }
                    if (Encoding.Default.GetBytes(schmodel.PlatformIP).Length > 15)//判断管理平台IP地址
                    {
                        errorstr += "管理平台IP地址超出15个字符;";
                    }
                    if (Encoding.Default.GetBytes(schmodel.ResourcePlatformIP).Length > 15)//判断资源平台IP地址
                    {
                        errorstr += "管理平台IP地址超出15个字符;";
                    }
                    if (Encoding.Default.GetBytes(schmodel.HomeSchPlatIP).Length > 15)//判断家校互通平台IP地址
                    {
                        errorstr += "管理平台IP地址超出15个字符;";
                    }
                    if (errorstr == "")
                    {
                        schid = schbll.SchAdd(schmodel);
                        if (schid > 0)
                        {
                            suiBll.AddUser(schid, schmodel.SchMaster, schmodel.Manageracount, Com.Public.StrToMD5("123456"), Com.Session.userid);
                            //添加家校互通平台基础数据
                            schmodel.SchId = schid;
                            schbll.SchAddXXT(schmodel);
                            //添加年级及科目
                            GradeSubAdd(selgrades, schid);
                            //添加科目
                            subAdd(selsubs, schid);
                            //添加子系统
                            SonSysAdd(sonsys, schid);
                            //资料科目及教版
                            dataSubMat(schid, kinderstr, primarystr, juniorstr, highstr);
                            //资源模块
                            ResourcesModel(resourcemodules, schid);
                            //家校互通平台学段科目及教版
                            schxxtPerSubMat(schid, homkinderstr, homprimarystr, homjuniorstr, homhighstr);
                            //家校互通平台子模块
                            schxxtSonModel(homschmodules, schid);
                            rsp.code = "success";
                            rsp.msg  = "添加成功";
                        }
                        else
                        {
                            rsp.code = "error";
                            rsp.msg  = "添加失败";
                        }
                    }
                    else
                    {
                        rsp.code = "error";
                        rsp.msg  = errorstr;
                    }
                }
                catch (Exception ex)
                {
                    rsp.code = "error";
                    rsp.msg  = ex.Message;
                }
            }
            return(rsp);
        }