unit U_ClothSCInPut;

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, cxDropDownEdit,StrUtils, cxPC,ShellAPI;

type
  TfrmClothSCInPut = class(TForm)
    ToolBar1: TToolBar;
    TBClose: TToolButton;
    ADOTemp: TADOQuery;
    ADOCmd: TADOQuery;
    ADOQuery1: TADOQuery;
    ADOQueryTemp: TADOQuery;
    Panel2: TPanel;
    DataSource2: TDataSource;
    CDS_YuanLiao: TClientDataSet;
    ADOQueryCmd: TADOQuery;
    cxPageControl1: TcxPageControl;
    cxTabSheet1: TcxTabSheet;
    cxTabSheet2: TcxTabSheet;
    cxGrid2: TcxGrid;
    Tv2: TcxGridDBTableView;
    v2YCLName: TcxGridDBColumn;
    v2PinPai: TcxGridDBColumn;
    cxGridDBColumn2: TcxGridDBColumn;
    v2Column4: TcxGridDBColumn;
    cxGridDBColumn6: TcxGridDBColumn;
    cxGridLevel1: TcxGridLevel;
    cxGrid3: TcxGrid;
    Tv3: TcxGridDBTableView;
    cxGridLevel2: TcxGridLevel;
    v3Column1: TcxGridDBColumn;
    cxGrid5: TcxGrid;
    Tv5: TcxGridDBTableView;
    cxGridDBColumn4: TcxGridDBColumn;
    cxGridDBColumn5: TcxGridDBColumn;
    cxGridDBColumn7: TcxGridDBColumn;
    cxGridDBColumn8: TcxGridDBColumn;
    cxGridDBColumn9: TcxGridDBColumn;
    cxGridDBColumn10: TcxGridDBColumn;
    cxGridDBColumn11: TcxGridDBColumn;
    cxGridDBColumn12: TcxGridDBColumn;
    cxGridDBColumn13: TcxGridDBColumn;
    cxGridDBColumn14: TcxGridDBColumn;
    cxGridDBColumn15: TcxGridDBColumn;
    cxGridDBColumn16: TcxGridDBColumn;
    cxGridDBColumn17: TcxGridDBColumn;
    cxGridDBColumn18: TcxGridDBColumn;
    cxGridDBColumn19: TcxGridDBColumn;
    cxGridDBColumn20: TcxGridDBColumn;
    cxGridDBColumn21: TcxGridDBColumn;
    cxGridDBColumn22: TcxGridDBColumn;
    cxGridDBColumn23: TcxGridDBColumn;
    cxGridDBColumn24: TcxGridDBColumn;
    cxGridDBColumn25: TcxGridDBColumn;
    cxGridDBColumn26: TcxGridDBColumn;
    cxGridDBColumn27: TcxGridDBColumn;
    cxGridDBColumn28: TcxGridDBColumn;
    cxGridLevel3: TcxGridLevel;
    Panel1: TPanel;
    Panel3: TPanel;
    ClientDataSet6: TClientDataSet;
    DataSource6: TDataSource;
    ClientDataSet5: TClientDataSet;
    DataSource3: TDataSource;
    ClientDataSet3: TClientDataSet;
    DataSource5: TDataSource;
    v2Column1: TcxGridDBColumn;
    v2Column3: TcxGridDBColumn;
    v2Column5: TcxGridDBColumn;
    v2YCLSpec: TcxGridDBColumn;
    Panel5: TPanel;
    Label33: TLabel;
    XSConNo: TBtnEditC;
    v2GYSName: TcxGridDBColumn;
    CDS_PBMX: TClientDataSet;
    DataSourcePBMX: TDataSource;
    Panel6: TPanel;
    cxGrid1: TcxGrid;
    TvPBMX: TcxGridDBTableView;
    cxGridDBColumn3: TcxGridDBColumn;
    cxGridDBColumn43: TcxGridDBColumn;
    cxGridDBColumn44: TcxGridDBColumn;
    cxGridDBColumn45: TcxGridDBColumn;
    cxGridDBColumn46: TcxGridDBColumn;
    cxGridDBColumn47: TcxGridDBColumn;
    cxGridDBColumn51: TcxGridDBColumn;
    cxGridLevel5: TcxGridLevel;
    ScrollBox1: TScrollBox;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label11: TLabel;
    Label9: TLabel;
    Label14: TLabel;
    Label15: TLabel;
    Label18: TLabel;
    Label19: TLabel;
    Label21: TLabel;
    Label22: TLabel;
    Label5: TLabel;
    Label4: TLabel;
    Label6: TLabel;
    Label8: TLabel;
    Label12: TLabel;
    Label10: TLabel;
    Label13: TLabel;
    Label16: TLabel;
    Label26: TLabel;
    Label27: TLabel;
    Label28: TLabel;
    Label7: TLabel;
    Label17: TLabel;
    Label23: TLabel;
    Label24: TLabel;
    Label25: TLabel;
    Label30: TLabel;
    Label31: TLabel;
    Label32: TLabel;
    Label39: TLabel;
    Label49: TLabel;
    ConNo: TEdit;
    QDTime: TDateTimePicker;
    C_CodeName: TcxButtonEdit;
    KZQty: TEdit;
    CarType: TcxButtonEdit;
    MFQty: TEdit;
    CompanyName: TcxButtonEdit;
    ZhuanQty: TEdit;
    DayQty: TEdit;
    DeliveryDate: TDateTimePicker;
    C_Color: TEdit;
    PiKgQty: TEdit;
    PiQty: TEdit;
    C_Qty: TEdit;
    C_Code: TEdit;
    PiZhong: TEdit;
    ZhenCun: TcxButtonEdit;
    ZongZhenQty: TEdit;
    ChouZhen: TcxButtonEdit;
    JGPrice: TEdit;
    C_Spec: TEdit;
    GZGSType: TComboBox;
    Panel8: TPanel;
    Label34: TLabel;
    Label35: TLabel;
    Label36: TLabel;
    Label37: TLabel;
    Label38: TLabel;
    Label40: TLabel;
    Label41: TLabel;
    Label42: TLabel;
    Label43: TLabel;
    Label44: TLabel;
    Label45: TLabel;
    Label46: TLabel;
    Label47: TLabel;
    Label48: TLabel;
    APPS: TEdit;
    JYPS: TEdit;
    JYQtyKg: TEdit;
    DJYPS: TEdit;
    RKPS: TEdit;
    RKQtyKg: TEdit;
    DRKPS: TEdit;
    DRKQtyKg: TEdit;
    CKPS: TEdit;
    CKQtyKg: TEdit;
    KCPS: TEdit;
    KCQtyKg: TEdit;
    DAPPS: TEdit;
    APJT: TEdit;
    ShaChang: TEdit;
    C_Note: TRichEdit;
    TaiTouFlag: TComboBox;
    procedure TBCloseClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure XSConNoBtnDnClick(Sender: TObject);
    procedure Tv3MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure Tv5MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
  private
    FXS:Integer;
    procedure InitData();
    procedure ZDYHelp(FButn:TcxButtonEdit;LType:string);
    { Private declarations }
  public
    PState,FCopyInt,YLOK,YLSJOK:Integer;
    FMainId,FConNo,PType,FSubId,FGYFlag:String;
    { Public declarations }
  end;

