public ResultSet AuthenticateHospital(string username, string password) { ResultSet result = new ResultSet(); try { string query = @"IF NOT EXISTS(SELECT TOP 1 1 FROM TBL_HOSPITAL WHERE HOSPITAL_USERNAME=@USERNAME OR EMAIL=@USERNAME) BEGIN RAISERROR('HOSPITAL USER DOES NOT EXISTS',16,1); RETURN; END IF NOT EXISTS(SELECT TOP 1 1 FROM TBL_HOSPITAL WHERE (HOSPITAL_USERNAME=@USERNAME OR EMAIL=@USERNAME) AND [PASSWORD]=@PASSWORD) BEGIN RAISERROR('HOSPITAL PASSWORD IS INCORRECT',16,1); RETURN; END IF NOT EXISTS(SELECT TOP 1 1 FROM TBL_HOSPITAL WHERE (HOSPITAL_USERNAME=@USERNAME OR EMAIL=@USERNAME) AND [PASSWORD]=@PASSWORD AND IS_ACTIVE=1) BEGIN RAISERROR('HOSPITAL USER IS NOT ACTIVE',16,1); RETURN; END ELSE BEGIN SELECT TOP 1 HOSPITAL_USERNAME,HOSPITAL_ID,HOSPITAL_NAME,EMAIL,CONTACT_NO FROM TBL_HOSPITAL WHERE ([HOSPITAL_USERNAME]=@USERNAME OR EMAIL=@USERNAME) END "; SqlParameter[] parameters = { new SqlParameter("@USERNAME", username ?? string.Empty), new SqlParameter("@PASSWORD", password ?? string.Empty) }; DataRow dataRow = _dao.GetTable(parameters, query, false).Rows[0]; result.Success = true; result.Message = "HOSPITAL ACCOUNT AUTHENITICATED SUCCESSFULLY"; result.Data = new HospitalModel { Id = int.Parse(dataRow["HOSPITAL_ID"].ToString()), Name = dataRow["HOSPITAL_NAME"].ToString(), Username = dataRow["HOSPITAL_USERNAME"].ToString(), }; } catch (System.Exception ex) { result.Success = false; result.Message = ex.Message; } return(result); }
public ResultSet AuthenticateReceiver(string username, string password) { ResultSet result = new ResultSet(); try { string query = @"IF NOT EXISTS(SELECT TOP 1 1 FROM TBL_USER WHERE [USERNAME]=@USERNAME OR EMAIL=@USERNAME) BEGIN RAISERROR('RECEIVER USER DOES NOT EXISTS',16,1); RETURN; END IF NOT EXISTS(SELECT TOP 1 1 FROM TBL_USER WHERE ([USERNAME]=@USERNAME OR EMAIL=@USERNAME) AND [PASSWORD]=@PASSWORD) BEGIN RAISERROR('RECEIVER PASSWORD IS INCORRECT',16,1); RETURN; END IF NOT EXISTS(SELECT TOP 1 1 FROM TBL_USER WHERE ([USERNAME]=@USERNAME OR EMAIL=@USERNAME) AND [PASSWORD]=@PASSWORD AND IS_ACTIVE=1) BEGIN RAISERROR('RECEIVER USER IS NOT ACTIVE',16,1); RETURN; END ELSE BEGIN SELECT TOP 1 USERNAME,[USER_ID],FULL_NAME,EMAIL,CONTACT_NO FROM TBL_USER WHERE ([USERNAME]=@USERNAME OR EMAIL=@USERNAME) END "; SqlParameter[] parameters = { new SqlParameter("@USERNAME", username), new SqlParameter("@PASSWORD", password) }; DataRow dataRow = _dao.GetTable(parameters, query, false).Rows[0]; result.Success = true; result.Message = "USER ACCOUNT AUTHENITICATED SUCCESSFULLY"; result.Data = new ReceiverModel { Username = dataRow["USERNAME"].ToString(), Name = dataRow["FULL_NAME"].ToString(), Id = int.Parse(dataRow["USER_ID"].ToString()) }; } catch (System.Exception ex) { result.Success = false; result.Message = ex.Message; } return(result); }
public DataTable GetRequestList(int hospitalId) { DataTable dataTable = new DataTable(); try { string query = @" SELECT TU.FULL_NAME, THBF.BLOOD_GROUP,CONVERT(VARCHAR,THBF.CREATED_DATE,111) AS [RELEASED_DATE],CONVERT(VARCHAR,TRBH.CREATED_DATE,111) AS [REQUESTED_DATE] FROM TBL_REQUEST_BLOOD_HIST TRBH INNER JOIN TBL_HOSPITAL_BLOOD_INFO THBF ON TRBH.BLOOD_INFO_ID=THBF.BLOOD_INFO_ID INNER JOIN TBL_USER TU ON TU.USER_ID=TRBH.USER_ID WHERE THBF.HOSPITAL_ID=@HOSPITAL_ID ORDER BY TRBH.CREATED_DATE DESC, THBF.CREATED_DATE DESC,THBF.BLOOD_GROUP ASC"; SqlParameter[] sqlParameters = { new SqlParameter("@HOSPITAL_ID", hospitalId) }; dataTable = _dao.GetTable(sqlParameters, query, isProc: false); } catch (System.Exception) { } return(dataTable); }