Esempio n. 1
0
        private void shortcut_Click(object sender, RoutedEventArgs e)
        {
            ViewTeacher viewTeacher = new ViewTeacher();

            (this.Parent as Grid).Children.Add(viewTeacher);
            (this.Parent as Grid).Children.Remove(this);
        }
Esempio n. 2
0
 private void save_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         SQLiteConnection conn;
         conn = new SQLiteConnection(@"Data Source=D:\Software Testing and QA\Database\MainDatabase.db;Version=3;");
         conn.Open();
         if (teacher_name.Text == "" || teacher_contact_no.Text == "" || teacher_subject.Text == "" || teacher_code.Text == "")
         {
             string msg = "Enter Teacher Name, Contact Number, Subject and Teacher Code (Mandatory)";
             MessageBox.Show(msg);
             return;
         }
         Int64 temp;
         if (!(Int64.TryParse(teacher_contact_no.Text, out temp)))
         {
             MessageBox.Show("Enter proper contact number");
             return;
         }
         string sql;
         if (updateTeacher == null)
         {
             sql = "INSERT INTO teacher( teacher_name, teacher_contact_no, qualification, other_details, teacher_email, teacher_code, teacher_subject, timing_optional) VALUES('"
                   + teacher_name.Text + "', '"
                   + teacher_contact_no.Text + "', '"
                   + qualification.Text + "', '"
                   + other_details.Text + "', '"
                   + teacher_email.Text + "', '"
                   + teacher_code.Text + "', '"
                   + teacher_subject.Text + "', '"
                   + timing_optional.Text + "');";
         }
         else
         {
             sql = "update teacher set teacher_name='" + teacher_name.Text + "', teacher_contact_no='"
                   + teacher_contact_no.Text + "', qualification= '"
                   + qualification.Text + "', other_details= '"
                   + other_details.Text + "', teacher_email='"
                   + teacher_email.Text + "', teacher_code='"
                   + teacher_code.Text + "', teacher_subject='"
                   + teacher_subject.Text + "', timing_optional='"
                   + timing_optional.Text + "' where teacher_code='" + updateTeacher + "';";
         }
         SQLiteCommand command = new SQLiteCommand(sql, conn);
         command.ExecuteNonQuery();
         teacher_name.Text            = teacher_contact_no.Text = qualification.Text = other_details.Text = "";
         teacher_email.Text           = teacher_code.Text = teacher_subject.Text = "";
         timing_optional.SelectedItem = timing_optional.Items[0];
         conn.Close();
         FillDataGrid();
         if (updateTeacher == null)
         {
             //MessageBox.Show("Saved");
             MessageBox.Show("Saved");
         }
         else
         {
             ViewTeacher vwteach = new ViewTeacher();
             vwteach.FillDataGrid();
             (this.Parent as Grid).Children.Add(vwteach);
             (this.Parent as Grid).Children.Remove(this);
         }
     }
     catch (SQLiteException eg)
     {
         MessageBox.Show(eg.Message);
     }
     catch (Exception ex)
     {
         string msg = ex.GetType().Name + " : " + ex.Message;
         MessageBox.Show(msg);
     }
 }