|
Вопрос # 4 635/ вопрос открыт / |
|
Здравствуйте, уважаемые эксперты!
Подскажите пожалуйста. У меня есть две формы. На первой форме при нажатии кнопки должны данные из таблицы переноситься как бы в буфер и потом после того как на второй форме все заполнится и при нажатии кнопки Добавить акцию открывается третья форма где уже в таблице будет видно все данные из 1 и 2 формы . Как это сделать подскажите пожалуйста?
К вопросу прикреплён файл. Загрузить » (срок хранения: 60 дней с момента отправки вопроса)
Приложение: Переключить в обычный режим-
- unit Unit2;
-
- interface
-
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, Grids, DBGrids, DBXpress, FMTBcd, DBClient, SimpleDS, DB,
- SqlExpr, ExtCtrls, DBCtrls, StdCtrls;
-
- type
- TForm2 = class(TForm)
- SQLConnection2: TSQLConnection;
- Q2: TSQLQuery;
- StringGrid2: TStringGrid;
- ComboBox1: TComboBox;
- Label1: TLabel;
- Label3: TLabel;
- ComboBox3: TComboBox;
- Label4: TLabel;
- Edit1: TEdit;
- Button1: TButton;
- RadioGroup1: TRadioGroup;
- Button2: TButton;
- procedure FormActivate(Sender: TObject);
- procedure Button1Click(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- procedure Button2Click(Sender: TObject);
-
-
-
-
-
-
- private
- { Private declarations }
- public
- { Public declarations }
- end;
-
- var
- Form2: TForm2;
-
- implementation
-
- uses Unit4;
-
- {$R *.dfm}
-
-
- procedure TForm2.FormActivate(Sender: TObject);
- var q:integer;
-
- begin
- try
- Q2.Open;
- except
- on e:exception do showmessage(e.Message)
- end;
- stringgrid2.Visible:=false;
- stringgrid2.RowCount:=2;
- q:=1;
-
- while not Q2.Eof do
- begin
- StringGrid2.Cells[0,0]:= 'Ôàìèëèÿ';
- StringGrid2.Cells[1,0]:= 'Èìÿ';
- StringGrid2.Cells[2,0]:=
'Îò÷åñòâî';
- StringGrid2.Cells[3,0]:=
'Äîìàøíèé
òåëåôîí';
- StringGrid2.Cells[4,0]:= 'Ðàáî÷èé
òåëåôîí';
- StringGrid2.Cells[5,0]:=
'Ìîáèëüíûé
òåëåôîí';
- StringGrid2.Cells[6,0]:= 'Ïî÷òà';
- StringGrid2.Cells[7,0]:= 'Äàòà
ðîæäåíèÿ';
- StringGrid2.Cells[8,0]:=
'Ñåìåéíîå
ïîëîæåíèå';
- StringGrid2.Cells[9,0]:= 'Ñôåðà
äåÿòåëüíîñòè';
- StringGrid2.Cells[10,0]:= 'Ïîë';
-
- stringgrid2.Cells[0,q]:=Q2.fields[0].AsString;
- stringgrid2.Cells[1,q]:=Q2.fields[1].AsString;
- stringgrid2.Cells[2,q]:=Q2.fields[2].AsString;
- stringgrid2.Cells[3,q]:=Q2.fields[3].AsString;
- stringgrid2.Cells[4,q]:=Q2.fields[4].AsString;
- stringgrid2.Cells[5,q]:=Q2.fields[5].AsString;
- stringgrid2.Cells[6,q]:=Q2.fields[6].AsString;
- stringgrid2.Cells[7,q]:=Q2.fields[7].AsString;
- stringgrid2.Cells[8,q]:=Q2.fields[8].AsString;
- stringgrid2.Cells[9,q]:=Q2.fields[9].AsString;
- stringgrid2.Cells[10,q]:=Q2.fields[10].AsString;
-
-
- Q2.Next;
- inc(q);
- stringgrid2.RowCount:=q+2;
- end;
- stringgrid2.Visible:=true;
- if Q2.Active then Q2.Close;
-
- combobox1.Clear;
- Form2.Q2.SQL.Text:='select DISTINCT family_status from owner';
- Form2.Q2.Open;
- if Form2.Q2.Active then
- begin
- Form2.Q2.First;
- while not q2.Eof do
- BEGIN
- Form2.ComboBox1.Items.Add(Form2.Q2.FieldByName('family_status').AsString);
- Form2.Q2.Next;
- END;
- q2.Close;
- END;
-
-
- combobox3.Clear;
- Form2.Q2.SQL.Text:='select DISTINCT typeorg from owner';
- Form2.Q2.Open;
- if Form2.Q2.Active then
- begin
- Form2.Q2.First;
- while not q2.Eof do
- BEGIN
- Form2.ComboBox3.Items.Add(Form2.Q2.FieldByName('typeorg').AsString);
- Form2.Q2.Next;
- END;
- q2.Close;
- end;
-
-
-
-
-
-
- end;
-
-
-
-
-
- procedure TForm2.Button1Click(Sender: TObject);
- begin
- q2.SQL.Text:='select * from owner where DateDiff(year,date_of_birth,GetDate())='+Edit1.Text+' and
family_status ='+char(39)+Combobox1.Text+char(39)+' and TypeOrg =
'+char(39)+Combobox3.Text+char(39)+' and sex='+inttostr(RadioGroup1.Itemindex);
- q2.Open;
- form2.FormActivate(Sender);
- q2.Close;
- end;
-
-
-
- procedure TForm2.FormCreate(Sender: TObject);
- var
- x, y, w: integer;
- s: string;
- MaxWidth: integer;
- begin
- with StringGrid2 do
- ClientHeight := DefaultRowHeight * RowCount + 5;
- randomize;
- with StringGrid2 do begin
- for y := 0 to RowCount - 1 do
- for x := 0 to ColCount - 1 do begin
- s := '';
- for w := 0 to random(20) do
- s := s + chr(ord('a') + random(26));
- Cells[x,y] := s;
- end;
-
- Canvas.Font := Font;
- for x := 0 to ColCount - 1 do begin
- MaxWidth := 0;
- for y := 0 to RowCount - 1 do begin
- w := Canvas.TextWidth(Cells[x,y]);
- if w > MaxWidth then MaxWidth := w;
- end;
- ColWidths[x] := MaxWidth + 5;
-
- end;
- end;
- end;
-
-
-
- procedure TForm2.Button2Click(Sender: TObject);
- begin
- Q2.SQL.Text:='use bonus_dbTest go declare @counts int select @counts = count(distinct field_id) from
act_new where active=1 if @counts<4 then begin insert into act_new() values() alter table
dbo.spiski add act_4 bit not null constraint df_spiski_act_4 default 0';
- Form4:= TForm4.Create(Application);
- Form4.Caption:= 'Íîâàÿ
àêöèÿ';
- Form4.Enabled:=true;
- form4.Show;
- Form2.Close;
- Form4.Button2.Enabled:=true;
- q2.Close;
- end;
- end.
-
-
-
- unit Unit4;
-
- interface
-
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, ComCtrls, StdCtrls, DBXpress, FMTBcd, DB, SqlExpr;
-
- type
- TForm4 = class(TForm)
- Label1: TLabel;
- Label2: TLabel;
- DateTimePicker1: TDateTimePicker;
- Button1: TButton;
- Label3: TLabel;
- DateTimePicker2: TDateTimePicker;
- Label4: TLabel;
- Button2: TButton;
- Edit3: TEdit;
- Label5: TLabel;
- SQLConnection1: TSQLConnection;
- Q6: TSQLQuery;
- Memo1: TMemo;
- Memo2: TMemo;
- procedure Button1Click(Sender: TObject);
- procedure Edit3KeyPress(Sender: TObject; var Key: Char);
- procedure Button2Click(Sender: TObject);
- procedure DateTimePicker1Change(Sender: TObject);
-
- private
- { Private declarations }
- public
- { Public declarations }
- end;
-
- var
- Form4: TForm4;
-
- implementation
-
- uses Unit2, Unit5, Unit1;
-
- {$R *.dfm}
-
- procedure TForm4.Button1Click(Sender: TObject);
- begin
- Form2:= TForm2.Create(Application);
- Form2.Caption:= 'Âûáîð
ó÷àñòíèêà';
- form2.Show;
- form4.visible:=false;
- end;
-
- procedure TForm4.Edit3KeyPress(Sender: TObject; var Key: Char);
- begin
- if (key='.')or(key=',')then key:=decimalseparator;
- if not (key in['0'..'9',decimalseparator,#8,#13]) then
- begin
- key:=#0;
- beep;
- end;
- end;
-
-
- procedure TForm4.Button2Click(Sender: TObject);
- begin
- q6.SQL.Text:='insert into act_new (name, description, date_begin, date_end, amount_bonus) values
(:name, :description, :date_begin, :date_end, :amount_bonus)';
- q6.Params[0].AsString := Memo2.Text;
- q6.Params[1].AsString := Memo1.Text;
- q6.Params[2].AsDate := DateTimePicker1.Date;
- q6.Params[3].AsDate := DateTimePicker2.Date;
- q6.Params[4].AsCurrency := StrToCurr(Edit3.Text);
- q6.Prepared := true;
- q6.ExecSQL;
- end;
-
- procedure TForm4.DateTimePicker1Change(Sender: TObject);
- begin
- q6.SQL.Text:='select date_begin, date_end from act_new convert(datetime, '+char(39)+'2010-10-01
16:20:21.710'+char(39)+' 121) -- yyyy-mm-dd hh:mm:ss.mmm';
- end;
-
- end.
-
-
-
- unit Unit1;
-
- interface
-
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, FMTBcd, DBXpress, DB, SqlExpr, Grids, DBGrids, StdCtrls,
- ExtCtrls, DBCtrls, DBClient, Provider, SimpleDS, Menus;
-
- type
- TForm1 = class(TForm)
- SQLConnection1: TSQLConnection;
- Q1: TSQLQuery;
- Button1: TButton;
- StringGrid1: TStringGrid;
- procedure Button1Click(Sender: TObject);
- procedure FormActivate(Sender: TObject);
- procedure StringGrid1DblClick(Sender: TObject);
- procedure Button2Click(Sender: TObject);
-
-
-
-
-
-
- private
- { Private declarations }
- public
- { Public declarations }
- end;
-
- var
- Form1: TForm1;
-
- implementation
-
- uses Unit2, Unit3, Unit4;
-
- {$R *.dfm}
-
-
-
-
-
-
-
-
-
-
- procedure TForm1.Button1Click(Sender: TObject);
- begin
- Form4:= TForm4.Create(Application);
- Form4.Caption:= 'Íîâàÿ
àêöèÿ';
- form4.Show;
-
- end;
-
- procedure TForm1.FormActivate(Sender: TObject);
- var i:integer;
- begin
- try
- Q1.Open;
- except
- on e: exception do showmessage(e.Message);
- end;
- stringgrid1.Visible:=false;
- i:=1;
-
-
-
-
- while not Q1.Eof do
- begin
-
-
- StringGrid1.Cells[0,0]:= 'Àêöèÿ';
- StringGrid1.Cells[1,0]:=
'Îïèñàíèå';
- StringGrid1.Cells[2,0]:= 'Äàòà
íà÷àëà';
- StringGrid1.Cells[3,0]:= 'Äàòà
îêîí÷àíèÿ';
- StringGrid1.Cells[4,0]:=
'Êîëè÷åñòâî
áîíóñîâ';
- StringGrid1.Cells[5,0]:=
'Àêòèâíûå';
- StringGrid1.Cells[6,0]:=
'Ïðàçäíè÷íûå';
-
-
-
- stringgrid1.Cells[0,i]:=q1.Fields[0].AsString;
- stringgrid1.Cells[1,i]:=q1.Fields[1].AsString;
- stringgrid1.Cells[2,i]:=q1.Fields[2].AsString;
- stringgrid1.Cells[3,i]:=q1.Fields[3].AsString;
- stringgrid1.Cells[4,i]:=q1.Fields[4].AsString;
- stringgrid1.Cells[5,i]:=q1.Fields[5].AsString;
- stringgrid1.Cells[6,i]:=q1.Fields[6].AsString;
-
- q1.Next;
- inc(i);
- stringgrid1.RowCount:=i+1;
- end;
- stringgrid1.Visible:=true;
- if q1.Active then q1.Close;
-
- end;
-
-
-
-
-
- procedure TForm1.StringGrid1DblClick(Sender: TObject);
- begin
- Form3:= TForm3.Create(Application);
- Form3.Caption:= 'Íîâàÿ
àêöèÿ';
- form3.Show;
- end;
-
- procedure TForm1.Button2Click(Sender: TObject);
- begin
- Form2:= TForm2.Create(Application);
- Form2.Caption:= 'Âûáîð';
- form2.Show;
- end;
- end.
-
-
-
 |
Вопрос задал: slai (статус: Посетитель)
Вопрос отправлен: 4 октября 2010, 06:50
Состояние вопроса: открыт, ответов: 0.
|
Мини-форум вопроса
Мини-форум пуст.
Чтобы оставлять сообщения в мини-форумах, Вы должны авторизироваться на сайте.
|