New Rich Text Document
New Rich Text Document
using System.Data.SqlClient;
using System.Windows.Forms;
namespace ScolariteApp
[STAThread]
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new LoginForm());
public LoginForm()
{
InitializeComponent();
this.SuspendLayout();
//
// txtUsername
//
this.txtUsername.Name = "txtUsername";
this.txtUsername.TabIndex = 0;
//
// txtPassword
//
this.txtPassword.Name = "txtPassword";
this.txtPassword.PasswordChar = '*';
//
// btnLogin
//
this.btnLogin.Name = "btnLogin";
this.btnLogin.TabIndex = 2;
this.btnLogin.Text = "Login";
this.btnLogin.UseVisualStyleBackColor = true;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Name = "label1";
this.label1.TabIndex = 3;
this.label1.Text = "Username";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(53, 13);
this.label2.TabIndex = 4;
this.label2.Text = "Password";
//
// LoginForm
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.btnLogin);
this.Controls.Add(this.txtPassword);
this.Controls.Add(this.txtUsername);
this.Name = "LoginForm";
this.Text = "Login";
this.ResumeLayout(false);
this.PerformLayout();
MessageBox.Show("Login successful!");
mainForm.Show();
this.Hide();
else
public MainForm()
InitializeComponent();
}
private void InitializeComponent()
this.SuspendLayout();
//
// btnManageStudents
//
this.btnManageStudents.Name = "btnManageStudents";
this.btnManageStudents.TabIndex = 0;
this.btnManageStudents.UseVisualStyleBackColor = true;
this.btnManageStudents.Click += new
System.EventHandler(this.btnManageStudents_Click);
//
// btnManageTeachers
//
this.btnManageTeachers.Name = "btnManageTeachers";
this.btnManageTeachers.TabIndex = 1;
this.btnManageTeachers.Text = "Manage Teachers";
this.btnManageTeachers.UseVisualStyleBackColor = true;
this.btnManageTeachers.Click += new
System.EventHandler(this.btnManageTeachers_Click);
//
// btnManageSubjects
//
this.btnManageSubjects.Name = "btnManageSubjects";
this.btnManageSubjects.TabIndex = 2;
this.btnManageSubjects.UseVisualStyleBackColor = true;
this.btnManageSubjects.Click += new
System.EventHandler(this.btnManageSubjects_Click);
//
// btnManageResults
//
this.btnManageResults.Name = "btnManageResults";
this.btnManageResults.TabIndex = 3;
this.btnManageResults.UseVisualStyleBackColor = true;
this.btnManageResults.Click += new
System.EventHandler(this.btnManageResults_Click);
//
// btnManageAttendance
//
this.btnManageAttendance.Name = "btnManageAttendance";
this.btnManageAttendance.TabIndex = 4;
this.btnManageAttendance.UseVisualStyleBackColor = true;
this.btnManageAttendance.Click += new
System.EventHandler(this.btnManageAttendance_Click);
//
// MainForm
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.btnManageAttendance);
this.Controls.Add(this.btnManageResults);
this.Controls.Add(this.btnManageSubjects);
this.Controls.Add(this.btnManageTeachers);
this.Controls.Add(this.btnManageStudents);
this.Name = "MainForm";
this.ResumeLayout(false);
{
StudentsForm studentsForm = new StudentsForm();
studentsForm.Show();
teachersForm.Show();
subjectsForm.Show();
resultsForm.Show();
attendanceForm.Show();
}
public StudentsForm()
InitializeComponent();
LoadStudents();
this.SuspendLayout();
//
// listBoxStudents
//
this.listBoxStudents.FormattingEnabled = true;
this.listBoxStudents.Name = "listBoxStudents";
this.listBoxStudents.TabIndex = 0;
//
// txtName
//
this.txtName.Name = "txtName";
this.txtName.TabIndex = 1;
//
// txtGrade
//
this.txtGrade.Name = "txtGrade";
//
// btnAddStudent
//
this.btnAddStudent.Name = "btnAddStudent";
this.btnAddStudent.TabIndex = 3;
this.btnAddStudent.UseVisualStyleBackColor = true;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Name = "label1";
this.label1.TabIndex = 4;
this.label1.Text = "Name";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(36, 13);
this.label2.TabIndex = 5;
this.label2.Text = "Grade";
//
// StudentsForm
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.btnAddStudent);
this.Controls.Add(this.txtGrade);
this.Controls.Add(this.txtName);
this.Controls.Add(this.listBoxStudents);
this.Name = "StudentsForm";
this.ResumeLayout(false);
this.PerformLayout();
try
connection.Open();
string query = "SELECT * FROM Students";
listBoxStudents.Items.Clear();
while (reader.Read())
listBoxStudents.Items.Add(studentInfo);
reader.Close();
finally
connection.Close();
return;
try
connection.Open();
string query = "INSERT INTO Students (Name, Grade) VALUES (@Name, @Grade)";
command.Parameters.AddWithValue("@Name", name);
command.Parameters.AddWithValue("@Grade", grade);
command.ExecuteNonQuery();
txtName.Clear();
txtGrade.Clear();
LoadStudents();
finally
{
connection.Close();
public TeachersForm()
InitializeComponent();
LoadTeachers();
this.SuspendLayout();
//
// listBoxTeachers
//
this.listBoxTeachers.FormattingEnabled = true;
this.listBoxTeachers.Name = "listBoxTeachers";
this.listBoxTeachers.TabIndex = 0;
//
// txtName
//
this.txtName.Name = "txtName";
this.txtName.TabIndex = 1;
//
// txtSpecialization
//
this.txtSpecialization.Location = new System.Drawing.Point(120, 230);
this.txtSpecialization.Name = "txtSpecialization";
this.txtSpecialization.TabIndex = 2;
//
// btnAddTeacher
//
this.btnAddTeacher.Name = "btnAddTeacher";
this.btnAddTeacher.TabIndex = 3;
this.btnAddTeacher.UseVisualStyleBackColor = true;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Name = "label1";
this.label1.TabIndex = 4;
this.label1.Text = "Name";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Name = "label2";
this.label2.TabIndex = 5;
this.label2.Text = "Specialization";
//
// TeachersForm
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.btnAddTeacher);
this.Controls.Add(this.txtSpecialization);
this.Controls.Add(this.txtName);
this.Controls.Add(this.listBoxTeachers);
this.Name = "TeachersForm";
this.ResumeLayout(false);
this.PerformLayout();
{
try
connection.Open();
listBoxTeachers.Items.Clear();
while (reader.Read())
listBoxTeachers.Items.Add(teacherInfo);
reader.Close();
finally
connection.Close();
if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(specialization))
return;
try
connection.Open();
command.Parameters.AddWithValue("@Name", name);
command.Parameters.AddWithValue("@Specialization", specialization);
command.ExecuteNonQuery();
txtName.Clear();
txtSpecialization.Clear();
LoadTeachers();
{
MessageBox.Show("Error: " + ex.Message);
finally
connection.Close();
public SubjectsForm()
InitializeComponent();
LoadSubjects();
}
this.SuspendLayout();
//
// listBoxSubjects
//
this.listBoxSubjects.FormattingEnabled = true;
this.listBoxSubjects.Name = "listBoxSubjects";
this.listBoxSubjects.TabIndex = 0;
//
// txtName
//
this.txtName.Name = "txtName";
this.txtName.TabIndex = 1;
//
// txtTeacherID
//
this.txtTeacherID.Name = "txtTeacherID";
this.txtTeacherID.TabIndex = 2;
//
// btnAddSubject
//
this.btnAddSubject.Name = "btnAddSubject";
this.btnAddSubject.TabIndex = 3;
this.btnAddSubject.UseVisualStyleBackColor = true;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Name = "label1";
this.label1.TabIndex = 4;
this.label1.Text = "Name";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Name = "label2";
this.label2.TabIndex = 5;
//
// SubjectsForm
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.btnAddSubject);
this.Controls.Add(this.txtTeacherID);
this.Controls.Add(this.txtName);
this.Controls.Add(this.listBoxSubjects);
this.Name = "SubjectsForm";
this.ResumeLayout(false);
this.PerformLayout();
}
private void LoadSubjects()
try
connection.Open();
listBoxSubjects.Items.Clear();
while (reader.Read())
listBoxSubjects.Items.Add(subjectInfo);
reader.Close();
finally
connection.Close();
}
}
return;
try
connection.Open();
command.Parameters.AddWithValue("@Name", name);
command.Parameters.AddWithValue("@TeacherID", teacherID);
command.ExecuteNonQuery();
txtName.Clear();
txtTeacherID.Clear();
LoadSubjects();
}
finally
connection.Close();