StudentsForm Cs
StudentsForm Cs
using System.Data.SqlClient;
using System.Windows.Forms;
namespace ScolariteApp
public StudentsForm()
InitializeComponent();
LoadStudents();
try
connection.Open();
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();
this.SuspendLayout();
//
// listBoxStudents
//
this.listBoxStudents.FormattingEnabled = true;
this.listBoxStudents.Name = "listBoxStudents";
this.listBoxStudents.TabIndex = 0;
//
// txtName
//
this.txtName.Location = new System.Drawing.Point(120, 200);
this.txtName.Name = "txtName";
this.txtName.TabIndex = 1;
//
// txtGrade
//
this.txtGrade.Name = "txtGrade";
this.txtGrade.TabIndex = 2;
//
// btnAddStudent
//
this.btnAddStudent.Name = "btnAddStudent";
this.btnAddStudent.TabIndex = 3;
this.btnAddStudent.UseVisualStyleBackColor = true;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(50, 203);
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 = "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();