如果不知道什麼是EF請看[EF(Asp.Net Entity Framework)做爲數據模型框架 與FLEX 的應用]
先看下界面
登錄窗口
密碼錯誤
驗證成功
LOGIN.mxml
id="loginRO"
source="PosServiceLibrary.login"
destination="fluorine"
showBusyCursor="true">
import mx.rpc.events.ResultEvent;
import mx.utils.ObjectUtil;
import mx.controls.Alert;
import mx.rpc.events.FaultEvent;
/* Call the login service*/
private function logIn():void{
//use remote object method setCredentials to
//enable Flex to send the values required
loginRO.logout();
loginRO.loginin(username.text, password.text)
}
/*Call logout*/
private function logOut():void
{
loginRO.logout();
appViews.selectedChild = loginView;
}
/* Display error messages returned */
private function serverFault(event:FaultEvent):void{
Alert.show( ObjectUtil.toString(event.fault.faultString), "Error", mx.controls.Alert.OK );
}
private function loginResult(event:ResultEvent):void {
var result:Boolean = event.result as Boolean;
if (result) appViews.selectedChild = secureView;
else
Alert.show( "密碼錯誤", "Error", mx.controls.Alert.OK );
}
private function loginFault(event:FaultEvent):void{
//Alert.show("Authentication failed", "Errors", mx.controls.Alert.OK);
Alert.show( ObjectUtil.toString(event.fault), "Authentication failed" );
}
private function getSecureDataResult(event:ResultEvent):void {
var result:String = event.result as String;
Alert.show(result, "Secure data", mx.controls.Alert.OK);
}
]]>
enabled="{(username.text.length == 0 || password.text.length == 0) ? false : true}"
toolTip="{loginButton.enabled == true ? 'Click to submit' : 'Enter username and password'}"
click="logIn()" />
-----------------------------------------------------------------
用了ado.net Entity Data Model
login.cs
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using FluorineFx;
using System.Data.OleDb;
using System.Data;
using System.Data.Linq;
using PosServiceLibrary.model;
namespace PosServiceLibrary
{
[RemotingService("Fluorine sample service")]
public class login
{
private posEntities pe = new posEntities();
public bool loginin(string name, string password)
{
var lo = from g in pe.Employees where g.E_NAME == name && g.E_PASSWORD == password select g;
if (lo.Count()!=0){return true;}else{return false;}
}
}
}
相關鏈接 :[Flex與FluorineFx的通信]
FLEX_riaedu.com 全國最大,資料最全的Ria富媒體 學習交流社區 Riaedu.com