Пример #1
0
        private void SaveSettingsButton_Click(object sender, EventArgs e)
        {
            try
            {
                darkeropacityform  = new DarkerOpacityForm();
                notificationwindow = new NotificationWindow();

                if (AllowRadioButton.Checked == true)
                {
                    UpdateQuery = "UPDATE [Tbl.SystemSettings] SET [VALUE] = @value WHERE [SETTINGS ID] = 'SEG105'";
                    sqlcommand  = new SqlCommand(UpdateQuery, sqlconnection);
                    sqlcommand.Parameters.AddWithValue("@value", "1");
                    sqlcommand.ExecuteNonQuery();
                }

                else if (DisAllowRadioButton.Checked == true)
                {
                    UpdateQuery = "UPDATE [Tbl.SystemSettings] SET [VALUE] = @value WHERE [SETTINGS ID] = 'SEG105'";
                    sqlcommand  = new SqlCommand(UpdateQuery, sqlconnection);
                    sqlcommand.Parameters.AddWithValue("@value", "0");
                    sqlcommand.ExecuteNonQuery();
                }

                else if (NotSureRadioButton.Checked == true)
                {
                    UpdateQuery = "UPDATE [Tbl.SystemSettings] SET [VALUE] = @value WHERE [SETTINGS ID] = 'SEG105'";
                    sqlcommand  = new SqlCommand(UpdateQuery, sqlconnection);
                    sqlcommand.Parameters.AddWithValue("@value", "NS");
                    sqlcommand.ExecuteNonQuery();
                }

                notificationwindow.CaptionText    = "STUDENT REGISTRATION & INFORMATION SYSTEM";
                notificationwindow.MsgImage.Image = Properties.Resources.check;
                notificationwindow.MessageText    = "SUCCESSFULLY SAVED !";

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

                DialogResult = DialogResult.OK;
            }

            catch (Exception)
            {
                //DO NOTHING BITCH !
            }
        }
        private void ChangeButton_Click(object sender, EventArgs e)
        {
            //EXCEPTION 1
            try
            {
                opacityform        = new OpacityForm();
                darkeropacityform  = new DarkerOpacityForm();
                notificationwindow = new NotificationWindow();

                if (NewPasswordTextbox.Text.Trim().Length == 0 || ConfirmPasswordTextbox.Text.Trim().Length == 0)
                {
                    notificationwindow.CaptionText    = "MESSAGE CONTENT";
                    notificationwindow.MsgImage.Image = Properties.Resources.warning;
                    notificationwindow.MessageText    = "PLEASE PROVIDE THE REQUIRED\nINFORMATIONS BEING ASK !";

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

                else if (!NewPasswordTextbox.Text.Trim().Equals(ConfirmPasswordTextbox.Text.Trim()) ||
                         !ConfirmPasswordTextbox.Text.Trim().Equals(NewPasswordTextbox.Text.Trim()))
                {
                    notificationwindow.CaptionText    = "MESSAGE CONTENT";
                    notificationwindow.MsgImage.Image = Properties.Resources.warning;
                    notificationwindow.MessageText    = "PLEASE CONFIRM YOUR NEW PASSWORD !";

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

                else if (NewPasswordTextbox.Text.Trim().Length < 8 || ConfirmPasswordTextbox.Text.Trim().Length < 8)
                {
                    notificationwindow.CaptionText    = "MESSAGE CONTENT";
                    notificationwindow.MsgImage.Image = Properties.Resources.warning;
                    notificationwindow.MessageText    = "YOUR PASSWORD IS TOO SHORT, MAKE IT\n8-CHARACTERS OR ABOVE LONG !";

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

                else
                {
                    //INNER EXCEPTION 1
                    try
                    {
                        variables           = new Variables();
                        cryptography        = new Cryptography();
                        sqlconnectionconfig = new SQLConnectionConfig();

                        RegistryKey registrykey   = Registry.CurrentUser.OpenSubKey(@variables.pathname);
                        string      tempdata      = registrykey.GetValue("SQLServerConnectionString").ToString();
                        string      currentuserid = registrykey.GetValue("User ID").ToString();

                        //USER SQLSERVER CONNECTION SETTINGS
                        sqlconnectionconfig.SqlConnectionString = cryptography.Decrypt(tempdata);
                        sqlconnection = new SqlConnection(sqlconnectionconfig.SqlConnectionString);
                        sqlconnection.Open();

                        //CHECK IF THE NEW USERNAME IS ALREADY TAKEN BY ANOTHER USER
                        sqlquery1 = "SELECT COUNT(PASSWORD) FROM [Tbl.Users] WHERE [USER ID] = '" + currentuserid + "' AND PASSWORD = '******'";
                        DataTable datatable = new DataTable();
                        sqldataadapter = new SqlDataAdapter(sqlquery1, sqlconnection);
                        sqldataadapter.Fill(datatable);

                        //OPPS, PASSWORD IS THE SAME WITH THE OLD ONE !
                        if (datatable.Rows[0][0].ToString() == "1")
                        {
                            notificationwindow.CaptionText    = "MESSAGE CONTENT";
                            notificationwindow.MsgImage.Image = Properties.Resources.warning;
                            notificationwindow.MessageText    = "YOUR NEW PASSWORD AND OLD ARE\nJUST THE SAME !";

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

                        //F**K YAH,! IT'S NOT THE SAME !
                        else if (datatable.Rows[0][0].ToString() == "0")
                        {
                            //ERROR EXIST HERE.
                            sqlquery2 = "UPDATE [Tbl.Users] SET PASSWORD = @password, [IS PWD CHANGED] = @ispwdchanged WHERE [USER ID] = '" +
                                        currentuserid + "'";
                            sqlcommand = new SqlCommand(sqlquery2, sqlconnection);

                            sqlcommand.Parameters.AddWithValue("@password", cryptography.Encrypt(ConfirmPasswordTextbox.Text.Trim()));
                            sqlcommand.Parameters.AddWithValue("@ispwdchanged", "True");
                            sqlcommand.ExecuteNonQuery();

                            notificationwindow.CaptionText    = "SUCCESS !";
                            notificationwindow.MsgImage.Image = Properties.Resources.check;
                            notificationwindow.MessageText    = "SUCCESSFULLY UPDATED !";

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

                            sqlconnection.Close();
                            isClosed     = true;
                            DialogResult = DialogResult.OK;
                        }
                    }

                    catch (Exception exception)
                    {
                        opacityform.Show();
                        MessageBox.Show(exception.Message.ToString(), "@Change Password Required Form Inner Exception 1",
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);

                        opacityform.Hide();
                    }
                }
            }

            catch (Exception exception)
            {
                opacityform.Show();
                MessageBox.Show(exception.Message.ToString(), "@Change Password Required Form Exception 1",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);

                opacityform.Hide();
            }
        }
Пример #3
0
        private void UpdateButton_Click(object sender, EventArgs e)
        {
            try
            {
                cryptography       = new Cryptography();
                darkeropacityform  = new DarkerOpacityForm();
                notificationwindow = new NotificationWindow();

                if (NewSecurityCodeTextbox.Text.Trim().Length == 0)
                {
                    notificationwindow.CaptionText    = "MESSAGE CONTENT";
                    notificationwindow.MsgImage.Image = Properties.Resources.warning;
                    notificationwindow.MessageText    = "PLEASE PROVIDE NEW SECURITY CODE !";

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

                else if (ConfirmSecurityCodeTextbox.Text.Trim().Length == 0)
                {
                    notificationwindow.CaptionText    = "MESSAGE CONTENT";
                    notificationwindow.MsgImage.Image = Properties.Resources.warning;
                    notificationwindow.MessageText    = "PLEASE CONFIRM YOUR NEW\nSECURITY CODE !";

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

                else if (!ConfirmSecurityCodeTextbox.Text.Trim().Equals(NewSecurityCodeTextbox.Text.Trim()) ||
                         !NewSecurityCodeTextbox.Text.Trim().Equals(ConfirmSecurityCodeTextbox.Text.Trim()))
                {
                    notificationwindow.CaptionText    = "MESSAGE CONTENT";
                    notificationwindow.MsgImage.Image = Properties.Resources.warning;
                    notificationwindow.MessageText    = "SECURITY CODES DOES NOT MATCH !";

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

                else
                {
                    RegistryKey updateregistrykey = Registry.CurrentUser.CreateSubKey(@variables.pathname);
                    updateregistrykey.SetValue("Security Code", cryptography.Encrypt(ConfirmSecurityCodeTextbox.Text.Trim()));

                    notificationwindow.CaptionText    = "MESSAGE CONTENT";
                    notificationwindow.MsgImage.Image = Properties.Resources.check;
                    notificationwindow.MessageText    = "SUCCESSFULLY UPDATED !";

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

                    DialogResult = DialogResult.OK;
                }
            }

            catch (Exception)
            {
                //DO NOTHING BITCH !
            }
        }
        private void SendButton_Click(object sender, EventArgs e)
        {
            variables    = new Variables();
            opacityform  = new OpacityForm();
            cryptography = new Cryptography();

            darkeropacityform  = new DarkerOpacityForm();
            notificationwindow = new NotificationWindow();

            //EXCEPTION 1
            try
            {
                SmtpClient  smtpclient = new SmtpClient("smtp.gmail.com");
                MailMessage email      = new MailMessage();

                AFK = "*****@*****.**";
                JFK = cryptography.Decrypt(variables._64BaseStringHash);

                if (FeedbackTextbox.Text.Trim().Length < 1 || NameTextbox.Text.Trim().Length < 1 || EmailTextbox.Text.Trim().Length < 1)
                {
                    notificationwindow.CaptionText    = "MESSAGE CONTENT";
                    notificationwindow.MsgImage.Image = Properties.Resources.warning;
                    notificationwindow.MessageText    = "PLEASE PROVIDE THE REQUIRED\nINFORMATIONS BEING ASK !";

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

                else if (!EmailTextbox.Text.Trim().Contains("@") || !EmailTextbox.Text.Trim().Contains(".com"))
                {
                    notificationwindow.CaptionText    = "MESSAGE CONTENT";
                    notificationwindow.MsgImage.Image = Properties.Resources.warning;
                    notificationwindow.MessageText    = "PLEASE PROVIDE A VALID EMAIL ADDRESS !";

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

                else
                {
                    //INNER EXCEPTION 1
                    try
                    {
                        email.To.Add("*****@*****.**");
                        email.From    = new MailAddress(EmailTextbox.Text.Trim(), NameTextbox.Text.Trim());
                        email.Subject = NameTextbox.Text + " added a " + FeedbackType + "! From " +
                                        NameTextbox.Text + " - " + EmailTextbox.Text;

                        email.Body = "Hello, Good day ! I am " + NameTextbox.Text + " and I feel " +
                                     UserFeeling + " whenever I use your system. and I am suggesting for " + SuggestionTextbox.Text +
                                     "My Feedback is " + FeedbackTextbox.Text + ", Keep it up! and have a nice day.";

                        smtpclient.EnableSsl      = true;
                        smtpclient.Port           = 587;
                        smtpclient.DeliveryMethod = SmtpDeliveryMethod.Network;
                        smtpclient.Credentials    = new NetworkCredential(AFK, JFK);
                        smtpclient.Timeout        = 15;

                        try {
                            smtpclient.Send(email);
                            notificationwindow.CaptionText    = "MESSAGE SENT !";
                            notificationwindow.MsgImage.Image = Properties.Resources.check;
                            notificationwindow.MessageText    = "YOUR FEEDBACK HAS BEEN SENT !, KEEP\nSENDING YOUR FEEDBACKS TO IMPROVE\nOUR SYSTEM !";

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

                        catch (SmtpException) {
                            notificationwindow.CaptionText    = "MESSAGE CONTENT";
                            notificationwindow.MsgImage.Image = Properties.Resources.error;
                            notificationwindow.MessageText    = "FEEDBACK NOT SENT, PLEASE CHECK\nYOUR INTERNET CONNECTION !";

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

                    catch (Exception exception)
                    {
                        opacityform.Show();
                        MessageBox.Show(exception.Message.ToString(), "@Feedback Form Inner Exception 1",
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                        opacityform.Hide();
                    }
                }
            }

            catch (Exception exception)
            {
                opacityform.Show();
                MessageBox.Show(exception.Message.ToString(), "@Feedback Form Exception 1",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                opacityform.Hide();
            }
        }
        private void UpdateButton_Click(object sender, EventArgs e)
        {
            try
            {
                darkeropacityform  = new DarkerOpacityForm();
                notificationwindow = new NotificationWindow();

                string VerifyQuery = "SELECT [MAXIMUM STUDENTS], [ENROLLED] FROM [Tbl.Sections] WHERE [SECTION NAME] = '" +
                                     NewSectionDropdown.selectedValue.ToString() + "' AND [SCHOOL YEAR] = '" + CurrentSchoolYear + "'";
                sqlcommand = new SqlCommand(VerifyQuery, sqlconnection);
                SqlDataReader sqldatareader = sqlcommand.ExecuteReader();

                while (sqldatareader.Read())
                {
                    MaxStudents   = sqldatareader.GetString(0);
                    EnrolledCount = sqldatareader.GetString(1);
                }
                sqldatareader.Close();

                if (EnrolledCount.Equals(MaxStudents) || MaxStudents.Equals(EnrolledCount))
                {
                    notificationwindow.CaptionText    = "UPDATE FAILED !";
                    notificationwindow.MsgImage.Image = Properties.Resources.warning;
                    notificationwindow.MessageText    = NewSectionDropdown.selectedValue.ToString().ToUpper() + " IS ALREADY FULL !";

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

                else if (!EnrolledCount.Equals(MaxStudents) || !MaxStudents.Equals(EnrolledCount))
                {
                    string VerifyQuery2 = "SELECT COUNT(*) FROM [Tbl.FirstGradingStudentLoad] WHERE [STUDENT ID] = '" +
                                          StudentID + "' AND [SCHOOL YEAR] = '" + CurrentSchoolYear + "'";

                    SqlDataAdapter sqldataadapter = new SqlDataAdapter(VerifyQuery2, sqlconnection);
                    DataTable      datatable      = new DataTable();
                    sqldataadapter.Fill(datatable);

                    //INSERT
                    if (datatable.Rows[0][0].ToString() == "0")
                    {
                        Set_Refers();

                        //UPDATE [Tbl.Students]
                        string UpdateQuery1 = "UPDATE [Tbl.Students] SET [GRADE LEVEL] = @glevel, [SECTION] = @section" +
                                              " WHERE [STUDENT ID] = '" + StudentID + "'";

                        sqlcommand = new SqlCommand(UpdateQuery1, sqlconnection);
                        sqlcommand.Parameters.AddWithValue("@glevel", NewGradeLevelDropdown.selectedValue.ToString());
                        sqlcommand.Parameters.AddWithValue("@section", NewSectionDropdown.selectedValue.ToString());
                        sqlcommand.ExecuteNonQuery();

                        //UPDATE [Tbl.Sections] --> Iterate Enrolled Count
                        string UpdateQuery2 = "UPDATE [Tbl.Sections] SET [ENROLLED] = @enrolled" +
                                              " WHERE [SECTION NAME] = @sname AND [SCHOOL YEAR] = '" + CurrentSchoolYear + "'";

                        sqlcommand = new SqlCommand(UpdateQuery2, sqlconnection);
                        sqlcommand.Parameters.AddWithValue("@enrolled", (long.Parse(EnrolledCount) + 1).ToString());
                        sqlcommand.Parameters.AddWithValue("@sname", NewSectionDropdown.selectedValue.ToString());
                        sqlcommand.ExecuteNonQuery();

                        //INSERT INTO STUDENT LOAD TABLE --> 1st Grading
                        string query6 = "INSERT INTO [Tbl.FirstGradingStudentLoad]([STUDENT ID], [STUDENT NAME], GENDER, [GRADE LEVEL], SECTION," +
                                        "FILIPINO, ENGLISH, MATHEMATICS, SCIENCE, AP, TLE, MAPEH, ESP, [SCHOOL YEAR]) VALUES(@studentid1g, @studentname1g," +
                                        "@gender1g, @gradelevel1g, @section1g, @sb11g, @sb21g, @sb31g, @sb41g, @sb51g, @sb61g, @sb71g, @sb81g, @schoolyear1g)";
                        sqlcommand = new SqlCommand(query6, sqlconnection);

                        sqlcommand.Parameters.AddWithValue("@studentid1g", StudentID);
                        sqlcommand.Parameters.AddWithValue("@studentname1g", FullName);
                        sqlcommand.Parameters.AddWithValue("@gender1g", Gender);
                        sqlcommand.Parameters.AddWithValue("@gradelevel1g", NewGradeLevelDropdown.selectedValue.ToString());
                        sqlcommand.Parameters.AddWithValue("@section1g", NewSectionDropdown.selectedValue.ToString());

                        sqlcommand.Parameters.AddWithValue("@sb11g", "");
                        sqlcommand.Parameters.AddWithValue("@sb21g", "");
                        sqlcommand.Parameters.AddWithValue("@sb31g", "");
                        sqlcommand.Parameters.AddWithValue("@sb41g", "");
                        sqlcommand.Parameters.AddWithValue("@sb51g", "");
                        sqlcommand.Parameters.AddWithValue("@sb61g", "");
                        sqlcommand.Parameters.AddWithValue("@sb71g", "");
                        sqlcommand.Parameters.AddWithValue("@sb81g", "");
                        sqlcommand.Parameters.AddWithValue("@schoolyear1g", CurrentSchoolYear);
                        sqlcommand.ExecuteNonQuery();

                        //INSERT INTO STUDENT LOAD TABLE --> 2nd Grading
                        string query7 = "INSERT INTO [Tbl.SecondGradingStudentLoad]([STUDENT ID], [STUDENT NAME], GENDER, [GRADE LEVEL], SECTION," +
                                        "FILIPINO, ENGLISH, MATHEMATICS, SCIENCE, AP, TLE, MAPEH, ESP, [SCHOOL YEAR]) VALUES(@studentid2g, @studentname2g," +
                                        "@gender2g, @gradelevel2g, @section2g, @sb12g, @sb22g, @sb32g, @sb42g, @sb52g, @sb62g, @sb72g, @sb82g, @schoolyear2g)";
                        sqlcommand = new SqlCommand(query7, sqlconnection);

                        sqlcommand.Parameters.AddWithValue("@studentid2g", StudentID);
                        sqlcommand.Parameters.AddWithValue("@studentname2g", FullName);
                        sqlcommand.Parameters.AddWithValue("@gender2g", Gender);
                        sqlcommand.Parameters.AddWithValue("@gradelevel2g", NewGradeLevelDropdown.selectedValue.ToString());
                        sqlcommand.Parameters.AddWithValue("@section2g", NewSectionDropdown.selectedValue.ToString());

                        sqlcommand.Parameters.AddWithValue("@sb12g", "");
                        sqlcommand.Parameters.AddWithValue("@sb22g", "");
                        sqlcommand.Parameters.AddWithValue("@sb32g", "");
                        sqlcommand.Parameters.AddWithValue("@sb42g", "");
                        sqlcommand.Parameters.AddWithValue("@sb52g", "");
                        sqlcommand.Parameters.AddWithValue("@sb62g", "");
                        sqlcommand.Parameters.AddWithValue("@sb72g", "");
                        sqlcommand.Parameters.AddWithValue("@sb82g", "");
                        sqlcommand.Parameters.AddWithValue("@schoolyear2g", CurrentSchoolYear);
                        sqlcommand.ExecuteNonQuery();

                        //INSERT INTO STUDENT LOAD TABLE --> 3rd Grading
                        string query8 = "INSERT INTO [Tbl.ThirdGradingStudentLoad]([STUDENT ID], [STUDENT NAME], GENDER, [GRADE LEVEL], SECTION," +
                                        "FILIPINO, ENGLISH, MATHEMATICS, SCIENCE, AP, TLE, MAPEH, ESP, [SCHOOL YEAR]) VALUES(@studentid3g, @studentname3g," +
                                        "@gender3g, @gradelevel3g, @section3g, @sb13g, @sb23g, @sb33g, @sb43g, @sb53g, @sb63g, @sb73g, @sb83g, @schoolyear3g)";
                        sqlcommand = new SqlCommand(query8, sqlconnection);

                        sqlcommand.Parameters.AddWithValue("@studentid3g", StudentID);
                        sqlcommand.Parameters.AddWithValue("@studentname3g", FullName);
                        sqlcommand.Parameters.AddWithValue("@gender3g", Gender);
                        sqlcommand.Parameters.AddWithValue("@gradelevel3g", NewGradeLevelDropdown.selectedValue.ToString());
                        sqlcommand.Parameters.AddWithValue("@section3g", NewSectionDropdown.selectedValue.ToString());

                        sqlcommand.Parameters.AddWithValue("@sb13g", "");
                        sqlcommand.Parameters.AddWithValue("@sb23g", "");
                        sqlcommand.Parameters.AddWithValue("@sb33g", "");
                        sqlcommand.Parameters.AddWithValue("@sb43g", "");
                        sqlcommand.Parameters.AddWithValue("@sb53g", "");
                        sqlcommand.Parameters.AddWithValue("@sb63g", "");
                        sqlcommand.Parameters.AddWithValue("@sb73g", "");
                        sqlcommand.Parameters.AddWithValue("@sb83g", "");
                        sqlcommand.Parameters.AddWithValue("@schoolyear3g", CurrentSchoolYear);
                        sqlcommand.ExecuteNonQuery();

                        //INSERT INTO STUDENT LOAD TABLE --> 4rth Grading
                        string query9 = "INSERT INTO [Tbl.FourthGradingStudentLoad]([STUDENT ID], [STUDENT NAME], GENDER, [GRADE LEVEL], SECTION," +
                                        "FILIPINO, ENGLISH, MATHEMATICS, SCIENCE, AP, TLE, MAPEH, ESP, [SCHOOL YEAR]) VALUES(@studentid4g, @studentname4g," +
                                        "@gender4g, @gradelevel4g, @section4g, @sb14g, @sb24g, @sb34g, @sb44g, @sb54g, @sb64g, @sb74g, @sb84g, @schoolyear4g)";
                        sqlcommand = new SqlCommand(query9, sqlconnection);

                        sqlcommand.Parameters.AddWithValue("@studentid4g", StudentID);
                        sqlcommand.Parameters.AddWithValue("@studentname4g", FullName);
                        sqlcommand.Parameters.AddWithValue("@gender4g", Gender);
                        sqlcommand.Parameters.AddWithValue("@gradelevel4g", NewGradeLevelDropdown.selectedValue.ToString());
                        sqlcommand.Parameters.AddWithValue("@section4g", NewSectionDropdown.selectedValue.ToString());

                        sqlcommand.Parameters.AddWithValue("@sb14g", "");
                        sqlcommand.Parameters.AddWithValue("@sb24g", "");
                        sqlcommand.Parameters.AddWithValue("@sb34g", "");
                        sqlcommand.Parameters.AddWithValue("@sb44g", "");
                        sqlcommand.Parameters.AddWithValue("@sb54g", "");
                        sqlcommand.Parameters.AddWithValue("@sb64g", "");
                        sqlcommand.Parameters.AddWithValue("@sb74g", "");
                        sqlcommand.Parameters.AddWithValue("@sb84g", "");
                        sqlcommand.Parameters.AddWithValue("@schoolyear4g", CurrentSchoolYear);
                        sqlcommand.ExecuteNonQuery();

                        //INSERT INTO [Tbl.StudentAverages]
                        string query10 = "INSERT INTO [Tbl.StudentAverages]([STUDENT ID], [STUDENT NAME], LRN, [GRADE LEVEL], SECTION, " +
                                         "[FIRST GRADING], [SECOND GRADING], [THIRD GRADING], [FOURTH GRADING], GPA, [SCHOOL YEAR]) " +
                                         "VALUES(@sid, @studname, @lrn, @glevel, @section, @fga, @sga, @tga, @ffga, @gpa, @schoolyear)";
                        sqlcommand = new SqlCommand(query10, sqlconnection);

                        sqlcommand.Parameters.AddWithValue("@sid", StudentID);
                        sqlcommand.Parameters.AddWithValue("@studname", FullName);
                        sqlcommand.Parameters.AddWithValue("@lrn", Lrn);
                        sqlcommand.Parameters.AddWithValue("@glevel", NewGradeLevelDropdown.selectedValue.ToString());
                        sqlcommand.Parameters.AddWithValue("@section", NewSectionDropdown.selectedValue.ToString());

                        sqlcommand.Parameters.AddWithValue("@fga", "");
                        sqlcommand.Parameters.AddWithValue("@sga", "");
                        sqlcommand.Parameters.AddWithValue("@tga", "");
                        sqlcommand.Parameters.AddWithValue("@ffga", "");
                        sqlcommand.Parameters.AddWithValue("@gpa", "");
                        sqlcommand.Parameters.AddWithValue("@schoolyear", CurrentSchoolYear);
                        sqlcommand.ExecuteNonQuery();

                        notificationwindow.CaptionText    = "UPDATE SUCCESS !";
                        notificationwindow.MsgImage.Image = Properties.Resources.check;
                        notificationwindow.MessageText    = "YOUR NEW GRADE LEVEL AND SECTION:\n" +
                                                            NewGradeLevelDropdown.selectedValue.ToString().ToUpper() + " - " + NewSectionDropdown.selectedValue.ToString().ToUpper();

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

                        sqlconnection.Close();
                        DialogResult = DialogResult.OK;
                    }

                    //UPDATE
                    else if (datatable.Rows[0][0].ToString() == "1")
                    {
                        BullShit();

                        //UPDATE [Tbl.Students]
                        string AlterQuery1 = "UPDATE [Tbl.Students] SET [GRADE LEVEL] = @glevel, [SECTION] = @section" +
                                             " WHERE [STUDENT ID] = '" + StudentID + "'";

                        sqlcommand = new SqlCommand(AlterQuery1, sqlconnection);
                        sqlcommand.Parameters.AddWithValue("@glevel", NewGradeLevelDropdown.selectedValue.ToString());
                        sqlcommand.Parameters.AddWithValue("@section", NewSectionDropdown.selectedValue.ToString());
                        sqlcommand.ExecuteNonQuery();

                        //UPDATE [Tbl.Section] --> DECRIMENT OLD SECTION
                        string AlterQuery2 = "UPDATE [Tbl.Sections] SET [ENROLLED] = @enrolled WHERE [SECTION NAME] = '" +
                                             OldSectionDropdown.selectedValue.ToString() + "' AND [SCHOOL YEAR] = '" + CurrentSchoolYear + "'";

                        sqlcommand = new SqlCommand(AlterQuery2, sqlconnection);
                        sqlcommand.Parameters.AddWithValue("@enrolled", (long.Parse(OldEnrolledCount) - 1).ToString());
                        sqlcommand.ExecuteNonQuery();

                        //UPDATE [Tbl.Section] --> INCRIMENT NEW SECTION
                        string AlterQuery3 = "UPDATE [Tbl.Sections] SET [ENROLLED] = @enrolled WHERE [SECTION NAME] = '" +
                                             NewSectionDropdown.selectedValue.ToString() + "' AND [SCHOOL YEAR] = '" + CurrentSchoolYear + "'";

                        sqlcommand = new SqlCommand(AlterQuery3, sqlconnection);
                        sqlcommand.Parameters.AddWithValue("@enrolled", (long.Parse(EnrolledCount) + 1).ToString());
                        sqlcommand.ExecuteNonQuery();

                        //UPDATE [Tbl.FirstGradingStudentLoad]
                        string AlterQuery4 = "UPDATE [Tbl.FirstGradingStudentLoad] SET [GRADE LEVEL] = @glevel, [SECTION] = @section" +
                                             " WHERE [STUDENT ID] = '" + StudentID + "' AND [SCHOOL YEAR] = '" + CurrentSchoolYear + "'";

                        sqlcommand = new SqlCommand(AlterQuery4, sqlconnection);
                        sqlcommand.Parameters.AddWithValue("@glevel", NewGradeLevelDropdown.selectedValue.ToString());
                        sqlcommand.Parameters.AddWithValue("@section", NewSectionDropdown.selectedValue.ToString());
                        sqlcommand.ExecuteNonQuery();

                        //UPDATE [Tbl.SecondGradingStudentLoad]
                        string AlterQuery5 = "UPDATE [Tbl.SecondGradingStudentLoad] SET [GRADE LEVEL] = @glevel, [SECTION] = @section" +
                                             " WHERE [STUDENT ID] = '" + StudentID + "' AND [SCHOOL YEAR] = '" + CurrentSchoolYear + "'";

                        sqlcommand = new SqlCommand(AlterQuery5, sqlconnection);
                        sqlcommand.Parameters.AddWithValue("@glevel", NewGradeLevelDropdown.selectedValue.ToString());
                        sqlcommand.Parameters.AddWithValue("@section", NewSectionDropdown.selectedValue.ToString());
                        sqlcommand.ExecuteNonQuery();

                        //UPDATE [Tbl.ThirdGradingStudentLoad]
                        string AlterQuery6 = "UPDATE [Tbl.ThirdGradingStudentLoad] SET [GRADE LEVEL] = @glevel, [SECTION] = @section" +
                                             " WHERE [STUDENT ID] = '" + StudentID + "' AND [SCHOOL YEAR] = '" + CurrentSchoolYear + "'";

                        sqlcommand = new SqlCommand(AlterQuery6, sqlconnection);
                        sqlcommand.Parameters.AddWithValue("@glevel", NewGradeLevelDropdown.selectedValue.ToString());
                        sqlcommand.Parameters.AddWithValue("@section", NewSectionDropdown.selectedValue.ToString());
                        sqlcommand.ExecuteNonQuery();

                        //UPDATE [Tbl.FourthGradingStudentLoad]
                        string AlterQuery7 = "UPDATE [Tbl.FourthGradingStudentLoad] SET [GRADE LEVEL] = @glevel, [SECTION] = @section" +
                                             " WHERE [STUDENT ID] = '" + StudentID + "' AND [SCHOOL YEAR] = '" + CurrentSchoolYear + "'";

                        sqlcommand = new SqlCommand(AlterQuery7, sqlconnection);
                        sqlcommand.Parameters.AddWithValue("@glevel", NewGradeLevelDropdown.selectedValue.ToString());
                        sqlcommand.Parameters.AddWithValue("@section", NewSectionDropdown.selectedValue.ToString());
                        sqlcommand.ExecuteNonQuery();

                        //UPDATE [Tbl.StudentAverages]
                        string AlterQuery8 = "UPDATE [Tbl.StudentAverages] SET [GRADE LEVEL] = @glevel, [SECTION] = @section" +
                                             " WHERE [STUDENT ID] = '" + StudentID + "' AND [SCHOOL YEAR] = '" + CurrentSchoolYear + "'";

                        sqlcommand = new SqlCommand(AlterQuery8, sqlconnection);
                        sqlcommand.Parameters.AddWithValue("@glevel", NewGradeLevelDropdown.selectedValue.ToString());
                        sqlcommand.Parameters.AddWithValue("@section", NewSectionDropdown.selectedValue.ToString());
                        sqlcommand.ExecuteNonQuery();

                        notificationwindow.CaptionText    = "UPDATE SUCCESS !";
                        notificationwindow.MsgImage.Image = Properties.Resources.check;
                        notificationwindow.MessageText    = "YOUR NEW GRADE LEVEL AND SECTION:\n" +
                                                            NewGradeLevelDropdown.selectedValue.ToString().ToUpper() + " - " + NewSectionDropdown.selectedValue.ToString().ToUpper();

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

                        sqlconnection.Close();
                        DialogResult = DialogResult.OK;
                    }
                }
            }

            catch (Exception)
            {
                throw;
                //DON'T DO ANYTHING BITCH !
            }
        }
        //SAVE DATA
        private void bunifuFlatButton2_Click(object sender, EventArgs e)
        {
            try
            {
                //START WORKING STATE
                SaveButton.Cursor = Cursors.AppStarting;

                variables    = new Variables();
                cryptography = new Cryptography();

                darkeropacityform  = new DarkerOpacityForm();
                notificationwindow = new NotificationWindow();

                int _row = 0; Set_Refers();
                foreach (DataRow row in datatable.Rows)
                {
                    //VERIFY SECTION EXISTENSE
                    string VerifyQuery1 = "SELECT COUNT(*) FROM [Tbl.Sections] WHERE [SECTION NAME] = '" +
                                          GridView.Rows[_row].Cells[11].Value.ToString().Trim().ToUpper() + "'";

                    sqldataadapter = new SqlDataAdapter(VerifyQuery1, sqlconnection);
                    DataTable VirtualTable1 = new DataTable();
                    sqldataadapter.Fill(VirtualTable1);

                    //VERIFY STUDENT REGISTRATION
                    string VerifyQuery2 = "SELECT COUNT(*) FROM [Tbl.Students] WHERE [FIRST NAME] = '" +
                                          GridView.Rows[_row].Cells[3].Value.ToString().Trim() + "' AND [MIDDLE NAME] = '" + GridView.Rows[_row].Cells[4].Value.ToString().Trim() +
                                          "' AND [LAST NAME] = '" + GridView.Rows[_row].Cells[5].Value.ToString().Trim() + "'";

                    sqldataadapter = new SqlDataAdapter(VerifyQuery2, sqlconnection);
                    DataTable VirtualTable2 = new DataTable();
                    sqldataadapter.Fill(VirtualTable2);

                    if (GridView.Rows[_row].Cells[0].Value.ToString().Trim() == "" || GridView.Rows[_row].Cells[1].Value.ToString().Trim() == "" ||
                        GridView.Rows[_row].Cells[2].Value.ToString().Trim() == "" || GridView.Rows[_row].Cells[3].Value.ToString().Trim() == "" ||
                        GridView.Rows[_row].Cells[4].Value.ToString().Trim() == "" || GridView.Rows[_row].Cells[5].Value.ToString().Trim() == "" ||
                        GridView.Rows[_row].Cells[6].Value.ToString().Trim() == "" || GridView.Rows[_row].Cells[7].Value.ToString().Trim() == "" ||
                        GridView.Rows[_row].Cells[8].Value.ToString().Trim() == "" || GridView.Rows[_row].Cells[9].Value.ToString().Trim() == "" ||
                        GridView.Rows[_row].Cells[10].Value.ToString().Trim() == "" || GridView.Rows[_row].Cells[11].Value.ToString().Trim() == "" ||
                        GridView.Rows[_row].Cells[12].Value.ToString().Trim() == "" || GridView.Rows[_row].Cells[13].Value.ToString().Trim() == "" ||
                        GridView.Rows[_row].Cells[14].Value.ToString().Trim() == "")
                    {
                        notificationwindow.CaptionText    = "MESSAGE CONTENT";
                        notificationwindow.MsgImage.Image = Properties.Resources.warning;
                        notificationwindow.MessageText    = "SOME CELL CONTAINS A NULL CHARACTER !";

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

                        Import_Student_Data_Begin = false;
                        break;
                    }

                    else if (VirtualTable1.Rows[0][0].ToString() == "0")
                    {
                        notificationwindow.CaptionText    = "MESSAGE CONTENT";
                        notificationwindow.MsgImage.Image = Properties.Resources.warning;
                        notificationwindow.MessageText    = "THERE IS UNKNOWN SECTION NAME !";

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

                        Import_Student_Data_Begin = false;
                        break;
                    }

                    else if (int.Parse(VirtualTable2.Rows[0][0].ToString()) > 0)
                    {
                        notificationwindow.CaptionText    = "MESSAGE CONTENT";
                        notificationwindow.MsgImage.Image = Properties.Resources.warning;
                        notificationwindow.MessageText    = "THERE ARE STUDENT ENTRY THAT IS\nALREADY REGISTERED !";

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

                        Import_Student_Data_Begin = false;
                        break;
                    }

                    else if (!GridView.Rows[_row].Cells[6].Value.ToString().ToUpper().Trim().Equals("MALE") &&
                             !GridView.Rows[_row].Cells[6].Value.ToString().ToUpper().Trim().Equals("FEMALE"))
                    {
                        notificationwindow.CaptionText    = "MESSAGE CONTENT";
                        notificationwindow.MsgImage.Image = Properties.Resources.warning;
                        notificationwindow.MessageText    = "THERE IS UNKNOWN GENDER TYPE !";

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

                        Import_Student_Data_Begin = false;
                        break;
                    }

                    else if (GridView.Rows[_row].Cells[9].Value.ToString().Trim().Length < 11 ||
                             GridView.Rows[_row].Cells[9].Value.ToString().Trim().Length > 11)
                    {
                        notificationwindow.CaptionText    = "MESSAGE CONTENT";
                        notificationwindow.MsgImage.Image = Properties.Resources.warning;
                        notificationwindow.MessageText    = "THERE IS INVALID MOBILE NUMBER !";

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

                        Import_Student_Data_Begin = false;
                        break;
                    }

                    else if (isNumber(GridView.Rows[_row].Cells[9].Value.ToString().Trim()) == false)
                    {
                        notificationwindow.CaptionText    = "MESSAGE CONTENT";
                        notificationwindow.MsgImage.Image = Properties.Resources.warning;
                        notificationwindow.MessageText    = "THERE IS MOBILE NUMBER THAT\nCONTAINS AN INVALID CHARACTER !";

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

                        Import_Student_Data_Begin = false;
                        break;
                    }

                    else if (!GridView.Rows[_row].Cells[10].Value.ToString().Trim().Contains("@") ||
                             !GridView.Rows[_row].Cells[10].Value.ToString().Trim().Contains(".com"))
                    {
                        notificationwindow.CaptionText    = "MESSAGE CONTENT";
                        notificationwindow.MsgImage.Image = Properties.Resources.warning;
                        notificationwindow.MessageText    = "THERE IS INVALID EMAIL ADDRESS !";

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

                        Import_Student_Data_Begin = false;
                        break;
                    }

                    else if (!GridView.Rows[_row].Cells[11].Value.ToString().ToUpper().Trim().Equals(ReferSectionName))
                    {
                        notificationwindow.CaptionText    = "MESSAGE CONTENT";
                        notificationwindow.MsgImage.Image = Properties.Resources.error;
                        notificationwindow.MessageText    = "SYSTEM CANNOT IMPORT MULTIPLE\nDIFFERENT SECTIONS AT ONE TIME !";

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

                        Import_Student_Data_Begin = false;
                        break;
                    }

                    else if (!GridView.Rows[_row].Cells[12].Value.ToString().ToUpper().Trim().Equals(ReferGradeLevelName))
                    {
                        notificationwindow.CaptionText    = "MESSAGE CONTENT";
                        notificationwindow.MsgImage.Image = Properties.Resources.error;
                        notificationwindow.MessageText    = "SYSTEM CANNOT IMPORT MULTIPLE\nDIFFERENT GRADE LEVEL AT ONE TIME !";

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

                        Import_Student_Data_Begin = false;
                        break;
                    }

                    else if (!GridView.Rows[_row].Cells[12].Value.ToString().ToUpper().Trim().Equals("GRADE 7") && !GridView.Rows[_row].Cells[12].Value.ToString().ToUpper().Trim().Equals("GRADE 8") &&
                             !GridView.Rows[_row].Cells[12].Value.ToString().ToUpper().Trim().Equals("GRADE 9") && !GridView.Rows[_row].Cells[12].Value.ToString().ToUpper().Trim().Equals("GRADE 10"))
                    {
                        notificationwindow.CaptionText    = "MESSAGE CONTENT";
                        notificationwindow.MsgImage.Image = Properties.Resources.warning;
                        notificationwindow.MessageText    = "THERE IS UNKNOWN GRADE LEVEL !";

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

                        Import_Student_Data_Begin = false;
                        break;
                    }

                    else if (EntryCount > int.Parse(Maximum_Students))
                    {
                        notificationwindow.CaptionText    = "MESSAGE CONTENT";
                        notificationwindow.MsgImage.Image = Properties.Resources.error;
                        notificationwindow.MessageText    = "STUDENT DATA EXCEEDS THE\nSECTION'S REGISTRATION LIMIT !";

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

                        Import_Student_Data_Begin = false;
                        break;
                    }

                    else
                    {
                        Import_Student_Data_Begin = true;
                    }

                    _row++;
                }

                //SHOW MESSAGE AFTER SUCCESSFULL IMPORT
                if (Import_Student_Data_Begin == true)
                {
                    int row = 0; Set_Refers();
                    foreach (DataRow rows in datatable.Rows)
                    {
                        string query2, query3, query4, query5, query6, query7, query8, query9, query10;
                        string FullName = GridView.Rows[row].Cells[5].Value.ToString().Trim() + ", " + GridView.Rows[row].Cells[3].Value.ToString().Trim() + " "
                                          + GridView.Rows[row].Cells[4].Value.ToString().Trim().Remove(1, GridView.Rows[row].Cells[4].Value.ToString().Trim().Length - 1) + ".";

                        //INSERT INTO STUDENTS TABLE
                        query2 = "INSERT INTO [Tbl.Students]([STUDENT ID], [USER ID], LRN, [FIRST NAME], [MIDDLE NAME], [LAST NAME], [GRADE LEVEL]," +
                                 "SECTION, GENDER, [BIRTH DATE], [PRESENT ADDRESS], [PLACE OF BIRTH], [BLOOD TYPE], RELIGION, [INDIGINOUS GROUP]," +
                                 "[EMAIL ADDRESS], [MOBILE NUMBER]) VALUES(@studentid, @userid, @lrn, @firstname, @middlename, @lastname, @gradelevel," +
                                 "@section, @gender, @birthdate, @presentaddress, @placeofbirth, @bloodtype, @religion, @indiginousgroup, @emailaddress," +
                                 "@mobilenumber)";
                        sqlcommand = new SqlCommand(query2, sqlconnection);
                        sqlcommand.Parameters.AddWithValue("@studentid", GridView.Rows[row].Cells[0].Value.ToString().Trim());
                        sqlcommand.Parameters.AddWithValue("@userid", GridView.Rows[row].Cells[1].Value.ToString().Trim());
                        sqlcommand.Parameters.AddWithValue("@lrn", GridView.Rows[row].Cells[2].Value.ToString().Trim());

                        sqlcommand.Parameters.AddWithValue("@firstname", GridView.Rows[row].Cells[3].Value.ToString().Trim());
                        sqlcommand.Parameters.AddWithValue("@middlename", GridView.Rows[row].Cells[4].Value.ToString().Trim());
                        sqlcommand.Parameters.AddWithValue("@lastname", GridView.Rows[row].Cells[5].Value.ToString().Trim());

                        sqlcommand.Parameters.AddWithValue("@gradelevel", GridView.Rows[row].Cells[12].Value.ToString().Trim());
                        sqlcommand.Parameters.AddWithValue("@section", GridView.Rows[row].Cells[11].Value.ToString().Trim());
                        sqlcommand.Parameters.AddWithValue("@gender", GridView.Rows[row].Cells[6].Value.ToString().Trim());

                        sqlcommand.Parameters.AddWithValue("@birthdate", GridView.Rows[row].Cells[7].Value.ToString().Trim());
                        sqlcommand.Parameters.AddWithValue("@presentaddress", GridView.Rows[row].Cells[8].Value.ToString().Trim());
                        sqlcommand.Parameters.AddWithValue("@placeofbirth", "");

                        sqlcommand.Parameters.AddWithValue("@bloodtype", "");
                        sqlcommand.Parameters.AddWithValue("@religion", "");
                        sqlcommand.Parameters.AddWithValue("@indiginousgroup", "");

                        sqlcommand.Parameters.AddWithValue("@emailaddress", GridView.Rows[row].Cells[10].Value.ToString().Trim());
                        sqlcommand.Parameters.AddWithValue("@mobilenumber", GridView.Rows[row].Cells[9].Value.ToString().Trim());
                        sqlcommand.ExecuteNonQuery();

                        //INSERT INTO FAMILY BACKGROUND TABLE
                        query3 = "INSERT INTO [Tbl.FamilyBackgrounds]([STUDENT ID], [FATHERS NAME], [FATHERS OCCUPATION], [FATHERS CONTACT NUMBER]," +
                                 "[FATHERS ADDRESS], [MOTHERS NAME], [MOTHERS OCCUPATION], [MOTHERS CONTACT NUMBER], [MOTHERS ADDRESS]) VALUES(@studentid," +
                                 "@fathersname, @fatheroccupation, @fathersnumber, @fathersaddress, @mothername, @motheroccupation, @mothernumber, @motheraddress)";
                        sqlcommand = new SqlCommand(query3, sqlconnection);
                        sqlcommand.Parameters.AddWithValue("@studentid", GridView.Rows[row].Cells[0].Value.ToString().Trim());

                        sqlcommand.Parameters.AddWithValue("@fathersname", "");
                        sqlcommand.Parameters.AddWithValue("@fatheroccupation", "");
                        sqlcommand.Parameters.AddWithValue("@fathersnumber", "");
                        sqlcommand.Parameters.AddWithValue("@fathersaddress", "");

                        sqlcommand.Parameters.AddWithValue("@mothername", "");
                        sqlcommand.Parameters.AddWithValue("@motheroccupation", "");
                        sqlcommand.Parameters.AddWithValue("@mothernumber", "");
                        sqlcommand.Parameters.AddWithValue("@motheraddress", "");
                        sqlcommand.ExecuteNonQuery();

                        //INSERT INTO USERS TABLE
                        query4 = "INSERT INTO [Tbl.Users]([USER ID], USERNAME, PASSWORD, [ACCOUNT STATUS], [ACCOUNT TYPE], [LAST LOGIN]," +
                                 "[IS PWD CHANGED], [SITUATION STATUS]) VALUES(@userid, @username, @password, @accountstatus, @account_type, @last_login, @ispwdchanged, @stat)";
                        sqlcommand = new SqlCommand(query4, sqlconnection);
                        sqlcommand.Parameters.AddWithValue("@userid", GridView.Rows[row].Cells[1].Value.ToString().Trim());
                        sqlcommand.Parameters.AddWithValue("@username", cryptography.Encrypt(GridView.Rows[row].Cells[13].Value.ToString().Trim()));
                        sqlcommand.Parameters.AddWithValue("@password", cryptography.Encrypt(GridView.Rows[row].Cells[14].Value.ToString().Trim()));
                        sqlcommand.Parameters.AddWithValue("@accountstatus", "Active");

                        sqlcommand.Parameters.AddWithValue("@account_type", "Student");
                        sqlcommand.Parameters.AddWithValue("@last_login", "NO LOGIN HISTORY");
                        sqlcommand.Parameters.AddWithValue("@ispwdchanged", "False");
                        sqlcommand.Parameters.AddWithValue("@stat", "0");
                        sqlcommand.ExecuteNonQuery();

                        //UPDATE SECTIONS TABLE --> ENROLLED
                        query5 = "UPDATE [Tbl.Sections] SET ENROLLED = @enrolled WHERE [SECTION NAME] = @section_nane" +
                                 " AND [SCHOOL YEAR] = '" + CurrentSchoolYear + "'";

                        sqlcommand = new SqlCommand(query5, sqlconnection);
                        sqlcommand.Parameters.AddWithValue("@enrolled", (long.Parse(Enrolled_Students) + 1).ToString());
                        sqlcommand.Parameters.AddWithValue("@section_nane", GridView.Rows[row].Cells[11].Value.ToString().Trim());
                        sqlcommand.ExecuteNonQuery();

                        //INSERT INTO STUDENT LOAD TABLE --> 1st Grading
                        query6 = "INSERT INTO [Tbl.FirstGradingStudentLoad]([STUDENT ID], [STUDENT NAME], GENDER, [GRADE LEVEL], SECTION," +
                                 "FILIPINO, ENGLISH, MATHEMATICS, SCIENCE, AP, TLE, MAPEH, ESP, [SCHOOL YEAR]) VALUES(@studentid1g, @studentname1g," +
                                 "@gender1g, @gradelevel1g, @section1g, @sb11g, @sb21g, @sb31g, @sb41g, @sb51g, @sb61g, @sb71g, @sb81g, @schoolyear1g)";
                        sqlcommand = new SqlCommand(query6, sqlconnection);

                        sqlcommand.Parameters.AddWithValue("@studentid1g", GridView.Rows[row].Cells[0].Value.ToString().Trim());
                        sqlcommand.Parameters.AddWithValue("@studentname1g", FullName);
                        sqlcommand.Parameters.AddWithValue("@gender1g", GridView.Rows[row].Cells[6].Value.ToString().Trim());
                        sqlcommand.Parameters.AddWithValue("@gradelevel1g", GridView.Rows[row].Cells[12].Value.ToString().Trim());
                        sqlcommand.Parameters.AddWithValue("@section1g", GridView.Rows[row].Cells[11].Value.ToString().Trim());

                        sqlcommand.Parameters.AddWithValue("@sb11g", "");
                        sqlcommand.Parameters.AddWithValue("@sb21g", "");
                        sqlcommand.Parameters.AddWithValue("@sb31g", "");
                        sqlcommand.Parameters.AddWithValue("@sb41g", "");
                        sqlcommand.Parameters.AddWithValue("@sb51g", "");
                        sqlcommand.Parameters.AddWithValue("@sb61g", "");
                        sqlcommand.Parameters.AddWithValue("@sb71g", "");
                        sqlcommand.Parameters.AddWithValue("@sb81g", "");
                        sqlcommand.Parameters.AddWithValue("@schoolyear1g", CurrentSchoolYear);
                        sqlcommand.ExecuteNonQuery();

                        //INSERT INTO STUDENT LOAD TABLE --> 2nd Grading
                        query7 = "INSERT INTO [Tbl.SecondGradingStudentLoad]([STUDENT ID], [STUDENT NAME], GENDER, [GRADE LEVEL], SECTION," +
                                 "FILIPINO, ENGLISH, MATHEMATICS, SCIENCE, AP, TLE, MAPEH, ESP, [SCHOOL YEAR]) VALUES(@studentid2g, @studentname2g," +
                                 "@gender2g, @gradelevel2g, @section2g, @sb12g, @sb22g, @sb32g, @sb42g, @sb52g, @sb62g, @sb72g, @sb82g, @schoolyear2g)";
                        sqlcommand = new SqlCommand(query7, sqlconnection);

                        sqlcommand.Parameters.AddWithValue("@studentid2g", GridView.Rows[row].Cells[0].Value.ToString().Trim());
                        sqlcommand.Parameters.AddWithValue("@studentname2g", FullName);
                        sqlcommand.Parameters.AddWithValue("@gender2g", GridView.Rows[row].Cells[6].Value.ToString().Trim());
                        sqlcommand.Parameters.AddWithValue("@gradelevel2g", GridView.Rows[row].Cells[12].Value.ToString().Trim());
                        sqlcommand.Parameters.AddWithValue("@section2g", GridView.Rows[row].Cells[11].Value.ToString().Trim());

                        sqlcommand.Parameters.AddWithValue("@sb12g", "");
                        sqlcommand.Parameters.AddWithValue("@sb22g", "");
                        sqlcommand.Parameters.AddWithValue("@sb32g", "");
                        sqlcommand.Parameters.AddWithValue("@sb42g", "");
                        sqlcommand.Parameters.AddWithValue("@sb52g", "");
                        sqlcommand.Parameters.AddWithValue("@sb62g", "");
                        sqlcommand.Parameters.AddWithValue("@sb72g", "");
                        sqlcommand.Parameters.AddWithValue("@sb82g", "");
                        sqlcommand.Parameters.AddWithValue("@schoolyear2g", CurrentSchoolYear);
                        sqlcommand.ExecuteNonQuery();

                        //INSERT INTO STUDENT LOAD TABLE --> 3rd Grading
                        query8 = "INSERT INTO [Tbl.ThirdGradingStudentLoad]([STUDENT ID], [STUDENT NAME], GENDER, [GRADE LEVEL], SECTION," +
                                 "FILIPINO, ENGLISH, MATHEMATICS, SCIENCE, AP, TLE, MAPEH, ESP, [SCHOOL YEAR]) VALUES(@studentid3g, @studentname3g," +
                                 "@gender3g, @gradelevel3g, @section3g, @sb13g, @sb23g, @sb33g, @sb43g, @sb53g, @sb63g, @sb73g, @sb83g, @schoolyear3g)";
                        sqlcommand = new SqlCommand(query8, sqlconnection);

                        sqlcommand.Parameters.AddWithValue("@studentid3g", GridView.Rows[row].Cells[0].Value.ToString().Trim());
                        sqlcommand.Parameters.AddWithValue("@studentname3g", FullName);
                        sqlcommand.Parameters.AddWithValue("@gender3g", GridView.Rows[row].Cells[6].Value.ToString().Trim());
                        sqlcommand.Parameters.AddWithValue("@gradelevel3g", GridView.Rows[row].Cells[12].Value.ToString().Trim());
                        sqlcommand.Parameters.AddWithValue("@section3g", GridView.Rows[row].Cells[11].Value.ToString().Trim());

                        sqlcommand.Parameters.AddWithValue("@sb13g", "");
                        sqlcommand.Parameters.AddWithValue("@sb23g", "");
                        sqlcommand.Parameters.AddWithValue("@sb33g", "");
                        sqlcommand.Parameters.AddWithValue("@sb43g", "");
                        sqlcommand.Parameters.AddWithValue("@sb53g", "");
                        sqlcommand.Parameters.AddWithValue("@sb63g", "");
                        sqlcommand.Parameters.AddWithValue("@sb73g", "");
                        sqlcommand.Parameters.AddWithValue("@sb83g", "");
                        sqlcommand.Parameters.AddWithValue("@schoolyear3g", CurrentSchoolYear);
                        sqlcommand.ExecuteNonQuery();

                        //INSERT INTO STUDENT LOAD TABLE --> 4rth Grading
                        query9 = "INSERT INTO [Tbl.FourthGradingStudentLoad]([STUDENT ID], [STUDENT NAME], GENDER, [GRADE LEVEL], SECTION," +
                                 "FILIPINO, ENGLISH, MATHEMATICS, SCIENCE, AP, TLE, MAPEH, ESP, [SCHOOL YEAR]) VALUES(@studentid4g, @studentname4g," +
                                 "@gender4g, @gradelevel4g, @section4g, @sb14g, @sb24g, @sb34g, @sb44g, @sb54g, @sb64g, @sb74g, @sb84g, @schoolyear4g)";
                        sqlcommand = new SqlCommand(query9, sqlconnection);

                        sqlcommand.Parameters.AddWithValue("@studentid4g", GridView.Rows[row].Cells[0].Value.ToString().Trim());
                        sqlcommand.Parameters.AddWithValue("@studentname4g", FullName);
                        sqlcommand.Parameters.AddWithValue("@gender4g", GridView.Rows[row].Cells[6].Value.ToString().Trim());
                        sqlcommand.Parameters.AddWithValue("@gradelevel4g", GridView.Rows[row].Cells[12].Value.ToString().Trim());
                        sqlcommand.Parameters.AddWithValue("@section4g", GridView.Rows[row].Cells[11].Value.ToString().Trim());

                        sqlcommand.Parameters.AddWithValue("@sb14g", "");
                        sqlcommand.Parameters.AddWithValue("@sb24g", "");
                        sqlcommand.Parameters.AddWithValue("@sb34g", "");
                        sqlcommand.Parameters.AddWithValue("@sb44g", "");
                        sqlcommand.Parameters.AddWithValue("@sb54g", "");
                        sqlcommand.Parameters.AddWithValue("@sb64g", "");
                        sqlcommand.Parameters.AddWithValue("@sb74g", "");
                        sqlcommand.Parameters.AddWithValue("@sb84g", "");
                        sqlcommand.Parameters.AddWithValue("@schoolyear4g", CurrentSchoolYear);
                        sqlcommand.ExecuteNonQuery();

                        //INSERT INTO [Tbl.StudentAverages]
                        query10 = "INSERT INTO [Tbl.StudentAverages]([STUDENT ID], [STUDENT NAME], LRN, [GRADE LEVEL], SECTION, " +
                                  "[FIRST GRADING], [SECOND GRADING], [THIRD GRADING], [FOURTH GRADING], GPA, [SCHOOL YEAR]) " +
                                  "VALUES(@sid, @studname, @lrn, @glevel, @section, @fga, @sga, @tga, @ffga, @gpa, @schoolyear)";
                        sqlcommand = new SqlCommand(query10, sqlconnection);

                        sqlcommand.Parameters.AddWithValue("@sid", GridView.Rows[row].Cells[0].Value.ToString().Trim());
                        sqlcommand.Parameters.AddWithValue("@studname", FullName);
                        sqlcommand.Parameters.AddWithValue("@lrn", GridView.Rows[row].Cells[2].Value.ToString().Trim());
                        sqlcommand.Parameters.AddWithValue("@glevel", GridView.Rows[row].Cells[12].Value.ToString().Trim());
                        sqlcommand.Parameters.AddWithValue("@section", GridView.Rows[row].Cells[11].Value.ToString().Trim());

                        sqlcommand.Parameters.AddWithValue("@fga", "");
                        sqlcommand.Parameters.AddWithValue("@sga", "");
                        sqlcommand.Parameters.AddWithValue("@tga", "");
                        sqlcommand.Parameters.AddWithValue("@ffga", "");
                        sqlcommand.Parameters.AddWithValue("@gpa", "");
                        sqlcommand.Parameters.AddWithValue("@schoolyear", CurrentSchoolYear);
                        sqlcommand.ExecuteNonQuery();

                        isSuccessfull = true;
                        row++;
                    }
                }

                if (isSuccessfull == true)
                {
                    notificationwindow.CaptionText    = "REGISTRATION SUCCESS !";
                    notificationwindow.MsgImage.Image = Properties.Resources.check;
                    notificationwindow.MessageText    = "ALL DATA WAS SAVED SUCCESSFULLY !";

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

                    DialogResult = DialogResult.OK;
                }

                //STOP WORKING STATE
                SaveButton.Cursor = Cursors.Default;
            }

            catch (Exception)
            {
                //DON'T DO ANYTHING BITCH !
            }
        }
Пример #7
0
        private void UpdateFlatButton_Click(object sender, EventArgs e)
        {
            //EXCEPTION 2
            try
            {
                string j = @"""";
                opacityform  = new OpacityForm();
                cryptography = new Cryptography();

                darkeropacityform  = new DarkerOpacityForm();
                notificationwindow = new NotificationWindow();

                //INNER EXCEPTION 2
                try
                {
                    if (LRNTextbox.Text.Trim().Length < 1 || FirstNameTextbox.Text.Trim().Length < 1 || MiddleNameTextbox.Text.Trim().Length < 1 ||
                        LastNameTextbox.Text.Trim().Length < 1 || PresentAddressTextbox.Text.Trim().Length < 1 || PlaceOfBirthTextbox.Text.Trim().Length < 1 ||
                        BloodTypeTextbox.Text.Trim().Length < 1 || ReligionTextbox.Text.Trim().Length < 1 || EmailAddressTextbox.Text.Trim().Length < 1 ||
                        MobileNumberTextbox.Text.Trim().Length < 1 || FathersNameTextbox.Text.Trim().Length < 1 || FathersOccupationTextbox.Text.Trim().Length < 1 ||
                        FathersContactNumberTextbox.Text.Trim().Length < 1 || FathersAddressTextbox.Text.Trim().Length < 1 || MothersNameTextbox.Text.Trim().Length < 1 ||
                        MothersOccupationTextbox.Text.Trim().Length < 1 || MothersContactNumberTextbox.Text.Trim().Length < 1 ||
                        MothersAddressTextbox.Text.Trim().Length < 1 || PasswordTextbox.Text.Trim().Length < 1 || ConfirmPasswordTextbox.Text.Trim().Length < 1)
                    {
                        notificationwindow.CaptionText    = "MESSAGE CONTENT";
                        notificationwindow.MsgImage.Image = Properties.Resources.warning;
                        notificationwindow.MessageText    = "PLEASE PROVIDE THE REQUIRED\nINFORMATIONS BEING ASK !";

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

                    else if (!EmailAddressTextbox.Text.Trim().Contains("@") || !EmailAddressTextbox.Text.Trim().Contains(".com"))
                    {
                        notificationwindow.CaptionText    = "MESSAGE CONTENT";
                        notificationwindow.MsgImage.Image = Properties.Resources.warning;
                        notificationwindow.MessageText    = "PLEASE PROVIDE A VALID EMAIL ADDRESS !";

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

                    else if (MobileNumberTextbox.Text.Trim().Length < 11 || MobileNumberTextbox.Text.Trim().Length > 11)
                    {
                        notificationwindow.CaptionText    = "MESSAGE CONTENT";
                        notificationwindow.MsgImage.Image = Properties.Resources.warning;
                        notificationwindow.MessageText    = "PHONE NUMBER MUST BE 11-DIGITS LONG !";

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

                    else if (FathersContactNumberTextbox.Text.Trim().Length < 11 || FathersContactNumberTextbox.Text.Trim().Length > 11)
                    {
                        notificationwindow.CaptionText    = "MESSAGE CONTENT";
                        notificationwindow.MsgImage.Image = Properties.Resources.warning;
                        notificationwindow.MessageText    = "YOUR FATHERS PHONE NUMBER MUST BE\n11-DIGITS LONG !";

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

                    else if (MothersContactNumberTextbox.Text.Trim().Length < 11 || MothersContactNumberTextbox.Text.Trim().Length > 11)
                    {
                        notificationwindow.CaptionText    = "MESSAGE CONTENT";
                        notificationwindow.MsgImage.Image = Properties.Resources.warning;
                        notificationwindow.MessageText    = "YOUR MOTHERS PHONE NUMBER MUST BE\n11-DIGITS LONG !";

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

                    else if (MobileNumberTextbox.Text.Trim().ToUpper().Contains("A") || MobileNumberTextbox.Text.Trim().ToUpper().Contains("B") ||
                             MobileNumberTextbox.Text.Trim().ToUpper().Contains("C") || MobileNumberTextbox.Text.Trim().ToUpper().Contains("D") ||
                             MobileNumberTextbox.Text.Trim().ToUpper().Contains("E") || MobileNumberTextbox.Text.Trim().ToUpper().Contains("F") ||
                             MobileNumberTextbox.Text.Trim().ToUpper().Contains("G") || MobileNumberTextbox.Text.Trim().ToUpper().Contains("H") ||
                             MobileNumberTextbox.Text.Trim().ToUpper().Contains("I") || MobileNumberTextbox.Text.Trim().ToUpper().Contains("J") ||
                             MobileNumberTextbox.Text.Trim().ToUpper().Contains("K") || MobileNumberTextbox.Text.Trim().ToUpper().Contains("L") ||
                             MobileNumberTextbox.Text.Trim().ToUpper().Contains("M") || MobileNumberTextbox.Text.Trim().ToUpper().Contains("N") ||
                             MobileNumberTextbox.Text.Trim().ToUpper().Contains("O") || MobileNumberTextbox.Text.Trim().ToUpper().Contains("P") ||
                             MobileNumberTextbox.Text.Trim().ToUpper().Contains("Q") || MobileNumberTextbox.Text.Trim().ToUpper().Contains("R") ||
                             MobileNumberTextbox.Text.Trim().ToUpper().Contains("S") || MobileNumberTextbox.Text.Trim().ToUpper().Contains("T") ||
                             MobileNumberTextbox.Text.Trim().ToUpper().Contains("W") || MobileNumberTextbox.Text.Trim().ToUpper().Contains("X") ||
                             MobileNumberTextbox.Text.Trim().ToUpper().Contains("Y") || MobileNumberTextbox.Text.Trim().ToUpper().Contains("Z") ||
                             MobileNumberTextbox.Text.Trim().ToUpper().Contains("`") || MobileNumberTextbox.Text.Trim().ToUpper().Contains("~") ||
                             MobileNumberTextbox.Text.Trim().ToUpper().Contains("!") || MobileNumberTextbox.Text.Trim().ToUpper().Contains("@") ||
                             MobileNumberTextbox.Text.Trim().ToUpper().Contains("#") || MobileNumberTextbox.Text.Trim().ToUpper().Contains("$") ||
                             MobileNumberTextbox.Text.Trim().ToUpper().Contains("%") || MobileNumberTextbox.Text.Trim().ToUpper().Contains("^") ||
                             MobileNumberTextbox.Text.Trim().ToUpper().Contains("&") || MobileNumberTextbox.Text.Trim().ToUpper().Contains("*") ||
                             MobileNumberTextbox.Text.Trim().ToUpper().Contains("(") || MobileNumberTextbox.Text.Trim().ToUpper().Contains(")") ||
                             MobileNumberTextbox.Text.Trim().ToUpper().Contains("_") || MobileNumberTextbox.Text.Trim().ToUpper().Contains("-") ||
                             MobileNumberTextbox.Text.Trim().ToUpper().Contains("+") || MobileNumberTextbox.Text.Trim().ToUpper().Contains("=") ||
                             MobileNumberTextbox.Text.Trim().ToUpper().Contains("{") || MobileNumberTextbox.Text.Trim().ToUpper().Contains("[") ||
                             MobileNumberTextbox.Text.Trim().ToUpper().Contains("}") || MobileNumberTextbox.Text.Trim().ToUpper().Contains("]") ||
                             MobileNumberTextbox.Text.Trim().ToUpper().Contains(";") || MobileNumberTextbox.Text.Trim().ToUpper().Contains(":") ||
                             MobileNumberTextbox.Text.Trim().ToUpper().Contains("'") || MobileNumberTextbox.Text.Trim().ToUpper().Contains(j) ||
                             MobileNumberTextbox.Text.Trim().ToUpper().Contains("\\") || MobileNumberTextbox.Text.Trim().ToUpper().Contains("|") ||
                             MobileNumberTextbox.Text.Trim().ToUpper().Contains(",") || MobileNumberTextbox.Text.Trim().ToUpper().Contains("<") ||
                             MobileNumberTextbox.Text.Trim().ToUpper().Contains(".") || MobileNumberTextbox.Text.Trim().ToUpper().Contains(">") ||
                             MobileNumberTextbox.Text.Trim().ToUpper().Contains("/") || MobileNumberTextbox.Text.Trim().ToUpper().Contains("?"))
                    {
                        notificationwindow.CaptionText    = "MESSAGE CONTENT";
                        notificationwindow.MsgImage.Image = Properties.Resources.warning;
                        notificationwindow.MessageText    = "PHONE NUMBER CONTAINS AN INVALID\nCHARACTER !";

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

                    else if (FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("A") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("B") ||
                             FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("C") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("D") ||
                             FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("E") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("F") ||
                             FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("G") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("H") ||
                             FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("I") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("J") ||
                             FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("K") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("L") ||
                             FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("M") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("N") ||
                             FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("O") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("P") ||
                             FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("Q") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("R") ||
                             FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("S") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("T") ||
                             FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("W") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("X") ||
                             FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("Y") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("Z") ||
                             FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("`") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("~") ||
                             FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("!") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("@") ||
                             FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("#") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("$") ||
                             FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("%") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("^") ||
                             FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("&") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("*") ||
                             FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("(") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains(")") ||
                             FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("_") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("-") ||
                             FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("+") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("=") ||
                             FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("{") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("[") ||
                             FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("}") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("]") ||
                             FathersContactNumberTextbox.Text.Trim().ToUpper().Contains(";") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains(":") ||
                             FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("'") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains(j) ||
                             FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("\\") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("|") ||
                             FathersContactNumberTextbox.Text.Trim().ToUpper().Contains(",") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("<") ||
                             FathersContactNumberTextbox.Text.Trim().ToUpper().Contains(".") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains(">") ||
                             FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("/") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("?"))
                    {
                        notificationwindow.CaptionText    = "MESSAGE CONTENT";
                        notificationwindow.MsgImage.Image = Properties.Resources.warning;
                        notificationwindow.MessageText    = "YOUR FATHERS PHONE NUMBER CONTAINS\nAN INVALID CHARACTER !";

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

                    else if (MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("A") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("B") ||
                             MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("C") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("D") ||
                             MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("E") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("F") ||
                             MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("G") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("H") ||
                             MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("I") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("J") ||
                             MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("K") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("L") ||
                             MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("M") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("N") ||
                             MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("O") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("P") ||
                             MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("Q") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("R") ||
                             MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("S") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("T") ||
                             MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("W") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("X") ||
                             MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("Y") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("Z") ||
                             MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("`") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("~") ||
                             MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("!") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("@") ||
                             MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("#") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("$") ||
                             MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("%") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("^") ||
                             MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("&") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("*") ||
                             MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("(") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains(")") ||
                             MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("_") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("-") ||
                             MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("+") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("=") ||
                             MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("{") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("[") ||
                             MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("}") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("]") ||
                             MothersContactNumberTextbox.Text.Trim().ToUpper().Contains(";") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains(":") ||
                             MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("'") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains(j) ||
                             MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("\\") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("|") ||
                             MothersContactNumberTextbox.Text.Trim().ToUpper().Contains(",") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("<") ||
                             MothersContactNumberTextbox.Text.Trim().ToUpper().Contains(".") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains(">") ||
                             MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("/") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("?"))
                    {
                        notificationwindow.CaptionText    = "MESSAGE CONTENT";
                        notificationwindow.MsgImage.Image = Properties.Resources.warning;
                        notificationwindow.MessageText    = "YOUR MOTHERS PHONE NUMBER CONTAINS\nAN INVALID CHARACTER !";

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

                    else if (!PasswordTextbox.Text.Trim().Equals(ConfirmPasswordTextbox.Text.Trim()) ||
                             !ConfirmPasswordTextbox.Text.Trim().Equals(PasswordTextbox.Text.Trim()))
                    {
                        notificationwindow.CaptionText    = "MESSAGE CONTENT";
                        notificationwindow.MsgImage.Image = Properties.Resources.warning;
                        notificationwindow.MessageText    = "PLEASE CONFIRM YOUR PASSWORD !";

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

                    else if (PasswordTextbox.Text.Trim().Length < 8 || ConfirmPasswordTextbox.Text.Trim().Length < 8)
                    {
                        notificationwindow.CaptionText    = "MESSAGE CONTENT";
                        notificationwindow.MsgImage.Image = Properties.Resources.warning;
                        notificationwindow.MessageText    = "YOUR PASSWORD IS TOO SHORT, MAKE IT\n8-CHARACTERS OR ABOVE LONG !";

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

                    else
                    {
                        if (ImageFilename != null)
                        {
                            //UPDATE [Tbl.Photos] IF IMAGE CHANGED
                            FileStream filestream = new FileStream(ImageFilename, FileMode.Open, FileAccess.Read);
                            byte[]     imgByteArr = new byte[filestream.Length];
                            filestream.Read(imgByteArr, 0, Convert.ToInt32(filestream.Length));
                            filestream.Close();

                            string UpdateQuery0 = "UPDATE [Tbl.Photos] SET [FILE NAME] = @filename, PICTURE = @picture WHERE [USER ID] = '" + UserID + "'";
                            sqlcommand = new SqlCommand(UpdateQuery0, sqlconnection);
                            sqlcommand.Parameters.AddWithValue("@filename", ImageFilename.ToString());
                            sqlcommand.Parameters.AddWithValue("@picture", imgByteArr);
                            sqlcommand.ExecuteNonQuery();
                        }

                        //UPDATE [Tbl.Students]
                        string UpdateQuery1 = "UPDATE [Tbl.Students] SET [FIRST NAME] = @1, [MIDDLE NAME] = @2, [LAST NAME] = @3, [GENDER] = @4, [BIRTH DATE] = @5, " +
                                              "[PRESENT ADDRESS] = @6, [PLACE OF BIRTH] = @7, [BLOOD TYPE] = @8, [RELIGION] = @9, [INDIGINOUS GROUP] = @10, [EMAIL ADDRESS] = @11, " +
                                              "[MOBILE NUMBER] = @12 WHERE [STUDENT ID] = '" + StudentID + "'";
                        sqlcommand = new SqlCommand(UpdateQuery1, sqlconnection);
                        sqlcommand.Parameters.AddWithValue("@1", FirstNameTextbox.Text.Trim());
                        sqlcommand.Parameters.AddWithValue("@2", MiddleNameTextbox.Text.Trim());
                        sqlcommand.Parameters.AddWithValue("@3", LastNameTextbox.Text.Trim());
                        sqlcommand.Parameters.AddWithValue("@4", GenderDropdown.selectedValue.ToString());

                        sqlcommand.Parameters.AddWithValue("@5", BirthDatepicker.Value.ToLongDateString().ToString());
                        sqlcommand.Parameters.AddWithValue("@6", PresentAddressTextbox.Text.Trim());
                        sqlcommand.Parameters.AddWithValue("@7", PlaceOfBirthTextbox.Text.Trim());
                        sqlcommand.Parameters.AddWithValue("@8", BloodTypeTextbox.Text.Trim());

                        sqlcommand.Parameters.AddWithValue("@9", ReligionTextbox.Text.Trim());
                        sqlcommand.Parameters.AddWithValue("@10", IndiginousGroupTextbox.Text.Trim());
                        sqlcommand.Parameters.AddWithValue("@11", EmailAddressTextbox.Text.Trim());
                        sqlcommand.Parameters.AddWithValue("@12", MobileNumberTextbox.Text.Trim());
                        sqlcommand.ExecuteNonQuery();

                        //UPDATE [Tbl.FamilyBackgrounds]
                        string UpdateQuery2 = "UPDATE [Tbl.FamilyBackgrounds] SET [FATHERS NAME] = @1, [FATHERS OCCUPATION] = @2, [FATHERS CONTACT NUMBER] = @3, [FATHERS ADDRESS] = @4, " +
                                              "[MOTHERS NAME] = @5, [MOTHERS OCCUPATION] = @6, [MOTHERS CONTACT NUMBER] = @7, [MOTHERS ADDRESS] = @8 WHERE [STUDENT ID] = '" + StudentID + "'";
                        sqlcommand = new SqlCommand(UpdateQuery2, sqlconnection);
                        sqlcommand.Parameters.AddWithValue("@1", FathersNameTextbox.Text.Trim());
                        sqlcommand.Parameters.AddWithValue("@2", FathersOccupationTextbox.Text.Trim());
                        sqlcommand.Parameters.AddWithValue("@3", FathersContactNumberTextbox.Text.Trim());
                        sqlcommand.Parameters.AddWithValue("@4", FathersAddressTextbox.Text.Trim());

                        sqlcommand.Parameters.AddWithValue("@5", MothersNameTextbox.Text.Trim());
                        sqlcommand.Parameters.AddWithValue("@6", MothersOccupationTextbox.Text.Trim());
                        sqlcommand.Parameters.AddWithValue("@7", MothersContactNumberTextbox.Text.Trim());
                        sqlcommand.Parameters.AddWithValue("@8", MothersAddressTextbox.Text.Trim());
                        sqlcommand.ExecuteNonQuery();

                        //UPDATE [Tbl.Users]
                        string UpdateQuery3 = "UPDATE [Tbl.Users] SET [USERNAME] = @1, [PASSWORD] = @2 WHERE [USER ID] = '" + UserID + "'";
                        sqlcommand = new SqlCommand(UpdateQuery3, sqlconnection);
                        sqlcommand.Parameters.AddWithValue("@1", cryptography.Encrypt(UsernameTextbox.Text));
                        sqlcommand.Parameters.AddWithValue("@2", cryptography.Encrypt(PasswordTextbox.Text));
                        sqlcommand.ExecuteNonQuery();

                        notificationwindow.CaptionText    = "MESSAGE CONTENT";
                        notificationwindow.MsgImage.Image = Properties.Resources.check;
                        notificationwindow.MessageText    = "SUCCESSFULY UPDATED !";

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

                        //CLOSE THE CURRENT FORM
                        sqlconnection.Close();
                        DialogResult = DialogResult.OK;
                    }
                }

                catch (Exception exception)
                {
                    opacityform.Show();
                    MessageBox.Show(exception.Message.ToString(), "@Student Edit Form Inner Exception 2",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);

                    opacityform.Hide();
                }
            }

            catch (Exception exception)
            {
                opacityform.Show();
                MessageBox.Show(exception.Message.ToString(), "@Student Edit Form Exception 2",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);

                opacityform.Hide();
            }
        }
        private void OKButton_Click(object sender, EventArgs e)
        {
            opacityform        = new OpacityForm();
            darkeropacityform  = new DarkerOpacityForm();
            notificationwindow = new NotificationWindow();

            //EXCEPTION 2
            try
            {
                //SHOW VISUAL REPRESENTATION FOR EMPTY TEXTBOXES
                Show_Hide_Visual_Representation_Labels();

                if (ServerNameTextbox.Text.Length == 0 || DatabaseNameTextbox.Text.Length == 0 ||
                    SqlServerUsernameTextbox.Text.Length == 0 || SqlServerPasswordTextbox.Text.Length == 0)
                {
                    notificationwindow.CaptionText    = "CONNECTION REFUSED";
                    notificationwindow.MsgImage.Image = Properties.Resources.warning;
                    notificationwindow.MessageText    = "PLEASE PROVIDE THE REQUIRED\nINFORMATIONS BEING ASK !";

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

                else if (ServerNameTextbox.Text.EndsWith(" ") || DatabaseNameTextbox.Text.EndsWith(" ") ||
                         SqlServerUsernameTextbox.Text.EndsWith(" ") || SqlServerPasswordTextbox.Text.EndsWith(" "))
                {
                    notificationwindow.CaptionText    = "CONNECTION REFUSED";
                    notificationwindow.MsgImage.Image = Properties.Resources.error;
                    notificationwindow.MessageText    = "LOGIN FAILED !\nPLEASE REVIEW YOUR INFORMATION.";

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

                else if (ServerNameTextbox.Text.Length != 0 && DatabaseNameTextbox.Text.Length != 0 &&
                         SqlServerUsernameTextbox.Text.Length != 0 && SqlServerPasswordTextbox.Text.Length != 0)
                {
                    //INNER EXCEPTION 2
                    try
                    {
                        variables    = new Variables();
                        cryptography = new Cryptography();
                        sqlconfig    = new SQLConnectionConfig();

                        tempconnectionstring = "Data Source=" + ServerNameTextbox.Text + ";" + "Initial Catalog=" + DatabaseNameTextbox.Text + ";"
                                               + "Persist Security Info=True;" + "User ID=" + SqlServerUsernameTextbox.Text + ";" + "Password="******"";

                        sqlconfig.SqlConnectionString = tempconnectionstring;
                        sqlconnection = new SqlConnection(sqlconfig.SqlConnectionString);

                        do
                        {
                            Cursor = Cursors.AppStarting;
                            sqlconnection.Open();

                            if (sqlconnection.State == ConnectionState.Open)
                            {
                                //PLEASE CHANGE THIS CODE !
                                if (DatabaseNameTextbox.Text.Trim().Equals("BUKSU.SLS_DB"))
                                {
                                    notificationwindow.CaptionText    = "CONNECTION RESULTS";
                                    notificationwindow.MsgImage.Image = Properties.Resources.check;
                                    notificationwindow.MessageText    = "YOU'RE ALL SET ! CONNECTION\nWAS SUCCESSFULY ESTABLISHED.";

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

                                    variables.UserSqlConnectionString = tempconnectionstring;

                                    //INNER EXCEPTION 3
                                    try
                                    {
                                        RegistryKey registrykey = Registry.CurrentUser.CreateSubKey(@variables.pathname);
                                        registrykey.SetValue("SQLServerConnectionString", cryptography.Encrypt(tempconnectionstring));
                                    }

                                    catch (Exception exception)
                                    {
                                        opacityform.Show();
                                        MessageBox.Show(exception.Message.ToString(), "@Server Connection Inner Exception 3",
                                                        MessageBoxButtons.OK, MessageBoxIcon.Error);

                                        opacityform.Hide();
                                    }

                                    Cursor       = Cursors.Default;
                                    DialogResult = DialogResult.OK;
                                    break;
                                }

                                else
                                {
                                    notificationwindow.CaptionText    = "CONNECTION RESULTS";
                                    notificationwindow.MsgImage.Image = Properties.Resources.error;
                                    notificationwindow.MessageText    = "INVALID DATABASE - " + DatabaseNameTextbox.Text.Trim() +
                                                                        "\nDATABASE DOES NOT CONTAIN ALL\nTHE TABLES NEEDED TO RUN THE SYSTEM !";

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

                                    Cursor = Cursors.Default;
                                    break;
                                }
                            }
                        }while (sqlconnection.State == ConnectionState.Closed);
                        sqlconnection.Close();
                    }

                    catch (Exception exception)
                    {
                        Cursor = Cursors.Default;
                        opacityform.Show();

                        MessageBox.Show(exception.Message.ToString(), "@Server Connection Inner Exception 2",
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);

                        opacityform.Hide();
                    }
                }
            }

            catch (Exception exception)
            {
                opacityform.Show();
                MessageBox.Show(exception.Message.ToString(), "@Server Connection Exception 2",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);

                opacityform.Hide();
            }
        }
Пример #9
0
        private void SubmitButton_Click(object sender, EventArgs e)
        {
            //EXCEPTION 2
            try
            {
                opacityform        = new OpacityForm();
                darkeropacityform  = new DarkerOpacityForm();
                notificationwindow = new NotificationWindow();

                if (NewUsernameTextbox.Text.Trim().Length == 0 || ConfirmUsernameTextbox.Text.Trim().Length == 0)
                {
                    notificationwindow.CaptionText    = "MESSAGE CONTENT";
                    notificationwindow.MsgImage.Image = Properties.Resources.warning;
                    notificationwindow.MessageText    = "PLEASE PROVIDE THE REQUIRED\nINFORMATIONS BEING ASK !";

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

                else if (NewUsernameTextbox.Text.Trim().Equals(OldUsernameTextbox.Text.Trim()) ||
                         OldUsernameTextbox.Text.Trim().Equals(NewUsernameTextbox.Text.Trim()))
                {
                    notificationwindow.CaptionText    = "MESSAGE CONTENT";
                    notificationwindow.MsgImage.Image = Properties.Resources.warning;
                    notificationwindow.MessageText    = "YOUR NEW USERNAME AND OLD ARE\nJUST THE SAME !";

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

                else if (!NewUsernameTextbox.Text.Trim().Equals(ConfirmUsernameTextbox.Text.Trim()) ||
                         !ConfirmUsernameTextbox.Text.Trim().Equals(NewUsernameTextbox.Text.Trim()))
                {
                    notificationwindow.CaptionText    = "MESSAGE CONTENT";
                    notificationwindow.MsgImage.Image = Properties.Resources.warning;
                    notificationwindow.MessageText    = "PLEASE CONFIRM YOUR NEW USERNAME !";

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

                else if (NewUsernameTextbox.Text.Trim().Length != 0 && ConfirmUsernameTextbox.Text.Trim().Length != 0)
                {
                    //INNER EXCEPTION 2
                    try
                    {
                        //CHECK IF THE NEW USERNAME IS ALREADY TAKEN BY ANOTHER USER
                        sqlquery2      = "SELECT COUNT(*) FROM [Tbl.Users] WHERE USERNAME = '******'";
                        sqldataadapter = new SqlDataAdapter(sqlquery2, sqlconnection);
                        DataTable datatable = new DataTable();
                        sqldataadapter.Fill(datatable);

                        //OPPS, USERNAME IS ALREADY TAKEN
                        if (datatable.Rows[0][0].ToString() == "1")
                        {
                            notificationwindow.CaptionText    = "UPDATE WAS ABORTED !";
                            notificationwindow.MsgImage.Image = Properties.Resources.error;
                            notificationwindow.MessageText    = "OPPS, USERNAME IS ALREADY TAKEN,\nTRY A DIFFERENT ONE !";

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

                        //F**K YEAH, USERNAME IS NOT YET TAKEN !!
                        else if (datatable.Rows[0][0].ToString() == "0")
                        {
                            //ERROR EXIST HERE.
                            sqlquery3  = "UPDATE [Tbl.Users] SET USERNAME = @username WHERE [USER ID] = '" + currentuserid + "'";
                            sqlcommand = new SqlCommand(sqlquery3, sqlconnection);

                            sqlcommand.Parameters.AddWithValue("@username", cryptography.Encrypt(ConfirmUsernameTextbox.Text.Trim()));
                            sqlcommand.ExecuteNonQuery();

                            notificationwindow.CaptionText    = "SUCCESS !";
                            notificationwindow.MsgImage.Image = Properties.Resources.check;
                            notificationwindow.MessageText    = "SUCCESSFULLY UPDATED !";

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

                            sqlconnection.Close();
                            DialogResult = DialogResult.OK;
                        }
                    }

                    catch (Exception exception)
                    {
                        opacityform.Show();
                        MessageBox.Show(exception.Message.ToString(), "@Change Username Form Inner Exception 2",
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);

                        opacityform.Hide();
                    }
                }
            }

            catch (Exception exception)
            {
                opacityform.Show();
                MessageBox.Show(exception.Message.ToString(), "@Change Username Form Exception 2",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);

                opacityform.Hide();
            }
        }
Пример #10
0
        private void SubmitButton_Click(object sender, EventArgs e)
        {
            //EXCEPTION 2
            try
            {
                opacityform        = new OpacityForm();
                darkeropacityform  = new DarkerOpacityForm();
                notificationwindow = new NotificationWindow();

                if (NewPasswordTextbox.Text.Trim().Length == 0 || ConfirmPasswordTextbox.Text.Trim().Length == 0)
                {
                    notificationwindow.CaptionText    = "MESSAGE CONTENT";
                    notificationwindow.MsgImage.Image = Properties.Resources.warning;
                    notificationwindow.MessageText    = "PLEASE PROVIDE THE REQUIRED\nINFORMATIONS BEING ASK !";

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

                else if (OldPasswordTextbox.Text.Trim().Equals(NewPasswordTextbox.Text.Trim()) ||
                         NewPasswordTextbox.Text.Trim().Equals(OldPasswordTextbox.Text.Trim()))
                {
                    notificationwindow.CaptionText    = "MESSAGE CONTENT";
                    notificationwindow.MsgImage.Image = Properties.Resources.warning;
                    notificationwindow.MessageText    = "YOUR NEW PASSWORD AND OLD ARE\nJUST THE SAME !";

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

                else if (!NewPasswordTextbox.Text.Trim().Equals(ConfirmPasswordTextbox.Text.Trim()) ||
                         !ConfirmPasswordTextbox.Text.Trim().Equals(NewPasswordTextbox.Text.Trim()))
                {
                    notificationwindow.CaptionText    = "MESSAGE CONTENT";
                    notificationwindow.MsgImage.Image = Properties.Resources.warning;
                    notificationwindow.MessageText    = "PLEASE CONFIRM YOUR NEW PASSWORD !";

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

                else if (NewPasswordTextbox.Text.Trim().Length < 8 || ConfirmPasswordTextbox.Text.Trim().Length < 8)
                {
                    notificationwindow.CaptionText    = "MESSAGE CONTENT";
                    notificationwindow.MsgImage.Image = Properties.Resources.warning;
                    notificationwindow.MessageText    = "YOUR PASSWORD IS TOO SHORT, MAKE IT\n8-CHARACTERS OR ABOVE LONG !";

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

                else
                {
                    //INNER EXCEPTION 2
                    try
                    {
                        //ERROR EXIST HERE.
                        sqlquery2  = "UPDATE [Tbl.Users] SET PASSWORD = @password WHERE [USER ID] = '" + currentuserid + "'";
                        sqlcommand = new SqlCommand(sqlquery2, sqlconnection);

                        sqlcommand.Parameters.AddWithValue("@password", cryptography.Encrypt(ConfirmPasswordTextbox.Text.Trim()));
                        sqlcommand.ExecuteNonQuery();

                        notificationwindow.CaptionText    = "SUCCESS !";
                        notificationwindow.MsgImage.Image = Properties.Resources.check;
                        notificationwindow.MessageText    = "SUCCESSFULLY UPDATED !";

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

                        sqlconnection.Close();
                        DialogResult = DialogResult.OK;
                    }

                    catch (Exception exception)
                    {
                        opacityform.Show();
                        MessageBox.Show(exception.Message.ToString(), "@Change Password Form Exception 2",
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);

                        opacityform.Hide();
                    }
                }
            }

            catch (Exception exception)
            {
                opacityform.Show();
                MessageBox.Show(exception.Message.ToString(), "@Change Password Form Exception 2",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);

                opacityform.Hide();
            }
        }
Пример #11
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();
            }
        }
Пример #12
0
        //UPDATE SECTION ERRORS
        private void SaveButton2_Click(object sender, EventArgs e)
        {
            opacityform          = new OpacityForm();
            getcurrentschoolyear = new GetCurrentSchoolYear();
            currentschoolyear    = getcurrentschoolyear.GetCurrentSchoolYearData();

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

                if (AlterSectionValueTextbox.Text.Trim().Length < 1 || AlterMaximumStudentValueTextbox.Text.Trim().Length < 1)
                {
                    notificationwindow.CaptionText    = "MESSAGE CONTENT";
                    notificationwindow.MsgImage.Image = Properties.Resources.warning;
                    notificationwindow.MessageText    = "PLEASE PROVIDE NEW SECTION NAME\n&& MAXIMUM STUDENTS !";

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

                else if (isnumber(AlterMaximumStudentValueTextbox.Text.Trim()) == false)
                {
                    notificationwindow.CaptionText    = "MESSAGE CONTENT";
                    notificationwindow.MsgImage.Image = Properties.Resources.warning;
                    notificationwindow.MessageText    = "INVALID VALUE ON MAXIMUM STUDENTS !";

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

                else
                {
                    string TempQuery = "SELECT COUNT(*) FROM [Tbl.Sections]" +
                                       " WHERE [SECTION ID] = '" + SectionIDDropdown.selectedValue.ToString() + "' AND [ENROLLED] = '0'";
                    sqldataadapter = new SqlDataAdapter(TempQuery, sqlconnection);
                    DataTable datatable = new DataTable();
                    sqldataadapter.Fill(datatable);

                    if (datatable.Rows[0][0].ToString() == "1")
                    {
                        //TODO:
                        string VerifyQuery = "SELECT COUNT(*) FROM [Tbl.Sections] WHERE [SECTION NAME] = '" +
                                             AlterSectionValueTextbox.Text.Trim().ToUpper() + "' AND [SCHOOL YEAR] = '" + currentschoolyear + "'";
                        sqldataadapter = new SqlDataAdapter(VerifyQuery, sqlconnection);
                        DataTable virtualtable = new DataTable();
                        sqldataadapter.Fill(virtualtable);

                        if (virtualtable.Rows[0][0].ToString() == "1")
                        {
                            notificationwindow.CaptionText    = "MESSAGE CONTENT";
                            notificationwindow.MsgImage.Image = Properties.Resources.warning;
                            notificationwindow.MessageText    = "THAT SECTION ALREADY EXIST FOR \nSCHOOL YEAR " +
                                                                CurrentSchoolYearDropdown.selectedValue.ToString();

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

                        else if (virtualtable.Rows[0][0].ToString() == "0")
                        {
                            string UpdateQuery1 = "UPDATE [Tbl.Sections] SET [SECTION NAME] = @secname, [MAXIMUM STUDENTS] = @maxstud," +
                                                  "[SCHOOL YEAR] = @scholyear WHERE [SECTION ID] = '" + SectionIDDropdown.selectedValue.ToString() + "'";

                            sqlcommand = new SqlCommand(UpdateQuery1, sqlconnection);
                            sqlcommand.Parameters.AddWithValue("@secname", AlterSectionValueTextbox.Text.Trim().ToUpper());
                            sqlcommand.Parameters.AddWithValue("@maxstud", AlterMaximumStudentValueTextbox.Text.Trim());
                            sqlcommand.Parameters.AddWithValue("@scholyear", SchoolYearDropdown.selectedValue.ToString());
                            sqlcommand.ExecuteNonQuery();

                            //REFRESH SECTIONS GRIDVIEW
                            Load_Section_Records();

                            //RESET CONTROL STATE
                            SchoolYearDropdown.selectedIndex = 0;
                            AlterSectionValueTextbox.ResetText();
                            AlterMaximumStudentValueTextbox.ResetText();
                        }
                    }

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

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

            catch (Exception exception)
            {
                opacityform.Show();
                MessageBox.Show(exception.ToString(), "@Other Settings Form Exception 3",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                opacityform.Hide();
            }
        }
Пример #13
0
        //SAVE CURRENT SCHOOL YEAR
        private void SaveButton_Click(object sender, EventArgs e)
        {
            variables   = new Variables();
            opacityform = new OpacityForm();

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

                string GetID = "SELECT [ENTRY ID] FROM [Tbl.SchoolYear] WHERE [SCHOOL YEAR] = '" +
                               CurrentSchoolYearDropdown.selectedValue.ToString() + "'";
                sqlcommand = new SqlCommand(GetID, sqlconnection);
                SqlDataReader sqldatareader = sqlcommand.ExecuteReader();

                while (sqldatareader.Read())
                {
                    EntryID = sqldatareader.GetString(0);
                }
                sqldatareader.Close();

                string TempQuery = "SELECT COUNT(*) FROM [Tbl.CurrentSchoolYear]";
                sqldataadapter = new SqlDataAdapter(TempQuery, sqlconnection);
                DataTable datatable = new DataTable();
                sqldataadapter.Fill(datatable);

                if (int.Parse(datatable.Rows[0][0].ToString()) > 0)
                {
                    string UpdateQuery0 = "UPDATE [Tbl.CurrentSchoolYear] SET [CURRENT SCHOOL YEAR] = @currentschoolyear, [SCHOOL YEAR ID] = @slyid";
                    sqlcommand = new SqlCommand(UpdateQuery0, sqlconnection);
                    sqlcommand.Parameters.AddWithValue("@currentschoolyear", CurrentSchoolYearDropdown.selectedValue.ToString());
                    sqlcommand.Parameters.AddWithValue("@slyid", EntryID);
                    sqlcommand.ExecuteNonQuery();

                    string UpdateQuery1 = "UPDATE [Tbl.SchoolYear] SET [WAS SET] = @ws WHERE [ENTRY ID] = '" + EntryID + "'";
                    sqlcommand = new SqlCommand(UpdateQuery1, sqlconnection);
                    sqlcommand.Parameters.AddWithValue("@ws", "1");
                    sqlcommand.ExecuteNonQuery();

                    notificationwindow.CaptionText    = "MESSAGE CONTENT";
                    notificationwindow.MsgImage.Image = Properties.Resources.check;
                    notificationwindow.MessageText    = "CURRENT SCHOOL YEAR WAS\nSET TO " + CurrentSchoolYearDropdown.selectedValue.ToString();

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

                    //SYNC NEW CURRENT SECTION LABEL
                    CurrentSchoolYearLabel.Text = "* CURRENT SCHOOL YEAR: " + CurrentSchoolYearDropdown.selectedValue.ToString();

                    //RESET CONTROL STATE
                    CurrentSchoolYearDropdown.selectedIndex = 0;
                }

                else if (datatable.Rows[0][0].ToString() == "0")
                {
                    string UpdateQuery0_0 = "INSERT INTO [Tbl.CurrentSchoolYear]([CURRENT SCHOOL YEAR], [SCHOOL YEAR ID]) VALUES(@currentschoolyear, @slyid)";
                    sqlcommand = new SqlCommand(UpdateQuery0_0, sqlconnection);
                    sqlcommand.Parameters.AddWithValue("@currentschoolyear", CurrentSchoolYearDropdown.selectedValue.ToString());
                    sqlcommand.Parameters.AddWithValue("@slyid", EntryID);
                    sqlcommand.ExecuteNonQuery();

                    string UpdateQuery1 = "UPDATE [Tbl.SchoolYear] SET [WAS SET] = @ws WHERE [ENTRY ID] = '" + EntryID + "'";
                    sqlcommand = new SqlCommand(UpdateQuery1, sqlconnection);
                    sqlcommand.Parameters.AddWithValue("@ws", "1");
                    sqlcommand.ExecuteNonQuery();

                    notificationwindow.CaptionText    = "MESSAGE CONTENT";
                    notificationwindow.MsgImage.Image = Properties.Resources.check;
                    notificationwindow.MessageText    = "CURRENT SCHOOL YEAR WAS\nSET TO " + CurrentSchoolYearDropdown.selectedValue.ToString();

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

                    //SYNC NEW CURRENT SECTION LABEL
                    CurrentSchoolYearLabel.Text = "* CURRENT SCHOOL YEAR: " + CurrentSchoolYearDropdown.selectedValue.ToString();

                    //RESET CONTROL STATE
                    CurrentSchoolYearDropdown.selectedIndex = 0;
                }

                //UPDATE REGISTRY VALUES
                RegistryKey updateregistrykey = Registry.CurrentUser.CreateSubKey(@variables.pathname);
                updateregistrykey.SetValue("NofMaxSections", "0");
            }

            catch (Exception exception)
            {
                opacityform.Show();
                MessageBox.Show(exception.ToString(), "@Other Settings Form Exception 2",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                opacityform.Hide();
            }
        }
Пример #14
0
        private void UserIDTextbox_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Escape)
            {
                DialogResult = DialogResult.OK;
            }

            else if (e.KeyCode == Keys.Enter)
            {
                //EXCEPTION 2
                try
                {
                    opacityform        = new OpacityForm();
                    darkeropacityform  = new DarkerOpacityForm();
                    notificationwindow = new NotificationWindow();

                    if (UserIDTextbox.Text.Trim().Length < 1)
                    {
                        notificationwindow.CaptionText    = "MESSAGE CONTENT";
                        notificationwindow.MsgImage.Image = Properties.Resources.warning;
                        notificationwindow.MessageText    = "NO USER ID ENTERED !";

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

                    else if (IsNumber(UserIDTextbox.Text.Trim()) == false)
                    {
                        notificationwindow.CaptionText    = "MESSAGE CONTENT";
                        notificationwindow.MsgImage.Image = Properties.Resources.warning;
                        notificationwindow.MessageText    = "INVALID USER ID - " + UserIDTextbox.Text.Trim() + " !";

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

                    else if (UserID.Equals(UserIDTextbox.Text.Trim()) || UserIDTextbox.Text.Trim().Equals(UserID))
                    {
                        notificationwindow.CaptionText    = "MESSAGE CONTENT";
                        notificationwindow.MsgImage.Image = Properties.Resources.error;
                        notificationwindow.MessageText    = "THIS OPERATION CANNOT BE DONE\nBECAUSE YOU CANNOT ALTER\nYOUR OWN ACCOUNT !";

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

                    else
                    {
                        string sqlquery1 = "SELECT COUNT(*) FROM [Tbl.Users] WHERE [USER ID] = '" + UserIDTextbox.Text.Trim() + "'";
                        sqldataadapter = new SqlDataAdapter(sqlquery1, sqlconnection);
                        DataTable datatable = new DataTable();
                        sqldataadapter.Fill(datatable);

                        //USER ID IS VALID - UPDATE USER STATUS
                        if (datatable.Rows[0][0].ToString() == "1")
                        {
                            string query1 = "SELECT [ACCOUNT STATUS] FROM [Tbl.Users] WHERE [USER ID] = '" + UserIDTextbox.Text.Trim() + "'";
                            sqlcommand = new SqlCommand(query1, sqlconnection);
                            SqlDataReader sqldatareader = sqlcommand.ExecuteReader();

                            while (sqldatareader.Read())
                            {
                                isActive = sqldatareader.GetString(0);
                            }
                            sqldatareader.Close();

                            if (isActive.Equals("Active"))
                            {
                                opacityform.Show();
                                var PlsDontContinue = MessageBox.Show("ARE YOU SURE TO DISABLE THIS ACCOUNT ?, THIS USER CANNOT LOGIN ANYMORE" +
                                                                      " UNLESS YOU ENABLE IT BACK !\n\nDO YOU WANT TO PROCEED ANYWAY ?", "ARE YOU SURE ?",
                                                                      MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);

                                if (PlsDontContinue == DialogResult.No || PlsDontContinue == DialogResult.Cancel)
                                {
                                    opacityform.Hide();
                                }

                                else if (PlsDontContinue == DialogResult.Yes)
                                {
                                    opacityform.Hide();
                                    string alterquery1 = "UPDATE [Tbl.Users] SET [ACCOUNT STATUS] = @accountstatus WHERE [USER ID] = '" +
                                                         UserIDTextbox.Text.Trim() + "'";

                                    sqlcommand = new SqlCommand(alterquery1, sqlconnection);
                                    sqlcommand.Parameters.AddWithValue("@accountstatus", "Disabled");
                                    sqlcommand.ExecuteNonQuery();

                                    notificationwindow.CaptionText    = "MESSAGE CONTENT";
                                    notificationwindow.MsgImage.Image = Properties.Resources.check;
                                    notificationwindow.MessageText    = "USER ACCOUNT IS NOW DISABLED !";

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

                                    RefreshPicture3_Click(sender, e);
                                }
                            }

                            else if (isActive.Equals("Disabled"))
                            {
                                string alterquery2 = "UPDATE [Tbl.Users] SET [ACCOUNT STATUS] = @accountstatus WHERE [USER ID] = '" +
                                                     UserIDTextbox.Text.Trim() + "'";

                                sqlcommand = new SqlCommand(alterquery2, sqlconnection);
                                sqlcommand.Parameters.AddWithValue("@accountstatus", "Active");
                                sqlcommand.ExecuteNonQuery();

                                notificationwindow.CaptionText    = "MESSAGE CONTENT";
                                notificationwindow.MsgImage.Image = Properties.Resources.check;
                                notificationwindow.MessageText    = "USER ACCOUNT IS NOW ENABLED !";

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

                                RefreshPicture3_Click(sender, e);
                            }
                        }

                        //F**K YEAH, USER ID IS NOT VALID
                        else if (datatable.Rows[0][0].ToString() == "0")
                        {
                            notificationwindow.CaptionText    = "MESSAGE CONTENT";
                            notificationwindow.MsgImage.Image = Properties.Resources.warning;
                            notificationwindow.MessageText    = "NO RECORDS FOUND FOR\nUSER ID - " + UserIDTextbox.Text.Trim() + " !";

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

                catch (Exception exception)
                {
                    opacityform.Show();
                    MessageBox.Show(exception.Message.ToString(), "@List Of System Objects Exception 2",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);

                    opacityform.Hide();
                }
            }
        }
        private void TestConnectionButton_Click(object sender, EventArgs e)
        {
            opacityform        = new OpacityForm();
            darkeropacityform  = new DarkerOpacityForm();
            notificationwindow = new NotificationWindow();

            //EXCEPTION 1
            try
            {
                //SHOW VISUAL REPRESENTATION FOR EMPTY TEXTBOXES
                Show_Hide_Visual_Representation_Labels();

                if (ServerNameTextbox.Text.Length == 0 || DatabaseNameTextbox.Text.Length == 0 ||
                    SqlServerUsernameTextbox.Text.Length == 0 || SqlServerPasswordTextbox.Text.Length == 0)
                {
                    notificationwindow.CaptionText    = "CONNECTION REFUSED";
                    notificationwindow.MsgImage.Image = Properties.Resources.warning;
                    notificationwindow.MessageText    = "PLEASE PROVIDE THE REQUIRED\nINFORMATIONS BEING ASK !";

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

                else if (ServerNameTextbox.Text.EndsWith(" ") || DatabaseNameTextbox.Text.EndsWith(" ") ||
                         SqlServerUsernameTextbox.Text.EndsWith(" ") || SqlServerPasswordTextbox.Text.EndsWith(" "))
                {
                    notificationwindow.CaptionText    = "CONNECTION REFUSED";
                    notificationwindow.MsgImage.Image = Properties.Resources.error;
                    notificationwindow.MessageText    = "LOGIN FAILED !\nPLEASE REVIEW YOUR INFORMATION.";

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

                else if (ServerNameTextbox.Text.Length != 0 && DatabaseNameTextbox.Text.Length != 0 &&
                         SqlServerUsernameTextbox.Text.Length != 0 && SqlServerPasswordTextbox.Text.Length != 0)
                {
                    //INNER EXCEPTION 1
                    try
                    {
                        variables = new Variables();
                        sqlconfig = new SQLConnectionConfig();

                        tempconnectionstring = "Data Source=" + ServerNameTextbox.Text + ";" + "Initial Catalog=" + DatabaseNameTextbox.Text + ";"
                                               + "Persist Security Info=True;" + "User ID=" + SqlServerUsernameTextbox.Text + ";" + "Password="******"";

                        sqlconfig.SqlConnectionString = tempconnectionstring;
                        sqlconnection = new SqlConnection(sqlconfig.SqlConnectionString);

                        do
                        {
                            Cursor = Cursors.AppStarting;
                            sqlconnection.Open();

                            if (sqlconnection.State == ConnectionState.Open)
                            {
                                notificationwindow.CaptionText    = "CONNECTION TESTING";
                                notificationwindow.MsgImage.Image = Properties.Resources.check;
                                notificationwindow.MessageText    = "TEST CONNECTION SUCCEEDED !";

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

                                Cursor = Cursors.Default;
                                break;
                            }
                        }while (sqlconnection.State == ConnectionState.Closed);
                        sqlconnection.Close();
                    }

                    catch (Exception exception)
                    {
                        Cursor = Cursors.Default;
                        opacityform.Show();
                        MessageBox.Show(exception.Message.ToString(), "@Server Connection Inner Exception 1",
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);

                        opacityform.Hide();
                    }
                }
            }

            catch (Exception exception)
            {
                opacityform.Show();
                MessageBox.Show(exception.Message.ToString(), "@Server Connection Exception 1",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);

                opacityform.Hide();
            }
        }
Пример #16
0
        private void SubmitButton_Click(object sender, EventArgs e)
        {
            //EXCEPTION 2
            try
            {
                opacityform        = new OpacityForm();
                darkeropacityform  = new DarkerOpacityForm();
                notificationwindow = new NotificationWindow();

                if (LRNTextbox.Text.Trim().Length < 1 || FirstNameTextbox.Text.Trim().Length < 1 || MiddleNameTextbox.Text.Trim().Length < 1 ||
                    LastNameTextbox.Text.Trim().Length < 1 || PresentAddressTextbox.Text.Trim().Length < 1 || PlaceOfBirthTextbox.Text.Trim().Length < 1 ||
                    BloodTypeTextbox.Text.Trim().Length < 1 || ReligionTextbox.Text.Trim().Length < 1 || EmailAddressTextbox.Text.Trim().Length < 1 ||
                    MobileNumberTextbox.Text.Trim().Length < 1 || SectionDropdown.selectedIndex == 0 || FathersNameTextbox.Text.Trim().Length < 1 ||
                    FathersOccupationTextbox.Text.Trim().Length < 1 || FathersContactNumberTextbox.Text.Trim().Length < 1 ||
                    FathersAddressTextbox.Text.Trim().Length < 1 || MothersNameTextbox.Text.Trim().Length < 1 || MothersOccupationTextbox.Text.Trim().Length < 1 ||
                    MothersContactNumberTextbox.Text.Trim().Length < 1 || MothersAddressTextbox.Text.Trim().Length < 1 || PasswordTextbox.Text.Trim().Length < 1 ||
                    ConfirmPasswordTextbox.Text.Trim().Length < 1)
                {
                    notificationwindow.CaptionText    = "MESSAGE CONTENT";
                    notificationwindow.MsgImage.Image = Properties.Resources.warning;
                    notificationwindow.MessageText    = "PLEASE PROVIDE THE REQUIRED\nINFORMATIONS BEING ASK !";

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

                else if (!EmailAddressTextbox.Text.Trim().Contains("@") || !EmailAddressTextbox.Text.Trim().Contains(".com"))
                {
                    notificationwindow.CaptionText    = "MESSAGE CONTENT";
                    notificationwindow.MsgImage.Image = Properties.Resources.warning;
                    notificationwindow.MessageText    = "PLEASE PROVIDE A VALID EMAIL ADDRESS !";

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

                else if (MobileNumberTextbox.Text.Trim().Length < 11 || MobileNumberTextbox.Text.Trim().Length > 11)
                {
                    notificationwindow.CaptionText    = "MESSAGE CONTENT";
                    notificationwindow.MsgImage.Image = Properties.Resources.warning;
                    notificationwindow.MessageText    = "PHONE NUMBER MUST BE 11-DIGITS LONG !";

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

                else if (FathersContactNumberTextbox.Text.Trim().Length < 11 || FathersContactNumberTextbox.Text.Trim().Length > 11)
                {
                    notificationwindow.CaptionText    = "MESSAGE CONTENT";
                    notificationwindow.MsgImage.Image = Properties.Resources.warning;
                    notificationwindow.MessageText    = "YOUR FATHERS PHONE NUMBER MUST BE\n11-DIGITS LONG !";

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

                else if (MothersContactNumberTextbox.Text.Trim().Length < 11 || MothersContactNumberTextbox.Text.Trim().Length > 11)
                {
                    notificationwindow.CaptionText    = "MESSAGE CONTENT";
                    notificationwindow.MsgImage.Image = Properties.Resources.warning;
                    notificationwindow.MessageText    = "YOUR MOTHERS PHONE NUMBER MUST BE\n11-DIGITS LONG !";

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

                else if (isNumber(MobileNumberTextbox.Text.Trim()) == false)
                {
                    notificationwindow.CaptionText    = "MESSAGE CONTENT";
                    notificationwindow.MsgImage.Image = Properties.Resources.warning;
                    notificationwindow.MessageText    = "PHONE NUMBER CONTAINS AN INVALID\nCHARACTER !";

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

                else if (isNumber(FathersContactNumberTextbox.Text.Trim()) == false)
                {
                    notificationwindow.CaptionText    = "MESSAGE CONTENT";
                    notificationwindow.MsgImage.Image = Properties.Resources.warning;
                    notificationwindow.MessageText    = "YOUR FATHERS PHONE NUMBER CONTAINS\nAN INVALID CHARACTER !";

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

                else if (isNumber(MothersContactNumberTextbox.Text.Trim()) == false)
                {
                    notificationwindow.CaptionText    = "MESSAGE CONTENT";
                    notificationwindow.MsgImage.Image = Properties.Resources.warning;
                    notificationwindow.MessageText    = "YOUR MOTHERS PHONE NUMBER CONTAINS\nAN INVALID CHARACTER !";

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

                else if (!PasswordTextbox.Text.Trim().Equals(ConfirmPasswordTextbox.Text.Trim()) ||
                         !ConfirmPasswordTextbox.Text.Trim().Equals(PasswordTextbox.Text.Trim()))
                {
                    notificationwindow.CaptionText    = "MESSAGE CONTENT";
                    notificationwindow.MsgImage.Image = Properties.Resources.warning;
                    notificationwindow.MessageText    = "PLEASE CONFIRM YOUR PASSWORD !";

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

                else if (PasswordTextbox.Text.Trim().Length < 8 || ConfirmPasswordTextbox.Text.Trim().Length < 8)
                {
                    notificationwindow.CaptionText    = "MESSAGE CONTENT";
                    notificationwindow.MsgImage.Image = Properties.Resources.warning;
                    notificationwindow.MessageText    = "YOUR PASSWORD IS TOO SHORT, MAKE IT\n8-CHARACTERS OR ABOVE LONG !";

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

                else
                {
                    //INNER EXCEPTION 22
                    try
                    {
                        string query1, query2, query3, query4, query5, query6, query7, query8, query9, query10;
                        string OldMaxStudents, OldEnrolled; int NewEnrolledCount;

                        string FullName = LastNameTextbox.Text.Trim() + ", " + FirstNameTextbox.Text.Trim() + " "
                                          + MiddleNameTextbox.Text.Trim().Remove(1, MiddleNameTextbox.Text.Trim().Length - 1) + ".";

                        //CHECK IF THE SECTION IS FULL OR NOT
                        query1 = "SELECT [MAXIMUM STUDENTS], ENROLLED FROM [Tbl.Sections] WHERE [SECTION NAME] = '" +
                                 SectionDropdown.selectedValue.ToString() + "' AND [SCHOOL YEAR] = '" + CurrentSchoolYear + "'";
                        sqlcommand = new SqlCommand(query1, sqlconnection);
                        SqlDataReader sqldatareader = sqlcommand.ExecuteReader();

                        while (sqldatareader.Read())
                        {
                            OldMaxStudents   = sqldatareader.GetString(0);
                            OldEnrolled      = sqldatareader.GetString(1);
                            NewEnrolledCount = int.Parse(OldEnrolled) + 1;

                            if (!OldEnrolled.Equals(OldMaxStudents) || !OldMaxStudents.Equals(OldEnrolled))
                            {
                                sqldatareader.Close();

                                //VALIDATE STUDENT REGISTRATION
                                string VerifyQuery = "SELECT COUNT(*) FROM [Tbl.Students] WHERE [FIRST NAME] = '" +
                                                     FirstNameTextbox.Text.Trim() + "' AND [MIDDLE NAME] = '" + MiddleNameTextbox.Text.Trim() +
                                                     "' AND [LAST NAME] = '" + LastNameTextbox.Text.Trim() + "'";

                                sqldataadapter = new SqlDataAdapter(VerifyQuery, sqlconnection);
                                DataTable VirtualTable = new DataTable();
                                sqldataadapter.Fill(VirtualTable);

                                if (VirtualTable.Rows[0][0].ToString() == "0")
                                {
                                    //INSERT INTO STUDENTS TABLE
                                    query2 = "INSERT INTO [Tbl.Students]([STUDENT ID], [USER ID], LRN, [FIRST NAME], [MIDDLE NAME], [LAST NAME], [GRADE LEVEL]," +
                                             "SECTION, GENDER, [BIRTH DATE], [PRESENT ADDRESS], [PLACE OF BIRTH], [BLOOD TYPE], RELIGION, [INDIGINOUS GROUP]," +
                                             "[EMAIL ADDRESS], [MOBILE NUMBER]) VALUES(@studentid, @userid, @lrn, @firstname, @middlename, @lastname, @gradelevel," +
                                             "@section, @gender, @birthdate, @presentaddress, @placeofbirth, @bloodtype, @religion, @indiginousgroup, @emailaddress," +
                                             "@mobilenumber)";
                                    sqlcommand = new SqlCommand(query2, sqlconnection);
                                    sqlcommand.Parameters.AddWithValue("@studentid", NewStudentID.ToString());
                                    sqlcommand.Parameters.AddWithValue("@userid", NewUserID.ToString());
                                    sqlcommand.Parameters.AddWithValue("@lrn", LRNTextbox.Text.Trim());

                                    sqlcommand.Parameters.AddWithValue("@firstname", FirstNameTextbox.Text.Trim());
                                    sqlcommand.Parameters.AddWithValue("@middlename", MiddleNameTextbox.Text.Trim());
                                    sqlcommand.Parameters.AddWithValue("@lastname", LastNameTextbox.Text.Trim());

                                    sqlcommand.Parameters.AddWithValue("@gradelevel", GradeLevelDropdown.selectedValue.ToString());
                                    sqlcommand.Parameters.AddWithValue("@section", SectionDropdown.selectedValue.ToString());
                                    sqlcommand.Parameters.AddWithValue("@gender", GenderDropdown.selectedValue.ToString());

                                    sqlcommand.Parameters.AddWithValue("@birthdate", BirthdayPicker.Value.ToLongDateString().ToString());
                                    sqlcommand.Parameters.AddWithValue("@presentaddress", PresentAddressTextbox.Text.Trim());
                                    sqlcommand.Parameters.AddWithValue("@placeofbirth", PlaceOfBirthTextbox.Text.Trim());

                                    sqlcommand.Parameters.AddWithValue("@bloodtype", BloodTypeTextbox.Text.Trim());
                                    sqlcommand.Parameters.AddWithValue("@religion", ReligionTextbox.Text.Trim());
                                    sqlcommand.Parameters.AddWithValue("@indiginousgroup", IndiginousGroupTextbox.Text.Trim() == "" ? "None" :
                                                                       IndiginousGroupTextbox.Text.Trim());

                                    sqlcommand.Parameters.AddWithValue("@emailaddress", EmailAddressTextbox.Text.Trim());
                                    sqlcommand.Parameters.AddWithValue("@mobilenumber", MobileNumberTextbox.Text.Trim());
                                    sqlcommand.ExecuteNonQuery();

                                    //INSERT INTO FAMILY BACKGROUND TABLE
                                    query3 = "INSERT INTO [Tbl.FamilyBackgrounds]([STUDENT ID], [FATHERS NAME], [FATHERS OCCUPATION], [FATHERS CONTACT NUMBER]," +
                                             "[FATHERS ADDRESS], [MOTHERS NAME], [MOTHERS OCCUPATION], [MOTHERS CONTACT NUMBER], [MOTHERS ADDRESS]) VALUES(@studentid," +
                                             "@fathersname, @fatheroccupation, @fathersnumber, @fathersaddress, @mothername, @motheroccupation, @mothernumber, @motheraddress)";
                                    sqlcommand = new SqlCommand(query3, sqlconnection);
                                    sqlcommand.Parameters.AddWithValue("@studentid", NewStudentID.ToString());

                                    sqlcommand.Parameters.AddWithValue("@fathersname", FathersNameTextbox.Text.Trim());
                                    sqlcommand.Parameters.AddWithValue("@fatheroccupation", FathersOccupationTextbox.Text.Trim());
                                    sqlcommand.Parameters.AddWithValue("@fathersnumber", FathersContactNumberTextbox.Text.Trim());
                                    sqlcommand.Parameters.AddWithValue("@fathersaddress", FathersAddressTextbox.Text.Trim());

                                    sqlcommand.Parameters.AddWithValue("@mothername", MothersNameTextbox.Text.Trim());
                                    sqlcommand.Parameters.AddWithValue("@motheroccupation", MothersOccupationTextbox.Text.Trim());
                                    sqlcommand.Parameters.AddWithValue("@mothernumber", MothersContactNumberTextbox.Text.Trim());
                                    sqlcommand.Parameters.AddWithValue("@motheraddress", MothersAddressTextbox.Text.Trim());
                                    sqlcommand.ExecuteNonQuery();

                                    //INSERT INTO USERS TABLE
                                    query4 = "INSERT INTO [Tbl.Users]([USER ID], USERNAME, PASSWORD, [ACCOUNT STATUS], [ACCOUNT TYPE], [LAST LOGIN]," +
                                             "[IS PWD CHANGED], [SITUATION STATUS]) VALUES(@userid, @username, @password, @accountstatus, @account_type, @last_login, @ispwdchanged, @stat)";
                                    sqlcommand = new SqlCommand(query4, sqlconnection);
                                    sqlcommand.Parameters.AddWithValue("@userid", NewUserID.ToString());
                                    sqlcommand.Parameters.AddWithValue("@username", cryptography.Encrypt(NewStudentID.ToString()));
                                    sqlcommand.Parameters.AddWithValue("@password", cryptography.Encrypt(PasswordTextbox.Text));
                                    sqlcommand.Parameters.AddWithValue("@accountstatus", "Active");

                                    sqlcommand.Parameters.AddWithValue("@account_type", "Student");
                                    sqlcommand.Parameters.AddWithValue("@last_login", "NO LOGIN HISTORY");
                                    sqlcommand.Parameters.AddWithValue("@ispwdchanged", "False");
                                    sqlcommand.Parameters.AddWithValue("@stat", "0");
                                    sqlcommand.ExecuteNonQuery();

                                    //UPDATE SECTIONS TABLE --> ENROLLED
                                    query5 = "UPDATE [Tbl.Sections] SET ENROLLED = @enrolled WHERE [SECTION NAME] = @section_nane" +
                                             " AND [SCHOOL YEAR] = '" + CurrentSchoolYear + "'";

                                    sqlcommand = new SqlCommand(query5, sqlconnection);
                                    sqlcommand.Parameters.AddWithValue("@enrolled", NewEnrolledCount.ToString());
                                    sqlcommand.Parameters.AddWithValue("@section_nane", SectionDropdown.selectedValue.ToString());
                                    sqlcommand.ExecuteNonQuery();

                                    //INSERT INTO STUDENT LOAD TABLE --> 1st Grading
                                    query6 = "INSERT INTO [Tbl.FirstGradingStudentLoad]([STUDENT ID], [STUDENT NAME], GENDER, [GRADE LEVEL], SECTION," +
                                             "FILIPINO, ENGLISH, MATHEMATICS, SCIENCE, AP, TLE, MAPEH, ESP, [SCHOOL YEAR]) VALUES(@studentid1g, @studentname1g," +
                                             "@gender1g, @gradelevel1g, @section1g, @sb11g, @sb21g, @sb31g, @sb41g, @sb51g, @sb61g, @sb71g, @sb81g, @schoolyear1g)";
                                    sqlcommand = new SqlCommand(query6, sqlconnection);

                                    sqlcommand.Parameters.AddWithValue("@studentid1g", NewStudentID.ToString());
                                    sqlcommand.Parameters.AddWithValue("@studentname1g", FullName);
                                    sqlcommand.Parameters.AddWithValue("@gender1g", GenderDropdown.selectedValue.ToString());
                                    sqlcommand.Parameters.AddWithValue("@gradelevel1g", GradeLevelDropdown.selectedValue.ToString());
                                    sqlcommand.Parameters.AddWithValue("@section1g", SectionDropdown.selectedValue.ToString());

                                    sqlcommand.Parameters.AddWithValue("@sb11g", "");
                                    sqlcommand.Parameters.AddWithValue("@sb21g", "");
                                    sqlcommand.Parameters.AddWithValue("@sb31g", "");
                                    sqlcommand.Parameters.AddWithValue("@sb41g", "");
                                    sqlcommand.Parameters.AddWithValue("@sb51g", "");
                                    sqlcommand.Parameters.AddWithValue("@sb61g", "");
                                    sqlcommand.Parameters.AddWithValue("@sb71g", "");
                                    sqlcommand.Parameters.AddWithValue("@sb81g", "");
                                    sqlcommand.Parameters.AddWithValue("@schoolyear1g", CurrentSchoolYear);
                                    sqlcommand.ExecuteNonQuery();

                                    //INSERT INTO STUDENT LOAD TABLE --> 2nd Grading
                                    query7 = "INSERT INTO [Tbl.SecondGradingStudentLoad]([STUDENT ID], [STUDENT NAME], GENDER, [GRADE LEVEL], SECTION," +
                                             "FILIPINO, ENGLISH, MATHEMATICS, SCIENCE, AP, TLE, MAPEH, ESP, [SCHOOL YEAR]) VALUES(@studentid2g, @studentname2g," +
                                             "@gender2g, @gradelevel2g, @section2g, @sb12g, @sb22g, @sb32g, @sb42g, @sb52g, @sb62g, @sb72g, @sb82g, @schoolyear2g)";
                                    sqlcommand = new SqlCommand(query7, sqlconnection);

                                    sqlcommand.Parameters.AddWithValue("@studentid2g", NewStudentID.ToString());
                                    sqlcommand.Parameters.AddWithValue("@studentname2g", FullName);
                                    sqlcommand.Parameters.AddWithValue("@gender2g", GenderDropdown.selectedValue.ToString());
                                    sqlcommand.Parameters.AddWithValue("@gradelevel2g", GradeLevelDropdown.selectedValue.ToString());
                                    sqlcommand.Parameters.AddWithValue("@section2g", SectionDropdown.selectedValue.ToString());

                                    sqlcommand.Parameters.AddWithValue("@sb12g", "");
                                    sqlcommand.Parameters.AddWithValue("@sb22g", "");
                                    sqlcommand.Parameters.AddWithValue("@sb32g", "");
                                    sqlcommand.Parameters.AddWithValue("@sb42g", "");
                                    sqlcommand.Parameters.AddWithValue("@sb52g", "");
                                    sqlcommand.Parameters.AddWithValue("@sb62g", "");
                                    sqlcommand.Parameters.AddWithValue("@sb72g", "");
                                    sqlcommand.Parameters.AddWithValue("@sb82g", "");
                                    sqlcommand.Parameters.AddWithValue("@schoolyear2g", CurrentSchoolYear);
                                    sqlcommand.ExecuteNonQuery();

                                    //INSERT INTO STUDENT LOAD TABLE --> 3rd Grading
                                    query8 = "INSERT INTO [Tbl.ThirdGradingStudentLoad]([STUDENT ID], [STUDENT NAME], GENDER, [GRADE LEVEL], SECTION," +
                                             "FILIPINO, ENGLISH, MATHEMATICS, SCIENCE, AP, TLE, MAPEH, ESP, [SCHOOL YEAR]) VALUES(@studentid3g, @studentname3g," +
                                             "@gender3g, @gradelevel3g, @section3g, @sb13g, @sb23g, @sb33g, @sb43g, @sb53g, @sb63g, @sb73g, @sb83g, @schoolyear3g)";
                                    sqlcommand = new SqlCommand(query8, sqlconnection);

                                    sqlcommand.Parameters.AddWithValue("@studentid3g", NewStudentID.ToString());
                                    sqlcommand.Parameters.AddWithValue("@studentname3g", FullName);
                                    sqlcommand.Parameters.AddWithValue("@gender3g", GenderDropdown.selectedValue.ToString());
                                    sqlcommand.Parameters.AddWithValue("@gradelevel3g", GradeLevelDropdown.selectedValue.ToString());
                                    sqlcommand.Parameters.AddWithValue("@section3g", SectionDropdown.selectedValue.ToString());

                                    sqlcommand.Parameters.AddWithValue("@sb13g", "");
                                    sqlcommand.Parameters.AddWithValue("@sb23g", "");
                                    sqlcommand.Parameters.AddWithValue("@sb33g", "");
                                    sqlcommand.Parameters.AddWithValue("@sb43g", "");
                                    sqlcommand.Parameters.AddWithValue("@sb53g", "");
                                    sqlcommand.Parameters.AddWithValue("@sb63g", "");
                                    sqlcommand.Parameters.AddWithValue("@sb73g", "");
                                    sqlcommand.Parameters.AddWithValue("@sb83g", "");
                                    sqlcommand.Parameters.AddWithValue("@schoolyear3g", CurrentSchoolYear);
                                    sqlcommand.ExecuteNonQuery();

                                    //INSERT INTO STUDENT LOAD TABLE --> 4rth Grading
                                    query9 = "INSERT INTO [Tbl.FourthGradingStudentLoad]([STUDENT ID], [STUDENT NAME], GENDER, [GRADE LEVEL], SECTION," +
                                             "FILIPINO, ENGLISH, MATHEMATICS, SCIENCE, AP, TLE, MAPEH, ESP, [SCHOOL YEAR]) VALUES(@studentid4g, @studentname4g," +
                                             "@gender4g, @gradelevel4g, @section4g, @sb14g, @sb24g, @sb34g, @sb44g, @sb54g, @sb64g, @sb74g, @sb84g, @schoolyear4g)";
                                    sqlcommand = new SqlCommand(query9, sqlconnection);

                                    sqlcommand.Parameters.AddWithValue("@studentid4g", NewStudentID.ToString());
                                    sqlcommand.Parameters.AddWithValue("@studentname4g", FullName);
                                    sqlcommand.Parameters.AddWithValue("@gender4g", GenderDropdown.selectedValue.ToString());
                                    sqlcommand.Parameters.AddWithValue("@gradelevel4g", GradeLevelDropdown.selectedValue.ToString());
                                    sqlcommand.Parameters.AddWithValue("@section4g", SectionDropdown.selectedValue.ToString());

                                    sqlcommand.Parameters.AddWithValue("@sb14g", "");
                                    sqlcommand.Parameters.AddWithValue("@sb24g", "");
                                    sqlcommand.Parameters.AddWithValue("@sb34g", "");
                                    sqlcommand.Parameters.AddWithValue("@sb44g", "");
                                    sqlcommand.Parameters.AddWithValue("@sb54g", "");
                                    sqlcommand.Parameters.AddWithValue("@sb64g", "");
                                    sqlcommand.Parameters.AddWithValue("@sb74g", "");
                                    sqlcommand.Parameters.AddWithValue("@sb84g", "");
                                    sqlcommand.Parameters.AddWithValue("@schoolyear4g", CurrentSchoolYear);
                                    sqlcommand.ExecuteNonQuery();

                                    //INSERT INTO [Tbl.StudentAverages]
                                    query10 = "INSERT INTO [Tbl.StudentAverages]([STUDENT ID], [STUDENT NAME], LRN, [GRADE LEVEL], SECTION, " +
                                              "[FIRST GRADING], [SECOND GRADING], [THIRD GRADING], [FOURTH GRADING], GPA, [SCHOOL YEAR]) " +
                                              "VALUES(@sid, @studname, @lrn, @glevel, @section, @fga, @sga, @tga, @ffga, @gpa, @schoolyear)";
                                    sqlcommand = new SqlCommand(query10, sqlconnection);

                                    sqlcommand.Parameters.AddWithValue("@sid", NewStudentID.ToString());
                                    sqlcommand.Parameters.AddWithValue("@studname", FullName);
                                    sqlcommand.Parameters.AddWithValue("@lrn", LRNTextbox.Text.Trim());
                                    sqlcommand.Parameters.AddWithValue("@glevel", GradeLevelDropdown.selectedValue.ToString());
                                    sqlcommand.Parameters.AddWithValue("@section", SectionDropdown.selectedValue.ToString());

                                    sqlcommand.Parameters.AddWithValue("@fga", "");
                                    sqlcommand.Parameters.AddWithValue("@sga", "");
                                    sqlcommand.Parameters.AddWithValue("@tga", "");
                                    sqlcommand.Parameters.AddWithValue("@ffga", "");
                                    sqlcommand.Parameters.AddWithValue("@gpa", "");
                                    sqlcommand.Parameters.AddWithValue("@schoolyear", CurrentSchoolYear);
                                    sqlcommand.ExecuteNonQuery();

                                    notificationwindow.CaptionText    = "REGISTRATION SUCCESS !";
                                    notificationwindow.MsgImage.Image = Properties.Resources.check;
                                    notificationwindow.MessageText    = FirstNameTextbox.Text.Trim().ToUpper() + " " +
                                                                        LastNameTextbox.Text.Trim().ToUpper() + " " + "WAS\nREGISTERED SUCCESSFULLY !";

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

                                    sqlconnection.Close();
                                    DialogResult = DialogResult.OK;
                                }

                                else if (int.Parse(VirtualTable.Rows[0][0].ToString()) > 0)
                                {
                                    notificationwindow.CaptionText    = "MESSAGE CONTENT";
                                    notificationwindow.MsgImage.Image = Properties.Resources.error;
                                    notificationwindow.MessageText    = "THIS STUDENT IS ALREADY REGISTERED !";

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

                            else
                            {
                                sqldatareader.Close();
                                notificationwindow.CaptionText    = "MESSAGE CONTENT";
                                notificationwindow.MsgImage.Image = Properties.Resources.error;
                                notificationwindow.MessageText    = "SECTION " + SectionDropdown.selectedValue.ToString() + "IS ALREADY FULL !";

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

                            break;
                        }
                        sqldatareader.Close();
                    }

                    catch (Exception exception)
                    {
                        opacityform.Show();
                        MessageBox.Show(exception.StackTrace.ToString() + exception.Message, "@Add Student Form Inner Exception 22",
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                        opacityform.Hide();
                    }
                }
            }

            catch (Exception exception)
            {
                opacityform.Show();
                MessageBox.Show(exception.StackTrace.ToString(), "@Add Student Form Exception 2",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                opacityform.Hide();
            }
        }
Пример #17
0
        private void InsertButton_Click(object sender, EventArgs e)
        {
            //EXCEPTION 3
            try
            {
                variables          = new Variables();
                opacityform        = new OpacityForm();
                darkeropacityform  = new DarkerOpacityForm();
                notificationwindow = new NotificationWindow();

                if (SectionNameTextbox.Text.Trim().Length < 1 || MaxStudentTextbox.Text.Trim().Length < 1)
                {
                    notificationwindow.CaptionText    = "MESSAGE CONTENT";
                    notificationwindow.MsgImage.Image = Properties.Resources.warning;
                    notificationwindow.MessageText    = "PLEASE PROVIDE SECTION NAME,\nMAXIMUM STUDENTS AND SCHOOL YEAR !";

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

                else if (isNumber(MaxStudentTextbox.Text.Trim()) == false)
                {
                    notificationwindow.CaptionText    = "MESSAGE CONTENT";
                    notificationwindow.MsgImage.Image = Properties.Resources.warning;
                    notificationwindow.MessageText    = "INVALID DATA ON MAXIMUM STUDENTS !";

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

                else
                {
                    //INNER EXCEPTION 3
                    try
                    {
                        string TempQuery = "SELECT COUNT(*) FROM [Tbl.Sections] WHERE [SECTION NAME] = '" +
                                           SectionNameTextbox.Text.Trim().ToUpper() + "' AND [SCHOOL YEAR] = '" + CurrentSchoolYearDropdown.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.warning;
                            notificationwindow.MessageText    = "THAT SECTION ALREADY EXIST FOR \nSCHOOL YEAR " + CurrentSchoolYearDropdown.selectedValue.ToString();

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

                        else if (datatable.Rows[0][0].ToString() == "0")
                        {
                            RegistryKey registrykey = Registry.CurrentUser.OpenSubKey(@variables.pathname);
                            CurrentSectionCount = registrykey.GetValue("NofMaxSections").ToString();

                            if (int.Parse(CurrentSectionCount) < 10)
                            {
                                sqlquery5 = "INSERT INTO [Tbl.Sections]([SECTION ID], [SECTION NAME], [MAXIMUM STUDENTS], ENROLLED, [SCHOOL YEAR])" +
                                            " VALUES(@sectionid, @section_name, @maximumstudents, @enrolled, @schoolyear)";
                                sqlcommand = new SqlCommand(sqlquery5, sqlconnection);
                                sqlcommand.Parameters.AddWithValue("@sectionid", Prefix + NewSectionID.ToString());
                                sqlcommand.Parameters.AddWithValue("@section_name", SectionNameTextbox.Text.Trim().ToUpper());
                                sqlcommand.Parameters.AddWithValue("@maximumstudents", MaxStudentTextbox.Text.Trim());
                                sqlcommand.Parameters.AddWithValue("@enrolled", "0");
                                sqlcommand.Parameters.AddWithValue("@schoolyear", CurrentSchoolYearDropdown.selectedValue.ToString().ToUpper());
                                sqlcommand.ExecuteNonQuery();

                                //UPDATE SECTION COUNT
                                RegistryKey updateregistrykey = Registry.CurrentUser.CreateSubKey(@variables.pathname);
                                updateregistrykey.SetValue("NofMaxSections", (int.Parse(CurrentSectionCount) + 1).ToString());

                                Init_NewSectionID();
                                RetriveSectionData();

                                SectionNameTextbox.ResetText();
                                MaxStudentTextbox.ResetText();

                                CurrentSchoolYearDropdown.selectedIndex = 0;
                                InsertButton.Select();
                            }

                            else if (int.Parse(CurrentSectionCount) == 10)
                            {
                                notificationwindow.CaptionText    = "MESSAGE CONTENT";
                                notificationwindow.MsgImage.Image = Properties.Resources.error;
                                notificationwindow.MessageText    = "YOU CAN ONLY CREATE 10 SECTIONS\nEVERY SCHOOL YEAR !";

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

                    catch (Exception exception)
                    {
                        opacityform.Show();
                        MessageBox.Show(exception.Message.ToString(), "@Add Section Form Inner Exception 3",
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                        opacityform.Hide();
                    }
                }
            }

            catch (Exception exception)
            {
                opacityform.Show();
                MessageBox.Show(exception.Message.ToString(), "@Add Section Form Exception 2",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                opacityform.Hide();
            }
        }
        private void LoginButton_Click(object sender, EventArgs e)
        {
            Show_BusyCursor_State();
            opacityform        = new OpacityForm();
            darkeropacityform  = new DarkerOpacityForm();
            notificationwindow = new NotificationWindow();

            //EXCEPTION 2
            try
            {
                variables = new Variables();
                RegistryKey getregistrykey = Registry.CurrentUser.OpenSubKey(@variables.pathname);
                string      tempdata       = getregistrykey.GetValue("SQLServerConnectionString").ToString();
                getregistrykey.Close();

                if (UsernameTextbox.Text.Length == 0 || PasswordTextbox.Text.Length == 0)
                {
                    authentication = new Authentication();
                    authentication.VerifyLoginCredentials(this);

                    Show_DefaultCursor_State();
                }

                else if (tempdata == string.Empty)
                {
                    notificationwindow.CaptionText    = "SERVER NOT FOUND";
                    notificationwindow.MsgImage.Image = Properties.Resources.warning;
                    notificationwindow.MessageText    = "WE CAN'T ESTABLISHED A CONNECTION\nTO THE SERVER, " +
                                                        "PLEASE SETUP THE\nFOLLOWING CONFIGURATIONS.";

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

                    SqlServerSettingsButton_Click(sender, e);
                    Show_DefaultCursor_State();
                }

                else
                {
                    //INNER EXCEPTION 2
                    try
                    {
                        authentication = new Authentication();
                        authentication.VerifyLoginCredentials(this);

                        //AUTHENTICATED & ADMINISTRATOR
                        if (authentication.IsVerified == true && authentication.IsAdmin == true)
                        {
                            administratorworkspace = new AdministratorWorkspace();

                            this.Hide();
                            administratorworkspace.Show();
                            Show_DefaultCursor_State();
                        }

                        //AUTHENTICATED & TEACHER
                        else if (authentication.IsVerified == true && authentication.IsTeacher == true)
                        {
                            teacherworkspace = new TeacherWorkspace();

                            this.Hide();
                            teacherworkspace.Show();
                            Show_DefaultCursor_State();
                        }

                        //AUTHENTICATED & STUDENT
                        else if (authentication.IsVerified == true && authentication.IsStudent == true)
                        {
                            studentworkspace = new StudentWorkspace();

                            this.Hide();
                            studentworkspace.Show();
                            Show_DefaultCursor_State();
                        }
                    }

                    catch (Exception exception)
                    {
                        opacityform.Show();
                        MessageBox.Show(exception.Message.ToString(), "@LoginForm Inner Exception 2",
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);

                        opacityform.Hide();
                    }

                    Show_DefaultCursor_State();
                }
            }

            catch (Exception exception)
            {
                opacityform.Show();
                MessageBox.Show(exception.Message.ToString(), "@LoginForm Exception 2",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);

                opacityform.Hide();
            }
        }
Пример #19
0
        private void InsertButton_Click(object sender, EventArgs e)
        {
            //EXCEPTION 2
            try
            {
                opacityform        = new OpacityForm();
                darkeropacityform  = new DarkerOpacityForm();
                notificationwindow = new NotificationWindow();

                if (SchoolYearTextbox.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 (!SchoolYearTextbox.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
                {
                    //INNER EXCEPTION 2
                    try
                    {
                        string TempQuery = "SELECT COUNT(*) FROM [Tbl.SchoolYear] WHERE [SCHOOL YEAR] = '" +
                                           SchoolYearTextbox.Text.Trim().ToUpper() + "'";
                        sqldataadapter = new SqlDataAdapter(TempQuery, sqlconnection);
                        DataTable datatable0 = new DataTable();
                        sqldataadapter.Fill(datatable0);


                        if (datatable0.Rows[0][0].ToString() == "1")
                        {
                            notificationwindow.CaptionText    = "MESSAGE CONTENT";
                            notificationwindow.MsgImage.Image = Properties.Resources.warning;
                            notificationwindow.MessageText    = "THAT SCHOOL YEAR ALREADY EXIST !";

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

                        else if (datatable0.Rows[0][0].ToString() == "0")
                        {
                            string InsertQuery = "INSERT INTO [Tbl.SchoolYear]([ENTRY ID], [SCHOOL YEAR], [WAS SET]) VALUES(@EntryID, @schoolyear, @ws)";
                            sqlcommand = new SqlCommand(InsertQuery, sqlconnection);
                            sqlcommand.Parameters.AddWithValue("@EntryID", Prefix_ID + NewEntryID.ToString());
                            sqlcommand.Parameters.AddWithValue("@schoolyear", SchoolYearTextbox.Text.Trim().ToUpper());
                            sqlcommand.Parameters.AddWithValue("@ws", "0");
                            sqlcommand.ExecuteNonQuery();

                            RetrieveSchoolYearData();
                            SchoolYearTextbox.ResetText();
                            InsertButton.Select();
                            Init_NewEntryID();
                        }
                    }

                    catch (Exception exception)
                    {
                        opacityform.Show();
                        MessageBox.Show(exception.StackTrace.ToString(), "@Add School Year Form Inner Exception 2",
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                        opacityform.Hide();
                    }
                }
            }

            catch (Exception exception)
            {
                opacityform.Show();
                MessageBox.Show(exception.StackTrace.ToString(), "@Add School Year Form Exception 2",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                opacityform.Hide();
            }
        }
Пример #20
0
        private void ListofPermissionsGridview_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                DataGridViewRow  VirtualGridRow  = ListofPermissionsGridview.CurrentRow;
                DataGridViewCell VirtualGridCell = ListofPermissionsGridview.CurrentCell;

                try
                {
                    if (ListofPermissionsGridview.CurrentRow != null)
                    {
                        if (isNumber(VirtualGridCell.Value.ToString().Trim()) == true)
                        {
                            darkeropacityform  = new DarkerOpacityForm();
                            notificationwindow = new NotificationWindow();

                            notificationwindow.CaptionText    = "MESSAGE CONTENT";
                            notificationwindow.MsgImage.Image = Properties.Resources.error;
                            notificationwindow.MessageText    = "NUMERIC CHARACTERS ARE NOT ALLOWED !";

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

                            //RESTORE SECURITY STATE
                            AccountPermissionsForm_Load(sender, e);
                        }

                        else if (!VirtualGridCell.Value.ToString().Trim().ToUpper().Equals("ALLOW") &&
                                 !VirtualGridCell.Value.ToString().Trim().ToUpper().Equals("DENY"))
                        {
                            darkeropacityform  = new DarkerOpacityForm();
                            notificationwindow = new NotificationWindow();

                            notificationwindow.CaptionText    = "MESSAGE CONTENT";
                            notificationwindow.MsgImage.Image = Properties.Resources.warning;
                            notificationwindow.MessageText    = "YOU CAN ONLY ENTER THESE VALUES\n\n1. DENY\n2. ALLOW";

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

                            //RESTORE SECURITY STATE
                            AccountPermissionsForm_Load(sender, e);
                        }

                        else
                        {
                            string UpdateQuery = "UPDATE [Tbl.Permissions] SET [PERMISSION ID] = @pmsid, [USER ID] = @uid," +
                                                 "[TEACHER ID] = @tid, [PMS-01] = @pms01, [PMS-02] = @pms02, [PMS-03] = @pms03 WHERE [USER ID] = '" + VirtualGridRow.Cells["ColumnUserID"].Value.ToString() + "'";
                            sqlcommand = new SqlCommand(UpdateQuery, sqlconnection);
                            sqlcommand.Parameters.AddWithValue("@pmsid", VirtualGridRow.Cells["ColumnPermissionID"].Value == DBNull.Value ? "" : VirtualGridRow.Cells["ColumnPermissionID"].Value.ToString().ToUpper().Trim());
                            sqlcommand.Parameters.AddWithValue("@uid", VirtualGridRow.Cells["ColumnUserID"].Value == DBNull.Value ? "" : VirtualGridRow.Cells["ColumnUserID"].Value.ToString().ToUpper().Trim());
                            sqlcommand.Parameters.AddWithValue("@tid", VirtualGridRow.Cells["ColumnTeacherID"].Value == DBNull.Value ? "" : VirtualGridRow.Cells["ColumnTeacherID"].Value.ToString().ToUpper().Trim());

                            sqlcommand.Parameters.AddWithValue("@pms01", VirtualGridRow.Cells["ColumnPMS01"].Value == DBNull.Value ? "" : VirtualGridRow.Cells["ColumnPMS01"].Value.ToString().ToUpper().Trim());
                            sqlcommand.Parameters.AddWithValue("@pms02", VirtualGridRow.Cells["ColumnPMS03"].Value == DBNull.Value ? "" : VirtualGridRow.Cells["ColumnPMS02"].Value.ToString().ToUpper().Trim());
                            sqlcommand.Parameters.AddWithValue("@pms03", VirtualGridRow.Cells["ColumnPMS03"].Value == DBNull.Value ? "" : VirtualGridRow.Cells["ColumnPMS03"].Value.ToString().ToUpper().Trim());
                            sqlcommand.ExecuteNonQuery();

                            //SYNC NEW RECORDS
                            AccountPermissionsForm_Load(sender, e);

                            darkeropacityform  = new DarkerOpacityForm();
                            notificationwindow = new NotificationWindow();

                            notificationwindow.CaptionText    = "SUCCESSFULLY UPDATED";
                            notificationwindow.MsgImage.Image = Properties.Resources.check;
                            notificationwindow.MessageText    = "ONE ACCOUNT PERMISSION CHANGED !";

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

                catch (Exception)
                {
                    //DO NOTHING BITCH !
                }
            }

            catch (Exception)
            {
                //DO NOTHING BITCH !
            }
        }
Пример #21
0
        private void UpdateButton_Click(object sender, EventArgs e)
        {
            if (UpdateButton.Text == "UPDATE INFORMATION")
            {
                UpdateButton.Text     = "SAVE ALL";
                UpdateButton.Size     = new Size(95, 30);
                UpdateButton.Location = new Point(901, 445);
                ResetButton.Visible   = true;

                EnableControls();
                FirstNameTextbox.Focus();
            }

            else if (UpdateButton.Text == "SAVE ALL")
            {
                //EXCEPTION 2
                try
                {
                    opacityform        = new OpacityForm();
                    cryptography       = new Cryptography();
                    darkeropacityform  = new DarkerOpacityForm();
                    notificationwindow = new NotificationWindow();

                    if (FirstNameTextbox.Text.Trim().Length < 1 || MiddleNameTextbox.Text.Trim().Length < 1 || LastNameTextbox.Text.Trim().Length < 1 ||
                        BirthDateTextbox.Text.Trim().Length < 1 || GenderTextbox.Text.Length < 1 || BloodTypeTextbox.Text.Trim().Length < 1 ||
                        PresentAddressTextbox.Text.Trim().Length < 1 || ReligionTextbox.Text.Trim().Length < 1 || EmailAddressTextbox.Text.Trim().Length < 1 ||
                        MobileNumberTextbox.Text.Trim().Length < 1)
                    {
                        notificationwindow.CaptionText    = "MESSAGE CONTENT";
                        notificationwindow.MsgImage.Image = Properties.Resources.warning;
                        notificationwindow.MessageText    = "PLEASE PROVIDE THE REQUIRED\nINFORMATIONS BEING ASK !";

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

                    else if (!EmailAddressTextbox.Text.Trim().Contains("@") || !EmailAddressTextbox.Text.Trim().Contains(".com"))
                    {
                        notificationwindow.CaptionText    = "MESSAGE CONTENT";
                        notificationwindow.MsgImage.Image = Properties.Resources.warning;
                        notificationwindow.MessageText    = "PLEASE PROVIDE A VALID EMAIL ADDRESS !";

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

                    else if (MobileNumberTextbox.Text.Trim().Length < 11 || MobileNumberTextbox.Text.Trim().Length > 11)
                    {
                        notificationwindow.CaptionText    = "MESSAGE CONTENT";
                        notificationwindow.MsgImage.Image = Properties.Resources.warning;
                        notificationwindow.MessageText    = "PHONE NUMBER MUST BE 11-DIGITS LONG !";

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

                    else if (isNumber(MobileNumberTextbox.Text.Trim()) == false)
                    {
                        notificationwindow.CaptionText    = "MESSAGE CONTENT";
                        notificationwindow.MsgImage.Image = Properties.Resources.warning;
                        notificationwindow.MessageText    = "PHONE NUMBER CONTAIN AN INVALID\nCHARACTERS !";

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

                    else
                    {
                        //INNER EXCEPTION 2
                        try
                        {
                            string alterquery = "UPDATE [Tbl.Teachers] SET [FIRST NAME] = @fname, [MIDDLE NAME] = @mname, [LAST NAME] = @lname," +
                                                "GENDER = @gender, [BIRTH DATE] = @bdate, [PRESENT ADDRESS] = @paddress, RELIGION = @religion, [BLOOD TYPE] = @btype," +
                                                "[EMAIL ADDRESS] = @eaddress, [MOBILE NUMBER] = @mnumber WHERE [USER ID] = '" + UserID + "'";
                            sqlcommand = new SqlCommand(alterquery, sqlconnection);

                            sqlcommand.Parameters.AddWithValue("@fname", FirstNameTextbox.Text.Trim());
                            sqlcommand.Parameters.AddWithValue("@mname", MiddleNameTextbox.Text.Trim());
                            sqlcommand.Parameters.AddWithValue("@lname", LastNameTextbox.Text.Trim());
                            sqlcommand.Parameters.AddWithValue("@gender", GenderTextbox.Text.Trim());

                            sqlcommand.Parameters.AddWithValue("@bdate", BirthDateTextbox.Text.Trim());
                            sqlcommand.Parameters.AddWithValue("@paddress", PresentAddressTextbox.Text.Trim());
                            sqlcommand.Parameters.AddWithValue("@religion", ReligionTextbox.Text.Trim());

                            sqlcommand.Parameters.AddWithValue("@btype", BloodTypeTextbox.Text.Trim());
                            sqlcommand.Parameters.AddWithValue("@eaddress", EmailAddressTextbox.Text.Trim());
                            sqlcommand.Parameters.AddWithValue("@mnumber", MobileNumberTextbox.Text.Trim());
                            sqlcommand.ExecuteNonQuery();

                            notificationwindow.CaptionText    = "MESSAGE CONTENT";
                            notificationwindow.MsgImage.Image = Properties.Resources.check;
                            notificationwindow.MessageText    = "SUCCESSFULLY UPDATED !";

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

                            UpdateButton.Text     = "UPDATE INFORMATION";
                            UpdateButton.Size     = new Size(170, 30);
                            UpdateButton.Location = new Point(826, 445);

                            ResetButton.Visible = false;
                            DisableControls();
                        }

                        catch (Exception exception)
                        {
                            opacityform.Show();
                            MessageBox.Show(exception.Message.ToString(), "Account Information Form Inner Exception 2",
                                            MessageBoxButtons.OK, MessageBoxIcon.Error);

                            opacityform.Hide();
                        }
                    }
                }

                catch (Exception exception)
                {
                    opacityform.Show();
                    MessageBox.Show(exception.Message.ToString(), "Account Information Form Exception 2",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);

                    opacityform.Hide();
                }
            }
        }