1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
| <?xml version="1.0" encoding="utf-8"?>
<s:Group xmlns:usersservice="services.usersservice.*"
xmlns:valueObjects="valueObjects.*">
<fx:Script>
<![CDATA[
import valueObjects.Users;
internal var login:String;
internal var droits:int;
public function validEnregistrement():void
{
var mail:String = mailbox_user.text;
Alert.yesLabel = "Enregistrer";
Alert.buttonWidth = 80;
Alert.noLabel = "Retour";
Alert.show("* Vérifiez la validité de l'adresse e-mail : " +mail+"\n\n*Cliquez :" +
"\n\n'Enregistrer' pour créer le nouvel utilisateur, \n'Retour' pour modifier les informations ",
"Validation e-mail",
(Alert.YES | Alert.NO),
this,
alertModif);
}
public function alertModif(e:CloseEvent):void
{
switch (e.detail){
case Alert.YES:
validerAjout(null);
break;
case Alert.NO:
cancelClick();
break;
}
}
public function validerAjout(event:MouseEvent):void
{
var nom:String = last_name_user.text;
var prenom:String = first_name_user.text;
var tel:String = telephone_number_user.text;
droits = saisieDroit.selectedItem.ID_PERMISSION;
var nom1:String = '';//nom sans les espaces
var mdp:String = "xxx";
for (var i:int = 0;i< nom.length; i++)
{
if (nom.charCodeAt(i)!= 32)
{
nom1 = nom1 + nom.charAt(i);
}
}
login =(prenom.charAt(0) + nom1).toLowerCase() //concatenation 1ere lettre prenom + nom sans espaces, le tout en minuscules
var user:Users = new Users();
user.FIRST_NAME_USER = first_name_user.text;
user.LAST_NAME_USER = last_name_user.text;
user.LOGIN_USER = login;
user.MAILBOX_USER = mailbox_user.text;
user.TELEPHONE_NUMBER_USER = telephone_number_user.text;
user.PASSWORD_USER = "xxx";
user.VALID_USER = 1;
user.ID_PERMISSION = droits;
users = user;
creationUser(users); //CREAATION DE L'USER
Alert.show(nom1+"\n"+login+"\ndroits : "+user.ID_PERMISSION,"Récapitulatif");
}
protected function creationUser(item:Users):void
{
createUsersResult.token = usersService.createUsers(item);
}
]]>
</fx:Script>
<fx:Declarations>
<valueObjects:Users id="users"/>
<s:CallResponder id="createUsersResult"
result="users.ID_USER = createUsersResult.lastResult.ID_USER;
Alert.show('user crée');" />
<usersservice:UsersService id="usersService" fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)" showBusyCursor="true"/>
</fx:Declarations>
<mx:ApplicationControlBar dock="true" paddingBottom="0" paddingTop="0"
x.userList="49" y.userList="624" width.userList="1092"
height.userList="32">
<mx:FormItem includeIn="userList" y="2" width="186" height="26"
label="Nom :" fontWeight="bold">
<s:TextInput id="last_name_user" width="124" enabled="true"
fontWeight="normal"
width.userList="133"/>
</mx:FormItem>
<mx:FormItem includeIn="userList" x="327" y="1"
width="194" height="27"
label="Prénom :"
fontWeight="bold">
<s:TextInput id="first_name_user"
width="122" enabled="true" fontWeight="normal"
/>
</mx:FormItem>
<mx:FormItem includeIn="userList" y="2" width="181"
height="26" label="Téléphone :"
fontWeight="bold">
<s:TextInput id="telephone_number_user" width="96"
enabled="true" fontWeight="normal"
/>
</mx:FormItem>
<mx:FormItem includeIn="userList" x="728" y="0" width="219" height="29"
label="Droits :"
fontWeight="bold">
<s:DropDownList id="saisieDroit" includeIn="userList" width="150" height="22"
creationComplete="saisieDroit_creationCompleteHandler(event)"
enabled="true" labelField="PERMISSION">
<s:AsyncListView list="{getAllPermissionsResult3.lastResult}"/>
</s:DropDownList>
</mx:FormItem>
<mx:FormItem includeIn="userList" x="938" y="2" width="181" height="25"
label="Mail :"
fontWeight="bold">
<s:TextInput id="mailbox_user" enabled="true" fontWeight="normal"
/>
</mx:FormItem>
<s:Button id="button" label="Valider" click="validEnregistrement()"
width.userList="69"/>
</mx:ApplicationControlBar>
</s:Group> |
Partager