?? zy110unit.pas
字號:
end;
end;
end;
procedure TZY110Form.Button1Click(Sender: TObject);
begin
inherited;
case PageControl1.TabIndex of
0: begin
CLS;
ENA;
DM.HYZY.Open;
DM.HYZY.Append; //加入新的記錄
DM.HYZY.FieldByName('輸單員').AsString := MainForm.Auser.UserName;
end;
1:
begin
CLS;
ENA;
DM.HYMX.Open;
DM.HYMX.Append; //加入新的記錄
DM.HYMX.FieldByName('委托單位').AsString := DM.HYZY.FieldByName('委托單位').AsString;
DM.HYMX.FieldByName('經營單位').AsString := DM.HYZY.FieldByName('經營單位').AsString;
DM.HYMX.FieldByName('委托單號').AsString := DM.HYZY.FieldByName('委托單號').AsString;
DM.HYMX.FieldByName('提單號').AsString := DM.HYZY.FieldByName('提單號').AsString;
DM.HYMX.FieldByName('合同號').AsString := DM.HYZY.FieldByName('合同號').AsString;
DM.HYMX.FieldByName('總單編號').AsString := DM.HYZY.FieldByName('編號').AsString;
DM.HYMX.FieldByName('數量箱型').AsString := DM.HYZY.FieldByName('數量箱型').AsString;
DBEdit14.Text := DM.HYZY.FieldByName('箱號').AsString;
DBEdit24.Text := DM.HYZY.FieldByName('貨名').AsString;
DBEdit25.Text := DM.HYZY.FieldByName('型號').AsString;
DBEdit26.Text := DM.HYZY.FieldByName('數量').AsString;
DBEdit27.Text := DM.HYZY.FieldByName('件重').AsString;
end;
end;
end;
procedure TZY110Form.Button2Click(Sender: TObject);
begin
inherited;
case PageControl1.TabIndex of
0: begin
ENA;
DM.HYZY.Edit;
end;
1:
begin
ENA;
DM.HYMX.Edit;
end;
end;
end;
procedure TZY110Form.Button3Click(Sender: TObject);
begin
inherited;
case PageControl1.TabIndex of
0: begin
DM.HYZY.Post;
DIS;
end;
1:
begin
DM.HYMX.Post;
DIS;
end;
end;
end;
procedure TZY110Form.Button4Click(Sender: TObject);
begin
inherited;
case PageControl1.TabIndex of
0: begin
DM.HYZY.Cancel;
DIS;
end;
1:
begin
DM.HYMX.Cancel;
DIS;
end;
end;
end;
procedure TZY110Form.Button5Click(Sender: TObject);
begin
inherited;
case PageControl1.TabIndex of
0: begin
if MessageBox(0, '你確定刪除該條記錄', '提示', MB_YESNO + MB_ICONQUESTION) =
IDYES then
begin
DM.HYZY.Delete;
end;
end;
1:
begin
if MessageBox(0, '你確定刪除該條記錄', '提示', MB_YESNO + MB_ICONQUESTION) =
IDYES then
begin
DM.HYMX.Delete;
end;
end;
end;
end;
procedure TZY110Form.Button6Click(Sender: TObject);
begin
inherited;
close;
end;
procedure TZY110Form.DBEdit3Click(Sender: TObject);
begin
inherited;
try
DateForm := TDateForm.Create(Application);
DateForm.ShowModal;
DBEdit3.Text := FormatDateTime('yyyy/mm/dd', DateForm.date1.Date);
DateForm.Free;
except
MessageBox(0, '日期選擇窗體創建錯誤', '錯誤', MB_OK + MB_ICONSTOP);
end;
end;
procedure TZY110Form.FormShow(Sender: TObject);
begin
inherited;
CLS;
DIS;
DM.HYZY.First;
end;
procedure TZY110Form.DBEdit15Click(Sender: TObject);
begin
inherited;
try {--- 彈出日期選擇窗體 ---}
DateForm := TDateForm.Create(Application);
DateForm.ShowModal;
DBEdit15.Text := FormatDateTime('yyyy/mm/dd', DateForm.date1.Date);
DateForm.Free;
except
MessageBox(0, '日期選擇窗體創建錯誤', '錯誤', MB_OK + MB_ICONSTOP);
end;
end;
procedure TZY110Form.DBEdit9Click(Sender: TObject);
begin
inherited;
try {--- 彈出日期選擇窗體 ---}
DateForm := TDateForm.Create(Application);
DateForm.ShowModal;
DBEdit9.Text := FormatDateTime('yyyy/mm/dd', DateForm.date1.Date);
DateForm.Free;
except
MessageBox(0, '日期選擇窗體創建錯誤', '錯誤', MB_OK + MB_ICONSTOP);
end;
end;
procedure TZY110Form.DBEdit12Click(Sender: TObject);
begin
inherited;
try {--- 彈出日期選擇窗體 ---}
DateForm := TDateForm.Create(Application);
DateForm.ShowModal;
DBEdit12.Text := FormatDateTime('yyyy/mm/dd', DateForm.date1.Date);
DateForm.Free;
except
MessageBox(0, '日期選擇窗體創建錯誤', '錯誤', MB_OK + MB_ICONSTOP);
end;
end;
procedure TZY110Form.DBEdit13Click(Sender: TObject);
begin
inherited;
try {--- 彈出日期選擇窗體 ---}
DateForm := TDateForm.Create(Application);
DateForm.ShowModal;
DBEdit13.Text := FormatDateTime('yyyy/mm/dd', DateForm.date1.Date);
DateForm.Free;
except
MessageBox(0, '日期選擇窗體創建錯誤', '錯誤', MB_OK + MB_ICONSTOP);
end;
end;
procedure TZY110Form.DBEdit23Click(Sender: TObject);
begin
inherited;
try {--- 彈出日期選擇窗體 ---}
DateForm := TDateForm.Create(Application);
DateForm.ShowModal;
DBEdit23.Text := FormatDateTime('yyyy/mm/dd', DateForm.date1.Date);
DateForm.Free;
except
MessageBox(0, '日期選擇窗體創建錯誤', '錯誤', MB_OK + MB_ICONSTOP);
end;
end;
procedure TZY110Form.DBEdit21Exit(Sender: TObject);
begin
inherited;
{--- 計算貨物總的重量 ---}
DBEdit22.Text := FloatToStr(StrToFloat(DBEdit21.Text) * StrToFloat(DBEdit20.Text));
DBCombobox5.SetFocus;
end;
procedure TZY110Form.DBComboBox6DropDown(Sender: TObject);
var
I: Integer;
begin
inherited;
DBComboBox6.Clear;
with DM.Querytemp do
begin
SQL.clear;
SQl.Text := 'select 名稱 from 到港名稱 ';
Close;
Active := False;
prepared := False;
prepared := True;
Active := True;
if (recordcount > 0) then
first;
for i := 0 to recordcount - 1 do
begin {--- 取得該列所有的數據到combobox6控件中 ---}
DBComboBox6.Items.add(FieldByName('名稱').asstring);
next;
end;
end;
end;
procedure TZY110Form.PageControl1Change(Sender: TObject);
begin
inherited;
case PageControl1.TabIndex of
0:
begin
{--- Panel3 不可見 ---}
Panel3.Visible := True;
{--- 改變 DBNavigator2 的數據源 ---}
DBNavigator2.DataSource := DM.dsHYZY;
end;
1:
begin
{--- Panel3 不可見 ---}
Panel3.Visible := True;
{--- 改變 DBNavigator2 的數據源 ---}
DBNavigator2.DataSource := DM.dsHYMX;
end;
2:
begin
Panel3.Visible := False;
end;
3:
begin
Panel3.Visible := False;
end;
end;
end;
procedure TZY110Form.ComboBox3DropDown(Sender: TObject);
var
i: Integer;
begin
inherited;
ComBobox3.Clear;
for i := 0 to DM.HYMX.FieldList.Count - 1 do
begin //取得所有的列名作為搜索條件
ComBobox3.Items.Add(DM.HYMX.Fields[i].FieldName);
end;
end;
procedure TZY110Form.ComboBox3Change(Sender: TObject);
var
I: Integer;
begin
inherited;
combobox4.Clear;
with DM.Querytemp do
begin
SQL.clear;
SQl.Text := 'select ' + trim(combobox3.Text) + ' from 貨運明細 ';
Close;
Active := False;
prepared := False;
prepared := True;
Active := True;
if (recordcount > 0) then
first;
for i := 0 to recordcount - 1 do
begin //取得該列所有的數據到combobox2控件中
combobox4.Items.add(FieldByName(ComboBox3.Text).asstring);
next;
end;
end;
end;
procedure TZY110Form.CheckBox2Click(Sender: TObject);
begin
inherited;
inherited;
{--- 判斷日期選擇是否可用 ---}
DateTimePicker3.Enabled := CheckBox2.Checked;
DateTimePicker4.Enabled := CheckBox2.Checked;
end;
procedure TZY110Form.Button10Click(Sender: TObject);
begin
inherited;
if (Combobox3.Text <> '') and (Combobox4.Text <> '') then
begin
with DM.Querytemp do
begin
SQL.clear;
if CheckBox1.Checked then
SQl.Text := 'select * from 貨運明細 where ' + trim(combobox3.Text) + ' like '
+ #39 + '%' + trim(combobox4.Text) + '%' + #39 + 'and 日期 > #'
+ FormatDateTime('yyyy/mm/dd', DateTimePicker3.DateTime) + '# and 日期 < #' + FormatDateTime('yyyy/mm/dd', DateTimePicker4.DateTime) + '#'
else
SQl.Text := 'select * from 貨運明細 where ' + trim(combobox3.Text) + ' like '
+ #39 + '%' + trim(combobox4.Text) + '%' + #39;
Close;
Active := False;
prepared := False;
prepared := True;
Active := True;
open;
DBGrid2.DataSource := DM.dsQuerytemp;
DBNavigator3.DataSource := DM.dsQuerytemp;
end;
end
else
MessageBox(0, '搜尋條件錯誤', '錯誤', MB_OK + MB_ICONSTOP);
end;
procedure TZY110Form.Button12Click(Sender: TObject);
begin
inherited;
Close;
end;
procedure TZY110Form.DBEdit7Click(Sender: TObject);
begin
inherited;
inherited;
try {--- 彈出日期選擇窗體 ---}
DateForm := TDateForm.Create(Application);
DateForm.ShowModal;
DBEdit7.Text := FormatDateTime('yyyy/mm/dd', DateForm.date1.Date);
DateForm.Free;
except
MessageBox(0, '日期選擇窗體創建錯誤', '錯誤', MB_OK + MB_ICONSTOP);
end;
end;
procedure TZY110Form.DBComboBox7DropDown(Sender: TObject);
var
I: Integer;
begin
inherited;
DBComboBox7.Clear;
with DM.Querytemp do
begin
SQL.clear;
SQl.Text := 'select 名稱 from 物流方式 ';
Close;
Active := False;
prepared := False;
prepared := True;
Active := True;
if (recordcount > 0) then
first;
for i := 0 to recordcount - 1 do
begin //取得該列所有的數據到combobox5控件中
DBComboBox7.Items.add(FieldByName('名稱').asstring);
next;
end;
end;
end;
procedure TZY110Form.DBComboBox8DropDown(Sender: TObject);
var
I: Integer;
begin
inherited;
DBComboBox8.Clear;
with DM.Querytemp do
begin
SQL.clear;
SQl.Text := 'select 名稱 from 到港名稱 ';
Close;
Active := False;
prepared := False;
prepared := True;
Active := True;
if (recordcount > 0) then
first;
for i := 0 to recordcount - 1 do
begin //取得該列所有的數據到combobox3控件中
DBComboBox8.Items.add(FieldByName('名稱').asstring);
next;
end;
end;
end;
procedure TZY110Form.DBComboBox9DropDown(Sender: TObject);
var
I: Integer;
begin
inherited;
DBComboBox9.Clear;
with DM.Querytemp do
begin
SQL.clear;
SQl.Text := 'select 車牌號碼 from 車輛資料 ';
Close;
Active := False;
prepared := False;
prepared := True;
Active := True;
if (recordcount > 0) then
first;
for i := 0 to recordcount - 1 do
begin {--- 取得該列所有的數據到combobox9控件中 ---}
DBComboBox9.Items.add(FieldByName('車牌號碼').AsString);
next;
end;
end;
end;
procedure TZY110Form.DBComboBox9Change(Sender: TObject);
begin
inherited;
with DM.Querytemp do
begin
SQL.clear;
SQl.Text := 'select * from 車輛資料 where 車牌號碼 =' + #39 + Trim(DBComboBox9.Text) + #39;
Close;
Active := False;
prepared := False;
prepared := True;
Active := True;
DBEdit32.Text := FieldByName('姓名').AsString;
DBEdit33.Text := FieldByName('所屬車隊').AsString;
end;
end;
procedure TZY110Form.DBEdit28Click(Sender: TObject);
begin
inherited;
try {--- 彈出日期選擇窗體 ---}
DateForm := TDateForm.Create(Application);
DateForm.ShowModal;
DBEdit28.Text := FormatDateTime('yyyy/mm/dd', DateForm.date1.Date);
DateForm.Free;
except
MessageBox(0, '日期選擇窗體創建錯誤', '錯誤', MB_OK + MB_ICONSTOP);
end;
end;
procedure TZY110Form.DBEdit1Exit(Sender: TObject);
begin
inherited;
{--- 只有插入狀態下才檢測是否重復 ---}
if DM.HYZY.State = dsInsert then
begin
with DM.QueryTemp do
begin
{--- 委托單號不允許重復,否則會導致后面的問題出現 ---}
close;
sql.clear;
SQL.text := 'select * from 貨運作業總表 where ' + '委托單號=' + #39 + DBEdit1.text + #39;
Close;
Active := False;
prepared := False;
prepared := True;
Active := True;
if RecordCount > 0 then
begin
MessageBox(0, '該委托單號已經存在!', '', MB_OK + MB_ICONSTOP);
DBEdit1.SetFocus;
end;
end;
end;
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -