unit U_BPZdy_RSSel;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData,
  cxDataStorage, cxEdit, DB, cxDBData, ToolWin, ComCtrls,
  cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxGridLevel,
  cxClasses, cxControls, cxGridCustomView, cxGrid, DBClient, ADODB, ImgList,
  StdCtrls, ExtCtrls, cxTextEdit, cxGridCustomPopupMenu, cxGridPopupMenu,
  cxButtonEdit, BtnEdit, cxTL, cxMaskEdit, cxInplaceContainer, cxDBTL,
  cxTLData, cxContainer, cxCurrencyEdit, cxCheckBox, cxSplitter,jpeg,U_SLT_PBSK,U_SLT_BF1,Math, Menus, cxCalendar,
  cxPC, Buttons;

type
  TfrmBPZDY_RSSel = class(TForm)
    ADOQueryMain: TADOQuery;
    ADOQueryTemp: TADOQuery;
    ADOQueryCmd: TADOQuery;
    ADOQuery6: TADOQuery;
    cxGridPopupMenu2: TcxGridPopupMenu;
    adoqueryPicture: TADOQuery;
    PopupMenu1: TPopupMenu;
    N1: TMenuItem;
    Ord_SH: TClientDataSet;
    Panel201: TPanel;
    ScrollBox4: TScrollBox;
    Button2: TButton;
    SY: TButton;
    XY: TButton;
    Label554: TLabel;
    Label555: TLabel;
    ScrollBox1: TScrollBox;
    Panel102: TPanel;
    Label450: TLabel;
    Label451: TLabel;
    Panel103: TPanel;
    Label405: TLabel;
    Edit2: TEdit;
    Edit3: TEdit;
    Panel101: TPanel;
    Label401: TLabel;
    Label402: TLabel;
    Panel104: TPanel;
    Label403: TLabel;
    Edit4: TEdit;
    Edit5: TEdit;
    Panel105: TPanel;
    Label404: TLabel;
    Label406: TLabel;
    Panel106: TPanel;
    Label407: TLabel;
    Edit6: TEdit;
    Edit7: TEdit;
    Panel107: TPanel;
    Label408: TLabel;
    Label409: TLabel;
    Panel108: TPanel;
    Label410: TLabel;
    Edit8: TEdit;
    Edit9: TEdit;
    Panel109: TPanel;
    Label411: TLabel;
    Label412: TLabel;
    Panel110: TPanel;
    Label413: TLabel;
    Edit10: TEdit;
    Edit11: TEdit;
    Panel111: TPanel;
    Label414: TLabel;
    Label415: TLabel;
    Panel112: TPanel;
    Label416: TLabel;
    Edit12: TEdit;
    Edit13: TEdit;
    Panel113: TPanel;
    Label417: TLabel;
    Label418: TLabel;
    Panel114: TPanel;
    Label419: TLabel;
    Edit14: TEdit;
    Edit15: TEdit;
    Panel115: TPanel;
    Label420: TLabel;
    Label421: TLabel;
    Panel116: TPanel;
    Label422: TLabel;
    Edit16: TEdit;
    Edit17: TEdit;
    Panel117: TPanel;
    Label423: TLabel;
    Label424: TLabel;
    Panel118: TPanel;
    Label425: TLabel;
    Edit18: TEdit;
    Edit19: TEdit;
    Panel119: TPanel;
    Label426: TLabel;
    Label427: TLabel;
    Panel120: TPanel;
    Label428: TLabel;
    Edit20: TEdit;
    Edit21: TEdit;
    Panel121: TPanel;
    Label429: TLabel;
    Label430: TLabel;
    Panel122: TPanel;
    Label431: TLabel;
    Edit22: TEdit;
    Edit23: TEdit;
    Panel123: TPanel;
    Label432: TLabel;
    Label433: TLabel;
    Panel124: TPanel;
    Label434: TLabel;
    Edit24: TEdit;
    Edit25: TEdit;
    Panel125: TPanel;
    Label435: TLabel;
    Label436: TLabel;
    Panel126: TPanel;
    Label437: TLabel;
    Edit26: TEdit;
    Edit27: TEdit;
    Panel127: TPanel;
    Label438: TLabel;
    Label439: TLabel;
    Panel128: TPanel;
    Label440: TLabel;
    Edit28: TEdit;
    Edit29: TEdit;
    Panel129: TPanel;
    Label441: TLabel;
    Label442: TLabel;
    Panel130: TPanel;
    Label443: TLabel;
    Edit30: TEdit;
    Edit31: TEdit;
    Panel131: TPanel;
    Label444: TLabel;
    Label445: TLabel;
    Panel132: TPanel;
    Label446: TLabel;
    Edit32: TEdit;
    Edit33: TEdit;
    Panel133: TPanel;
    Label447: TLabel;
    Label448: TLabel;
    Panel134: TPanel;
    Label449: TLabel;
    Edit34: TEdit;
    Edit35: TEdit;
    Panel135: TPanel;
    Label452: TLabel;
    Label453: TLabel;
    Panel136: TPanel;
    Label454: TLabel;
    Edit36: TEdit;
    Edit37: TEdit;
    Panel137: TPanel;
    Label455: TLabel;
    Label456: TLabel;
    Panel138: TPanel;
    Label457: TLabel;
    Edit38: TEdit;
    Edit39: TEdit;
    Panel139: TPanel;
    Label458: TLabel;
    Label459: TLabel;
    Panel140: TPanel;
    Label460: TLabel;
    Edit40: TEdit;
    Edit41: TEdit;
    Panel141: TPanel;
    Label461: TLabel;
    Label462: TLabel;
    Panel142: TPanel;
    Label463: TLabel;
    Edit42: TEdit;
    Edit43: TEdit;
    Panel143: TPanel;
    Label464: TLabel;
    Label465: TLabel;
    Panel144: TPanel;
    Label466: TLabel;
    Edit44: TEdit;
    Edit45: TEdit;
    Panel145: TPanel;
    Label467: TLabel;
    Label468: TLabel;
    Panel146: TPanel;
    Label469: TLabel;
    Edit46: TEdit;
    Edit47: TEdit;
    Panel147: TPanel;
    Label470: TLabel;
    Label471: TLabel;
    Panel148: TPanel;
    Label472: TLabel;
    Edit48: TEdit;
    Edit49: TEdit;
    Panel149: TPanel;
    Label473: TLabel;
    Label474: TLabel;
    Panel150: TPanel;
    Label475: TLabel;
    Edit50: TEdit;
    Edit51: TEdit;
    Panel151: TPanel;
    Label476: TLabel;
    Label477: TLabel;
    Panel152: TPanel;
    Label478: TLabel;
    Edit52: TEdit;
    Edit53: TEdit;
    Panel153: TPanel;
    Label479: TLabel;
    Label480: TLabel;
    Panel154: TPanel;
    Label481: TLabel;
    Edit54: TEdit;
    Edit55: TEdit;
    Panel155: TPanel;
    Label482: TLabel;
    Label483: TLabel;
    Panel156: TPanel;
    Label484: TLabel;
    Edit56: TEdit;
    Edit57: TEdit;
    Panel157: TPanel;
    Label485: TLabel;
    Label486: TLabel;
    Panel158: TPanel;
    Label487: TLabel;
    Edit58: TEdit;
    Edit59: TEdit;
    Panel159: TPanel;
    Label488: TLabel;
    Label489: TLabel;
    Panel160: TPanel;
    Label490: TLabel;
    Edit60: TEdit;
    Edit61: TEdit;
    Panel161: TPanel;
    Label491: TLabel;
    Label492: TLabel;
    Panel162: TPanel;
    Label493: TLabel;
    Edit62: TEdit;
    Edit63: TEdit;
    Panel163: TPanel;
    Label494: TLabel;
    Label495: TLabel;
    Panel164: TPanel;
    Label496: TLabel;
    Edit64: TEdit;
    Edit65: TEdit;
    Panel165: TPanel;
    Label497: TLabel;
    Label498: TLabel;
    Panel166: TPanel;
    Label499: TLabel;
    Edit66: TEdit;
    Edit67: TEdit;
    Panel167: TPanel;
    Label500: TLabel;
    Label501: TLabel;
    Panel168: TPanel;
    Label502: TLabel;
    Edit68: TEdit;
    Edit69: TEdit;
    Panel169: TPanel;
    Label503: TLabel;
    Label504: TLabel;
    Panel170: TPanel;
    Label505: TLabel;
    Edit70: TEdit;
    Edit71: TEdit;
    Panel171: TPanel;
    Label506: TLabel;
    Label507: TLabel;
    Panel172: TPanel;
    Label508: TLabel;
    Edit72: TEdit;
    Edit73: TEdit;
    Panel173: TPanel;
    Label509: TLabel;
    Label510: TLabel;
    Panel174: TPanel;
    Label511: TLabel;
    Edit74: TEdit;
    Edit75: TEdit;
    Panel175: TPanel;
    Label512: TLabel;
    Label513: TLabel;
    Panel176: TPanel;
    Label514: TLabel;
    Edit76: TEdit;
    Edit77: TEdit;
    Panel177: TPanel;
    Label515: TLabel;
    Label516: TLabel;
    Panel178: TPanel;
    Label517: TLabel;
    Edit78: TEdit;
    Edit79: TEdit;
    Panel179: TPanel;
    Label518: TLabel;
    Label519: TLabel;
    Panel180: TPanel;
    Label520: TLabel;
    Edit80: TEdit;
    Edit81: TEdit;
    Panel181: TPanel;
    Label523: TLabel;
    Label524: TLabel;
    Panel182: TPanel;
    Label525: TLabel;
    Edit82: TEdit;
    Edit83: TEdit;
    Panel183: TPanel;
    Label526: TLabel;
    Label527: TLabel;
    Panel184: TPanel;
    Label528: TLabel;
    Edit84: TEdit;
    Edit85: TEdit;
    Panel185: TPanel;
    Label529: TLabel;
    Label530: TLabel;
    Panel186: TPanel;
    Label531: TLabel;
    Edit86: TEdit;
    Edit87: TEdit;
    Panel187: TPanel;
    Label532: TLabel;
    Label533: TLabel;
    Panel188: TPanel;
    Label534: TLabel;
    Edit88: TEdit;
    Edit89: TEdit;
    Panel189: TPanel;
    Label535: TLabel;
    Label536: TLabel;
    Panel190: TPanel;
    Label537: TLabel;
    Edit90: TEdit;
    Edit91: TEdit;
    Panel191: TPanel;
    Label538: TLabel;
    Label539: TLabel;
    Panel192: TPanel;
    Label540: TLabel;
    Edit92: TEdit;
    Edit93: TEdit;
    Panel193: TPanel;
    Label541: TLabel;
    Label542: TLabel;
    Panel194: TPanel;
    Label543: TLabel;
    Edit94: TEdit;
    Edit95: TEdit;
    Panel195: TPanel;
    Label544: TLabel;
    Label545: TLabel;
    Panel196: TPanel;
    Label546: TLabel;
    Edit96: TEdit;
    Edit97: TEdit;
    Panel197: TPanel;
    Label547: TLabel;
    Label548: TLabel;
    Panel198: TPanel;
    Label549: TLabel;
    Edit98: TEdit;
    Edit99: TEdit;
    Panel199: TPanel;
    Label550: TLabel;
    Label551: TLabel;
    Panel200: TPanel;
    Label552: TLabel;
    Edit100: TEdit;
    Edit101: TEdit;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure TBCloseClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure Panel1MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure N1Click(Sender: TObject);
    procedure Panel1DblClick(Sender: TObject);
    procedure Panel101DblClick(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Panel102MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure Edit2Exit(Sender: TObject);
    procedure Edit3Exit(Sender: TObject);
    procedure XYClick(Sender: TObject);
    procedure SYClick(Sender: TObject);
    procedure ColNameKeyPress(Sender: TObject; var Key: Char);
  private
    FSKID,FCPID,FCPNo,FCPName:string;
    FPTID,FColNameEng,FColName,FColNameKH:string;
    FColor:TColor;
    y,Z,my,mz:integer;
    procedure SaveData();
    procedure InitSHByOrdBP_SH();
    { Private declarations }
  public
    flag,flagname,snote,MainType,FGYName,Fint,FColorFlag,formid:string;
    fnote,fnote1,forderno,fZdyFlag,ViewFlag,fHelpType:Boolean;
    PPSTE:integer;
    procedure initimageSH();
    procedure initimageSHSql();
    procedure initPanel();
    procedure initPL();
    { Public declarations }
  end;
var
  frmBPZDY_RSSel: TfrmBPZDY_RSSel;
implementation
uses
  U_DataLink,U_Fun10,U_BPZdy_YT;

{$R *.dfm}
procedure TfrmBPZDY_RSSel.InitSHByOrdBP_SH();
var
  i,j,z,q:Integer;
begin
  with Ord_SH do
  begin
    First;
    i:=0;
    q:=1;
    while not Eof do
    begin
      if (q>50*(my-1)) and (q<=50*my) then
      begin
        with ScrollBox1 do
        begin
          TPanel(Controls[i]).Visible:=True;
          TPanel(Controls[i]).Hint:=Trim(Ord_SH.Fieldbyname('PTID').AsString);
          TPanel(Controls[i]).Color:=StrToInt('$'+Trim(Ord_SH.Fieldbyname('ColDaiMa').AsString));
          with TPanel(Controls[i]) do
          begin
            TLabel(Controls[0]).Caption:=Trim(Ord_SH.Fieldbyname('PTID').AsString);
            TLabel(Controls[1]).Caption:=Trim(Ord_SH.Fieldbyname('ColNameEng').AsString);
            for j:=0 to ControlCount-1 do
            begin
              if Controls[j] is TPanel then
              begin
                with TPanel(Controls[j]) do
                begin
                  for z:=0 to ControlCount-1 do
                  begin
                    if Controls[z] is TEdit then
                    begin
                      if TEdit(Controls[z]).Tag=1 then
                      begin
                        TEdit(Controls[z]).Text:=Trim(Ord_SH.Fieldbyname('ColNo').AsString);
                        TEdit(Controls[z]).Hint:=Trim(Ord_SH.Fieldbyname('PTID').AsString);
                      end else
                      begin
                        TEdit(Controls[z]).Text:=Trim(Ord_SH.Fieldbyname('ColNameKH').AsString);
                        TEdit(Controls[z]).Hint:=Trim(Ord_SH.Fieldbyname('PTID').AsString);
                      end;
                    end;
                  end;
                end;
              end;
            end;
          end;
        end;
        i:=i+1;
      end;
      q:=q+1;
      Next;
    end;
  end;
end;

procedure TfrmBPZDY_RSSel.initPL();
var i,j,x:Integer;
begin
  with Self.ScrollBox1 do
  begin
    for i:=0 to Self.ScrollBox1.ControlCount-1 do
    begin
      if Controls[i] is TPanel then
      begin
        if TPanel(Controls[i]).Ctl3D=False then
        begin
          TPanel(Controls[i]).Visible:=false;
          Self.ScrollBox1.Refresh;
        end;
      end;
    end;
  end;
  Self.ScrollBox1.Refresh;
  Self.InitSHByOrdBP_SH();
end;

procedure TfrmBPZDY_RSSel.initPanel();
var i:integer;
begin
  with ScrollBox1 do
  begin
    for i:=0 to ScrollBox1.ControlCount-1 do
    begin
      if TPanel(Controls[i]).Visible=False then
      begin
        TPanel(Controls[i]).Visible:=True;
        TPanel(Controls[i]).Color:=FColor;
        TPanel(Controls[i]).Hint:=FPTID;
        with TPanel(Controls[i]) do
        begin
          TLabel(Controls[0]).Caption:=Trim(FPTID);
          TLabel(Controls[1]).Caption:=Trim(FColNameEng);
          TLabel(Controls[2]).Caption:=Trim(FColName);
          TLabel(Controls[3]).Caption:=Trim(FColNameKH);
          TLabel(Controls[0]).Visible:=False;
          TLabel(Controls[1]).Visible:=False;
          TLabel(Controls[2]).Visible:=False;
          TLabel(Controls[3]).Visible:=False;
        end;
        Exit;
      end;
    end;
  end;
end;

procedure TfrmBPZDY_RSSel.initimageSH();
begin
 
end;

procedure TfrmBPZDY_RSSel.initimageSHSql();
begin
  
end;

procedure TfrmBPZDY_RSSel.SaveData();
var
  maxno,FColID:string;
  j,i:Integer;
begin
  try
    ADOQueryCmd.Connection.BeginTrans;
    Ord_SH.DisableControls;
    with Ord_SH do
    begin
      //First;
      //while not Eof do
      begin
        FColID:=Trim(fieldbyname('ColID').AsString);
        if Trim(FColID)='' then
        begin
          if GetLSNo(ADOQueryCmd,maxno,'TJ','BP_ColZDY_M',3,1)=False then
          begin
            Application.MessageBox('取最大号失败!','提示',0);
            Exit;
          end;
        end else
        begin
          maxno:=Trim(FColID);
        end;
        with ADOQueryCmd do
        begin
          Close;
          sql.Clear;
          sql.Add('select * from BP_ColZDY_M where ColID='''+Trim(maxno)+'''');
          Open;
        end;
        with ADOQueryCmd do
        begin
          if Trim(FColID)='' then
          begin
            Append;
          end else
          begin
            Edit;
          end;
          FieldByName('ColID').Value:=Trim(maxno);
          FieldByName('PTID').Value:=Trim(Ord_SH.fieldbyname('PTID').AsString);
          if Ord_SH.fieldbyname('ColNo').AsString='' then
          begin
            FieldByName('ColNo').Value:=Ord_SH.RecordCount+1;
          end
          else
          FieldByName('ColNo').Value:=Trim(Ord_SH.fieldbyname('ColNo').AsString);
          FieldByName('ColNameKH').Value:=Trim(Ord_SH.fieldbyname('ColNameKH').AsString);
          if FColorFlag<>'' then
          FieldByName('SKID').Value:=Trim(FColorFlag)
          else
          FieldByName('SKID').Value:=Trim(maxno);
          Post;
        end;
        Edit;
        FieldByName('ColID').Value:=Trim(maxno);
        with ADOQueryCmd do
        begin
          close;
          sql.Clear;
          SQL.Add('update RT_PTColor_M set ColNameKH='''+trim(Ord_SH.fieldbyname('ColNameKH').AsString)+''' ');
          sql.Add(' where PTID='''+trim(Ord_SH.fieldbyname('PTID').AsString)+'''');
          ExecSQL;
        end;
        //Next;
      end;
    end;
    Ord_SH.EnableControls;
    ADOQueryCmd.Connection.CommitTrans;
    //Application.MessageBox('操作成功。','提示');
  except
    Ord_SH.EnableControls;
    ADOQueryCmd.Connection.RollbackTrans;
    Application.MessageBox('保存异常!','提示');
  end;
end;

procedure TfrmBPZDY_RSSel.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  Action:=caFree;
end;

procedure TfrmBPZDY_RSSel.TBCloseClick(Sender: TObject);
begin
  Close;
end;

procedure TfrmBPZDY_RSSel.FormShow(Sender: TObject);
var x:integer;
begin
  my:=1;
  with ScrollBox1 do
  begin
    for x:=0 to ScrollBox1.ControlCount-1 do
    begin
      TPanel(Controls[x]).Visible:=false;
    end;
  end;
  with ADOQueryTemp do
  begin
    Close;
    sql.Clear;
    sql.Add('select A.*,B.* ');
    SQL.Add(',MXGS=(select count(C.PTID) from BP_ColZDY C where C.SKID=B.SKID and isnull(C.SKID,'''')<>'''') ');
    sql.Add('from RT_PTColor A ');
    sql.Add('inner join BP_ColZDY B on B.PTID=A.PTID ');
    sql.Add('where B.SKID='''+trim(FColorFlag)+''' and isnull(B.SKID,'''')<>''''');
    sql.Add(' order by cast(B.ColNo as int)');
    //showmessage(sql.text);
    Open;
  end;
  mz:=ceil(ADOQueryTemp.fieldbyname('MXGS').AsInteger/50);
  label554.Caption:=inttostr(my)+'/'+inttostr(mz);
  SCreateCDS20(ADOQueryTemp,Ord_SH);
  SInitCDSData20(ADOQueryTemp,Ord_SH);
  InitSHByOrdBP_SH();
end;

procedure TfrmBPZDY_RSSel.Panel1MouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
  i:Integer;
begin
  FColor:=TPanel(Sender).Color;
  with TPanel(Sender) do
  begin
    for i:=0 to 3 do
    begin
      if TLabel(Controls[i]).Visible=false then
        TLabel(Controls[i]).Visible:=True
      else
        TLabel(Controls[i]).Visible:=false;
      TLabel(Controls[i]).Color:=clWhite;
    end;
    FPTID:=Trim(TLabel(Controls[0]).Caption);
    FColNameEng:=Trim(TLabel(Controls[1]).Caption);
    FColName:=Trim(TLabel(Controls[2]).Caption);
    FColNameKH:=Trim(TLabel(Controls[3]).Caption);
  end;
end;

procedure TfrmBPZDY_RSSel.N1Click(Sender: TObject);
begin
  FrmBPZdy_YT:=TFrmBPZdy_YT.create(Self);
  with FrmBPZdy_YT do
  begin
    BJFlag:='Y';
    Panel1.Color:=FColor;
    Label1.Caption:=FPTID;
    Label2.Caption:=FColNameEng;
    Label3.Caption:=FColName;
    Label4.Caption:=FColNameKH;
    if showmodal=1 then
    begin

    end;
    free;
  end;
end;

procedure TfrmBPZDY_RSSel.Panel1DblClick(Sender: TObject);
var i:Integer;
begin
  with TPanel(Sender) do
  begin
    FPTID:=Trim(TLabel(Controls[0]).Caption);
    FColNameEng:=Trim(TLabel(Controls[1]).Caption);
    FColName:=Trim(TLabel(Controls[2]).Caption);
    FColNameKH:=Trim(TLabel(Controls[3]).Caption);
  end;
  if Ord_SH.Locate('PTID',FPTID,[])=False then
  begin
    with ADOQueryTemp do
    begin
      Close;
      sql.Clear;
      sql.Add('select * from RT_PTColor_M where PTID='''+Trim(FPTID)+'''');
      Open;
    end;
    with Ord_SH do
    begin
      if formid='1' then
      edit
      else
      Append;
      FieldByName('ColDaiMa').Value:=Trim(ADOQueryTemp.fieldbyname('ColDaiMa').AsString);
      FieldByName('PTID').Value:=FPTID;
      FieldByName('ColNo').Value:=Ord_SH.RecordCount+1;
      FieldByName('ColNameEng').Value:=FColNameEng;
      FieldByName('ColName').Value:=FColName;
      FieldByName('ColNameKH').Value:=FColNameKH;
      post;
    end;
    i:=Ord_SH.RecordCount;
    mz:=ceil(i/50);
    Label554.Caption:=inttostr(my)+'/'+inttostr(mz);
  end;
  InitSHByOrdBP_SH();
  if formid='1' then
  begin
    Button2.Click;
  end;
end;

procedure TfrmBPZDY_RSSel.Panel101DblClick(Sender: TObject);
var i:Integer;
begin
  Button2.Click;
end;

procedure TfrmBPZDY_RSSel.Button2Click(Sender: TObject);
begin
  if Ord_SH.IsEmpty then exit;
  ScrollBox4.SetFocus;
  //savedata();
  ModalResult:=1;
end;

procedure TfrmBPZDY_RSSel.Panel102MouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
  i:Integer;
  FPT:string;
begin
  FColor:=TPanel(Sender).Color;
  with TPanel(Sender) do
  begin
    for i:=0 to 1 do
    begin
      if TLabel(Controls[i]).Visible=false then
        TLabel(Controls[i]).Visible:=True
      else
        TLabel(Controls[i]).Visible:=false;
      TLabel(Controls[i]).Color:=clWhite;
    end;
    FPT:=Trim(TLabel(Controls[0]).Caption);
    Ord_SH.Locate('PTID',FPT,[]);
    FPTID:=Trim(Ord_SH.fieldbyname('PTID').AsString);
    FColNameEng:=Trim(Ord_SH.fieldbyname('ColNameEng').AsString);
    FColName:=Trim(Ord_SH.fieldbyname('ColName').AsString);
    FColNameKH:=Trim(Ord_SH.fieldbyname('ColNameKH').AsString);
  end;
end;

procedure TfrmBPZDY_RSSel.Edit2Exit(Sender: TObject);
var
  FPT,FTEX:string;
begin
  FPT:=Trim(TEdit(Sender).Hint);
  FTEX:=Trim(TEdit(Sender).Text);
  if FTEX<>'0' then
  begin
    if StrToIntDef(FTEX,0)=0 then
    begin
      application.MessageBox('色号必须是数字','提示');
      FTEX:='';
      TEdit(Sender).Text:='';
      exit;
    end;
  end;
  //ShowMessage(FPT);
  with Ord_SH do
  begin
    if Locate('PTID',FPT,[]) then
    begin
      Edit;
      FieldByName('ColNo').value:=Trim(FTEX);
      Post;
    end;
  end;
end;

procedure TfrmBPZDY_RSSel.Edit3Exit(Sender: TObject);
var FPT,FTEX:string;
begin
  FPT:=Trim(TEdit(Sender).Hint);
  FTEX:=Trim(TEdit(Sender).Text);
  with Ord_SH do
  begin
    if Locate('PTID',FPT,[]) then
    begin
      Edit;
      FieldByName('ColNameKH').value:=Trim(FTEX);
      Post;
    end;
  end;
end;

procedure TfrmBPZDY_RSSel.XYClick(Sender: TObject);
var x:integer;
begin
  if my=mz then exit;
  XY.Enabled:=False;
  my:=my+1;
  if my>0 then
  begin
    SY.Enabled:=True;
  end
  else
  begin
    SY.Enabled:=False;
  end;
  with ScrollBox1 do
  begin
    for x:=0 to ScrollBox1.ControlCount-1 do
    begin
      TPanel(Controls[x]).Visible:=false;
    end;
  end;
  label554.Caption:=inttostr(my)+'/'+inttostr(mz);
  InitSHByOrdBP_SH();
  XY.Enabled:=true;
end;

procedure TfrmBPZDY_RSSel.SYClick(Sender: TObject);
var x:integer;
begin
  if my=1 then exit;
  SY.Enabled:=False;
  my:=my-1;
  if my<mz then
  begin
    XY.Enabled:=True;
  end
  else
  begin
    XY.Enabled:=False;
  end;
  with ScrollBox1 do
  begin
    for x:=0 to ScrollBox1.ControlCount-1 do
    begin
      TPanel(Controls[x]).Visible:=false;
    end;
  end;
  label554.Caption:=inttostr(my)+'/'+inttostr(mz);
  InitSHByOrdBP_SH();
  SY.Enabled:=true;
end;

procedure TfrmBPZDY_RSSel.ColNameKeyPress(Sender: TObject; var Key: Char);
begin
  if Key=#13 then
  begin
    initimageSHSql();
  end;
end;

end.
