public void AddNewUser(string userName, string firstName, string lastName, string accountType, string cript_password, string byWho, out string resCode, out string resDesc) { try { Log.AppendText("กำลังส่งข้อมูลเพิ่มรายชื่อผู้ใช้ระบบใหม่ {" + userName + ", " + firstName + ", " + lastName + ", " + accountType + "} by " + byWho); ManageBiz ms = new ManageBiz(); DataTable dtUser; dtUser = ms.GetUserBy(userName); if (dtUser.Rows.Count == 0) { Log.AppendText("ตรวจสอบ ชื่อผู้ใช้ เรียบร้อย"); ms.AddNewUser(userName, firstName, lastName, accountType, cript_password); resCode = "00"; resDesc = ""; } else { Log.AppendText("WARNING! : ชื่อผู้ใช้ซ้ำ"); resCode = "01"; resDesc = "ชื่อผู้ใช้ซ้ำ!"; } } catch (Exception ex) { resCode = "EX"; resDesc = ex.Message; Log.AppendText(ex.Message); } }
public bool Login(string UserName, string Password) { try { ManageBiz ms = new ManageBiz(); string crptPassword = StringCipher.Encrypt(Password, true); DataTable dtUser; dtUser = ms.GetUserBy(UserName); bool ShowDenineMessage = false; if (dtUser != null) { if (dtUser.Rows.Count == 1) { string dbPassword = dtUser.Rows[0]["Password"].ToString(); if (dbPassword == crptPassword) { return(true); } else { ShowDenineMessage = true; } } else { ShowDenineMessage = true; } } else { ShowDenineMessage = true; } if (ShowDenineMessage) { MessageBox.Show("Access denine. Invalid user name or password.", "Login", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1); } return(false); } catch (Exception ex) { Log.AppendText(ex.Message); MessageBox.Show("Login Error : " + ex.Message); return(false); } }