// تابع تسجيل الدخول public bool Login(string Username, string Password) { string pass = "", nat = ""; try { OleDbCommand Command = new OleDbCommand("SELECT Pass_HV,NationalNumber FROM Users WHERE Username='******'", con); con.Open(); OleDbDataReader reader = Command.ExecuteReader(); while (reader.Read()) { pass = reader["Pass_HV"].ToString().Trim(); nat = reader["NationalNumber"].ToString().Trim(); } con.Close(); if (pass != "" && nat != "") { string HashedPass = HashFunctions.Pass_HV(Password, nat); if (pass == HashedPass) { return(true); } else { return(false); } } else { return(false); } } catch { return(false); } }
// تابع اضافة كلمة مرور جديدة public bool NewPassword(string Username, string Password, string NationalNumber) { string Pass_HV = HashFunctions.Pass_HV(Password, NationalNumber); try { DatabaseFunctions.UpdatePassword(Username, Pass_HV); return(true); } catch { return(false); } }
// تابع تعديل البيانات public bool UpdateInfo(string Username, string NationalNumber, string MobileNumber, string Password) { int ID = DatabaseFunctions.GetUserID(Username); string Pass_HV = HashFunctions.Pass_HV(Password, NationalNumber); string Personal_Info_HV = HashFunctions.Personal_Info_HV(Username, NationalNumber, MobileNumber); try { DatabaseFunctions.UpdateInformation(ID, Username, Pass_HV, NationalNumber, MobileNumber, Personal_Info_HV); return(true); } catch { return(false); } }
// تابع تسجيل يوزر جديد public string Register(string Username, string NationalNumber, string MobileNumber, string Password) { // تابع التهشير المطبق على كلمة المرور والرقم الوطني string Pass_HV = HashFunctions.Pass_HV(Password, NationalNumber); // تابع التهشير المطبق على اسم المستخدم والرقم الوطني ورقم الجوال string Personal_Info_HV = HashFunctions.Personal_Info_HV(Username, NationalNumber, MobileNumber); try { if (!DatabaseFunctions.UsernameUsed(Username)) { DatabaseFunctions.InsertIntoUsers(Username, Pass_HV, NationalNumber, MobileNumber, Personal_Info_HV); return("Registration Success"); } else { return("User Name Used Before !! Pleas Choose another one."); } } catch (Exception ex) { return(ex.Message); } }