📄 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 + -