public ActionResult Add(int id) { var viewModel = new StudentAddForm { classStructureId = id }; return(View("StudentForm", viewModel)); }
private void addToolStripMenuItem_Click(object sender, EventArgs e) { addToolStripMenuItem.Enabled = false; exitAddToolStripMenuItem.Enabled = true; this.Height = 600; StudentGridView.Hide(); SearchButton.Hide(); StudentSearctBox.Hide(); label10.Hide(); StudentAddForm.Show(); StudentDeleteButton.Hide(); label11.Hide(); label12.Hide(); FirstPageButton.Hide(); NextPageButton.Hide(); PreviousButton.Hide(); LastPageButton.Hide(); RefreshButton.Hide(); }
private void StudentInsertForm_Load(object sender, EventArgs e) { // TODO: This line of code loads data into the 'libraryDataSet1.Student' table. You can move, or remove it, as needed. // this.studentTableAdapter.Fill(this.libraryDataSet1.Student); label7.Hide(); // TODO: This line of code loads data into the 'sessionDataSet.Session' table. You can move, or remove it, as needed. this.sessionTableAdapter.Fill(this.sessionDataSet.Session); SessionComboBox.SelectedValue = 0; DepartmentComboBox.SelectedValue = 0; label4.Hide(); label5.Hide(); label6.Hide(); label16.Hide(); label15.Hide(); this.Height = 650; label9.Hide(); label11.Hide(); label12.Hide(); StudentAddForm.Hide(); label8.Hide(); StudentGridView.ForeColor = Color.Black; LoadStudentGridView(); using (var con = new SqlConnection(@"data source=.\SQLEXPRESS;DATABASE=Library ;Integrated Security=true;")) { var cmd = new SqlCommand("select DepartmentShortName,DepartmentFullName from Department", con); con.Open(); var reader = cmd.ExecuteReader(); while (reader.Read()) { try { var departmenShortName = reader.GetString(0); var departmenFullName = reader.GetString(1); string departmenName = ""; departmenName = departmenShortName != "" ? departmenShortName : departmenFullName; DepartmentComboBox.Items.Add(departmenName); } catch (Exception exception) { MessageBox.Show(exception.Message); } } } exitAddToolStripMenuItem.Enabled = false; }
public ActionResult Add(StudentAddForm viewModel) { string UserName = viewModel.UserName; string RoleName = "Student"; int id = viewModel.classStructureId; ApplicationUser user = _context.Users.Where(u => u.UserName.Equals(UserName, StringComparison.CurrentCultureIgnoreCase)).FirstOrDefault(); UserManager.AddToRole(user.Id, RoleName); var student = new ClassOrganisation { ClassStructureId = viewModel.classStructureId, StudentId = user.Id, }; _context.ClassOrganisation.Add(student); _context.SaveChanges(); return(RedirectToAction("Index", new { id = id })); }