unit U_QryBSPrtDyeejInEdit;

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,
  cxCurrencyEdit, cxGridCustomPopupMenu, cxGridPopupMenu, cxDropDownEdit,
  RM_Common, RM_Preview, RM_System, RM_Class, RM_GridReport, RM_Dataset, Menus,
  cxSplitter, cxLookAndFeels, cxLookAndFeelPainters, cxNavigator, cxCheckBox,
   dxDateRanges, dxBarBuiltInMenu, cxPC,
  System.ImageList, Vcl.ImgList, U_BaseInput, cxImage, cxDBEdit,
  IdBaseComponent,
  IdComponent, IdTCPConnection, IdTCPClient, IdExplicitTLSClientServerBase,
  IdFTP, ShellAPI,  dxScrollbarAnnotations, cxGeometry,
  dxFramedControl, dxLayoutContainer, dxLayoutControl, dxPanel, cxGroupBox,
  dxLayoutcxEditAdapters, dxCore, cxDateUtils, cxImageList, dxSkinsCore,
  dxSkinsDefaultPainters, cxSpinEdit, dxLayoutControlAdapters, dxSkinWXI;

type
  TfrmQryBSPrtDyeejInEdit = class(TfrmBaseInput)
    ToolBar1: TToolBar;
    TBSave: TToolButton;
    TBClose: TToolButton;
    ADOTemp: TADOQuery;
    ADOCmd: TADOQuery;
    DS_1: TDataSource;
    CDS_1: TClientDataSet;
    GPM_1: TcxGridPopupMenu;
    Label51: TLabel;
    cxgrdpmn2: TcxGridPopupMenu;
    Qry_ImgHX: TADOQuery;
    DS_ImgHX: TDataSource;
    Tbcgs: TToolButton;
    IdFTP1: TIdFTP;
    dxPanel1: TdxPanel;
    dxLayoutControl_bzplan: TdxLayoutControl;
    dxLayoutControl_bzplanGroup_Root: TdxLayoutGroup;
    Tsj: TToolButton;
    ZIONO: TcxTextEdit;
    dxLayoutItem1: TdxLayoutItem;
    FromCoName: TcxButtonEdit;
    dxLayoutItem4: TdxLayoutItem;
    TBAdd: TToolButton;
    TBDel: TToolButton;
    FromCono: TcxButtonEdit;
    dxLayoutItem5: TdxLayoutItem;
    IOType: TcxComboBox;
    dxLayoutItem6: TdxLayoutItem;
    cxGrid1: TcxGrid;
    Tv1: TcxGridDBTableView;
    v1Column6: TcxGridDBColumn;
    v1Column2: TcxGridDBColumn;
    v1FactoryName: TcxGridDBColumn;
    Tv1Column1: TcxGridDBColumn;
    Tv1Column2: TcxGridDBColumn;
    v1SPName: TcxGridDBColumn;
    v1SPSpec: TcxGridDBColumn;
    v1Column1: TcxGridDBColumn;
    v2Column6: TcxGridDBColumn;
    v1QtyUnit: TcxGridDBColumn;
    v1Column5: TcxGridDBColumn;
    v1Column12: TcxGridDBColumn;
    cxGrid1Level1: TcxGridLevel;
    procedure TBCloseClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure TBSaveClick(Sender: TObject);
    procedure ToolButton2Click(Sender: TObject);
    procedure TcxButtonEditSel(Sender: TObject;
  AButtonIndex: Integer);
    procedure TcxButtonEditDel(Sender: TObject);
    procedure TbcgsClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure ToolButton3Click(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure TsjClick(Sender: TObject);
    procedure Tv1Column1PropertiesButtonClick(Sender: TObject;
      AButtonIndex: Integer);
    procedure Tv1Column2PropertiesButtonClick(Sender: TObject;
      AButtonIndex: Integer);
    procedure Tv1Column3PropertiesEditValueChanged(Sender: TObject);
    procedure Tv1Column6PropertiesEditValueChanged(Sender: TObject);
    procedure v1Column5PropertiesButtonClick(Sender: TObject;
      AButtonIndex: Integer);
    procedure v1FactoryNamePropertiesButtonClick(Sender: TObject;
      AButtonIndex: Integer);
    procedure TBAddClick(Sender: TObject);
    procedure TBDelClick(Sender: TObject);
    procedure FromCoNamePropertiesButtonClick(Sender: TObject;
      AButtonIndex: Integer);
  private
    function SaveData(): Boolean;
    { Private declarations }
  public
    FBCId, canshu3, FSTKName, FKHName: string;

    { Public declarations }
  end;

var
  frmQryBSPrtDyeejInEdit: TfrmQryBSPrtDyeejInEdit;
  newh: hwnd;

implementation

uses
  U_DataLink, U_RTFun, U_CompanySel, U_ZDYHelp,
  U_cxGridCustomSet, U_FormLayOutDesign, U_globalVar, U_ProductInfoSel;


{$R *.dfm}


procedure TfrmQryBSPrtDyeejInEdit.TBCloseClick(Sender: TObject);
begin

  close;

end;

procedure TfrmQryBSPrtDyeejInEdit.TBDelClick(Sender: TObject);
begin
  if CDS_1.IsEmpty then
    Exit;
  if Trim(CDS_1.fieldbyname('BPIOID').AsString) <> '' then
  begin
    if Application.MessageBox('确定要删除数据吗？', '提示', 32 + 4) <> IDYES then
      Exit;
    with ADOTemp do
    begin
      Close;
      sql.Clear;
      sql.Add('exec P_Fin_Flow_Judge ');
      Sql.Add(' @FFIDS=' + quotedstr(Trim(CDS_1.fieldbyname('BPIOID').AsString)));
      Sql.Add(',@DCode=' + quotedstr(Trim(DCode)));
      Sql.Add(',@DName=' + quotedstr(Trim(DName)));
      Open;
    end;
    if ADOTemp.FieldByName('intReturn').AsInteger = -1 then
    begin
      Application.MessageBox(PChar(ADOTemp.fieldbyname('ShowMsg').AsString), '提示', 0);
      exit;
    end;
    try
      ADOCmd.Connection.BeginTrans;
      with ADOCmd do
      begin
        Close;
        sql.Clear;
        sql.Add('insert into Finance_Need_Up(UType,UDataId,UOperation,UOperator,UModule,UDetails)       ');
        sql.Add('values(''二级仓入库''    ');
        sql.Add(',' + quotedstr(CDS_1.fieldbyname('BPIOID').AsString));
        sql.Add(',''撤销入库''   ');
        sql.Add(',' + quotedstr(DName));
        sql.Add(',' + quotedstr(trim(self.Caption)));
        sql.Add(',' + quotedstr(CDS_1.fieldbyname('BPIOID').AsString));
        sql.Add(')  ');
        execsql;
      end;
      with ADOCmd do
      begin
        Close;
        Sql.Clear;
        Sql.Add('exec P_BS_Product_In_Del ');
        Sql.Add(' @BPIOIDS=' + quotedstr(Trim(CDS_1.fieldbyname('BPIOID').AsString)));
        Sql.Add(',@DCode=' + quotedstr(Trim(DCode)));
        Sql.Add(',@DName=' + quotedstr(Trim(DName)));
        Open;
      end;
      if ADOCmd.FieldByName('intReturn').AsInteger = -1 then
        raise Exception.Create(pchar(trim(ADOCmd.FieldByName('ShowMsg').AsString)));
      ADOCmd.Connection.CommitTrans;
      CDS_1.Delete;
    except
      ADOCmd.Connection.RollbackTrans;
      application.MessageBox(PChar(Exception(ExceptObject).Message), '提示信息', 0);
    end;
  end
  else
  begin
    CDS_1.Delete;
  end;

end;
procedure TfrmQryBSPrtDyeejInEdit.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  Action := cahide;
end;

procedure TfrmQryBSPrtDyeejInEdit.FormCreate(Sender: TObject);
begin
   inherited;
   cxGrid1.Align := alClient;
end;

procedure TfrmQryBSPrtDyeejInEdit.FormDestroy(Sender: TObject);
begin
  inherited;
  frmQryBSPrtDyeejInEdit:=nil;
end;

procedure TfrmQryBSPrtDyeejInEdit.FormShow(Sender: TObject);
var
  fsj, maxId: string;
begin
  inherited;
  ReadCxGrid(FSTKName + '入库登记', Tv1, '机物料仓库');
  with ADOTemp do
  begin
    Close;
    sql.Clear;
    sql.Add(' select A.* ');
    sql.Add(' from BS_Product_IO A');
    sql.Add(' where BPIOID=''' + Trim(FBCId) + '''');
    Open;
  end;
  SCreateCDS(ADOTemp, CDS_1);
  SInitCDSData(ADOTemp, CDS_1);
  if ADOTemp.FieldByName('ZIONO').AsString = '' then
  begin
    if GetLSNo(ADOCmd, maxId, 'RI', 'BS_Product_IO', 3, 1) = False then
    begin
      Application.MessageBox('取最大号失败!', '提示', 0);
      Exit;
    end;
    ZIONO.Text := maxId;
  end
  else
  begin
    ZIONO.Text := ADOTemp.FieldByName('ZIONO').AsString;
    IOType.ItemIndex := IOType.Properties.Items.IndexOf(trim(ADOTemp.fieldbyname('IOType').AsString));
    FromCoName.Text := ADOTemp.FieldByName('FromCoName').AsString;
    FromCono.Text := ADOTemp.FieldByName('FromCono').AsString;
  end;

end;





procedure TfrmQryBSPrtDyeejInEdit.FromCoNamePropertiesButtonClick(Sender: TObject;
  AButtonIndex: Integer);
begin
  inherited;
  try
    frmCompanySel := TfrmCompanySel.Create(Application);
    with frmCompanySel do
    begin
      FCoType := '供应商';
      if ShowModal = 1 then
      begin
        FromCoNo.Text := Trim(CDS_1.fieldbyname('CoCode').AsString);
        FromCoName.Text := Trim(CDS_1.fieldbyname('CoAbbrName').AsString);
      end;
    end;
  finally
    frmCompanySel.Free;
  end;
end;

function TfrmQryBSPrtDyeejInEdit.SaveData(): Boolean;
var
  Maxno, MBPIOID: string;
  fprice: double;
begin
  try
    ADOCmd.Connection.BeginTrans;
    CDS_1.DisableControls;
    with CDS_1 do
    begin
      First;
      while not eof do
      begin
        with ADOTemp do
        begin
          Close;
          sql.Clear;
          sql.Add('select * from BS_Product_IO where BPIOID=''' + Trim(CDS_1.fieldbyname('BPIOID').AsString) + '''');
          open;
        end;
        MBPIOID := Trim(ADOTemp.fieldbyname('BPIOID').AsString);
        if Trim(MBPIOID) = '' then
        begin
          if not GetLSNo(ADOCmd, Maxno, 'PR', 'BS_Product_IO', 3, 1) then
            raise Exception.Create('取入库编号失败！');
        end
        else
        begin
          Maxno := Trim(MBPIOID);
        end;
        with ADOCmd do
        begin
          Close;
          sql.Clear;
          sql.Add('select * from BS_Product_IO where BPIOID=''' + Trim(Maxno) + '''');
          Open;
        end;
        with ADOCmd do
        begin
          if Trim(MBPIOID) = '' then
          begin
            Append;
            FieldByName('Fillid').Value := Trim(Dcode);
            FieldByName('Filler').Value := Trim(DName);
          end
          else
          begin
            Edit;
            FieldByName('Editid').Value := Trim(Dcode);
            FieldByName('Editer').Value := Trim(DName);
            FieldByName('EditTime').Value := SGetServerDate(ADOTemp);
          end;
          RTSetSaveDataCDS(ADOCmd, Tv1, CDS_1, 'BS_Product_IO', 0);
          FieldByName('iotype').Value := Trim(iotype.Text);
          FieldByName('FromCoNo').Value := Trim(FromCoNo.Text);
          FieldByName('FromConame').Value := Trim(FromConame.Text);

          FieldByName('StkCoNo').Value := CDS_1.fieldbyname('StkCoNo').Value;
          FieldByName('BPIOID').Value := Trim(Maxno);
          FieldByName('STKID').Value := Trim(Maxno);
          FieldByName('ZIONO').Value := Trim(ZIONO.Text);
          FieldByName('STKName').Value := FSTKName;
          FieldByName('IOFlag').Value := '入库';
          FieldByName('IOQtyFlag').Value := 1;
          Post;
        end;
        with ADOCmd do
        begin
          Close;
          sql.Clear;
          sql.Add('Update BS_Product_IO Set  StkQty=(select Sum(isnull(Qty,0)*IOQtyFlag) from BS_Product_IO A where A.STKID=BS_Product_IO.BPIOID )');
          sql.Add(' where BPIOID=''' + Trim(Maxno) + '''');
          ExecSQL;
        end;
        with ADOTemp do
        begin
          Close;
          sql.Clear;
          sql.Add('select stkQty   from BS_Product_IO where BPIOID=''' + Trim(Maxno) + '''');
          Open;
        end;
        if ADOTemp.FieldByName('stkQty').Value < 0 then
          raise Exception.Create('入库数量小于出库数量不能保存!');

        fprice := strtofloatdef(CDS_1.fieldbyname('price').AsString, 0);
        with ADOCmd do
        begin
          Close;
          sql.Clear;
          sql.Add('insert into Finance_Need_Up(UType,UDataId,UOperation,UOperator,UModule,UDetails)       ');
          sql.Add('values(''染化料入库''    ');
          sql.Add(',' + quotedstr(Maxno));
          sql.Add(',''入库''   ');
          sql.Add(',' + quotedstr(DName));
          sql.Add(',' + quotedstr(trim(self.Caption)));
          sql.Add(',' + quotedstr(Maxno));
          sql.Add(')  ');
          execsql;
        end;
        with ADOCmd do
        begin
          Close;
          sql.Clear;
          sql.Add('Update BS_Product_Info Set  Price=' + FloatToStr(fprice));
          sql.Add(' where P_Code=''' + Trim(CDS_1.fieldbyname('P_Code').AsString) + '''');
          sql.Add('and stkname=''染化料''');
          sql.Add('insert into SY_SysLog(operor,opertime,Model,acction,opevent,result) values( ');
          sql.Add(' ' + quotedstr(trim(DName)));
          sql.Add(',getdate() ');
          sql.Add(',' + quotedstr(trim(self.Caption)));
          sql.Add(',' + quotedstr(trim('染化料单价修改')));
          sql.Add(',' + quotedstr(trim('编号：' + trim(CDS_1.FieldByName('P_Code').AsString) + '改为' + trim(FloatToStr(fprice)))));
          sql.Add(',' + quotedstr(trim('成功')));
          sql.Add(')');
          ExecSQL;
        end;
        Edit;
        FieldByName('BPIOID').Value := Trim(Maxno);
        Post;
        Next;
      end;
    end;

    CDS_1.EnableControls;
    ADOCmd.Connection.CommitTrans;

    Result := True;
  except
    Result := False;
    ADOCmd.Connection.RollbackTrans;
    application.MessageBox(PChar(Exception(ExceptObject).Message), '提示信息', 0);
  end;

end;

procedure TfrmQryBSPrtDyeejInEdit.TBSaveClick(Sender: TObject);
begin
  if CDS_1.IsEmpty then
    Exit;
  if CDS_1.Locate('IOType', null, []) = True then
  begin
    Application.MessageBox('入库类型不能为空!', '提示', 0);
    Exit;
  end;
  if CDS_1.Locate('P_Name', null, []) = True then
  begin
    Application.MessageBox('品名不能为空!', '提示', 0);
    Exit;
  end;

  if CDS_1.Locate('Qty', null, []) = True then
  begin
    Application.MessageBox('数量不能为空!', '提示', 0);
    Exit;
  end;
  if CDS_1.Locate('QtyUnit', null, []) = True then
  begin
    Application.MessageBox('数量单位不能为空!', '提示', 0);
    Exit;
  end;

  if SaveData() then
  begin
    Application.MessageBox('保存成功!', '提示', 0);
    ModalResult := 1;
    Exit;
  end;
end;

procedure TfrmQryBSPrtDyeejInEdit.ToolButton2Click(Sender: TObject);
begin
  if CDS_1.IsEmpty then
    exit;
  if CDS_1.Locate('SSel', True, []) = false then
  begin
    Application.MessageBox('没有选择数据!', '提示', 0);
    exit;
  end;
  if Application.MessageBox('确定要删除选择的数据吗？', '提示', 32 + 4) <> IDYES then
    exit;
  try
  CDS_1.DisableControls;
  with CDS_1 do
  begin
    First;
    while Locate('SSel', True, []) do
    begin
      if trim(CDS_1.fieldbyname('McId').AsString) <> '' then
      begin
        with ADOCmd do
        begin
          close;
          sql.Clear;
          sql.Add('delete bs_arrange_line_machine where mcid=''' +
            trim(CDS_1.fieldbyname('mcid').AsString) + '''');
          execsql;
        end;
      end;
      Delete;
    end;
  end;
  finally
    CDS_1.EnableControls;
  end;
end;

procedure TfrmQryBSPrtDyeejInEdit.ToolButton3Click(Sender: TObject);
begin
  inherited;
  ToolBar1.SetFocus;
  if CDS_1.IsEmpty then
    Exit;
  OneKeyPost(Tv1, CDS_1);
end;


procedure TfrmQryBSPrtDyeejInEdit.TBAddClick(Sender: TObject);
begin

  try
    frmProductInfoSel := TfrmProductInfoSel.Create(Application);
    with frmProductInfoSel do
    begin
      FSTKName := '染化料';
      if ShowModal = 1 then
      begin
        with Self.CDS_1 do
        begin
          Append;
          FieldByName('IOTime').Value := Trim(FormatDateTime('yyyy-MM-dd', Now));
          FieldByName('StkCoNo').Value := '本厂仓库';
          FieldByName('StkCoName').Value := '本厂仓库';
          FieldByName('IOType').Value := '采购入库';
          FieldByName('shuilv').Value := 13;
          FieldByName('P_Code').Value := frmProductInfoSel.CDS_1.fieldbyname('C_SCCODE').value;
          FieldByName('P_Name').Value := frmProductInfoSel.CDS_1.fieldbyname('P_Name').value;
          FieldByName('P_Spec').Value := frmProductInfoSel.CDS_1.fieldbyname('P_Spec').value;
          FieldByName('QtyUnit').Value := frmProductInfoSel.CDS_1.fieldbyname('QtyUnit').value;
          FieldByName('Price').Value := frmProductInfoSel.CDS_1.fieldbyname('Price').value;
        end;
      end;
    end;
  finally
    frmProductInfoSel.Free;
  end;
end;

procedure TfrmQryBSPrtDyeejInEdit.TbcgsClick(Sender: TObject);
begin
  WriteCxGrid(trim(SELF.Caption) + '-录入窗口', Tv1, gDllFileCaption);

end;

procedure TfrmQryBSPrtDyeejInEdit.TsjClick(Sender: TObject);
begin
  saveLayOut(application,dxLayoutControl_bzplan, ADOQueryBaseCmd,
  PWideChar( fDllFileName + '|' + SELF.Name + '|' + dxLayoutControl_bzplan.Name+ '.ini'));
end;

procedure TfrmQryBSPrtDyeejInEdit.Tv1Column1PropertiesButtonClick(Sender: TObject;
  AButtonIndex: Integer);
begin
  try
    frmCompanySel := TfrmCompanySel.Create(Application);
    with frmCompanySel do
    begin
      FCoType := '客户';
      if ShowModal = 1 then
      begin
        with Self.CDS_1 do
        begin
          Edit;
          FieldByName('StkCoNo').Value := Trim(CDS_1.fieldbyname('CoCode').AsString);
          FieldByName('StkCoName').Value := Trim(CDS_1.fieldbyname('CoAbbrName').AsString);
        end;
      end;
    end;
  finally
    frmCompanySel.Free;
  end;

end;

procedure TfrmQryBSPrtDyeejInEdit.Tv1Column2PropertiesButtonClick(Sender: TObject;
  AButtonIndex: Integer);
begin
  try
    frmProductInfoSel := TfrmProductInfoSel.Create(Application);
    with frmProductInfoSel do
    begin
      FSTKName := Self.FSTKName;
      if ShowModal = 1 then
      begin
        with Self.CDS_1 do
        begin
          Edit;
          FieldByName('P_Code').Value := frmProductInfoSel.CDS_1.fieldbyname('P_Code').value;
          FieldByName('P_Name').Value := frmProductInfoSel.CDS_1.fieldbyname('P_Name').value;
          FieldByName('P_Spec').Value := frmProductInfoSel.CDS_1.fieldbyname('P_Spec').value;
          FieldByName('QtyUnit').Value := frmProductInfoSel.CDS_1.fieldbyname('QtyUnit').value;
          FieldByName('Price').Value := frmProductInfoSel.CDS_1.fieldbyname('Price').value;
        end;
      end;
    end;
  finally
    frmProductInfoSel.Free;
  end;
end;

procedure TfrmQryBSPrtDyeejInEdit.Tv1Column3PropertiesEditValueChanged(
  Sender: TObject);
var
  mvalue, FFieldName: string;
  FQty, FPrice, FMxMoney: double;
begin
  mvalue := TcxTextEdit(Sender).EditingText;
  FFieldName := Trim(Tv1.Controller.FocusedColumn.DataBinding.FilterFieldName);
  if Trim(mvalue) = '' then
  begin
    mvalue := '0';
  end;
  with CDS_1 do
  begin
    Edit;
    FieldByName(FFieldName).Value := Trim(mvalue);
    Post;
  end;
  with CDS_1 do
  begin
    Edit;
    FQty := FieldByName('Qty').AsFloat;
    FPrice := FieldByName('Price').AsFloat;
    Post;
  end;
  FMxMoney := ROUNDFLOAT(FQty * FPrice, 2);
  with CDS_1 do
  begin
    Edit;
    FieldByName(FFieldName).Value := Trim(mvalue);
    FieldbyName('sjMoney').Value := FMxMoney;
    Post;
  end;
  tv1.Controller.EditingController.ShowEdit();
end;

procedure TfrmQryBSPrtDyeejInEdit.Tv1Column6PropertiesEditValueChanged(
  Sender: TObject);
var
  mvalue, FFieldName: string;
  FQty, FPrice, FMxMoney: double;
begin
  mvalue := TcxTextEdit(Sender).EditingText;
  FFieldName := Trim(Tv1.Controller.FocusedColumn.DataBinding.FilterFieldName);
  if Trim(mvalue) = '' then
  begin
    mvalue := '0';
  end;
  with CDS_1 do
  begin
    Edit;
    FieldByName(FFieldName).Value := Trim(mvalue);
    Post;
  end;

  tv1.Controller.EditingController.ShowEdit();
end;

procedure TfrmQryBSPrtDyeejInEdit.v1Column5PropertiesButtonClick(Sender: TObject;
  AButtonIndex: Integer);
begin
  try
    frmZDYHelp := TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag := 'StkPosition';
      flagname := '库位';
      MainType := FSTKName;
      if ShowModal = 1 then
      begin
        with Self.CDS_1 do
        begin
          Edit;
          FieldByName('StkPosition').Value := Trim(frmZDYHelp.ClientDataSet1.fieldbyname('ZdyName').AsString);
        end;
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TfrmQryBSPrtDyeejInEdit.v1FactoryNamePropertiesButtonClick(
  Sender: TObject; AButtonIndex: Integer);
begin

  try
    frmCompanySel := TfrmCompanySel.Create(Application);
    with frmCompanySel do
    begin
      FCoType := '供应商';
      if ShowModal = 1 then
      begin
        with Self.CDS_1 do
        begin
          Edit;
          FieldByName('FromCoNo').Value := Trim(CDS_1.fieldbyname('CoCode').AsString);
          FieldByName('FromCoName').Value := Trim(CDS_1.fieldbyname('CoAbbrName').AsString);
        end;
      end;
    end;
  finally
    frmCompanySel.Free;
  end;

end;

procedure TfrmQryBSPrtDyeejInEdit.TcxButtonEditSel(Sender: TObject;
  AButtonIndex: Integer);
var
  fsj: string;
  FWZ: Integer;
begin
  fsj := trim(TcxButtonEdit(Sender).Hint);
  FWZ := Pos('/', fsj);
  try
    frmZDYHelp := TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag := Copy(fsj, 1, FWZ - 1);
      flagname := Copy(fsj, FWZ + 1, Length(fsj) - FWZ);
      if ShowModal = 1 then
      begin
        TcxButtonEdit(Sender).Text := trim(ClientDataSet1.fieldbyname('ZDYName')
          .AsString);
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

/// //////////////////////////////////
///
procedure TfrmQryBSPrtDyeejInEdit.TcxButtonEditDel(Sender: TObject);
begin
  TcxButtonEdit(Sender).Text := '';
  TcxButtonEdit(Sender).Properties.LookupItems.Text := '';
end;
end.
