Пример #1
0
        public ActionResult OrgUserDel(string UserID, string ID)
        {
            int iID = 0;
            try
            {
                iID = int.Parse(UserID);
            }
            catch
            {
                //错误页面
            }
            var Querry = from u in CQGJ.User where u.UserID == iID select u;
            CQGJUserViewData viewData = new CQGJUserViewData();
            viewData.Users = Querry.ToList();

            if (viewData.Users.Count > 0)
            {
                viewData.User = viewData.Users[0];
                try
                {
                    try
                    {
                        UsersInOrgs userinorg = new UsersInOrgs();
                        userinorg = (from uo in CQGJ.UsersInOrgs where (uo.b0111 == ID && uo.User.UserID == iID) select uo).First();
                        CQGJ.DeleteObject(userinorg);

                        CQGJ.SaveChanges(true);

                        viewData.ActionSuccess = true;
                        viewData.Org = (from o in CQGJ.b01 where (o.b0111 == ID) select o).First();
                        viewData.HtmlPage = viewData.Users[0].Username + "在单位:" + viewData.Org.b0104 + "中的记录删除成功!";
                        viewData.JavaScriptPage = "/admin/orguserlist/" + ID;
                    }
                    catch
                    {
                        //错误页面
                    }
                }
                catch
                {
                    viewData.HtmlPage = "无";
                    viewData.HtmlPage2 = "无";
                }
            }
            else
            {
                return RedirectToAction("index");
            }

            return View("MessagePage", viewData);
        }
Пример #2
0
        /// <summary>
        /// 添加用户-负责数据库保存
        /// </summary>
        /// <param name="id"></param>
        public ActionResult CreateUser(string id)
        {
            CQGJUserViewData viewData = new CQGJUserViewData();
            User user = new User();
            //user.UserID = Request.Form["UserID"].ToString();
            user.Username = Request.Form["UserName"].ToString();
            user.Remark = Request.Form["AdminRemark"].ToString();
            try
            {
                user.Status = int.Parse(Request.Form["AdminStatus"].ToString());
            }
            catch { }
            user.Birthday = DateTime.Parse(Request.Form["Birthday"].ToString());
            user.Cellphone = Request.Form["Cellphone"].ToString();
            //user.COUPost = Request.Form["COUPost"].ToString();
            //user.Degree = Request.Form["Degree"].ToString();
            //user.Description = Request.Form["Description"].ToString();
            //user.Edu = Request.Form["Edu"].ToString();
            //user.Email = Request.Form["Email"].ToString();
            user.Gender = Request.Form["Gender"].ToString();
            user.IDCard = Request.Form["IDCard"].ToString();
            if (HttpContext.Session["Photo"] != null && HttpContext.Session["PhotoType"] != null)
            {
                user.PhotoType = HttpContext.Session["PhotoType"].ToString();
                user.Photo = (byte[])HttpContext.Session["Photo"];

            }
            user.Password = Security.MD5Encrypt(Request.Form["userPassword"].ToString());
            try
            {
                user.JoinWorkDate = DateTime.Parse(Request.Form["JoinWorkDate"].ToString());
            }
            catch { }
            user.Nation = Request.Form["Nation"].ToString();
            //user.OtherLink = Request.Form["OtherLink"].ToString();
            //user.Password = Request.Form["OtherLink"].ToString();
            user.Politics = Request.Form["Politics"].ToString();
            user.Position = Request.Form["Position"].ToString();

            user.WorkTel = Request.Form["WorkTel"].ToString();
            user.RelationsName = Request.Form["OrgName"].ToString();
            user.RelationsCode = Request.Form["OrgCode"].ToString();
            try
            {
                user.Class = (Request.Form["Level"].ToString());
            }
            catch { }

            CQGJ.AddToUser(user);
            CQGJ.SaveChanges(true);
            viewData.User = user;
            viewData.ActionSuccess = true;

            viewData.JavaScriptPage = "添加人员:" + user.Username;
            //调用webservers
            CQGJAP.CQGJWebServices ap = new CQGJ.Passport.CQGJAP.CQGJWebServices();
            ap.AddUser(user.UserID);

            var querry = from b in CQGJ.b01 where b.b0111 == id select b;
            b01 Org = new b01();
            try
            {
                Org = querry.First();
            }
            catch
            {
                //错误
            }
            UsersInOrgs userinorg = new UsersInOrgs();
            userinorg.User = viewData.User;
            userinorg.b0111 = Org.b0111;

            CQGJ.AddToUsersInOrgs(userinorg);
            CQGJ.SaveChanges(true);
            viewData.HtmlPage = user.Username + "添加功,请添加" + Org.b0104 + "中的职务信息";
            viewData.JavaScriptPage = "/admin/OrgUserAdd/" + user.UserID + "/" + Org.b0111;
            return View("MessagePage", viewData);
        }
