public bool SaveAdmin(ref Admin admin, ref string message) { var result = true; if (!AdminCheck(ref admin, ref message)) { result = false; } else { try { var adminBDO = new AdminBDO(); TranslateAdminDTOToAdminBDO(admin, adminBDO); result = adminLogic.InsertAdmin( ref adminBDO, ref message); } catch (Exception e) { var msg = e.Message; throw new FaultException<AdminFault> (new AdminFault(msg), msg); } } return result; }
private void button2_Click(object sender, EventArgs e) { string id = textBox1.Text.Trim(); string password = textBox2.Text.Trim(); string againPw = textBox3.Text.Trim(); if (id != "" && password != "" && againPw != "") { if (SqlAdmin.exitById(id)) { MessageBox.Show("该用户名已经存在。"); return; } else if (password != againPw) { MessageBox.Show("请确保两段密码相同."); } else { Admin admin = new Admin(id,password); SqlAdmin.addAdmin(admin); MessageBox.Show("注册成功."); Login loginView = new Login(); loginView.Show(); this.Dispose(); } } else { MessageBox.Show("该输入所有数据."); } }
public AssociateController( IMembershipService membershipService, IMembershipService associateMembershipService, IAssociateService associateService, IDocumentService documentService, IReferenceService referenceService, IEmployeeService employeeService, IProspectService prospectService, IPrincipal user, IClientProjectSharedService clientProjectSharedService, IIndividualService individualService, IRoleService roleService, Admin.Services.IEmailService emailService) : base(membershipService, associateService, user) { this.associateService = associateService; this.documentService = documentService; this.referenceService = referenceService; this.employeeService = employeeService; this.prospectService = prospectService; this.associateMembershipService = associateMembershipService; this.clientProjectSharedService = clientProjectSharedService; this.individualService = individualService; this.roleService = roleService; this.emailService = emailService; }
/// <summary> /// 处理确定按钮点击事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btConfirm_Click(object sender, EventArgs e) { Admin admin = new Admin(); MD5CryptoServiceProvider HashMD5 = new MD5CryptoServiceProvider(); string oldPwd = ASCIIEncoding.ASCII.GetString(HashMD5.ComputeHash(ASCIIEncoding.ASCII.GetBytes(tbOldPwd.Text))); string newPwd1 = ASCIIEncoding.ASCII.GetString(HashMD5.ComputeHash(ASCIIEncoding.ASCII.GetBytes(tbNewPwd1.Text))); string newPwd2 = ASCIIEncoding.ASCII.GetString(HashMD5.ComputeHash(ASCIIEncoding.ASCII.GetBytes(tdNewPwd2.Text))); if (admin.ChangePassword(Session["UserName"].ToString(), oldPwd, newPwd1, newPwd2)) { //胡媛媛修改,修改跳转语句的位置,2010-01-15 Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert", "<script>alert('修改成功!');window.location='./index.aspx'</script>"); //Response.Redirect("./index.aspx"); //胡媛媛修改,修改跳转语句的位置,2010-01-15 } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert", "<script>alert('对不起,您修改密码失败,原因可能是您输入的原密码不正确或是两次输入的新密码不一致!')</script>"); } }
public static Admin GetAll_DataByEmail(string email) { Connection con = new Connection(); string strConnString = con.GetConnString(); using(SqlConnection SqlCon = new SqlConnection(strConnString)) { SqlCommand SqlComm = new SqlCommand("", SqlCon); SqlCon.Open(); string query = string.Format("SELECT id, name, email, password FROM admin WHERE email='"+ email +"'"); SqlComm.CommandText = query; SqlDataReader reader = SqlComm.ExecuteReader(); Admin adminDataByEmail = null; while(reader.Read()) { int Id = reader.GetInt32(0); string Name = reader.GetString(1); string Email = reader.GetString(2); string Pass = reader.GetString(3); adminDataByEmail = new Admin(Id, Name, Email, Pass); } return adminDataByEmail; } }
static void Main(string[] args) { //Base class UserController userController = new UserController(); userController.Login("John.Smith", "secret"); //userController.SetPermissions("John.Smith"); //inherits from userController so gets its methods AdminController adminController = new AdminController(); adminController.Login("Jane.Doe", "pass123"); adminController.SetPermissions("Jane.Doe"); //inherits from adminController so get its methods and all the methods inherited from userController AdminController superAdminController = new SuperAdminController(); superAdminController.Login("Joe.Bloggs", "password"); superAdminController.SetPermissions("Joe.Bloggs"); Admin admin = new Admin(); admin.name = "Jane.Doe"; admin.role = "admin"; Seller seller = new Seller(); seller.name = "John.Smith"; seller.role = "Seller"; //AbstractUser user = new AbstractUser(); // Oooops, no can do! //IDatabaseConnection connection1 = new IDatabaseConnection(); // Not possible! IDatabaseConnection connection2 = new MicrosoftDbConnection(); Console.ReadLine(); }
public EvaluatePerformance(Admin obj) { InitializeComponent(); evaluatebyadmintext.Text = obj.adminId; evaluatebyadmintext.ReadOnly = true; }
public string DoRequest(Admin.Model.DesList dmodel) { try { HttpWebRequest request = null; //ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult); string url = "http://interface.angeletsoft.cn/interface_ent.php"; request = WebRequest.Create(url) as HttpWebRequest; //request.ProtocolVersion = HttpVersion.Version10; request.ContentType = "application/json"; request.Method = "POST"; request.UserAgent = DefaultUserAgent; //string form = "{\"FunctionCode\":\"GET_STATUS_BYID\",\"ID\":\"1\"}"; string form = "{\"FunctionCode\":\"EXEUTE_ORDER\",\"Body\":{\"Sender\":\"" + dmodel.Sender + "\",\"Receiver\":\"" + dmodel.Receiver + "\",\"CmdOrder\":\"DEL\",\"OrderCotent\":\"D\",\"STATUS\":\"0\",\"IsValid\":\"1\"}}"; byte[] data = Encoding.UTF8.GetBytes(form); request.ContentLength = data.Length; using (Stream stream = request.GetRequestStream()) { stream.Write(data, 0, data.Length); stream.Close(); } HttpWebResponse wr = request.GetResponse() as HttpWebResponse; string cs = wr.CharacterSet; StreamReader reader = new StreamReader(wr.GetResponseStream(), Encoding.GetEncoding(cs)); return reader.ReadToEnd(); } catch (Exception) { return ""; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { IEntityAccessor accessor = EntityAccessorFactory.Create(EntityAccessorTypes.WebForm); Admin admin = Admin.FindAll()[0]; accessor .SetConfig(EntityAccessorOptions.AllFields, true) .SetConfig(EntityAccessorOptions.ItemPrefix, "field") .SetConfig(EntityAccessorOptions.Container, this) .Write(admin, null); Admin admin2 = new Admin(); accessor.Read(admin2, null); Debug.Assert(admin.ID == admin2.ID); Debug.Assert(admin.Name == admin2.Name); Debug.Assert(admin2.DisplayName == null); // Label只能写不能读 Debug.Assert(admin2.FriendName == admin2.FriendName); Debug.Assert(admin.Logins == admin2.Logins); Debug.Assert(admin.IsEnable == admin2.IsEnable); Debug.Assert(Math.Abs((admin.LastLogin - admin2.LastLogin).Ticks) < TimeSpan.FromSeconds(1).Ticks); Debug.Assert(admin.RoleID == admin2.RoleID); Debug.Assert(admin.RoleName == admin2.RoleName); Debug.Assert(admin.SSOUserID == admin2.SSOUserID); } }
public Admin Create(Admin admin) { Context.Admins.Add(admin); Context.SaveChanges(); return admin; }
protected void Bt_Update_Click(object sender, EventArgs e) { if (Page.IsValid) { Admin admin = new Admin(); admin.LoadInfo(Request.Cookies["userID"].Value.ToString()); if (txtPwdold.Text == admin.adminPwd) { string xwhere = "where adminID=" + SQLString.GetQuotedString(Request.Cookies["userID"].Value.ToString()); Hashtable ht = new Hashtable(); ht.Add("adminPwd", SQLString.GetQuotedString(txtPwdnew.Text)); if (admin.Update(ht, xwhere)) { Response.Write("<Script Language=JavaScript>alert(\"密码修改成功!\")</Script>"); } else { Response.Write("<Script Language=JavaScript>alert(\"密码修改失败!\")</Script>"); } } else { Response.Write("<Script Language=JavaScript>alert(\"旧密码错误!\")</Script>"); } } }
protected void btnAlta_Click(object sender, EventArgs e) { bool est = false; if (chkPuede.Checked == true) { est = true; } try { cargarWCF(); unAdmin = new Admin(); unAdmin.CI = Convert.ToInt32(txtCi.Text.Trim()); unAdmin.NOM_COMPLETO = txtNombre.Text.Trim(); unAdmin.USUARIO = txtUsuario.Text.Trim(); unAdmin.PASS = txtPass.Text.Trim(); unAdmin.ESTADISTICAS = est; trivias.AltaUsuario((Usuarios)unAdmin); Response.Write("<div id=\"exito\" class=\"alert alert-success\">EXITO AL REGISTRAR ADMINISTRADOR</div>" + "<script type=\"text/javascript\">window.onload=function(){alertBootstrap();};</script>"); trivias.Close(); Limpiar(); } catch (Exception ex) { Response.Write("<div id=\"error\" class=\"alert alert-danger\">" + ex.Message + "</div>" + "<script type=\"text/javascript\">window.onload=function(){alertBootstrap();};</script>"); } }
public bool updateAdmin(Admin obj) { string insertCommand = "update admin set adminName= @adminName,adminPassword = @adminPassword " + "where adminid= @adminid "; SqlCommand command = new SqlCommand(insertCommand); SqlParameter idParameter = new SqlParameter("@adminid", SqlDbType.NVarChar, 50); idParameter.Value = obj.adminId; SqlParameter nameParameter = new SqlParameter("@adminName", SqlDbType.NVarChar, 50); nameParameter.Value = obj.adminName; SqlParameter passwordParameter = new SqlParameter("@adminPassword", SqlDbType.NVarChar, 50); passwordParameter.Value = obj.adminPassword; command.Parameters.Add(idParameter); command.Parameters.Add(nameParameter); command.Parameters.Add(passwordParameter); if (da.Execution(command)) { return true; } else { return false; } }
public IHttpActionResult PutAdmin(int id, Admin admin) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != admin.AdminId) { return BadRequest(); } db.Entry(admin).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!AdminExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public Admin GetAdmin(int id) { AdminBDO adminBDO = null; try { adminBDO = adminLogic.GetAdmin(id); } catch (Exception e) { var msg = e.Message; var reason = "GetAdmin exception"; throw new FaultException<AdminFault> (new AdminFault(msg), reason); } if (adminBDO == null) { var msg = string.Format("No admin found for id {0}", id); var reason = "GetAdmin empty"; throw new FaultException<AdminFault> (new AdminFault(msg), reason); } var admin = new Admin(); TranslateAdminBDOToAdminDTO(adminBDO, admin); return admin; }
public ActionResult CreateAdmin(Admin admin) { if (!Application.IsAuthenticated && Application.AdminType != 1) { ViewBag.Header = "Authorization Level Too Low"; ViewBag.Message = "Your authorization is not valid for this type of operation"; return View("Message", "_LayoutGuest"); } if (!admin.Email.IsEmail()) { ViewBag.Header = "Inputs were incorrect"; ViewBag.Message = "Please go back to the form and input the correct data"; return View("Message", "_LayoutAdmin"); } //Airah's Code using (KnowledgeChannelEntities context = new KnowledgeChannelEntities()) { if (ModelState.IsValid) { admin.Password = Encrypt.ComputeHash(admin.Password, "SHA512", null); admin.DateCreated = DateTime.Now; context.AddToAdmins(admin); context.SaveChanges(); return RedirectToAction("ViewAdmins"); } } return View(); }
public AssignNewJob(Admin obj) { InitializeComponent(); assignnewjobbyadminidtext.Text = obj.adminId; assignnewjobbyadminidtext.ReadOnly = true; }
protected void btConfirm_Click(object sender, EventArgs e) { Admin admin = new Admin (); Search search = new Search(); TeacherInfo thisTeacher = new TeacherInfo(); thisTeacher.StrUserName=tbxUserName.Text; thisTeacher.StrTeacherName=tbxName.Text; thisTeacher.StrIdentityId=tbxIdentityNO.Text; MD5CryptoServiceProvider HashMD5 = new MD5CryptoServiceProvider(); thisTeacher.StrPassword=ASCIIEncoding.ASCII.GetString(HashMD5.ComputeHash(ASCIIEncoding.ASCII.GetBytes("888888"))); string s = tbxUserName.Text; string last4userName = s.Substring(s.Length - 4, 4); string p = tbxIdentityNO.Text; string last4IdentityNO = p.Substring(p.Length - 4, 4); if (last4userName!=last4IdentityNO) { Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert", "<script>alert('请确认用户名末四位与身份证号末四位相同')</script>"); } //else if (thisTeacher.StrIdentityId==search.GetTeacherByUsername(s).StrIdentityId) else if (thisTeacher.StrIdentityId == search.GetTeacherByIdentityID(p).StrIdentityId)// 武剑洁修改,2009-9-11 { Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert", "<script>alert('身份证号重复,已存在该老师')</script>"); tbxIdentityNO.Text = ""; } else if (search.GetTeacherIdByUsername(thisTeacher.StrUserName) > 0)// 尚书修改,2012-8-5 { Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert", "<script>alert('该用户名已存在,请更换')</script>"); tbxUserName.Text = ""; } else if (search.GetTeacherIdByName(thisTeacher.StrTeacherName) > 0)// 武剑洁修改,2012-8-5 { Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert", "<script>alert('老师姓名重复,请修改姓名以区分两位老师')</script>"); tbxName.Text = ""; } else { if (admin.AddTeacher(thisTeacher)) { //Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert", // "<script>alert('添加成功!')</script>"); // 武剑洁修改,添加页面跳转,2009-9-10 Response.Write("<script>alert('添加成功!');window.location='./Teacher_Manage.aspx'</script>"); } else { //Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert", // "<script>alert('添加失败!')</script>"); // 武剑洁修改,添加页面跳转,2009-9-10 Response.Write("<script>alert('添加失败!');window.location='./Teacher_Manage.aspx'</script>"); } } }
public ProductView(Admin.ReadModels.Client.IProductsView adminProductView) { adminProducts = adminProductView; if (products.Count == 0) { InitialiseProducts(); } }
public void NoChangesUsingSnapshotter() { var user = new Admin { UserId = 1 }; var snap = _database.StartSnapshot(user); Assert.AreEqual(0, snap.Changes().Count); Assert.AreEqual(0, snap.UpdatedColumns().Count); }
protected void btConfirm_Click(object sender, EventArgs e) { Admin admin = new Admin(); Search thisSearch = new Search(); StudentInfo thisStudent = new StudentInfo(); // 从界面读取学生信息 thisStudent.StrStudentNO = tbxStuNO.Text;// 读取学号 thisStudent.StrStudentName = tbxStuName.Text;// 姓名 thisStudent.StrIdentityId = tbxIdentityNO.Text;// 身份证号 MD5CryptoServiceProvider HashMD5 = new MD5CryptoServiceProvider();// 设置初始密码 thisStudent.StrPassword = ASCIIEncoding.ASCII.GetString(HashMD5.ComputeHash(ASCIIEncoding.ASCII.GetBytes("888888"))); string stuNO=this.tbxStuNO.Text;// 获取学号 if (Convert.ToInt32(this.DropDownList1.SelectedValue) == 0) { Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert", "<script>alert('请选择班级!')</script>"); return; } ////else if (thisStudent.StrIdentityId == thisSearch.GetStudentByUsername(stuNO).StrIdentityId) // 武剑洁修改,2009-9-11 else if (thisSearch.GetStudentIdByUsername(tbxStuNO.Text) > 0) {// 用户名重复,则禁止添加新用户 Response.Write("<script>alert('用户名重复,该同学已存在!')</script>"); tbxStuNO.Text = "";// 清空输入 return; } else if (thisSearch.GetStudentIdByIdentityID(tbxIdentityNO.Text) > 0) {// 身份证号重复,则禁止添加新用户 Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert","<script>alert('身份证号重复,该同学已经存在!')</script>"); tbxIdentityNO.Text = "";// 清空输入 return; } thisStudent.StrStudentNO=this.tbxStuNO.Text; thisStudent.StrStudentName=this.tbxStuName.Text; thisStudent.StrIdentityId=this.tbxIdentityNO.Text; thisStudent.ClassName = this.DropDownList1.SelectedItem.Text; HashMD5 = new MD5CryptoServiceProvider(); thisStudent.StrPassword = ASCIIEncoding.ASCII.GetString(HashMD5.ComputeHash(ASCIIEncoding.ASCII.GetBytes("888888"))); if (admin.AddStudent(thisStudent)) { //Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert", // "<script>alert('添加成功!')</script>"); // 武剑洁修改,添加页面跳转,2009-9-10 Response.Write("<script>alert('添加成功!');window.location='./Student_Manage.aspx'</script>"); } else { //Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert", // "<script>alert('添加失败!')</script>"); // 武剑洁修改,添加页面跳转,2009-9-10 Response.Write("<script>alert('添加成功!');window.location='./Student_Manage.aspx'</script>"); } }
public static async Task<Admin> insertAdmin(string login, string nome, string senha, string matricula) { Usuario usuario = new Usuario() { Login = login, Nome = nome, Senha = senha }; await App.MobileService.GetTable<Usuario>().InsertAsync(usuario); Admin admin = new Admin { Matricula = matricula, UsuarioId = usuario.Id }; await App.MobileService.GetTable<Admin>().InsertAsync(admin); return admin; }
private void updateadminidcombobox_SelectedValueChanged(object sender, EventArgs e) { string id = updateadminidcombobox.Text; updateadmin = updatedata.GetAdminUpdateData(id); updateadminnametext.Text = updateadmin.adminName; updateadminpasswordtext.Text = updateadmin.adminPassword; }
public void AddAdmin(Admin admin) { if (this.UnitOfWork.Data.Admins.SingleOrDefault(a => a.Nick == admin.Nick) == null) { List<Admin> admins = this.UnitOfWork.Data.Admins.ToList(); admins.Add(admin); this.UnitOfWork.Data.Admins = admins.ToArray(); } }
static void Main(string[] args) { HealthyJourneyContext ctx = null; ctx = new HealthyJourneyContext(); Admin c = new Admin { UserName = "******",Password="******",ConfirmPAssword="******",Email="*****@*****.**",IsApproved=false }; ctx.Users.Add(c); ctx.SaveChanges(); }
public void Update(Admin model) { var admin = Get(model.Id); admin.FirstName = model.FirstName; admin.LastName = model.LastName; admin.Email = model.Email; Context.SaveChanges(); }
static void Main(string[] args) { Admin setup = new Admin(); Controller game = new Controller(); setup.ConsoleSetup(); //sets up console size, title, background and foreground color setup.Intro(); //displays intro to application game.MainGame(); //hands off application to the controller setup.Goodbye(); //exit screen }
public bool Authenticate(string user, string pwd) { if (null == _admin) lock (_lock) if (null == _admin) _admin = _session.Load<Admin>("admin"); return null != _admin && _admin.Accounts.ContainsKey(user) && _admin.Accounts[user].Password == pwd; }
public IHttpActionResult PostAdmin(Admin admin) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Admins.Add(admin); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = admin.AdminId }, admin); }
public void RefreshTopPlayerList(Admin.Account[] accounts) { if (accounts == null || accounts.Length == 0) accounts = NetworkManager.GetProxy().GetAccountList(); topPlayersTable.Rows.Clear(); foreach (Admin.Account account in accounts) { topPlayersTable.Rows.Add(account.accountName, account.points, "< Unknown >"); } }
public PartialViewResult _Editpart(string id) { Admin admin = db.Admin.Find(Session["UserID"]); return(PartialView("_Editpart", admin)); }
// Update Admin public void UpdateAdmin(Admin myAdmin) { adminC.Update(myAdmin); }
public Admin CreateAdmin(Admin adminToCreate) { ControlAdmin ctrlAdmin = new ControlAdmin(); return(ctrlAdmin.CreateAdmin(adminToCreate)); }
static void Main(string[] args) { //Academy Management Application //The app will have users that can login and preform some actions //The user can choose one of the 3 roles and login // Console.WriteLine(); //-Admin //-Trainer //-Student (has a current Subject, and Grades) //After logging in there should be different options for different roles //Admins can add/remove Trainers, Students and other Admins (can`t remove it self) //Trainer can choose between seeing all students and all subjects // - When choosing Students, all student names should appear // - When chosen a name, it should print all the subjects // - When choosing Subjects, all Subject names appear with how many students attend it next to it //Student are shown subjects that they are listening and a list of their grades #region Initializing Lists Admin adminOne = new Admin("Bill", "Billsky"); Admin adminTwo = new Admin("Jane", "Doe"); Admin adminThree = new Admin("Stefan", "Stefanoski"); Admin adminFour = new Admin("Jerry", "Tompson"); List <Admin> admins = new List <Admin>() { adminOne, adminTwo, adminThree, adminFour }; Trainer trainerOne = new Trainer("John", "Brown"); Trainer trainerTwo = new Trainer("Stone", "Stonsky"); Trainer trainerThree = new Trainer("Maria", "Campbel"); Trainer trainerFour = new Trainer("Angel", "Bozinovski"); List <Trainer> trainers = new List <Trainer>() { trainerOne, trainerTwo, trainerThree, trainerFour }; Student studentOne = new Student("Angela", "Avramovska"); Student studentTwo = new Student("Pavle", "Nikolov"); Student studentThree = new Student("Stefan", "Trajkov"); Student studentFour = new Student("Daniela", "Bozinova"); List <Student> students = new List <Student>() { studentOne, studentTwo, studentThree, studentFour }; Subjects subjectOne = new Subjects("HTML/CSS"); Subjects subjectTwo = new Subjects("JavaScript"); Subjects subjectThree = new Subjects("AdvancedJavaScript"); Subjects subjectFour = new Subjects("Basic C#"); List <Subjects> subjects = new List <Subjects> { subjectOne, subjectTwo, subjectThree, subjectFour }; studentOne.MySubject = new Dictionary <Subjects, int>(); studentOne.MySubject.Add(subjectOne, 5); studentOne.MySubject.Add(subjectThree, 3); studentTwo.MySubject = new Dictionary <Subjects, int>(); studentTwo.MySubject.Add(subjectOne, 4); studentTwo.MySubject.Add(subjectTwo, 5); studentTwo.MySubject.Add(subjectFour, 4); studentThree.MySubject = new Dictionary <Subjects, int>(); studentThree.MySubject.Add(subjectOne, 5); studentThree.MySubject.Add(subjectFour, 5); studentThree.MySubject.Add(subjectThree, 5); studentFour.MySubject = new Dictionary <Subjects, int>(); studentFour.MySubject.Add(subjectTwo, 3); studentFour.MySubject.Add(subjectOne, 5); var nameOfSubjectOne = subjectOne.NameOfSubject; int index = 0; foreach (var student in students) { var listofsubjects = student.MySubject.Where(s => s.Key.NameOfSubject == nameOfSubjectOne).ToList(); if (listofsubjects.Count != 0) { index++; } } subjectOne.indicatiorOfStudents = index; var nameOfSubjectTwo = subjectTwo.NameOfSubject; int index2 = 0; foreach (var student in students) { var listofsubjects = student.MySubject.Where(s => s.Key.NameOfSubject == nameOfSubjectTwo).ToList(); if (listofsubjects.Count != 0) { index2++; } } subjectTwo.indicatiorOfStudents = index2; var nameOfSubjectThree = subjectThree.NameOfSubject; int index3 = 0; foreach (var student in students) { var listofsubjects = student.MySubject.Where(s => s.Key.NameOfSubject == nameOfSubjectThree).ToList(); if (listofsubjects.Count != 0) { index3++; } } subjectThree.indicatiorOfStudents = index3; var nameOfSubjectFour = subjectThree.NameOfSubject; int index4 = 0; foreach (var student in students) { var listofsubjects = student.MySubject.Where(s => s.Key.NameOfSubject == nameOfSubjectFour).ToList(); if (listofsubjects.Count != 0) { index4++; } } subjectFour.indicatiorOfStudents = index4; #endregion Console.WriteLine("Login on Academy Managemnt Application!"); Console.WriteLine(); Console.WriteLine("Press 1) for Admin"); Console.WriteLine("Press 2) for Trainer"); Console.WriteLine("Press 3) for Student"); Console.WriteLine(); try { int roleInput = Convert.ToInt32(Console.ReadLine()); switch (roleInput) { case 1: Console.Clear(); Console.WriteLine("Please enter your first name!"); string firstName = Console.ReadLine(); Console.WriteLine(); Console.WriteLine("Please enter your last name!"); string lastName = Console.ReadLine(); Console.WriteLine(); var currentAdmin = admins.Where(a => a.FirstName.ToLower().Trim() == firstName.ToLower().Trim() && a.LastName.ToLower().Trim() == lastName.ToLower().Trim()).ToList(); if (currentAdmin.Count == 0) { Console.WriteLine("There is no admin with that personal infos!"); } else { //Admin Console.WriteLine("If you want to add Admins/Trainers/Students press 1"); Console.WriteLine("If you want to remove Admins/Trainers/Students press 2"); Console.WriteLine(); try { int inputChoice = Convert.ToInt32(Console.ReadLine()); if (inputChoice == 1) { // Add in list Admin.Add(admins, trainers, students); } else if (inputChoice == 2) { //Remove from list, but not it`s self Admin.Remove(admins, trainers, students, firstName, lastName); } else { Console.WriteLine("Wrong input!"); } } catch (Exception ex) { Console.WriteLine(ex.Message); } //RemoveAdmins(); } break; case 2: //Trainer Console.Clear(); Console.WriteLine("Please enter your first name!"); string firstNameTrainer = Console.ReadLine(); Console.WriteLine(); Console.WriteLine("Please enter your last name!"); string lastNameTrainer = Console.ReadLine(); Console.WriteLine(); var currentTrainer = trainers.Where(a => a.FirstName.ToLower().Trim() == firstNameTrainer.ToLower().Trim() && a.LastName.ToLower().Trim() == lastNameTrainer.ToLower().Trim()).ToList(); if (currentTrainer.Count == 0) { Console.WriteLine("There is no trainer with that personal infos!"); } else { //Trainer Console.WriteLine("If you want to see all Students -> press 1"); Console.WriteLine("If you want to see all Subjects -> press 2"); Console.WriteLine(); try { int inputChoice = Convert.ToInt32(Console.ReadLine()); if (inputChoice == 1) { //See all Students foreach (var student in students) { student.GetFullName(); } Console.WriteLine(); Console.WriteLine("Write the first name of the student you want to search!"); Console.WriteLine(); string studentName = Console.ReadLine(); var studentInStudents = students.Where(s => s.FirstName.ToLower().Trim() == studentName.ToLower().Trim()).FirstOrDefault(); if (studentInStudents == null) { Console.WriteLine("Wrong input of name!"); } else { Console.WriteLine($"{studentInStudents.FirstName} has attend to: "); Console.WriteLine(); int number = 1; foreach (var subject in studentInStudents.MySubject) { Console.WriteLine($"{number}){subject.Key.NameOfSubject}"); number++; } } } else if (inputChoice == 2) { //See all Subjects Console.WriteLine("All subjects:"); //When choosing Subjects, all Subject names appear with how many students attend it next to it foreach (var subject in subjects) { Console.WriteLine($"{subject.NameOfSubject} -> {subject.indicatiorOfStudents} students attend to it!"); } } else { Console.WriteLine("Wrong input!"); } } catch (Exception ex) { Console.WriteLine(ex.Message); } } break; case 3: //Student are shown subjects that they are listening and a list of their grades Console.WriteLine("Please enter your first name!"); string firstNameStudent = Console.ReadLine(); Console.WriteLine(); Console.WriteLine("Please enter your last name!"); string lastNameStudent = Console.ReadLine(); Console.WriteLine(); var currentStudent = students.Where(a => a.FirstName.ToLower() == firstNameStudent.ToLower() && a.LastName.ToLower() == lastNameStudent.ToLower()).ToList(); Console.WriteLine(); if (currentStudent.Count == 0) { Console.WriteLine("There is no student with that personal infos!"); } else { foreach (var student in currentStudent) { student.GetFullName(); foreach (var subject in student.MySubject) { Console.WriteLine($"Subject: {subject.Key.NameOfSubject} -> Grade: {subject.Value}"); } Console.WriteLine(); } } break; default: Console.WriteLine("Wrong input!"); break; } } catch (Exception ex) { Console.WriteLine(ex.Message); } Console.ReadLine(); }
public IResult Delete(Admin admin) { _adminDal.Delete(admin); return(new SuccessResult(Messages.AdminDeleted)); }
protected void initControl(int Id) { //txtContent.DisableFilter(Telerik.Web.UI.EditorFilters.ConvertCharactersToEntities); AdminBSO adminBSO = new AdminBSO(); Admin admin = new Admin(); if (Id > 0) { btn_add.Visible = false; btn_edit.Visible = true; btn_add1.Visible = false; btn_edit1.Visible = true; hddCommentID.Value = Convert.ToString(Id); try { NewsCommentBSO newsCommentBSO = new NewsCommentBSO(); NewsComment newsComment = newsCommentBSO.GetNewsCommentById(Id); txtTitle.Text = newsComment.Title; txtFullName.Text = newsComment.FullName; hddNewsID.Value = Convert.ToString(newsComment.NewsID); txtContent.Text = newsComment.Content; txtDateCreated.Text = String.Format("{0:dd/MM/yyyy HH:mm}", newsComment.DateCreated); //DateTime.Parse(newsgroup.PostDate.ToString()).ToString("dd/MM/yyyy hh:mm", ci); // newsgroup.PostDate.ToString(); hddPostDate.Value = String.Format("{0:dd/MM/yyyy HH:mm}", newsComment.DateCreated); // "9/3/2008 16:05:07" .ToString(); txtEmail.Text = newsComment.Email; // rdbActive.SelectedValue = newsComment.Actived.ToString(); hddGroup.Value = newsComment.GroupCate.ToString(); hddApprovalUserName.Value = newsComment.ApprovalUserName; hddApprovalDate.Value = Convert.ToString(newsComment.ApprovalDate); admin = adminBSO.GetAdminById(Session["Admin_UserName"].ToString()); if (Session["Admin_UserName"].ToString().Equals("administrator") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Approval")) { rdbActive.Checked = newsComment.Actived; rdbActive.Enabled = true; } else { rdbActive.Checked = newsComment.Actived; rdbActive.Enabled = false; } } catch (Exception ex) { clientview.Text = ex.Message.ToString(); } } else { btn_add.Visible = true; btn_edit.Visible = false; btn_add1.Visible = true; btn_edit1.Visible = false; // hddNewsID = 0; txtDateCreated.Text = String.Format("{0:dd/MM/yyyy HH:mm}", DateTime.Now); //DateTime.Parse(newsgroup.PostDate.ToString()).ToString("dd/MM/yyyy hh:mm", ci); // newsgroup.PostDate.ToString(); hddPostDate.Value = String.Format("{0:dd/MM/yyyy HH:mm}", DateTime.Now); // "9/3/2008 16:05:07" .ToString(); if (Session["Admin_UserName"].ToString().Equals("administrator") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Approval")) { rdbActive.Enabled = true; } else { rdbActive.Enabled = false; } } }
public void CreateRolesAdmin() { ApplicationDbContext context = new ApplicationDbContext(); var roleManager = new RoleManager <IdentityRole>(new RoleStore <IdentityRole>(context)); var userManager = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(context)); //creating role if (!roleManager.RoleExists("Admin")) { var role = new Microsoft.AspNet.Identity.EntityFramework.IdentityRole(); role.Name = "Admin"; roleManager.Create(role); } Admin ad = context.Admins.ToList().Find(x => x.Email == "*****@*****.**"); if (ad == null) { Admin newAdmin = new Admin { AdminID = Guid.NewGuid().ToString(), FirstName = "Administrator", LastName = "Admin", Email = "*****@*****.**" }; context.Admins.Add(newAdmin); context.SaveChanges(); var user = new ApplicationUser(); user.UserName = newAdmin.Email; user.Email = newAdmin.Email; string password = "******"; var User = userManager.Create(user, password); if (User.Succeeded) { userManager.AddToRole(user.Id, "Admin"); } } //populating initial role ////creating other roles //if (!roleManager.RoleExists("RankManager")) //{ // var role = new Microsoft.AspNet.Identity.EntityFramework.IdentityRole(); // role.Name = "RankManager"; // roleManager.Create(role); //} //if (!roleManager.RoleExists("Owner")) //{ // var role = new Microsoft.AspNet.Identity.EntityFramework.IdentityRole(); // role.Name = "Owner"; // roleManager.Create(role); //} //if (!roleManager.RoleExists("Driver")) //{ // var role = new Microsoft.AspNet.Identity.EntityFramework.IdentityRole(); // role.Name = "Driver"; // roleManager.Create(role); //} //if (!roleManager.RoleExists("Passenger")) //{ // var role = new Microsoft.AspNet.Identity.EntityFramework.IdentityRole(); // role.Name = "Passenger"; // roleManager.Create(role); //} }
public ActionResult ChangeRole(Admin admin) { adm.ChangeRole(admin.Id, admin.Role); return(RedirectToAction("Index")); }
private void Submit_btn_Click(object sender, EventArgs e) { LibraryDBDataContext db = new LibraryDBDataContext(); User loaded = User.LoadByUsername(Username_TB.Text); if (Username_TB.Text == "" || Password_TB.Text == "" || Repass_TB.Text == "") { MessageBox.Show("Please Enter Username and Passwords"); } else if (loaded != null && loaded.ID != me.ID) { MessageBox.Show("UserName Exists!"); } else if (Password_TB.Text != Repass_TB.Text) { MessageBox.Show("Passwords aren't identical!"); } else if (FName_TB.Text == "" || SName_TB.Text == "") { MessageBox.Show("Please Enter Your Name!"); } else if (Phone_TB.Text == "") { MessageBox.Show("Please Enter Your Phone Number!"); } else { User u = new User(); u.ID = me.ID; u.Username = Username_TB.Text; u.Password = Password_TB.Text; u.FName = FName_TB.Text; u.SName = SName_TB.Text; u.Birthdate = Birthdate_Picker.Value.Date; u.Address = Address_TB.Text; u.Email = Email_TB.Text; u.PhoneNumber = Phone_TB.Text; u.NationalID = NationalID_TB.Text; if (me.Rolename == RolesEnum.Admin) { u.Rolename = RolesEnum.Admin; Admin a = new Admin(); a.CopyInto(ref u); a.Shift = int.Parse(Shift_TB.Text); a.Salary = double.Parse(Salary_TB.Text); a.HireDate = HireDate_DB.Value.Date; a.SaveChanges(); this.Close(); } else { u.Rolename = RolesEnum.Student; Student s = new Student(); s.CopyInto(u); s.University = University_TB.Text; s.University_ID = Uni_ID_TB.Text; s.GPA = double.Parse(GPA_TB.Text); s.SaveChanges(); this.Close(); } } }
public ActionResult UpdateAdmin(Admin admin) { adminManager.AdminUpdate(admin); return(RedirectToAction("Index")); }
public ActionResult AddAdmin(Admin p) { adminManager.AdminAddBL(p); return(RedirectToAction("Index")); }
public BusForm(Admin ad) { InitializeComponent(); administrateur = ad; }
public csUsersGroups(string[] args) { parseArgs(args); Console.WriteLine("Admin: Create Users and Groups sample."); Console.WriteLine("Using server: " + serverUrl); try { // Create the admin connection to the TIBCO EMS server Admin admin = new Admin(serverUrl, username, password); // Create a UserInfo for each user UserInfo u1 = new UserInfo("mair", "Architect"); UserInfo u2 = new UserInfo("ahren", "Engineer"); // Create user "mair" try { u1 = admin.CreateUser(u1); Console.WriteLine("Created User: "******"mair"); Console.WriteLine("User already exists: " + u1); } // Create user "ahren" try { u2 = admin.CreateUser(u2); Console.WriteLine("Created User: "******"ahren"); Console.WriteLine("User already exists: " + u2); } // Change the password for user "mair" u1.Password = "******"; admin.UpdateUser(u1); u1 = admin.GetUser("mair"); Console.WriteLine("Updated User Password: "******"ahren" u2.Description = "Lead Engineer"; admin.UpdateUser(u2); u2 = admin.GetUser("ahren"); Console.WriteLine("Updated User Description: " + u2); // Create groups GroupInfo g1 = new GroupInfo("Managers", "Company managers"); try { g1 = admin.CreateGroup(g1); Console.WriteLine("Created Group: " + g1); } catch (AdminNameExistsException) { g1 = admin.GetGroup("Managers"); Console.WriteLine("Group already exists: " + g1); } GroupInfo g2 = new GroupInfo("Leads", "Company leads"); try { g2 = admin.CreateGroup(g2); Console.WriteLine("Created Group: " + g2); } catch (AdminNameExistsException) { g2 = admin.GetGroup("Leads"); Console.WriteLine("Group already exists: " + g2); } GroupInfo g3 = new GroupInfo("Employees", "Company employees"); try { g3 = admin.CreateGroup(g3); Console.WriteLine("Created Group: " + g3); } catch (AdminNameExistsException) { g3 = admin.GetGroup("Employees"); Console.WriteLine("Group already exists: " + g3); } // Change group description g1.Description = "Company managers, North America"; admin.UpdateGroup(g1); g1 = admin.GetGroup("Managers"); Console.WriteLine("Updated Group Description: " + g1); // Add user "mair" to the "Managers" group admin.AddUserToGroup(g1.Name, u1.Name); Console.WriteLine("Added User: \"" + u1.Name + "\" to Group: \"" + g1.Name + "\""); // Add users "mair" and "ahren" to the "Leads" group string[] users = new string[] { u1.Name, u2.Name }; admin.AddUsersToGroup(g2.Name, users); Console.WriteLine("Added Users: \"" + u1.Name + "\", \"" + u2.Name + "\" to Group: \"" + g2.Name + "\""); // Add users "mair" and "ahren" to the "Employees" group admin.AddUsersToGroup(g3.Name, users); Console.WriteLine("Added Users: \"" + u1.Name + "\", \"" + u2.Name + "\" to Group: \"" + g3.Name + "\""); // Get groups from server g1 = admin.GetGroup("Managers"); g2 = admin.GetGroup("Leads"); g3 = admin.GetGroup("Employees"); // Remove user "mair" from "Lead" group admin.RemoveUserFromGroup(g2.Name, u1.Name); Console.WriteLine("Removed User: \"" + u1.Name + "\" from Group: \"" + g2.Name + "\""); // Get groups from server GroupInfo[] groups = admin.Groups; Console.WriteLine("Groups defined in the server:"); for (int i = 0; i < groups.Length; i++) { Console.WriteLine("\t" + groups[i]); } } catch (AdminException e) { Console.Error.WriteLine("Exception in csUsersGroups: " + e.Message); Console.Error.WriteLine(e.StackTrace); Environment.Exit(-1); } }
private PaginationDataList <SetDto> GetPicBooksByTeacher(int?pageSize, int?pageRows, int setStatus, Admin admin) { List <SetDto> setDtoList = new List <SetDto>(); foreach (var teacherAllocation in admin.TeacherAllocations) { int allocatedNum = teacherAllocation.StudentAllocations.Count; if (FilterSetBySetStatus(setStatus, allocatedNum, teacherAllocation.Credit)) { continue; } var setInfo = _setRepostitory.GetAllIncluding(e => e.Books).FirstOrDefault(e => e.Id == teacherAllocation.SetId); SetDto setDto = new SetDto() { Id = teacherAllocation.SetId, SetName = setInfo.SetName, SetType = HintInfo.StandardCourse, Synopsis = setInfo.Synopsis, Books = setInfo.Books, DateCreated = teacherAllocation.DateAllocated, SurplusCredit = allocatedNum + "/" + teacherAllocation.Credit }; setDtoList.Add(setDto); } return(setDtoList.OrderByDescending(e => e.DateCreated).AsQueryable().ToPagination(pageSize, pageRows)); }
private PaginationDataList <SetDto> GetPicBooksByAdmin(int?pageSize, int?pageRows, int setStatus, Admin admin) { List <SetDto> setDtoList = new List <SetDto>(); var orderItems = admin.Orders.SelectMany(e => e.OrderItems); var payments = admin.Orders.SelectMany(e => e.Payments); foreach (var orderItem in orderItems) { var allocatedNum = orderItem.TeacherAllocations.Sum(e => e.Credit); if (FilterSetBySetStatus(setStatus, allocatedNum, orderItem.Quantity)) { continue; } SetDto setDto = new SetDto() { Id = orderItem.SetId, Synopsis = orderItem.Set.Synopsis, SetName = orderItem.Set.SetName, SetType = HintInfo.StandardCourse, Books = _bookRepostitory.GetAllList(e => e.SetId == orderItem.SetId), DateCreated = payments.FirstOrDefault(e => e.OrderRef == orderItem.OrderRef)?.DateCreated, SurplusCredit = allocatedNum + "/" + orderItem.Quantity }; setDtoList.Add(setDto); } return(setDtoList.OrderByDescending(e => e.DateCreated).AsQueryable().ToPagination(pageSize, pageRows)); }
public bool CanMakeAPayment(Admin admin) { return(true); }
public PartialViewResult Summary(Admin admin) { return(PartialView(admin)); }
/// <summary> /// 更新管理员信息 /// </summary> /// <param name="id"></param> /// <param name="diary"></param> /// <returns></returns> public Boolean UpdateAdmin(string adminAccount, Admin admin) { AdminAccess.UpdateAdmin(adminAccount, admin); return(true); }
public IResult Update(Admin admin) { _adminDal.Update(admin); return(new SuccessResult(Messages.AdminUpdated)); }
public async Task <Admin> UpdateAdmin(Admin admin) { var updated = await _adminRepository.Update(AdminMapper.Map(admin)); return(AdminMapper.Map(updated)); }
public IResult Add(Admin admin) { _adminDal.Add(admin); return(new SuccessResult(Messages.AdminAdded)); }
public AdminViewModel(Admin adminOpen) { adminr = adminOpen; }
public async Task <GetAllPaymentsVm> Handle(GetAllPaymentsQuery request, CancellationToken cancellationToken) { User currentUser = await _context.User .Where(x => x.UserGuid == Guid.Parse(_currentUser.NameIdentifier)) .SingleOrDefaultAsync(cancellationToken); if (currentUser == null) { return new GetAllPaymentsVm() { Message = "کاربر مورد نظر یافت نشد", State = (int)GetAllPaymentsState.UserNotFound } } ; Admin admin = await _context.Admin .SingleOrDefaultAsync(x => x.UserId == currentUser.UserId, cancellationToken); if (admin == null) { return new GetAllPaymentsVm() { Message = "ادمین مورد نظر یافت نشد", State = (int)GetAllPaymentsState.AdminNotFound } } ; IQueryable <Payment> payments = _context.Payment .AsQueryable(); if (request.ContractorGuid != null) { payments = payments.Where(x => x.Contractor.ContractorGuid == request.ContractorGuid); } if (!string.IsNullOrEmpty(request.StartDate)) { string monthName = request.StartDate.Substring(4, 3); _monthNumber.TryGetValue(monthName, out int month); // TODO: error handling //if (month == 0) return new GetAllPaymentsVm() //{ // Message = "تاریخ شروع نامعتبر", // State = (int)GetAllPaymentsState.InvalidStartDate //}; int day = Convert.ToInt32(request.StartDate.Substring(8, 2)); int year = Convert.ToInt32(request.StartDate.Substring(11, 4)); DateTime date = new DateTime(year, month, day); payments = payments.Where(x => x.CreationDate.Date >= date); } if (!string.IsNullOrEmpty(request.EndDate)) { string monthName = request.EndDate.Substring(4, 3); _monthNumber.TryGetValue(monthName, out int month); // TODO: error handling //if (month == 0) return new GetAllPaymentsVm() //{ // Message = "تاریخ پایان نامعتبر", // State = (int)GetAllPaymentsState.InvalidEndDate //}; int day = Convert.ToInt32(request.EndDate.Substring(8, 2)); int year = Convert.ToInt32(request.EndDate.Substring(11, 4)); DateTime date = new DateTime(year, month, day); payments = payments.Where(x => x.CreationDate.Date <= date); } if (request.SuccessfulStatus != null) { payments = payments.Where(x => x.IsSuccessful == request.SuccessfulStatus); } List <GetAllPaymentsDto> paymentsResult = await payments .OrderByDescending(x => x.CreationDate) .ProjectTo <GetAllPaymentsDto>(_mapper.ConfigurationProvider) .ToListAsync(cancellationToken); if (paymentsResult.Count <= 0) { return new GetAllPaymentsVm() { Message = "پرداختی یافت نشد", State = (int)GetAllPaymentsState.NotAnyPaymentsFound } } ; return(new GetAllPaymentsVm() { Message = "عملیات موفق آمیز", State = (int)GetAllPaymentsState.Success, Payments = paymentsResult }); } } } }
public AdminViewModel(Admin adminOpen, tblAccount accountToView, tblAdministrator adminToView) { adminr = adminOpen; account = accountToView; admin = adminToView; }
public ActionResult <Admin> Update([FromBody] Admin TargetAdmin) { return(methods.UpdateMethod(TargetAdmin)); }
// Create Admin public void CreateAdmin(Admin myAdmin) { adminC.Create(myAdmin); }
public void AddAdmin(Admin admin) { _userContext.Admins.Add(admin); Save(); }
public UserDao(AppConfiguration appConfiguration, DanmuContext context) { _admin = appConfiguration.GetAppSetting().Admin; _context = context; }
public AddCashierPage() { InitializeComponent(); admin = new Admin(); }
public bool CreateAdmin([FromBody] Admin admin) { return(Database.AddAdmin(admin)); }