unit U_SKTP_DJ;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, DB, ADODB;

type
  TFrmSKTP_DJ = class(TForm)
    Panel0: TPanel;
    Label1: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Label10: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    WBID: TEdit;
    SKName: TEdit;
    SKWZ: TEdit;
    SKCode: TEdit;
    SKNote: TMemo;
    Button2: TButton;
    SKCodeOld: TEdit;
    SKID: TEdit;
    ADOQuery1: TADOQuery;
    ADOQuery2: TADOQuery;
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    FCPID:String;
    { Public declarations }
  end;

var
  FrmSKTP_DJ: TFrmSKTP_DJ;

implementation
uses
  U_DataLink,U_Fun;

{$R *.dfm}

procedure TFrmSKTP_DJ.Button2Click(Sender: TObject);
var maxno:string;
begin
  if SKCode.Text='' then
  begin
    application.MessageBox('色卡编号不能为空','提示');
    exit;
  end;
  with ADOQuery1 do
  begin
    close;
    sql.Clear;
    sql.Add('select * from SK_Base where SKID='''+Trim(SKID.Text)+'''');
    open;
  end;
  with ADOQuery1 do
  begin
    if IsEmpty then
    begin
      if GetLSNo(ADOQuery2,MaxNo,'SK','SK_Base',4,1)=False then
      begin
        Application.MessageBox('取图片最大号失败！','提示',0);
        Exit;
      end;
      Append;
      FieldByName('SKID').Value:=Trim(MaxNo);
      SKID.Text:=Trim(MaxNo);
      FieldByName('filler').Value:=Trim(DName);
      fieldbyname('CPID').Value:=trim(FCPID);
      FieldByName('Valid').Value:='Y';
    end
    else
    begin
      edit;
      FieldByName('editer').Value:=Trim(DName);
      FieldByName('Edittime').Value:=now;
    end;
    RTSetsavedata(ADOQuery1,'SK_Base',Self.Panel0,2);
    post;
  end;
  Application.MessageBox('保存成功','提示');
  ModalResult:=1;
end;

end.
