📄 contract_order.pas
字号:
aaa: string;
intb: integer;
begin
if DBComboBox1.Items.IndexOf(DBComboBox5.Text )>= 0 then
begin //1
if Query1.State = dsInsert then //yes /add new //保留text 值
begin //
aaa:= DBComboBox1.Text ;
if MessageBox(handle,'此订单号已经存在, 请输入一个新的订单号! 请重新输入订单号?','出错',MB_IconQuestion+ MB_OK)=IDOK then
begin
self.DBComboBox5.SetFocus ;
self.DBComboBox5.SelText := aaa;
end
end;
if Query1.State = dsEdit then //add new dsEdit;//保留原来的值
begin //
if MessageBox(handle,'此订单号已经存在, 请输入一个新的订单号! 是否重新输入订单号?','出错',MB_IconQuestion+ MB_OK)=IDOK then
begin
Query1.FieldByName('订单号').AsString := DBComboBox1_str;
self.DBComboBox5.SetFocus ;
self.DBComboBox5.SelText := DBComboBox1_str; // DBComboBox1_str is a public var
end
end; //
end //1
else
begin
self.DBComboBox6.SetFocus;
end
end;
procedure TForm_contract_order.Button1Click(Sender: TObject);
begin
Query1.Filtered:= false;
self.Close;
end;
procedure TForm_contract_order.DBComboBox3Enter(Sender: TObject);
begin
DBComboBox1_str := DBComboBox3.Text;//.FieldByName('合同编号').AsString;
end;
procedure TForm_contract_order.DBComboBox3Exit(Sender: TObject);
/////////
var
aaa: string;
intb: integer;
begin
DBComboBox1_str:= DBComboBox3.Text;
if DBComboBox3.Items.IndexOf(DBComboBox3.Text )< 0 then
begin //1
if Query1.State = dsInsert then //yes /add new //保留text 值
begin //
aaa:= DBComboBox3.Text ;
if MessageBox(handle,'此合同编号不存在, 请输入一个已经存在的合同编号,或者在列表框中选择一个合同编号! 是否重新输入合同编号?','出错',MB_IconQuestion+ MB_OK)=IDOK then
begin
self.DBComboBox3.SetFocus ;
self.DBComboBox3.SelText := aaa;
end
end;
if Query1.State = dsEdit then //add new dsEdit;//保留原来的值
begin //
if MessageBox(handle,'此合同编号不存在, 请输入一个已经存在的合同编号,或者在列表框中选择一个合同编号! 是否重新输入合同编号?','出错',MB_IconQuestion+ MB_OK)=IDOK then
begin
Query1.FieldByName('合同号').AsString := DBComboBox1_str;
self.DBComboBox3.SetFocus ;
self.DBComboBox3.SelText := DBComboBox1_str; // DBComboBox1_str is a public var
end
else //合同编号正确的, 永远执行不到的,因为合同编号肯定不对,因为itemindex <0
begin
//取得行号,合同号, 滚动到此行,然后再edit;
query1.Cancel;
with query1 do
begin
query1.Filtered := False;
Filter := '合同号 = ' + DBComboBox1_str;
Filtered := True;
end;
query1.Edit;
end;
end; //
end //1
else //是一个已经存在的合同
begin
query1.Cancel;
with query1 do
begin
query1.Filtered := False;
Filter := '合同号 = ' + DBComboBox1_str;
Filtered := True;
end;
query1.Edit;
self.DBComboBox4.SetFocus;
end;//else end;
end;
procedure TForm_contract_order.Query1aaaaAfterScroll(DataSet: TDataSet);
begin
query2select;
end;
procedure TForm_contract_order.Button2Click(Sender: TObject);
begin
self.DBGrid4.ReadOnly:=false;
query3.Append;
query3.FieldByName('合同号').AsString:=query1.fieldbyname('合同号').asstring;
end;
procedure TForm_contract_order.Button3Click(Sender: TObject);
begin
if self.Query3.RecordCount <>0 then
begin
if application.MessageBox(pchar('确信要删除这条记录嘛?'),
pchar('注意'),MB_OKCANCEL)=IDOK then
self.query3.Delete;
Form_contract_order.Button6Click(Button6);
//self.query4.post;
end
end;
procedure TForm_contract_order.Button4Click(Sender: TObject);
begin
seLF.DBGrid5.ReadOnly :=false;
query4.Close;
query4.Open;
query4.Append;
query4.FieldByName('合同号').AsString:=query1.fieldbyname('合同号').asstring;
end;
procedure TForm_contract_order.Button5Click(Sender: TObject);
begin
if self.Query4.RecordCount <>0 then
begin
if application.MessageBox(pchar('确信要删除这条记录嘛?'),
pchar('注意'),MB_OKCANCEL)=IDOK then
self.query4.Delete;
Form_contract_order.Button7Click(Button7);
//self.query4.post;
end
end;
procedure TForm_contract_order.Button6Click(Sender: TObject);
begin
self.Query3.ApplyUpdates ;
self.DBGrid4.ReadOnly:=true;
end;
procedure TForm_contract_order.Button7Click(Sender: TObject);
begin
self.DBGrid5.ReadOnly :=true;
self.Query4.ApplyUpdates ;
end;
procedure TForm_contract_order.Button8Click(Sender: TObject);
begin
Application.CreateForm(TForm_search, Form_search);
form_search.TransADO :=self.Query1 ;
unit_wxp.WhichForm := 500 ;
form_search.Showmodal ;
end;
procedure TForm_contract_order.Button9Click(Sender: TObject);
begin
self.Query1.Active :=false;
self.Query1.SQL.Clear ;
self.Query1.SQL.Add('select * from pub_z_contract ');
self.Query1.Active :=true;
unit_wxp.FinalSql:= 'select * from pub_z_contract ';
end;
procedure TForm_contract_order.Button10Click(Sender: TObject);
begin
//Application.CreateForm(TQReport_contract_order, QReport_contract_order);
//QReport_contract_order.Query1 .Active :=false;
//QReport_contract_order.Query1.SQL.Clear ;
//QReport_contract_order.Query1.SQL.Add(unit_wxp.FinalSql );
//QReport_contract_order.Query1.Active :=true;
//QReport_contract_order.Preview ;
//QReport_contract_order.Free ;
end;
procedure TForm_contract_order.Query1AfterScroll(DataSet: TDataSet);
begin
query2select;
end;
procedure TForm_contract_order.PageControl1Change(Sender: TObject);
begin
self.PageControl1.Top := 0;
self.ScrollBox.VertScrollBar.Position:=0;
end;
procedure TForm_contract_order.DBRadioGroup1Exit(Sender: TObject);
begin
if self.DBRadioGroup1.ItemIndex = 0 then
begin
self.DBComboBox8.Text:=banshichu;
query1.Fieldbyname('销售地办事处').AsString := banshichu;
self.DBComboBox8.Enabled:=true;
end
else
begin
query1.Fieldbyname('销售地办事处').AsString :='' ;
self.DBComboBox8.text:= '';
self.DBComboBox8.Enabled:=false;
end
end;
procedure TForm_contract_order.FormKeyPress(Sender: TObject;
var Key: Char);
begin
if Key = #13 then //如果是一个Enter键盘
begin
if not (ActiveControl is TDBGrid) then //如果当前的控件不是TDBGrid
begin
Key := #0;
Perform(WM_NEXTDLGCTL, 0, 0); { move to next control }
end
else if (ActiveControl is TDBGrid) then //在TDBGrid中
begin
with TDBGrid(ActiveControl) do
begin
if selectedindex <(fieldcount -1) then //如果不是最后一个字段
selectedindex := selectedindex +1
else
selectedindex := 0;
end;
end;
end;
end;
procedure TForm_contract_order.DBRadioGroup1Enter(Sender: TObject);
var aa: string;
bb:string;
begin
self.DBComboBox8.Enabled:=true;
banshichu:= query1.Fieldbyname('销售地办事处').AsString ;
aa := query1.Fieldbyname('销售地办事处').AsString ;
bb:='bb' ;
end;
procedure TForm_contract_order.DBGrid4ColEnter(Sender: TObject);
begin
//条件了
if self.DBGrid4.Columns[self.DBGrid4.SelectedIndex].Fieldname = '所属型号' then
begin
with Query_contract_client do
begin
if active then close;
unprepare;
sql.Clear;
sql.Add('select distinct 机型 FROM std_machine');
prepare;
open;
self.DBGrid4.Columns[self.DBGrid4.SelectedIndex].PickList.clear;//机型
while not eof do
begin
self.DBGrid4.Columns[self.DBGrid4.SelectedIndex].PickList.add(fieldbyname('机型').AsString) ;
next;
end;
end;
end;
end;
procedure TForm_contract_order.DBGrid5ColEnter(Sender: TObject);
begin
//条件了
if self.DBGrid5.Columns[self.DBGrid5.SelectedIndex].Fieldname = '所属型号' then
begin
with Query_contract_client do
begin
if active then close;
unprepare;
sql.Clear;
sql.Add('select distinct 机型 FROM std_machine');
prepare;
open;
self.DBGrid5.Columns[self.DBGrid5.SelectedIndex].PickList.clear;//机型
while not eof do
begin
self.DBGrid5.Columns[self.DBGrid5.SelectedIndex].PickList.add(fieldbyname('机型').AsString) ;
next;
end;
end;
end;
end;
procedure TForm_contract_order.Button11Click(Sender: TObject);
begin
self.DBGrid4.ReadOnly:=false;
self.Query3.Edit ;
end;
procedure TForm_contract_order.Button12Click(Sender: TObject);
begin
Query4.Close;
Query4.Open;
if Query4.CanModify then
begin
self.DBGrid5.ReadOnly:=false;
self.Query4.Edit ;
end
else
showMessage('当前数据库不能编辑');
end;
procedure TForm_contract_order.DBGrid4ColExit(Sender: TObject);
begin
with self.Query3 do
begin
Edit;
if (Fieldbyname('标准单价').value >0) and (Fieldbyname('数量').value >0) then
Fieldbyname('合计').value := Fieldbyname('标准单价').value *Fieldbyname('数量').value;
post;
end;
end;
procedure TForm_contract_order.DBGrid5ColExit(Sender: TObject);
begin
with self.Query4 do
begin
Edit;
if (Fieldbyname('标准单价').value >0) and (Fieldbyname('数量').value >0) then
Fieldbyname('合计').value := Fieldbyname('标准单价').value *Fieldbyname('数量').value;
post;
end;
end;
procedure TForm_contract_order.FormDestroy(Sender: TObject);
begin
Form_contract_order:=nil;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -