Example #1
0
 public ExamRoleModel() : base()
 {
     checkRole    = new List <string>();
     ListExamRole = new List <ExamRole>();
     VExamRole    = new ExamRole();
     LRole        = new List <string>();
     LPic         = new List <PicData>();
 }
Example #2
0
        public string SaveExamRole(string username)
        {
            var Result = "";

            try
            {
                if (string.IsNullOrEmpty(RoleID))
                {
                    var Role = Data.ExamRole.Get_ExamRole(new { RoleName = RoleName });
                    if (Role != null)
                    {
                        Result = "角色已存在";
                    }
                    else
                    {
                        ExamRole rolemodel = new ExamRole();
                        rolemodel.RoleName   = RoleName;
                        rolemodel.CreateUser = username;
                        rolemodel.CreateDate = DateTime.Now;
                        Data.ExamRole.Insert_ExamRole(rolemodel, null, new string[] { "ID" });
                        foreach (var item in checkRole)
                        {
                            if (!string.IsNullOrEmpty(item))
                            {
                                ExamRolePart rolepart = new ExamRolePart();
                                rolepart.RoleName = RoleName;
                                rolepart.PartName = item;
                                Data.ExamRolePart.Insert_ExamRolePart(rolepart, null, new string[] { "ID" });
                            }
                        }
                    }
                }
                else
                {
                    var Role = Data.ExamRole.Get_ExamRole(new { ID = RoleID });
                    Role.RoleName   = RoleName;
                    Role.CreateUser = username;
                    Role.CreateDate = DateTime.Now;
                    Data.ExamRole.Update_ExamRole(Role, null, new string[] { "ID" });
                    Data.ExamRolePart.Delete_ExamRolePartByName(RoleName);
                    foreach (var item in checkRole)
                    {
                        if (!string.IsNullOrEmpty(item))
                        {
                            ExamRolePart rolepart = new ExamRolePart();
                            rolepart.RoleName = RoleName;
                            rolepart.PartName = item;
                            Data.ExamRolePart.Insert_ExamRolePart(rolepart, null, new string[] { "ID" });
                        }
                    }
                }

                ListExamRole = Data.ExamRole.Get_All_ExamRole();
            }
            catch (Exception ex)
            {
                throw;
            }

            return(Result);
        }