private void btnSave_Click(object sender, EventArgs e)
 {
     try {
         int rowsaffected = MitchellDAL.EditTutor(Convert.ToInt32(tb_ID.Text), tb_Name.Text, tb_Surname.Text, tb_Address1.Text, tb_Address2.Text, tb_Postcode.Text, tb_Tel.Text, tb_Instrument.Text);
         if (rowsaffected == 1)
         {
             add.showBalloonTip("Success", "Successfully Updated Tutor Details");
         }
         else
         {
             add.showBalloonTip("UnSuccessful", "Could not update Tutor Details");
         }
         // this.Dispose();
         this.Hide();
         Tutor_Details mynextscreen = new Tutor_Details();
         mynextscreen.ShowDialog();
         Close();
     }
     catch (Exception ex)
     {
         if (count1 < 1)
         {
             add.showBalloonTip("Error", "Something Went Wrong");
         }
         System.IO.StreamWriter writer = new System.IO.StreamWriter("../../ErrorLog.txt", true);
         writer.WriteLine("- " + DateTime.Now + " " + ex.Message, true);
         writer.Flush();
         writer.Close();
         count1++;
     }
 }
 private void btnSave_Click(object sender, EventArgs e)
 {
     btnSave.Enabled = false;
     try {
         if (Controls.OfType <TextBox>().Any(t => t.Text == ""))
         {
             showBalloonTip("Field entries", "All Fields must be used");
         }
         else if (Controls.OfType <ComboBox>().Any(t => t.Text == ""))
         {
             showBalloonTip("Field entries", "All Fields must be used");
         }
         else
         {
             int rowsAffected = MitchellDAL.AddNewStudent(Convert.ToInt32(tb_ID.Text), tb_Name.Text, tb_Surname.Text, tb_Address1.Text, tb_Address2.Text, tb_Postcode.Text, tb_Tel.Text, Convert.ToInt32(tb_Tutor.Text), tb_Instrument.Text, cbo_Status.Text, tb_Start.Text, cboClass.Text, (bool)checkBox1.Checked, cboLevel.Text);
             if (rowsAffected == 1)
             {
                 showBalloonTip("Successful", "Successfully Added Student");
             }
             else
             {
                 showBalloonTip("UnSuccessful", "Could Not Add Student");
             }
             // this.Dispose();
             this.Hide();
             StudentDetails mynextscreen = new StudentDetails();
             mynextscreen.ShowDialog();
             Close();
         }
     }
     catch (Exception ex)
     {
         if (count < 1)
         {
             showBalloonTip("Error", "Something Went Wrong");
         }
         System.IO.StreamWriter writer = new System.IO.StreamWriter("../../ErrorLog.txt", true);
         writer.WriteLine("- " + DateTime.Now + " " + ex.Message, true);
         writer.Flush();
         writer.Close();
         count++;
     }
     btnSave.Enabled = true;
 }
 private void btnSave_Click(object sender, EventArgs e)
 {
     try {
         if (Controls.OfType <TextBox>().Any(t => t.Text == ""))
         {
             student.showBalloonTip("Field entries", "All Fields must be used");
         }
         else if (Controls.OfType <ComboBox>().Any(t => t.Text == ""))
         {
             student.showBalloonTip("Field entries", "All Fields must be used");
         }
         else
         {
             int rowsAffected = MitchellDAL.AddNewTutor(Convert.ToInt32(tb_ID.Text), tb_Name.Text, tb_Surname.Text, tb_Address1.Text, tb_Address2.Text, tb_Postcode.Text, tb_Tel.Text, tb_Instrument.Text, tb_DOB.Text);
             if (rowsAffected == 1)
             {
                 student.showBalloonTip("Success", "Successfully Added Tutor");
             }
             else
             {
                 student.showBalloonTip("Unsuccessful", "Could not add Tutor");
             }
             //this.Dispose();
             this.Hide();
             Tutor_Details mynextscreen = new Tutor_Details();
             mynextscreen.ShowDialog();
             Dispose();
         }
     }
     catch (Exception ex)
     {
         if (count < 1)
         {
             add.showBalloonTip("Error", "Something Went Wrong");
         }
         System.IO.StreamWriter writer = new System.IO.StreamWriter("../../ErrorLog.txt", true);
         writer.WriteLine("- " + DateTime.Now + " " + ex.Message, true);
         writer.Flush();
         writer.Close();
         count++;
     }
 }
예제 #4
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            try {
                frmAddStudent student = new frmAddStudent();

                int rowsAffected = MitchellDAL.DeleteStudent(Convert.ToInt32(tb_Student_Delete.Text));

                if (rowsAffected == 0)
                {
                    student.showBalloonTip("Delete Successful", "Successfully deleted Student");
                }
                else
                {
                    student.showBalloonTip("Delete Unsuccessful", "Could not delete Student");
                }
                //this.Dispose();
                this.Hide();
                StudentDetails mynextscreen = new StudentDetails();
                mynextscreen.ShowDialog();
                Close();
            }
            catch (Exception ex) {
                if (count < 1)
                {
                    add.showBalloonTip("Error", "Something Went Wrong");
                }
                System.IO.StreamWriter writer = new System.IO.StreamWriter("../../ErrorLog.txt", true);
                writer.WriteLine("- " + DateTime.Now + " " + ex.Message, true);
                writer.Flush();
                writer.Close();
                count++;
                this.Hide();
                StudentDetails nextScreen = new StudentDetails();
                nextScreen.ShowDialog();
                //this.Dispose();
                Close();
            }
        }