unit U_RCCKInPut;

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, Menus,
  ImgList,ShellAPI;

type
  TfrmRCCKInPut = 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;
    labMYType: TLabel;
    Panel4: TPanel;
    Label13: TLabel;
    Label27: TLabel;
    CRTime: TDateTimePicker;
    KHName: TBtnEditA;
    Panel5: TPanel;
    Label12: TLabel;
    Label14: TLabel;
    Label15: TLabel;
    Label16: TLabel;
    Label31: TLabel;
    Label32: TLabel;
    MYKZ: TEdit;
    MYMF: TEdit;
    PS: TEdit;
    Qty: TEdit;
    KgQty: TEdit;
    Label4: TLabel;
    Label5: 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;
    PTID: TEdit;
    ODPat: TOpenDialog;
    IdFTP1: TIdFTP;
    SaveDialog1: TSaveDialog;
    adoqueryPicture: TADOQuery;
    Label2: TLabel;
    MYCF: TEdit;
    Label3: TLabel;
    MYJWS: TEdit;
    Label11: TLabel;
    MYMD: TEdit;
    Label23: TLabel;
    MYPrice: TEdit;
    Panel16: TPanel;
    Label24: TLabel;
    Panel6: TPanel;
    Panel8: TPanel;
    cxGrid1: TcxGrid;
    Tv1: TcxGridDBTableView;
    v1Column4: TcxGridDBColumn;
    v1Column6: TcxGridDBColumn;
    v1JH: TcxGridDBColumn;
    v1Column17: TcxGridDBColumn;
    v1Column3: TcxGridDBColumn;
    cxGrid1Level1: TcxGridLevel;
    Button5: TButton;
    cxGridPopupMenu2: TcxGridPopupMenu;
    DataSource2: TDataSource;
    KHNo: TEdit;
    PopupMenu2: TPopupMenu;
    MenuItem1: TMenuItem;
    N3: TMenuItem;
    MenuItem2: TMenuItem;
    N4: TMenuItem;
    ImageList1: TImageList;
    ADOQueryCmd: TADOQuery;
    ADOQueryTmp: TADOQuery;
    cxGroupBox2: TcxGroupBox;
    ListView1: TListView;
    Label33: TLabel;
    JCDanWei: TBtnEditA;
    JCNo: TEdit;
    Panel10: TPanel;
    Button10: TButton;
    Label41: TLabel;
    Label42: TLabel;
    KgQtyAvg: TEdit;
    QtyAvg: TEdit;
    Label39: TLabel;
    RCGangNo1: TEdit;
    Label40: TLabel;
    JH: TEdit;
    ADOQuery2: TADOQuery;
    Panel12: TPanel;
    Label8: TLabel;
    Button2: TButton;
    Panel13: TPanel;
    Image2: TImage;
    WJName: TEdit;
    Button7: TButton;
    WJPach: TEdit;
    Button8: TButton;
    Label44: TLabel;
    Label45: TLabel;
    Label49: TLabel;
    Label50: TLabel;
    Panel15: TPanel;
    Label22: TLabel;
    MYCode: TEdit;
    MYName: TBtnEditA;
    Panel2: TPanel;
    Label1: TLabel;
    Note: TEdit;
    v1MXNote: TcxGridDBColumn;
    Panel17: TPanel;
    Label34: TLabel;
    Label30: TLabel;
    Label35: TLabel;
    Label36: TLabel;
    Label37: TLabel;
    Label52: TLabel;
    Label53: TLabel;
    Label54: TLabel;
    Label55: TLabel;
    Label56: TLabel;
    Label57: TLabel;
    Label58: TLabel;
    Edit1: TEdit;
    Edit3: TEdit;
    MYColor: TEdit;
    Edit4: TEdit;
    Edit5: TEdit;
    MYColorNo: TEdit;
    Edit7: TEdit;
    Panel18: TPanel;
    Button4: TButton;
    Edit8: TEdit;
    GYLXName: TEdit;
    Button6: TButton;
    Panel14: TPanel;
    Label51: TLabel;
    Label43: TLabel;
    MYMDPrice: TEdit;
    MDMFlag: TCheckBox;
    MDKGFlag: TCheckBox;
    HSFlag: TCheckBox;
    BHSFlag: TCheckBox;
    cxGrid2: TcxGrid;
    TV2: TcxGridDBTableView;
    cxMYColor: TcxGridDBColumn;
    cxMYColorNo: TcxGridDBColumn;
    cxGangQty: TcxGridDBColumn;
    cxPS: TcxGridDBColumn;
    cxKgQty: TcxGridDBColumn;
    cxQty: TcxGridDBColumn;
    cxNote: TcxGridDBColumn;
    cxGridLevel1: TcxGridLevel;
    procedure TBCloseClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure TBSaveClick(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure Panel6DblClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure KHNameBtnClick(Sender: TObject);
    procedure Image1DblClick(Sender: TObject);
    procedure Panel1Click(Sender: TObject);
    procedure Label20Click(Sender: TObject);
    procedure Button5Click(Sender: TObject);
    procedure N1Click(Sender: TObject);
    procedure N2Click(Sender: TObject);
    procedure MYNameBtnClick(Sender: TObject);
    procedure Panel13Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button8Click(Sender: TObject);
    procedure Button7Click(Sender: TObject);
    procedure Image2Click(Sender: TObject);
    procedure MenuItem1Click(Sender: TObject);
    procedure N3Click(Sender: TObject);
    procedure MenuItem2Click(Sender: TObject);
    procedure N4Click(Sender: TObject);
    procedure Panel2Click(Sender: TObject);
    procedure ListView1DblClick(Sender: TObject);
    procedure JCDanWeiBtnClick(Sender: TObject);
    procedure RCGangNo1Change(Sender: TObject);
    procedure HSFlagClick(Sender: TObject);
    procedure BHSFlagClick(Sender: TObject);
    procedure PSChaEChange(Sender: TObject);
    procedure QtyChaEChange(Sender: TObject);
    procedure KgQtyChaEChange(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure Panel18DblClick(Sender: TObject);
    procedure Button6Click(Sender: TObject);
  private
    lstPat:TStringList;
    FangXiang1,FSaveFlag:String;
    procedure InitData();
    procedure SaveImage(maxnoWB:String);
    procedure ReadINIFile10();
    function  SaveData():Boolean;
    procedure InitColor();
    procedure ShowImage();
    procedure GetHZData();
    function SaveDataMX():Boolean;
    procedure InitMXData();
    procedure Initimage();
    { Private declarations }
  public
    canshu1:String;
    PState,CopyInt:Integer;
    FMainId:String;
    FRead:String;
    FMYType,FMYTypeFlag,FML:string;
    { Public declarations }
  end;

var
  frmRCCKInPut: TfrmRCCKInPut;
implementation
uses
  U_DataLink,U_ZDYHelp,U_RTFun,U_ZDYHelpSel, U_GYSList,U_SCPerson,U_QCRKJLList,U_RSColorBig,U_MLMangeRS_GYCX,
  U_RTPTColor,U_KHListSelJJ,U_ZHCPBigTP,U_LLRKMXInPutMH,U_ZDYCPName,U_BPZdy_LRPB,U_MLMangeRS_CX;

{$R *.dfm}

procedure TfrmRCCKInPut.TBCloseClick(Sender: TObject);
begin
  WriteCxGrid('坯布采购入库1',Tv1,'贸易生产管理');
  Close;
end;

procedure TfrmRCCKInPut.Initimage();
var
  ListItem: TListItem;
  Flag: Cardinal;
  info: SHFILEINFOA;
  Icon: TIcon;
begin
  ListView1.Items.Clear;
  with adoqueryTmp do
  begin
    close;
    sql.Clear;
    sql.Add('select fileName from TP_File ');
    sql.Add('where WBID='''+trim(FMainId)+''' ');
    sql.Add('and TFType=''采购坯布''');
    //ShowMessage(sql.Text);
    open;
    if not IsEmpty then
    begin
      while not eof do
      begin
        with ListView1 do
        begin
           LargeImages := ImageList1;
           Icon := TIcon.Create;
           ListItem := Items.Add;
           Listitem.Caption := trim(fieldbyname('fileName').AsString);
           Flag := (SHGFI_LARGEICON or SHGFI_ICON or SHGFI_USEFILEATTRIBUTES);
           SHGetFileInfo(Pchar(trim(fieldbyname('fileName').AsString)), 0, info, Sizeof(info), Flag);
           Icon.Handle := info.hIcon;
           ImageList1.AddIcon(Icon);
           ListItem.ImageIndex := ImageList1.Count - 1;
        end;
        next;
      end;
    end;
  end;
end;

procedure TfrmRCCKInPut.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;
  SCSHDataNew(ADOQuery1,Panel4,2);
  SCSHDataNew(ADOQuery1,Panel4,0);
  SCSHDataNew(ADOQuery1,Panel5,2);
  SCSHDataNew(ADOQuery1,Panel5,0);
  MDMFlag.Checked:=ADOQuery1.FieldByName('MDMflag').AsBoolean;
  MDKGFlag.Checked:=ADOQuery1.FieldByName('MDKGFlag').AsBoolean;
  HSFlag.Checked:=ADOQuery1.FieldByName('HSFlag').AsBoolean;
  BHSFlag.Checked:=ADOQuery1.FieldByName('BHSFlag').AsBoolean;
  KHName.TxtCode:=Trim(ADOQuery1.fieldbyname('KHCode').AsString);
  labMYType.Caption:=Trim(ADOQuery1.fieldbyname('MYType').AsString);
  MYName.text:=Trim(ADOQuery1.fieldbyname('MYName').AsString);
  MYCode.text:=Trim(ADOQuery1.fieldbyname('MYCode').AsString);
  MYMDPrice.text:=Trim(floattostr(ADOQuery1.fieldbyname('MYMDPrice').asfloat));
  ShowImage();
  if PState=0 then
  begin
    CRTime.Date:=SGetServerDate(ADOTemp);
    labMYType.Caption:=FMYType;
  end;
  if TBSave.Visible=False then
  begin
   // Panel8.Visible:=False;
    Panel2.Visible:=False;
    initBtnColor(Panel4,clMenu);
    initBtnColor(Panel5,clMenu);
  end;
  InitMXData();
  GetHZData();
  initImage();
end;

procedure TfrmRCCKInPut.InitMXData();
begin
  with ADOQuery2 do
  begin
    Close;
    sql.Clear;
    sql.Add('select A.*,A.RCGangNo RCGangNo1');
    sql.Add(',Laster=isnull(Editer,Filler) from CK_MYSC_CR_MX A where isnull(MYID,'''')='''+Trim(FMainId)+'''');
    Open;
  end;
  SCreateCDS20(ADOQuery2,ClientDataSet1);
  SInitCDSData20(ADOQuery2,ClientDataSet1);
end;

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

function TfrmRCCKInPut.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('MDMflag').Value:=MDMFlag.Checked;
      FieldByName('MDKGflag').Value:=MDKGflag.Checked;
      FieldByName('HSFlag').AsBoolean:=HSFlag.Checked;
      FieldByName('BHSFlag').AsBoolean:=BHSFlag.Checked;
      FieldByName('MYType').Value:=Trim(FMYType);
      FieldByName('MYTypeFlag').Value:=Trim(FMYTypeFlag);
      fieldbyname('KHCode').AsString:=Trim(KHName.TxtCode);
      fieldbyname('MYName').AsString:=Trim(MYName.Text);
      fieldbyname('MYCode').AsString:=Trim(MYCode.Text);
      fieldbyname('MYMDPrice').Value:=StrToFloatdef(MYMDPrice.Text,0);
      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;
    with ADOCmd do
    begin
      close;
      sql.Clear;
      SQL.Add('update BP_ZDY set BPPrice='''+trim(MYMDPrice.Text)+''' ');
      if HSFlag.Checked=True then
      sql.Add(',IFHS=''含税''')
      else
      sql.Add(',IFHS=''不含税''');
      sql.Add(' where BPCode='''+trim(MYCode.Text)+'''');
      sql.Add(' and BPName='''+trim(MYName.Text)+'''');
      ExecSQL;
    end;
    Button5.Click;
    ADOCmd.Connection.CommitTrans;
    FMainId:=Trim(maxno);
    Result:=True;
  except
    Result:=False;
    ClientDataSet1.EnableControls;
    ADOCmd.Connection.RollbackTrans;
    Application.MessageBox('保存失败！','提示',0);
  end;
end;

procedure TfrmRCCKInPut.TBSaveClick(Sender: TObject);
var
  FReal:Double;
  FInt:Integer;
begin
  ToolBar1.SetFocus;
  if Trim(KHName.Text)='' then
  begin
    Application.MessageBox('客户不能为空!','提示',0);
    Exit;
  end;
  if Trim(MYName.Text)='' then
  begin
    Application.MessageBox('品名不能为空!','提示',0);
    Exit;
  end;
  if Trim(MYCode.Text)='' then
  begin
    Application.MessageBox('产品编号不能为空!','提示',0);
    Exit;
  end;
  if (MDMFlag.Checked=False) and (MDKGFlag.Checked=False) then
  begin
    Application.MessageBox('请选择计价方式','提示',0);
    Exit;
  end;
  if (HSFlag.Checked=False) and (BHSFlag.Checked=False) then
  begin
    Application.MessageBox('请选择含税或不含税','提示',0);
    Exit;
  end;
  if Trim(PS.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)='') 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 TfrmRCCKInPut.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 TfrmRCCKInPut.SaveImage(maxnoWB:string);
begin
  
end;

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

procedure TfrmRCCKInPut.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
    Panel18.Color:=StrToInt('$'+Trim(fsj));
  end;
end;
procedure TfrmRCCKInPut.ShowImage();
begin

end;
procedure TfrmRCCKInPut.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 TfrmRCCKInPut.FormCreate(Sender: TObject);
begin
  lstPat := TStringList.Create;
  ReadCxGrid('坯布采购入库1',Tv1,'贸易生产管理');
end;

procedure TfrmRCCKInPut.KHNameBtnClick(Sender: TObject);
begin
  try
    frmGYSList:=TfrmGYSList.Create(Application);
    with frmGYSList do
    begin
      KHType.Text:='坯布厂';
      KHType.TxtCode:='坯布厂';
      if ShowModal=1 then
      begin
        Self.KHName.Text:=Trim(frmGYSList.Order_Main.fieldbyname('KHName').AsString);
        Self.KHNo.Text:=Trim(frmGYSList.Order_Main.fieldbyname('KHNo').AsString);
      end;
    end;
  finally
    frmGYSList.Free;
  end;
end;

procedure TfrmRCCKInPut.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 TfrmRCCKInPut.Panel1Click(Sender: TObject);
begin
  if Trim(FMainId)='' then
  begin
    Application.MessageBox('未保存数据！','',0);
    Exit;
  end;
  try
    frmLLRKMXInPutMH:=TfrmLLRKMXInPutMH.Create(Application);
    with frmLLRKMXInPutMH do
    begin
      PState:=1;
      frmLLRKMXInPutMH.FMainId:=Trim(Self.FMainId);
      if Self.TBSave.Visible=False  then
      begin
        frmLLRKMXInPutMH.TBSave.Visible:=False;
      end;
      if ShowModal=1 then
      begin
        InitData();
      end;
    end;
  finally
    frmLLRKMXInPutMH.Free;
  end;
end;

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

procedure TfrmRCCKInPut.GetHZData();
var
  FKG,FM,FPS:String;
begin
  FKG:=Tv1.DataController.Summary.FooterSummaryTexts[0];
  FM:=Tv1.DataController.Summary.FooterSummaryTexts[1];
  FPS:=Tv1.DataController.Summary.FooterSummaryTexts[2];
  MXHZPS.Text:=FPS;
  MXHZKGQty.Text:=FKG;
  MXHZQty.Text:=FM;
  if (Trim(FPS)='') or (Trim(FPS)='0')  then
  begin
    SClearData(Panel2,2);
    SClearData(Panel2,99);
  end else
  begin
    with ADOTemp do
    begin
      close;
      sql.Clear;
      sql.Add('exec P_Avg_JS :KgQty,:MQty,:PS');
      if Trim(FKG)<>'' then
      begin
        Parameters.ParamByName('KGQty').Value:=FKG;
      end else
      begin
        Parameters.ParamByName('KGQty').Value:=Null;
      end;
      if Trim(FM)<>'' then
      begin
        Parameters.ParamByName('MQty').Value:=FM;
      end else
      begin
        Parameters.ParamByName('MQty').Value:=Null;
      end;
      Parameters.ParamByName('PS').Value:=FPS;
      Open;
    end;
    KgQtyAvg.Text:=ADOTemp.fieldbyname('KgQtyAvg').Value;
    QtyAvg.Text:=ADOTemp.fieldbyname('QtyAvg').Value;
  end;
  PSChaE.Text:=FloatToStr(strtofloatdef(MXHZPS.Text,0)-strtofloatdef(PS.Text,0));
  QtyChaE.Text:=FloatToStr(strtofloatdef(MXHZQty.Text,0)-strtofloatdef(Qty.Text,0));
  KgQtyChaE.Text:=FloatToStr(strtofloatdef(MXHZKgQty.Text,0)-strtofloatdef(KGQty.Text,0));
end;

function TfrmRCCKInPut.SaveDataMX():Boolean;
var
  maxmxno,maxnoflag,fsj,FMXID:String;
begin
  Result:=False;
  with ADOCmd do
  begin
    Close;
    sql.Clear;
    sql.Add('delete from CK_MYSC_CR_MX where MYID='''+Trim(FMainId)+'''');
    ExecSQL;
  end;
  try
    ClientDataSet1.DisableControls;
    with ClientDataSet1 do
    begin
      First;
      while not Eof do
      begin
        if Trim(FMXID)='' then
        begin
          if GetLSNo(ADOCmd,maxmxno,'LM','CK_MYSC_CR_MX',4,1)=False then
          begin
            ClientDataSet1.EnableControls;
            Application.MessageBox('取来料入库数据最大号失败','提示',0);
            Exit;
          end;
          maxmxno:=maxmxno+'LML';
          with ADOCmd do
          begin
            Close;
            sql.Clear;
            sql.Add('select * from CK_MYSC_CR_MX where MXID='''+Trim(maxmxno)+'''');
            Open;
          end;
          with ADOCmd do
          begin
            Append;
            FieldByName('MYID').Value:=Trim(FMainId);
            FieldByName('MXID').Value:=Trim(maxmxno);
            FieldByName('RCGangNo').Value:=ClientDataSet1.fieldbyname('RCGangNo').Value;
            FieldByName('MXPrice').Value:=ClientDataSet1.fieldbyname('MXPrice').Value;
            FieldByName('MXMoney').Value:=ClientDataSet1.fieldbyname('MXMoney').Value;
            FieldByName('KgQty').Value:=ClientDataSet1.fieldbyname('KgQty').Value;
            FieldByName('MQty').Value:=ClientDataSet1.fieldbyname('MQty').Value;
            FieldByName('JH').Value:=ClientDataSet1.fieldbyname('JH').Value;
            FieldByName('Filler').Value:=Trim(DName);
            FieldByName('FillerCode').Value:=Trim(DCode);
            Post;
          end;
          if ClientDataSet1.fieldbyname('GangNo').AsString='' then
          begin
            with ADOCmd do
            begin
              Close;
              sql.Clear;
              sql.Add(' exec P_Update_QCRK_GangNo :MYID');
              Parameters.ParamByName('MYID').Value:=Trim(FMainId);
              ExecSQL;
            end;
          end;
          if ClientDataSet1.fieldbyname('JH').AsFloat=0 then
          begin
            with ADOCmd do
            begin
              Close;
              sql.Clear;
              sql.Add('Update CK_MYSC_CR_MX Set JH=isnull((select isnull(max(JH),0) from CK_MYSC_CR_MX A ');
              sql.Add(' where A.MYID='''+Trim(FMainId)+''' and isnull(A.RCGangNO,'''')=isnull(CK_MYSC_CR_MX.RCGangNO,'''')');
              sql.Add(' and isnull(A.GangNO,'''')=isnull(CK_MYSC_CR_MX.GangNO,'''')),0)+1 ');
              sql.Add(' where MXID='''+Trim(maxmxno)+'''');
              ExecSQL;
            end;
          end;
          Edit;
          FieldByName('MYID').Value:=Trim(FMainId);
          FieldByName('MXID').Value:=Trim(maxmxno);
          Post;
        end;
        Next;
      end;
    end;
    ClientDataSet1.EnableControls;
    with ADOCmd do
    begin
      Close;
      sql.Clear;
      sql.Add(' exec P_Update_LLRK_Qty :MYID');
      Parameters.ParamByName('MYID').Value:=Trim(FMainId);
      ExecSQL;
    end;
    //InitData();
    Result:=True;
  except
    Result:=False;
    ClientDataSet1.EnableControls;
    Application.MessageBox('保存失败！','提示',0);
  end;
end;

procedure TfrmRCCKInPut.Button5Click(Sender: TObject);
var
  FReal:Double;
begin
  if SaveDataMX() then
  begin
    GetHZData();
  end;
end;

procedure TfrmRCCKInPut.N1Click(Sender: TObject);
begin
  SelOKNo(ClientDataSet1,True);
end;

procedure TfrmRCCKInPut.N2Click(Sender: TObject);
begin
  SelOKNo(ClientDataSet1,False);
end;

procedure TfrmRCCKInPut.MYNameBtnClick(Sender: TObject);
begin
  frmBPZDY_LRPB:=TfrmBPZDY_LRPB.create(self);
  with frmBPZDY_LRPB do
  begin
    flag:='PBName';
    flagName:='坯布';
    ViewFlag:=true;
    Panel4.Align:=alClient;
    ToolBar3.Visible:=false;
    Button1.Visible:=False;
    if ShowModal=1 then
    begin
      MYName.text:=Trim(ClientDataSet1.fieldbyname('BPName').AsString);
      MYCode.text:=Trim(ClientDataSet1.fieldbyname('BPCode').AsString);
      MYCF.text:=Trim(ClientDataSet1.fieldbyname('BPCF').AsString);
      MYMF.text:=Trim(ClientDataSet1.fieldbyname('BPMF').AsString);
      MYKZ.text:=Trim(ClientDataSet1.fieldbyname('BPKZ').AsString);
      MYJWS.text:=Trim(ClientDataSet1.fieldbyname('BPJS').AsString);
      MYMD.text:=Trim(ClientDataSet1.fieldbyname('BPMiDu').AsString);
      MYPrice.text:=Trim(ClientDataSet1.fieldbyname('BPPrice').AsString);
      MYMDPrice.text:=Trim(ClientDataSet1.fieldbyname('BPPrice').AsString);
      Note.text:=Trim(ClientDataSet1.fieldbyname('BPNote').AsString);
      if ClientDataSet1.fieldbyname('IFHS').AsString='含税' then
      begin
        HSFlag.Checked:=True;
        BHSFlag.Checked:=false;
      end
      else
      begin
        HSFlag.Checked:=false;
        BHSFlag.Checked:=true;
      end;
    end;
    free;
  end;
end;

procedure TfrmRCCKInPut.Panel13Click(Sender: TObject);
begin
  Panel12.Visible:=False;
end;

procedure TfrmRCCKInPut.Button2Click(Sender: TObject);
var
  fFileName:string;
  fFilePath:string;
  maxNo:string;
begin
  try
    adoqueryCmd.Connection.BeginTrans;
    begin
      fFilePath:=WJPach.Text;
      fFileName:=WJName.Text;
      with adoqueryCmd do
      begin
        close;
        sql.Clear;
        sql.Add('select TFId from TP_File ');
        sql.Add('where WBID='''+trim(FMainid)+'''');
        sql.Add('and TFType=''采购坯布''');
        sql.Add('and FileName='+quotedstr(trim(fFileName)));
        open;
      end;
      IF ADOQueryCmd.IsEmpty=False  then
      begin
        ADOQueryCmd.Connection.RollbackTrans;
        application.MessageBox('此附件名称已存在，请修改文件名，继续上传！','提示信息',MB_ICONERROR);
        exit;
      end;
      Panel12.Visible:=False;
      Panel2.Caption:='正在上传数据，请稍等...';
      Panel2.Visible:=true;
      application.ProcessMessages;

      if GetLSNo(ADOQueryCmd,maxNo,'MD','TP_File',4,1)=False then
      begin
        ADOQueryCmd.Connection.RollbackTrans;
        Application.MessageBox('取最大号失败！','提示',0);
        Exit;
      end;

      with adoqueryCmd do
      begin
        close;
        sql.Clear;
        sql.Add('delete from TP_File ');
        sql.Add('where WBID='''+trim(FMainid)+'''');
        sql.Add('and TFType=''采购坯布''');
        sql.Add('and FileName='+quotedstr(trim(fFileName)));
        execsql;
      end;
      with adoqueryCmd do
      begin
        close;
        sql.Clear;
        sql.Add('select * from TP_File ');
        sql.Add('where WBID='''+trim(FMainid)+'''');
        sql.Add('and TFType=''采购坯布''');
        sql.Add('and FileName='+quotedstr(trim(fFileName)));
        open;
        append;
        fieldbyname('TFID').Value:=trim(maxNO);
        fieldbyname('WBID').Value:=trim(FMainid);
        fieldbyname('TFType').Value:='采购坯布';
        fieldbyname('FileName').Value:=trim(fFileName);
        post;
      end;
      if fFilePath <> '' then
      begin
        try
          IdFTP1.Host := ReadINIFileStr('SYSTEMSET.INI','SERVER','服务器地址','127.0.0.1');
          IdFTP1.Username := 'three';
          IdFTP1.Password := '641010';
          IdFTP1.Connect();
          IdFTP1.Put(fFilePath, 'FJ\' + Trim(fFileName));
          IdFTP1.Quit;
        except
          IdFTP1.Quit;
          Application.MessageBox('上传文件失败，请检查文件服务器！', '提示', MB_ICONWARNING);
        end;
      end;
      IdFTP1.Quit;
      Panel2.Visible:=false;
      Initimage();
    end;
    adoqueryCmd.Connection.CommitTrans;
  except
    adoqueryCmd.Connection.RollbackTrans;
    application.MessageBox('文件保存失败！','提示信息',0);
  end;
end;

procedure TfrmRCCKInPut.Button8Click(Sender: TObject);
var
  fFileName:String;
begin
  fFileName:=WJName.Hint;
  with ADOQueryCmd do
  begin
    close;
    sql.Clear;
    sql.Add('UPdate  TP_File Set FileName='''+Trim(WJName.Text)+'''');
    sql.Add('where WBID='''+trim(FMainid)+'''');
    sql.Add('and TFType=''采购坯布''');
    sql.Add('and FileName='+quotedstr(trim(fFileName)));
    execsql;
  end;
  Panel12.Visible:=False;
  Initimage();
end;

procedure TfrmRCCKInPut.Button7Click(Sender: TObject);
var
  fFileName:string;
  fFilePath:string;
  maxNo:string;
begin
  try
    adoqueryCmd.Connection.BeginTrans;
    fFilePath:=WJPach.Text;
    fFileName:=WJName.Hint;
    with adoqueryCmd do
    begin
      close;
      sql.Clear;
      sql.Add('select TFId from TP_File ');
      sql.Add('where WBID='''+trim(FMainid)+'''');
      sql.Add('and TFType=''采购坯布''');
      sql.Add('and FileName='+quotedstr(trim(fFileName)));
      open;
      IF not adoqueryCmd.IsEmpty then
      begin
        ADOQueryCmd.Connection.RollbackTrans;
        application.MessageBox('此附件名称已存在，请修改文件名，继续上传！','提示信息',MB_ICONERROR);
        exit;
      end;
    end;
    Panel12.Visible:=False;
    Panel2.Caption:='正在上传数据，请稍等...';
    Panel2.Visible:=true;
    application.ProcessMessages;

    if GetLSNo(ADOQueryCmd,maxNo,'FJ','TP_File',4,1)=False then
    begin
      ADOQueryCmd.Connection.RollbackTrans;
      Application.MessageBox('取最大号失败！','提示',0);
      Exit;
    end;

    with adoqueryCmd do
    begin
      close;
      sql.Clear;
      sql.Add('delete from TP_File ');
      sql.Add('where WBID='''+trim(FMainid)+'''');
      sql.Add('and TFType=''采购坯布''');
      sql.Add('and FileName='+quotedstr(trim(fFileName)));
      execsql;
    end;
    with adoqueryCmd do
    begin
      close;
      sql.Clear;
      sql.Add('select * from TP_File ');
      sql.Add('where WBID='''+trim(FMainid)+'''');
      sql.Add('and TFType=''采购坯布''');
      sql.Add('and FileName='+quotedstr(trim(fFileName)));
      open;
      append;
      fieldbyname('TFID').Value:=trim(maxNO);
      fieldbyname('WBID').Value:=trim(FMainid);
      fieldbyname('TFType').Value:='采购坯布';
      fieldbyname('FileName').Value:=trim(fFileName);
      post;
    end;
    if fFilePath <> '' then
    begin
      try
        IdFTP1.Host := ReadINIFileStr('SYSTEMSET.INI','SERVER','服务器地址','127.0.0.1');
        IdFTP1.Username := 'three';
        IdFTP1.Password := '641010';
        IdFTP1.Connect();
        IdFTP1.Put(fFilePath, 'FJ\' + Trim(fFileName));
        IdFTP1.Quit;
      except
        IdFTP1.Quit;
        Application.MessageBox('上传文件失败，请检查文件服务器！', '提示', MB_ICONWARNING);
      end;
    end;
    IdFTP1.Quit;
    Panel2.Visible:=false;
    Initimage();
    adoqueryCmd.Connection.CommitTrans;
  except
    adoqueryCmd.Connection.RollbackTrans;
    application.MessageBox('文件保存失败！','提示信息',0);
  end;
end;

procedure TfrmRCCKInPut.Image2Click(Sender: TObject);
begin
  Panel12.Visible:=false;
end;

procedure TfrmRCCKInPut.MenuItem1Click(Sender: TObject);
var
  OpenDiaLog: TOpenDialog;
  fFileName:string;
  fFilePath:string;
begin
  OpenDiaLog := TOpenDialog.Create(Self);
  if OpenDiaLog.Execute then
  begin
    fFilePath:=OpenDiaLog.FileName;
    fFileName:=ExtractFileName(OpenDiaLog.FileName);
    Panel12.Visible:=True;
    WJName.Text:=Trim(fFileName);
    WJName.Hint:=Trim(fFileName);
    WJPach.Text:=fFilePath;
    Button8.Visible:=False;
    Button2.Visible:=True;
    Button7.Visible:=True;
    Panel12.Refresh;
  end;
end;

procedure TfrmRCCKInPut.N3Click(Sender: TObject);
var
  fFileName:string;
begin
  if listView1.SelCount<1 then exit;
  try
    fFileName:=ListView1.Selected.Caption;
    with ADOQueryCmd do
    begin
      close;
      sql.Clear;
      sql.Add('delete  from TP_File ');
      sql.Add('where WBID='''+trim(FMainid)+'''');
      sql.Add('and TFType=''采购坯布''');
      sql.Add('and FileName='+quotedstr(trim(fFileName)));
      execsql;
    end;
    Initimage();
  except
  end;
end;

procedure TfrmRCCKInPut.MenuItem2Click(Sender: TObject);
begin
  if listView1.SelCount<1 then exit;
  Panel12.Visible:=True;
  Button2.Visible:=False;
  Button7.Visible:=False;
  Button8.Visible:=True;
  Panel12.Refresh;
  WJName.Text:=Trim(ListView1.Selected.Caption);
  WJName.Hint:=Trim(ListView1.Selected.Caption);
end;

procedure TfrmRCCKInPut.N4Click(Sender: TObject);
var
  SaveDialog: TSaveDialog;
  fFileName:string;
  fFilePath:string;
begin
  if listView1.SelCount<1 then exit;
  try
    fFileName:=ListView1.Selected.Caption;
    SaveDialog := TSaveDialog.Create(Self);
    SaveDialog.FileName:=fFileName;
    if SaveDialog.Execute then
    begin
      Panel2.Caption:='正在保存数据，请稍等...';
      Panel2.Visible:=true;
      application.ProcessMessages;
      fFilePath:=SaveDialog.FileName;
      try
        IdFTP1.Host := ReadINIFileStr('SYSTEMSET.INI','SERVER','FTP地址','127.0.0.1');;
        IdFTP1.Username := 'three';
		    IdFTP1.Password := '641010';
        IdFTP1.Connect();
      except
        ;
      end;

      if IdFTP1.Connected then
      begin
        Panel2.Caption:='正在下载数据，请稍等...';
        Panel2.Visible:=true;
        application.ProcessMessages;
        try
         IdFTP1.Get('FJ\'+ Trim(fFileName), fFilePath,false, true);
        except
          Panel2.Visible:=false;
          Application.MessageBox('客户图样文件不存在', '提示', MB_ICONWARNING);
          IdFTP1.Quit;
          Exit;
        end;
      end else
      begin
        Panel2.Visible:=false;
        Application.MessageBox('无法连接文件服务器', '提示', MB_ICONWARNING);
        IdFTP1.Quit;
        Exit;
      end;
     Panel2.Visible:=false;
     if IdFTP1.Connected then IdFTP1.Quit;
    end;
  except
    Panel2.Visible:=false;
  end;
end;

procedure TfrmRCCKInPut.Panel2Click(Sender: TObject);
begin
  Panel2.Visible:=false;
end;

procedure TfrmRCCKInPut.ListView1DblClick(Sender: TObject);
var
  sFieldName:string;
  fileName:string;
begin
  if ListView1.Items.Count<1 THEN EXIT;

  if listView1.SelCount<1 then exit;
  sFieldName:=leftbstr(ExtractFilePath(Application.ExeName),1)+':\图片查看';

  if not DirectoryExists(pchar(sFieldName)) then
  CreateDirectory(pchar(sFieldName),nil);

  fileName:=ListView1.Selected.Caption;

  sFieldName:=sFieldName+'\'+trim(fileName);

  try
    IdFTP1.Host := ReadINIFileStr('SYSTEMSET.INI','SERVER','服务器地址','127.0.0.1');
    IdFTP1.Username := 'three';
		IdFTP1.Password := '641010';
    IdFTP1.Connect();
  except
    ;
  end;

  if IdFTP1.Connected then
  begin

      Panel2.Caption:='正在下载数据，请稍等...';
      Panel2.Visible:=true;
      application.ProcessMessages;
    try
      IdFTP1.Get('FJ\'+ Trim(fileName), sFieldName,true, false);
    except
      Panel2.Visible:=false;
      Application.MessageBox('客户图样文件不存在', '提示', MB_ICONWARNING);
      IdFTP1.Quit;
      Exit;
    end;
  end
  else
  begin
    Panel2.Visible:=false;
    Application.MessageBox('无法连接文件服务器', '提示', MB_ICONWARNING);
    IdFTP1.Quit;
    Exit;
  end;
  Panel2.Visible:=false;
   if IdFTP1.Connected then IdFTP1.Quit;
  ShellExecute(Handle, 'open',PChar(sFieldName),'', '', SW_SHOWNORMAL);
end;

procedure TfrmRCCKInPut.JCDanWeiBtnClick(Sender: TObject);
begin
  try
    frmGYSList:=TfrmGYSList.Create(Application);
    with frmGYSList do
    begin
      KHType.Text:='染厂';
      KHType.TxtCode:='染厂';
      if ShowModal=1 then
      begin
        Self.JCDanWei.Text:=Trim(frmGYSList.Order_Main.fieldbyname('KHName').AsString);
        Self.JCNo.Text:=Trim(frmGYSList.Order_Main.fieldbyname('KHNo').AsString);
      end;
    end;
  finally
    frmGYSList.Free;
  end;
end;

procedure TfrmRCCKInPut.RCGangNo1Change(Sender: TObject);
begin
  SDofilter(ADOQuery2,SGetFilters(Panel8,1,2));
  SCreateCDS20(ADOQuery2,ClientDataSet1);
  SInitCDSData20(ADOQuery2,ClientDataSet1);
end;

procedure TfrmRCCKInPut.HSFlagClick(Sender: TObject);
begin
  if HSFlag.Checked=true then
  begin
    if BHSFlag.Checked=true then
    BHSFlag.Checked:=false;
  end
  else
  begin
    if BHSFlag.Checked=false then
    BHSFlag.Checked:=true;
  end;
end;

procedure TfrmRCCKInPut.BHSFlagClick(Sender: TObject);
begin
  if BHSFlag.Checked=true then
  begin
    if HSFlag.Checked=true then
    HSFlag.Checked:=false;
  end
  else
  begin
    if HSFlag.Checked=false then
    HSFlag.Checked:=true;
  end;
end;

procedure TfrmRCCKInPut.PSChaEChange(Sender: TObject);
begin
  if StrToFloatDef(PSChaE.Text,0)>0 then
  begin
    PSChaE.Font.Color:=clGreen;
  end;
  if StrToFloatDef(PSChaE.Text,0)<0 then
  begin
    PSChaE.Font.Color:=clRed;
  end;
end;

procedure TfrmRCCKInPut.QtyChaEChange(Sender: TObject);
begin
  if StrToFloatDef(QtyChaE.Text,0)>0 then
  begin
    QtyChaE.Font.Color:=clGreen;
  end;
  if StrToFloatDef(QtyChaE.Text,0)<0 then
  begin
    QtyChaE.Font.Color:=clRed;
  end;
end;

procedure TfrmRCCKInPut.KgQtyChaEChange(Sender: TObject);
begin
  if StrToFloatDef(KgQtyChaE.Text,0)>0 then
  begin
    KgQtyChaE.Font.Color:=clGreen;
  end;
  if StrToFloatDef(KgQtyChaE.Text,0)<0 then
  begin
    KgQtyChaE.Font.Color:=clRed;
  end;
end;

procedure TfrmRCCKInPut.Button4Click(Sender: TObject);
var FDate:TDateTime;
    SXMaxno:string;
begin
  frmMLMangeRS_CX:=TfrmMLMangeRS_CX.create(self);
  with frmMLMangeRS_CX do
  begin
    if showmodal=1 then
    begin
      Self.MYCode.Text:=Trim(CDS_Main.fieldbyname('MLNo').AsString);
      Self.MYCode.Hint:=Trim(CDS_Main.fieldbyname('MLNo').AsString);
      Self.MYName.Text:=Trim(CDS_Main.fieldbyname('MLName').AsString);
      Self.MYMF.Text:=Trim(CDS_Main.fieldbyname('MLMF').AsString);
      Self.MYKZ.Text:=Trim(CDS_Main.fieldbyname('MLKZ').AsString);
      Self.MYColor.Text:=Trim(CDS_Main.fieldbyname('ColNamekh').AsString);
      Self.MYColorNo.Text:=Trim(CDS_Main.fieldbyname('ColNo').AsString);
      Self.PTID.Text:=Trim(CDS_Main.fieldbyname('PTID').AsString);
      Self.GYLXName.Text:=Trim(CDS_Main.fieldbyname('GYLXName').AsString);
      FDate:=SGetServerDate(ADOTemp);
      InitColor();
    end;
    free;
  end;
end;

procedure TfrmRCCKInPut.Panel18DblClick(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 TfrmRCCKInPut.Button6Click(Sender: TObject);
var FDate:TDateTime;
    SXMaxno:string;
begin
  frmMLMangeRS_GYCX:=TfrmMLMangeRS_GYCX.create(self);
  with frmMLMangeRS_GYCX do
  begin
    MLNo.Text:=Trim(MYCode.Text);
    if showmodal=1 then
    begin
      Self.MYCode.Text:=Trim(CDS_Main.fieldbyname('MLNo').AsString);
      Self.MYCode.Hint:=Trim(CDS_Main.fieldbyname('MLNo').AsString);
      Self.MYName.Text:=Trim(CDS_Main.fieldbyname('MLName').AsString);
      Self.MYMF.Text:=Trim(CDS_Main.fieldbyname('MLMF').AsString);
      Self.MYKZ.Text:=Trim(CDS_Main.fieldbyname('MLKZ').AsString);
      Self.GYLXName.Text:=Trim(CDS_Main.fieldbyname('GYLXName').AsString);
    end;
    free;
  end;
end;

end.
