private void UserControl3_Load(object sender, EventArgs e) { clsUser clsuser = new clsUser(); txtItemCode.Focus(); //LoadCity(); LoadCustCbo(); lblCashierName.Text = clsuser.GetGName(); SelectInvoiceNo(); }
private void btnOK_Click(object sender, EventArgs e) { string un = txtUN.Text; string pw = txtPW.Text; string[] result; //to do: filter the input //to do: byte[] data = System.Text.Encoding.UTF8.GetBytes ("stRhong%pword"); // byte[] hash = SHA256.Create().ComputeHash(data); //The GetBytes method on an Encoding object converts a string to a byte array; the GetString method converts it back. An Encoding object cannot, however, convert an encrypted or hashed byte array to a string, because scrambled data usually violates text encoding rules.Instead, use Convert .ToBase64String and Convert.FromBase64String : these convert between any byte array and a legal(and XML - friendly) string. //byte[] data = System.Text.Encoding.UTF8.GetBytes(pw); //byte[] hash = SHA256.Create().ComputeHash(data); classDatabaseConnect dbConnObj = new classDatabaseConnect(); result = dbConnObj.authenticate(un, pw); if (result == null) { MessageBox.Show("Please provide a valid credential", "Login", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else if (result[3] == "True") { MessageBox.Show("User is logged-in in other computer", "Login", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { user.SetUserID(result[0]); user.SetGName(result[1]); user.SetPrivelge(result[2]); user.SetLoginStatus(result[3]); string q = "UPDATE users SET login_status=1 WHERE userID='" + user.GetUserID() + "'"; dbConnObj.ManipulateData(q); MessageBox.Show("Welcome " + user.GetGName(), "Login", MessageBoxButtons.OK, MessageBoxIcon.Information); string uid = user.GetUserID(); log.userLogin(uid, dt, "Logged In"); Close(); } }