Example #1
0
        //SCHOOL YEAR ID
        public string GetSchoolYearPrefix()
        {
            variables           = new Variables();
            opacityform         = new OpacityForm();
            cryptography        = new Cryptography();
            sqlconnectionconfig = new SQLConnectionConfig();

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

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

            sqlconnection.Open();
            sqlquery0  = "SELECT PREFIX FROM [Tbl.Defaults] WHERE [ENTRY NAME] = '" + "SCHOOL YEAR ID" + "'";
            sqlcommand = new SqlCommand(sqlquery0, sqlconnection);
            SqlDataReader sqldatareader = sqlcommand.ExecuteReader();

            while (sqldatareader.Read())
            {
                schoolyearid_prefix = sqldatareader.GetString(0);
            }
            sqldatareader.Close();
            return(schoolyearid_prefix);
        }
Example #2
0
        private void ChangePasswordForm_Load(object sender, EventArgs e)
        {
            OldPasswordTextbox.ResetText();
            ConfirmPasswordTextbox.ResetText();
            NewPasswordTextbox.Focus();

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

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

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

                //INNER EXCEPTION 1
                try
                {
                    sqlquery1  = "SELECT PASSWORD FROM [Tbl.Users] WHERE [USER ID] = '" + currentuserid + "'";
                    sqlcommand = new SqlCommand(sqlquery1, sqlconnection);
                    SqlDataReader sqldatareader = sqlcommand.ExecuteReader();

                    while (sqldatareader.Read())
                    {
                        OldPasswordTextbox.Text = cryptography.Decrypt(sqldatareader.GetString(0));
                    }
                    sqldatareader.Close();
                }

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

                    opacityform.Hide();
                }
            }

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

                opacityform.Hide();
            }
        }
        private void ImportForm_Load(object sender, EventArgs e)
        {
            int BoundsWidth  = Screen.PrimaryScreen.Bounds.Width;
            int BoundsHeight = Screen.PrimaryScreen.Bounds.Height;
            int X_Coordinate = BoundsWidth - this.Width;
            int Y_Coordinate = BoundsHeight - this.Height;

            Location = new Point(X_Coordinate / 2, (Y_Coordinate / 2) + 26);

            SaveButton.Enabled = false; GenerateidButton.Enabled = false; GenerateupButton.Enabled = false;
            SaveButton.Cursor  = Cursors.No; GenerateidButton.Cursor = Cursors.No; GenerateupButton.Cursor = Cursors.No;

            //EXCEPTION 1
            try
            {
                variables    = new Variables();
                opacityform  = new OpacityForm();
                cryptography = new Cryptography();

                sqlconnectionconfig = new SQLConnectionConfig();
                RegistryKey registrykey = Registry.CurrentUser.OpenSubKey(@variables.pathname);
                string      tempdata    = registrykey.GetValue("SQLServerConnectionString").ToString();

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

                //INNER EXCEPTION 1
                try
                {
                    GetCurrentSchoolYear();
                    Populate_Section_Gridview();
                }

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

                    opacityform.Hide();
                }
            }

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

                opacityform.Hide();
            }
        }
        private void StudentAverageForm_RON_Load(object sender, EventArgs e)
        {
            //EXCEPTION 1
            try
            {
                variables           = new Variables();
                opacityform         = new OpacityForm();
                cryptography        = new Cryptography();
                sqlconnectionconfig = new SQLConnectionConfig();

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

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

                //INNER EXCEPTION 1
                try
                {
                    GetCurrentSchoolYear();
                    GetSchoolYearList();

                    Retrieve_Account_Picture();
                    Retrieve_StudentName_StudentID();
                    Retrive_StudentLRN_Section_GradeLevel();

                    Populate_DataGridView();
                }

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

                    opacityform.Hide();
                }
            }

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

                opacityform.Hide();
            }
        }
