unit U_LLRKInPut;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData,
  cxDataStorage, cxEdit, DB, cxDBData, cxGridLevel, cxGridCustomTableView,
  cxGridTableView, cxGridDBTableView, cxClasses, cxControls,
  cxGridCustomView, cxGrid, cxMemo, cxRichEdit, ComCtrls, cxContainer,
  cxTextEdit, cxMaskEdit, cxButtonEdit, StdCtrls, ToolWin, DBClient, ADODB,
  ExtCtrls, BtnEdit, cxCalendar,StrUtils, cxDropDownEdit,jpeg,
  IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, IdFTP, cxPC,
  cxGridCustomPopupMenu, cxGridPopupMenu, cxGroupBox, cxCheckBox,
  RM_Dataset, RM_System, RM_Common, RM_Class, RM_GridReport,IniFiles;

type
  TfrmLLRKInPut = class(TForm)
    ToolBar1: TToolBar;
    TBClose: TToolButton;
    ADOTemp: TADOQuery;
    ADOCmd: TADOQuery;
    ADOQuery1: TADOQuery;
    TBSave: TToolButton;
    DataSource1: TDataSource;
    ClientDataSet1: TClientDataSet;
    cxGridPopupMenu1: TcxGridPopupMenu;
    Label21: TLabel;
    Label26: TLabel;
    Label19: TLabel;
    CDS_Print: TClientDataSet;
    RM1: TRMGridReport;
    Panel3: TPanel;
    Panel6: TPanel;
    labMYType: TLabel;
    Panel4: TPanel;
    Label13: TLabel;
    Label27: TLabel;
    CRTime: TDateTimePicker;
    KHName: TBtnEditA;
    HWType: TEdit;
    Label22: TLabel;
    Panel5: TPanel;
    Label6: TLabel;
    Label11: TLabel;
    Label12: TLabel;
    Label14: TLabel;
    Label15: TLabel;
    Label16: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label31: TLabel;
    Label32: TLabel;
    Label33: TLabel;
    Label34: TLabel;
    Note: TEdit;
    PS: TEdit;
    Qty: TEdit;
    KgQty: TEdit;
    Label4: TLabel;
    Label5: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    MXHZPS: TEdit;
    MXHZQty: TEdit;
    MXHZKgQty: TEdit;
    Label9: TLabel;
    Label10: TLabel;
    Label17: TLabel;
    Label18: TLabel;
    PSChaE: TEdit;
    QtyChaE: TEdit;
    KgQtyChaE: TEdit;
    Panel7: TPanel;
    Panel1: TPanel;
    Label20: TLabel;
    Panel8: TPanel;
    Button1: TButton;
    PTID: TEdit;
    ODPat: TOpenDialog;
    IdFTP1: TIdFTP;
    SaveDialog1: TSaveDialog;
    Panel16: TPanel;
    Panel2: TPanel;
    Button3: TButton;
    Panel9: TPanel;
    Image1: TImage;
    Image11: TImage;
    adoqueryPicture: TADOQuery;
    Label1: TLabel;
    Label23: TLabel;
    JCDanWei: TBtnEditA;
    MYName: TBtnEditA;
    MYMF: TBtnEditA;
    MYKZ: TBtnEditA;
    MYColorNo: TBtnEditA;
    MYColor: TBtnEditA;
    Label24: TLabel;
    Label25: TLabel;
    SJKZ: TEdit;
    Label28: TLabel;
    RCGangNo: TEdit;
    procedure TBCloseClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure TBSaveClick(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure Panel6DblClick(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure KHNameBtnClick(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Image1DblClick(Sender: TObject);
    procedure Panel1Click(Sender: TObject);
    procedure Label20Click(Sender: TObject);
    procedure JCDanWeiBtnClick(Sender: TObject);
    procedure MYNameBtnClick(Sender: TObject);
    procedure MYMFBtnClick(Sender: TObject);
    procedure MYColorNoBtnClick(Sender: TObject);
    procedure KgQtyChange(Sender: TObject);
  private
    lstPat:TStringList;
    FangXiang1:String;
    procedure InitData();
    procedure SaveImage(maxnoWB:String);
    procedure ReadINIFile10();
    function  SaveData():Boolean;
    procedure InitColor();
    procedure ShowImage();
    { Private declarations }
  public
    canshu1:String;
    PState,CopyInt:Integer;
    FMainId:String;
    FRead:String;
    FMYType,FMYTypeFlag,FML:string;
    { Public declarations }
  end;

var
  frmLLRKInPut: TfrmLLRKInPut;
implementation
uses
  U_DataLink,U_ZDYHelp,U_RTFun,U_ZDYHelpSel, U_GYSList,U_SCPerson,U_QCRKJLList,U_RSColorBig,
  U_RTPTColor,U_KHListSelJJ,U_ZHCPBigTP,U_LLRKMXInPut,U_ZDYHelp_MFKZ;

{$R *.dfm}

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

procedure TfrmLLRKInPut.InitData();
begin
  with ADOQuery1 do
  begin
    Close;
    sql.Clear;
    sql.Add(' select * ');
    sql.Add(' from CK_MYSC_CR ');
    sql.Add(' where MYID='''+Trim(FMainId)+'''');
    Open;
  end;
  if ADOQuery1.IsEmpty=false then
  begin
    SCSHDataNew(ADOQuery1,Panel4,2);
    SCSHDataNew(ADOQuery1,Panel4,0);
    SCSHDataNew(ADOQuery1,Panel5,2);
    SCSHDataNew(ADOQuery1,Panel5,0);
    KHName.TxtCode:=Trim(ADOQuery1.fieldbyname('KHCode').AsString);
    labMYType.Caption:=Trim(ADOQuery1.fieldbyname('MYType').AsString);
  end;
  ShowImage();
  if PState=0 then
  begin
    CRTime.Date:=SGetServerDate(ADOTemp);
  end;
  if PState=2 then
  begin
    CRTime.Date:=SGetServerDate(ADOTemp);
    FMainId:='';
    ps.Text:='';
    Qty.Text:='';
    KgQty.Text:='';
    JCDanWei.Text:='';
    SJKZ.Text:='';
  end;
  if Trim(PTID.Text)<>'' then
  begin
    InitColor();
  end;
  if TBSave.Visible=False then
  begin
    Panel8.Visible:=False;
    Panel2.Visible:=False;
    initBtnColor(Panel4,clMenu);
    initBtnColor(Panel5,clMenu);
  end;
end;

procedure TfrmLLRKInPut.FormShow(Sender: TObject);
begin
  InitData();
end;

function TfrmLLRKInPut.SaveData():Boolean;
var
  maxno,maxmxno,maxnoflag,fsj,FMXID:String;
begin
  Result:=False;
  try
    ADOCmd.Connection.BeginTrans;
    ///保存主表
    if Trim(FMainId)='' then
    begin
      if GetLSNo(ADOCmd,maxno,'LL','CK_MYSC_CR',3,1)=False then
      begin
        ADOCmd.Connection.RollbackTrans;
        Application.MessageBox('取最大号失败!','提示',0);
        Exit;
      end;
      maxno:=Trim(maxno);
    end else
    begin
      maxno:=Trim(FMainId);
    end;
    with ADOCmd do
    begin
      Close;
      sql.Clear;
      SQL.Add('select * from CK_MYSC_CR where MYId='''+Trim(FMainId)+'''');
      Open;
    end;
    with ADOCmd do
    begin
      if Trim(FMainId)='' then
      begin
        Append;
      end
      else begin
        Edit;
      end;
      FieldByName('MYId').Value:=Trim(maxno);
      FieldByName('CRType').Value:='来料入库';
      FieldByName('CRFlag').Value:='入库';
      FieldByName('CRQtyFlag').Value:=1;
      if Trim(FMainId)='' then
      begin
        FieldByName('Filler').Value:=Trim(DName);
        FieldByName('FillerCode').Value:=Trim(DCode);
      end else
      begin
        FieldByName('Editer').Value:=Trim(DName);
        FieldByName('EditerCode').Value:=Trim(DCode);
        FieldByName('EditTime').Value:=SGetServerDateTime(ADOTemp);
      end;
      RTSetsavedata(ADOCmd,'CK_MYSC_CR',Panel4,2);
      RTSetsavedata(ADOCmd,'CK_MYSC_CR',Panel5,2);
      FieldByName('MYType').Value:=Trim(FMYType);
      FieldByName('MYTypeFlag').Value:=Trim(FMYTypeFlag);
      FieldByName('HWType').Value:=Trim(KHName.Text)+Trim(FormatDateTime('MMdd',CRTime.Date))+FML;
      fieldbyname('KHCode').AsString:=Trim(KHName.TxtCode);
      Post;
    end;
    FMainId:=Trim(maxno);
    with ADOCmd do
    begin
      Close;
      sql.Clear;
      SQL.Add('UPdate CK_MYSC_CR Set KHDayCS=isnull((select isnull(max(KHDayCS),0) from CK_MYSC_CR A ');
      sql.Add(' where A.CRTime=CK_MYSC_CR.CRTime and A.MYType=CK_MYSC_CR.MYType and isnull(A.KHName,'''')=isnull(CK_MYSC_CR.KHName,'''')),0)+1');
      SQL.Add('where MYID='''+Trim(FMainId)+''' and isnull(KHName,'''')<>'''' ');
      sql.Add(' and isnull(KHDayCS,0)=0');
      ExecSQL;
    end;
    with ADOCmd do
    begin
      Close;
      sql.Clear;
      sql.Add(' exec P_Update_LLRK_Qty :MYID');
      Parameters.ParamByName('MYID').Value:=Trim(maxno);
      ExecSQL;
    end;
    if Trim(Image1.Hint)<>'' then
    begin
      SaveImage(maxno);
    end;
    ADOCmd.Connection.CommitTrans;
    FMainId:=Trim(maxno);
    Result:=True;
  except
    Result:=False;
    ClientDataSet1.EnableControls;
    ADOCmd.Connection.RollbackTrans;
    Application.MessageBox('保存失败！','提示',0);
  end;
end;

procedure TfrmLLRKInPut.TBSaveClick(Sender: TObject);
var
  FReal:Double;
  FInt:Integer;
begin
  ToolBar1.SetFocus;
  if Trim(KHName.Text)='' then
  begin
    Application.MessageBox('客户不能为空!','提示',0);
    Exit;
  end;
  if TryStrToInt(PS.Text,FInt)=False then
  begin
    Application.MessageBox('匹数非法数字!','提示',0);
    exit;
  end;
  if (Trim(Qty.Text)='') and (Trim(KgQty.text)='') and (Trim(PS.Text)='') then
  begin
    Application.MessageBox('匹数、米数和公斤数不能同时为空!','提示',0);
    exit;
  end;
  if Trim(Qty.Text)<>'' then
  begin
    if TryStrToFloat(Qty.Text,FReal)=False then
    begin
      Application.MessageBox('米数非法数字!','提示',0);
      exit;
    end;
  end;
  if Trim(KgQty.Text)<>'' then
  begin
    if TryStrToFloat(KgQty.Text,FReal)=False then
    begin
      Application.MessageBox('公斤数非法数字!','提示',0);
      exit;
    end;
  end;
  if SaveData() then
  begin
    Application.MessageBox('保存成功！','提示',0);
    ModalResult:=1;
  end;
end;
procedure TfrmLLRKInPut.ReadINIFile10();
var
  programIni:Tinifile;  //配置文件名
  FileName:string;
begin
  FileName:=ExtractFilePath(Paramstr(0))+'SYSTEMSET.INI';
  programIni:=Tinifile.create(FileName);
  server:=programIni.ReadString('SERVER','服务器地址','127.0.0.1');
  programIni.Free;
end;
procedure TfrmLLRKInPut.SaveImage(maxnoWB:string);
var
  ImagePath,ImagName,MaxNo,MaxNoFile:String;
  AJpeg:TJPEGImage;
  myStream:TADOBlobStream;
begin
  try
    ImagePath:=Image1.Hint;
    ImagName:=Image1.Hint;
    AJpeg:=TJpegImage.Create();
    with ADOCmd do
    begin
      Close;
      sql.Clear;
      SQL.Add('UPdate Image_File Set Valid=''N'' ');
      sql.Add(' where IMID=(select IMID from Image_Info');
      Sql.Add('where WBID='''+Trim(maxnoWB)+''' and Valid=''Y'' )');
      ExecSQL;
    end;
    with ADOCmd do
    begin
      Close;
      sql.Clear;
      SQL.Add('UPdate Image_Info Set Editer='''+Trim(DName)+''',EditerCode='''+Trim(DCode)+''',EditTime=getdate()');
      sql.Add(',Valid=''N''  where WBID='''+Trim(maxnoWB)+''' and Valid=''Y''  ');
      ExecSQL;
    end;
    if GetLSNo(ADOCmd,MaxNo,'IM','Image_Info',4,1)=False then
    begin
      ADOCmd.Connection.RollbackTrans;
      Application.MessageBox('取图片信息最大号失败！','提示',0);
      Exit;
    end;
    with ADOCmd do
    begin
      Close;
      SQL.Clear;
      SQL.Add('select * from Image_Info where 1=2');
      Open;
    end;
    with ADOCmd do
    begin
      Append;
      FieldByName('IMID').Value:=Trim(MaxNo);
      FieldByName('WBID').Value:=Trim(maxnoWB);
      FieldByName('ImageName').Value:=Trim(ImagName);
      FieldByName('ImagePath').Value:=Trim(MaxNo)+Trim(ImagName);
      FieldByName('ImageDate').Value:=SGetServerDate(ADOTemp);
      Fieldbyname('ImageType').value:=Trim('YP');
      Fieldbyname('Valid').value:=Trim('Y');
      Post;
    end;
    if GetLSNo(ADOCmd,MaxNoFile,'IF','Image_File',4,1)=False then
    begin
      ADOCmd.Connection.RollbackTrans;
      Application.MessageBox('取图片文件最大号失败！','提示',0);
      Exit;
    end;
    with ADOCmd do
    begin
      close;
      sql.Clear;
      sql.Add(' select *  from Image_File where 1=2');
      open;
    end;
    with ADOCmd do
    begin
      Append;
      FieldByName('IMID').Value:=Trim(MaxNo);
      FieldByName('IFID').Value:=Trim(MaxNoFile);
      Fieldbyname('Valid').value:=Trim('Y');
      FieldByName('ImageWidth').Value:=Image1.Width;
      FieldByName('ImageHeight').Value:=Image1.Height;
      FieldByName('FangXiang').Value:=FangXiang1;
      FieldByName('IFType').Value:='小';
      myStream := TADOBlobStream.Create(TBlobField(ADOCmd.FieldByName('ImageFile')), bmWrite);
      AJpeg.Assign(Image1.Picture.Graphic);
      AJpeg.SaveToStream(myStream);
      myStream.Free;
      Post;
    end;
    with ADOCmd do
    begin
      Append;
      FieldByName('IMID').Value:=Trim(MaxNo);
      FieldByName('IFID').Value:=Trim(MaxNoFile)+'D';
      Fieldbyname('Valid').value:=Trim('Y');
      FieldByName('ImageWidth').Value:=Image11.Width;
      FieldByName('ImageHeight').Value:=Image11.Height;
      FieldByName('FangXiang').Value:=FangXiang1;
      FieldByName('IFType').Value:='大';
      myStream := TADOBlobStream.Create(TBlobField(ADOCmd.FieldByName('ImageFile')), bmWrite);
      AJpeg.Assign(Image11.Picture.Graphic);
      AJpeg.SaveToStream(myStream);
      myStream.Free;
      Post;
    end;
    try
      ReadINIFile10();
      server:=ReadINIFileStr('SYSTEMSET.INI','SERVER','服务器地址','127.0.0.1');
      IdFTP1.Host :=server;//PicSvr;
      IdFTP1.Username := 'three';
      IdFTP1.Password := '641010';
      IdFTP1.Connect();
    except
      IdFTP1.Quit;
      Application.MessageBox('无法连接到文件服务器，请检查！', '提示', MB_ICONWARNING);
      Exit;
    end;
    if IdFTP1.Connected then
    begin
      IdFTP1.Put(lstPat[0], 'YP'+'\'+Trim(MaxNo)+Trim(ImagName));
    end;
    if IdFTP1.Connected then IdFTP1.Quit;
  except
    ADOCmd.Connection.RollbackTrans;
    Application.MessageBox('图片保存失败！','提示',0);
  end;
end;

Procedure TfrmLLRKInPut.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  ModalResult:=1;
end;

procedure TfrmLLRKInPut.InitColor();
var
  fsj:string;
begin
  with ADOTemp do
  begin
    Close;
    sql.Clear;
    sql.Add('select * from RT_PTColor where PTID='''+Trim(PTID.Text)+'''');
    Open;
  end;
  fsj:=Trim(ADOTemp.fieldbyname('ColDaiMa').AsString);
  if Trim(fsj)<>'' then
  begin
    Panel6.Color:=StrToInt('$'+Trim(fsj));
  end;
end;

procedure TfrmLLRKInPut.ShowImage();
var
  jpg:TJpegImage;
  myStream: TADOBlobStream;
begin
 with adoqueryPicture do
  begin
    Close;
    sql.Clear;
    sql.Add('select * from Image_Info A');
    sql.Add(' inner join Image_File B on A.IMID=B.IMID');
    sql.Add(' and A.WBID='''+Trim(FMainId)+'''');
    sql.Add(' and A.Valid=''Y'' ');
    Open;
  end;
  if adoqueryPicture.IsEmpty=False then
  begin
    jpg:=TJpegImage.Create();
    myStream:=tadoblobstream.Create(tblobfield(adoqueryPicture.fieldbyname('ImageFile')),bmread);
    jpg.LoadFromStream(myStream);
    Image1.Picture.Assign(jpg);
    Image1.Width:=adoqueryPicture.fieldbyname('ImageWidth').Value;
    Image1.Height:=adoqueryPicture.fieldbyname('ImageHeight').Value;
    if Trim(adoqueryPicture.fieldbyname('FangXiang').AsString)='垂直' then
    begin
      Image1.Top:=1;
      Image1.Left:=Round((Panel9.Width-Image1.Width)/2);
    end else
    begin
      Image1.Left:=1;
      Image1.Top:=Round((Panel9.Height-Image1.Height)/2);
    end;
    Image1.Visible:=True;
  end;
end;

procedure TfrmLLRKInPut.Panel6DblClick(Sender: TObject);
begin
  try
    frmRSColorBig:=TfrmRSColorBig.Create(Application);
    with frmRSColorBig do
    begin
      frmRSColorBig.Label1.Caption:=Self.MYColorNo.Text+'#';
      frmRSColorBig.Label2.Caption:=Self.MYColor.Text;
      frmRSColorBig.Color:=Self.Panel6.Color;
      if ShowModal=1 then
      begin

      end;
    end;
  finally
  end;
end;

procedure TfrmLLRKInPut.Button1Click(Sender: TObject);
begin
  try
    frmRTPTColor:=TfrmRTPTColor.Create(Application);
    with frmRTPTColor do
    begin
      if ShowModal=1 then
      begin
        Self.PTID.Text:=Trim(frmRTPTColor.FPTID);
        Self.MYColor.Text:=Trim(frmRTPTColor.FColNameKH);
      end;
    end;
  finally
    frmRTPTColor.Free;
  end;
  if Trim(PTID.Text)<>'' then
  begin
    InitColor();
  end;
end;

procedure TfrmLLRKInPut.FormCreate(Sender: TObject);
begin
  lstPat := TStringList.Create;
end;

procedure TfrmLLRKInPut.KHNameBtnClick(Sender: TObject);
begin
  try
    frmKHListSelJJ:=TfrmKHListSelJJ.Create(Application);
    with frmKHListSelJJ do
    begin
      frmKHListSelJJ.canshu2:='高权限';
      if ShowModal=1 then
      begin
        Self.KHName.Text:=Trim(frmKHListSelJJ.CDS_HZ.fieldbyname('KHNameJC').AsString);
        Self.KHName.TxtCode:=Trim(frmKHListSelJJ.CDS_HZ.fieldbyname('KHNo').AsString);
      end;
    end;
  finally
    frmKHListSelJJ.Free;
  end;
end;

procedure TfrmLLRKInPut.Button3Click(Sender: TObject);
var
  AJpeg:TJPEGImage;
  Bitmap,Bitmap11: TBitmap;
  ARect,ARect11: TRect;
  TPHeight, AHeightOffset: Integer;
  TPWidth, AWidthOffset: Integer;
  WZShuiPing,WZChuiZhi:Integer;
  WZFlag:String;
  FHFStr:String;
begin
  lstPat.Clear;
  if ODPat.Execute then
  begin
    lstPat.AddStrings(ODPat.Files);
  end else
  begin
    Exit;
  end;
  if  lstPat.Count>1 then
  begin
    lstPat.Clear;
    Application.MessageBox('不能上传多个图片!','提示',0);
    Exit;
  end else
  if lstPat.Count<1 then
  begin
    Exit;
  end;
 // Panel1.Visible:=True;
 // Panel1.Refresh;
  Panel9.Color:=clBtnFace;
  Panel9.Hint:='';
  AJpeg:=TJpegImage.Create();
  AJpeg.LoadFromFile(ExtractFileName(ODPat.FileName));
  Image1.Hint:=ExtractFileName(ODPat.FileName);
  TPWidth:=AJpeg.Width;
  TPHeight:=AJpeg.Height;
  Bitmap := TBitmap.Create;
  Bitmap11 := TBitmap.Create;
  Bitmap.Width :=Panel9.Width-2;
  Bitmap.Height :=Round(Panel9.Width/TPWidth*TPHeight);
  if Bitmap.Height>Panel9.Height then
  begin
    WZFlag:='垂直';
    Bitmap.Height:=Panel9.Height-2;
    Bitmap.Width :=Round(Panel9.Height/TPHeight*TPWidth);
  end;
  Bitmap11.Width:=Bitmap.Width*2;
  Bitmap11.Height:=Bitmap.Height*2;
  Bitmap.Canvas.FillRect(Rect(0, 0, Bitmap.Width, Bitmap.Height));
  ARect := Rect(0, 0, Bitmap.Width, Bitmap.Height);
  Bitmap.Canvas.StretchDraw(ARect, AJPeg);
  Image1.Height:=Bitmap.Height;
  Image1.Width:=Bitmap.Width;
  Image1.Picture.Assign(BitMap);
  if Trim(WZFlag)='垂直' then
  begin
    Image1.Top:=1;
    Image1.Left:=Round((Panel9.Width-Image1.Width)/2);
  end else
  begin
    Image1.Left:=1;
    Image1.Top:=Round((Panel9.Height-Image1.Height)/2);
  end;
  FangXiang1:=WZFlag;
  Image1.Visible:=True;
  Bitmap11.Canvas.FillRect(Rect(0, 0, Bitmap11.Width, Bitmap11.Height));
  ARect11 := Rect(0, 0, Bitmap11.Width, Bitmap11.Height);
  Bitmap11.Canvas.StretchDraw(ARect11, AJPeg);
  Image11.Height:=Bitmap11.Height;
  Image11.Width:=Bitmap11.Width;
  Image11.Picture.Assign(BitMap11);
end;

procedure TfrmLLRKInPut.Image1DblClick(Sender: TObject);
begin
  if Trim(FMainId)='' then
  begin
    Application.MessageBox('没有保存数据，不能查看大图!','提示',0);
    Exit;
  end;
  try
    frmZHCPBigTP:=TfrmZHCPBigTP.Create(Application);
    with frmZHCPBigTP do
    begin
      frmZHCPBigTP.FMainId:=Self.FMainId;
      frmZHCPBigTP.FIMNO:='';
      if ShowModal=1 then
      begin

      end;
    end;
  finally
    frmZHCPBigTP.Free;
  end;
end;

procedure TfrmLLRKInPut.Panel1Click(Sender: TObject);
begin
  if Trim(FMainId)='' then
  begin
    Application.MessageBox('未保存数据！','',0);
    Exit;
  end;
  try
    frmLLRKMXInPut:=TfrmLLRKMXInPut.Create(Application);
    with frmLLRKMXInPut do
    begin
      PState:=1;
      frmLLRKMXInPut.FMainId:=Trim(Self.FMainId);
      if Self.TBSave.Visible=False  then
      begin
        frmLLRKMXInPut.TBSave.Visible:=False;
      end;
      if ShowModal=1 then
      begin
        InitData();
      end;
    end;
  finally
    frmLLRKMXInPut.Free;
  end;
end;

procedure TfrmLLRKInPut.Label20Click(Sender: TObject);
begin
  if Trim(FMainId)='' then
  begin
    Application.MessageBox('未保存数据！','',0);
    Exit;
  end;
  try
    frmLLRKMXInPut:=TfrmLLRKMXInPut.Create(Application);
    with frmLLRKMXInPut do
    begin
      PState:=1;
      frmLLRKMXInPut.FMainId:=Trim(Self.FMainId);
      if Self.TBSave.Visible=False  then
      begin
        frmLLRKMXInPut.TBSave.Visible:=False;
      end;
      if ShowModal=1 then
      begin
        InitData();
      end;
    end;
  finally
    frmLLRKMXInPut.Free;
  end;
end;

procedure TfrmLLRKInPut.JCDanWeiBtnClick(Sender: TObject);
begin
  frmZDYHelp:=TfrmZDYHelp.Create(self);
  with frmZDYHelp do
  begin
    flag:='LHJCDanWei'+trim(FMYTypeFlag);
    flagName:='来货单位';
    MainType:=Trim(KHName.Text);
    if ShowModal=1 then
    begin
      JCDanWei.Text:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
    end;
    free;
  end;
end;

procedure TfrmLLRKInPut.MYNameBtnClick(Sender: TObject);
begin
  frmZDYHelp:=TfrmZDYHelp.Create(self);
  with frmZDYHelp do
  begin
    flag:='MLMYName'+trim(FMYTypeFlag);
    flagName:='货物品名';
    MainType:=Trim(KHName.Text);
    if ShowModal=1 then
    begin
      MYName.Text:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
    end;
    free;
  end;
end;

procedure TfrmLLRKInPut.MYMFBtnClick(Sender: TObject);
begin
  frmZDYHelp_MFKZ:=TfrmZDYHelp_MFKZ.Create(self);
  with frmZDYHelp_MFKZ do
  begin
    flag:='MLMYMF'+trim(FMYTypeFlag);
    flagName:='门幅克重';
    fnote:=true;
    V1Note.Caption:='克重';
    V1Name.Caption:='门幅';
    MainType:=Trim(KHName.Text);
    if ShowModal=1 then
    begin
      MYMF.Text:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
      MYKZ.Text:=Trim(ClientDataSet1.fieldbyname('Note').AsString);
      if (Qty.Text<>'') and (MYMF.Text<>'') then
      SJKZ.Text:=FloatToStr(StrToFloatdef(KGQty.text,0)*1000/strtofloatdef(Qty.Text,0)/strtofloatdef(MYMF.Text,0)*100);
    end;
    free;
  end;
end;

procedure TfrmLLRKInPut.MYColorNoBtnClick(Sender: TObject);
begin
  frmZDYHelp:=TfrmZDYHelp.Create(self);
  with frmZDYHelp do
  begin
    flag:='MLMYColorNo'+trim(FMYTypeFlag);
    flagName:='色号颜色';
    fnote:=true;
    V1Note.Caption:='颜色';
    V1Name.Caption:='色号';
    MainType:=Trim(KHName.Text);
    if ShowModal=1 then
    begin
      MYColorNo.Text:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
      MYColor.Text:=Trim(ClientDataSet1.fieldbyname('Note').AsString);
    end;
    free;
  end;
end;

procedure TfrmLLRKInPut.KgQtyChange(Sender: TObject);
begin
  if (Qty.Text<>'') and (MYMF.Text<>'') then
  SJKZ.Text:=FloatToStr(StrToFloatdef(KGQty.text,0)*1000/strtofloatdef(Qty.Text,0)/strtofloatdef(MYMF.Text,0)*100);
end;

end.
