|
| 1 | +unit login; |
| 2 | + |
| 3 | +interface |
| 4 | + |
| 5 | +uses |
| 6 | + Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, |
| 7 | + Dialogs, cxLookAndFeelPainters, cxTextEdit, cxControls, cxContainer, |
| 8 | + cxEdit, cxMaskEdit, cxDropDownEdit, StdCtrls, cxButtons, ExtCtrls, |
| 9 | + cxLookupEdit, cxDBLookupEdit, cxDBLookupComboBox, cxGraphics, Menus, GIFImg, |
| 10 | + dxSkinsCore, dxSkinOffice2007Silver, cxLookAndFeels, dxSkinOffice2007Blue, |
| 11 | + dxSkinBlack, dxSkinBlue, dxSkinCaramel, dxSkinCoffee, dxSkinDarkRoom, |
| 12 | + dxSkinDarkSide, dxSkinFoggy, dxSkinGlassOceans, dxSkiniMaginary, dxSkinLilian, |
| 13 | + dxSkinLiquidSky, dxSkinLondonLiquidSky, dxSkinMcSkin, dxSkinMoneyTwins, |
| 14 | + dxSkinOffice2007Black, dxSkinOffice2007Green, dxSkinOffice2007Pink, |
| 15 | + dxSkinOffice2010Black, dxSkinOffice2010Blue, dxSkinOffice2010Silver, |
| 16 | + dxSkinPumpkin, dxSkinSeven, dxSkinSharp, dxSkinSilver, dxSkinSpringTime, |
| 17 | + dxSkinStardust, dxSkinSummer2008, dxSkinsDefaultPainters, dxSkinValentine, |
| 18 | + dxSkinXmas2008Blue, cxImage, dxGDIPlusClasses, dxSkinDevExpressStyle; |
| 19 | + |
| 20 | +type |
| 21 | + TformLogin = class(TForm) |
| 22 | + Panel1: TPanel; |
| 23 | + pnlDados: TPanel; |
| 24 | + Label1: TLabel; |
| 25 | + Label2: TLabel; |
| 26 | + edtSenha: TcxTextEdit; |
| 27 | + dlcUsuario: TcxLookupComboBox; |
| 28 | + pnlBotoes: TPanel; |
| 29 | + cxButton1: TcxButton; |
| 30 | + cxButton2: TcxButton; |
| 31 | + Bevel1: TBevel; |
| 32 | + cxImage1: TcxImage; |
| 33 | + procedure edtSenhaEnter(Sender: TObject); |
| 34 | + procedure edtSenhaExit(Sender: TObject); |
| 35 | + procedure cxButton2Click(Sender: TObject); |
| 36 | + procedure FormShow(Sender: TObject); |
| 37 | + procedure dlcUsuarioPropertiesCloseUp(Sender: TObject); |
| 38 | + procedure cxButton1Click(Sender: TObject); |
| 39 | + procedure FormKeyDown(Sender: TObject; var Key: Word; |
| 40 | + Shift: TShiftState); |
| 41 | + private |
| 42 | + { Private declarations } |
| 43 | + public |
| 44 | + { Public declarations } |
| 45 | + end; |
| 46 | + |
| 47 | +var |
| 48 | + formLogin: TformLogin; |
| 49 | + |
| 50 | +implementation |
| 51 | + |
| 52 | +uses principal; |
| 53 | + |
| 54 | +{$R *.dfm} |
| 55 | + |
| 56 | +procedure TformLogin.edtSenhaEnter(Sender: TObject); |
| 57 | +var |
| 58 | + i: word; |
| 59 | +begin |
| 60 | + if Sender is TcxLookupComboBox then |
| 61 | + begin |
| 62 | + TcxLookupComboBox(Sender).Style.Color := clInfoBk; |
| 63 | + TcxLookupComboBox(Sender).Style.Font.Style := [fsBold]; |
| 64 | + TcxLookupComboBox(Sender).Style.Shadow := True; |
| 65 | + end; |
| 66 | + |
| 67 | + if Sender is TcxTextEdit then |
| 68 | + begin |
| 69 | + TcxTextEdit(Sender).Style.Color := clInfoBk; |
| 70 | + TcxTextEdit(Sender).Style.Font.Style := [fsBold]; |
| 71 | + TcxTextEdit(Sender).Style.Shadow := True; |
| 72 | + end; |
| 73 | + |
| 74 | + { coloco o label em negrito } |
| 75 | + for i := 0 to ComponentCount -1 do |
| 76 | + if Components[i] is TLabel then |
| 77 | + if (Components[i] as TLabel).FocusControl = Sender then |
| 78 | + if (Components[i] as TLabel).Font.Color = clMaroon then |
| 79 | + (Components[i] as TLabel).Font.Style := [fsBold, fsUnderline] |
| 80 | + else |
| 81 | + (Components[i] as TLabel).Font.Style := [fsBold]; |
| 82 | +end; |
| 83 | + |
| 84 | +procedure TformLogin.edtSenhaExit(Sender: TObject); |
| 85 | +var |
| 86 | + i: word; |
| 87 | +begin |
| 88 | + if Sender is TcxLookupComboBox then |
| 89 | + begin |
| 90 | + TcxLookupComboBox(Sender).Style.Color := clWindow; |
| 91 | + TcxLookupComboBox(Sender).Style.Font.Style := []; |
| 92 | + TcxLookupComboBox(Sender).Style.Shadow := False; |
| 93 | + end; |
| 94 | + |
| 95 | + if Sender is TcxTextEdit then |
| 96 | + begin |
| 97 | + TcxTextEdit(Sender).Style.Color := clWindow; |
| 98 | + TcxTextEdit(Sender).Style.Font.Style := []; |
| 99 | + TcxTextEdit(Sender).Style.Shadow := False; |
| 100 | + end; |
| 101 | + |
| 102 | + { coloco o label em negrito } |
| 103 | + for i := 0 to ComponentCount -1 do |
| 104 | + if Components[i] is TLabel then |
| 105 | + if (Components[i] as TLabel).FocusControl = Sender then |
| 106 | + if (Components[i] as TLabel).Font.Color = clMaroon then |
| 107 | + (Components[i] as TLabel).Font.Style := [fsUnderline] |
| 108 | + else |
| 109 | + (Components[i] as TLabel).Font.Style := []; |
| 110 | +end; |
| 111 | + |
| 112 | +procedure TformLogin.cxButton2Click(Sender: TObject); |
| 113 | +begin |
| 114 | + close; |
| 115 | +end; |
| 116 | + |
| 117 | +procedure TformLogin.FormShow(Sender: TObject); |
| 118 | +begin |
| 119 | + dlcUsuario.SetFocus; |
| 120 | +end; |
| 121 | + |
| 122 | +procedure TformLogin.dlcUsuarioPropertiesCloseUp(Sender: TObject); |
| 123 | +begin |
| 124 | + if edtSenha.CanFocus then |
| 125 | + begin |
| 126 | + edtSenha.Clear; |
| 127 | + edtSenha.SetFocus; |
| 128 | + end; |
| 129 | +end; |
| 130 | + |
| 131 | +procedure TformLogin.cxButton1Click(Sender: TObject); |
| 132 | +begin |
| 133 | + formPrincipal.cdsUsuarios.Locate('EMAIL', |
| 134 | + dlcUsuario.Text, []); |
| 135 | + |
| 136 | + if (formPrincipal.cdsUsuarios.fieldByName('SENHAWEB').AsString = |
| 137 | + edtSenha.Text) then |
| 138 | + ModalResult := mrOk |
| 139 | + else |
| 140 | + begin |
| 141 | + formPrincipal.MsgError( |
| 142 | + 'Usu�rio ou Senha incorretos!', |
| 143 | + 'Login'); |
| 144 | + if edtSenha.CanFocus then |
| 145 | + edtSenha.SetFocus; |
| 146 | + end; |
| 147 | +end; |
| 148 | + |
| 149 | +procedure TformLogin.FormKeyDown(Sender: TObject; var Key: Word; |
| 150 | + Shift: TShiftState); |
| 151 | +begin |
| 152 | + if key = vk_Return then |
| 153 | + if shift = [] then Perform(wm_NextDlgCtl, 0, 0) else |
| 154 | + if shift = [ssShift] then Perform(wm_NextDlgCtl, 0, 0); |
| 155 | +end; |
| 156 | + |
| 157 | +end. |
0 commit comments