public void Init() { login_timer = new Timer(); login_timer.Interval = 50; login_timer.Tick += new EventHandler(Login_timer_Tick); // Init databases MapsDB _dbMaps = new MapsDB(); _dbMaps.Dispose(); UsersDB _dbUsers = new UsersDB(); _dbUsers.Dispose(); StoragesDB _dbStorages = new StoragesDB(); _dbStorages.Dispose(); PlacesDB _dbMyPlaces = new PlacesDB(); _dbMyPlaces.Dispose(); ProjectsDB _dbMyProjects = new ProjectsDB(); _dbMyProjects.Dispose(); CreateLogin(); }
private void btnOK_Click(object sender, EventArgs e) { bool passed = false; bool userfound = false; string loginoremail = "LOGIN"; aEmail = txtEmail.Text; if (txtEmail.Text == "") { lblEmail.ForeColor = System.Drawing.Color.Red; } else if (txtPassword.Text == "") { lblPassword.ForeColor = System.Drawing.Color.Red; } else { if (Internet.EmailIsValid(txtEmail.Text) == true) { loginoremail = "EMAIL"; } UsersDB _db = new UsersDB(); DataTable _dt = _db.ExecuteQuery("select * from USERS"); foreach (DataRow _row in _dt.Rows) { if (_row[loginoremail].ToString() == txtEmail.Text) // user found { userfound = true; aName = _row["NAME"].ToString(); aEmail = _row["EMAIL"].ToString(); if (_row["PASS"].ToString() == txtPassword.Text) // TODO password decrypt? { passed = true; MMUtils.SetRegistry("", "CurrentUserName", aName); MMUtils.SetRegistry("", "CurrentUserEmail", aEmail); if (checkBoxRemember.Checked == true) { MMUtils.SetRegistry("", "RememberMe", "1"); MMUtils.SetRegistry("", "RememberedUserName", aName); MMUtils.SetRegistry("", "RememberedUserEmail", aEmail); } break; } else //password wrong { string _arg = MMUtils.GetString("loginDlg.login.text"); if (loginoremail == "EMAIL") { _arg = MMUtils.GetString("loginDlg.Email.text"); } lblPasswordNoMatch.Text = String.Format(MMUtils.GetString("loginDlg.wrongpassword.text"), _arg); } } } _db.Dispose(); if (!userfound) { lblUserNoExists.Text = MMUtils.GetString("loginDlg.usernoexists.text"); } if (passed) { this.DialogResult = DialogResult.OK; } } }