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

📄 partin.pas

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

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

procedure TForm_partin.btn_filterfieldClick(Sender: TObject);
begin
        Application.CreateForm(TForm_search, Form_search);
        form_search.TransADO  :=self.ADOQuery1 ;
        unit_wxp.WhichForm:=4;
        form_search.Showmodal ;
end;

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

procedure TForm_partin.DBEdit3Enter(Sender: TObject);
begin
     dbedit3.Text :=datetostr(date)  ;
end;

procedure TForm_partin.ADOQuery1AfterOpen(DataSet: TDataSet);
var
i:integer;
tempName:string;
begin
     Label23.Caption :=inttostr(ADOQuery1.Recordset.RecordCount) ;
     if NotFirst=false then
     begin
        StringGrid1.Cells [0,1]:='合计';
        StringGrid1.Cells [0,0]:='统计数据';
        j:=0;
        for i:=0 to self.ADOQuery1.FieldList.Count-1  do
        begin
                //list_fields.Items.Add  (TransADO.Fields[i].FieldName  );
                //将每个字段的字段类型放在数组中
                unit_wxp.FieldType[i]:= self.ADOQuery1.Fields[i].DataType;
                tempName:= self.ADOQuery1 .Fields[i].FieldName ;
                if (tempName<>'单价') and (tempName<>'序号') then
                begin
                     if (unit_wxp.GetFieldType(i)='number') or  (unit_wxp.GetFieldType(i)='money') then
                     begin
                          j:=j+1;
                          StringGrid1.Cells [j,0]:=tempName;
                          stringgrid1.ColCount := stringgrid1.ColCount +1;
                          myIndex[j]:=i;

                     end;
                end;
        end;
        NotFirst:=true;
     end;

     while not ADOQuery1.Eof do
     begin
          for  i:=1 to j do
          begin
               myValue[i]:=myValue[i]+ADOQuery1.Fields.Fields[myIndex[i]].AsFloat ;

          end;
          ADOQuery1.Next ;

     end;
     for i:=1 to j do
     begin
         stringgrid1.Cells[i,1]:=floattostr(myValue[i]);
         myValue[i]:=0;
     end;
end;

procedure TForm_partin.EditDBEdit11Exit(Sender: TObject);
begin
     if  (EditDBEdit11.Text<>'') and (EditDBEdit12.Text<>'') then
     EditDBEdit13.Text :=floattostr(strtofloat(EditDBEdit11.Text )*strtofloat(EditDBEdit12.Text ));
end;

procedure TForm_partin.EditDBEdit12Exit(Sender: TObject);
begin
     if  (EditDBEdit11.Text<>'') and (EditDBEdit12.Text<>'') then
     EditDBEdit13.Text :=floattostr(strtofloat(EditDBEdit11.Text )*strtofloat(EditDBEdit12.Text ));
end;


procedure TForm_partin.Button2Click(Sender: TObject);
begin
     self.ADOQuery1.Active :=false;
     self.ADOQuery1.SQL.Clear ;
     self.ADOQuery1.SQL.Add('select * from pub_z_partin ');
     self.ADOQuery1.Active :=true;
end;