Example #5
0
        private void AccountPermissionsForm_Load(object sender, EventArgs e)
        {
            //EXCEPTION 1
            try
            {
                variables           = new Variables();
                opacityform         = new OpacityForm();
                cryptography        = new Cryptography();
                sqlconnectionconfig = new SQLConnectionConfig();

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

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

                //INNER EXCEPTION 1
                try
                {
                    //TODO:
                    string Query1 = "SELECT * FROM [Tbl.Permissions]";
                    sqldataadapter = new SqlDataAdapter(Query1, sqlconnection);
                    DataTable datatable = new DataTable();

                    sqldataadapter.Fill(datatable);
                    ListofPermissionsGridview.AutoGenerateColumns = false;
                    ListofPermissionsGridview.DataSource          = datatable;
                }

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

            catch (Exception exception)
            {
                opacityform.Show();
                MessageBox.Show(exception.ToString(), "@Account Permission Form Exception 1",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                opacityform.Hide();
            }
        }
        private void StudentSettingsForm_Load(object sender, EventArgs e)
        {
            try
            {
                variables    = new Variables();
                opacityform  = new OpacityForm();
                cryptography = new Cryptography();

                sqlconnectionconfig = new SQLConnectionConfig();
                RegistryKey registrykey = Registry.CurrentUser.OpenSubKey(@variables.pathname);
                string      tempdata    = registrykey.GetValue("SQLServerConnectionString").ToString();
                StudentID = registrykey.GetValue("Student ID").ToString();

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

                try
                {
                    GetCurrentSchoolYear();
                    Populate_Section_Gridview();

                    Get_Old_Student_Data(); Fill_New_SectionDropdown(); Determine_Student_GradeLevel_And_Set_For_Identifier();
                    ListofSections_GroupBox.Text = "LIST OF SECTIONS FOR THE SCHOOL YEAR: " + CurrentSchoolYear;
                    Enable_Disable_Update_Button();
                }

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

                    opacityform.Hide();
                }
            }

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

                opacityform.Hide();
            }
        }
Example #7
0
        private void AddSectionForm_Load(object sender, EventArgs e)
        {
            InsertButton.Select();

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

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

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

                //INNER EXCEPTION 1
                try
                {
                    Init_NewSectionID();
                    RetriveSectionData();
                    RetrieveSchoolYearList();
                }

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

            catch (Exception exception)
            {
                opacityform.Show();
                MessageBox.Show(exception.ToString(), "@Add Section Form Exception 1",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                opacityform.Hide();
            }
        }
Example #8
0
        private void ManageTeachersForm_Load(object sender, EventArgs e)
        {
            //EXCEPTION 1
            try
            {
                variables           = new Variables();
                opacityform         = new OpacityForm();
                cryptography        = new Cryptography();
                sqlconnectionconfig = new SQLConnectionConfig();

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

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

                //INNER EXCEPTION 1
                try
                {
                    Where_To_Check_CheckBoxes();
                }

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

                    opacityform.Hide();
                }
            }

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

                opacityform.Hide();
            }
        }
