示例#1
0
        //DELETE SCHOOL YEAR
        private void DeleteFlatButton2_Click(object sender, EventArgs e)
        {
            opacityform = new OpacityForm();

            //DELETE SCHOOL YEAR EXCEPTION
            try
            {
                darkeropacityform  = new DarkerOpacityForm();
                notificationwindow = new NotificationWindow();

                string TempString = "SELECT COUNT(*) FROM [Tbl.SchoolYear] WHERE [ENTRY ID] = '" + SchoolYearIDDropdown.selectedValue.ToString()
                                    + "' AND [WAS SET] = '0'";
                sqldataadapter = new SqlDataAdapter(TempString, sqlconnection);
                DataTable datatable = new DataTable();
                sqldataadapter.Fill(datatable);

                if (datatable.Rows[0][0].ToString() == "1")
                {
                    string DeleteQuery = "DELETE FROM [Tbl.SchoolYear] WHERE [ENTRY ID] = '" + SchoolYearIDDropdown.selectedValue.ToString() + "'";
                    sqlcommand = new SqlCommand(DeleteQuery, sqlconnection);
                    sqlcommand.ExecuteNonQuery();

                    //REFRESH SCHOOL YEAR GRIDVIEW
                    Load_School_Year_Records();

                    //REMOVE DELETED VALUES
                    CurrentSchoolYearDropdown.Clear();
                    SectionIDDropdown.Clear();
                    SchoolYearDropdown.Clear();
                    SchoolYearIDDropdown.Clear();

                    //RETRIEVE NEW VALUES
                    Retrieve_School_Year_List_And_ID();
                    Retrieve_SectionID_List();
                }

                else if (datatable.Rows[0][0].ToString() == "0")
                {
                    notificationwindow.CaptionText    = "MESSAGE CONTENT";
                    notificationwindow.MsgImage.Image = Properties.Resources.error;
                    notificationwindow.MessageText    = "THIS SCHOOL YEAR CAN'T BE DELETED,\nSOME STUDENTS ARE ENROLLED HERE !";

                    darkeropacityform.Show();
                    notificationwindow.ShowDialog();
                    darkeropacityform.Hide();
                }
            }

            catch (Exception exception)
            {
                opacityform.Show();
                MessageBox.Show(exception.ToString(), "@Delete School Year Exception",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                opacityform.Hide();
            }
        }
示例#2
0
        //UPDATE SCHOOL YEAR ERRORS
        private void SaveButton3_Click(object sender, EventArgs e)
        {
            opacityform = new OpacityForm();

            //EXCEPTION 4
            try
            {
                darkeropacityform  = new DarkerOpacityForm();
                notificationwindow = new NotificationWindow();

                if (AlterSchoolYearValueTextbox.Text.Trim().Length < 1)
                {
                    notificationwindow.CaptionText    = "MESSAGE CONTENT";
                    notificationwindow.MsgImage.Image = Properties.Resources.warning;
                    notificationwindow.MessageText    = "PLEASE PROVIDE A SCHOOL YEAR !";

                    darkeropacityform.Show();
                    notificationwindow.ShowDialog();
                    darkeropacityform.Hide();
                }

                else if (!AlterSchoolYearValueTextbox.Text.Trim().ToUpper().Contains("S.Y."))
                {
                    notificationwindow.CaptionText    = "MESSAGE CONTENT";
                    notificationwindow.MsgImage.Image = Properties.Resources.warning;
                    notificationwindow.MessageText    = "PLEASE FOLLOW AND PROVIDE\nTHE SPECIFIED SCHOOL YEAR FORMAT !";

                    darkeropacityform.Show();
                    notificationwindow.ShowDialog();
                    darkeropacityform.Hide();
                }

                else
                {
                    string TempQuery = "SELECT COUNT(*) FROM [Tbl.CurrentSchoolYear] WHERE [SCHOOL YEAR ID] = '" +
                                       SchoolYearIDDropdown.selectedValue.ToString() + "'";
                    sqldataadapter = new SqlDataAdapter(TempQuery, sqlconnection);
                    DataTable datatable = new DataTable();
                    sqldataadapter.Fill(datatable);

                    if (datatable.Rows[0][0].ToString() == "1")
                    {
                        notificationwindow.CaptionText    = "MESSAGE CONTENT";
                        notificationwindow.MsgImage.Image = Properties.Resources.error;
                        notificationwindow.MessageText    = "YOU CAN'T ALTER THE CURRENT\nSCHOOL YEAR !";

                        darkeropacityform.Show();
                        notificationwindow.ShowDialog();
                        darkeropacityform.Hide();
                    }

                    else if (datatable.Rows[0][0].ToString() == "0")
                    {
                        string TempQuery1 = "SELECT COUNT(*) FROM [Tbl.SchoolYear] WHERE [ENTRY ID] = '" +
                                            SchoolYearIDDropdown.selectedValue.ToString() + "' AND [WAS SET] = '0'";

                        sqldataadapter = new SqlDataAdapter(TempQuery1, sqlconnection);
                        DataTable datatable1 = new DataTable();
                        sqldataadapter.Fill(datatable1);

                        if (datatable1.Rows[0][0].ToString() == "1")
                        {
                            string UpdateQuery2 = "UPDATE [Tbl.SchoolYear] SET [SCHOOL YEAR] = @schoolyear WHERE [ENTRY ID] = '" +
                                                  SchoolYearIDDropdown.selectedValue.ToString() + "'";

                            sqlcommand = new SqlCommand(UpdateQuery2, sqlconnection);
                            sqlcommand.Parameters.AddWithValue("@schoolyear", AlterSchoolYearValueTextbox.Text.Trim().ToUpper());
                            sqlcommand.ExecuteNonQuery();

                            //REFRESH SCHOOL YEAR GRIDVIEW
                            Load_School_Year_Records();

                            //RESET CONTROL STATE
                            SchoolYearIDDropdown.selectedIndex = 0;
                            AlterSchoolYearValueTextbox.ResetText();
                            bunifuCards1.Select();

                            //REMOVE OLD VALUES
                            SchoolYearDropdown.Clear();
                            SchoolYearIDDropdown.Clear();
                            CurrentSchoolYearDropdown.Clear();

                            //SYNC NEW VALUE TO SCHOOL YEAR DROPDOWNS
                            Retrieve_School_Year_List_And_ID();
                        }

                        else if (datatable1.Rows[0][0].ToString() == "0")
                        {
                            notificationwindow.CaptionText    = "MESSAGE CONTENT";
                            notificationwindow.MsgImage.Image = Properties.Resources.error;
                            notificationwindow.MessageText    = "THIS SCHOOL YEAR CAN'T BE ALTERED !";

                            darkeropacityform.Show();
                            notificationwindow.ShowDialog();
                            darkeropacityform.Hide();
                        }
                    }
                }
            }

            catch (Exception exception)
            {
                opacityform.Show();
                MessageBox.Show(exception.ToString(), "@Other Settings Form Exception 4",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                opacityform.Hide();
            }
        }