📄 contract_cjd_ys.pas
字号:
end;
procedure TForm_ys_cjd.btn_edit1Click(Sender: TObject);
begin
EnableScrollBox(ScrollBox);
DisableBtn;
self.query1.Edit ;
btn_save1.Enabled :=true;
btn_cancel1.Enabled :=true;
btn_save.Enabled :=true;
btn_cancel.Enabled :=true;
end;
procedure TForm_ys_cjd.btn_save1Click(Sender: TObject);
begin
self.Query1.post ;
btn_save1.Enabled :=false;
btn_cancel1.Enabled :=false;
btn_save.Enabled :=false;
btn_cancel.Enabled :=false;
//锁住所有文本框
EnableScrollBox(ScrollBox);
//使按钮有效
EnableBtn ;
btn_addnew1.Enabled :=true;
btn_edit1.Enabled :=true;
btn_addnew.Enabled :=true;
btn_edit.Enabled :=true;
end;
procedure TForm_ys_cjd.btn_cancel1Click(Sender: TObject);
begin
self.Query1.Cancel ;
EnableBtn;
DisableScrollBox(ScrollBox);
btn_cancel.Enabled :=false;
btn_save.Enabled :=false;
btn_cancel1.Enabled :=false;
btn_save1.Enabled :=false;
end;
procedure TForm_ys_cjd.btn_close1Click(Sender: TObject);
begin
self.Close;
end;
procedure TForm_ys_cjd.btn_closeClick(Sender: TObject);
begin
btn_close1Click(btn_close1);
end;
procedure TForm_ys_cjd.FormCreate(Sender: TObject);
begin
self.Query1.Open;
Form_ys_cjd.KeyPreview := true;
unit_public_jin.Setcolor(ScrollBox);
DisableScrollBox(ScrollBox); //使scrollbox上的控件只读;
///////////
//合同号
with Query_contract_client do
begin
if active then close;
unprepare;
sql.Clear;
sql.Add('select distinct 合同号 from pub_z_contract_machine ');
sql.Add(' WHERE 型号 LIKE ''SM%'' '); // NOT LIKE
prepare;
open;
DBComboBox1.Items.Clear;
while not eof do
begin
DBComboBox1.Items.Add(fieldbyname('合同号').AsString);
next;
end;
end;
end;
procedure TForm_ys_cjd.FormKeyPress(Sender: TObject; var Key: Char);
begin
if Key = #13 then
begin
Key := #0;
Perform(WM_NEXTDLGCTL, 0, 0);
end;
end;
procedure TForm_ys_cjd.DBComboBox1Enter(Sender: TObject);
begin
DBComboBox1_str := DBComboBox1.Text;//
old_index:= self.DBComboBox1.Items.IndexOf(DBComboBox1_str); //old_index;
end;
procedure TForm_ys_cjd.DBComboBox1Exit(Sender: TObject);
var
aaa: string;
intb: integer;
begin
aaa:=DBComboBox1.Text;
if Query1.State = dsInsert then // 新增时候add new
begin
if DBComboBox1.Items.IndexOf(aaa)< 0 then //不存在时
begin
if MessageBox(handle,'此合同编号不存在,请输入一个已经存在的合同编号,或者在列表框中选择一个合同编号! 是否重新输入合同编号?','出错',MB_IconQuestion+ MB_OKCANCEL)=IDOK then
begin
self.DBComboBox1.SetFocus ;
self.DBComboBox1.SelText := aaa;
end
else
begin
self.Close;
end;
end //不存在时 end
else //存在时
begin
///////
//init
with Query_contract_client do
begin
if active then close;
unprepare;
sql.Clear;
sql.Add('select * from pub_z_contract ');
sql.Add(' WHERE 合同号 = :hth '); // NOT LIKE ]
Query_contract_client.ParamByName('hth').AsString := aaa;
prepare;
open;
{ while not eof do //Eof and Bof
begin
Query_contract_client.First;
Query1.FieldByName('公司地址').AsString := Query_contract_client.FieldByName('卖方住所').AsString;
Query1.FieldByName('公司联系人').AsString := '楼广' ;//Query_contract_client.FieldByName('卖方住所').AsString;
Query1.FieldByName('交提货方式').AsString := Query_contract_client.FieldByName('交提货方式').AsString;
Query1.FieldByName('交提货费用承担方').AsString := Query_contract_client.FieldByName('交提货费用承担方').AsString;
Query1.FieldByName('公司传真').AsString := Query_contract_client.FieldByName('卖方传真').AsString;
Query1.FieldByName('公司电话').AsString := Query_contract_client.FieldByName('卖方电话').AsString;
Query1.FieldByName('公司开户行').AsString := Query_contract_client.FieldByName('卖方开户银行').AsString;
Query1.FieldByName('公司帐号').AsString := Query_contract_client.FieldByName('卖方银行帐号').AsString;
Query1.FieldByName('税号').AsString := Query_contract_client.FieldByName('卖方税务证号').AsString;
Query_contract_client.Last;
end; }
//检索其它表;
with Query2 do //biao di wu
begin
if active then close;
unprepare;
sql.Clear;
sql.Add('select * from pub_z_contract_machine ');
sql.Add(' WHERE 合同号 = :hth '); // NOT LIKE ]
sql.Add(' and 型号 like ''SM%'' ');
ParamByName('hth').AsString := aaa ;
prepare;
open;
end;
{
with Query3 do //tebie gong cheng
begin
if active then close;
unprepare;
sql.Clear;
sql.Add('select * from pub_z_contract_project ');
sql.Add(' WHERE 合同号 = :hth '); // NOT LIKE ]
sql.Add(' and 所属机型 not like ''SM%'' ');
ParamByName('hth').AsString := aaa ;
prepare;
open;
end;
}
with Query4 do //tebie gong cheng
begin
if active then close;
unprepare;
sql.Clear;
sql.Add(' select * from pub_z_contract_specialties ');
sql.Add(' WHERE 合同号 = :hth '); // NOT LIKE ]
sql.Add(' and 所属机型 like ''SM%'' ');
ParamByName('hth').AsString := aaa ;
prepare;
open;
end;
end;
//////
end; //存在时 end
end; //新增时候add new end
if Query1.State = dsEdit then // edit ]
begin
aaa:=DBComboBox1.Text;
new_index:= self.DBComboBox1.Items.IndexOf(aaa);
//判别现在的值与刚进来的时候值得差别;
//new = old no change
//new <> old
// if new < 0 then change to init value
// if new >0 then change;
//if DBComboBox1.Items.IndexOf(DBComboBox1.Text )< 0 then //
if new_index = old_index then
begin
//if MessageBox(handle,'此合同编号没有变化,! 是否重新输入合同编号?','出错',MB_IconQuestion+ MB_OKCANCEL)=IDOK then
DBEdit2.SetFocus;
end
else//<>
begin
if new_index < 0 then
begin
if MessageBox(handle,'此合同编号不存在,是否重新输入合同编号?','出错提示',MB_IconQuestion+ MB_YESNO)=IDYES then
begin//重新输入;
self.DBComboBox1.SetFocus;
self.DBComboBox1.SelText := DBComboBox1_str;//恢复初始值;
end
else
begin
self.DBComboBox1.Text := DBComboBox1_str;//恢复初始值;
self.DBEdit2.SetFocus;
end;
end //<0 end
else// >0 begin
begin
if MessageBox(handle,'是否真的要改变合同编号?','提示',MB_IconQuestion+ MB_YESNO)=IDNO then
begin//不改变;
self.DBComboBox1.Text := DBComboBox1_str;//恢复初始值;
self.DBEdit2.SetFocus;
end
else//改变
begin
////
with Query_contract_client do
begin
if active then close;
unprepare;
sql.Clear;
sql.Add('select * from pub_z_contract ');
sql.Add(' WHERE 合同号 = :hth '); // NOT LIKE ]
Query_contract_client.ParamByName('hth').AsString := aaa;
prepare;
open;
{ while not eof do //Eof and Bof
begin
Query_contract_client.First;
Query1.FieldByName('公司地址').AsString := Query_contract_client.FieldByName('卖方住所').AsString;
Query1.FieldByName('公司联系人').AsString := '楼广' ;//Query_contract_client.FieldByName('卖方住所').AsString;
Query1.FieldByName('交提货方式').AsString := Query_contract_client.FieldByName('交提货方式').AsString;
Query1.FieldByName('交提货费用承担方').AsString := Query_contract_client.FieldByName('交提货费用承担方').AsString;
Query1.FieldByName('公司传真').AsString := Query_contract_client.FieldByName('卖方传真').AsString;
Query1.FieldByName('公司电话').AsString := Query_contract_client.FieldByName('卖方电话').AsString;
Query1.FieldByName('公司开户行').AsString := Query_contract_client.FieldByName('卖方开户银行').AsString;
Query1.FieldByName('公司帐号').AsString := Query_contract_client.FieldByName('卖方银行帐号').AsString;
Query1.FieldByName('税号').AsString := Query_contract_client.FieldByName('卖方税务证号').AsString;
Query_contract_client.Last;
end;}
//检索其它表;
with Query2 do //biao di wu
begin
if active then close;
unprepare;
sql.Clear;
sql.Add('select * from pub_z_contract_machine ');
sql.Add(' WHERE 合同号 = :hth '); // NOT LIKE ]
sql.Add(' and 型号 not like ''SM%'' ');
ParamByName('hth').AsString := aaa ;
prepare;
open;
end;
{ with Query3 do //tebie gong cheng
begin
if active then close;
unprepare;
sql.Clear;
sql.Add('select * from pub_z_contract_project ');
sql.Add(' WHERE 合同号 = :hth '); // NOT LIKE ]
sql.Add(' and 所属机型 not like ''SM%'' ');
ParamByName('hth').AsString := aaa ;
prepare;
open;
end;}
with Query4 do //tebie gong cheng
begin
if active then close;
unprepare;
sql.Clear;
sql.Add(' select * from pub_z_contract_specialties ');
sql.Add(' WHERE 合同号 = :hth '); // NOT LIKE ]
sql.Add(' and 所属机型 not like ''SM%'' ');
ParamByName('hth').AsString := aaa ;
prepare;
open;
end;
end;
////
end//改变 end
end;// >0 end
end;// <> end
end; //edit end
end;
procedure TForm_ys_cjd.Button8Click(Sender: TObject);
begin
Application.CreateForm(TForm_search, Form_search);
form_search.TransADO := self.Query1 ;
unit_wxp.WhichForm := 700 ;
form_search.Showmodal ;
end;
procedure TForm_ys_cjd.Query1AfterScroll(DataSet: TDataSet);
begin
query2select;
end;
procedure TForm_ys_cjd.Button9Click(Sender: TObject);
begin
self.Query1.Active :=false;
self.Query1.SQL.Clear ;
self.Query1.SQL.Add('SELECT * FROM pub_z_contract_machine_requisition_ys ');
self.Query1.Active :=true;
unit_wxp.FinalSql:= 'SELECT * FROM pub_z_contract_machine_requisition_ys ';
end;
procedure TForm_ys_cjd.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
Action:=cafree;
end;
procedure TForm_ys_cjd.FormDestroy(Sender: TObject);
begin
Form_ys_cjd:=nil;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -