X
xhzhengzheng
Unregistered / Unconfirmed
GUEST, unregistred user!
Delphi7运行一个程序,老是跳出如下错误,'access violation at 0x4be43541 : read of address 0x0000000026'. Process Stopped . Use Step or Run to continue.(100分)<br />我在Delphi7运行一个程序,老是跳出如下错误,<br>Debugger Fault Notification<br>'access violation at 0x4be43541 : read of address 0x0000000026'. Process Stopped . Use Step or Run to continue.<br><br>然后就是显示CPU运行界面,但是这个程序可以Compile和 Build ,就是不能Debug ,数据库联接是Dephi7中的BDE,差不过在运行到联接ORACLE8i数据库时就提示上面的内容,我不知道应该怎样处理好?<br>部分原代码,帮忙看看有没有错.<br>(以下为从A数据库ORACEL某一表中读取数据据,向B SYBASE数据库中的某表中导入数据,中间有转换数据库,是作为AB两数据库的临时存储)<br>object Form1: TForm1<br> Left = 113<br> Top = 73<br> BorderStyle = bsDialog<br> Caption = '转换程序'<br> ClientHeight = 573<br> ClientWidth = 792<br> Color = clBtnFace<br> Font.Charset = GB2312_CHARSET<br> Font.Color = clBlack<br> Font.Height = -15<br> Font.Name = '宋体'<br> Font.Style = []<br> OldCreateOrder = False<br> OnCreate = FormCreate<br> PixelsPerInch = 96<br> TextHeight = 15<br> object Label1: TLabel<br> Left = 16<br> Top = 544<br> Width = 181<br> Height = 15<br> Caption = '可选单数:0;已选单数:0'<br> Font.Charset = GB2312_CHARSET<br> Font.Color = clRed<br> Font.Height = -15<br> Font.Name = '宋体'<br> Font.Style = []<br> ParentFont = False<br> end<br> object Label2: TLabel<br> Left = 328<br> Top = 544<br> Width = 48<br> Height = 15<br> Caption = '99/100'<br> Color = clBtnFace<br> Font.Charset = GB2312_CHARSET<br> Font.Color = clBlue<br> Font.Height = -15<br> Font.Name = '宋体'<br> Font.Style = []<br> ParentColor = False<br> ParentFont = False<br> Visible = False<br> end<br> object DBGrid1: TDBGrid<br> Left = 16<br> Top = 16<br> Width = 761<br> Height = 241<br> Ctl3D = False<br> DataSource = DataSource1<br> Font.Charset = GB2312_CHARSET<br> Font.Color = clBlack<br> Font.Height = -15<br> Font.Name = '宋体'<br> Font.Style = []<br> Options = [dgTitles, dgColumnResize, dgColLines, dgTabs, dgRowSelect, dgConfirmDelete, dgCancelOnExit]<br> ParentCtl3D = False<br> ParentFont = False<br> PopupMenu = PopupMenu1<br> ReadOnly = True<br> TabOrder = 0<br> TitleFont.Charset = GB2312_CHARSET<br> TitleFont.Color = clBlack<br> TitleFont.Height = -15<br> TitleFont.Name = '宋体'<br> TitleFont.Style = []<br> OnDblClick = DBGrid1DblClick<br> OnTitleClick = DBGrid1TitleClick<br> Columns = <<br> item<br> Expanded = False<br> FieldName = 'Incabillid'<br> Title.Caption = '英.单号'<br> Width = 85<br> Visible = True<br> end<br> item<br> Expanded = False<br> FieldName = 'Incagysid'<br> Title.Caption = '英.供号'<br> Width = 81<br> Visible = True<br> end<br> item<br> Expanded = False<br> FieldName = 'Rhgysid'<br> Title.Caption = '润.供号'<br> Width = 68<br> Visible = True<br> end<br> item<br> Expanded = False<br> FieldName = 'Incagysname'<br> Title.Caption = '英.供应商'<br> Width = 171<br> Visible = True<br> end<br> item<br> Expanded = False<br> FieldName = 'Rhgysname'<br> Title.Caption = '润.供应商'<br> Width = 156<br> Visible = True<br> end<br> item<br> Expanded = False<br> FieldName = 'Incadate'<br> Title.Caption = '开单日期'<br> Width = 81<br> Visible = True<br> end<br> item<br> Expanded = False<br> FieldName = 'Je'<br> Title.Caption = '金额'<br> Visible = True<br> end><br> end<br> object DBGrid2: TDBGrid<br> Left = 16<br> Top = 296<br> Width = 761<br> Height = 241<br> Ctl3D = False<br> DataSource = DataSource2<br> Font.Charset = GB2312_CHARSET<br> Font.Color = clBlack<br> Font.Height = -15<br> Font.Name = '宋体'<br> Font.Style = []<br> Options = [dgTitles, dgColumnResize, dgColLines, dgTabs, dgRowSelect, dgConfirmDelete, dgCancelOnExit]<br> ParentCtl3D = False<br> ParentFont = False<br> PopupMenu = PopupMenu2<br> ReadOnly = True<br> TabOrder = 1<br> TitleFont.Charset = GB2312_CHARSET<br> TitleFont.Color = clBlack<br> TitleFont.Height = -15<br> TitleFont.Name = '宋体'<br> TitleFont.Style = []<br> OnDblClick = DBGrid2DblClick<br> OnTitleClick = DBGrid2TitleClick<br> Columns = <<br> item<br> Expanded = False<br> FieldName = 'Incabillid'<br> Title.Caption = '英.单号'<br> Width = 85<br> Visible = True<br> end<br> item<br> Expanded = False<br> FieldName = 'Incagysid'<br> Title.Caption = '英.供号'<br> Width = 81<br> Visible = True<br> end<br> item<br> Expanded = False<br> FieldName = 'Rhgysid'<br> Title.Caption = '润.供号'<br> Width = 68<br> Visible = True<br> end<br> item<br> Expanded = False<br> FieldName = 'Incagysname'<br> Title.Caption = '英.供应商'<br> Width = 171<br> Visible = True<br> end<br> item<br> Expanded = False<br> FieldName = 'Rhgysname'<br> Title.Caption = '润.供应商'<br> Width = 156<br> Visible = True<br> end<br> item<br> Expanded = False<br> FieldName = 'Incadate'<br> Title.Caption = '开单日期'<br> Width = 81<br> Visible = True<br> end<br> item<br> Expanded = False<br> FieldName = 'Je'<br> Title.Caption = '金额'<br> Visible = True<br> end><br> end<br> object Button1: TButton<br> Left = 16<br> Top = 264<br> Width = 75<br> Height = 22<br> Caption = '增加 ▼'<br> Font.Charset = GB2312_CHARSET<br> Font.Color = clBlack<br> Font.Height = -15<br> Font.Name = '宋体'<br> Font.Style = []<br> ParentFont = False<br> TabOrder = 2<br> OnClick = Button1Click<br> end<br> object Button2: TButton<br> Left = 96<br> Top = 264<br> Width = 75<br> Height = 22<br> Caption = '全加▼▼'<br> Font.Charset = GB2312_CHARSET<br> Font.Color = clBlack<br> Font.Height = -15<br> Font.Name = '宋体'<br> Font.Style = []<br> ParentFont = False<br> TabOrder = 3<br> OnClick = Button2Click<br> end<br> object Button3: TButton<br> Left = 624<br> Top = 264<br> Width = 75<br> Height = 22<br> Caption = '删除▲'<br> Font.Charset = GB2312_CHARSET<br> Font.Color = clBlack<br> Font.Height = -15<br> Font.Name = '宋体'<br> Font.Style = []<br> ParentFont = False<br> TabOrder = 4<br> OnClick = Button3Click<br> end<br> object Button4: TButton<br> Left = 704<br> Top = 264<br> Width = 75<br> Height = 22<br> Caption = '全删▲▲'<br> Font.Charset = GB2312_CHARSET<br> Font.Color = clBlack<br> Font.Height = -15<br> Font.Name = '宋体'<br> Font.Style = []<br> ParentFont = False<br> TabOrder = 5<br> OnClick = Button4Click<br> end<br> object Button5: TButton<br> Left = 704<br> Top = 544<br> Width = 75<br> Height = 22<br> Caption = '开始转换'<br> Font.Charset = GB2312_CHARSET<br> Font.Color = clBlack<br> Font.Height = -15<br> Font.Name = '宋体'<br> Font.Style = []<br> ParentFont = False<br> TabOrder = 6<br> OnClick = Button5Click<br> end<br> object Button6: TButton<br> Left = 264<br> Top = 264<br> Width = 113<br> Height = 22<br> Caption = '读入英克数据'<br> Font.Charset = GB2312_CHARSET<br> Font.Color = clBlack<br> Font.Height = -15<br> Font.Name = '宋体'<br> Font.Style = []<br> ParentFont = False<br> TabOrder = 7<br> OnClick = Button6Click<br> end<br> object ProgressBar1: TProgressBar<br> Left = 16<br> Top = 561<br> Width = 681<br> Height = 7<br> TabOrder = 8<br> Visible = False<br> end<br> object Button7: TButton<br> Left = 432<br> Top = 264<br> Width = 113<br> Height = 22<br> Caption = '出库单转换'<br> TabOrder = 9<br> OnClick = Button7Click<br> end<br> object DataSource1: TDataSource<br> DataSet = Query1<br> Left = 16<br> Top = 448<br> end<br> object DataSource2: TDataSource<br> DataSet = Query2<br> Left = 152<br> Top = 448<br> end<br> object Table3: TTable<br> DatabaseName = 'tempdb'<br> TableName = 'Fromtemp.DB'<br> Left = 544<br> Top = 64<br> end<br> object Table4: TTable<br> DatabaseName = 'tempdb'<br> TableName = 'Totemp.DB'<br> Left = 352<br> Top = 448<br> end<br> object BatchMove1: TBatchMove<br> Left = 608<br> Top = 64<br> end<br> object Query1: TQuery<br> DatabaseName = 'tempdb'<br> Left = 192<br> Top = 264<br> end<br> object Query2: TQuery<br> DatabaseName = 'tempdb'<br> Left = 232<br> Top = 264<br> end<br> object Query3: TQuery<br> DatabaseName = 'tempdb'<br> Left = 272<br> Top = 96<br> end<br> object Query4: TQuery<br> DatabaseName = 'tempdb'<br> Left = 312<br> Top = 96<br> end<br> object Query5: TQuery<br> DatabaseName = 'DelphiInca'<br> SQL.Strings = (<br> <br> 'SELECT "BMS_SU_DOC_V"."SUDOCID", "BMS_SU_DOC_V"."CREDATE", "BMS_' +<br> 'SU_DOC_V"."SUPPLYID", "BMS_SU_DOC_V"."SUPPLYNAME", "BMS_SU_DOC_V' +<br> '"."TOTAL", "BMS_SU_DOC_V"."DTL_LINES",'<br> <br> '"BMS_SU_DOC_V"."INPUTMANID", "BMS_SU_DOC_V"."FACTCERTNO", "BMS_S' +<br> 'U_DOC_V"."ARRIVEDATE", "BMS_SU_DOC_V"."DELIVERDATE", "BMS_SU_DOC' +<br> '_V"."TRANSDOCNO", '<br> <br> '"BMS_SU_DOC_V"."MEMO", "BMS_SU_DOC_V"."SUTYPEID", "BMS_SU_DOC_V"' +<br> '."SUPPLYOPCODE", "BMS_SU_DOC_V"."SUPPLYNO", "BMS_SU_DOC_V"."SUPP' +<br> 'LYPINYIN", '<br> <br> '"BMS_SU_DOC_V"."INVOICEPRECISION", "BMS_SU_DOC_V"."USESTATUS", "' +<br> 'BMS_SU_DOC_V"."INPUTMANNAME", "BMS_SU_DOC_V"."INPUTMANOPCODE", "' +<br> 'BMS_SU_DOC_V"."INPUTMANPINYIN", '<br><br> '"BMS_SU_DOC_V"."INITFLAG", "BMS_SU_DOC_V"."ENTRYID", "BMS_SU_DOC' +<br> '_V"."ENTRYNAME", "BMS_SU_DOC_V"."ENGLISHSHORT", "BMS_SU_DOC_V"."' +<br> 'FMID", "BMS_SU_DOC_V"."FMNAME", '<br> <br> '"BMS_SU_DOC_V"."EXCHANGE" , "BMS_SU_DOC_V"."INVOICETYPE", BMS_SU' +<br> '_DOC_V.zxcolumn1, BMS_SU_DOC_V.zxcolumn2, BMS_SU_DOC_V.zxcolumn3' +<br> ', BMS_SU_DOC_V.zxcolumn4, '<br> <br> 'BMS_SU_DOC_V.zxcolumn5, BMS_SU_DOC_V.zxcolumn6, BMS_SU_DOC_V.zxc' +<br> 'olumn7, BMS_SU_DOC_V.zxcolumn8, BMS_SU_DOC_V.zxcolumn9, BMS_SU_D' +<br> 'OC_V.zxcolumn10 '<br> 'FROM "BMS_SU_DOC_V" '<br> 'where '<br> 'bms_su_doc_v.sudocid in ('<br> 'select bms_su_doc_v.sudocid '<br> 'from bms_su_doc_v,bms_su_dtl_v '<br> <br> 'where bms_su_doc_v.sudocid=bms_su_dtl_v.sudocid and BMS_SU_DOC_V' +<br> '.CREDATE between :startdate and :enddate and'<br><br> ' (BMS_SU_DTL_V.sutypeid not in (select sutypeid from bms_sudoc_t' +<br> 'ype where systype = 3)) '<br> <br> 'and (BMS_SU_DTL_V.USESTATUS not in (0)) and (BMS_SU_DTL_V.USESTA' +<br> 'TUS not in (0)) ) ')<br> Left = 472<br> Top = 256<br> ParamData = <<br> item<br> DataType = ftUnknown<br> Name = 'startdate'<br> ParamType = ptUnknown<br> end<br> item<br> DataType = ftUnknown<br> Name = 'enddate'<br> ParamType = ptUnknown<br> end><br> end<br> object Query6: TQuery<br> DatabaseName = 'DelphiRhyao'<br> SQL.Strings = (<br> 'select * from sitrh a,pos01.khda b'<br> 'where a.b=b.dwbh')<br> Left = 408<br> Top = 256<br> end<br> object PopupMenu1: TPopupMenu<br> Left = 288<br> Top = 200<br> object N12121: TMenuItem<br> Caption = '供应商对应关系'<br> OnClick = N12121Click<br> end<br> end<br> object PopupMenu2: TPopupMenu<br> Left = 392<br> Top = 376<br> object N1: TMenuItem<br> Caption = '供应商对应关系'<br> OnClick = N1Click<br> end<br> end<br> object Query7: TQuery<br> DatabaseName = 'DelphiInca'<br> Left = 384<br> Top = 448<br> end<br> object Query8: TQuery<br> DatabaseName = 'DelphiRhyao'<br> SQL.Strings = (<br> 'select * from gitrh a,pos01.cpda b '<br> 'where a.b=b.cpbh and a.a=:incaid')<br> Left = 416<br> Top = 448<br> ParamData = <<br> item<br> DataType = ftUnknown<br> Name = 'incaid'<br> ParamType = ptUnknown<br> end><br> end<br>end<br><br>出错的PAS程序代码:<br>unit Unit1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> Dialogs, DB, DBTables, Grids, DBGrids, StdCtrls, Menus, ComCtrls;<br><br>type<br> TForm1 = class(TForm)<br> DBGrid1: TDBGrid;<br> DBGrid2: TDBGrid;<br> Button1: TButton;<br> Button2: TButton;<br> Button3: TButton;<br> Button4: TButton;<br> DataSource1: TDataSource;<br> DataSource2: TDataSource;<br> Button5: TButton;<br> Button6: TButton;<br> Table3: TTable;<br> Table4: TTable;<br> BatchMove1: TBatchMove;<br> Label1: TLabel;<br> Query1: TQuery;<br> Query2: TQuery;<br> Query3: TQuery;<br> Query4: TQuery;<br> Query5: TQuery;<br> Query6: TQuery;<br> PopupMenu1: TPopupMenu;<br> N12121: TMenuItem;<br> PopupMenu2: TPopupMenu;<br> N1: TMenuItem;<br> ProgressBar1: TProgressBar;<br> Label2: TLabel;<br> Query7: TQuery;<br> Query8: TQuery;<br> Button7: TButton;<br> procedure FormCreate(Sender: TObject);<br> procedure Button6Click(Sender: TObject);<br> procedure DBGrid1DblClick(Sender: TObject);<br> procedure DBGrid2DblClick(Sender: TObject);<br> procedure Button1Click(Sender: TObject);<br> procedure Button3Click(Sender: TObject);<br> procedure Button2Click(Sender: TObject);<br> procedure Button4Click(Sender: TObject);<br> procedure DBGrid1TitleClick(Column: TColumn);<br> procedure DBGrid2TitleClick(Column: TColumn);<br> procedure N12121Click(Sender: TObject);<br> procedure N1Click(Sender: TObject);<br> procedure Button5Click(Sender: TObject);<br> procedure Button7Click(Sender: TObject);<br> private<br> ls_bookmark_001:integer;<br> ls_bookmark_002:integer;<br> orderby01_s,orderby02_s:string;<br> orderby01_b,orderby02_b:boolean;<br> un_sel_count,sel_count:integer;<br> function mygyspassok:boolean;<br> function mygoodspassok:boolean;<br> procedure addone;<br> procedure addall;<br> procedure deleteone;<br> procedure deleteall;<br> procedure refreshinterface;<br> procedure refreshquerys01;<br> procedure refreshquerys02;<br> procedure refreshgys;<br> { Private declarations }<br> public<br> current_usename:string;<br> { Public declarations }<br> end;<br><br>var<br> Form1: TForm1;<br><br>implementation<br><br>uses Unit2, Unit5, Unit6, Unit4, Unit7;<br><br>{$R *.dfm}<br>function myCopytorh(<br>ls_Params1,ls_Params2,ls_Params3:tstrings;<br>ProgressBar1:TProgressBar;<br>Label2:TLabel;<br>current_usename:String<br>):boolean;stdcall;external 'Project.pas';<br><br>procedure TForm1.FormCreate(Sender: TObject);<br>begin<br> current_usename:=Application.Title;<br> Application.Title:='转换程序';<br> Self.Left:=(Screen.Width-Self.Width) div 2;<br> Self.Top:=(Screen.Height-Self.Height) div 2;<br> Table3.Active:=false;<br> Table3.EmptyTable;<br> Table4.Active:=false;<br> Table4.EmptyTable;<br> un_sel_count:=0;<br> sel_count:=0;<br> orderby01_s:='';<br> orderby02_s:='';<br> orderby01_b:=false;<br> orderby02_b:=false;<br> refreshquerys01;<br> refreshquerys02;<br> refreshinterface;<br>end;<br><br>procedure TForm1.Button6Click(Sender: TObject);<br>var<br> i:integer;<br> start_date,end_date:tdate;<br> ls_supply_array:array[1..6000,1..3] of string;<br> ls_supply_array_total:integer;<br>begin<br> form2:=tform2.Create(self);<br> form2.ShowModal;<br> if Form2.selectedok then begin<br> Query6.Active:=false;<br> Query6.Active:=true;<br> ls_supply_array_total:=0;<br> while not(Query6.Eof) do<br> begin<br> ls_supply_array_total:=ls_supply_array_total+1;<br> ls_supply_array[ls_supply_array_total,1]:=Query6.Fieldbyname('a').AsString;<br> ls_supply_array[ls_supply_array_total,2]:=Query6.Fieldbyname('dwbh').AsString;<br> ls_supply_array[ls_supply_array_total,3]:=Query6.Fieldbyname('dwmc').AsString;<br> Query6.Next;<br> end;<br> Query6.Active:=false;<br> start_date:=form2.DateTimePicker1.Date;<br> end_date:=form2.DateTimePicker2.Date;<br> Query5.Active:=false;<br> query5.ParamByName('startdate').AsDate:=start_date;<br> query5.ParamByName('enddate').AsDate:=end_date;<br> Query5.Active:=true;<br> Table3.Active:=false;<br> Table3.EmptyTable;<br> Table3.Active:=true;<br> while not(query5.Eof) do<br> begin<br> Table3.Append;<br> for i:=1 to ls_supply_array_total do begin<br> if (strtoint(ls_supply_array[i,1])=query5.Fieldbyname('supplyid').AsInteger) then begin<br> Table3.FieldByName('Rhgysid').AsString:=ls_supply_array[i,2];<br> Table3.FieldByName('rhgysname').AsString:=ls_supply_array[i,3];<br> break;<br> end;<br> end;<br> Table3.FieldByName('incabillid').AsInteger:=query5.Fieldbyname('sudocid').AsInteger;<br> Table3.FieldByName('incagysid').AsInteger:=query5.Fieldbyname('supplyid').AsInteger;<br> Table3.FieldByName('incagysname').AsString:=query5.Fieldbyname('supplyname').AsString;<br> Table3.FieldByName('je').AsFloat:=query5.Fieldbyname('total').AsFloat;<br> Table3.FieldByName('incadate').AsDateTime:=query5.Fieldbyname('arrivedate').AsDateTime;<br> Table3.FieldByName('rhdate').AsDateTime:=query5.Fieldbyname('arrivedate').AsDateTime;<br> Table3.Post;<br> Query5.Next;<br> end;<br> Table3.Active:=false;<br> refreshquerys01;<br> refreshquerys02;<br> refreshinterface;<br> end;<br> form2.Free;<br>end;<br><br>procedure TForm1.addone;<br>begin<br> if Query1.Fieldbyname('incabillid').AsInteger>0 then begin<br> ls_bookmark_001:=query1.RecNo;<br> Query4.Active:=false;<br> Query4.SQL.Clear;<br> Query4.SQL.Add('insert into totemp.db (incabillid,incagysid,rhgysid,incagysname,rhgysname,incadate,rhdate,je) values pincabillid,incagysid,rhgysid,incagysname,rhgysname,incadate,rhdate,je)');<br> Query4.ParamByName('pincabillid').AsInteger:=Query1.Fieldbyname('incabillid').AsInteger;<br> Query4.ParamByName('pincagysid').AsInteger:=Query1.Fieldbyname('incagysid').AsInteger;<br> Query4.ParamByName('prhgysid').AsString:=Query1.Fieldbyname('rhgysid').AsString;<br> Query4.ParamByName('pincagysname').AsString:=Query1.Fieldbyname('incagysname').AsString;<br> Query4.ParamByName('prhgysname').AsString:=Query1.Fieldbyname('rhgysname').AsString;<br> Query4.ParamByName('pincadate').AsDate:=Query1.Fieldbyname('incadate').AsDateTime;<br> Query4.ParamByName('prhdate').AsDate:=Query1.Fieldbyname('rhdate').AsDateTime;<br> Query4.ParamByName('pje').AsFloat:=Query1.Fieldbyname('je').AsFloat;<br> Query4.ExecSQL;<br> Query3.Active:=false;<br> Query3.SQL.Clear;<br> Query3.SQL.Add('delete from fromtemp.db where autoid=autoid');<br> Query3.ParamByName('pautoid').AsInteger:=Query1.Fieldbyname('autoid').AsInteger;<br> Query3.ExecSQL;<br> refreshquerys01;<br> refreshquerys02;<br> refreshinterface;<br> ls_bookmark_001:=-1;<br> end;<br>end;<br><br>procedure TForm1.addall;<br>begin<br> Table3.Active:=true;<br> Table4.Active:=true;<br> if Table3.IsEmpty=false then begin<br> BatchMove1.Source:=Table3;<br> BatchMove1.Destination:=Table4;<br> BatchMove1.Execute;<br> Table3.Active:=false;<br> Table3.EmptyTable;<br> refreshquerys01;<br> refreshquerys02;<br> refreshinterface;<br> end;<br> Table3.Active:=false;<br> Table4.Active:=false;<br>end;<br><br>procedure TForm1.deleteone;<br>begin<br> if Query2.Fieldbyname('incabillid').AsInteger>0 then begin<br> ls_bookmark_002:=query2.RecNo;<br> Query4.Active:=false;<br> Query4.SQL.Clear;<br> Query4.SQL.Add('insert into fromtemp.db (incabillid,incagysid,rhgysid,incagysname,rhgysname,incadate,rhdate,je) values pincabillid,incagysid,rhgysid,incagysname,rhgysname,incadate,rhdate,je)');<br> Query4.ParamByName('pincabillid').AsInteger:=Query2.Fieldbyname('incabillid').AsInteger;<br> Query4.ParamByName('pincagysid').AsInteger:=Query2.Fieldbyname('incagysid').AsInteger;<br> Query4.ParamByName('prhgysid').AsString:=Query2.Fieldbyname('rhgysid').AsString;<br> Query4.ParamByName('pincagysname').AsString:=Query2.Fieldbyname('incagysname').AsString;<br> Query4.ParamByName('prhgysname').AsString:=Query2.Fieldbyname('rhgysname').AsString;<br> Query4.ParamByName('pincadate').AsDate:=Query2.Fieldbyname('incadate').AsDateTime;<br> Query4.ParamByName('prhdate').AsDate:=Query2.Fieldbyname('rhdate').AsDateTime;<br> Query4.ParamByName('pje').AsFloat:=Query2.Fieldbyname('je').AsFloat;<br> Query4.ExecSQL;<br> Query3.Active:=false;<br> Query3.SQL.Clear;<br> Query3.SQL.Add('delete from totemp.db where autoid=autoid');<br> Query3.ParamByName('pautoid').AsInteger:=Query2.Fieldbyname('autoid').AsInteger;<br> Query3.ExecSQL;<br> refreshquerys01;<br> refreshquerys02;<br> refreshinterface;<br> ls_bookmark_002:=-1;<br> end;<br>end;<br><br>procedure TForm1.deleteall;<br>begin<br> Table3.Active:=true;<br> Table4.Active:=true;<br> if Table4.IsEmpty=false then begin<br> BatchMove1.Source:=Table4;<br> BatchMove1.Destination:=Table3;<br> BatchMove1.Execute;<br> Table4.Active:=false;<br> Table4.EmptyTable;<br> refreshquerys01;<br> refreshquerys02;<br> refreshinterface;<br> end;<br> Table3.Active:=false;<br> Table4.Active:=false;<br>end;<br><br>procedure TForm1.DBGrid1DblClick(Sender: TObject);<br>begin<br> addone;<br>end;<br><br>procedure TForm1.DBGrid2DblClick(Sender: TObject);<br>begin<br> deleteone;<br>end;<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br> addone;<br>end;<br><br>procedure TForm1.Button3Click(Sender: TObject);<br>begin<br> deleteone;<br>end;<br><br>procedure TForm1.Button2Click(Sender: TObject);<br>begin<br> addall;<br>end;<br><br>procedure TForm1.Button4Click(Sender: TObject);<br>begin<br> deleteall;<br>end;<br><br>procedure TForm1.refreshinterface;<br>begin<br> un_sel_count:=Query1.RecordCount;<br> sel_count:=Query2.RecordCount;<br> Label1.Caption:='可选单数:'+inttostr(un_sel_count)+';已选单数:'+inttostr(sel_count);<br> Button1.Enabled:=true;<br> Button2.Enabled:=true;<br> Button3.Enabled:=true;<br> Button4.Enabled:=true;<br> DBGrid1.PopupMenu:=PopupMenu1;<br> DBGrid2.PopupMenu:=PopupMenu2;<br> Button5.Enabled:=true;<br> if un_sel_count=0 then begin<br> DBGrid1.PopupMenu:=nil;<br> Button1.Enabled:=false;<br> Button2.Enabled:=false;<br> end;<br> if sel_count=0 then begin<br> DBGrid2.PopupMenu:=nil;<br> Button3.Enabled:=false;<br> Button4.Enabled:=false;<br> Button5.Enabled:=false;<br> end;<br>end;<br><br>procedure TForm1.refreshquerys01;<br>var<br> i:integer;<br>begin<br> Query1.Active:=false;<br> Query1.SQL.Clear;<br> query1.SQL.Add('select * from Fromtemp.DB');<br> if orderby01_s<>'' then begin<br> query1.SQL.Add('order by '+orderby01_s);<br> if orderby01_b then begin<br> query1.SQL.Add(' desc');<br> end;<br> end;<br> Query1.Active:=true;<br> if (query1.IsEmpty=false) and (ls_bookmark_001<>-1) then begin<br> query1.First;<br> Query1.MoveBy(ls_bookmark_001);<br> end;<br> for i:=0 to DBGrid1.Columns.Count-1 do begin<br> if ((copy(DBGrid1.Columns.Title.Caption,(length(DBGrid1.Columns.Title.Caption)-1),2)='▼') or<br> (copy(DBGrid1.Columns.Title.Caption,(length(DBGrid1.Columns.Title.Caption)-1),2)='▲')) then begin<br> DBGrid1.Columns.Title.Caption:=copy(DBGrid1.Columns.Title.Caption,1,(length(DBGrid1.Columns.Title.Caption)-2));<br> end;<br> if DBGrid1.Columns.DisplayName=orderby01_s then begin<br> if orderby01_b then<br> begin<br> DBGrid1.Columns.Title.Caption:=DBGrid1.Columns.Title.Caption+'▼';<br> end<br> else<br> begin<br> DBGrid1.Columns.Title.Caption:=DBGrid1.Columns.Title.Caption+'▲';<br> end;<br> end;<br> end;<br>end;<br><br>procedure TForm1.refreshquerys02;<br>var<br> i:integer;<br>begin<br> Query2.Active:=false;<br> Query2.SQL.Clear;<br> query2.SQL.Add('select * from Totemp.DB');<br> if orderby02_s<>'' then begin<br> query2.SQL.Add('order by '+orderby02_s);<br> if orderby02_b then begin<br> query2.SQL.Add(' desc');<br> end;<br> end;<br> Query2.Active:=true;<br> if (query2.IsEmpty=false) and (ls_bookmark_002<>-1) then begin<br> query2.First;<br> Query2.MoveBy(ls_bookmark_002);<br> end;<br> for i:=0 to DBGrid2.Columns.Count-1 do begin<br> if ((copy(DBGrid2.Columns.Title.Caption,(length(DBGrid2.Columns.Title.Caption)-1),2)='▼') or<br> (copy(DBGrid2.Columns.Title.Caption,(length(DBGrid2.Columns.Title.Caption)-1),2)='▲')) then begin<br> DBGrid2.Columns.Title.Caption:=copy(DBGrid2.Columns.Title.Caption,1,(length(DBGrid2.Columns.Title.Caption)-2));<br> end;<br> if DBGrid2.Columns.DisplayName=orderby02_s then begin<br> if orderby02_b then<br> begin<br> DBGrid2.Columns.Title.Caption:=DBGrid2.Columns.Title.Caption+'▼';<br> end<br> else<br> begin<br> DBGrid2.Columns.Title.Caption:=DBGrid2.Columns.Title.Caption+'▲';<br> end;<br> end;<br> end;<br>end;<br><br>procedure TForm1.DBGrid1TitleClick(Column: TColumn);<br>begin<br> if Column.DisplayName=orderby01_s then<br> begin<br> orderby01_b:=not(orderby01_b);<br> end<br> else<br> begin<br> orderby01_s:=Column.DisplayName;<br> orderby01_b:=false;<br> end;<br> refreshquerys01;<br>end;<br><br>procedure TForm1.DBGrid2TitleClick(Column: TColumn);<br>begin<br> if Column.DisplayName=orderby02_s then<br> begin<br> orderby02_b:=not(orderby02_b);<br> end<br> else<br> begin<br> orderby02_s:=Column.DisplayName;<br> orderby02_b:=false;<br> end;<br> refreshquerys02;<br>end;<br><br>procedure TForm1.N12121Click(Sender: TObject);<br>begin<br> form5:=tform5.Create(self);<br> form5.incaoid:=Query1.Fieldbyname('incagysid').AsInteger;<br> form5.rhid:=Query1.Fieldbyname('rhgysid').AsString;<br> form5.ShowModal;<br> if Form5.Sel_Id<>'' then begin<br> refreshgys;<br> end;<br> form5.Free;<br>end;<br><br>procedure TForm1.N1Click(Sender: TObject);<br>begin<br> form5:=tform5.Create(self);<br> form5.incaoid:=Query2.Fieldbyname('incagysid').AsInteger;<br> form5.rhid:=Query2.Fieldbyname('rhgysid').AsString;<br> form5.ShowModal;<br> if Form5.Sel_Id<>'' then begin<br> refreshgys;<br> end;<br> form5.Free;<br>end;<br><br>procedure TForm1.refreshgys;<br>var<br> i:integer;<br> ls_supply_array:array[1..6000,1..3] of string;<br> ls_supply_array_total:integer;<br>begin<br> Query6.Active:=false;<br> Query6.Active:=true;<br> ls_supply_array_total:=0;<br> while not(Query6.Eof) do<br> begin<br> ls_supply_array_total:=ls_supply_array_total+1;<br> ls_supply_array[ls_supply_array_total,1]:=Query6.Fieldbyname('a').AsString;<br> ls_supply_array[ls_supply_array_total,2]:=Query6.Fieldbyname('dwbh').AsString;<br> ls_supply_array[ls_supply_array_total,3]:=Query6.Fieldbyname('dwmc').AsString;<br> Query6.Next;<br> end;<br> Table3.Active:=true;<br> while not(Table3.Eof) do<br> begin<br> Table3.Edit;<br> for i:=1 to ls_supply_array_total do begin<br> if (strtoint(ls_supply_array[i,1])=Table3.Fieldbyname('incagysid').AsInteger) then begin<br> Table3.FieldByName('Rhgysid').AsString:=ls_supply_array[i,2];<br> Table3.FieldByName('rhgysname').AsString:=ls_supply_array[i,3];<br> break;<br> end;<br> end;<br> Table3.Post;<br> Table3.Next;<br> end;<br> Table3.Active:=false;<br> Table4.Active:=true;<br> while not(Table4.Eof) do<br> begin<br> Table4.Edit;<br> for i:=1 to ls_supply_array_total do begin<br> if (strtoint(ls_supply_array[i,1])=Table4.Fieldbyname('incagysid').AsInteger) then begin<br> Table4.FieldByName('Rhgysid').AsString:=ls_supply_array[i,2];<br> Table4.FieldByName('rhgysname').AsString:=ls_supply_array[i,3];<br> break;<br> end;<br> end;<br> Table4.Post;<br> Table4.Next;<br> end;<br> Table4.Active:=false;<br> refreshquerys01;<br> refreshquerys02;<br> refreshinterface;<br>end;<br><br>function TForm1.mygyspassok:boolean;<br>var<br> pass_ok:boolean;<br>begin<br> pass_ok:=true;<br> Table4.Active:=false;<br> Table4.Active:=true;<br> Table4.First;<br> while not(Table4.Eof) do<br> begin<br> if ((Table4.fieldbyname('rhgysname').AsString='') or (Table4.fieldbyname('rhgysid').AsString='')) then begin<br> pass_ok:=false;<br> ShowMessage('尚有未对应的供应商'+#13+'请手工加以对应!');<br> break;<br> end;<br> Table4.Next;<br> end;<br> Table4.Active:=false;<br> Result:=pass_ok;<br>end;<br><br>function TForm1.mygoodspassok:boolean;<br>var<br> pass_ok:boolean;<br> ls_where:string;<br>begin<br> pass_ok:=true;<br> Table4.Active:=false;<br> Table4.Active:=true;<br> Table4.First;<br> ProgressBar1.Position:=0;<br> ProgressBar1.Visible:=true;<br> ProgressBar1.Max:=Table4.RecordCount*100;<br> ProgressBar1.Min:=0;<br> Label2.caption:='0/'+inttostr(Table4.RecordCount);<br> Self.Refresh;<br> Label2.Visible:=true;<br> while not(Table4.Eof) do<br> begin<br> ls_where:='where sudocid='''+Format('%10.10d',[Table4.Fieldbyname('incabillid').Asinteger])+'''';<br> query7.Active:=False;<br> Query7.SQL.Clear;<br> query7.SQL.Add('select * from kcm.bms_su_dtl_v');<br> query7.SQL.Add(ls_where);<br> query7.Active:=true;<br> ProgressBar1.Step:=100 div query7.RecordCount;<br> while not(query7.Eof) do<br> begin<br> query8.Active:=false;<br> Query8.ParamByName('incaid').AsInteger:=Query7.Fieldbyname('goodsid').AsInteger;<br> query8.Active:=true; <br> if (query8.IsEmpty) then begin<br> form6:=tform6.Create(self);<br> form6.incaoid:=Query7.Fieldbyname('goodsid').AsInteger;<br> form6.rhid:='';<br> form6.ShowModal;<br> if Form6.Sel_Id='' then begin<br> ShowMessage('用户中断了操作。。。');<br> pass_ok:=false;<br> break;<br> end;<br> form6.Free;<br> end;<br> query8.Active:=false;<br> ProgressBar1.StepIt;<br> query7.Next;<br> end;<br> query7.Active:=False;<br> if pass_ok=false then begin<br> Break;<br> end;<br> Label2.caption:=inttostr(Table4.Recno)+'/'+inttostr(Table4.RecordCount);<br> Self.Refresh;<br> Table4.Next;<br> end;<br> Table4.Active:=false;<br> ProgressBar1.Visible:=false;<br> Label2.Visible:=false;<br> Result:=pass_ok;<br>end;<br><br>procedure TForm1.Button5Click(Sender: TObject);<br>var<br> pass_ok:boolean;<br> jiejieii,jiejiels_i1,jiejiels_i2,jiejiels_i3:integer;<br> jiejiels_string:string;<br> jiejiels_string02:string;<br>begin<br> pass_ok:=true;<br> if pass_ok then begin<br> pass_ok:=mygyspassok;<br> end;<br> if pass_ok then begin<br> pass_ok:=mygoodspassok;<br> if pass_ok=false then begin<br> ShowMessage('尚有未对应的商品资料'+#13+'操作终止!');<br> end;<br> end;<br> if pass_ok then<br> begin<br> myCopytorh(DataModule4.Database1.Params,DataModule4.Database2.Params,<br> DataModule4.Database3.Params,ProgressBar1,Label2,current_usename);<br> end<br> else<br> begin<br> end;<br>end;<br><br>procedure TForm1.Button7Click(Sender: TObject);<br>var<br> form7:Tform7;<br> jiejieii,jiejiels_i1,jiejiels_i2,jiejiels_i3:integer;<br> jiejiels_string:string;<br> jiejiels_string02:string;<br>begin<br> form7:=tform7.Create(self);<br> form7.ShowModal;<br> form7.free;<br>end;<br><br>end.