private void BackButton_Click(object sender, EventArgs e) { ManageAssignAdvisorToProject form = new ManageAssignAdvisorToProject(); form.Show(); this.Close(); }
/*private void GoToGroupsForm_Click(object sender, EventArgs e) * { * ManageGroups form = new ManageGroups(); * form.Show(); * this.Hide(); * }*/ /*private void AssignProjectButton_Click(object sender, EventArgs e) * { * GroupProjects form = new GroupProjects(); * form.Show(); * this.Hide(); * }*/ private void ProjectAdvsiors_Click(object sender, EventArgs e) { ManageAssignAdvisorToProject form = new ManageAssignAdvisorToProject(); form.Show(); this.Hide(); }
private void AssignAdvisorButton_Click(object sender, EventArgs e) { try { if (ProjectsComboBox.Text == "" || AdvisorComboBox.Text == "" || RoleComboBox.Text == "") { throw new ArgumentException(); } string projectTitle = ProjectsComboBox.Text; string AdvisorName = AdvisorComboBox.Text; SqlConnection conn = new SqlConnection(connString); conn.Open(); string query1 = string.Format("SELECT Id FROM Project WHERE Title = '{0}'", projectTitle); SqlCommand cmd = new SqlCommand(query1, conn); int pid = (Int32)cmd.ExecuteScalar(); cmd.CommandText = string.Format("SELECT Advisor.Id FROM Person JOIN Advisor ON Person.Id = Advisor.Id WHERE CONCAT(FirstName,' ', LastName) = '{0}'", AdvisorName); int Aid = (Int32)cmd.ExecuteScalar(); cmd.CommandText = string.Format("SELECT Id FROM LookUp WHERE Value = '{0}' AND CATEGORY = 'ADVISOR_ROLE'", RoleComboBox.Text); int Rid = (Int32)cmd.ExecuteScalar(); if (value != "edit") { string query = string.Format("INSERT INTO ProjectAdvisor(AdvisorId, ProjectId, AdvisorRole, AssignmentDate) Values('{0}', '{1}', '{2}', '{3}')", Aid, pid, Rid, DateTime.Now); cmd.CommandText = query; cmd.ExecuteNonQuery(); MessageBox.Show(string.Format("Advisor assigned to project '{0}'", projectTitle)); } else if (value == "edit") { cmd.CommandText = string.Format("UPDATE ProjectAdvisor SET AdvisorRole = '{0}' WHERE ProjectId = '{1}' AND AdvisorId = '{2}'", Rid, pid, Aid); cmd.ExecuteNonQuery(); MessageBox.Show("Advisor Role Updated!"); } ManageAssignAdvisorToProject form = new ManageAssignAdvisorToProject(); form.Show(); this.Close(); } catch (Exception) { MessageBox.Show("Please select project, advisor and advisor role from drop-down list"); } }