public int Data_Update_KHAcount_Role(int KHID, string STAFFUSER, string STAFFPW, string roledata)    //给客户修改加用户名和密码并管理角色
        {
            token = appClass.CRM_Gettoken();
            //CRM_Report_STAFFModel model = new CRM_Report_STAFFModel();
            //model.STAFFNO = STAFFNO;
            //model.ISACTIVE = 1;
            //int staffid = crmModels.HG_STAFF.Report(model, token)[0].STAFFID;            //根据工号找到staffid

            CRM_KH_KHList khdata = crmModels.KH_KH.Read(KHID, token);

            CRM_HG_STAFF data = new CRM_HG_STAFF();

            data.STAFFNO   = khdata.SAPSN;
            data.STAFFNAME = khdata.MC;
            data.STAFFUSER = STAFFUSER;
            if (STAFFPW != "")              //如果密码有所改动
            {
                string pattern = @"(?=.*[a-zA-Z])(?=.*[0-9])";
                bool   result  = Regex.IsMatch(STAFFPW, pattern);
                if (result == false)
                {
                    return(-2);             //复杂度不够
                }
                if (STAFFPW.Length < 8)
                {
                    return(-3);            //长度少于8
                }
                data.STAFFPW = FormsAuthentication.HashPasswordForStoringInConfigFile(STAFFPW, "MD5").ToLower();
            }

            data.SISLOCK  = false;
            data.USERLX   = 1107;
            data.ISACTIVE = 1;

            int staffid = crmModels.HG_STAFF.Create(data, token);             //帐号密码加进去,更新人员信息

            if (staffid == -1)
            {
                return(-4);
            }

            CRM_HG_ROLE[] rolemodel = Newtonsoft.Json.JsonConvert.DeserializeObject <CRM_HG_ROLE[]>(roledata);
            crmModels.HG_ROLE.Delete_STAFFROLEByStaffid(staffid, token);
            for (int x = 0; x < rolemodel.Length; x++)
            {
                int _i = crmModels.HG_ROLE.Create_STAFFROLE(staffid, rolemodel[x].ROLEID, token);
                if (_i <= 0)
                {
                    return(-10);
                }
            }



            return(staffid);
        }
Exemple #2
0
        public ActionResult UpdateIndex(int KHID)
        {
            if (Session["token"] != null)
            {
                token = Session["token"].ToString();
            }
            CRM_KH_KHList model = crmModels.KH_KH.Read(KHID, token);

            ViewBag.KHID  = KHID;
            ViewBag.MC    = model.MC;
            ViewBag.CRMID = model.CRMID;
            ViewBag.KHLX  = model.KHLX;
            return(View());
        }