var
  frmClothSCInPut: TfrmClothSCInPut;
  newh:hwnd;
implementation
uses
  U_DataLink,U_ZDYHelp,U_RTFun;

{$R *.dfm}

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

procedure TfrmClothSCInPut.InitData();

begin

  with ADOQuery1 do
  begin
    Close;
    SQL.Clear;
    sql.Add(' exec Cloth_QryList :MainId,:WSql');
    if PState=1 then
    begin
      ADOQuery1.Parameters.ParamByName('MainId').Value:=Trim(FMainId);
      ADOQuery1.Parameters.ParamByName('WSQl').Value:='';
    end;
    if PState=0 then
    begin
      ADOQuery1.Parameters.ParamByName('MainId').Value:=Trim(FMainId);
      ADOQuery1.Parameters.ParamByName('WSql').Value:=' and 1<>1 ';
    end;
    Open;
  end;
  SCSHData(ADOQuery1,ScrollBox1,0);
  SCSHData(ADOQuery1,ScrollBox1,2);
  XSConNo.Text:=Trim(ADOQuery1.fieldbyname('XSConNo').AsString);
  XSConNo.TxtCode:=Trim(ADOQuery1.fieldbyname('ConSubId').AsString);
  with ADOTemp do
  begin
    Close;
    sql.Clear;
    sql.Add('select * from Cloth_YCL_PB where MainId='''+Trim(FMainId)+'''');
    Open;
  end;
  SCreateCDS20(ADOTemp,CDS_YuanLiao);
  SInitCDSData20(ADOTemp,CDS_YuanLiao);
  with ADOTemp do
  begin
    Close;
    sql.Clear;
    sql.Add('select * from Cloth_PaiZhen where MainId='''+Trim(FMainId)+'''');
    sql.Add(' and PZType=''ÅÅÕë'' ');
    Open;
  end;
  SCreateCDS20(ADOTemp,ClientDataSet3);
  SInitCDSData20(ADOTemp,ClientDataSet3);
  if ClientDataSet3.IsEmpty then
  begin
    with ClientDataSet3 do
    begin
      Append;
      FieldByName('PZName').Value:='ÉÏÕë';
      Post;
      Append;
      FieldByName('PZName').Value:='ÏÂÕë';
      Post;
    end;
  end;
  with ADOTemp do
  begin
    Close;
    sql.Clear;
    sql.Add('select * from Cloth_PaiZhen where MainId='''+Trim(FMainId)+'''');
    sql.Add(' and PZType=''Èý½Ç'' ');
    Open;
  end;
  SCreateCDS20(ADOTemp,ClientDataSet5);
  SInitCDSData20(ADOTemp,ClientDataSet5);
  if Trim(FMainId)<>'' then
  begin
    with ADOQueryTemp do
    begin
      Close;
      sql.Clear;
      SQL.Add(' exec P_View_ClothQtyHZ '''+Trim(FMainId)+''','''' ');
      Open;
    end;
    SCSHData(ADOQueryTemp,Panel8,666);
  end;

end;

procedure TfrmClothSCInPut.ZDYHelp(FButn:TcxButtonEdit;LType:string);

begin

end;

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


procedure TfrmClothSCInPut.XSConNoBtnDnClick(Sender: TObject);
begin
  XSConNo.Text:='';
  XSConNo.TxtCode:='';
end;

procedure TfrmClothSCInPut.Tv3MouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  FXS:=1;
end;

procedure TfrmClothSCInPut.Tv5MouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  FXS:=2;
end;

end.
