private void bAdd_Click(object sender, EventArgs e) { if (!CheckPWDValidity()) { MessageBox.Show("Password do not match", "Password Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } if (tbFullName.Text == "") { MessageBox.Show("Full name cannot be empty", "Full name Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } usec.UserName = tbUID.Text; usec.Password = es.EncodeText(tbPWD1.Text); usec.FullName = tbFullName.Text; usec.CreatedBy = 1; try { usec.AddUser(); MessageBox.Show("Record Saved ", "Saved", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show("Saving returned and error \n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void bLogon_Click(object sender, EventArgs e) { if (user.GetUser(tbUID.Text)) { if (user.Password.Trim().Length == 0) { FormChgPwd form = new FormChgPwd(); form.UserName = tbUID.Text; form.Owner = this; form.ShowDialog(); } else { string encodePwd = esha.EncodeText(tbPWD.Text).Trim(); string savedPwd = user.Password.Trim(); if (user.Password.Trim() == encodePwd) { RuntimeDefaults.UserName = user.UserName; RuntimeDefaults.LoggedStatus = true; RuntimeDefaults.UserId = user.id; this.Close(); } else { MessageBox.Show("Password does not match"); return; } } } else { //Here we should add new admin user } }