private void AddClicked(object sender, EventArgs e) { if (this.textBoxSemesterName.Text != "") { char[] s = new char[4]; s[0] = this.textBoxSemesterName.Text[0]; s[1] = Char.ToUpper(this.textBoxSemesterName.Text[1]); s[2] = this.textBoxSemesterName.Text[this.textBoxSemesterName.Text.Length - 2]; s[3] = this.textBoxSemesterName.Text[this.textBoxSemesterName.Text.Length - 1]; string s1 = new string(s); Semester s2 = new Semester(); s2.SemesterId = s1; s2.Name = this.textBoxSemesterName.Text; s2.RegistrationStatus = "Close"; SemesterRepository sRepo = new SemesterRepository(); if (sRepo.Insert2(s2)) { MessageBox.Show("One Semester Added", "Successful"); this.dataGridViewSemesters.DataSource = sRepo.GetAllSemesters2(); this.textBoxSemesterName.Text = ""; } else { MessageBox.Show("Operation Failed / This Name Already Exists", "Failed"); } } }