Example #9
0
        private void ListOfSystemObjectsForm_Load(object sender, EventArgs e)
        {
            int BoundsWidth  = Screen.PrimaryScreen.Bounds.Width;
            int BoundsHeight = Screen.PrimaryScreen.Bounds.Height;
            int X_Coordinate = BoundsWidth - this.Width;
            int Y_Coordinate = BoundsHeight - this.Height;

            Location = new Point(X_Coordinate / 2, (Y_Coordinate / 2) + 26);

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

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

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

                DisplayStudentsListInHumanReadableFormat();
                DisplayTeachersListInHumanReadableFormat();
                DisplayUsersListInHumanReadableFormat();
            }

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

                opacityform.Hide();
            }
        }
        public string GetCurrentSchoolYearData()
        {
            //EXCEPTION 1
            try
            {
                variables           = new Variables();
                opacityform         = new OpacityForm();
                cryptography        = new Cryptography();
                sqlconnectionconfig = new SQLConnectionConfig();

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

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

                sqlconnection.Open();
                sqlquery1  = "SELECT [CURRENT SCHOOL YEAR] FROM [Tbl.CurrentSchoolYear]";
                sqlcommand = new SqlCommand(sqlquery1, sqlconnection);
                SqlDataReader sqldatareader = sqlcommand.ExecuteReader();

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

            catch (Exception exception)
            {
                MessageBox.Show(exception.Message.ToString(), "@GetCurrentSchoolYear Exception 1",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(SchoolYear);
            }
        }
Example #11
0
        //PICTURE ID
        public string GetPictureIDPrefix()
        {
            try
            {
                variables           = new Variables();
                opacityform         = new OpacityForm();
                cryptography        = new Cryptography();
                sqlconnectionconfig = new SQLConnectionConfig();

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

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

                sqlconnection.Open();
                sqlquery2  = "SELECT PREFIX FROM [Tbl.Defaults] WHERE [ENTRY NAME] = '" + "PICTURE ID" + "'";
                sqlcommand = new SqlCommand(sqlquery2, sqlconnection);
                SqlDataReader sqldatareader = sqlcommand.ExecuteReader();

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

            catch (Exception exception)
            {
                MessageBox.Show(exception.Message.ToString(), "@GetSpecifiedPrefix Exception 2",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(pictureid_prefix);
            }
        }
Example #12
0
        private void AccountInformationForm_Load(object sender, EventArgs e)
        {
            int BoundsWidth  = Screen.PrimaryScreen.Bounds.Width;
            int BoundsHeight = Screen.PrimaryScreen.Bounds.Height;
            int X_Coordinate = BoundsWidth - this.Width;
            int Y_Coordinate = BoundsHeight - this.Height;

            Location = new Point(X_Coordinate / 2, (Y_Coordinate / 2));

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

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

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

                //INNER EXCEPTION 1
                try
                {
                    RetrievePersonalInformation();
                    RetrieveAccountInformation();
                    LoadAccountImage();
                    GetCurrentSchoolYear();

                    Init_1();
                    RetrieveHandledSubjects();

                    Init_2();
                    RetrieveAssignedSections();

                    LoadSectionsList();
                    Where_to_Check_Checkboxes();
                    Enable_DisAble_Update_Buttons();
                }

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

                    opacityform.Hide();
                }
            }

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

                opacityform.Hide();
            }
        }
Example #13
0
        private void SystemDefaultsForm_Load(object sender, EventArgs e)
        {
            SaveButton.Select();
            int BoundsWidth  = Screen.PrimaryScreen.Bounds.Width;
            int BoundsHeight = Screen.PrimaryScreen.Bounds.Height;
            int X_Coordinate = BoundsWidth - this.Width;
            int Y_Coordinate = BoundsHeight - this.Height;

            Location = new Point(X_Coordinate / 2, (Y_Coordinate / 2) + 10);

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

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

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

                //INNER EXCEPTION 1
                try
                {
                    //DON'T MIND THIS !
                    Where_To_Check_Radio_Buttons();

                    //DISPLAY CURRENT SCHOOL YEAR
                    Init_Current_SchoolYear();

                    //INITIALIZE SCHOOL YEAR DROPDOWN AND ID
                    Retrieve_School_Year_List_And_ID();

                    //CHECK VALIDITY OF SECTIONS
                    Enable_Or_Disable_2ndSaveButton();

                    //INITIALIZE SECTION ID DROPDOWN
                    Retrieve_SectionID_List();

                    //POPULATE DATAGRIDVIES
                    Load_Section_Records();
                    Load_School_Year_Records();
                }

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

            catch (Exception exception)
            {
                opacityform.Show();
                MessageBox.Show(exception.ToString(), "@Other Settings Form Exception 1",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                opacityform.Hide();
            }
        }
Example #14
0
        private void StudentEditDetailsForm_Load(object sender, EventArgs e)
        {
            int BoundsWidth  = Screen.PrimaryScreen.Bounds.Width;
            int BoundsHeight = Screen.PrimaryScreen.Bounds.Height;
            int X_Coordinate = BoundsWidth - this.Width;
            int Y_Coordinate = BoundsHeight - this.Height;

            Location = new Point(X_Coordinate / 2, (Y_Coordinate / 2) + 26);

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

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

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

                //INNER EXCEPTION 1
                try
                {
                    //LOAD ACCOUNT PICTURE
                    Load_Account_Picture();

                    //LOAD PERSONAL INFO AS PLACEHOLDER
                    Load_Personal_Info_AsPlaceholder();

                    //LOAD FAMILY BACKGROUND AS PLACEHOLDER
                    Load_Family_Background_AsPlaceholder();

                    //LOAD ACCOUNT INFORMATION
                    Load_Account_Information();
                }

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

                    opacityform.Hide();
                }
            }

            catch (Exception exception)
            {
                opacityform.Show();
                MessageBox.Show(exception.Message.ToString(), "@Student Edit Form Exception 1",
                                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();
            }
        }
Example #16
0
        private void AddStudentForm_Load(object sender, EventArgs e)
        {
            int BoundsWidth  = Screen.PrimaryScreen.Bounds.Width;
            int BoundsHeight = Screen.PrimaryScreen.Bounds.Height;
            int X_Coordinate = BoundsWidth - this.Width;
            int Y_Coordinate = BoundsHeight - this.Height;

            Location = new Point(X_Coordinate / 2, (Y_Coordinate / 2) + 25);

            SubmitButton.Select();
            BirthdayPicker.Value = DateTime.Now;

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

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

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

                DataTable datatable = new DataTable();
                sqlconnection.Open();

                //INNER EXCEPTION 1
                try
                {
                    //INIT STUDENT ID
                    AssignNewStudentID();

                    //INIT NEW USER ID
                    AssignNewUserID();

                    //GET CURRENT SCHOOL YEAR
                    GetCurrentSchoolYear();

                    //INIT SECTION DROPDOWN
                    RetrieveSectionList();
                }

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

            catch (Exception exception)
            {
                opacityform.Show();
                MessageBox.Show(exception.StackTrace.ToString(), "@Add Student Form Exception 1",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                opacityform.Hide();
            }
        }
Example #17
0
        public void VerifyLoginCredentials(LoginForm Controls)
        {
            Controls.LoginErrorMessage.Text    = "";
            Controls.LoginErrorMessage.Visible = false;

            if (Controls.UsernameTextbox.Text.Length == 0)
            {
                System.Threading.Thread.Sleep(100);
                Controls.LoginErrorMessage.Text     = "USERNAME REQUIRED !";
                Controls.LoginErrorMessage.Location = new Point(141, 134);
                Controls.LoginErrorMessage.Visible  = true;
                Controls.UsernameTextbox.Focus();
            }

            else if (Controls.PasswordTextbox.Text.Length == 0)
            {
                System.Threading.Thread.Sleep(100);
                Controls.LoginErrorMessage.Text     = "PASSWORD REQUIRED !";
                Controls.LoginErrorMessage.Location = new Point(141, 134);
                Controls.LoginErrorMessage.Visible  = true;
                Controls.PasswordTextbox.Focus();
            }

            else if (Controls.PasswordTextbox.Text.Length != 0 && Controls.PasswordTextbox.Text.Length != 0)
            {
                if (Controls.UsernameTextbox.Text.EndsWith(" ") || Controls.PasswordTextbox.Text.EndsWith(" "))
                {
                    System.Threading.Thread.Sleep(100);
                    Controls.LoginErrorMessage.Text     = "SORRY, THAT DIDN'T WORK !";
                    Controls.LoginErrorMessage.Location = new Point(126, 134);
                    Controls.LoginErrorMessage.Visible  = true;
                    IsVerified = false;
                }

                else
                {
                    variables    = new Variables();
                    opacityform  = new OpacityForm();
                    cryptography = new Cryptography();

                    sqlconfig     = new SQLConnectionConfig();
                    sqlmanualconn = new ServerManualConnectionForm();

                    DataTable      datatable = new DataTable();
                    SqlDataAdapter sqldataadapter;
                    SqlCommand     sqlcommand;

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

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

                        //CHECK ACCOUNT VALIDITY
                        sqlquery1 = "SELECT COUNT(*) FROM [Tbl.Users] WHERE USERNAME = '******' AND PASSWORD = '******' AND [ACCOUNT STATUS] = 'Active' AND [SITUATION STATUS] = '0'";

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

                        //ACCOUNT EXIST
                        if (datatable.Rows[0][0].ToString() == "1")
                        {
                            if (isAdministrator(Controls.UsernameTextbox.Text) == true)
                            {
                                //UPDATE USER LOGIN HISTORY
                                string LongDate, ShortTime;
                                LongDate  = DateTime.Now.ToLongDateString();
                                ShortTime = DateTime.Now.ToShortTimeString();

                                sqlquery2  = "UPDATE [Tbl.Users] SET [LAST LOGIN] = @lastlogin, [SITUATION STATUS] = @sitstat WHERE USERNAME = @username";
                                sqlcommand = new SqlCommand(sqlquery2, sqlconnection);

                                sqlcommand.Parameters.AddWithValue("@username", cryptography.Encrypt(Controls.UsernameTextbox.Text.Trim()));
                                sqlcommand.Parameters.AddWithValue("@lastlogin", LongDate + " - " + ShortTime);
                                sqlcommand.Parameters.AddWithValue("@sitstat", "1");
                                sqlcommand.ExecuteNonQuery();

                                //SET REGISTRY SETTINGS
                                string wildcardquery = "SELECT [USER ID] FROM [Tbl.Users] WHERE USERNAME = '******'";

                                sqlcommand = new SqlCommand(wildcardquery, sqlconnection);
                                SqlDataReader sqldatareader = sqlcommand.ExecuteReader();

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

                                //SET REGISTRY SETTINGS
                                string newwildcardquery = "SELECT [TEACHER ID] FROM [Tbl.Teachers] WHERE [USER ID] = '" +
                                                          Useridvirtualdata + "'";

                                sqlcommand = new SqlCommand(newwildcardquery, sqlconnection);
                                SqlDataReader sqldatareader2 = sqlcommand.ExecuteReader();

                                while (sqldatareader2.Read())
                                {
                                    TeacheridVirtualdata = sqldatareader2.GetString(0);
                                }
                                sqldatareader2.Close();

                                RegistryKey newregistrykey = Registry.CurrentUser.CreateSubKey(@variables.pathname);
                                newregistrykey.SetValue("User ID", Useridvirtualdata);
                                newregistrykey.SetValue("Teacher ID", TeacheridVirtualdata);

                                IsVerified = true;
                                IsAdmin    = true;
                                sqlconnection.Close();
                            }

                            else if (isTeacher(Controls.UsernameTextbox.Text) == true)
                            {
                                //UPDATE USER LOGIN HISTORY
                                string LongDate, ShortTime;
                                LongDate  = DateTime.Now.ToLongDateString();
                                ShortTime = DateTime.Now.ToShortTimeString();

                                sqlquery2  = "UPDATE [Tbl.Users] SET [LAST LOGIN] = @lastlogin, [SITUATION STATUS] = @sitstat WHERE USERNAME = @username";
                                sqlcommand = new SqlCommand(sqlquery2, sqlconnection);

                                sqlcommand.Parameters.AddWithValue("@username", cryptography.Encrypt(Controls.UsernameTextbox.Text.Trim()));
                                sqlcommand.Parameters.AddWithValue("@lastlogin", LongDate + " - " + ShortTime);
                                sqlcommand.Parameters.AddWithValue("@sitstat", "1");
                                sqlcommand.ExecuteNonQuery();

                                //SET REGISTRY SETTINGS
                                string wildcardquery = "SELECT [USER ID] FROM [Tbl.Users] WHERE USERNAME = '******'";

                                sqlcommand = new SqlCommand(wildcardquery, sqlconnection);
                                SqlDataReader sqldatareader = sqlcommand.ExecuteReader();

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

                                //SET REGISTRY SETTINGS
                                string newwildcardquery = "SELECT [TEACHER ID] FROM [Tbl.Teachers] WHERE [USER ID] = '" +
                                                          Useridvirtualdata + "'";

                                sqlcommand = new SqlCommand(newwildcardquery, sqlconnection);
                                SqlDataReader sqldatareader2 = sqlcommand.ExecuteReader();

                                while (sqldatareader2.Read())
                                {
                                    TeacheridVirtualdata = sqldatareader2.GetString(0);
                                }
                                sqldatareader2.Close();

                                RegistryKey newregistrykey = Registry.CurrentUser.CreateSubKey(@variables.pathname);
                                newregistrykey.SetValue("User ID", Useridvirtualdata);
                                newregistrykey.SetValue("Teacher ID", TeacheridVirtualdata);

                                IsVerified = true;
                                IsTeacher  = true;
                                sqlconnection.Close();
                            }

                            else if (isStudent(Controls.UsernameTextbox.Text) == true)
                            {
                                //UPDATE USER LOGIN HISTORY
                                string LongDate, ShortTime;
                                LongDate  = DateTime.Now.ToLongDateString();
                                ShortTime = DateTime.Now.ToShortTimeString();

                                sqlquery2  = "UPDATE [Tbl.Users] SET [LAST LOGIN] = @lastlogin, [SITUATION STATUS] = @sitstat WHERE USERNAME = @username";
                                sqlcommand = new SqlCommand(sqlquery2, sqlconnection);

                                sqlcommand.Parameters.AddWithValue("@username", cryptography.Encrypt(Controls.UsernameTextbox.Text.Trim()));
                                sqlcommand.Parameters.AddWithValue("@lastlogin", LongDate + " - " + ShortTime);
                                sqlcommand.Parameters.AddWithValue("@sitstat", "1");
                                sqlcommand.ExecuteNonQuery();

                                //SET REGISTRY SETTINGS
                                string wildcardquery = "SELECT [USER ID] FROM [Tbl.Users] WHERE USERNAME = '******'";

                                sqlcommand = new SqlCommand(wildcardquery, sqlconnection);
                                SqlDataReader sqldatareader = sqlcommand.ExecuteReader();

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

                                //SET REGISTRY SETTINGS
                                string newwildcardquery = "SELECT [STUDENT ID] FROM [Tbl.Students] WHERE [USER ID] = '" +
                                                          Useridvirtualdata + "'";

                                sqlcommand = new SqlCommand(newwildcardquery, sqlconnection);
                                SqlDataReader sqldatareader2 = sqlcommand.ExecuteReader();

                                while (sqldatareader2.Read())
                                {
                                    StudentidVirtualdata = sqldatareader2.GetString(0);
                                }
                                sqldatareader2.Close();

                                RegistryKey newregistrykey = Registry.CurrentUser.CreateSubKey(@variables.pathname);
                                newregistrykey.SetValue("User ID", Useridvirtualdata);
                                newregistrykey.SetValue("Student ID", StudentidVirtualdata);

                                IsVerified = true;
                                IsStudent  = true;
                                sqlconnection.Close();
                            }
                        }

                        //ACCOUNT NOT FOUND
                        else if (datatable.Rows[0][0].ToString() == "0")
                        {
                            IsVerified = false;
                            sqlconnection.Close();

                            Controls.LoginErrorMessage.Text     = "SORRY, THAT DIDN'T WORK !";
                            Controls.LoginErrorMessage.Location = new Point(126, 134);
                            Controls.LoginErrorMessage.Visible  = true;
                        }
                    }

                    catch (Exception exception)
                    {
                        opacityform = new OpacityForm();
                        opacityform.Show();

                        MessageBox.Show(exception.Message.ToString(), "@Authentication Exception 1",
                                        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();
            }
        }
        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();
            }
        }