起步软件技术论坛-X3

 找回密码
 立即注册
搜索
12
返回列表 发新帖
楼主: xhong

【结帖】功能退出出错怎么解决?**

[复制链接]
 楼主| 发表于 2008-7-4 09:19:51 | 显示全部楼层
unit JHSJWG;

interface

uses
  Business.System, Business.Model, Business.Forms, Business.Data;

type
  TJHSJWG = class(TFormDoc)
    InfoBroker: TInfoBroker;
    DataGrid: TDataGrid;
    dpt: TMonthCalendar;
    procedure DataGridMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
    procedure dptExit(Sender: TObject);
    procedure dptChange(Sender: TObject);
    procedure DataGridChangeLeftCoord(Sender: TObject);
    procedure DataGridChangeTopVisibleNode(Sender: TObject);
  private
    {private declarations}
    procedure SetDptDate();
    procedure SetCalendarPos();
  public
    {public declarations}
    DateRect:TRect;
    blnVisible:boolean;
  end;

implementation

{**************************************
   procedure:    DataGridMouseDown
   Describe:     鼠标按下事件  判断焦点所在字段 设置相关字段的区域位置
   Author:       Panyc
   Date:         2008-06-27
**************************************/}
procedure TJHSJWG.DataGridMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
   posx,posy,i:integer;
   FocusedField:string;
begin
    posx:=10;
    posy:=0;
    FocusedField:=DataGrid.FocusedField.FieldName ;
    if (FocusedField<>'MoldID') and (FocusedField<>'BZT') then
    begin
        if (FocusedField.Length>3) and (FocusedField.Substring(FocusedField.Length-3,3)='ZZD') then
        begin
            dpt.Visible:=false;
        end
        else
        begin
           dpt.Visible:=true;
           blnVisible:= dpt.Visible;
           SetCalendarPos();
           SetDptDate();
        end;
    end
    else
    dpt.Visible:=false;
end;

{**************************************
   procedure:    SetDptDate
   Describe:     设置日期控件显示的时间 当前字段有时间 显示时间 没有时间 显示当天
   Author:       Panyc
   Date:         2008-06-27
**************************************/}
procedure TJHSJWG.SetDptDate();
var
   FieldName:string;
   FieldValue:string;
begin
   try
       FieldName:=DataGrid.FocusedField.FieldName;
       FieldValue:=DataGrid.DataSource.DataSet.FieldByName(FieldName).AsString;
       if (FieldValue='-') or (FieldValue='') then
          dpt.Date:=Business.System.SysUtils.Date
       else
          dpt.Date:=SysUtils.StrToDate(FieldValue);
   Except
       dialogs.ShowMessage('日期数据不合法!');
   end;
end;


{**************************************
   procedure:    SetCalendarPos
   Describe:     设置日期控件位置
   Author:       DeyuLiu
   Date:         2008-06-27
**************************************/}
procedure TJHSJWG.SetCalendarPos();
var
    posx,posy,i:integer;
begin
     posx:=13;
     posy:=0;
     if DataGrid.Focused and blnVisible then
     begin
          for i:=0 to DataGrid.FocusedField.FieldNo-2 do
          begin
              if DataGrid.Columns.Visible=true then
                 posx:=posx+DataGrid.Columns.width;
          end;
          posx:=posx-DataGrid.LeftCoord;
          if (DataGrid.FocusedNode<>nil) and (DataGrid.TopVisibleNode<>nil) then
                posy:= (DataGrid.FocusedNode.Index+1-DataGrid.TopVisibleNode.Index)*DataGrid.RowHeight+DataGrid.HeaderHeight;

          if posy>(DataGrid.Height div 2) then
             posy:=posy-DataGrid.RowHeight-dpt.Height;
          if posx>(DataGrid.Width div 2) then
             posx:=posx+DataGrid.Columns[DataGrid.FocusedField.FieldNo].Width-dpt.Width;

          dpt.Visible:=true;

          if (posx<0) or (posx+dpt.Width>DataGrid.Width) then
             dpt.Visible:=false;

          dpt.SetBounds(posx,posy,0,0);
     end;
end;

procedure TJHSJWG.dptExit(Sender: TObject);
begin
    dpt.Visible:=false;
end;

{**************************************
   procedure:    dptChange
   Describe:     将客户选择的日期填充到数据集中
   Author:       Panyc
   Date:         2008-06-27
**************************************/}
procedure TJHSJWG.dptChange(Sender: TObject);
var
    FieldName:string;
    FieldValueouble;
begin
    dpt.Visible:=false;
    FieldName:=DataGrid.FocusedField.FieldName;
    FieldValue:=dpt.Date;
    DataGrid.DataSource.DataSet.Open;
    DataGrid.DataSource.DataSet.Edit;
    DataGrid.DataSource.DataSet.FieldByName(FieldName).AsDateTime:=FieldValue;
end;

procedure TJHSJWG.DataGridChangeLeftCoord(Sender: TObject);
begin
     SetCalendarPos();
end;

procedure TJHSJWG.DataGridChangeTopVisibleNode(Sender: TObject);
begin
    SetCalendarPos();
end;

end.

这是这个功能信息层的代码 在功能窗体销毁的时候 跟踪代码 会进入信息层 是不是因为这个原因才会出错 信息层主要是在点DataGrid的时候在单元格旁弹出一个日期控件
回复 支持 反对

使用道具 举报

发表于 2008-7-4 09:32:23 | 显示全部楼层
楼主,你把那个功能的代码都屏蔽掉,然后看是否报错?
如果不报错,那你就一个个的函数注释掉,看到底是哪个函数的问题。
如果报错,那就要看你是怎么调用功能的
(看你这么多代码,好长好晕。。。。。)
回复 支持 反对

使用道具 举报

 楼主| 发表于 2008-7-4 09:38:56 | 显示全部楼层
我刚才已经试过了 函数全部屏蔽 还是报错
procedure TMainForm.DataGridClick(Sender:TObject);
var
    FieldName:string;
    ProjectID:string;
    lParams:TStrings;
begin
    lParams:=TStringList.Create;
    FieldName:=DataGrid.FocusedField.FieldName;
    ProjectID:= DataSetBroker1.DataSet.FieldByName('ProjectID').AsString;
    if FieldName='UpLoad' then
    begin
       lParams.Clear;
       lParams.Add('Type=Upload');
    end;
    if FieldName='DownLoad' then
    begin
       lParams.Clear;
       lParams.Add('Type=DownLoad');
    end;
    lParams.Add('ProjectID='+ProjectID);
    SystemCore.TSystemCore.FuncManager.RunFunc(Self.Context.Parent,ProjectID,'Biz:\OPERATION\AMCPMS\WGJHSC.Func',lParams.Text,nil,false);
    lParams.Free;
end;

这是调用的过程 调用那个功能的  那个功能一关闭就出错
回复 支持 反对

使用道具 举报

发表于 2008-7-4 11:34:13 | 显示全部楼层
你用这个方式调用空白的功能看下呢
回复 支持 反对

使用道具 举报

发表于 2008-7-4 16:07:11 | 显示全部楼层
??
回复 支持 反对

使用道具 举报

发表于 2008-7-9 09:32:01 | 显示全部楼层
楼主,还有问题吗?
没问题就结帖了!!
回复 支持 反对

使用道具 举报

发表于 2008-7-10 17:40:01 | 显示全部楼层
这个问题已经通过现场找到问题所在了,是处理的代码有问题。
揭帖。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Justep Inc.

GMT+8, 2025-7-18 23:45 , Processed in 0.039577 second(s), 14 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表