Esempio n. 1
0
        private void DisableTeacherForm_Load(object sender, EventArgs e)
        {
            UserIDTextbox.Focus();
            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);
            bunifuCards1.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();

                DisplayUsersListInHumanReadableFormat();
            }

            catch (Exception exception)
            {
                opacityform.Show();
                MessageBox.Show(exception.Message.ToString(), "Disable Teacher Form 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);
            }
        }
Esempio n. 3
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);
            }
        }
Esempio n. 4
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();
            }
        }
Esempio n. 5
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();
            }
        }
Esempio n. 6
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 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();
            }
        }
        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();
            }
        }
Esempio n. 9
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();
            }
        }
Esempio n. 10
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();
            }
        }