private void btn_Add_Click(object sender, EventArgs e)
 {
     if (txt_Name.Text.Replace(" ", "") != "" || txt_LastName.Text.Replace(" ", "") != "")
     {
         DialogResult dr = MessageBox.Show("Do you Want To Add ?", "CRUD", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (dr == DialogResult.Yes)
         {
             DbDataContext dbdc = new DbDataContext();
             tbl_Student   tbls = new tbl_Student()
             {
                 S_Name         = txt_Name.Text,
                 S_LastName     = txt_LastName.Text,
                 S_NationalCode = txt_NationalCode.Text
             };
             dbdc.tbl_Students.InsertOnSubmit(tbls);
             dbdc.SubmitChanges();
             dgv_Data.DataSource = dbdc.tbl_Students;
             S_ID = "";
             Clear();
         }
     }
     else
     {
         if (txt_Name.Text.Replace(" ", "") != "")
         {
             MessageBox.Show("Please enter Student Name", "CRUD", MessageBoxButtons.OK, MessageBoxIcon.Information);
             txt_Name.Focus();
         }
         else
         {
             MessageBox.Show("Please enter Student Lastname", "CRUD", MessageBoxButtons.OK, MessageBoxIcon.Information);
             txt_LastName.Focus();
         }
     }
 }
Пример #2
0
 partial void Updatetbl_Student(tbl_Student instance);
Пример #3
0
 partial void Deletetbl_Student(tbl_Student instance);
Пример #4
0
 partial void Inserttbl_Student(tbl_Student instance);