Beispiel #1
0
        /*
         * private void delete_btn_Click(object sender, EventArgs e)
         * {
         *  DBConnection con = new DBConnection();
         *  string delQuery = $"DELETE FROM personal WHERE personal_id = '{id}'";
         *  try
         *  {
         *      DialogResult result = MessageBox.Show("Are you Sure LAN", "Important Question", MessageBoxButtons.YesNo);
         *      if (result == DialogResult.Yes)
         *      {
         *          con.Delete(delQuery);
         *          refresh();
         *          id = this.data_dgv.Rows[0].Cells[0].Value.ToString();
         *      }
         *  }
         *  catch (Exception ex)
         *  {
         *      MessageBox.Show("Error :" + ex);
         *  }
         *  finally
         *  {
         *      search_txtbx.Text = "";
         *      by_combx.SelectedIndex = -1;
         *  }
         * }
         */

        private void delete_btn_Click(object sender, EventArgs e)
        {
            DBConnection con      = new DBConnection();
            string       delQuery = "delete_student";

            try
            {
                DialogResult result = MessageBox.Show("Are you Sure?", "Important Question", MessageBoxButtons.YesNo);
                if (result == DialogResult.Yes)
                {
                    con.Delete(delQuery, id);
                    refresh();
                    try
                    {
                        id = this.data_dgv.Rows[0].Cells[0].Value.ToString();
                    }
                    catch (Exception ex)
                    {
Start:
                        DialogResult addNewStudent = MessageBox.Show("There is no Registered Students, Add a new student?", "Important Question", MessageBoxButtons.YesNo);
                        if (addNewStudent == DialogResult.Yes)
                        {
                            student_mod myform = new student_mod("-1");
                            myform.ShowDialog();
                            refresh();
                            try
                            {
                                id = this.data_dgv.Rows[0].Cells[0].Value.ToString();
                            }
                            catch (Exception ex2)
                            {
                                goto Start;
                            }
                        }
                        else
                        {
                            DialogResult Exit = MessageBox.Show("Close Application", "Important Question", MessageBoxButtons.YesNo);
                            if (Exit == DialogResult.Yes)
                            {
                                Application.Exit();
                            }
                            else
                            {
                                goto Start;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error :" + ex);
            }
            finally
            {
                search_txtbx.Text      = "";
                by_combx.SelectedIndex = -1;
            }
        }
Beispiel #2
0
        private void edit_btn_Click(object sender, EventArgs e)
        {
            student_mod myform = new student_mod(id);

            myform.ShowDialog();
            refresh();
            id = this.data_dgv.Rows[0].Cells[0].Value.ToString();
        }
Beispiel #3
0
        private void student_form_Load(object sender, EventArgs e)
        {
            refresh();
            current_page = 1;
            if (current_page == last_page)
            {
                prev_btn.Enabled = true;
                next_btn.Enabled = false;
            }
            if (current_page == 1)
            {
                prev_btn.Enabled = false;
            }
            try
            {
                id = this.data_dgv.Rows[0].Cells[0].Value.ToString();
            }
            catch (Exception ex)
            {
Start:
                DialogResult addNewStudent = MessageBox.Show("There is no Registered Students, Add a new student?", "Important Question", MessageBoxButtons.YesNo);
                if (addNewStudent == DialogResult.Yes)
                {
                    student_mod myform = new student_mod("-1");
                    myform.ShowDialog();
                    refresh();
                    try
                    {
                        id = this.data_dgv.Rows[0].Cells[0].Value.ToString();
                    }
                    catch (Exception ex2)
                    {
                        goto Start;
                    }
                }
                else
                {
                    DialogResult Exit = MessageBox.Show("Close Application", "Important Question", MessageBoxButtons.YesNo);
                    if (Exit == DialogResult.Yes)
                    {
                        Application.Exit();
                    }
                    else
                    {
                        goto Start;
                    }
                }
            }
        }