procedure TForm_partin.ADOQuery1AfterPost(DataSet: TDataSet);
var
tempNum:string;
begin
     tempNum:=editdbedit11.Text ;
     dm_wxp.ADOQuery1.Close ;
     dm_wxp.ADOQuery1.SQL.Clear ;
     dm_wxp.ADOQuery1.SQL.Add('update pub_z_part set 库存量=库存量+'+tempNum +' where 编号='''+
     DBComboBox2.Text +'''' );
     dm_wxp.ADOQuery1.ExecSQL ;

end;


procedure  TForm_partin.AddPartNum();
begin
     dm_wxp.ADOQuery1.Close ;
     dm_wxp.ADOQuery1.SQL.Clear ;
     dm_wxp.ADOQuery1.SQL.Add('select 编号,名称 from pub_z_part' );

     dm_wxp.ADOQuery1.Active :=true ;

      while not  dm_wxp.ADOQuery1.Eof    do
      begin
         DBComboBox2.Items.Add(dm_wxp.ADOQuery1.Fields.Fields[0].asstring) ;
         editdbedit9.Items.Add(dm_wxp.ADOQuery1.Fields.Fields[1].asstring) ;
         dm_wxp.ADOQuery1.Next ;
      end;
      dm_wxp.ADOQuery1.Active :=false ;


end;

procedure TForm_partin.DBComboBox2Exit(Sender: TObject);
begin
     if DbComboBox2.Text <>'' then
     begin
     dm_wxp.ADOQuery1.Active :=false;
     dm_wxp.ADOQuery1.SQL.Clear ;
     //showmessage('select 名称,机型,型号 from pub_z_part where 编号='''
     //+self.EditDBEdit2.Text +'''');
     dm_wxp.ADOQuery1.SQL.Add('select 名称,型号,单位,进价,机型 from pub_z_part where 编号='''
     +trim(self.DBComboBox2.Text) +'''');

     dm_wxp.ADOQuery1.Active :=true;
     //showmessage(inttostr(dm_wxp.ADOQuery1.RecordCount ));

     //dm_wxp.ADOQuery1.First ;
     if   dm_wxp.ADOQuery1.eof then

     begin
         showmessage('该零件不存在');
         end;
         end;
end;

procedure TForm_partin.btn_deleteClick(Sender: TObject);
var
tempNum:string;
tempStr:string;
begin
     NumDelete:=editdbedit11.Text ;
     StrDelete:=DBComboBox2.Text;
     if application.MessageBox(pchar('确信要删除这条记录嘛?'),
        pchar('注意'),MB_OKCANCEL)=IDOK then
        
     self.ADOQuery1.Delete ;
     if self.ADOQuery1.Recordset.RecordCount =0 then
     begin
          btn_delete.Enabled :=false;
          btn_edit.Enabled :=false;
     end;
     label23.Caption :=inttostr(self.ADOQuery1.Recordset.RecordCount);
end;

procedure TForm_partin.editdbedit9Exit(Sender: TObject);
begin
     if editdbedit9.Text <>'' then
     begin
     dm_wxp.ADOQuery1.Active :=false;
     dm_wxp.ADOQuery1.SQL.Clear ;
     //showmessage('select 名称,机型,型号 from pub_z_part where 编号='''
     //+self.EditDBEdit2.Text +'''');
     dm_wxp.ADOQuery1.SQL.Add('select 编号,型号,单位,进价,机型 from pub_z_part where 名称='''
     +trim(self.editdbedit9.Text) +'''');

     dm_wxp.ADOQuery1.Active :=true;
     //showmessage(inttostr(dm_wxp.ADOQuery1.RecordCount ));

     //dm_wxp.ADOQuery1.First ;

     if   dm_wxp.ADOQuery1.eof then

     begin
         showmessage('该零件不存在');
         end ;
         end;
end;

procedure TForm_partin.FormDestroy(Sender: TObject);
begin
  Form_partin:=nil;
end;

procedure TForm_partin.ADOQuery1AfterDelete(DataSet: TDataSet);
begin

     dm_wxp.ADOQuery1.Close ;
     dm_wxp.ADOQuery1.SQL.Clear ;
     dm_wxp.ADOQuery1.SQL.Add('update pub_z_part set 库存量=库存量-'+NumDelete +' where 编号='''+
     StrDelete+'''' );
     dm_wxp.ADOQuery1.ExecSQL ;
end;

procedure TForm_partin.DBComboBox2Click(Sender: TObject);
begin
     dm_wxp.ADOQuery1.Active :=false;
     dm_wxp.ADOQuery1.SQL.Clear ;
     //showmessage('select 名称,机型,型号 from pub_z_part where 编号='''
     //+self.EditDBEdit2.Text +'''');
     dm_wxp.ADOQuery1.SQL.Add('select 名称,型号,单位,进价,机型,物资类别 from pub_z_part where 编号='''
     +trim(self.DBComboBox2.Text) +'''');

     dm_wxp.ADOQuery1.Active :=true;
     //showmessage(inttostr(dm_wxp.ADOQuery1.RecordCount ));

     //dm_wxp.ADOQuery1.First ;
     if  not dm_wxp.ADOQuery1.eof then
     begin
          //self.EditDBEdit9.Text :=dm_wxp.ADOQuery1.Fields.Fields[0].AsString ;
          self.ADOQuery1.FieldValues['名称']:=dm_wxp.ADOQuery1.Fields.Fields[0].AsString ;
          self.EditDBEdit10.Text :=dm_wxp.ADOQuery1.Fields.Fields[1].AsString ;
          self.DBEdit2.Text :=dm_wxp.ADOQuery1.Fields.Fields[2].AsString ;
          self.EditDBEdit12.Text :=dm_wxp.ADOQuery1.Fields.Fields[3].AsString ;
          self.DBEdit6.Text := dm_wxp.ADOQuery1.Fields.Fields[4].AsString ;
          self.DBEdit7.Text := dm_wxp.ADOQuery1.Fields.Fields[5].AsString ;
     end;
end;

procedure TForm_partin.editdbedit9Click(Sender: TObject);
begin
dm_wxp.ADOQuery1.Active :=false;
     dm_wxp.ADOQuery1.SQL.Clear ;
     //showmessage('select 名称,机型,型号 from pub_z_part where 编号='''
     //+self.EditDBEdit2.Text +'''');
     dm_wxp.ADOQuery1.SQL.Add('select 编号,型号,单位,进价,机型,物资类别 from pub_z_part where 名称='''
     +trim(self.editdbedit9.Text) +'''');

     dm_wxp.ADOQuery1.Active :=true;
     //showmessage(inttostr(dm_wxp.ADOQuery1.RecordCount ));

     //dm_wxp.ADOQuery1.First ;
     if  dm_wxp.ADOQuery1.RecordCount<>0 then
     begin
          //self.DBComboBox1.SetFocus ;
          //self.DBComboBox2.Text :=dm_wxp.ADOQuery1.Fields.Fields[0].AsString ;
          self.ADOQuery1.FieldValues['物资编号']:=dm_wxp.ADOQuery1.Fields.Fields[0].AsString ;
          self.EditDBEdit10.Text :=dm_wxp.ADOQuery1.Fields.Fields[1].AsString ;
          self.DBEdit2.Text :=dm_wxp.ADOQuery1.Fields.Fields[2].AsString ;
          self.EditDBEdit12.Text :=dm_wxp.ADOQuery1.Fields.Fields[3].AsString ;
          self.DBEdit6.Text := dm_wxp.ADOQuery1.Fields.Fields[4].AsString ;
          self.DBEdit7.Text := dm_wxp.ADOQuery1.Fields.Fields[5].AsString ;
     end;
end;

procedure TForm_partin.PageControl1Change(Sender: TObject);
begin
     if pagecontrol1.TabIndex =0 then
     begin
       panel1.Enabled :=true;
     end
     else
     begin
       panel1.Enabled :=false;
     end;
end;

end.

⌨️ 快捷键说明

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