void Btn_okClick(object sender, EventArgs e) { DataTable dt = Functions.GetTable("select name, password from " + Program.ModName_lcns + "_users where name = '" + Program.currentUSER + "'"); if (dt.Rows.Count == 0) { MessageBox.Show("Old password did not match."); return; } else { string decryptedPassword = StringCipher.Decrypt(dt.Rows[0]["password"].ToString(), Program.EncryptionKey); if (string.Compare(decryptedPassword, txb_old_password.Text) != 0) { MessageBox.Show("Old password did not match."); return; } } if (txb_new_password.Text == "") { MessageBox.Show("Please enter new password"); return; } if (txb_new_password.Text != txb_confirmPassword.Text) { MessageBox.Show("Password and Confirm Password did not match."); return; } Functions.SqlNonQuery("update " + Program.ModName_lcns + "_users set password = '******' "); }
public void openCompany() { if (lb_databases.SelectedIndex >= 0 || Program.IsDefaultDBset == true) { MySqlConnection conn = new MySqlConnection(); try { string database = Program.IsDefaultDBset == true ? Program.currentDB : "GBC_" + lb_databases.SelectedItem.ToString().Replace(' ', '_'); string connStr = string.Format("server={0};database={1};user={2};port={3};password={4};", Program.Server, database, Program.SqlUser, Program.Port, Program.Password); Program.GlobalConn = new MySqlConnection(connStr); Program.GlobalConn.Open(); DataTable dt = Functions.GetTable("show tables like '" + Program.ModName_lcns + "_users'"); if (dt.Rows.Count == 0) { var dialogResult = MessageBox.Show("[" + Program.ThisModuleName + "] Module has not been configured with selected database. " + "Do you want to configure now?\n\nIt is recommended to open Accounting Module and save backup before configuring modules.", "Module Configuration", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialogResult == DialogResult.Yes) { // module configuration code ConfigureModule(); } else { return; } } else { // code to open the company i.e. check userid and password dt = Functions.GetTable("select name, password from " + Program.ModName_lcns + "_users where name = '" + txb_userid.Text + "'"); if (dt.Rows.Count == 0) { MessageBox.Show("User ID or Password not correct"); } else { string decryptedPassword = StringCipher.Decrypt(dt.Rows[0]["password"].ToString(), Program.EncryptionKey); if (string.Compare(decryptedPassword, txb_password.Text) == 0) { //userid and password are correct Program.currentUSER = txb_userid.Text; Program.MainWindow.EnableMenues(true); Program.MainWindow.Text += " - [User: "******"] "; this.Close(); } else { MessageBox.Show("User ID or Password not correct"); } } } } catch (Exception ex) { ExceptionMB emb = new ExceptionMB(); emb.ShowMB(ex); } } }