?? floor.pas
字號:
dbcomboboxeh4.Text:=inttostr(months-1);
dbdatetimeeditEh1.Value:=date;
dbdatetimeeditEh2.Value:=date;
end;
procedure TForm1.FormKeyPress(Sender: TObject; var Key: Char);
begin
{if key=#13 then
begin
key:=#0;
perform(WM_nextdlgctl,0,0);
end; }
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
// datamodule1.searchq.Close;
end;
procedure TForm1.BitBtn4Click(Sender: TObject);
begin
with datamodule1.searchq do
begin
sql.clear;
if dbcomboboxeh1.Value<>'' then
sql.add('select * from company where floor=:mc')
else
sql.add('select * from company');
if dbcomboboxeh1.Value<>'' then
parambyname('mc').asstring:=dbcomboboxeh1.Value;
open;
end;
end;
procedure TForm1.BitBtn13Click(Sender: TObject);
begin
if application.MessageBox('確定要刪除嗎?','提示',mb_yesno)=6 then
begin
with datamodule1.insertcustom do
begin
sql.clear;
sql.Add('delete from company where customno=:mc');
parambyname('mc').asstring:=datamodule1.searchq.fieldbyname('customno').asstring;
execsql;
end;
with datamodule1.searchq do
begin
sql.clear;
sql.add('select * from company');
open;
end;
application.MessageBox('刪除完畢!','提示',mb_ok);
end;
end;
procedure TForm1.N3Click(Sender: TObject);
begin
form4:=tform4.create(self);
form4.showmodal;
end;
procedure TForm1.BitBtn16Click(Sender: TObject);
begin
if application.MessageBox('確定要刪除這筆記錄嗎?','提示',mb_yesno)=6 then
begin
with datamodule1.insertsd do
begin
sql.clear;
sql.add('delete from sd where customno=:mc and years=:my and months=:mm and floor=:mf');
parambyname('mc').Value:=datamodule1.sdq.fieldbyname('customno').Value;
parambyname('my').Value:=datamodule1.sdq.fieldbyname('years').Value;
parambyname('mm').Value:=datamodule1.sdq.fieldbyname('months').Value;
parambyname('mf').Value:=datamodule1.sdq.fieldbyname('floor').Value;
execsql;
end;
with datamodule1.sdq do
begin
sql.clear;
sql.add('select * from sd where years=:my and months=:mm and floor=:mf');
parambyname('my').Value:=dbcomboboxeh3.Value;
parambyname('mm').Value:=dbcomboboxeh4.Value;
parambyname('mf').Value:=dbcomboboxeh2.Value;
open;
end;
end;
end;
procedure TForm1.BitBtn18Click(Sender: TObject);
begin
if application.MessageBox('確定要刪除這筆記錄嗎?','提示',mb_yesno)=6 then
begin
with datamodule1.insertsd do
begin
sql.clear;
sql.add('delete from ht where htno=:mht');
parambyname('mht').Value:=datamodule1.htq.fieldbyname('htno').Value;
execsql;
end;
datamodule1.tpq.sql.clear;
datamodule1.tpq.sql.add('delete from repo where htno=:mm');
datamodule1.tpq.parambyname('mm').value:=edit4.Text;
datamodule1.tpq.execsql;
with datamodule1.htq do
begin
sql.clear;
sql.add('select * from ht');
open;
end;
end;
end;
procedure TForm1.Edit10Exit(Sender: TObject);
begin
with datamodule1.insertcustom do
begin
sql.clear;
sql.add('select * from company where customno=:mc');
open;
end;
end;
procedure TForm1.BitBtn2Click(Sender: TObject);
var
ExcelApp: Variant;
ll,nn:integer;
begin
ExcelApp := CreateOleObject( 'Excel.Application' );
ExcelApp.Visible := True;
ExcelApp.WorkBooks.Add;
if datamodule1.sdq.RecordCount<=0 then
datamodule1.sdq.Open;
datamodule1.sdq.First;
for ll:=1 to dbgrideh1.Columns.Count do
ExcelApp.Cells[1,ll].Value :=dbgrideh1.Columns[ll-1].title.caption; //EXCEL標題
for nn:=2 to datamodule1.sdq.RecordCount+1 do
begin
dbgrideh1.Row:=nn-2; //設置當前行
for ll:=1 to dbgrideh1.Columns.count do
ExcelApp.Cells[nn,ll].Value :=dbgrideh1.Columns[ll-1].DisplayText;
ExcelApp.cells[nn,ll+1].value:=datamodule1.sdq.FieldByName('floor').value;
datamodule1.sdq.Next;
end;
{ for ll:=1 to 13 do
ExcelApp.Cells[1,ll].Value :=dbgrideh1.Columns[ll-1].title.caption; //EXCEL標題
for nn:=2 to datamodule1.sdq.RecordCount+1 do
begin
dbgrideh1.Row:=nn-2; //設置當前行
for ll:=1 to 13 do
ExcelApp.Cells[nn,ll].Value :=dbgrideh1.Columns[ll-1].DisplayText;
datamodule1.sdq.Next;
end;}
end;
procedure TForm1.BitBtn17Click(Sender: TObject);
begin
PrintDBGridEh1.DBGridEh := DBGridEh1;
PrintDBGridEh1.SetSubstitutes(['%[Today]',DateToStr(Now)]);
PrintDBGridEh1.Preview;
end;
procedure TForm1.DBGridEh3TitleBtnClick(Sender: TObject; ACol: Integer;
Column: TColumnEh);
begin
{case Column.Title.SortMarker of
smNoneEh: Column.Title.SortMarker := smDownEh;
smDownEh: Column.Title.SortMarker := smUpEh;
smUpEh: Column.Title.SortMarker := smNoneEh;
end;}
end;
procedure TForm1.DBGridEh1TitleBtnClick(Sender: TObject; ACol: Integer;
Column: TColumnEh);
begin
case Column.Title.SortMarker of
smNoneEh: Column.Title.SortMarker := smDownEh;
smDownEh: Column.Title.SortMarker := smUpEh;
smUpEh: Column.Title.SortMarker := smNoneEh;
end;
end;
procedure TForm1.BitBtn8Click(Sender: TObject);
begin
PrintDBGridEh1.DBGridEh := DBGridEh3;
PrintDBGridEh1.SetSubstitutes(['%[Today]',DateToStr(Now)]);
PrintDBGridEh1.Preview;
end;
procedure TForm1.BitBtn7Click(Sender: TObject);
begin
PrintDBGridEh1.DBGridEh := DBGridEh2;
PrintDBGridEh1.SetSubstitutes(['%[Today]',DateToStr(Now)]);
PrintDBGridEh1.Preview;
end;
procedure TForm1.BitBtn20Click(Sender: TObject);
var
ExcelApp: Variant;
ll,nn:integer;
begin
ExcelApp := CreateOleObject( 'Excel.Application' );
ExcelApp.Visible := True;
ExcelApp.WorkBooks.Add;
if datamodule1.searchq.RecordCount<=0 then
datamodule1.searchq.Open;
datamodule1.searchq.First;
for ll:=1 to dbgrideh3.Columns.Count do
ExcelApp.Cells[1,ll].Value :=dbgrideh3.Columns[ll-1].title.caption; //EXCEL標題
for nn:=2 to datamodule1.searchq.RecordCount+1 do
begin
dbgrideh3.Row:=nn-2; //設置當前行
for ll:=1 to dbgrideh3.Columns.count do
ExcelApp.Cells[nn,ll].Value :=dbgrideh3.Columns[ll-1].DisplayText;
ExcelApp.cells[nn,ll+1].value:=datamodule1.searchq.FieldByName('floor').value;
datamodule1.searchq.Next;
end;
end;
procedure TForm1.BitBtn19Click(Sender: TObject);
var
ExcelApp: Variant;
ll,nn:integer;
begin
ExcelApp := CreateOleObject( 'Excel.Application' );
ExcelApp.Visible := True;
ExcelApp.WorkBooks.Add;
if datamodule1.htQ.RecordCount<=0 then
datamodule1.htq.Open;
datamodule1.htq.First;
for ll:=1 to dbgrideh2.Columns.Count do
ExcelApp.Cells[1,ll].Value :=dbgrideh2.Columns[ll-1].title.caption; //EXCEL標題
for nn:=2 to datamodule1.htq.RecordCount+1 do
begin
dbgrideh2.Row:=nn-2; //設置當前行
for ll:=1 to dbgrideh2.Columns.count do
ExcelApp.Cells[nn,ll].Value :=dbgrideh2.Columns[ll-1].DisplayText;
ExcelApp.cells[nn,ll+1].value:=datamodule1.htq.FieldByName('floor').value;
datamodule1.htq.Next;
end;
end;
procedure TForm1.DBGridEh3KeyPress(Sender: TObject; var Key: Char);
begin
{ if key=#13 then
begin
key:=#0;
// showmessage(inttostr(dbgrideh3.Columns.Count));
if dbgrideh3.Col<dbgrideh3.Columns.Count then
dbgridEh3.Col:=dbgridEh3.Col+1 else
begin
dbgrideh3.Col:=1;
if dbgrideh3.row<dbgrideh3.RowCount-1 then
dbgrideh3.Row:=dbgrideh3.Row+1
else
dbgrideh3.Row:=dbgrideh3.Rowcount-1;
end;
end;}
end;
procedure TForm1.BitBtn5Click(Sender: TObject);
begin
//showmessage('rowcount:'+inttostr(dbgrideh3.Rowcount));
//showmessage('row:'+inttostr(dbgrideh3.Row));
if dbcomboboxeh1.Value='' then
begin
application.MessageBox('請先選擇大廈名稱','提示',mb_ok);
abort;
end;
dbgrideh3.ReadOnly:=false;
bitbtn5.Enabled:=false;
bitbtn6.Enabled:=true;
datamodule1.searchq.edit;
end;
procedure TForm1.BitBtn6Click(Sender: TObject);
begin
dbgrideh3.ReadOnly:=true;
bitbtn6.Enabled:=false;
bitbtn5.Enabled:=true;
bitbtn15.Enabled:=true;
with datamodule1.searchq do
begin
datamodule1.Database1.StartTransaction;
try
//fieldbyname('floor').Value:=dbcomboboxeh1.Value; //用此方法會出錯,表示狀態不對。
ApplyUpdates; {try to write the updates to the database};
datamodule1.Database1.Commit; {on success, commit the changes};
except
datamodule1.Database1.Rollback; {on failure, undo the changes};
raise; {raise the exception to prevent a call to CommitUpdates!}
end;
CommitUpdates; {on success, clear the cache}
datamodule1.sdpriceq.sql.clear;
datamodule1.sdpriceq.sql.Add('update company set floor=:mf where floor=null');
datamodule1.sdpriceQ.ParamByName('mf').Value:=dbcomboboxeh1.Value;
datamodule1.sdpriceQ.execsql; //更新大廈名稱
application.MessageBox('保存完畢!','提示',mb_ok)
end;
end;
procedure TForm1.BitBtn15Click(Sender: TObject);
begin
if dbcomboboxeh1.Value='' then
begin
application.MessageBox('請先選擇大廈名稱','提示',mb_ok);
abort;
end;
dbgrideh3.ReadOnly:=false;
bitbtn5.Enabled:=false;
bitbtn15.Enabled:=false;
bitbtn6.Enabled:=true;
datamodule1.searchq.Append;
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
if dbcomboboxeh2.Value='' then
begin
application.MessageBox('大廈不能為空!','提示',mb_ok);
abort;
end;
if dbcomboboxeh3.Value='' then
begin
application.MessageBox('年份不能為空!','提示',mb_ok);
abort;
end;
if dbcomboboxeh4.Value='' then
begin
application.MessageBox('月份不能為空!','提示',mb_ok);
abort;
end;
with datamodule1.sdq do
begin
sql.clear;
sql.add('select * from sd where floor=:mf and years=:my and months=:mm');
parambyname('mf').asstring:=dbcomboboxeh2.Value;
parambyname('my').asstring:=dbcomboboxeh3.Value;
parambyname('mm').asstring:=dbcomboboxeh4.Value;
open;
end;
end;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -