private void ChangePasswordForm_Load(object sender, EventArgs e) { OldPasswordTextbox.ResetText(); ConfirmPasswordTextbox.ResetText(); NewPasswordTextbox.Focus(); //EXCEPTION 1 try { variables = new Variables(); opacityform = new OpacityForm(); cryptography = new Cryptography(); sqlconnectionconfig = new SQLConnectionConfig(); RegistryKey registrykey = Registry.CurrentUser.OpenSubKey(@variables.pathname); string tempdata = registrykey.GetValue("SQLServerConnectionString").ToString(); currentuserid = registrykey.GetValue("User ID").ToString(); //USER SQLSERVER CONNECTION SETTINGS sqlconnectionconfig.SqlConnectionString = cryptography.Decrypt(tempdata); sqlconnection = new SqlConnection(sqlconnectionconfig.SqlConnectionString); sqlconnection.Open(); //INNER EXCEPTION 1 try { sqlquery1 = "SELECT PASSWORD FROM [Tbl.Users] WHERE [USER ID] = '" + currentuserid + "'"; sqlcommand = new SqlCommand(sqlquery1, sqlconnection); SqlDataReader sqldatareader = sqlcommand.ExecuteReader(); while (sqldatareader.Read()) { OldPasswordTextbox.Text = cryptography.Decrypt(sqldatareader.GetString(0)); } sqldatareader.Close(); } catch (Exception exception) { opacityform.Show(); MessageBox.Show(exception.Message.ToString(), "@Change Password Form Inner Exception 1", MessageBoxButtons.OK, MessageBoxIcon.Error); opacityform.Hide(); } } catch (Exception exception) { opacityform.Show(); MessageBox.Show(exception.Message.ToString(), "@Change Password Form Exception 1", MessageBoxButtons.OK, MessageBoxIcon.Error); opacityform.Hide(); } }
private void ImportForm_Load(object sender, EventArgs e) { int BoundsWidth = Screen.PrimaryScreen.Bounds.Width; int BoundsHeight = Screen.PrimaryScreen.Bounds.Height; int X_Coordinate = BoundsWidth - this.Width; int Y_Coordinate = BoundsHeight - this.Height; Location = new Point(X_Coordinate / 2, (Y_Coordinate / 2) + 26); SaveButton.Enabled = false; GenerateidButton.Enabled = false; GenerateupButton.Enabled = false; SaveButton.Cursor = Cursors.No; GenerateidButton.Cursor = Cursors.No; GenerateupButton.Cursor = Cursors.No; //EXCEPTION 1 try { variables = new Variables(); opacityform = new OpacityForm(); cryptography = new Cryptography(); sqlconnectionconfig = new SQLConnectionConfig(); RegistryKey registrykey = Registry.CurrentUser.OpenSubKey(@variables.pathname); string tempdata = registrykey.GetValue("SQLServerConnectionString").ToString(); //USER SQLSERVER CONNECTION SETTINGS sqlconnectionconfig.SqlConnectionString = cryptography.Decrypt(tempdata); sqlconnection = new SqlConnection(sqlconnectionconfig.SqlConnectionString); sqlconnection.Open(); //INNER EXCEPTION 1 try { GetCurrentSchoolYear(); Populate_Section_Gridview(); } catch (Exception exception) { opacityform.Show(); MessageBox.Show(exception.Message.ToString(), "@Import Form Inner Exception 1", MessageBoxButtons.OK, MessageBoxIcon.Error); opacityform.Hide(); } } catch (Exception exception) { opacityform.Show(); MessageBox.Show(exception.Message.ToString(), "@Import Form Exception 1", MessageBoxButtons.OK, MessageBoxIcon.Error); opacityform.Hide(); } }
private void StudentAverageForm_RON_Load(object sender, EventArgs e) { //EXCEPTION 1 try { variables = new Variables(); opacityform = new OpacityForm(); cryptography = new Cryptography(); sqlconnectionconfig = new SQLConnectionConfig(); RegistryKey registrykey = Registry.CurrentUser.OpenSubKey(@variables.pathname); string tempdata = registrykey.GetValue("SQLServerConnectionString").ToString(); //USER SQLSERVER CONNECTION SETTINGS sqlconnectionconfig.SqlConnectionString = cryptography.Decrypt(tempdata); sqlconnection = new SqlConnection(sqlconnectionconfig.SqlConnectionString); sqlconnection.Open(); //INNER EXCEPTION 1 try { GetCurrentSchoolYear(); GetSchoolYearList(); Retrieve_Account_Picture(); Retrieve_StudentName_StudentID(); Retrive_StudentLRN_Section_GradeLevel(); Populate_DataGridView(); } catch (Exception exception) { opacityform.Show(); MessageBox.Show(exception.Message.ToString(), "@Student Average Form Inner Exception 1", MessageBoxButtons.OK, MessageBoxIcon.Error); opacityform.Hide(); } } catch (Exception exception) { opacityform.Show(); MessageBox.Show(exception.Message.ToString(), "@Student Average Form Exception 1", MessageBoxButtons.OK, MessageBoxIcon.Error); opacityform.Hide(); } }
private void AccountPermissionsForm_Load(object sender, EventArgs e) { //EXCEPTION 1 try { variables = new Variables(); opacityform = new OpacityForm(); cryptography = new Cryptography(); sqlconnectionconfig = new SQLConnectionConfig(); RegistryKey registrykey = Registry.CurrentUser.OpenSubKey(@variables.pathname); string tempdata = registrykey.GetValue("SQLServerConnectionString").ToString(); //USER SQLSERVER CONNECTION SETTINGS sqlconnectionconfig.SqlConnectionString = cryptography.Decrypt(tempdata); sqlconnection = new SqlConnection(sqlconnectionconfig.SqlConnectionString); sqlconnection.Open(); //INNER EXCEPTION 1 try { //TODO: string Query1 = "SELECT * FROM [Tbl.Permissions]"; sqldataadapter = new SqlDataAdapter(Query1, sqlconnection); DataTable datatable = new DataTable(); sqldataadapter.Fill(datatable); ListofPermissionsGridview.AutoGenerateColumns = false; ListofPermissionsGridview.DataSource = datatable; } catch (Exception exception) { opacityform.Show(); MessageBox.Show(exception.ToString(), "@Account Permission Form Inner Exception 1", MessageBoxButtons.OK, MessageBoxIcon.Error); opacityform.Hide(); } } catch (Exception exception) { opacityform.Show(); MessageBox.Show(exception.ToString(), "@Account Permission Form Exception 1", MessageBoxButtons.OK, MessageBoxIcon.Error); opacityform.Hide(); } }
//DELETE SECTIONS private void DeleteFlatButton1_Click(object sender, EventArgs e) { variables = new Variables(); opacityform = new OpacityForm(); //DELETE SECTION EXCEPTION try { darkeropacityform = new DarkerOpacityForm(); notificationwindow = new NotificationWindow(); string TempQuery = "SELECT COUNT(*) FROM [Tbl.Sections]" + " WHERE [SECTION ID] = '" + SectionIDDropdown.selectedValue.ToString() + "' AND [ENROLLED] = '0'"; sqldataadapter = new SqlDataAdapter(TempQuery, sqlconnection); DataTable datatable = new DataTable(); sqldataadapter.Fill(datatable); if (datatable.Rows[0][0].ToString() == "1") { RegistryKey registrykey = Registry.CurrentUser.OpenSubKey(@variables.pathname); string CurrentSectionCount = registrykey.GetValue("NofMaxSections").ToString(); string DeleteQuery = "DELETE FROM [Tbl.Sections] WHERE [SECTION ID] = '" + SectionIDDropdown.selectedValue.ToString() + "'"; sqlcommand = new SqlCommand(DeleteQuery, sqlconnection); sqlcommand.ExecuteNonQuery(); //UPDATE SECTION COUNT RegistryKey updateregistrykey = Registry.CurrentUser.CreateSubKey(@variables.pathname); updateregistrykey.SetValue("NofMaxSections", (int.Parse(CurrentSectionCount) - 1).ToString()); //REFRESH SECTIONS GRIDVIEW Load_Section_Records(); //REMOVE DELETED ID SectionIDDropdown.Clear(); //RETRIEVE NEW VALUES Retrieve_SectionID_List(); } else if (datatable.Rows[0][0].ToString() == "0") { notificationwindow.CaptionText = "MESSAGE CONTENT"; notificationwindow.MsgImage.Image = Properties.Resources.error; notificationwindow.MessageText = "THIS SECTION CAN'T BE DELETED,\nSOME STUDENTS ARE ENROLLED HERE !"; darkeropacityform.Show(); notificationwindow.ShowDialog(); darkeropacityform.Hide(); } } catch (Exception exception) { opacityform.Show(); MessageBox.Show(exception.ToString(), "@Delete Section Exception", MessageBoxButtons.OK, MessageBoxIcon.Error); opacityform.Hide(); } }
private void StudentSettingsForm_Load(object sender, EventArgs e) { try { variables = new Variables(); opacityform = new OpacityForm(); cryptography = new Cryptography(); sqlconnectionconfig = new SQLConnectionConfig(); RegistryKey registrykey = Registry.CurrentUser.OpenSubKey(@variables.pathname); string tempdata = registrykey.GetValue("SQLServerConnectionString").ToString(); StudentID = registrykey.GetValue("Student ID").ToString(); //USER SQLSERVER CONNECTION SETTINGS sqlconnectionconfig.SqlConnectionString = cryptography.Decrypt(tempdata); sqlconnection = new SqlConnection(sqlconnectionconfig.SqlConnectionString); sqlconnection.Open(); try { GetCurrentSchoolYear(); Populate_Section_Gridview(); Get_Old_Student_Data(); Fill_New_SectionDropdown(); Determine_Student_GradeLevel_And_Set_For_Identifier(); ListofSections_GroupBox.Text = "LIST OF SECTIONS FOR THE SCHOOL YEAR: " + CurrentSchoolYear; Enable_Disable_Update_Button(); } catch (Exception exception) { opacityform.Show(); MessageBox.Show(exception.Message.ToString(), "@Student Settings Form Inner Exception 1", MessageBoxButtons.OK, MessageBoxIcon.Error); opacityform.Hide(); } } catch (Exception exception) { opacityform.Show(); MessageBox.Show(exception.Message.ToString(), "@Student Settings Form Exception 1", MessageBoxButtons.OK, MessageBoxIcon.Error); opacityform.Hide(); } }
private void AddSectionForm_Load(object sender, EventArgs e) { InsertButton.Select(); //EXCEPTION 1 try { variables = new Variables(); opacityform = new OpacityForm(); cryptography = new Cryptography(); sqlconnectionconfig = new SQLConnectionConfig(); RegistryKey registrykey = Registry.CurrentUser.OpenSubKey(@variables.pathname); string tempdata = registrykey.GetValue("SQLServerConnectionString").ToString(); //USER SQLSERVER CONNECTION SETTINGS sqlconnectionconfig.SqlConnectionString = cryptography.Decrypt(tempdata); sqlconnection = new SqlConnection(sqlconnectionconfig.SqlConnectionString); sqlconnection.Open(); //INNER EXCEPTION 1 try { Init_NewSectionID(); RetriveSectionData(); RetrieveSchoolYearList(); } catch (Exception exception) { opacityform.Show(); MessageBox.Show(exception.ToString(), "@Add Section Form Inner Exception 1", MessageBoxButtons.OK, MessageBoxIcon.Error); opacityform.Hide(); } } catch (Exception exception) { opacityform.Show(); MessageBox.Show(exception.ToString(), "@Add Section Form Exception 1", MessageBoxButtons.OK, MessageBoxIcon.Error); opacityform.Hide(); } }
//DELETE SCHOOL YEAR private void DeleteFlatButton2_Click(object sender, EventArgs e) { opacityform = new OpacityForm(); //DELETE SCHOOL YEAR EXCEPTION try { darkeropacityform = new DarkerOpacityForm(); notificationwindow = new NotificationWindow(); string TempString = "SELECT COUNT(*) FROM [Tbl.SchoolYear] WHERE [ENTRY ID] = '" + SchoolYearIDDropdown.selectedValue.ToString() + "' AND [WAS SET] = '0'"; sqldataadapter = new SqlDataAdapter(TempString, sqlconnection); DataTable datatable = new DataTable(); sqldataadapter.Fill(datatable); if (datatable.Rows[0][0].ToString() == "1") { string DeleteQuery = "DELETE FROM [Tbl.SchoolYear] WHERE [ENTRY ID] = '" + SchoolYearIDDropdown.selectedValue.ToString() + "'"; sqlcommand = new SqlCommand(DeleteQuery, sqlconnection); sqlcommand.ExecuteNonQuery(); //REFRESH SCHOOL YEAR GRIDVIEW Load_School_Year_Records(); //REMOVE DELETED VALUES CurrentSchoolYearDropdown.Clear(); SectionIDDropdown.Clear(); SchoolYearDropdown.Clear(); SchoolYearIDDropdown.Clear(); //RETRIEVE NEW VALUES Retrieve_School_Year_List_And_ID(); Retrieve_SectionID_List(); } else if (datatable.Rows[0][0].ToString() == "0") { notificationwindow.CaptionText = "MESSAGE CONTENT"; notificationwindow.MsgImage.Image = Properties.Resources.error; notificationwindow.MessageText = "THIS SCHOOL YEAR CAN'T BE DELETED,\nSOME STUDENTS ARE ENROLLED HERE !"; darkeropacityform.Show(); notificationwindow.ShowDialog(); darkeropacityform.Hide(); } } catch (Exception exception) { opacityform.Show(); MessageBox.Show(exception.ToString(), "@Delete School Year Exception", MessageBoxButtons.OK, MessageBoxIcon.Error); opacityform.Hide(); } }
private void ManageTeachersForm_Load(object sender, EventArgs e) { //EXCEPTION 1 try { variables = new Variables(); opacityform = new OpacityForm(); cryptography = new Cryptography(); sqlconnectionconfig = new SQLConnectionConfig(); RegistryKey registrykey = Registry.CurrentUser.OpenSubKey(@variables.pathname); string tempdata = registrykey.GetValue("SQLServerConnectionString").ToString(); //USER SQLSERVER CONNECTION SETTINGS sqlconnectionconfig.SqlConnectionString = cryptography.Decrypt(tempdata); sqlconnection = new SqlConnection(sqlconnectionconfig.SqlConnectionString); sqlconnection.Open(); //INNER EXCEPTION 1 try { Where_To_Check_CheckBoxes(); } catch (Exception exception) { opacityform.Show(); MessageBox.Show(exception.Message.ToString(), "@Manage Teacher Form Inner Exception 1", MessageBoxButtons.OK, MessageBoxIcon.Error); opacityform.Hide(); } } catch (Exception exception) { opacityform.Show(); MessageBox.Show(exception.Message.ToString(), "@Manage Teacher Form Exception 1", MessageBoxButtons.OK, MessageBoxIcon.Error); opacityform.Hide(); } }
private void SqlServerSettingsButton_Click(object sender, EventArgs e) { opacityform = new OpacityForm(); servermanualconnection = new ServerManualConnectionForm(); opacityform.Show(); servermanualconnection.ShowDialog(); opacityform.Hide(); }
private void BukSULinkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { //EXCEPTION 1 try { opacityform = new OpacityForm(); System.Diagnostics.Process.Start("http://buksu.edu.ph/"); } catch (Exception exception) { opacityform.Show(); MessageBox.Show(exception.Message.ToString(), "@About University Form Exception 1", MessageBoxButtons.OK, MessageBoxIcon.Error); opacityform.Hide(); } }
private void ChangePasswordRequiredForm_FormClosing(object sender, FormClosingEventArgs e) { opacityform = new OpacityForm(); opacityform.Show(); if (isClosed == false) { MessageBox.Show("CLOSING THIS FORM IS NOT ALLOWED !", "NOT ALLOWED !", MessageBoxButtons.OK, MessageBoxIcon.Stop); opacityform.Hide(); e.Cancel = true; } else if (isClosed == true) { opacityform.Hide(); e.Cancel = false; } }
//0 private void DisableAllRadioButton_CheckedChanged(object sender, EventArgs e) { opacityform = new OpacityForm(); //EXCEPTION 9 try { string UpdateQuery4 = "UPDATE [Tbl.SystemSettings] SET VALUE = '0' WHERE [SETTINGS ID] = 'SEG100'"; sqlcommand = new SqlCommand(UpdateQuery4, sqlconnection); sqlcommand.ExecuteNonQuery(); } catch (Exception exception) { opacityform.Show(); MessageBox.Show(exception.ToString(), "@Other Settings Form Exception 9", MessageBoxButtons.OK, MessageBoxIcon.Error); opacityform.Hide(); } }
private void NoRadioButton_CheckedChanged(object sender, EventArgs e) { //EXCEPTION 2 try { variables = new Variables(); opacityform = new OpacityForm(); RegistryKey updateregistrykey = Registry.CurrentUser.CreateSubKey(@variables.pathname); updateregistrykey.SetValue("Show Feedback Form", "True"); } catch (Exception exception) { opacityform.Show(); MessageBox.Show(exception.Message.ToString(), "@Feedback Form Exception 2", MessageBoxButtons.OK, MessageBoxIcon.Error); opacityform.Hide(); } }
private void ListOfSystemObjectsForm_Load(object sender, EventArgs e) { int BoundsWidth = Screen.PrimaryScreen.Bounds.Width; int BoundsHeight = Screen.PrimaryScreen.Bounds.Height; int X_Coordinate = BoundsWidth - this.Width; int Y_Coordinate = BoundsHeight - this.Height; Location = new Point(X_Coordinate / 2, (Y_Coordinate / 2) + 26); //EXCEPTION 1 try { variables = new Variables(); opacityform = new OpacityForm(); cryptography = new Cryptography(); sqlconnectionconfig = new SQLConnectionConfig(); RegistryKey registrykey = Registry.CurrentUser.OpenSubKey(@variables.pathname); string tempdata = registrykey.GetValue("SQLServerConnectionString").ToString(); UserID = registrykey.GetValue("User ID").ToString(); //USER SQLSERVER CONNECTION SETTINGS sqlconnectionconfig.SqlConnectionString = cryptography.Decrypt(tempdata); sqlconnection = new SqlConnection(sqlconnectionconfig.SqlConnectionString); sqlconnection.Open(); DisplayStudentsListInHumanReadableFormat(); DisplayTeachersListInHumanReadableFormat(); DisplayUsersListInHumanReadableFormat(); } catch (Exception exception) { opacityform.Show(); MessageBox.Show(exception.Message.ToString(), "@List Of System Objects Exception 1", MessageBoxButtons.OK, MessageBoxIcon.Error); opacityform.Hide(); } }
private void RetriveSectionData() { //EXCEPTION 2 try { sqlquery4 = "SELECT * FROM [Tbl.Sections]"; sqldataadapter = new SqlDataAdapter(sqlquery4, sqlconnection); DataTable datatable = new DataTable(); sqldataadapter.Fill(datatable); ListofSectionsGridview.AutoGenerateColumns = false; ListofSectionsGridview.DataSource = datatable; } catch (Exception exception) { opacityform.Show(); MessageBox.Show(exception.Message.ToString(), "@Add Section Form Exception 2", MessageBoxButtons.OK, MessageBoxIcon.Error); opacityform.Hide(); } }
private void UpdateFlatButton_Click(object sender, EventArgs e) { //EXCEPTION 2 try { string j = @""""; opacityform = new OpacityForm(); cryptography = new Cryptography(); darkeropacityform = new DarkerOpacityForm(); notificationwindow = new NotificationWindow(); //INNER EXCEPTION 2 try { if (LRNTextbox.Text.Trim().Length < 1 || FirstNameTextbox.Text.Trim().Length < 1 || MiddleNameTextbox.Text.Trim().Length < 1 || LastNameTextbox.Text.Trim().Length < 1 || PresentAddressTextbox.Text.Trim().Length < 1 || PlaceOfBirthTextbox.Text.Trim().Length < 1 || BloodTypeTextbox.Text.Trim().Length < 1 || ReligionTextbox.Text.Trim().Length < 1 || EmailAddressTextbox.Text.Trim().Length < 1 || MobileNumberTextbox.Text.Trim().Length < 1 || FathersNameTextbox.Text.Trim().Length < 1 || FathersOccupationTextbox.Text.Trim().Length < 1 || FathersContactNumberTextbox.Text.Trim().Length < 1 || FathersAddressTextbox.Text.Trim().Length < 1 || MothersNameTextbox.Text.Trim().Length < 1 || MothersOccupationTextbox.Text.Trim().Length < 1 || MothersContactNumberTextbox.Text.Trim().Length < 1 || MothersAddressTextbox.Text.Trim().Length < 1 || PasswordTextbox.Text.Trim().Length < 1 || ConfirmPasswordTextbox.Text.Trim().Length < 1) { notificationwindow.CaptionText = "MESSAGE CONTENT"; notificationwindow.MsgImage.Image = Properties.Resources.warning; notificationwindow.MessageText = "PLEASE PROVIDE THE REQUIRED\nINFORMATIONS BEING ASK !"; darkeropacityform.Show(); notificationwindow.ShowDialog(); darkeropacityform.Hide(); } else if (!EmailAddressTextbox.Text.Trim().Contains("@") || !EmailAddressTextbox.Text.Trim().Contains(".com")) { notificationwindow.CaptionText = "MESSAGE CONTENT"; notificationwindow.MsgImage.Image = Properties.Resources.warning; notificationwindow.MessageText = "PLEASE PROVIDE A VALID EMAIL ADDRESS !"; darkeropacityform.Show(); notificationwindow.ShowDialog(); darkeropacityform.Hide(); } else if (MobileNumberTextbox.Text.Trim().Length < 11 || MobileNumberTextbox.Text.Trim().Length > 11) { notificationwindow.CaptionText = "MESSAGE CONTENT"; notificationwindow.MsgImage.Image = Properties.Resources.warning; notificationwindow.MessageText = "PHONE NUMBER MUST BE 11-DIGITS LONG !"; darkeropacityform.Show(); notificationwindow.ShowDialog(); darkeropacityform.Hide(); } else if (FathersContactNumberTextbox.Text.Trim().Length < 11 || FathersContactNumberTextbox.Text.Trim().Length > 11) { notificationwindow.CaptionText = "MESSAGE CONTENT"; notificationwindow.MsgImage.Image = Properties.Resources.warning; notificationwindow.MessageText = "YOUR FATHERS PHONE NUMBER MUST BE\n11-DIGITS LONG !"; darkeropacityform.Show(); notificationwindow.ShowDialog(); darkeropacityform.Hide(); } else if (MothersContactNumberTextbox.Text.Trim().Length < 11 || MothersContactNumberTextbox.Text.Trim().Length > 11) { notificationwindow.CaptionText = "MESSAGE CONTENT"; notificationwindow.MsgImage.Image = Properties.Resources.warning; notificationwindow.MessageText = "YOUR MOTHERS PHONE NUMBER MUST BE\n11-DIGITS LONG !"; darkeropacityform.Show(); notificationwindow.ShowDialog(); darkeropacityform.Hide(); } else if (MobileNumberTextbox.Text.Trim().ToUpper().Contains("A") || MobileNumberTextbox.Text.Trim().ToUpper().Contains("B") || MobileNumberTextbox.Text.Trim().ToUpper().Contains("C") || MobileNumberTextbox.Text.Trim().ToUpper().Contains("D") || MobileNumberTextbox.Text.Trim().ToUpper().Contains("E") || MobileNumberTextbox.Text.Trim().ToUpper().Contains("F") || MobileNumberTextbox.Text.Trim().ToUpper().Contains("G") || MobileNumberTextbox.Text.Trim().ToUpper().Contains("H") || MobileNumberTextbox.Text.Trim().ToUpper().Contains("I") || MobileNumberTextbox.Text.Trim().ToUpper().Contains("J") || MobileNumberTextbox.Text.Trim().ToUpper().Contains("K") || MobileNumberTextbox.Text.Trim().ToUpper().Contains("L") || MobileNumberTextbox.Text.Trim().ToUpper().Contains("M") || MobileNumberTextbox.Text.Trim().ToUpper().Contains("N") || MobileNumberTextbox.Text.Trim().ToUpper().Contains("O") || MobileNumberTextbox.Text.Trim().ToUpper().Contains("P") || MobileNumberTextbox.Text.Trim().ToUpper().Contains("Q") || MobileNumberTextbox.Text.Trim().ToUpper().Contains("R") || MobileNumberTextbox.Text.Trim().ToUpper().Contains("S") || MobileNumberTextbox.Text.Trim().ToUpper().Contains("T") || MobileNumberTextbox.Text.Trim().ToUpper().Contains("W") || MobileNumberTextbox.Text.Trim().ToUpper().Contains("X") || MobileNumberTextbox.Text.Trim().ToUpper().Contains("Y") || MobileNumberTextbox.Text.Trim().ToUpper().Contains("Z") || MobileNumberTextbox.Text.Trim().ToUpper().Contains("`") || MobileNumberTextbox.Text.Trim().ToUpper().Contains("~") || MobileNumberTextbox.Text.Trim().ToUpper().Contains("!") || MobileNumberTextbox.Text.Trim().ToUpper().Contains("@") || MobileNumberTextbox.Text.Trim().ToUpper().Contains("#") || MobileNumberTextbox.Text.Trim().ToUpper().Contains("$") || MobileNumberTextbox.Text.Trim().ToUpper().Contains("%") || MobileNumberTextbox.Text.Trim().ToUpper().Contains("^") || MobileNumberTextbox.Text.Trim().ToUpper().Contains("&") || MobileNumberTextbox.Text.Trim().ToUpper().Contains("*") || MobileNumberTextbox.Text.Trim().ToUpper().Contains("(") || MobileNumberTextbox.Text.Trim().ToUpper().Contains(")") || MobileNumberTextbox.Text.Trim().ToUpper().Contains("_") || MobileNumberTextbox.Text.Trim().ToUpper().Contains("-") || MobileNumberTextbox.Text.Trim().ToUpper().Contains("+") || MobileNumberTextbox.Text.Trim().ToUpper().Contains("=") || MobileNumberTextbox.Text.Trim().ToUpper().Contains("{") || MobileNumberTextbox.Text.Trim().ToUpper().Contains("[") || MobileNumberTextbox.Text.Trim().ToUpper().Contains("}") || MobileNumberTextbox.Text.Trim().ToUpper().Contains("]") || MobileNumberTextbox.Text.Trim().ToUpper().Contains(";") || MobileNumberTextbox.Text.Trim().ToUpper().Contains(":") || MobileNumberTextbox.Text.Trim().ToUpper().Contains("'") || MobileNumberTextbox.Text.Trim().ToUpper().Contains(j) || MobileNumberTextbox.Text.Trim().ToUpper().Contains("\\") || MobileNumberTextbox.Text.Trim().ToUpper().Contains("|") || MobileNumberTextbox.Text.Trim().ToUpper().Contains(",") || MobileNumberTextbox.Text.Trim().ToUpper().Contains("<") || MobileNumberTextbox.Text.Trim().ToUpper().Contains(".") || MobileNumberTextbox.Text.Trim().ToUpper().Contains(">") || MobileNumberTextbox.Text.Trim().ToUpper().Contains("/") || MobileNumberTextbox.Text.Trim().ToUpper().Contains("?")) { notificationwindow.CaptionText = "MESSAGE CONTENT"; notificationwindow.MsgImage.Image = Properties.Resources.warning; notificationwindow.MessageText = "PHONE NUMBER CONTAINS AN INVALID\nCHARACTER !"; darkeropacityform.Show(); notificationwindow.ShowDialog(); darkeropacityform.Hide(); } else if (FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("A") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("B") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("C") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("D") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("E") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("F") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("G") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("H") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("I") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("J") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("K") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("L") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("M") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("N") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("O") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("P") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("Q") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("R") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("S") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("T") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("W") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("X") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("Y") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("Z") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("`") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("~") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("!") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("@") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("#") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("$") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("%") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("^") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("&") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("*") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("(") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains(")") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("_") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("-") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("+") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("=") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("{") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("[") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("}") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("]") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains(";") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains(":") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("'") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains(j) || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("\\") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("|") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains(",") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("<") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains(".") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains(">") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("/") || FathersContactNumberTextbox.Text.Trim().ToUpper().Contains("?")) { notificationwindow.CaptionText = "MESSAGE CONTENT"; notificationwindow.MsgImage.Image = Properties.Resources.warning; notificationwindow.MessageText = "YOUR FATHERS PHONE NUMBER CONTAINS\nAN INVALID CHARACTER !"; darkeropacityform.Show(); notificationwindow.ShowDialog(); darkeropacityform.Hide(); } else if (MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("A") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("B") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("C") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("D") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("E") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("F") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("G") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("H") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("I") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("J") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("K") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("L") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("M") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("N") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("O") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("P") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("Q") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("R") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("S") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("T") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("W") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("X") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("Y") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("Z") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("`") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("~") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("!") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("@") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("#") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("$") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("%") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("^") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("&") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("*") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("(") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains(")") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("_") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("-") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("+") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("=") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("{") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("[") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("}") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("]") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains(";") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains(":") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("'") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains(j) || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("\\") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("|") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains(",") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("<") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains(".") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains(">") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("/") || MothersContactNumberTextbox.Text.Trim().ToUpper().Contains("?")) { notificationwindow.CaptionText = "MESSAGE CONTENT"; notificationwindow.MsgImage.Image = Properties.Resources.warning; notificationwindow.MessageText = "YOUR MOTHERS PHONE NUMBER CONTAINS\nAN INVALID CHARACTER !"; darkeropacityform.Show(); notificationwindow.ShowDialog(); darkeropacityform.Hide(); } else if (!PasswordTextbox.Text.Trim().Equals(ConfirmPasswordTextbox.Text.Trim()) || !ConfirmPasswordTextbox.Text.Trim().Equals(PasswordTextbox.Text.Trim())) { notificationwindow.CaptionText = "MESSAGE CONTENT"; notificationwindow.MsgImage.Image = Properties.Resources.warning; notificationwindow.MessageText = "PLEASE CONFIRM YOUR PASSWORD !"; darkeropacityform.Show(); notificationwindow.ShowDialog(); darkeropacityform.Hide(); } else if (PasswordTextbox.Text.Trim().Length < 8 || ConfirmPasswordTextbox.Text.Trim().Length < 8) { notificationwindow.CaptionText = "MESSAGE CONTENT"; notificationwindow.MsgImage.Image = Properties.Resources.warning; notificationwindow.MessageText = "YOUR PASSWORD IS TOO SHORT, MAKE IT\n8-CHARACTERS OR ABOVE LONG !"; darkeropacityform.Show(); notificationwindow.ShowDialog(); darkeropacityform.Hide(); } else { if (ImageFilename != null) { //UPDATE [Tbl.Photos] IF IMAGE CHANGED FileStream filestream = new FileStream(ImageFilename, FileMode.Open, FileAccess.Read); byte[] imgByteArr = new byte[filestream.Length]; filestream.Read(imgByteArr, 0, Convert.ToInt32(filestream.Length)); filestream.Close(); string UpdateQuery0 = "UPDATE [Tbl.Photos] SET [FILE NAME] = @filename, PICTURE = @picture WHERE [USER ID] = '" + UserID + "'"; sqlcommand = new SqlCommand(UpdateQuery0, sqlconnection); sqlcommand.Parameters.AddWithValue("@filename", ImageFilename.ToString()); sqlcommand.Parameters.AddWithValue("@picture", imgByteArr); sqlcommand.ExecuteNonQuery(); } //UPDATE [Tbl.Students] string UpdateQuery1 = "UPDATE [Tbl.Students] SET [FIRST NAME] = @1, [MIDDLE NAME] = @2, [LAST NAME] = @3, [GENDER] = @4, [BIRTH DATE] = @5, " + "[PRESENT ADDRESS] = @6, [PLACE OF BIRTH] = @7, [BLOOD TYPE] = @8, [RELIGION] = @9, [INDIGINOUS GROUP] = @10, [EMAIL ADDRESS] = @11, " + "[MOBILE NUMBER] = @12 WHERE [STUDENT ID] = '" + StudentID + "'"; sqlcommand = new SqlCommand(UpdateQuery1, sqlconnection); sqlcommand.Parameters.AddWithValue("@1", FirstNameTextbox.Text.Trim()); sqlcommand.Parameters.AddWithValue("@2", MiddleNameTextbox.Text.Trim()); sqlcommand.Parameters.AddWithValue("@3", LastNameTextbox.Text.Trim()); sqlcommand.Parameters.AddWithValue("@4", GenderDropdown.selectedValue.ToString()); sqlcommand.Parameters.AddWithValue("@5", BirthDatepicker.Value.ToLongDateString().ToString()); sqlcommand.Parameters.AddWithValue("@6", PresentAddressTextbox.Text.Trim()); sqlcommand.Parameters.AddWithValue("@7", PlaceOfBirthTextbox.Text.Trim()); sqlcommand.Parameters.AddWithValue("@8", BloodTypeTextbox.Text.Trim()); sqlcommand.Parameters.AddWithValue("@9", ReligionTextbox.Text.Trim()); sqlcommand.Parameters.AddWithValue("@10", IndiginousGroupTextbox.Text.Trim()); sqlcommand.Parameters.AddWithValue("@11", EmailAddressTextbox.Text.Trim()); sqlcommand.Parameters.AddWithValue("@12", MobileNumberTextbox.Text.Trim()); sqlcommand.ExecuteNonQuery(); //UPDATE [Tbl.FamilyBackgrounds] string UpdateQuery2 = "UPDATE [Tbl.FamilyBackgrounds] SET [FATHERS NAME] = @1, [FATHERS OCCUPATION] = @2, [FATHERS CONTACT NUMBER] = @3, [FATHERS ADDRESS] = @4, " + "[MOTHERS NAME] = @5, [MOTHERS OCCUPATION] = @6, [MOTHERS CONTACT NUMBER] = @7, [MOTHERS ADDRESS] = @8 WHERE [STUDENT ID] = '" + StudentID + "'"; sqlcommand = new SqlCommand(UpdateQuery2, sqlconnection); sqlcommand.Parameters.AddWithValue("@1", FathersNameTextbox.Text.Trim()); sqlcommand.Parameters.AddWithValue("@2", FathersOccupationTextbox.Text.Trim()); sqlcommand.Parameters.AddWithValue("@3", FathersContactNumberTextbox.Text.Trim()); sqlcommand.Parameters.AddWithValue("@4", FathersAddressTextbox.Text.Trim()); sqlcommand.Parameters.AddWithValue("@5", MothersNameTextbox.Text.Trim()); sqlcommand.Parameters.AddWithValue("@6", MothersOccupationTextbox.Text.Trim()); sqlcommand.Parameters.AddWithValue("@7", MothersContactNumberTextbox.Text.Trim()); sqlcommand.Parameters.AddWithValue("@8", MothersAddressTextbox.Text.Trim()); sqlcommand.ExecuteNonQuery(); //UPDATE [Tbl.Users] string UpdateQuery3 = "UPDATE [Tbl.Users] SET [USERNAME] = @1, [PASSWORD] = @2 WHERE [USER ID] = '" + UserID + "'"; sqlcommand = new SqlCommand(UpdateQuery3, sqlconnection); sqlcommand.Parameters.AddWithValue("@1", cryptography.Encrypt(UsernameTextbox.Text)); sqlcommand.Parameters.AddWithValue("@2", cryptography.Encrypt(PasswordTextbox.Text)); sqlcommand.ExecuteNonQuery(); notificationwindow.CaptionText = "MESSAGE CONTENT"; notificationwindow.MsgImage.Image = Properties.Resources.check; notificationwindow.MessageText = "SUCCESSFULY UPDATED !"; darkeropacityform.Show(); notificationwindow.ShowDialog(); darkeropacityform.Hide(); //CLOSE THE CURRENT FORM sqlconnection.Close(); DialogResult = DialogResult.OK; } } catch (Exception exception) { opacityform.Show(); MessageBox.Show(exception.Message.ToString(), "@Student Edit Form Inner Exception 2", MessageBoxButtons.OK, MessageBoxIcon.Error); opacityform.Hide(); } } catch (Exception exception) { opacityform.Show(); MessageBox.Show(exception.Message.ToString(), "@Student Edit Form Exception 2", MessageBoxButtons.OK, MessageBoxIcon.Error); opacityform.Hide(); } }
private void SubmitButton_Click(object sender, EventArgs e) { //EXCEPTION 2 try { opacityform = new OpacityForm(); darkeropacityform = new DarkerOpacityForm(); notificationwindow = new NotificationWindow(); if (NewPasswordTextbox.Text.Trim().Length == 0 || ConfirmPasswordTextbox.Text.Trim().Length == 0) { notificationwindow.CaptionText = "MESSAGE CONTENT"; notificationwindow.MsgImage.Image = Properties.Resources.warning; notificationwindow.MessageText = "PLEASE PROVIDE THE REQUIRED\nINFORMATIONS BEING ASK !"; darkeropacityform.Show(); notificationwindow.ShowDialog(); darkeropacityform.Hide(); } else if (OldPasswordTextbox.Text.Trim().Equals(NewPasswordTextbox.Text.Trim()) || NewPasswordTextbox.Text.Trim().Equals(OldPasswordTextbox.Text.Trim())) { notificationwindow.CaptionText = "MESSAGE CONTENT"; notificationwindow.MsgImage.Image = Properties.Resources.warning; notificationwindow.MessageText = "YOUR NEW PASSWORD AND OLD ARE\nJUST THE SAME !"; darkeropacityform.Show(); notificationwindow.ShowDialog(); darkeropacityform.Hide(); } else if (!NewPasswordTextbox.Text.Trim().Equals(ConfirmPasswordTextbox.Text.Trim()) || !ConfirmPasswordTextbox.Text.Trim().Equals(NewPasswordTextbox.Text.Trim())) { notificationwindow.CaptionText = "MESSAGE CONTENT"; notificationwindow.MsgImage.Image = Properties.Resources.warning; notificationwindow.MessageText = "PLEASE CONFIRM YOUR NEW PASSWORD !"; darkeropacityform.Show(); notificationwindow.ShowDialog(); darkeropacityform.Hide(); } else if (NewPasswordTextbox.Text.Trim().Length < 8 || ConfirmPasswordTextbox.Text.Trim().Length < 8) { notificationwindow.CaptionText = "MESSAGE CONTENT"; notificationwindow.MsgImage.Image = Properties.Resources.warning; notificationwindow.MessageText = "YOUR PASSWORD IS TOO SHORT, MAKE IT\n8-CHARACTERS OR ABOVE LONG !"; darkeropacityform.Show(); notificationwindow.ShowDialog(); darkeropacityform.Hide(); } else { //INNER EXCEPTION 2 try { //ERROR EXIST HERE. sqlquery2 = "UPDATE [Tbl.Users] SET PASSWORD = @password WHERE [USER ID] = '" + currentuserid + "'"; sqlcommand = new SqlCommand(sqlquery2, sqlconnection); sqlcommand.Parameters.AddWithValue("@password", cryptography.Encrypt(ConfirmPasswordTextbox.Text.Trim())); sqlcommand.ExecuteNonQuery(); notificationwindow.CaptionText = "SUCCESS !"; notificationwindow.MsgImage.Image = Properties.Resources.check; notificationwindow.MessageText = "SUCCESSFULLY UPDATED !"; darkeropacityform.Show(); notificationwindow.ShowDialog(); darkeropacityform.Hide(); sqlconnection.Close(); DialogResult = DialogResult.OK; } catch (Exception exception) { opacityform.Show(); MessageBox.Show(exception.Message.ToString(), "@Change Password Form Exception 2", MessageBoxButtons.OK, MessageBoxIcon.Error); opacityform.Hide(); } } } catch (Exception exception) { opacityform.Show(); MessageBox.Show(exception.Message.ToString(), "@Change Password Form Exception 2", MessageBoxButtons.OK, MessageBoxIcon.Error); opacityform.Hide(); } }
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 LoginButton_Click(object sender, EventArgs e) { Show_BusyCursor_State(); opacityform = new OpacityForm(); darkeropacityform = new DarkerOpacityForm(); notificationwindow = new NotificationWindow(); //EXCEPTION 2 try { variables = new Variables(); RegistryKey getregistrykey = Registry.CurrentUser.OpenSubKey(@variables.pathname); string tempdata = getregistrykey.GetValue("SQLServerConnectionString").ToString(); getregistrykey.Close(); if (UsernameTextbox.Text.Length == 0 || PasswordTextbox.Text.Length == 0) { authentication = new Authentication(); authentication.VerifyLoginCredentials(this); Show_DefaultCursor_State(); } else if (tempdata == string.Empty) { notificationwindow.CaptionText = "SERVER NOT FOUND"; notificationwindow.MsgImage.Image = Properties.Resources.warning; notificationwindow.MessageText = "WE CAN'T ESTABLISHED A CONNECTION\nTO THE SERVER, " + "PLEASE SETUP THE\nFOLLOWING CONFIGURATIONS."; darkeropacityform.Show(); notificationwindow.ShowDialog(); darkeropacityform.Hide(); SqlServerSettingsButton_Click(sender, e); Show_DefaultCursor_State(); } else { //INNER EXCEPTION 2 try { authentication = new Authentication(); authentication.VerifyLoginCredentials(this); //AUTHENTICATED & ADMINISTRATOR if (authentication.IsVerified == true && authentication.IsAdmin == true) { administratorworkspace = new AdministratorWorkspace(); this.Hide(); administratorworkspace.Show(); Show_DefaultCursor_State(); } //AUTHENTICATED & TEACHER else if (authentication.IsVerified == true && authentication.IsTeacher == true) { teacherworkspace = new TeacherWorkspace(); this.Hide(); teacherworkspace.Show(); Show_DefaultCursor_State(); } //AUTHENTICATED & STUDENT else if (authentication.IsVerified == true && authentication.IsStudent == true) { studentworkspace = new StudentWorkspace(); this.Hide(); studentworkspace.Show(); Show_DefaultCursor_State(); } } catch (Exception exception) { opacityform.Show(); MessageBox.Show(exception.Message.ToString(), "@LoginForm Inner Exception 2", MessageBoxButtons.OK, MessageBoxIcon.Error); opacityform.Hide(); } Show_DefaultCursor_State(); } } catch (Exception exception) { opacityform.Show(); MessageBox.Show(exception.Message.ToString(), "@LoginForm Exception 2", MessageBoxButtons.OK, MessageBoxIcon.Error); opacityform.Hide(); } }
private void TestConnectionButton_Click(object sender, EventArgs e) { opacityform = new OpacityForm(); darkeropacityform = new DarkerOpacityForm(); notificationwindow = new NotificationWindow(); //EXCEPTION 1 try { //SHOW VISUAL REPRESENTATION FOR EMPTY TEXTBOXES Show_Hide_Visual_Representation_Labels(); if (ServerNameTextbox.Text.Length == 0 || DatabaseNameTextbox.Text.Length == 0 || SqlServerUsernameTextbox.Text.Length == 0 || SqlServerPasswordTextbox.Text.Length == 0) { notificationwindow.CaptionText = "CONNECTION REFUSED"; notificationwindow.MsgImage.Image = Properties.Resources.warning; notificationwindow.MessageText = "PLEASE PROVIDE THE REQUIRED\nINFORMATIONS BEING ASK !"; darkeropacityform.Show(); notificationwindow.ShowDialog(); darkeropacityform.Hide(); } else if (ServerNameTextbox.Text.EndsWith(" ") || DatabaseNameTextbox.Text.EndsWith(" ") || SqlServerUsernameTextbox.Text.EndsWith(" ") || SqlServerPasswordTextbox.Text.EndsWith(" ")) { notificationwindow.CaptionText = "CONNECTION REFUSED"; notificationwindow.MsgImage.Image = Properties.Resources.error; notificationwindow.MessageText = "LOGIN FAILED !\nPLEASE REVIEW YOUR INFORMATION."; darkeropacityform.Show(); notificationwindow.ShowDialog(); darkeropacityform.Hide(); } else if (ServerNameTextbox.Text.Length != 0 && DatabaseNameTextbox.Text.Length != 0 && SqlServerUsernameTextbox.Text.Length != 0 && SqlServerPasswordTextbox.Text.Length != 0) { //INNER EXCEPTION 1 try { variables = new Variables(); sqlconfig = new SQLConnectionConfig(); tempconnectionstring = "Data Source=" + ServerNameTextbox.Text + ";" + "Initial Catalog=" + DatabaseNameTextbox.Text + ";" + "Persist Security Info=True;" + "User ID=" + SqlServerUsernameTextbox.Text + ";" + "Password="******""; sqlconfig.SqlConnectionString = tempconnectionstring; sqlconnection = new SqlConnection(sqlconfig.SqlConnectionString); do { Cursor = Cursors.AppStarting; sqlconnection.Open(); if (sqlconnection.State == ConnectionState.Open) { notificationwindow.CaptionText = "CONNECTION TESTING"; notificationwindow.MsgImage.Image = Properties.Resources.check; notificationwindow.MessageText = "TEST CONNECTION SUCCEEDED !"; darkeropacityform.Show(); notificationwindow.ShowDialog(); darkeropacityform.Hide(); Cursor = Cursors.Default; break; } }while (sqlconnection.State == ConnectionState.Closed); sqlconnection.Close(); } catch (Exception exception) { Cursor = Cursors.Default; opacityform.Show(); MessageBox.Show(exception.Message.ToString(), "@Server Connection Inner Exception 1", MessageBoxButtons.OK, MessageBoxIcon.Error); opacityform.Hide(); } } } catch (Exception exception) { opacityform.Show(); MessageBox.Show(exception.Message.ToString(), "@Server Connection Exception 1", MessageBoxButtons.OK, MessageBoxIcon.Error); opacityform.Hide(); } }
private void 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(); } }
private void SubmitButton_Click(object sender, EventArgs e) { //EXCEPTION 2 try { opacityform = new OpacityForm(); darkeropacityform = new DarkerOpacityForm(); notificationwindow = new NotificationWindow(); if (LRNTextbox.Text.Trim().Length < 1 || FirstNameTextbox.Text.Trim().Length < 1 || MiddleNameTextbox.Text.Trim().Length < 1 || LastNameTextbox.Text.Trim().Length < 1 || PresentAddressTextbox.Text.Trim().Length < 1 || PlaceOfBirthTextbox.Text.Trim().Length < 1 || BloodTypeTextbox.Text.Trim().Length < 1 || ReligionTextbox.Text.Trim().Length < 1 || EmailAddressTextbox.Text.Trim().Length < 1 || MobileNumberTextbox.Text.Trim().Length < 1 || SectionDropdown.selectedIndex == 0 || FathersNameTextbox.Text.Trim().Length < 1 || FathersOccupationTextbox.Text.Trim().Length < 1 || FathersContactNumberTextbox.Text.Trim().Length < 1 || FathersAddressTextbox.Text.Trim().Length < 1 || MothersNameTextbox.Text.Trim().Length < 1 || MothersOccupationTextbox.Text.Trim().Length < 1 || MothersContactNumberTextbox.Text.Trim().Length < 1 || MothersAddressTextbox.Text.Trim().Length < 1 || PasswordTextbox.Text.Trim().Length < 1 || ConfirmPasswordTextbox.Text.Trim().Length < 1) { notificationwindow.CaptionText = "MESSAGE CONTENT"; notificationwindow.MsgImage.Image = Properties.Resources.warning; notificationwindow.MessageText = "PLEASE PROVIDE THE REQUIRED\nINFORMATIONS BEING ASK !"; darkeropacityform.Show(); notificationwindow.ShowDialog(); darkeropacityform.Hide(); } else if (!EmailAddressTextbox.Text.Trim().Contains("@") || !EmailAddressTextbox.Text.Trim().Contains(".com")) { notificationwindow.CaptionText = "MESSAGE CONTENT"; notificationwindow.MsgImage.Image = Properties.Resources.warning; notificationwindow.MessageText = "PLEASE PROVIDE A VALID EMAIL ADDRESS !"; darkeropacityform.Show(); notificationwindow.ShowDialog(); darkeropacityform.Hide(); } else if (MobileNumberTextbox.Text.Trim().Length < 11 || MobileNumberTextbox.Text.Trim().Length > 11) { notificationwindow.CaptionText = "MESSAGE CONTENT"; notificationwindow.MsgImage.Image = Properties.Resources.warning; notificationwindow.MessageText = "PHONE NUMBER MUST BE 11-DIGITS LONG !"; darkeropacityform.Show(); notificationwindow.ShowDialog(); darkeropacityform.Hide(); } else if (FathersContactNumberTextbox.Text.Trim().Length < 11 || FathersContactNumberTextbox.Text.Trim().Length > 11) { notificationwindow.CaptionText = "MESSAGE CONTENT"; notificationwindow.MsgImage.Image = Properties.Resources.warning; notificationwindow.MessageText = "YOUR FATHERS PHONE NUMBER MUST BE\n11-DIGITS LONG !"; darkeropacityform.Show(); notificationwindow.ShowDialog(); darkeropacityform.Hide(); } else if (MothersContactNumberTextbox.Text.Trim().Length < 11 || MothersContactNumberTextbox.Text.Trim().Length > 11) { notificationwindow.CaptionText = "MESSAGE CONTENT"; notificationwindow.MsgImage.Image = Properties.Resources.warning; notificationwindow.MessageText = "YOUR MOTHERS PHONE NUMBER MUST BE\n11-DIGITS LONG !"; darkeropacityform.Show(); notificationwindow.ShowDialog(); darkeropacityform.Hide(); } else if (isNumber(MobileNumberTextbox.Text.Trim()) == false) { notificationwindow.CaptionText = "MESSAGE CONTENT"; notificationwindow.MsgImage.Image = Properties.Resources.warning; notificationwindow.MessageText = "PHONE NUMBER CONTAINS AN INVALID\nCHARACTER !"; darkeropacityform.Show(); notificationwindow.ShowDialog(); darkeropacityform.Hide(); } else if (isNumber(FathersContactNumberTextbox.Text.Trim()) == false) { notificationwindow.CaptionText = "MESSAGE CONTENT"; notificationwindow.MsgImage.Image = Properties.Resources.warning; notificationwindow.MessageText = "YOUR FATHERS PHONE NUMBER CONTAINS\nAN INVALID CHARACTER !"; darkeropacityform.Show(); notificationwindow.ShowDialog(); darkeropacityform.Hide(); } else if (isNumber(MothersContactNumberTextbox.Text.Trim()) == false) { notificationwindow.CaptionText = "MESSAGE CONTENT"; notificationwindow.MsgImage.Image = Properties.Resources.warning; notificationwindow.MessageText = "YOUR MOTHERS PHONE NUMBER CONTAINS\nAN INVALID CHARACTER !"; darkeropacityform.Show(); notificationwindow.ShowDialog(); darkeropacityform.Hide(); } else if (!PasswordTextbox.Text.Trim().Equals(ConfirmPasswordTextbox.Text.Trim()) || !ConfirmPasswordTextbox.Text.Trim().Equals(PasswordTextbox.Text.Trim())) { notificationwindow.CaptionText = "MESSAGE CONTENT"; notificationwindow.MsgImage.Image = Properties.Resources.warning; notificationwindow.MessageText = "PLEASE CONFIRM YOUR PASSWORD !"; darkeropacityform.Show(); notificationwindow.ShowDialog(); darkeropacityform.Hide(); } else if (PasswordTextbox.Text.Trim().Length < 8 || ConfirmPasswordTextbox.Text.Trim().Length < 8) { notificationwindow.CaptionText = "MESSAGE CONTENT"; notificationwindow.MsgImage.Image = Properties.Resources.warning; notificationwindow.MessageText = "YOUR PASSWORD IS TOO SHORT, MAKE IT\n8-CHARACTERS OR ABOVE LONG !"; darkeropacityform.Show(); notificationwindow.ShowDialog(); darkeropacityform.Hide(); } else { //INNER EXCEPTION 22 try { string query1, query2, query3, query4, query5, query6, query7, query8, query9, query10; string OldMaxStudents, OldEnrolled; int NewEnrolledCount; string FullName = LastNameTextbox.Text.Trim() + ", " + FirstNameTextbox.Text.Trim() + " " + MiddleNameTextbox.Text.Trim().Remove(1, MiddleNameTextbox.Text.Trim().Length - 1) + "."; //CHECK IF THE SECTION IS FULL OR NOT query1 = "SELECT [MAXIMUM STUDENTS], ENROLLED FROM [Tbl.Sections] WHERE [SECTION NAME] = '" + SectionDropdown.selectedValue.ToString() + "' AND [SCHOOL YEAR] = '" + CurrentSchoolYear + "'"; sqlcommand = new SqlCommand(query1, sqlconnection); SqlDataReader sqldatareader = sqlcommand.ExecuteReader(); while (sqldatareader.Read()) { OldMaxStudents = sqldatareader.GetString(0); OldEnrolled = sqldatareader.GetString(1); NewEnrolledCount = int.Parse(OldEnrolled) + 1; if (!OldEnrolled.Equals(OldMaxStudents) || !OldMaxStudents.Equals(OldEnrolled)) { sqldatareader.Close(); //VALIDATE STUDENT REGISTRATION string VerifyQuery = "SELECT COUNT(*) FROM [Tbl.Students] WHERE [FIRST NAME] = '" + FirstNameTextbox.Text.Trim() + "' AND [MIDDLE NAME] = '" + MiddleNameTextbox.Text.Trim() + "' AND [LAST NAME] = '" + LastNameTextbox.Text.Trim() + "'"; sqldataadapter = new SqlDataAdapter(VerifyQuery, sqlconnection); DataTable VirtualTable = new DataTable(); sqldataadapter.Fill(VirtualTable); if (VirtualTable.Rows[0][0].ToString() == "0") { //INSERT INTO STUDENTS TABLE query2 = "INSERT INTO [Tbl.Students]([STUDENT ID], [USER ID], LRN, [FIRST NAME], [MIDDLE NAME], [LAST NAME], [GRADE LEVEL]," + "SECTION, GENDER, [BIRTH DATE], [PRESENT ADDRESS], [PLACE OF BIRTH], [BLOOD TYPE], RELIGION, [INDIGINOUS GROUP]," + "[EMAIL ADDRESS], [MOBILE NUMBER]) VALUES(@studentid, @userid, @lrn, @firstname, @middlename, @lastname, @gradelevel," + "@section, @gender, @birthdate, @presentaddress, @placeofbirth, @bloodtype, @religion, @indiginousgroup, @emailaddress," + "@mobilenumber)"; sqlcommand = new SqlCommand(query2, sqlconnection); sqlcommand.Parameters.AddWithValue("@studentid", NewStudentID.ToString()); sqlcommand.Parameters.AddWithValue("@userid", NewUserID.ToString()); sqlcommand.Parameters.AddWithValue("@lrn", LRNTextbox.Text.Trim()); sqlcommand.Parameters.AddWithValue("@firstname", FirstNameTextbox.Text.Trim()); sqlcommand.Parameters.AddWithValue("@middlename", MiddleNameTextbox.Text.Trim()); sqlcommand.Parameters.AddWithValue("@lastname", LastNameTextbox.Text.Trim()); sqlcommand.Parameters.AddWithValue("@gradelevel", GradeLevelDropdown.selectedValue.ToString()); sqlcommand.Parameters.AddWithValue("@section", SectionDropdown.selectedValue.ToString()); sqlcommand.Parameters.AddWithValue("@gender", GenderDropdown.selectedValue.ToString()); sqlcommand.Parameters.AddWithValue("@birthdate", BirthdayPicker.Value.ToLongDateString().ToString()); sqlcommand.Parameters.AddWithValue("@presentaddress", PresentAddressTextbox.Text.Trim()); sqlcommand.Parameters.AddWithValue("@placeofbirth", PlaceOfBirthTextbox.Text.Trim()); sqlcommand.Parameters.AddWithValue("@bloodtype", BloodTypeTextbox.Text.Trim()); sqlcommand.Parameters.AddWithValue("@religion", ReligionTextbox.Text.Trim()); sqlcommand.Parameters.AddWithValue("@indiginousgroup", IndiginousGroupTextbox.Text.Trim() == "" ? "None" : IndiginousGroupTextbox.Text.Trim()); sqlcommand.Parameters.AddWithValue("@emailaddress", EmailAddressTextbox.Text.Trim()); sqlcommand.Parameters.AddWithValue("@mobilenumber", MobileNumberTextbox.Text.Trim()); sqlcommand.ExecuteNonQuery(); //INSERT INTO FAMILY BACKGROUND TABLE query3 = "INSERT INTO [Tbl.FamilyBackgrounds]([STUDENT ID], [FATHERS NAME], [FATHERS OCCUPATION], [FATHERS CONTACT NUMBER]," + "[FATHERS ADDRESS], [MOTHERS NAME], [MOTHERS OCCUPATION], [MOTHERS CONTACT NUMBER], [MOTHERS ADDRESS]) VALUES(@studentid," + "@fathersname, @fatheroccupation, @fathersnumber, @fathersaddress, @mothername, @motheroccupation, @mothernumber, @motheraddress)"; sqlcommand = new SqlCommand(query3, sqlconnection); sqlcommand.Parameters.AddWithValue("@studentid", NewStudentID.ToString()); sqlcommand.Parameters.AddWithValue("@fathersname", FathersNameTextbox.Text.Trim()); sqlcommand.Parameters.AddWithValue("@fatheroccupation", FathersOccupationTextbox.Text.Trim()); sqlcommand.Parameters.AddWithValue("@fathersnumber", FathersContactNumberTextbox.Text.Trim()); sqlcommand.Parameters.AddWithValue("@fathersaddress", FathersAddressTextbox.Text.Trim()); sqlcommand.Parameters.AddWithValue("@mothername", MothersNameTextbox.Text.Trim()); sqlcommand.Parameters.AddWithValue("@motheroccupation", MothersOccupationTextbox.Text.Trim()); sqlcommand.Parameters.AddWithValue("@mothernumber", MothersContactNumberTextbox.Text.Trim()); sqlcommand.Parameters.AddWithValue("@motheraddress", MothersAddressTextbox.Text.Trim()); sqlcommand.ExecuteNonQuery(); //INSERT INTO USERS TABLE query4 = "INSERT INTO [Tbl.Users]([USER ID], USERNAME, PASSWORD, [ACCOUNT STATUS], [ACCOUNT TYPE], [LAST LOGIN]," + "[IS PWD CHANGED], [SITUATION STATUS]) VALUES(@userid, @username, @password, @accountstatus, @account_type, @last_login, @ispwdchanged, @stat)"; sqlcommand = new SqlCommand(query4, sqlconnection); sqlcommand.Parameters.AddWithValue("@userid", NewUserID.ToString()); sqlcommand.Parameters.AddWithValue("@username", cryptography.Encrypt(NewStudentID.ToString())); sqlcommand.Parameters.AddWithValue("@password", cryptography.Encrypt(PasswordTextbox.Text)); sqlcommand.Parameters.AddWithValue("@accountstatus", "Active"); sqlcommand.Parameters.AddWithValue("@account_type", "Student"); sqlcommand.Parameters.AddWithValue("@last_login", "NO LOGIN HISTORY"); sqlcommand.Parameters.AddWithValue("@ispwdchanged", "False"); sqlcommand.Parameters.AddWithValue("@stat", "0"); sqlcommand.ExecuteNonQuery(); //UPDATE SECTIONS TABLE --> ENROLLED query5 = "UPDATE [Tbl.Sections] SET ENROLLED = @enrolled WHERE [SECTION NAME] = @section_nane" + " AND [SCHOOL YEAR] = '" + CurrentSchoolYear + "'"; sqlcommand = new SqlCommand(query5, sqlconnection); sqlcommand.Parameters.AddWithValue("@enrolled", NewEnrolledCount.ToString()); sqlcommand.Parameters.AddWithValue("@section_nane", SectionDropdown.selectedValue.ToString()); sqlcommand.ExecuteNonQuery(); //INSERT INTO STUDENT LOAD TABLE --> 1st Grading query6 = "INSERT INTO [Tbl.FirstGradingStudentLoad]([STUDENT ID], [STUDENT NAME], GENDER, [GRADE LEVEL], SECTION," + "FILIPINO, ENGLISH, MATHEMATICS, SCIENCE, AP, TLE, MAPEH, ESP, [SCHOOL YEAR]) VALUES(@studentid1g, @studentname1g," + "@gender1g, @gradelevel1g, @section1g, @sb11g, @sb21g, @sb31g, @sb41g, @sb51g, @sb61g, @sb71g, @sb81g, @schoolyear1g)"; sqlcommand = new SqlCommand(query6, sqlconnection); sqlcommand.Parameters.AddWithValue("@studentid1g", NewStudentID.ToString()); sqlcommand.Parameters.AddWithValue("@studentname1g", FullName); sqlcommand.Parameters.AddWithValue("@gender1g", GenderDropdown.selectedValue.ToString()); sqlcommand.Parameters.AddWithValue("@gradelevel1g", GradeLevelDropdown.selectedValue.ToString()); sqlcommand.Parameters.AddWithValue("@section1g", SectionDropdown.selectedValue.ToString()); sqlcommand.Parameters.AddWithValue("@sb11g", ""); sqlcommand.Parameters.AddWithValue("@sb21g", ""); sqlcommand.Parameters.AddWithValue("@sb31g", ""); sqlcommand.Parameters.AddWithValue("@sb41g", ""); sqlcommand.Parameters.AddWithValue("@sb51g", ""); sqlcommand.Parameters.AddWithValue("@sb61g", ""); sqlcommand.Parameters.AddWithValue("@sb71g", ""); sqlcommand.Parameters.AddWithValue("@sb81g", ""); sqlcommand.Parameters.AddWithValue("@schoolyear1g", CurrentSchoolYear); sqlcommand.ExecuteNonQuery(); //INSERT INTO STUDENT LOAD TABLE --> 2nd Grading query7 = "INSERT INTO [Tbl.SecondGradingStudentLoad]([STUDENT ID], [STUDENT NAME], GENDER, [GRADE LEVEL], SECTION," + "FILIPINO, ENGLISH, MATHEMATICS, SCIENCE, AP, TLE, MAPEH, ESP, [SCHOOL YEAR]) VALUES(@studentid2g, @studentname2g," + "@gender2g, @gradelevel2g, @section2g, @sb12g, @sb22g, @sb32g, @sb42g, @sb52g, @sb62g, @sb72g, @sb82g, @schoolyear2g)"; sqlcommand = new SqlCommand(query7, sqlconnection); sqlcommand.Parameters.AddWithValue("@studentid2g", NewStudentID.ToString()); sqlcommand.Parameters.AddWithValue("@studentname2g", FullName); sqlcommand.Parameters.AddWithValue("@gender2g", GenderDropdown.selectedValue.ToString()); sqlcommand.Parameters.AddWithValue("@gradelevel2g", GradeLevelDropdown.selectedValue.ToString()); sqlcommand.Parameters.AddWithValue("@section2g", SectionDropdown.selectedValue.ToString()); sqlcommand.Parameters.AddWithValue("@sb12g", ""); sqlcommand.Parameters.AddWithValue("@sb22g", ""); sqlcommand.Parameters.AddWithValue("@sb32g", ""); sqlcommand.Parameters.AddWithValue("@sb42g", ""); sqlcommand.Parameters.AddWithValue("@sb52g", ""); sqlcommand.Parameters.AddWithValue("@sb62g", ""); sqlcommand.Parameters.AddWithValue("@sb72g", ""); sqlcommand.Parameters.AddWithValue("@sb82g", ""); sqlcommand.Parameters.AddWithValue("@schoolyear2g", CurrentSchoolYear); sqlcommand.ExecuteNonQuery(); //INSERT INTO STUDENT LOAD TABLE --> 3rd Grading query8 = "INSERT INTO [Tbl.ThirdGradingStudentLoad]([STUDENT ID], [STUDENT NAME], GENDER, [GRADE LEVEL], SECTION," + "FILIPINO, ENGLISH, MATHEMATICS, SCIENCE, AP, TLE, MAPEH, ESP, [SCHOOL YEAR]) VALUES(@studentid3g, @studentname3g," + "@gender3g, @gradelevel3g, @section3g, @sb13g, @sb23g, @sb33g, @sb43g, @sb53g, @sb63g, @sb73g, @sb83g, @schoolyear3g)"; sqlcommand = new SqlCommand(query8, sqlconnection); sqlcommand.Parameters.AddWithValue("@studentid3g", NewStudentID.ToString()); sqlcommand.Parameters.AddWithValue("@studentname3g", FullName); sqlcommand.Parameters.AddWithValue("@gender3g", GenderDropdown.selectedValue.ToString()); sqlcommand.Parameters.AddWithValue("@gradelevel3g", GradeLevelDropdown.selectedValue.ToString()); sqlcommand.Parameters.AddWithValue("@section3g", SectionDropdown.selectedValue.ToString()); sqlcommand.Parameters.AddWithValue("@sb13g", ""); sqlcommand.Parameters.AddWithValue("@sb23g", ""); sqlcommand.Parameters.AddWithValue("@sb33g", ""); sqlcommand.Parameters.AddWithValue("@sb43g", ""); sqlcommand.Parameters.AddWithValue("@sb53g", ""); sqlcommand.Parameters.AddWithValue("@sb63g", ""); sqlcommand.Parameters.AddWithValue("@sb73g", ""); sqlcommand.Parameters.AddWithValue("@sb83g", ""); sqlcommand.Parameters.AddWithValue("@schoolyear3g", CurrentSchoolYear); sqlcommand.ExecuteNonQuery(); //INSERT INTO STUDENT LOAD TABLE --> 4rth Grading query9 = "INSERT INTO [Tbl.FourthGradingStudentLoad]([STUDENT ID], [STUDENT NAME], GENDER, [GRADE LEVEL], SECTION," + "FILIPINO, ENGLISH, MATHEMATICS, SCIENCE, AP, TLE, MAPEH, ESP, [SCHOOL YEAR]) VALUES(@studentid4g, @studentname4g," + "@gender4g, @gradelevel4g, @section4g, @sb14g, @sb24g, @sb34g, @sb44g, @sb54g, @sb64g, @sb74g, @sb84g, @schoolyear4g)"; sqlcommand = new SqlCommand(query9, sqlconnection); sqlcommand.Parameters.AddWithValue("@studentid4g", NewStudentID.ToString()); sqlcommand.Parameters.AddWithValue("@studentname4g", FullName); sqlcommand.Parameters.AddWithValue("@gender4g", GenderDropdown.selectedValue.ToString()); sqlcommand.Parameters.AddWithValue("@gradelevel4g", GradeLevelDropdown.selectedValue.ToString()); sqlcommand.Parameters.AddWithValue("@section4g", SectionDropdown.selectedValue.ToString()); sqlcommand.Parameters.AddWithValue("@sb14g", ""); sqlcommand.Parameters.AddWithValue("@sb24g", ""); sqlcommand.Parameters.AddWithValue("@sb34g", ""); sqlcommand.Parameters.AddWithValue("@sb44g", ""); sqlcommand.Parameters.AddWithValue("@sb54g", ""); sqlcommand.Parameters.AddWithValue("@sb64g", ""); sqlcommand.Parameters.AddWithValue("@sb74g", ""); sqlcommand.Parameters.AddWithValue("@sb84g", ""); sqlcommand.Parameters.AddWithValue("@schoolyear4g", CurrentSchoolYear); sqlcommand.ExecuteNonQuery(); //INSERT INTO [Tbl.StudentAverages] query10 = "INSERT INTO [Tbl.StudentAverages]([STUDENT ID], [STUDENT NAME], LRN, [GRADE LEVEL], SECTION, " + "[FIRST GRADING], [SECOND GRADING], [THIRD GRADING], [FOURTH GRADING], GPA, [SCHOOL YEAR]) " + "VALUES(@sid, @studname, @lrn, @glevel, @section, @fga, @sga, @tga, @ffga, @gpa, @schoolyear)"; sqlcommand = new SqlCommand(query10, sqlconnection); sqlcommand.Parameters.AddWithValue("@sid", NewStudentID.ToString()); sqlcommand.Parameters.AddWithValue("@studname", FullName); sqlcommand.Parameters.AddWithValue("@lrn", LRNTextbox.Text.Trim()); sqlcommand.Parameters.AddWithValue("@glevel", GradeLevelDropdown.selectedValue.ToString()); sqlcommand.Parameters.AddWithValue("@section", SectionDropdown.selectedValue.ToString()); sqlcommand.Parameters.AddWithValue("@fga", ""); sqlcommand.Parameters.AddWithValue("@sga", ""); sqlcommand.Parameters.AddWithValue("@tga", ""); sqlcommand.Parameters.AddWithValue("@ffga", ""); sqlcommand.Parameters.AddWithValue("@gpa", ""); sqlcommand.Parameters.AddWithValue("@schoolyear", CurrentSchoolYear); sqlcommand.ExecuteNonQuery(); notificationwindow.CaptionText = "REGISTRATION SUCCESS !"; notificationwindow.MsgImage.Image = Properties.Resources.check; notificationwindow.MessageText = FirstNameTextbox.Text.Trim().ToUpper() + " " + LastNameTextbox.Text.Trim().ToUpper() + " " + "WAS\nREGISTERED SUCCESSFULLY !"; darkeropacityform.Show(); notificationwindow.ShowDialog(); darkeropacityform.Hide(); sqlconnection.Close(); DialogResult = DialogResult.OK; } else if (int.Parse(VirtualTable.Rows[0][0].ToString()) > 0) { notificationwindow.CaptionText = "MESSAGE CONTENT"; notificationwindow.MsgImage.Image = Properties.Resources.error; notificationwindow.MessageText = "THIS STUDENT IS ALREADY REGISTERED !"; darkeropacityform.Show(); notificationwindow.ShowDialog(); darkeropacityform.Hide(); } } else { sqldatareader.Close(); notificationwindow.CaptionText = "MESSAGE CONTENT"; notificationwindow.MsgImage.Image = Properties.Resources.error; notificationwindow.MessageText = "SECTION " + SectionDropdown.selectedValue.ToString() + "IS ALREADY FULL !"; darkeropacityform.Show(); notificationwindow.ShowDialog(); darkeropacityform.Hide(); } break; } sqldatareader.Close(); } catch (Exception exception) { opacityform.Show(); MessageBox.Show(exception.StackTrace.ToString() + exception.Message, "@Add Student Form Inner Exception 22", MessageBoxButtons.OK, MessageBoxIcon.Error); opacityform.Hide(); } } } catch (Exception exception) { opacityform.Show(); MessageBox.Show(exception.StackTrace.ToString(), "@Add Student Form Exception 2", MessageBoxButtons.OK, MessageBoxIcon.Error); opacityform.Hide(); } }
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 UserIDTextbox_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Escape) { DialogResult = DialogResult.OK; } else if (e.KeyCode == Keys.Enter) { //EXCEPTION 2 try { opacityform = new OpacityForm(); darkeropacityform = new DarkerOpacityForm(); notificationwindow = new NotificationWindow(); if (UserIDTextbox.Text.Trim().Length < 1) { notificationwindow.CaptionText = "MESSAGE CONTENT"; notificationwindow.MsgImage.Image = Properties.Resources.warning; notificationwindow.MessageText = "NO USER ID ENTERED !"; darkeropacityform.Show(); notificationwindow.ShowDialog(); darkeropacityform.Hide(); } else if (IsNumber(UserIDTextbox.Text.Trim()) == false) { notificationwindow.CaptionText = "MESSAGE CONTENT"; notificationwindow.MsgImage.Image = Properties.Resources.warning; notificationwindow.MessageText = "INVALID USER ID - " + UserIDTextbox.Text.Trim() + " !"; darkeropacityform.Show(); notificationwindow.ShowDialog(); darkeropacityform.Hide(); } else if (UserID.Equals(UserIDTextbox.Text.Trim()) || UserIDTextbox.Text.Trim().Equals(UserID)) { notificationwindow.CaptionText = "MESSAGE CONTENT"; notificationwindow.MsgImage.Image = Properties.Resources.error; notificationwindow.MessageText = "THIS OPERATION CANNOT BE DONE\nBECAUSE YOU CANNOT ALTER\nYOUR OWN ACCOUNT !"; darkeropacityform.Show(); notificationwindow.ShowDialog(); darkeropacityform.Hide(); } else { string sqlquery1 = "SELECT COUNT(*) FROM [Tbl.Users] WHERE [USER ID] = '" + UserIDTextbox.Text.Trim() + "'"; sqldataadapter = new SqlDataAdapter(sqlquery1, sqlconnection); DataTable datatable = new DataTable(); sqldataadapter.Fill(datatable); //USER ID IS VALID - UPDATE USER STATUS if (datatable.Rows[0][0].ToString() == "1") { string query1 = "SELECT [ACCOUNT STATUS] FROM [Tbl.Users] WHERE [USER ID] = '" + UserIDTextbox.Text.Trim() + "'"; sqlcommand = new SqlCommand(query1, sqlconnection); SqlDataReader sqldatareader = sqlcommand.ExecuteReader(); while (sqldatareader.Read()) { isActive = sqldatareader.GetString(0); } sqldatareader.Close(); if (isActive.Equals("Active")) { opacityform.Show(); var PlsDontContinue = MessageBox.Show("ARE YOU SURE TO DISABLE THIS ACCOUNT ?, THIS USER CANNOT LOGIN ANYMORE" + " UNLESS YOU ENABLE IT BACK !\n\nDO YOU WANT TO PROCEED ANYWAY ?", "ARE YOU SURE ?", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (PlsDontContinue == DialogResult.No || PlsDontContinue == DialogResult.Cancel) { opacityform.Hide(); } else if (PlsDontContinue == DialogResult.Yes) { opacityform.Hide(); string alterquery1 = "UPDATE [Tbl.Users] SET [ACCOUNT STATUS] = @accountstatus WHERE [USER ID] = '" + UserIDTextbox.Text.Trim() + "'"; sqlcommand = new SqlCommand(alterquery1, sqlconnection); sqlcommand.Parameters.AddWithValue("@accountstatus", "Disabled"); sqlcommand.ExecuteNonQuery(); notificationwindow.CaptionText = "MESSAGE CONTENT"; notificationwindow.MsgImage.Image = Properties.Resources.check; notificationwindow.MessageText = "USER ACCOUNT IS NOW DISABLED !"; darkeropacityform.Show(); notificationwindow.ShowDialog(); darkeropacityform.Hide(); RefreshPicture3_Click(sender, e); } } else if (isActive.Equals("Disabled")) { string alterquery2 = "UPDATE [Tbl.Users] SET [ACCOUNT STATUS] = @accountstatus WHERE [USER ID] = '" + UserIDTextbox.Text.Trim() + "'"; sqlcommand = new SqlCommand(alterquery2, sqlconnection); sqlcommand.Parameters.AddWithValue("@accountstatus", "Active"); sqlcommand.ExecuteNonQuery(); notificationwindow.CaptionText = "MESSAGE CONTENT"; notificationwindow.MsgImage.Image = Properties.Resources.check; notificationwindow.MessageText = "USER ACCOUNT IS NOW ENABLED !"; darkeropacityform.Show(); notificationwindow.ShowDialog(); darkeropacityform.Hide(); RefreshPicture3_Click(sender, e); } } //F**K YEAH, USER ID IS NOT VALID else if (datatable.Rows[0][0].ToString() == "0") { notificationwindow.CaptionText = "MESSAGE CONTENT"; notificationwindow.MsgImage.Image = Properties.Resources.warning; notificationwindow.MessageText = "NO RECORDS FOUND FOR\nUSER ID - " + UserIDTextbox.Text.Trim() + " !"; darkeropacityform.Show(); notificationwindow.ShowDialog(); darkeropacityform.Hide(); } } } catch (Exception exception) { opacityform.Show(); MessageBox.Show(exception.Message.ToString(), "@List Of System Objects Exception 2", MessageBoxButtons.OK, MessageBoxIcon.Error); opacityform.Hide(); } } }
private void StudentEditDetailsForm_Load(object sender, EventArgs e) { int BoundsWidth = Screen.PrimaryScreen.Bounds.Width; int BoundsHeight = Screen.PrimaryScreen.Bounds.Height; int X_Coordinate = BoundsWidth - this.Width; int Y_Coordinate = BoundsHeight - this.Height; Location = new Point(X_Coordinate / 2, (Y_Coordinate / 2) + 26); //EXCEPTION 1 try { variables = new Variables(); opacityform = new OpacityForm(); cryptography = new Cryptography(); sqlconnectionconfig = new SQLConnectionConfig(); RegistryKey registrykey = Registry.CurrentUser.OpenSubKey(@variables.pathname); string tempdata = registrykey.GetValue("SQLServerConnectionString").ToString(); StudentID = registrykey.GetValue("Student ID").ToString(); UserID = registrykey.GetValue("User ID").ToString(); //USER SQLSERVER CONNECTION SETTINGS sqlconnectionconfig.SqlConnectionString = cryptography.Decrypt(tempdata); sqlconnection = new SqlConnection(sqlconnectionconfig.SqlConnectionString); sqlconnection.Open(); //INNER EXCEPTION 1 try { //LOAD ACCOUNT PICTURE Load_Account_Picture(); //LOAD PERSONAL INFO AS PLACEHOLDER Load_Personal_Info_AsPlaceholder(); //LOAD FAMILY BACKGROUND AS PLACEHOLDER Load_Family_Background_AsPlaceholder(); //LOAD ACCOUNT INFORMATION Load_Account_Information(); } catch (Exception exception) { opacityform.Show(); MessageBox.Show(exception.Message.ToString(), "@Student Edit Form Inner Exception 1", MessageBoxButtons.OK, MessageBoxIcon.Error); opacityform.Hide(); } } catch (Exception exception) { opacityform.Show(); MessageBox.Show(exception.Message.ToString(), "@Student Edit Form Exception 1", MessageBoxButtons.OK, MessageBoxIcon.Error); opacityform.Hide(); } }
private void InsertButton_Click(object sender, EventArgs e) { //EXCEPTION 3 try { variables = new Variables(); opacityform = new OpacityForm(); darkeropacityform = new DarkerOpacityForm(); notificationwindow = new NotificationWindow(); if (SectionNameTextbox.Text.Trim().Length < 1 || MaxStudentTextbox.Text.Trim().Length < 1) { notificationwindow.CaptionText = "MESSAGE CONTENT"; notificationwindow.MsgImage.Image = Properties.Resources.warning; notificationwindow.MessageText = "PLEASE PROVIDE SECTION NAME,\nMAXIMUM STUDENTS AND SCHOOL YEAR !"; darkeropacityform.Show(); notificationwindow.ShowDialog(); darkeropacityform.Hide(); } else if (isNumber(MaxStudentTextbox.Text.Trim()) == false) { notificationwindow.CaptionText = "MESSAGE CONTENT"; notificationwindow.MsgImage.Image = Properties.Resources.warning; notificationwindow.MessageText = "INVALID DATA ON MAXIMUM STUDENTS !"; darkeropacityform.Show(); notificationwindow.ShowDialog(); darkeropacityform.Hide(); } else { //INNER EXCEPTION 3 try { string TempQuery = "SELECT COUNT(*) FROM [Tbl.Sections] WHERE [SECTION NAME] = '" + SectionNameTextbox.Text.Trim().ToUpper() + "' AND [SCHOOL YEAR] = '" + CurrentSchoolYearDropdown.selectedValue.ToString() + "'"; sqldataadapter = new SqlDataAdapter(TempQuery, sqlconnection); DataTable datatable = new DataTable(); sqldataadapter.Fill(datatable); if (datatable.Rows[0][0].ToString() == "1") { notificationwindow.CaptionText = "MESSAGE CONTENT"; notificationwindow.MsgImage.Image = Properties.Resources.warning; notificationwindow.MessageText = "THAT SECTION ALREADY EXIST FOR \nSCHOOL YEAR " + CurrentSchoolYearDropdown.selectedValue.ToString(); darkeropacityform.Show(); notificationwindow.ShowDialog(); darkeropacityform.Hide(); } else if (datatable.Rows[0][0].ToString() == "0") { RegistryKey registrykey = Registry.CurrentUser.OpenSubKey(@variables.pathname); CurrentSectionCount = registrykey.GetValue("NofMaxSections").ToString(); if (int.Parse(CurrentSectionCount) < 10) { sqlquery5 = "INSERT INTO [Tbl.Sections]([SECTION ID], [SECTION NAME], [MAXIMUM STUDENTS], ENROLLED, [SCHOOL YEAR])" + " VALUES(@sectionid, @section_name, @maximumstudents, @enrolled, @schoolyear)"; sqlcommand = new SqlCommand(sqlquery5, sqlconnection); sqlcommand.Parameters.AddWithValue("@sectionid", Prefix + NewSectionID.ToString()); sqlcommand.Parameters.AddWithValue("@section_name", SectionNameTextbox.Text.Trim().ToUpper()); sqlcommand.Parameters.AddWithValue("@maximumstudents", MaxStudentTextbox.Text.Trim()); sqlcommand.Parameters.AddWithValue("@enrolled", "0"); sqlcommand.Parameters.AddWithValue("@schoolyear", CurrentSchoolYearDropdown.selectedValue.ToString().ToUpper()); sqlcommand.ExecuteNonQuery(); //UPDATE SECTION COUNT RegistryKey updateregistrykey = Registry.CurrentUser.CreateSubKey(@variables.pathname); updateregistrykey.SetValue("NofMaxSections", (int.Parse(CurrentSectionCount) + 1).ToString()); Init_NewSectionID(); RetriveSectionData(); SectionNameTextbox.ResetText(); MaxStudentTextbox.ResetText(); CurrentSchoolYearDropdown.selectedIndex = 0; InsertButton.Select(); } else if (int.Parse(CurrentSectionCount) == 10) { notificationwindow.CaptionText = "MESSAGE CONTENT"; notificationwindow.MsgImage.Image = Properties.Resources.error; notificationwindow.MessageText = "YOU CAN ONLY CREATE 10 SECTIONS\nEVERY SCHOOL YEAR !"; darkeropacityform.Show(); notificationwindow.ShowDialog(); darkeropacityform.Hide(); } } } catch (Exception exception) { opacityform.Show(); MessageBox.Show(exception.Message.ToString(), "@Add Section Form Inner Exception 3", MessageBoxButtons.OK, MessageBoxIcon.Error); opacityform.Hide(); } } } catch (Exception exception) { opacityform.Show(); MessageBox.Show(exception.Message.ToString(), "@Add Section Form Exception 2", MessageBoxButtons.OK, MessageBoxIcon.Error); opacityform.Hide(); } }
private void InsertButton_Click(object sender, EventArgs e) { //EXCEPTION 2 try { opacityform = new OpacityForm(); darkeropacityform = new DarkerOpacityForm(); notificationwindow = new NotificationWindow(); if (SchoolYearTextbox.Text.Trim().Length < 1) { notificationwindow.CaptionText = "MESSAGE CONTENT"; notificationwindow.MsgImage.Image = Properties.Resources.warning; notificationwindow.MessageText = "PLEASE PROVIDE A SCHOOL YEAR !"; darkeropacityform.Show(); notificationwindow.ShowDialog(); darkeropacityform.Hide(); } else if (!SchoolYearTextbox.Text.Trim().ToUpper().Contains("S.Y.")) { notificationwindow.CaptionText = "MESSAGE CONTENT"; notificationwindow.MsgImage.Image = Properties.Resources.warning; notificationwindow.MessageText = "PLEASE FOLLOW AND PROVIDE\nTHE SPECIFIED SCHOOL YEAR FORMAT !"; darkeropacityform.Show(); notificationwindow.ShowDialog(); darkeropacityform.Hide(); } else { //INNER EXCEPTION 2 try { string TempQuery = "SELECT COUNT(*) FROM [Tbl.SchoolYear] WHERE [SCHOOL YEAR] = '" + SchoolYearTextbox.Text.Trim().ToUpper() + "'"; sqldataadapter = new SqlDataAdapter(TempQuery, sqlconnection); DataTable datatable0 = new DataTable(); sqldataadapter.Fill(datatable0); if (datatable0.Rows[0][0].ToString() == "1") { notificationwindow.CaptionText = "MESSAGE CONTENT"; notificationwindow.MsgImage.Image = Properties.Resources.warning; notificationwindow.MessageText = "THAT SCHOOL YEAR ALREADY EXIST !"; darkeropacityform.Show(); notificationwindow.ShowDialog(); darkeropacityform.Hide(); } else if (datatable0.Rows[0][0].ToString() == "0") { string InsertQuery = "INSERT INTO [Tbl.SchoolYear]([ENTRY ID], [SCHOOL YEAR], [WAS SET]) VALUES(@EntryID, @schoolyear, @ws)"; sqlcommand = new SqlCommand(InsertQuery, sqlconnection); sqlcommand.Parameters.AddWithValue("@EntryID", Prefix_ID + NewEntryID.ToString()); sqlcommand.Parameters.AddWithValue("@schoolyear", SchoolYearTextbox.Text.Trim().ToUpper()); sqlcommand.Parameters.AddWithValue("@ws", "0"); sqlcommand.ExecuteNonQuery(); RetrieveSchoolYearData(); SchoolYearTextbox.ResetText(); InsertButton.Select(); Init_NewEntryID(); } } catch (Exception exception) { opacityform.Show(); MessageBox.Show(exception.StackTrace.ToString(), "@Add School Year Form Inner Exception 2", MessageBoxButtons.OK, MessageBoxIcon.Error); opacityform.Hide(); } } } catch (Exception exception) { opacityform.Show(); MessageBox.Show(exception.StackTrace.ToString(), "@Add School Year Form Exception 2", MessageBoxButtons.OK, MessageBoxIcon.Error); opacityform.Hide(); } }
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 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(); } }