Пример #3
0
        public ActionResult UserRole(string UserID, string ID)
        {
            int iID = 0;
            try
            {
                iID = int.Parse(UserID);
            }
            catch
            {
                //错误页面
            }
            var Querry = from u in CQGJ.User where u.UserID == iID select u;
            CQGJUserViewData viewData = new CQGJUserViewData();
            viewData.Users = Querry.ToList();

            if (viewData.Users.Count > 0)
            {
                viewData.User = viewData.Users[0];
                try
                {
                    UsersInOrgs userinorg = new UsersInOrgs();
                    userinorg = (from uo in CQGJ.UsersInOrgs where (uo.b0111 == ID && uo.User.UserID == iID) select uo).First();
                    b01Expansion OrgE = (from oe in CQGJ.b01Expansion where (oe.b01.b0111 == ID) select oe).First();
                    viewData.Org = (from o in CQGJ.b01 where (o.b0111 == ID) select o).First();
                    int OrgType = (int)(OrgE.OrgType);
                    if (OrgType == 4)
                    { OrgType = 2; }

                    string orgtype = OrgType.ToString();
                    //获取与用户所属单位类型一致的角色列表
                    List<Role> roles = (from r in CQGJ.Role
                                        where r.RoleType.Contains(orgtype)
                                        select r).ToList();
                    viewData.RoleList = roles;
                    //for (int j = 0; j < roles.Count; j++)
                    //{
                    //    if (int.Parse(roles[j].AppID) >= OrgType)
                    //    {
                    //        if (OrgType == 2 && int.Parse(roles[j].AppID) == 3)//区县组织部,市直属机构
                    //        {
                    //            ;
                    //        }
                    //        else viewData.RoleList.Add(roles[j]);
                    //    }
                    //}
                    viewData.UsersInRoles = (from ur in CQGJ.UsersInRoles where ur.User.UserID == iID select ur).ToList();

                    if (GetString("btOK").Equals(""))
                    {
                        return View("UserRole", viewData);
                    }
                    else
                    {
                        List<UsersInRoles> userroles = (from ur in CQGJ.UsersInRoles where ur.User.UserID == iID select ur).ToList();
                        if (userroles.Count > 0)
                        {
                            for (int l = 0; l < userroles.Count; ++l)
                            {
                                CQGJ.DeleteObject(userroles[l]);
                            }
                        }
                        if (GetString("CheckNoRole").Equals(""))
                        {
                            for (int k = 0; k < viewData.RoleList.Count; ++k)
                            {
                                string str = GetString("check" + viewData.RoleList[k].RoleID.ToString());
                                if (str.Equals("on"))
                                {
                                    UsersInRoles userinrole = new UsersInRoles();
                                    userinrole.Role = viewData.RoleList[k];
                                    userinrole.User = viewData.User;
                                    CQGJ.AddToUsersInRoles(userinrole);
                                }
                            }
                        }
                        CQGJ.SaveChanges(true);

                        viewData.UsersInRoles = (from ur in CQGJ.UsersInRoles where ur.User.UserID == iID select ur).ToList();

                        viewData.HtmlPage = "人员:" + viewData.User.Username + "角色设置成功!";
                        viewData.JavaScriptPage = "/admin/UserRole/" + UserID + "/" + ID;
                        viewData.ActionSuccess = true;
                        CQGJ.SaveChanges(true);

                        return View("MessagePage", viewData);
                    }
                }
                catch
                {
                    viewData.HtmlPage = "无";
                    viewData.HtmlPage2 = "无";
                }
            }
            else
            {
                return RedirectToAction("index");
            }
            return View("UserRole", viewData);
        }
