// TODO: this should return a boolean value not a dataTable (fix it) .. fixed (DONE), EMAD public int login(string username, string password) { if (!dal.testDBConnection()) { return(2); } string hashedPassword = GetHashString(password); SqlParameter[] param = new SqlParameter[2]; // first param (username) param[0] = new SqlParameter("@username", SqlDbType.VarChar, 30); param[0].Value = username; // first param (password), length = 40 (sha1 hash) param[1] = new SqlParameter("@pwd", SqlDbType.VarChar, 40); param[1].Value = hashedPassword; DataTable dt = dal.selectData("sp_login", param); if (dt.Rows.Count > 0) { int loggedUserID = Convert.ToInt32(dt.Rows[0][0].ToString()); string loggedUser_username = dt.Rows[0][1].ToString(); string loggedUser_fullName = dt.Rows[0][3].ToString(); string loggedUser_phoneNum = dt.Rows[0][4].ToString(); setRuntimeInfo(loggedUserID, loggedUser_username, loggedUser_fullName); controlMenus(); // TODO: enable the menus based on the permissions return(1); } return(0); }
private void btnTestConeection_Click(object sender, EventArgs e) { string[] dbServerInfo = _dbConnectionSettings.getDBserverInfo(); string dbServerName = dbServerInfo[0]; //"(LocalDB)\\MSSQLLocalDB"; string dbName = dbServerInfo[1]; //"C:\\Users\emad\\documents\\visual studio 2015\\Projects\\Emad Store\\Emad Store\\kfs_hospital.mdf"; if (dbServerName == "" || dbName == "") // make sure that there is some info stored in the settings { MessageBox.Show("لا يوجد معلومات اتصال بقاعدة البيانات مخزنة في البرنامج"); return; } else { Models.DataAcessLayer dal = new Models.DataAcessLayer(); if (dal.testDBConnection()) { MessageBox.Show("الاتصال يعمل بشكل صحيح"); } else { MessageBox.Show("يوجد خطأ في الاتصال بقاعدة البيانات"); } } }