private void btnLogout_Click(object sender, EventArgs e) { UserRequsts.Logout(); this.Close(); login.Opacity = 100; login.ShowInTaskbar = true; }
private void button1_Click(object sender, EventArgs e) { int idUser = (int)comboBox1.SelectedValue; UserRequsts.RemoveUser(idUser); this.Close(); }
private void EditUser_Load(object sender, EventArgs e) { HttpWebRequest request; HttpWebResponse response; string content; teamLeaders = UserRequsts.GetAllTeamLeaders(); //fill comboBox with team leaders comboBoxTeamLeaderEdit.DataSource = teamLeaders; comboBoxTeamLeaderEdit.ValueMember = "UserId"; comboBoxTeamLeaderEdit.DisplayMember = "UserName"; //fill comboBox with userKinds usersKind = UsersKindRequst.GetAllUsersKind(); comboBoxUserKindEdit.DataSource = usersKind; comboBoxUserKindEdit.ValueMember = "KindUserId"; comboBoxUserKindEdit.DisplayMember = "KindUserName"; //get all the workers and fill the combobox allUsers = UserRequsts.GetAllUsers(); comboBoxAllUsers.SelectedIndexChanged -= new EventHandler(ComboBoxAllUsers_SelectedIndexChanged); comboBoxAllUsers.DataSource = allUsers; comboBoxAllUsers.ValueMember = "UserId"; comboBoxAllUsers.DisplayMember = "UserName"; comboBoxAllUsers.SelectedIndexChanged += ComboBoxAllUsers_SelectedIndexChanged; }
private void LoginButton_Click(object sender, EventArgs e) { string userName = textBoxUserName.Text; string password = sha256(textBoxPassword.Text); try { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(@"http://localhost:56028/api/users/Login/" + userName + "/" + password); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); if (response.StatusCode == HttpStatusCode.OK) { string content = new StreamReader(response.GetResponseStream()).ReadToEnd(); user = JsonConvert.DeserializeObject <User>(content); } MessageBox.Show(user.UserName); textBoxUserName.Text = string.Empty; textBoxPassword.Text = string.Empty; checkState(); ip = GetLocalIPAddress(); user.UserIP = ip; UserRequsts.UpdateUser(user); } catch (Exception) { MessageBox.Show("the user is not exists"); } }
private void comboBoxUsers_SelectedIndexChanged(object sender, EventArgs e) { selectedUser = UserRequsts.GetUserById((int)comboBoxUsers.SelectedValue); ProjectsForUser = ProjectsRequst.GetProjectsByUserId((int)comboBoxUsers.SelectedValue); if (ProjectsForUser != null) { for (int i = 0; i < ProjectsForteamLeader.Count; i++) { for (int j = 0; j < ProjectsForUser.Count; j++) { if (ProjectsForteamLeader[i].ProjectId == ProjectsForUser[j].ProjectId) { commonProjectsInTheList.Add(ProjectsForteamLeader[i]); } } } //var results = ProjectsForteamLeader.Join(ProjectsForUser, ptl => ptl.ProjectId, p => p.ProjectId, (post, meta) => new { Post = post, Meta = meta }); comboBoxProjects.SelectedIndexChanged -= new EventHandler(comboBoxProjects_SelectedIndexChanged); comboBoxProjects.DataSource = commonProjectsInTheList; comboBoxProjects.DisplayMember = "ProjectName"; comboBoxProjects.ValueMember = "ProjectId"; comboBoxProjects.SelectedIndexChanged += comboBoxProjects_SelectedIndexChanged; numericCountHours.Value = 0; // MessageBox.Show("success"); } else { comboBoxProjects.DataSource = null; } }
private void buttonUpdate_Click(object sender, EventArgs e) { user = new User() { UserEmail = textBoxEmailEdit.Text, UserName = textBoxUserNameEdit.Text, TeamLeaderId = (int)comboBoxTeamLeaderEdit.SelectedValue, UserKindId = (int)comboBoxUserKindEdit.SelectedValue }; user.UserId = (int)comboBoxAllUsers.SelectedValue; var validationContext = new ValidationContext(user, null, null); var results = new List <ValidationResult>(); if (Validator.TryValidateObject(user, validationContext, results, true)) { if (UserRequsts.UpdateUser(user)) { MessageBox.Show("update success"); } else { MessageBox.Show("update filed"); } } else { MessageBox.Show(string.Join(",\n", results.Select(p => p.ErrorMessage))); } }
public Login() { InitializeComponent(); ip = GetLocalIPAddress(); user = UserRequsts.checkUserIp(ip); if (user != null) { checkState(); } }
private void UpdateHours_Load(object sender, EventArgs e) { usersUnderTeamLeader = UserRequsts.GetUsersForTeamLeader(); if (usersUnderTeamLeader != null) { comboBoxUsers.SelectedIndexChanged -= new EventHandler(comboBoxUsers_SelectedIndexChanged); comboBoxUsers.DataSource = usersUnderTeamLeader; comboBoxUsers.ValueMember = "UserId"; comboBoxUsers.DisplayMember = "UserName"; comboBoxUsers.SelectedIndexChanged += comboBoxUsers_SelectedIndexChanged; } ProjectsForteamLeader = ProjectsRequst.GetProjectsByTeamLeaderId(); allWorkersToProject = WokrerToProjectRequst.GetWorkersToProjects(); }
private void AddProject_Load(object sender, EventArgs e) { HttpWebRequest request; HttpWebResponse response; string content; //fill comboBox With teamLeaders teamLeaders = UserRequsts.GetAllTeamLeaders(); comboBoxTeamLeader.DataSource = teamLeaders; comboBoxTeamLeader.ValueMember = "UserId"; comboBoxTeamLeader.DisplayMember = "UserName"; //get all the another workers allUsers = UserRequsts.GetAllUsers(); }
private void RemoveUser_Load(object sender, EventArgs e) { HttpWebRequest request; HttpWebResponse response; string content; teamLeaders = UserRequsts.GetAllTeamLeaders(); //fill comboBox with userKinds usersKind = UsersKindRequst.GetAllUsersKind(); //get all the workers and fill the combobox allUsers = UserRequsts.GetAllUsers(); comboBox1.DataSource = allUsers; comboBox1.ValueMember = "UserId"; comboBox1.DisplayMember = "UserName"; }
override protected ValidationResult IsValid(object value, ValidationContext validationContext) { List <User> users = UserRequsts.GetAllUsers(); object instance = validationContext.ObjectInstance; Type type = instance.GetType(); PropertyInfo property = type.GetProperty("UserId"); object propertyValue = property.GetValue(instance); int.TryParse(propertyValue.ToString(), out int UserId); bool isUniqe = users.Any(user => user.UserName.Equals(value.ToString()) && user.UserId != UserId) == false; if (isUniqe == false) { return(new ValidationResult("the Name is already exist")); } else { return(null); } }
private void FillUserDetails() { var validationContext = new ValidationContext(user, null, null); var results = new List <ValidationResult>(); if (Validator.TryValidateObject(user, validationContext, results, true)) { if (UserRequsts.AddUser(user)) { MessageBox.Show("added success"); } else { MessageBox.Show("faild"); } } else { MessageBox.Show(string.Join(",\n", results.Select(p => p.ErrorMessage))); } }
private void btnSave_Click(object sender, EventArgs e) { this.user.Password = UserRequsts.sha256(tbPassword.Text); UserRequsts.UpdatePassword(user); this.Close(); }
private void buttonUpdate_Click(object sender, EventArgs e) { workerToProject.Hours = (int)numericCountHours.Value; //update the worker to project with the houers //check if is valid var validationContext = new ValidationContext(workerToProject, null, null); var results = new List <ValidationResult>(); if (Validator.TryValidateObject(workerToProject, validationContext, results, true)) { sumAllActual = 0; flagHours = false; User tmpUser; var kindId = selectedUser.UserKindId; allWorkersToProject = allWorkersToProject.Where(p => p.ProjectId == selectedProject.ProjectId).ToList(); foreach (var item in allWorkersToProject) { tmpUser = UserRequsts.GetUserById(item.UserId); if (tmpUser.UserKindId == kindId && tmpUser.UserId != this.selectedUser.UserId) { sumAllActual += item.Hours; } } // workerToProject.Hours switch (kindId) { case 3: if (selectedProject.DevelopersHours < this.sumAllActual + workerToProject.Hours) { MessageBox.Show("Exceeded the hours allotted for development for this project"); flagHours = true; } break; case 4: if (selectedProject.QaHours < this.sumAllActual + workerToProject.Hours) { MessageBox.Show("Exceeded the hours allotted for QA for this project"); flagHours = true; } break; case 5: if (selectedProject.UiUxHours < this.sumAllActual + workerToProject.Hours) { MessageBox.Show("Exceeded the hours allotted for Ui/Ux for this project"); flagHours = true; } break; } if (this.flagHours == false) { if (WokrerToProjectRequst.UpdateWorkerToProject(workerToProject)) { MessageBox.Show("update success"); } else { MessageBox.Show("update filed"); } } else { MessageBox.Show("update filed"); } } else { MessageBox.Show(string.Join(",\n", results.Select(p => p.ErrorMessage))); } }
private void buttonRemove_Click(object sender, EventArgs e) { int idUser = (int)comboBoxAllUsersRemove.SelectedValue; UserRequsts.RemoveUser(idUser); }