⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 contract_cjd.pas

📁 主要是介绍DELPHI三层应用以及分布式数据库的应用
💻 PAS
📖 第 1 页 / 共 2 页
字号:
      btn_cancel.Enabled :=false;
      btn_save.Enabled :=false;

      btn_cancel1.Enabled :=false;
      btn_save1.Enabled :=false;
end;

procedure TForm_zx_cjd.Button1Click(Sender: TObject);
begin
self.Close;
end;

procedure TForm_zx_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.DBComboBox4.SetFocus;
  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 型号 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; //新增时候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
  DBComboBox4.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.Text := DBComboBox1_str;//恢复初始值;
  end
  else
  begin
   self.DBComboBox1.Text := DBComboBox1_str;//恢复初始值;
   self.DBComboBox4.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.DBComboBox4.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_zx_cjd.DBComboBox1Enter(Sender: TObject);
begin
DBComboBox1_str :=  DBComboBox1.Text;//
old_index:= self.DBComboBox1.Items.IndexOf(DBComboBox1_str); //old_index;
 


end;

procedure TForm_zx_cjd.FormKeyPress(Sender: TObject; var Key: Char);
begin
if Key = #13 then
    begin
      Key := #0;
      Perform(WM_NEXTDLGCTL, 0, 0);
    end;

end;

procedure TForm_zx_cjd.btn_firstClick(Sender: TObject);
begin
btn_first1Click(btn_first1);
end;

procedure TForm_zx_cjd.btn_nextClick(Sender: TObject);
begin
 btn_next1Click(btn_next1);
end;

procedure TForm_zx_cjd.btn_lastClick(Sender: TObject);
begin
 btn_last1Click(btn_last1);
end;

procedure TForm_zx_cjd.btn_addnewClick(Sender: TObject);
begin
btn_addnew1Click(btn_addnew1);
end;

procedure TForm_zx_cjd.btn_editClick(Sender: TObject);
begin
 btn_edit1Click(btn_edit1);
end;

procedure TForm_zx_cjd.btn_saveClick(Sender: TObject);
begin
 btn_save1Click(btn_save1) ;
end;

procedure TForm_zx_cjd.btn_cancelClick(Sender: TObject);
begin
btn_cancel1Click(btn_cancel1);
end;

procedure TForm_zx_cjd.btn_prevClick(Sender: TObject);
begin
 btn_prev1Click(btn_prev1) ;
end;

procedure TForm_zx_cjd.Query1AfterScroll(DataSet: TDataSet);
begin
query2select;
end;

procedure TForm_zx_cjd.Button8Click(Sender: TObject);
begin
Application.CreateForm(TForm_search, Form_search);
        form_search.TransADO :=self.Query1 ;
        unit_wxp.WhichForm := 600 ;
        form_search.Showmodal ;
end;

procedure TForm_zx_cjd.Button9Click(Sender: TObject);
begin
     self.Query1.Active :=false;
     self.Query1.SQL.Clear ;
     self.Query1.SQL.Add('select * from pub_z_contract_machine_requisition ');
     self.Query1.Active :=true;
     unit_wxp.FinalSql:= 'select * from pub_z_contract_machine_requisition ';
end;

procedure TForm_zx_cjd.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
 Action:=cafree;
end;

procedure TForm_zx_cjd.PageControl1Change(Sender: TObject);
begin
self.PageControl1.Top:= self.Panel5.Height;
self.VertScrollBar.Position := 0;
self.ScrollBox.VertScrollBar.Position:=0;
end;

procedure TForm_zx_cjd.DBComboBox4Exit(Sender: TObject);
var
aaa: string;
intb: integer;
begin
  aaa:=DBComboBox4.Text;
  if DBComboBox4.Items.IndexOf(DBComboBox4.Text )>= 0 then//not find records
  begin //1
     if  self.query1.State = dsInsert  then //yes  /add new //保留text 值
       begin //
             //aaa:= DBComboBox7.Text :
             if MessageBox(handle,'此编号已存在, 请重新输入一个新的编号!', '出错:编号重名' ,MB_IconQuestion+ MB_OK )= IDOK then
              begin
               //重新输入 ;
               self.DBComboBox4.SelText :=aaa;
               self.DBComboBox4.SetFocus ;
              end

       end;  //dsInsert end;

     if  self.Query1.State = dsEdit  then //add new   dsEdit;//保留原来的值
       begin   //
           if MessageBox(handle,'此编号已存在, 请重新输入一个新的编号!', '出错:编号重名' ,MB_IconQuestion+ MB_OK )= IDOK then
            begin // 重新输入
                  self.DBComboBox4.SelText := DBComboBox1_str; //   DBComboBox1_str is  a public var
                  self.DBComboBox4.SetFocus ;
            end ;
     end;  //
  end //1
  else
  begin
    //合同编号不能为空;
    if length(self.DBComboBox4.Text)<=0 then
       begin
         Beep;
         if MessageBox(handle,'编号不能为空, 请重新输入编号!', '出错:编号' ,MB_IconQuestion+ MB_OK )= IDOK then
         begin
         self.DBComboBox4.SetFocus;
         end
       end
     else
        begin
         self.DBEdit3.SetFocus ;
       end;
  end;
end;//else end;

procedure TForm_zx_cjd.DBComboBox4Enter(Sender: TObject);
begin
//new add
  DBComboBox1_str :=DBComboBox1.Text;//  Query_contract_client.FieldByName('客户名称').AsString;
  DBComboBox1_index:=DBComboBox1.Items.IndexOf(DBComboBox1_str) ;

  //////// ///////////////////
  //hetong hao
  with Query_contract_client  do
  begin
    if active then close;
    unprepare;
    sql.Clear;
    sql.Add('select distinct 编号  from  pub_z_contract_machine_requisition');
    prepare;
    open;
    DBComboBox4.Items.Clear;
    while not eof do
    begin
      DBComboBox4.Items.Add(fieldbyname('编号').AsString);
      next;
    end;
  end;
  ////////////////////
end;

procedure TForm_zx_cjd.FormDestroy(Sender: TObject);
begin
    Form_zx_cjd:=nil;
end;

end.


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -