1 Star 0 Fork 0

qinix/SangyMed

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
U_Entreprise.pas 9.21 KB
一键复制 编辑 原始数据 按行查看 历史
MrGreen7 提交于 2018-04-24 18:12 . Date : 09/06/1439
unit U_Entreprise;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes,
System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, U_Base_Form,
FMX.StdCtrls, FMX.TabControl, FMX.Edit, FMX.ListBox,
FMX.Controls.Presentation, FMX.Effects, FMX.Objects;
type
TEtablissement = class(TBase_Form)
GroupBox1: TGroupBox;
ComboBox1: TComboBox;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Edit1: TEdit;
Edit2: TEdit;
ID_Contact: TTabControl;
TabItem1: TTabItem;
GroupBox2: TGroupBox;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
ComboBox2: TComboBox;
ComboBox3: TComboBox;
Edit3: TEdit;
Label12: TLabel;
Label13: TLabel;
Edit_Code_Wilaya: TEdit;
Edit_Code_Postal: TEdit;
GroupBox3: TGroupBox;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
Label11: TLabel;
Edit4: TEdit;
Edit6: TEdit;
Edit8: TEdit;
Edit5: TEdit;
Edit7: TEdit;
Button1: TButton;
Button2: TButton;
Button3: TButton;
InnerGlowEffect1: TInnerGlowEffect;
InnerGlowEffect2: TInnerGlowEffect;
InnerGlowEffect3: TInnerGlowEffect;
Rectangle1: TRectangle;
Rectangle2: TRectangle;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure ComboBox2Change(Sender: TObject);
procedure ComboBox3Change(Sender: TObject);
procedure Edit_Code_WilayaChange(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure ComboBox2MouseEnter(Sender: TObject);
procedure ComboBox1Change(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Etablissement: TEtablissement;
implementation
uses
U_DataModule, U_Main;
{$R *.fmx}
procedure WiliyaLoad(const Combo: TComboBox);
begin
// Open Alg
with DataModule1.FDQ_Wilaya do
begin
Active := False;
SQL.Clear;
SQL.Text := ('SELECT Nom FROM wilayas');
Active := True;
while not Eof do
begin
Combo.Items.Add(Fields.Fields[0].AsString);
Next;
end;
SQL.Clear;
Active := False;
end;
end;
procedure CommuneLoad(const Edit: TEdit; const Combo: TComboBox);
var
Code_P: string;
begin
Code_P := Edit.Text; // Edit_Code_Wiliya
Combo.Items.Clear; // Combobox3
with DataModule1.FDQ_Commune do
begin
Active := False;
SQL.Clear;
SQL.Text := ('SELECT Nom FROM communes WHERE `Code_Wilaya`="' +
Code_P + '"');
Active := True;
while not Eof do
begin
Combo.Items.Add(Fields.Fields[0].AsString); // Combobox3
Next;
end;
SQL.Clear;
Active := False;
end;
end;
procedure TEtablissement.Button1Click(Sender: TObject);
Var
MDlg: Integer;
begin
inherited;
if (Main.Privilege = True) then
Begin
if ((ComboBox1.Items.Text <> '') and (ComboBox2.Items.Text <> '') and
(ComboBox3.Items.Text <> '') and (Edit1.Text <> '') and (Edit3.Text <> '')
and (Edit_Code_Wilaya.Text <> '') and (Edit_Code_Postal.Text <> '')) then
begin
with DataModule1.FDQ_Entreprise do
begin
SQL.Clear;
SQL.Text := (' Select * From Etablissement ');
Active := True;
Edit;
FieldByName('Form_Juridique').AsString := ComboBox1.Selected.Text;
FieldByName('Wilaya').AsString := ComboBox2.Selected.Text;
FieldByName('Commune').AsString := ComboBox3.Selected.Text;
FieldByName('Libelle').AsString := Edit1.Text;
FieldByName('Libelle_Sec').AsString := Edit2.Text;
FieldByName('Adresse').AsString := Edit3.Text;
FieldByName('Telephone').AsString := Edit4.Text;
FieldByName('Mobile').AsString := Edit5.Text;
FieldByName('Fax').AsString := Edit6.Text;
FieldByName('Email').AsString := Edit7.Text;
FieldByName('Web').AsString := Edit8.Text;
FieldByName('Code_de_Wilaya').Value := Edit_Code_Wilaya.Text;
FieldByName('Code_Postal').Value := Edit_Code_Postal.Text;
Post;
SQL.Clear;
Active := False;
end;
Showmessage('Les information a t Enregistrer');
ModalResult := mrClose;
end
else
Begin
if (ComboBox1.ItemIndex = -1) then
Begin
InnerGlowEffect1.Enabled := True;
End;
if (ComboBox2.ItemIndex = -1) then
Begin
InnerGlowEffect2.Enabled := True;
End;
if (ComboBox3.ItemIndex = -1) then
Begin
InnerGlowEffect3.Enabled := True;
End;
MDlg := MessageDlg('''il vous plat rempli les champs necessaire',
TMsgDlgType.mtWarning, [TMsgDlgBtn.mbRetry], 0);
if (MDlg = mrRetry) then
Begin
ComboBox1.SetFocus;
End;
End;
End;
end;
procedure TEtablissement.Button2Click(Sender: TObject);
begin
inherited;
try
ModalResult := mrCancel;
except
on E: Exception do
begin
Etablissement.Close;
end;
end;
end;
procedure TEtablissement.Button3Click(Sender: TObject);
begin
inherited;
if (Main.Privilege = True) then
Begin
ComboBox1.HitTest := True;
ComboBox2.HitTest := True;
ComboBox3.HitTest := True;
ComboBox1.Clear;
ComboBox2.Clear;
ComboBox3.Clear;
ComboBox1.Items.Add('EPH');
ComboBox1.Items.Add('EPSP');
WiliyaLoad(ComboBox2);
Edit_Code_Wilaya.Text := '';
Edit_Code_Postal.Text := '';
CommuneLoad(Edit_Code_Wilaya, ComboBox3);
Edit1.HitTest := True;
Edit2.HitTest := True;
Edit3.HitTest := True;
Edit4.HitTest := True;
Edit5.HitTest := True;
Edit6.HitTest := True;
Edit7.HitTest := True;
Edit8.HitTest := True;
ComboBox1.SetFocus;
end
else
MessageDlg
('Ce type de compte n''est pas autoris modifier ce type de paramtre',
TMsgDlgType.mtWarning, [TMsgDlgBtn.mbOK], 0);
end;
procedure TEtablissement.ComboBox1Change(Sender: TObject);
begin
inherited;
if (ComboBox1.ItemIndex <> -1) then
InnerGlowEffect1.Enabled := False;
end;
procedure TEtablissement.ComboBox2Change(Sender: TObject);
begin
inherited;
if (ComboBox2.ItemIndex <> -1) then
InnerGlowEffect2.Enabled := False;
with DataModule1.FDQ_Wilaya do
begin
Active := False;
SQL.Clear;
SQL.Text := ('SELECT Code_Wilaya, Nom FROM wilayas');
Active := True;
Locate('Nom', ComboBox2.Selected.Text, []);
Edit_Code_Wilaya.Text := FieldByName('Code_Wilaya').AsString;
SQL.Clear;
Active := False;
end;
end;
procedure TEtablissement.ComboBox2MouseEnter(Sender: TObject);
begin
inherited;
if (ComboBox2.Items.Capacity = 0) then
WiliyaLoad(ComboBox2);
end;
procedure TEtablissement.ComboBox3Change(Sender: TObject);
begin
inherited;
if (ComboBox3.ItemIndex <> -1) then
InnerGlowEffect3.Enabled := False;
with DataModule1.FDQ_Commune do
begin
Active := False;
SQL.Clear;
SQL.Text := ('SELECT Code_Postal, Nom FROM communes');
Active := True;
Locate('Nom', ComboBox3.Selected.Text, []);
Edit_Code_Postal.Text := FieldByName('Code_Postal').Value;
Active := False;
end;
end;
procedure TEtablissement.Edit_Code_WilayaChange(Sender: TObject);
var
Code_P: string;
begin
inherited;
CommuneLoad(Edit_Code_Wilaya, ComboBox3);
end;
procedure TEtablissement.FormShow(Sender: TObject);
var
Existed: boolean;
begin
inherited;
if (Main.Privilege = False) then
Button1.Enabled := False
else if (Main.Privilege = True) then
Button1.Enabled := True;
with DataModule1.FDQ_Entreprise do
begin
SQL.Text := ('Select * From Etablissement');
Active := True;
if (FieldByName('Etab_ID').AsString <> '') then
Existed := True
else
Existed := False;
if (Existed = True) then
begin
Open;
ComboBox1.Items.Text := FieldByName('Form_Juridique').AsString;
ComboBox1.ItemIndex := 0;
ComboBox2.Items.Text := FieldByName('Wilaya').AsString;
ComboBox2.ItemIndex := 0;
Edit1.Text := FieldByName('Libelle').AsString;
Edit2.Text := FieldByName('Libelle_Sec').AsString;
Edit3.Text := FieldByName('Adresse').AsString;
Edit4.Text := FieldByName('Telephone').AsString;
Edit5.Text := FieldByName('Mobile').AsString;
Edit6.Text := FieldByName('Fax').AsString;
Edit7.Text := FieldByName('Email').AsString;
Edit8.Text := FieldByName('Web').AsString;
Edit_Code_Wilaya.Text := FieldByName('Code_de_Wilaya').Value;
Edit_Code_Postal.Text := FieldByName('Code_Postal').Value;
if (Edit_Code_Wilaya.Text <> '') then
begin
ComboBox3.Items.Text := FieldByName('Commune').AsString;
ComboBox3.ItemIndex := 0;
end;
ComboBox1.HitTest := False;
ComboBox2.HitTest := False;
ComboBox3.HitTest := False;
Edit1.HitTest := False;
Edit2.HitTest := False;
Edit3.HitTest := False;
Edit4.HitTest := False;
Edit5.HitTest := False;
Edit6.HitTest := False;
Edit7.HitTest := False;
Edit8.HitTest := False;
end;
end;
end;
end.
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/qinix2/SangyMed.git
git@gitee.com:qinix2/SangyMed.git
qinix2
SangyMed
SangyMed
master

搜索帮助