Пример #4
0
        /// <summary>
        /// 删除用户在单位中信息(用户为中心)
        /// </summary>
        /// <param name="UserID"></param>
        /// <param name="ID"></param>
        public ActionResult UserOrgDel(string UserID, string ID)
        {
            CQGJUserViewData viewData = new CQGJUserViewData();
            int iID = 0;
            try
            {
                iID = int.Parse(UserID);
            }
            catch
            {
                //错误页面
            }

            var Qurrey = from uo in CQGJ.UsersInOrgs where uo.User.UserID == iID && uo.b0111 == ID select uo;
            var QUser = from u in CQGJ.User where u.UserID == iID select u;
            var QOrg = from o in CQGJ.b01 where o.b0111 == ID select o;
            UsersInOrgs userOrg = new UsersInOrgs();
            try
            {
                userOrg = Qurrey.First();
                CQGJ.DeleteObject(userOrg);
                viewData.HtmlPage = "人员:" + QUser.First().Username + "在单位:" + QOrg.First().b0104 + "中的关系删除成功!";
                viewData.JavaScriptPage = "/admin/UserOrgList/" + UserID;
                viewData.ActionSuccess = true;
                CQGJ.SaveChanges(true);

                return View("MessagePage", viewData);
            }
            catch
            {
                //错误页面
            }
            return View();
        }
Пример #5
0
        public ActionResult UserOrgAdd(string UserID, string ID)
        {
            int iID = 0;
            try
            {
                iID = int.Parse(UserID);
            }
            catch
            {
                //错误页面
            }
            var Querry = from u in CQGJ.User where u.UserID == iID select u;
            CQGJUserViewData viewData = new CQGJUserViewData();
            viewData.Users = Querry.ToList();

            if (viewData.Users.Count > 0)
            {
                viewData.User = viewData.Users[0];
                viewData.Org = (from o in CQGJ.b01 where (o.b0111 == ID) select o).First();
                try
                {
                    try
                    {

                        UsersInOrgs userinorg = new UsersInOrgs();
                        userinorg.User = viewData.User;
                        userinorg.b0111 = ID;
                        if (GetString("DeptName").Equals(""))
                        {
                            return View("AddUserOrgDetail", viewData);
                        }
                        else
                        {
                            userinorg.CurrentPosition = GetString("CurrentPosition");
                            userinorg.LeaderPostion = GetString("LeaderPostion");
                            userinorg.Remark = GetString("Remark");
                            userinorg.DeptName = GetString("DeptName");
                            CQGJ.AddToUsersInOrgs(userinorg);

                            CQGJ.SaveChanges(true);
                            viewData.ActionSuccess = true;
                            viewData.HtmlPage = viewData.Users[0].Username + "在单位:" + viewData.Org.b0104 + "中的记录添加成功!";
                            viewData.JavaScriptPage = "/admin/UserNotOrg/" + UserID;
                            return View("MessagePage", viewData);
                        }
                    }
                    catch
                    {
                        //错误页面
                    }
                }
                catch
                {
                    viewData.HtmlPage = "无";
                    viewData.HtmlPage2 = "无";
                }
            }
            else
            {
                return RedirectToAction("index");
            }
            return View("MessagePage", viewData);
        }
Пример #6
0
        public ActionResult OrgUserSave(string UserID, string ID)
        {
            int iID = 0;
            try
            {
                iID = int.Parse(UserID);
            }
            catch
            {
                //错误页面
            }
            var Querry = from u in CQGJ.User where u.UserID == iID select u;
            CQGJUserViewData viewData = new CQGJUserViewData();
            viewData.Users = Querry.ToList();

            if (viewData.Users.Count > 0)
            {
                viewData.User = viewData.Users[0];
                try
                {
                    try
                    {
                        UsersInOrgs userinorg = new UsersInOrgs();
                        userinorg = (from uo in CQGJ.UsersInOrgs where (uo.b0111 == ID && uo.User.UserID == iID) select uo).First();
                        userinorg.CurrentPosition = GetString("CurrentPosition");
                        userinorg.LeaderPostion = GetString("LeaderPostion");
                        userinorg.Remark = GetString("Remark");
                        userinorg.DeptName = GetString("DeptName");

                        CQGJ.SaveChanges(true);
                        viewData.UsersInOrg = userinorg;
                        viewData.Org = (from o in CQGJ.b01 where (o.b0111 == ID) select o).First();
                        viewData.ActionSuccess = true;
                    }
                    catch
                    {
                        //错误页面
                    }
                }
                catch
                {
                    viewData.HtmlPage = "无";
                    viewData.HtmlPage2 = "无";
                }
            }
            else
            {
                return RedirectToAction("index");
            }

            return View("OrgUserEdit", viewData);
        }