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(); } }
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(); } } } }
static void Main() { try { //CREATE REGISTRY SETTINGS string pathname = "PTLE Solutions\\CLAYGO\\Current User Settings"; RegistryKey getregistrykey = Registry.CurrentUser.OpenSubKey(@pathname); Cryptography cryptography = new Cryptography(); //CREATE if (getregistrykey == null) { RegistryKey createregistrykey = Registry.CurrentUser.CreateSubKey(@pathname); createregistrykey.SetValue("User ID", ""); createregistrykey.SetValue("Teacher ID", ""); createregistrykey.SetValue("Student ID", ""); createregistrykey.SetValue("NofMaxSections", "0"); createregistrykey.SetValue("Show Feedback Form", "True"); createregistrykey.SetValue("Show Security Form", "True"); createregistrykey.SetValue("SQLServerConnectionString", ""); createregistrykey.SetValue("Security Code", cryptography.Encrypt("CLAYGO@PTLE")); } //CONCATE else if (getregistrykey != null) { RegistryKey updateregistrykey = Registry.CurrentUser.CreateSubKey(@pathname); string tempdata5 = getregistrykey.GetValue("Security Code").ToString(); string tempdata4 = getregistrykey.GetValue("Show Security Form").ToString(); string tempdata3 = getregistrykey.GetValue("NofMaxSections").ToString(); string tempdata2 = getregistrykey.GetValue("Show Feedback Form").ToString(); string tempdata = getregistrykey.GetValue("SQLServerConnectionString").ToString(); updateregistrykey.SetValue("User ID", ""); updateregistrykey.SetValue("Teacher ID", ""); updateregistrykey.SetValue("Student ID", ""); updateregistrykey.SetValue("Security Code", tempdata5); updateregistrykey.SetValue("Show Security Form", tempdata4); updateregistrykey.SetValue("NofMaxSections", tempdata3); updateregistrykey.SetValue("Show Feedback Form", tempdata2); updateregistrykey.SetValue("SQLServerConnectionString", tempdata); } RegistryKey GetRegistryValue = Registry.CurrentUser.OpenSubKey(@pathname); string VirtualString = GetRegistryValue.GetValue("Show Security Form").ToString(); //SUB if (VirtualString.Equals("True")) { System.Windows.Forms.Application.EnableVisualStyles(); System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false); System.Windows.Forms.Application.Run(new SecurityCodeForm()); } else if (VirtualString.Equals("False")) { System.Windows.Forms.Application.EnableVisualStyles(); System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false); System.Windows.Forms.Application.Run(new LoginForm()); } } catch (Exception exception) { MessageBox.Show(exception.Message + exception.StackTrace + "\nClosing ...", "Main entry point exception", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { System.Windows.Forms.Application.Exit(); } }
private void UpdateButton_Click(object sender, EventArgs e) { try { cryptography = new Cryptography(); darkeropacityform = new DarkerOpacityForm(); notificationwindow = new NotificationWindow(); if (NewSecurityCodeTextbox.Text.Trim().Length == 0) { notificationwindow.CaptionText = "MESSAGE CONTENT"; notificationwindow.MsgImage.Image = Properties.Resources.warning; notificationwindow.MessageText = "PLEASE PROVIDE NEW SECURITY CODE !"; darkeropacityform.Show(); notificationwindow.ShowDialog(); darkeropacityform.Hide(); } else if (ConfirmSecurityCodeTextbox.Text.Trim().Length == 0) { notificationwindow.CaptionText = "MESSAGE CONTENT"; notificationwindow.MsgImage.Image = Properties.Resources.warning; notificationwindow.MessageText = "PLEASE CONFIRM YOUR NEW\nSECURITY CODE !"; darkeropacityform.Show(); notificationwindow.ShowDialog(); darkeropacityform.Hide(); } else if (!ConfirmSecurityCodeTextbox.Text.Trim().Equals(NewSecurityCodeTextbox.Text.Trim()) || !NewSecurityCodeTextbox.Text.Trim().Equals(ConfirmSecurityCodeTextbox.Text.Trim())) { notificationwindow.CaptionText = "MESSAGE CONTENT"; notificationwindow.MsgImage.Image = Properties.Resources.warning; notificationwindow.MessageText = "SECURITY CODES DOES NOT MATCH !"; darkeropacityform.Show(); notificationwindow.ShowDialog(); darkeropacityform.Hide(); } else { RegistryKey updateregistrykey = Registry.CurrentUser.CreateSubKey(@variables.pathname); updateregistrykey.SetValue("Security Code", cryptography.Encrypt(ConfirmSecurityCodeTextbox.Text.Trim())); notificationwindow.CaptionText = "MESSAGE CONTENT"; notificationwindow.MsgImage.Image = Properties.Resources.check; notificationwindow.MessageText = "SUCCESSFULLY UPDATED !"; darkeropacityform.Show(); notificationwindow.ShowDialog(); darkeropacityform.Hide(); DialogResult = DialogResult.OK; } } catch (Exception) { //DO NOTHING BITCH ! } }
private void 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 StudentFullDetailsForm_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); ImageGridView.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 { //RETRIEVE ACCOUNT PICTURE Retrieve_Account_Picture(); //RETRIEVE PERSONAL INFORMATION Retrieve_Student_Personal_Info(); //RETRIEVE FAMILY BACKGROUND INFORMATION Retrieve_Family_Background_Info(); //RETRIEVE ACCOUNT INFORMATION Retrieve_Account_Info(); } catch (Exception exception) { opacityform.Show(); MessageBox.Show(exception.Message.ToString(), "@Student Details Form Inner Exception 1", MessageBoxButtons.OK, MessageBoxIcon.Error); opacityform.Hide(); } } catch (Exception exception) { opacityform.Show(); MessageBox.Show(exception.Message.ToString(), "@Student Details 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(); } }
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(); } }
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(); } }
//SAVE DATA private void bunifuFlatButton2_Click(object sender, EventArgs e) { try { //START WORKING STATE SaveButton.Cursor = Cursors.AppStarting; variables = new Variables(); cryptography = new Cryptography(); darkeropacityform = new DarkerOpacityForm(); notificationwindow = new NotificationWindow(); int _row = 0; Set_Refers(); foreach (DataRow row in datatable.Rows) { //VERIFY SECTION EXISTENSE string VerifyQuery1 = "SELECT COUNT(*) FROM [Tbl.Sections] WHERE [SECTION NAME] = '" + GridView.Rows[_row].Cells[11].Value.ToString().Trim().ToUpper() + "'"; sqldataadapter = new SqlDataAdapter(VerifyQuery1, sqlconnection); DataTable VirtualTable1 = new DataTable(); sqldataadapter.Fill(VirtualTable1); //VERIFY STUDENT REGISTRATION string VerifyQuery2 = "SELECT COUNT(*) FROM [Tbl.Students] WHERE [FIRST NAME] = '" + GridView.Rows[_row].Cells[3].Value.ToString().Trim() + "' AND [MIDDLE NAME] = '" + GridView.Rows[_row].Cells[4].Value.ToString().Trim() + "' AND [LAST NAME] = '" + GridView.Rows[_row].Cells[5].Value.ToString().Trim() + "'"; sqldataadapter = new SqlDataAdapter(VerifyQuery2, sqlconnection); DataTable VirtualTable2 = new DataTable(); sqldataadapter.Fill(VirtualTable2); if (GridView.Rows[_row].Cells[0].Value.ToString().Trim() == "" || GridView.Rows[_row].Cells[1].Value.ToString().Trim() == "" || GridView.Rows[_row].Cells[2].Value.ToString().Trim() == "" || GridView.Rows[_row].Cells[3].Value.ToString().Trim() == "" || GridView.Rows[_row].Cells[4].Value.ToString().Trim() == "" || GridView.Rows[_row].Cells[5].Value.ToString().Trim() == "" || GridView.Rows[_row].Cells[6].Value.ToString().Trim() == "" || GridView.Rows[_row].Cells[7].Value.ToString().Trim() == "" || GridView.Rows[_row].Cells[8].Value.ToString().Trim() == "" || GridView.Rows[_row].Cells[9].Value.ToString().Trim() == "" || GridView.Rows[_row].Cells[10].Value.ToString().Trim() == "" || GridView.Rows[_row].Cells[11].Value.ToString().Trim() == "" || GridView.Rows[_row].Cells[12].Value.ToString().Trim() == "" || GridView.Rows[_row].Cells[13].Value.ToString().Trim() == "" || GridView.Rows[_row].Cells[14].Value.ToString().Trim() == "") { notificationwindow.CaptionText = "MESSAGE CONTENT"; notificationwindow.MsgImage.Image = Properties.Resources.warning; notificationwindow.MessageText = "SOME CELL CONTAINS A NULL CHARACTER !"; darkeropacityform.Show(); notificationwindow.ShowDialog(); darkeropacityform.Hide(); Import_Student_Data_Begin = false; break; } else if (VirtualTable1.Rows[0][0].ToString() == "0") { notificationwindow.CaptionText = "MESSAGE CONTENT"; notificationwindow.MsgImage.Image = Properties.Resources.warning; notificationwindow.MessageText = "THERE IS UNKNOWN SECTION NAME !"; darkeropacityform.Show(); notificationwindow.ShowDialog(); darkeropacityform.Hide(); Import_Student_Data_Begin = false; break; } else if (int.Parse(VirtualTable2.Rows[0][0].ToString()) > 0) { notificationwindow.CaptionText = "MESSAGE CONTENT"; notificationwindow.MsgImage.Image = Properties.Resources.warning; notificationwindow.MessageText = "THERE ARE STUDENT ENTRY THAT IS\nALREADY REGISTERED !"; darkeropacityform.Show(); notificationwindow.ShowDialog(); darkeropacityform.Hide(); Import_Student_Data_Begin = false; break; } else if (!GridView.Rows[_row].Cells[6].Value.ToString().ToUpper().Trim().Equals("MALE") && !GridView.Rows[_row].Cells[6].Value.ToString().ToUpper().Trim().Equals("FEMALE")) { notificationwindow.CaptionText = "MESSAGE CONTENT"; notificationwindow.MsgImage.Image = Properties.Resources.warning; notificationwindow.MessageText = "THERE IS UNKNOWN GENDER TYPE !"; darkeropacityform.Show(); notificationwindow.ShowDialog(); darkeropacityform.Hide(); Import_Student_Data_Begin = false; break; } else if (GridView.Rows[_row].Cells[9].Value.ToString().Trim().Length < 11 || GridView.Rows[_row].Cells[9].Value.ToString().Trim().Length > 11) { notificationwindow.CaptionText = "MESSAGE CONTENT"; notificationwindow.MsgImage.Image = Properties.Resources.warning; notificationwindow.MessageText = "THERE IS INVALID MOBILE NUMBER !"; darkeropacityform.Show(); notificationwindow.ShowDialog(); darkeropacityform.Hide(); Import_Student_Data_Begin = false; break; } else if (isNumber(GridView.Rows[_row].Cells[9].Value.ToString().Trim()) == false) { notificationwindow.CaptionText = "MESSAGE CONTENT"; notificationwindow.MsgImage.Image = Properties.Resources.warning; notificationwindow.MessageText = "THERE IS MOBILE NUMBER THAT\nCONTAINS AN INVALID CHARACTER !"; darkeropacityform.Show(); notificationwindow.ShowDialog(); darkeropacityform.Hide(); Import_Student_Data_Begin = false; break; } else if (!GridView.Rows[_row].Cells[10].Value.ToString().Trim().Contains("@") || !GridView.Rows[_row].Cells[10].Value.ToString().Trim().Contains(".com")) { notificationwindow.CaptionText = "MESSAGE CONTENT"; notificationwindow.MsgImage.Image = Properties.Resources.warning; notificationwindow.MessageText = "THERE IS INVALID EMAIL ADDRESS !"; darkeropacityform.Show(); notificationwindow.ShowDialog(); darkeropacityform.Hide(); Import_Student_Data_Begin = false; break; } else if (!GridView.Rows[_row].Cells[11].Value.ToString().ToUpper().Trim().Equals(ReferSectionName)) { notificationwindow.CaptionText = "MESSAGE CONTENT"; notificationwindow.MsgImage.Image = Properties.Resources.error; notificationwindow.MessageText = "SYSTEM CANNOT IMPORT MULTIPLE\nDIFFERENT SECTIONS AT ONE TIME !"; darkeropacityform.Show(); notificationwindow.ShowDialog(); darkeropacityform.Hide(); Import_Student_Data_Begin = false; break; } else if (!GridView.Rows[_row].Cells[12].Value.ToString().ToUpper().Trim().Equals(ReferGradeLevelName)) { notificationwindow.CaptionText = "MESSAGE CONTENT"; notificationwindow.MsgImage.Image = Properties.Resources.error; notificationwindow.MessageText = "SYSTEM CANNOT IMPORT MULTIPLE\nDIFFERENT GRADE LEVEL AT ONE TIME !"; darkeropacityform.Show(); notificationwindow.ShowDialog(); darkeropacityform.Hide(); Import_Student_Data_Begin = false; break; } else if (!GridView.Rows[_row].Cells[12].Value.ToString().ToUpper().Trim().Equals("GRADE 7") && !GridView.Rows[_row].Cells[12].Value.ToString().ToUpper().Trim().Equals("GRADE 8") && !GridView.Rows[_row].Cells[12].Value.ToString().ToUpper().Trim().Equals("GRADE 9") && !GridView.Rows[_row].Cells[12].Value.ToString().ToUpper().Trim().Equals("GRADE 10")) { notificationwindow.CaptionText = "MESSAGE CONTENT"; notificationwindow.MsgImage.Image = Properties.Resources.warning; notificationwindow.MessageText = "THERE IS UNKNOWN GRADE LEVEL !"; darkeropacityform.Show(); notificationwindow.ShowDialog(); darkeropacityform.Hide(); Import_Student_Data_Begin = false; break; } else if (EntryCount > int.Parse(Maximum_Students)) { notificationwindow.CaptionText = "MESSAGE CONTENT"; notificationwindow.MsgImage.Image = Properties.Resources.error; notificationwindow.MessageText = "STUDENT DATA EXCEEDS THE\nSECTION'S REGISTRATION LIMIT !"; darkeropacityform.Show(); notificationwindow.ShowDialog(); darkeropacityform.Hide(); Import_Student_Data_Begin = false; break; } else { Import_Student_Data_Begin = true; } _row++; } //SHOW MESSAGE AFTER SUCCESSFULL IMPORT if (Import_Student_Data_Begin == true) { int row = 0; Set_Refers(); foreach (DataRow rows in datatable.Rows) { string query2, query3, query4, query5, query6, query7, query8, query9, query10; string FullName = GridView.Rows[row].Cells[5].Value.ToString().Trim() + ", " + GridView.Rows[row].Cells[3].Value.ToString().Trim() + " " + GridView.Rows[row].Cells[4].Value.ToString().Trim().Remove(1, GridView.Rows[row].Cells[4].Value.ToString().Trim().Length - 1) + "."; //INSERT INTO STUDENTS TABLE query2 = "INSERT INTO [Tbl.Students]([STUDENT ID], [USER ID], LRN, [FIRST NAME], [MIDDLE NAME], [LAST NAME], [GRADE LEVEL]," + "SECTION, GENDER, [BIRTH DATE], [PRESENT ADDRESS], [PLACE OF BIRTH], [BLOOD TYPE], RELIGION, [INDIGINOUS GROUP]," + "[EMAIL ADDRESS], [MOBILE NUMBER]) VALUES(@studentid, @userid, @lrn, @firstname, @middlename, @lastname, @gradelevel," + "@section, @gender, @birthdate, @presentaddress, @placeofbirth, @bloodtype, @religion, @indiginousgroup, @emailaddress," + "@mobilenumber)"; sqlcommand = new SqlCommand(query2, sqlconnection); sqlcommand.Parameters.AddWithValue("@studentid", GridView.Rows[row].Cells[0].Value.ToString().Trim()); sqlcommand.Parameters.AddWithValue("@userid", GridView.Rows[row].Cells[1].Value.ToString().Trim()); sqlcommand.Parameters.AddWithValue("@lrn", GridView.Rows[row].Cells[2].Value.ToString().Trim()); sqlcommand.Parameters.AddWithValue("@firstname", GridView.Rows[row].Cells[3].Value.ToString().Trim()); sqlcommand.Parameters.AddWithValue("@middlename", GridView.Rows[row].Cells[4].Value.ToString().Trim()); sqlcommand.Parameters.AddWithValue("@lastname", GridView.Rows[row].Cells[5].Value.ToString().Trim()); sqlcommand.Parameters.AddWithValue("@gradelevel", GridView.Rows[row].Cells[12].Value.ToString().Trim()); sqlcommand.Parameters.AddWithValue("@section", GridView.Rows[row].Cells[11].Value.ToString().Trim()); sqlcommand.Parameters.AddWithValue("@gender", GridView.Rows[row].Cells[6].Value.ToString().Trim()); sqlcommand.Parameters.AddWithValue("@birthdate", GridView.Rows[row].Cells[7].Value.ToString().Trim()); sqlcommand.Parameters.AddWithValue("@presentaddress", GridView.Rows[row].Cells[8].Value.ToString().Trim()); sqlcommand.Parameters.AddWithValue("@placeofbirth", ""); sqlcommand.Parameters.AddWithValue("@bloodtype", ""); sqlcommand.Parameters.AddWithValue("@religion", ""); sqlcommand.Parameters.AddWithValue("@indiginousgroup", ""); sqlcommand.Parameters.AddWithValue("@emailaddress", GridView.Rows[row].Cells[10].Value.ToString().Trim()); sqlcommand.Parameters.AddWithValue("@mobilenumber", GridView.Rows[row].Cells[9].Value.ToString().Trim()); sqlcommand.ExecuteNonQuery(); //INSERT INTO FAMILY BACKGROUND TABLE query3 = "INSERT INTO [Tbl.FamilyBackgrounds]([STUDENT ID], [FATHERS NAME], [FATHERS OCCUPATION], [FATHERS CONTACT NUMBER]," + "[FATHERS ADDRESS], [MOTHERS NAME], [MOTHERS OCCUPATION], [MOTHERS CONTACT NUMBER], [MOTHERS ADDRESS]) VALUES(@studentid," + "@fathersname, @fatheroccupation, @fathersnumber, @fathersaddress, @mothername, @motheroccupation, @mothernumber, @motheraddress)"; sqlcommand = new SqlCommand(query3, sqlconnection); sqlcommand.Parameters.AddWithValue("@studentid", GridView.Rows[row].Cells[0].Value.ToString().Trim()); sqlcommand.Parameters.AddWithValue("@fathersname", ""); sqlcommand.Parameters.AddWithValue("@fatheroccupation", ""); sqlcommand.Parameters.AddWithValue("@fathersnumber", ""); sqlcommand.Parameters.AddWithValue("@fathersaddress", ""); sqlcommand.Parameters.AddWithValue("@mothername", ""); sqlcommand.Parameters.AddWithValue("@motheroccupation", ""); sqlcommand.Parameters.AddWithValue("@mothernumber", ""); sqlcommand.Parameters.AddWithValue("@motheraddress", ""); sqlcommand.ExecuteNonQuery(); //INSERT INTO USERS TABLE query4 = "INSERT INTO [Tbl.Users]([USER ID], USERNAME, PASSWORD, [ACCOUNT STATUS], [ACCOUNT TYPE], [LAST LOGIN]," + "[IS PWD CHANGED], [SITUATION STATUS]) VALUES(@userid, @username, @password, @accountstatus, @account_type, @last_login, @ispwdchanged, @stat)"; sqlcommand = new SqlCommand(query4, sqlconnection); sqlcommand.Parameters.AddWithValue("@userid", GridView.Rows[row].Cells[1].Value.ToString().Trim()); sqlcommand.Parameters.AddWithValue("@username", cryptography.Encrypt(GridView.Rows[row].Cells[13].Value.ToString().Trim())); sqlcommand.Parameters.AddWithValue("@password", cryptography.Encrypt(GridView.Rows[row].Cells[14].Value.ToString().Trim())); sqlcommand.Parameters.AddWithValue("@accountstatus", "Active"); sqlcommand.Parameters.AddWithValue("@account_type", "Student"); sqlcommand.Parameters.AddWithValue("@last_login", "NO LOGIN HISTORY"); sqlcommand.Parameters.AddWithValue("@ispwdchanged", "False"); sqlcommand.Parameters.AddWithValue("@stat", "0"); sqlcommand.ExecuteNonQuery(); //UPDATE SECTIONS TABLE --> ENROLLED query5 = "UPDATE [Tbl.Sections] SET ENROLLED = @enrolled WHERE [SECTION NAME] = @section_nane" + " AND [SCHOOL YEAR] = '" + CurrentSchoolYear + "'"; sqlcommand = new SqlCommand(query5, sqlconnection); sqlcommand.Parameters.AddWithValue("@enrolled", (long.Parse(Enrolled_Students) + 1).ToString()); sqlcommand.Parameters.AddWithValue("@section_nane", GridView.Rows[row].Cells[11].Value.ToString().Trim()); sqlcommand.ExecuteNonQuery(); //INSERT INTO STUDENT LOAD TABLE --> 1st Grading query6 = "INSERT INTO [Tbl.FirstGradingStudentLoad]([STUDENT ID], [STUDENT NAME], GENDER, [GRADE LEVEL], SECTION," + "FILIPINO, ENGLISH, MATHEMATICS, SCIENCE, AP, TLE, MAPEH, ESP, [SCHOOL YEAR]) VALUES(@studentid1g, @studentname1g," + "@gender1g, @gradelevel1g, @section1g, @sb11g, @sb21g, @sb31g, @sb41g, @sb51g, @sb61g, @sb71g, @sb81g, @schoolyear1g)"; sqlcommand = new SqlCommand(query6, sqlconnection); sqlcommand.Parameters.AddWithValue("@studentid1g", GridView.Rows[row].Cells[0].Value.ToString().Trim()); sqlcommand.Parameters.AddWithValue("@studentname1g", FullName); sqlcommand.Parameters.AddWithValue("@gender1g", GridView.Rows[row].Cells[6].Value.ToString().Trim()); sqlcommand.Parameters.AddWithValue("@gradelevel1g", GridView.Rows[row].Cells[12].Value.ToString().Trim()); sqlcommand.Parameters.AddWithValue("@section1g", GridView.Rows[row].Cells[11].Value.ToString().Trim()); sqlcommand.Parameters.AddWithValue("@sb11g", ""); sqlcommand.Parameters.AddWithValue("@sb21g", ""); sqlcommand.Parameters.AddWithValue("@sb31g", ""); sqlcommand.Parameters.AddWithValue("@sb41g", ""); sqlcommand.Parameters.AddWithValue("@sb51g", ""); sqlcommand.Parameters.AddWithValue("@sb61g", ""); sqlcommand.Parameters.AddWithValue("@sb71g", ""); sqlcommand.Parameters.AddWithValue("@sb81g", ""); sqlcommand.Parameters.AddWithValue("@schoolyear1g", CurrentSchoolYear); sqlcommand.ExecuteNonQuery(); //INSERT INTO STUDENT LOAD TABLE --> 2nd Grading query7 = "INSERT INTO [Tbl.SecondGradingStudentLoad]([STUDENT ID], [STUDENT NAME], GENDER, [GRADE LEVEL], SECTION," + "FILIPINO, ENGLISH, MATHEMATICS, SCIENCE, AP, TLE, MAPEH, ESP, [SCHOOL YEAR]) VALUES(@studentid2g, @studentname2g," + "@gender2g, @gradelevel2g, @section2g, @sb12g, @sb22g, @sb32g, @sb42g, @sb52g, @sb62g, @sb72g, @sb82g, @schoolyear2g)"; sqlcommand = new SqlCommand(query7, sqlconnection); sqlcommand.Parameters.AddWithValue("@studentid2g", GridView.Rows[row].Cells[0].Value.ToString().Trim()); sqlcommand.Parameters.AddWithValue("@studentname2g", FullName); sqlcommand.Parameters.AddWithValue("@gender2g", GridView.Rows[row].Cells[6].Value.ToString().Trim()); sqlcommand.Parameters.AddWithValue("@gradelevel2g", GridView.Rows[row].Cells[12].Value.ToString().Trim()); sqlcommand.Parameters.AddWithValue("@section2g", GridView.Rows[row].Cells[11].Value.ToString().Trim()); sqlcommand.Parameters.AddWithValue("@sb12g", ""); sqlcommand.Parameters.AddWithValue("@sb22g", ""); sqlcommand.Parameters.AddWithValue("@sb32g", ""); sqlcommand.Parameters.AddWithValue("@sb42g", ""); sqlcommand.Parameters.AddWithValue("@sb52g", ""); sqlcommand.Parameters.AddWithValue("@sb62g", ""); sqlcommand.Parameters.AddWithValue("@sb72g", ""); sqlcommand.Parameters.AddWithValue("@sb82g", ""); sqlcommand.Parameters.AddWithValue("@schoolyear2g", CurrentSchoolYear); sqlcommand.ExecuteNonQuery(); //INSERT INTO STUDENT LOAD TABLE --> 3rd Grading query8 = "INSERT INTO [Tbl.ThirdGradingStudentLoad]([STUDENT ID], [STUDENT NAME], GENDER, [GRADE LEVEL], SECTION," + "FILIPINO, ENGLISH, MATHEMATICS, SCIENCE, AP, TLE, MAPEH, ESP, [SCHOOL YEAR]) VALUES(@studentid3g, @studentname3g," + "@gender3g, @gradelevel3g, @section3g, @sb13g, @sb23g, @sb33g, @sb43g, @sb53g, @sb63g, @sb73g, @sb83g, @schoolyear3g)"; sqlcommand = new SqlCommand(query8, sqlconnection); sqlcommand.Parameters.AddWithValue("@studentid3g", GridView.Rows[row].Cells[0].Value.ToString().Trim()); sqlcommand.Parameters.AddWithValue("@studentname3g", FullName); sqlcommand.Parameters.AddWithValue("@gender3g", GridView.Rows[row].Cells[6].Value.ToString().Trim()); sqlcommand.Parameters.AddWithValue("@gradelevel3g", GridView.Rows[row].Cells[12].Value.ToString().Trim()); sqlcommand.Parameters.AddWithValue("@section3g", GridView.Rows[row].Cells[11].Value.ToString().Trim()); sqlcommand.Parameters.AddWithValue("@sb13g", ""); sqlcommand.Parameters.AddWithValue("@sb23g", ""); sqlcommand.Parameters.AddWithValue("@sb33g", ""); sqlcommand.Parameters.AddWithValue("@sb43g", ""); sqlcommand.Parameters.AddWithValue("@sb53g", ""); sqlcommand.Parameters.AddWithValue("@sb63g", ""); sqlcommand.Parameters.AddWithValue("@sb73g", ""); sqlcommand.Parameters.AddWithValue("@sb83g", ""); sqlcommand.Parameters.AddWithValue("@schoolyear3g", CurrentSchoolYear); sqlcommand.ExecuteNonQuery(); //INSERT INTO STUDENT LOAD TABLE --> 4rth Grading query9 = "INSERT INTO [Tbl.FourthGradingStudentLoad]([STUDENT ID], [STUDENT NAME], GENDER, [GRADE LEVEL], SECTION," + "FILIPINO, ENGLISH, MATHEMATICS, SCIENCE, AP, TLE, MAPEH, ESP, [SCHOOL YEAR]) VALUES(@studentid4g, @studentname4g," + "@gender4g, @gradelevel4g, @section4g, @sb14g, @sb24g, @sb34g, @sb44g, @sb54g, @sb64g, @sb74g, @sb84g, @schoolyear4g)"; sqlcommand = new SqlCommand(query9, sqlconnection); sqlcommand.Parameters.AddWithValue("@studentid4g", GridView.Rows[row].Cells[0].Value.ToString().Trim()); sqlcommand.Parameters.AddWithValue("@studentname4g", FullName); sqlcommand.Parameters.AddWithValue("@gender4g", GridView.Rows[row].Cells[6].Value.ToString().Trim()); sqlcommand.Parameters.AddWithValue("@gradelevel4g", GridView.Rows[row].Cells[12].Value.ToString().Trim()); sqlcommand.Parameters.AddWithValue("@section4g", GridView.Rows[row].Cells[11].Value.ToString().Trim()); sqlcommand.Parameters.AddWithValue("@sb14g", ""); sqlcommand.Parameters.AddWithValue("@sb24g", ""); sqlcommand.Parameters.AddWithValue("@sb34g", ""); sqlcommand.Parameters.AddWithValue("@sb44g", ""); sqlcommand.Parameters.AddWithValue("@sb54g", ""); sqlcommand.Parameters.AddWithValue("@sb64g", ""); sqlcommand.Parameters.AddWithValue("@sb74g", ""); sqlcommand.Parameters.AddWithValue("@sb84g", ""); sqlcommand.Parameters.AddWithValue("@schoolyear4g", CurrentSchoolYear); sqlcommand.ExecuteNonQuery(); //INSERT INTO [Tbl.StudentAverages] query10 = "INSERT INTO [Tbl.StudentAverages]([STUDENT ID], [STUDENT NAME], LRN, [GRADE LEVEL], SECTION, " + "[FIRST GRADING], [SECOND GRADING], [THIRD GRADING], [FOURTH GRADING], GPA, [SCHOOL YEAR]) " + "VALUES(@sid, @studname, @lrn, @glevel, @section, @fga, @sga, @tga, @ffga, @gpa, @schoolyear)"; sqlcommand = new SqlCommand(query10, sqlconnection); sqlcommand.Parameters.AddWithValue("@sid", GridView.Rows[row].Cells[0].Value.ToString().Trim()); sqlcommand.Parameters.AddWithValue("@studname", FullName); sqlcommand.Parameters.AddWithValue("@lrn", GridView.Rows[row].Cells[2].Value.ToString().Trim()); sqlcommand.Parameters.AddWithValue("@glevel", GridView.Rows[row].Cells[12].Value.ToString().Trim()); sqlcommand.Parameters.AddWithValue("@section", GridView.Rows[row].Cells[11].Value.ToString().Trim()); sqlcommand.Parameters.AddWithValue("@fga", ""); sqlcommand.Parameters.AddWithValue("@sga", ""); sqlcommand.Parameters.AddWithValue("@tga", ""); sqlcommand.Parameters.AddWithValue("@ffga", ""); sqlcommand.Parameters.AddWithValue("@gpa", ""); sqlcommand.Parameters.AddWithValue("@schoolyear", CurrentSchoolYear); sqlcommand.ExecuteNonQuery(); isSuccessfull = true; row++; } } if (isSuccessfull == true) { notificationwindow.CaptionText = "REGISTRATION SUCCESS !"; notificationwindow.MsgImage.Image = Properties.Resources.check; notificationwindow.MessageText = "ALL DATA WAS SAVED SUCCESSFULLY !"; darkeropacityform.Show(); notificationwindow.ShowDialog(); darkeropacityform.Hide(); DialogResult = DialogResult.OK; } //STOP WORKING STATE SaveButton.Cursor = Cursors.Default; } catch (Exception) { //DON'T DO ANYTHING BITCH ! } }
private void UpdateButton_Click(object sender, EventArgs e) { if (UpdateButton.Text == "UPDATE INFORMATION") { UpdateButton.Text = "SAVE ALL"; UpdateButton.Size = new Size(95, 30); UpdateButton.Location = new Point(901, 445); ResetButton.Visible = true; EnableControls(); FirstNameTextbox.Focus(); } else if (UpdateButton.Text == "SAVE ALL") { //EXCEPTION 2 try { opacityform = new OpacityForm(); cryptography = new Cryptography(); darkeropacityform = new DarkerOpacityForm(); notificationwindow = new NotificationWindow(); if (FirstNameTextbox.Text.Trim().Length < 1 || MiddleNameTextbox.Text.Trim().Length < 1 || LastNameTextbox.Text.Trim().Length < 1 || BirthDateTextbox.Text.Trim().Length < 1 || GenderTextbox.Text.Length < 1 || BloodTypeTextbox.Text.Trim().Length < 1 || PresentAddressTextbox.Text.Trim().Length < 1 || ReligionTextbox.Text.Trim().Length < 1 || EmailAddressTextbox.Text.Trim().Length < 1 || MobileNumberTextbox.Text.Trim().Length < 1) { notificationwindow.CaptionText = "MESSAGE CONTENT"; notificationwindow.MsgImage.Image = Properties.Resources.warning; notificationwindow.MessageText = "PLEASE PROVIDE THE REQUIRED\nINFORMATIONS BEING ASK !"; darkeropacityform.Show(); notificationwindow.ShowDialog(); darkeropacityform.Hide(); } else if (!EmailAddressTextbox.Text.Trim().Contains("@") || !EmailAddressTextbox.Text.Trim().Contains(".com")) { notificationwindow.CaptionText = "MESSAGE CONTENT"; notificationwindow.MsgImage.Image = Properties.Resources.warning; notificationwindow.MessageText = "PLEASE PROVIDE A VALID EMAIL ADDRESS !"; darkeropacityform.Show(); notificationwindow.ShowDialog(); darkeropacityform.Hide(); } else if (MobileNumberTextbox.Text.Trim().Length < 11 || MobileNumberTextbox.Text.Trim().Length > 11) { notificationwindow.CaptionText = "MESSAGE CONTENT"; notificationwindow.MsgImage.Image = Properties.Resources.warning; notificationwindow.MessageText = "PHONE NUMBER MUST BE 11-DIGITS LONG !"; darkeropacityform.Show(); notificationwindow.ShowDialog(); darkeropacityform.Hide(); } else if (isNumber(MobileNumberTextbox.Text.Trim()) == false) { notificationwindow.CaptionText = "MESSAGE CONTENT"; notificationwindow.MsgImage.Image = Properties.Resources.warning; notificationwindow.MessageText = "PHONE NUMBER CONTAIN AN INVALID\nCHARACTERS !"; darkeropacityform.Show(); notificationwindow.ShowDialog(); darkeropacityform.Hide(); } else { //INNER EXCEPTION 2 try { string alterquery = "UPDATE [Tbl.Teachers] SET [FIRST NAME] = @fname, [MIDDLE NAME] = @mname, [LAST NAME] = @lname," + "GENDER = @gender, [BIRTH DATE] = @bdate, [PRESENT ADDRESS] = @paddress, RELIGION = @religion, [BLOOD TYPE] = @btype," + "[EMAIL ADDRESS] = @eaddress, [MOBILE NUMBER] = @mnumber WHERE [USER ID] = '" + UserID + "'"; sqlcommand = new SqlCommand(alterquery, sqlconnection); sqlcommand.Parameters.AddWithValue("@fname", FirstNameTextbox.Text.Trim()); sqlcommand.Parameters.AddWithValue("@mname", MiddleNameTextbox.Text.Trim()); sqlcommand.Parameters.AddWithValue("@lname", LastNameTextbox.Text.Trim()); sqlcommand.Parameters.AddWithValue("@gender", GenderTextbox.Text.Trim()); sqlcommand.Parameters.AddWithValue("@bdate", BirthDateTextbox.Text.Trim()); sqlcommand.Parameters.AddWithValue("@paddress", PresentAddressTextbox.Text.Trim()); sqlcommand.Parameters.AddWithValue("@religion", ReligionTextbox.Text.Trim()); sqlcommand.Parameters.AddWithValue("@btype", BloodTypeTextbox.Text.Trim()); sqlcommand.Parameters.AddWithValue("@eaddress", EmailAddressTextbox.Text.Trim()); sqlcommand.Parameters.AddWithValue("@mnumber", MobileNumberTextbox.Text.Trim()); sqlcommand.ExecuteNonQuery(); notificationwindow.CaptionText = "MESSAGE CONTENT"; notificationwindow.MsgImage.Image = Properties.Resources.check; notificationwindow.MessageText = "SUCCESSFULLY UPDATED !"; darkeropacityform.Show(); notificationwindow.ShowDialog(); darkeropacityform.Hide(); UpdateButton.Text = "UPDATE INFORMATION"; UpdateButton.Size = new Size(170, 30); UpdateButton.Location = new Point(826, 445); ResetButton.Visible = false; DisableControls(); } catch (Exception exception) { opacityform.Show(); MessageBox.Show(exception.Message.ToString(), "Account Information Form Inner Exception 2", MessageBoxButtons.OK, MessageBoxIcon.Error); opacityform.Hide(); } } } catch (Exception exception) { opacityform.Show(); MessageBox.Show(exception.Message.ToString(), "Account Information Form Exception 2", MessageBoxButtons.OK, MessageBoxIcon.Error); opacityform.Hide(); } } }
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(); } }