/// <summary> /// 驗證帳號密碼 /// </summary> /// <param name="id">帳號</param> /// <param name="password">密碼</param> /// <returns>使用者物件</returns> internal Model.SupplierAccount CheckPassword(string id, string password) { if (string.IsNullOrEmpty(id) || string.IsNullOrEmpty(password)) { return(null); } //查詢SupplierAccount資料 SupplierAccountDao dao = new SupplierAccountDao(); Model.SupplierAccount supplier = dao.FindSupplierAccountBySupplierAccountID(id); if (supplier == null) { return(null); } string hashPassword = Util.GetHash(password + supplier.PasswordSalt); if (hashPassword.Equals(supplier.PasswordHash)) { return(supplier); } return(null); }
private Model.SupplierAccount GetSupplierAccount(DataRow dr) { if (dr == null) { return(null); } Model.SupplierAccount supplier = new Model.SupplierAccount(); supplier.SupplierAccountOID = Convert.ToInt32(dr["SupplierAccountOID"]); supplier.SupplierAccountID = Convert.ToString(dr["SupplierAccountID"]); supplier.PasswordHash = Convert.ToString(dr["PasswordHash"]); supplier.PasswordSalt = Convert.ToString(dr["PasswordSalt"]); supplier.ContactName = Convert.ToString(dr["ContactName"]); supplier.Email = Convert.ToString(dr["Email"]); supplier.Address = Convert.ToString(dr["Address"]); supplier.Mobile = Convert.ToString(dr["Mobile"]); supplier.Tel = Convert.ToString(dr["Tel"]); supplier.SupplierCode = Convert.ToString(dr["SupplierCode"]); supplier.AccountStatus = Convert.ToString(dr["AccountStatus"]); supplier.CreateDate = Convert.ToDateTime(dr["CreateDate"]); supplier.CreatorEmployeeID = Convert.ToString(dr["CreatorEmployeeID"]); if (!SqlHelper.IsNull(dr["ModifiedDate"])) { supplier.ModifiedDate = Convert.ToDateTime(dr["ModifiedDate"]); } supplier.SASendLetterState = Convert.ToString(dr["SASendLetterState"]); if (!SqlHelper.IsNull(dr["SASendLetterDate"])) { supplier.SASendLetterDate = Convert.ToDateTime(dr["SASendLetterDate"]); } return(supplier); }
private void btnLogin_Click(object sender, EventArgs e) { SupplierLoginService bls = new SupplierLoginService(); Model.SupplierAccount sa = bls.CheckPassword(this.txtID.Text.Trim(), this.txtPassword.Text.Trim()); if (sa == null) { MessageBox.Show("帳號或密碼錯誤,請重新輸入"); return; } else { Common.ContainerForm.SupplierLoginAccount = sa; Common.ContainerForm.SetLoginRole(); Common.ContainerForm.SetMenuButton(); Common.ContainerForm.btnFrontPage_Click_1(null, null); Common.ContainerForm.Visible = true; } Common.LoginForm.Close(); }
public Model.SupplierAccount FindSupplierAccountBySupplierCode(string SupplierCode) { string strCmd = @"select SupplierAccountOID, SupplierAccountID, PasswordHash, PasswordSalt, ContactName, Email, Address, Mobile, Tel, SupplierCode, AccountStatus, CreateDate, CreatorEmployeeID, ModifiedDate, SASendLetterState, SASendLetterDate from SupplierAccount where SupplierCode = @SupplierCode"; List <SqlParameter> parameters = new List <SqlParameter>(); parameters.Add(SqlHelper.CreateParameter("@SupplierCode", SqlDbType.NVarChar, 6, SupplierCode)); DataTable dt = SqlHelper.AdapterFill(strCmd, parameters); if (dt.Rows.Count == 0) { return(null); } Model.SupplierAccount supplier = this.GetSupplierAccount(dt.Rows[0]); return(supplier); }