Пример #1
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     try {
         int rowsaffected = MitchellDAL.EditStudent(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, cboClass.Text, checkBox1.Checked, cboLevel.Text);
         if (rowsaffected == 1)
         {
             add.showBalloonTip("Success", "Successfully Updated Student Details");
         }
         else
         {
             add.showBalloonTip("UnSuccessful", "Could not update Student Details");
         }
         //
         this.Hide();
         StudentDetails mynextscreen = new StudentDetails();
         mynextscreen.ShowDialog();
         this.Dispose();
     }
     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 pbHome_Click(object sender, EventArgs e)
        {
            //Form Hidden, New Form opened, Current Resources Disposed of
            this.Hide();
            StudentDetails nextScreen = new StudentDetails();

            nextScreen.ShowDialog();
        }
        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Dispose();
            this.Hide();
            StudentDetails mynextscreen = new StudentDetails();

            mynextscreen.ShowDialog();
        }
Пример #4
0
 private void tb_Student_Delete_TextChanged(object sender, EventArgs e)
 {
     if (tb_Student_Delete.Text == "x")
     {
         //this.Dispose();
         this.Hide();
         StudentDetails nextForm = new StudentDetails();
         nextForm.ShowDialog();
         Close();
     }
     else
     {
     }
 }
 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;
 }
Пример #6
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();
            }
        }