안냐세요
먼저 소스 좀 봐주세요...
아래에 보면 나이계산과 남녀구별하는 부분이 있습니다.
이 두부분을 변경하고 싶은데요.... 소스를 좀 도와주세요...
지금 Combobox를 이용하여 선택하면 DBGrid에 뿌려주는 형식입니다.
그런데 DB에는 Age필드와 Sex필드는 없어서 현디비 뒤어 추가로 만들었습니다.
나이와 성별을 계산후 자동으로 새로운 필드인 Sex나 Age필드에 각각의 레코드의 값을 넣어두고 싶습니다.
즉, 구한 값을 Age,Sex필드에 넣어서 그것을 Combobox에서 선택하면 되지 않을까 싶은데요....
소스좀 보시고, 쉽게 아주 쉽게 너무 쉬워서 초보라도 한 눈에 보고 이해할수 있을정도로 가르쳐 주시면 넘 감사하겠습니다.
unit Unit27;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Grids, DBGrids, StdCtrls, ExtCtrls, Db, DBTables, Mask, DBCtrls, ComCtrls,
TeEngine, Series, TeeProcs, Chart, DBChart;
type
TForm27 = class(TForm)
Panel1: TPanel;
Label1: TLabel;
Button25: TButton;
Button26: TButton;
Button1: TButton;
DBNavigator1: TDBNavigator;
Button2: TButton;
Edit1: TEdit;
Panel2: TPanel;
Label3: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
Label11: TLabel;
Label12: TLabel;
Label13: TLabel;
Label14: TLabel;
DBEdit9: TDBEdit;
PageControl1: TPageControl;
TabSheet1: TTabSheet;
Label2: TLabel;
Label4: TLabel;
Edit2: TEdit;
Panel3: TPanel;
Label16: TLabel;
ComboBox1: TComboBox;
TabSheet2: TTabSheet;
Label15: TLabel;
Label17: TLabel;
Label18: TLabel;
Label19: TLabel;
Edit4: TEdit;
Edit5: TEdit;
TabSheet3: TTabSheet;
Label21: TLabel;
Label22: TLabel;
Panel4: TPanel;
Label20: TLabel;
Edit6: TEdit;
Edit7: TEdit;
TabSheet4: TTabSheet;
Label24: TLabel;
Label25: TLabel;
Panel5: TPanel;
Label23: TLabel;
Edit8: TEdit;
Edit9: TEdit;
TabSheet5: TTabSheet;
Label27: TLabel;
Label28: TLabel;
Panel6: TPanel;
Label26: TLabel;
Edit10: TEdit;
Edit11: TEdit;
DBGrid1: TDBGrid;
DataSource1: TDataSource;
DBEdit10: TDBEdit;
DBEdit11: TDBEdit;
DBEdit1: TDBEdit;
DBEdit2: TDBEdit;
DBEdit3: TDBEdit;
DBEdit4: TDBEdit;
DBEdit5: TDBEdit;
DBEdit6: TDBEdit;
DBEdit7: TDBEdit;
DBEdit8: TDBEdit;
Table1: TTable;
Edit3: TEdit;
Panel8: TPanel;
Label30: TLabel;
ComboBox3: TComboBox;
ComboBox4: TComboBox;
ComboBox5: TComboBox;
ComboBox6: TComboBox;
Table1StringField: TStringField;
Table1StringField2: TStringField;
Table1StringField3: TStringField;
Table1StringField4: TStringField;
Table1StringField5: TStringField;
Table1StringField6: TStringField;
Table1StringField7: TStringField;
Table1StringField8: TStringField;
Table1StringField9: TStringField;
Table1StringField10: TStringField;
Table1StringField11: TStringField;
Table1StringField12: TStringField;
Table1Sex: TStringField;
Edit12: TEdit;
Edit13: TEdit;
Button3: TButton;
Button4: TButton;
procedure Button25Click(Sender: TObject);
procedure Button26Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure ComboBox3Change(Sender: TObject);
procedure Table1AfterOpen(DataSet: TDataSet);
procedure ComboBox4Change(Sender: TObject);
procedure ComboBox6Change(Sender: TObject);
procedure ComboBox1Change(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Table1BeforePost(DataSet: TDataSet);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form27: TForm27;
implementation
uses Unit4, Unit1;
{$R *.DFM}
procedure TForm27.Button25Click(Sender: TObject);
begin
form27.hide;
form4.show;
end;
procedure TForm27.Button26Click(Sender: TObject);
begin
form27.hide;
form1.show;
end;
procedure TForm27.Button1Click(Sender: TObject);
begin
if Table1.Locate('이름',Edit1.Text,[lopartialkey])
=False then
showMessage('검색한 인원의 찾을 수 없습니다');
end;
procedure TForm27.Button2Click(Sender: TObject);
begin
close;
end;
procedure TForm27.ComboBox3Change(Sender: TObject);
var
i,t:integer;
begin
Table1.Filtered :=false;
t:=table1.RecordCount ;
edit4.text:= IntTostr(Table1.RecordCount);
if t>0then begin
case combobox3.ItemIndex of
0 : begin
table1.Filtered := false;
edit4.text:= IntTostr(Table1.RecordCount);
edit5.text:='';
end;
1 : begin
table1.Filtered := false;
table1.Filter := '세대주 = ''세''';
table1.Filtered := true;
i:=Table1.RecordCount;
edit4.text:=IntTostr(Table1.RecordCount);
edit5.text:=FloatTostr(trunc((i/t*100)*100+0.5)/100)+'%';
end;
end;
end;
end;
procedure TForm27.Table1AfterOpen(DataSet: TDataSet);
begin
Edit4.text:=IntTostr(Table1.RecordCount);
end;
procedure TForm27.ComboBox4Change(Sender: TObject);
var
i,t:integer;
begin
Table1.Filtered :=false;
t:=table1.RecordCount ;
edit6.text:= IntTostr(Table1.RecordCount);
if t>0then begin
case combobox4.ItemIndex of
0 : begin
table1.Filtered := false;
edit6.text:= IntTostr(Table1.RecordCount);
edit7.text:='';
end;
1 : begin
table1.Filtered := false;
table1.Filter := '직업 = ''상업''';
table1.Filtered := true;
i:=Table1.RecordCount;
edit7.text:=FloatTostr(trunc((i/t*100)*100+0.5)/100)+'%';
edit6.text:= IntTostr(Table1.RecordCount);
end;
2 : begin
table1.Filtered := false;
table1.Filter := '직업 = ''수산업''';
table1.Filtered := true;
i:=Table1.RecordCount;
edit6.text:= IntTostr(Table1.RecordCount);
edit7.text:=FloatTostr(trunc((i/t*100)*100+0.5)/100)+'%';
end;
3 : begin
table1.Filtered := false;
table1.Filter := '직업 = ''서비스업''';
table1.Filtered := true;
i:=Table1.RecordCount;
edit6.text:= IntTostr(Table1.RecordCount);
edit7.text:=FloatTostr(trunc((i/t*100)*100+0.5)/100)+'%';
end;
4 : begin
table1.Filtered := false;
table1.Filter := '직업 = ''공무원''';
table1.Filtered := true;
i:=Table1.RecordCount;
edit6.text:= IntTostr(Table1.RecordCount);
edit7.text:=FloatTostr(trunc((i/t*100)*100+0.5)/100)+'%';
end;
5 : begin
table1.Filtered := false;
table1.Filter := '직업 = ''회사원''';
table1.Filtered := true;
i:=Table1.RecordCount;
edit6.text:= IntTostr(Table1.RecordCount);
edit7.text:=FloatTostr(trunc((i/t*100)*100+0.5)/100)+'%';
end;
6 : begin
table1.Filtered := false;
table1.Filter := '직업 = ''학생''';
table1.Filtered := true;
i:=Table1.RecordCount;
edit6.text:= IntTostr(Table1.RecordCount);
edit7.text:=FloatTostr(trunc((i/t*100)*100+0.5)/100)+'%';
end;
7 : begin
table1.Filtered := false;
table1.Filter := '직업 = ''기타''';
table1.Filtered := true;
i:=Table1.RecordCount;
edit6.text:= IntTostr(Table1.RecordCount);
edit7.text:=FloatTostr(trunc((i/t*100)*100+0.5)/100)+'%';
end;
end;
end;
end;
procedure TForm27.ComboBox6Change(Sender: TObject);
var
i,t:integer;
begin
Table1.Filtered :=false;
t:=table1.RecordCount ;
edit10.text:= IntTostr(Table1.RecordCount);
if t>0then begin
case combobox6.ItemIndex of
0 : begin
table1.Filtered := false;
edit10.text:= IntTostr(Table1.RecordCount);
edit11.text:='';
end;
1 : begin
table1.Filtered := false;
table1.Filter := '분석 = ''A''';
table1.Filtered := true;
i:=Table1.RecordCount;
edit10.text:= IntTostr(Table1.RecordCount);
edit11.text:=FloatTostr(trunc((i/t*100)*100+0.5)/100)+'%';
end;
2 : begin
table1.Filtered := false;
table1.Filter := '분석 = ''B''';
table1.Filtered := true;
i:=Table1.RecordCount;
edit10.text:= IntTostr(Table1.RecordCount);
edit11.text:=FloatTostr(trunc((i/t*100)*100+0.5)/100)+'%'; end;
3 : begin
table1.Filtered := false;
table1.Filter := '분석 = ''C''';
table1.Filtered := true;
i:=Table1.RecordCount;
edit10.text:= IntTostr(Table1.RecordCount);
edit11.text:=FloatTostr(trunc((i/t*100)*100+0.5)/100)+'%';
end;
4 : begin
table1.Filtered := false;
table1.Filter := '분석 = ''D''';
table1.Filtered := true;
i:=Table1.RecordCount;
edit10.text:= IntTostr(Table1.RecordCount);
edit11.text:=FloatTostr(trunc((i/t*100)*100+0.5)/100)+'%';
end;
5 : begin
table1.Filtered := false;
table1.Filter := '분석 = ''E''';
table1.Filtered := true;
edit10.text:= IntTostr(Table1.RecordCount);
i:=Table1.RecordCount;
edit11.text:=FloatTostr(trunc((i/t*100)*100+0.5)/100)+'%';
end;
6 : begin
table1.Filtered := false;
table1.Filter := '분석 = ''F''';
table1.Filtered := true;
edit10.text:= IntTostr(Table1.RecordCount);
i:=Table1.RecordCount;
edit11.text:=FloatTostr(trunc((i/t*100)*100+0.5)/100)+'%';
end;
end;
end;
end;
procedure TForm27.ComboBox1Change(Sender: TObject);
var
i,t:integer;
begin
Table1.Filtered :=false;
t:=table1.RecordCount ;
edit2.text:= IntTostr(Table1.RecordCount);
if t>0then begin
case combobox1.ItemIndex of
0 : begin
table1.Filtered := false;
edit2.text:= IntTostr(Table1.RecordCount);
edit3.text:='';
end;
1 : begin
table1.Filtered := false;
table1.Filter := 'sex = ''남자''';
table1.Filtered := true;
i:=Table1.RecordCount;
edit2.text:=IntTostr(Table1.RecordCount);
edit3.text:=FloatTostr(trunc((i/t*100)*100+0.5)/100)+'%';
end;
2 : begin
table1.Filtered := false;
table1.Filter := 'sex = ''여자''';
table1.Filtered := true;
i:=Table1.RecordCount;
edit2.text:=IntTostr(Table1.RecordCount);
edit3.text:=FloatTostr(trunc((i/t*100)*100+0.5)/100)+'%';
end;
end;
end;
end;
procedure TForm27.Button3Click(Sender: TObject);
var
reply:String;
s:string;
begin
reply:=copy(Table1.fieldByName('주민등록번호').AsString,8,1);
if (reply='1')or(reply='3') then
begin
Table1.edit;
Table1.FieldByName('sex').AsString:='남자';
Table1.Post;
end
else if (reply='2') or(reply='4') then
begin
Table1.Edit;
Table1.FieldByName('sex').AsString:='여자';
Table1.Post;
end
else
showMessage('오류^^;');
end;
procedure TForm27.Button4Click(Sender: TObject);
var
yy,mmdd,nowyy,nowmmdd:string;
reply:string;
a,yy1,mm1,dd1:integer;
begin
yy:=copy(Table1.fieldByName('주민등록번호').AsString,1,2);
mmdd:=copy(Table1.FieldByName('주민등록번호').AsString,3,4);
reply:=copy(Table1.FieldByName('주민등록번호').AsString,8,1);
if (reply='1')or(reply='2')then
yy:='19'+yy
else if(reply='3')or(reply='4') then
yy:='20'+yy
else begin
ShoWmessage('오류^^;');
exit;
end;
nowyy:=formatDateTime('yyyy',Date);
nowmmdd:=FormatDateTime('mm',Date)+FormatDateTime('dd',Date);
if nowmmdd<=mmdd then
a:=InttoStr(StrtoInt(nowyy)-StrtoInt(yy)-1)
Table1.FieldByName('age').AsInteger:=a;
else
a:=InttoStr(StrtoInt(nowyy)-Strtoint(yy));
Table1.FieldByName('age').AsInteger:=a;
end;
procedure TForm27.Table1BeforePost(DataSet: TDataSet);
var
reply:String;
s:string;
begin
reply:=copy(Table1.fieldByName('주민등록번호').AsString,8,1);
if (reply='1')or(reply='3') then
begin
Table1.edit;
Table1.FieldByName('sex').AsString:='남자';
Table1.Post;
end
else if (reply='2') or(reply='4') then
begin
Table1.Edit;
Table1.FieldByName('sex').AsString:='여자';
Table1.Post;
end
else
showMessage('오류^^;');
end;
END.
> 안냐세요
> 먼저 소스 좀 봐주세요...
> 아래에 보면 나이계산과 남녀구별하는 부분이 있습니다.
> 이 두부분을 변경하고 싶은데요.... 소스를 좀 도와주세요...
>
> 지금 Combobox를 이용하여 선택하면 DBGrid에 뿌려주는 형식입니다.
> 그런데 DB에는 Age필드와 Sex필드는 없어서 현디비 뒤어 추가로 만들었습니다.
> 나이와 성별을 계산후 자동으로 새로운 필드인 Sex나 Age필드에 각각의 레코드의 값을 넣어두고 싶습니다.
> 즉, 구한 값을 Age,Sex필드에 넣어서 그것을 Combobox에서 선택하면 되지 않을까 싶은데요....
>
> 소스좀 보시고, 쉽게 아주 쉽게 너무 쉬워서 초보라도 한 눈에 보고 이해할수 있을정도로 가르쳐 주시면 넘 감사하겠습니다.
>
> unit Unit27;
>
> interface
>
> uses
> Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
> Grids, DBGrids, StdCtrls, ExtCtrls, Db, DBTables, Mask, DBCtrls, ComCtrls,
> TeEngine, Series, TeeProcs, Chart, DBChart;
>
> type
> TForm27 = class(TForm)
> Panel1: TPanel;
> Label1: TLabel;
> Button25: TButton;
> Button26: TButton;
> Button1: TButton;
> DBNavigator1: TDBNavigator;
> Button2: TButton;
> Edit1: TEdit;
> Panel2: TPanel;
> Label3: TLabel;
> Label5: TLabel;
> Label6: TLabel;
> Label7: TLabel;
> Label8: TLabel;
> Label9: TLabel;
> Label10: TLabel;
> Label11: TLabel;
> Label12: TLabel;
> Label13: TLabel;
> Label14: TLabel;
> DBEdit9: TDBEdit;
> PageControl1: TPageControl;
> TabSheet1: TTabSheet;
> Label2: TLabel;
> Label4: TLabel;
> Edit2: TEdit;
> Panel3: TPanel;
> Label16: TLabel;
> ComboBox1: TComboBox;
> TabSheet2: TTabSheet;
> Label15: TLabel;
> Label17: TLabel;
> Label18: TLabel;
> Label19: TLabel;
> Edit4: TEdit;
> Edit5: TEdit;
> TabSheet3: TTabSheet;
> Label21: TLabel;
> Label22: TLabel;
> Panel4: TPanel;
> Label20: TLabel;
> Edit6: TEdit;
> Edit7: TEdit;
> TabSheet4: TTabSheet;
> Label24: TLabel;
> Label25: TLabel;
> Panel5: TPanel;
> Label23: TLabel;
> Edit8: TEdit;
> Edit9: TEdit;
> TabSheet5: TTabSheet;
> Label27: TLabel;
> Label28: TLabel;
> Panel6: TPanel;
> Label26: TLabel;
> Edit10: TEdit;
> Edit11: TEdit;
> DBGrid1: TDBGrid;
> DataSource1: TDataSource;
> DBEdit10: TDBEdit;
> DBEdit11: TDBEdit;
> DBEdit1: TDBEdit;
> DBEdit2: TDBEdit;
> DBEdit3: TDBEdit;
> DBEdit4: TDBEdit;
> DBEdit5: TDBEdit;
> DBEdit6: TDBEdit;
> DBEdit7: TDBEdit;
> DBEdit8: TDBEdit;
> Table1: TTable;
> Edit3: TEdit;
> Panel8: TPanel;
> Label30: TLabel;
> ComboBox3: TComboBox;
> ComboBox4: TComboBox;
> ComboBox5: TComboBox;
> ComboBox6: TComboBox;
> Table1StringField: TStringField;
> Table1StringField2: TStringField;
> Table1StringField3: TStringField;
> Table1StringField4: TStringField;
> Table1StringField5: TStringField;
> Table1StringField6: TStringField;
> Table1StringField7: TStringField;
> Table1StringField8: TStringField;
> Table1StringField9: TStringField;
> Table1StringField10: TStringField;
> Table1StringField11: TStringField;
> Table1StringField12: TStringField;
> Table1Sex: TStringField;
> Edit12: TEdit;
> Edit13: TEdit;
> Button3: TButton;
> Button4: TButton;
> procedure Button25Click(Sender: TObject);
> procedure Button26Click(Sender: TObject);
> procedure Button1Click(Sender: TObject);
> procedure Button2Click(Sender: TObject);
> procedure ComboBox3Change(Sender: TObject);
> procedure Table1AfterOpen(DataSet: TDataSet);
> procedure ComboBox4Change(Sender: TObject);
> procedure ComboBox6Change(Sender: TObject);
> procedure ComboBox1Change(Sender: TObject);
> procedure Button3Click(Sender: TObject);
> procedure Button4Click(Sender: TObject);
> procedure Table1BeforePost(DataSet: TDataSet);
>
>
> private
> { Private declarations }
> public
> { Public declarations }
> end;
>
> var
> Form27: TForm27;
>
> implementation
>
> uses Unit4, Unit1;
>
> {$R *.DFM}
>
> procedure TForm27.Button25Click(Sender: TObject);
> begin
> form27.hide;
> form4.show;
> end;
>
> procedure TForm27.Button26Click(Sender: TObject);
> begin
> form27.hide;
> form1.show;
> end;
>
> procedure TForm27.Button1Click(Sender: TObject);
> begin
> if Table1.Locate('이름',Edit1.Text,[lopartialkey])
> =False then
> showMessage('검색한 인원의 찾을 수 없습니다');
> end;
>
> procedure TForm27.Button2Click(Sender: TObject);
> begin
> close;
> end;
>
>
>
> procedure TForm27.ComboBox3Change(Sender: TObject);
> var
> i,t:integer;
> begin
> Table1.Filtered :=false;
> t:=table1.RecordCount ;
> edit4.text:= IntTostr(Table1.RecordCount);
> if t>0then begin
> case combobox3.ItemIndex of
> 0 : begin
> table1.Filtered := false;
> edit4.text:= IntTostr(Table1.RecordCount);
> edit5.text:='';
> end;
>
> 1 : begin
> table1.Filtered := false;
> table1.Filter := '세대주 = ''세''';
> table1.Filtered := true;
> i:=Table1.RecordCount;
> edit4.text:=IntTostr(Table1.RecordCount);
> edit5.text:=FloatTostr(trunc((i/t*100)*100+0.5)/100)+'%';
> end;
> end;
> end;
> end;
>
>
>
> procedure TForm27.Table1AfterOpen(DataSet: TDataSet);
> begin
> Edit4.text:=IntTostr(Table1.RecordCount);
> end;
>
> procedure TForm27.ComboBox4Change(Sender: TObject);
> var
> i,t:integer;
> begin
> Table1.Filtered :=false;
> t:=table1.RecordCount ;
> edit6.text:= IntTostr(Table1.RecordCount);
> if t>0then begin
> case combobox4.ItemIndex of
> 0 : begin
> table1.Filtered := false;
> edit6.text:= IntTostr(Table1.RecordCount);
> edit7.text:='';
> end;
>
> 1 : begin
> table1.Filtered := false;
> table1.Filter := '직업 = ''상업''';
> table1.Filtered := true;
> i:=Table1.RecordCount;
> edit7.text:=FloatTostr(trunc((i/t*100)*100+0.5)/100)+'%';
> edit6.text:= IntTostr(Table1.RecordCount);
> end;
> 2 : begin
> table1.Filtered := false;
> table1.Filter := '직업 = ''수산업''';
> table1.Filtered := true;
> i:=Table1.RecordCount;
> edit6.text:= IntTostr(Table1.RecordCount);
> edit7.text:=FloatTostr(trunc((i/t*100)*100+0.5)/100)+'%';
> end;
> 3 : begin
> table1.Filtered := false;
> table1.Filter := '직업 = ''서비스업''';
> table1.Filtered := true;
> i:=Table1.RecordCount;
> edit6.text:= IntTostr(Table1.RecordCount);
> edit7.text:=FloatTostr(trunc((i/t*100)*100+0.5)/100)+'%';
> end;
> 4 : begin
> table1.Filtered := false;
> table1.Filter := '직업 = ''공무원''';
> table1.Filtered := true;
> i:=Table1.RecordCount;
> edit6.text:= IntTostr(Table1.RecordCount);
> edit7.text:=FloatTostr(trunc((i/t*100)*100+0.5)/100)+'%';
> end;
> 5 : begin
> table1.Filtered := false;
> table1.Filter := '직업 = ''회사원''';
> table1.Filtered := true;
> i:=Table1.RecordCount;
> edit6.text:= IntTostr(Table1.RecordCount);
> edit7.text:=FloatTostr(trunc((i/t*100)*100+0.5)/100)+'%';
> end;
> 6 : begin
> table1.Filtered := false;
> table1.Filter := '직업 = ''학생''';
> table1.Filtered := true;
> i:=Table1.RecordCount;
> edit6.text:= IntTostr(Table1.RecordCount);
> edit7.text:=FloatTostr(trunc((i/t*100)*100+0.5)/100)+'%';
> end;
> 7 : begin
> table1.Filtered := false;
> table1.Filter := '직업 = ''기타''';
> table1.Filtered := true;
> i:=Table1.RecordCount;
> edit6.text:= IntTostr(Table1.RecordCount);
> edit7.text:=FloatTostr(trunc((i/t*100)*100+0.5)/100)+'%';
> end;
> end;
> end;
> end;
>
>
> procedure TForm27.ComboBox6Change(Sender: TObject);
> var
> i,t:integer;
> begin
> Table1.Filtered :=false;
> t:=table1.RecordCount ;
> edit10.text:= IntTostr(Table1.RecordCount);
> if t>0then begin
> case combobox6.ItemIndex of
> 0 : begin
> table1.Filtered := false;
> edit10.text:= IntTostr(Table1.RecordCount);
> edit11.text:='';
> end;
> 1 : begin
> table1.Filtered := false;
> table1.Filter := '분석 = ''A''';
> table1.Filtered := true;
> i:=Table1.RecordCount;
> edit10.text:= IntTostr(Table1.RecordCount);
> edit11.text:=FloatTostr(trunc((i/t*100)*100+0.5)/100)+'%';
> end;
> 2 : begin
> table1.Filtered := false;
> table1.Filter := '분석 = ''B''';
> table1.Filtered := true;
> i:=Table1.RecordCount;
> edit10.text:= IntTostr(Table1.RecordCount);
> edit11.text:=FloatTostr(trunc((i/t*100)*100+0.5)/100)+'%'; end;
> 3 : begin
> table1.Filtered := false;
> table1.Filter := '분석 = ''C''';
> table1.Filtered := true;
> i:=Table1.RecordCount;
> edit10.text:= IntTostr(Table1.RecordCount);
> edit11.text:=FloatTostr(trunc((i/t*100)*100+0.5)/100)+'%';
> end;
> 4 : begin
> table1.Filtered := false;
> table1.Filter := '분석 = ''D''';
> table1.Filtered := true;
> i:=Table1.RecordCount;
> edit10.text:= IntTostr(Table1.RecordCount);
> edit11.text:=FloatTostr(trunc((i/t*100)*100+0.5)/100)+'%';
> end;
> 5 : begin
> table1.Filtered := false;
> table1.Filter := '분석 = ''E''';
> table1.Filtered := true;
> edit10.text:= IntTostr(Table1.RecordCount);
> i:=Table1.RecordCount;
> edit11.text:=FloatTostr(trunc((i/t*100)*100+0.5)/100)+'%';
> end;
> 6 : begin
> table1.Filtered := false;
> table1.Filter := '분석 = ''F''';
> table1.Filtered := true;
> edit10.text:= IntTostr(Table1.RecordCount);
> i:=Table1.RecordCount;
> edit11.text:=FloatTostr(trunc((i/t*100)*100+0.5)/100)+'%';
> end;
> end;
> end;
> end;
>
>
> procedure TForm27.ComboBox1Change(Sender: TObject);
> var
> i,t:integer;
> begin
> Table1.Filtered :=false;
> t:=table1.RecordCount ;
> edit2.text:= IntTostr(Table1.RecordCount);
> if t>0then begin
> case combobox1.ItemIndex of
> 0 : begin
> table1.Filtered := false;
> edit2.text:= IntTostr(Table1.RecordCount);
> edit3.text:='';
> end;
>
> 1 : begin
> table1.Filtered := false;
> table1.Filter := 'sex = ''남자''';
> table1.Filtered := true;
> i:=Table1.RecordCount;
> edit2.text:=IntTostr(Table1.RecordCount);
> edit3.text:=FloatTostr(trunc((i/t*100)*100+0.5)/100)+'%';
> end;
> 2 : begin
> table1.Filtered := false;
> table1.Filter := 'sex = ''여자''';
> table1.Filtered := true;
> i:=Table1.RecordCount;
> edit2.text:=IntTostr(Table1.RecordCount);
> edit3.text:=FloatTostr(trunc((i/t*100)*100+0.5)/100)+'%';
> end;
> end;
> end;
>
> end;
>
> procedure TForm27.Button3Click(Sender: TObject);
> var
> reply:String;
> s:string;
> begin
> reply:=copy(Table1.fieldByName('주민등록번호').AsString,8,1);
> if (reply='1')or(reply='3') then
> begin
> Table1.edit;
> Table1.FieldByName('sex').AsString:='남자';
> Table1.Post;
> end
> else if (reply='2') or(reply='4') then
> begin
> Table1.Edit;
> Table1.FieldByName('sex').AsString:='여자';
> Table1.Post;
> end
> else
> showMessage('오류^^;');
> end;
>
> procedure TForm27.Button4Click(Sender: TObject);
> var
> yy,mmdd,nowyy,nowmmdd:string;
> reply:string;
> a,yy1,mm1,dd1:integer;
> begin
> yy:=copy(Table1.fieldByName('주민등록번호').AsString,1,2);
> mmdd:=copy(Table1.FieldByName('주민등록번호').AsString,3,4);
> reply:=copy(Table1.FieldByName('주민등록번호').AsString,8,1);
> if (reply='1')or(reply='2')then
> yy:='19'+yy
> else if(reply='3')or(reply='4') then
> yy:='20'+yy
> else begin
> ShoWmessage('오류^^;');
> exit;
> end;
> nowyy:=formatDateTime('yyyy',Date);
> nowmmdd:=FormatDateTime('mm',Date)+FormatDateTime('dd',Date);
> if nowmmdd<=mmdd then
> a:=InttoStr(StrtoInt(nowyy)-StrtoInt(yy)-1)
> Table1.FieldByName('age').AsInteger:=a;
> else
> a:=InttoStr(StrtoInt(nowyy)-Strtoint(yy));
> Table1.FieldByName('age').AsInteger:=a;
> end;
>
> procedure TForm27.Table1BeforePost(DataSet: TDataSet);
> var
> reply:String;
> s:string;
> begin
> reply:=copy(Table1.fieldByName('주민등록번호').AsString,8,1);
> if (reply='1')or(reply='3') then
> begin
> Table1.edit;
> Table1.FieldByName('sex').AsString:='남자';
> Table1.Post;
> end
> else if (reply='2') or(reply='4') then
> begin
> Table1.Edit;
> Table1.FieldByName('sex').AsString:='여자';
> Table1.Post;
> end
> else
> showMessage('오류^^;');
> end;
>
> END.
>
================================================================================
글세여....
맞는진 모르겠지만...
어떤 용도로 사용하려는지 애매해서...
그리구 age와 sex 필드가 실제 테이블의 필드로 존재하는지 아님 테이블 콤포넌트의
필드에디터를 통해 가상의 필드만 추가한것인지 애매해서리...
암튼...
많이 고치진 않구여....
procedure TForm1.Button2Click(Sender: TObject);
var
yy,mmdd,nowyy,nowmmdd:string;
reply:string;
a,yy1,mm1,dd1:integer;
begin
Table1.First;
While not Table1.EOF do
begin
yy := copy(Table1.fieldByName('jumin').AsString,1,2);
mmdd:=copy(Table1.FieldByName('jumin').AsString,3,4);
reply:=copy(Table1.FieldByName('jumin').AsString,7,1); // 이부분이 잘못되어 있던거 같던데... (8,1, 이 아니라 7,1이죠)
if (reply='1')or(reply='2')then
yy:='19'+yy
else if(reply='3')or(reply='4') then
yy:='20'+yy
else
begin
ShoWmessage('오류^^;');
exit;
end;
Table1.Edit;
nowyy:=formatDateTime('yyyy',Date);
nowmmdd:=FormatDateTime('mm',Date)+FormatDateTime('dd',Date);
// 아래부분에서도 데이타 형변환에 약간의 문제가....
if nowmmdd<=mmdd then
Table1.FieldByName('age').AsInteger:= StrtoInt(nowyy)-StrtoInt(yy)-1
else
Table1.FieldByName('age').AsInteger := StrtoInt(nowyy)-Strtoint(yy);
Table1.Post;
// 남,여 구분을 구하는 부분
if (reply='1')or(reply='3') then
begin
Table1.edit;
Table1.FieldByName('sex').AsString:='남자';
end
else if (reply='2') or(reply='4') then
begin
Table1.Edit;
Table1.FieldByName('sex').AsString:='여자';
end
else
showMessage('오류^^;');
Table1.Post;
Table1.Next;
end;
Table1.First;
Database1.ApplyUpdates([Table1]); // 이부분은 첨가돼야 구한 age, sex 값이
db상에 write 되는거 같드라구여...
end;
글세여...
원하는 답이 아닌거 같기두하구..쩝쩝...
암튼... 질문있으면 다시 알려줘여...
ps .. 글쿠 이건 사견인데여...
주민번호, 나이, 성별 등등은 나중에 계산 or 입력에의해 자료를 관리하는 것
보다는 애초 데이타가 생성될 시점에 같이 입력해주는것이 좋을것두 같은데...