unit U_ProductOrderLBNameSet11;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, ComCtrls, ToolWin, cxStyles, cxCustomData,
  cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, DB, cxDBData, ADODB,
  cxGridCustomPopupMenu, cxGridPopupMenu, cxGridLevel, cxClasses,
  cxControls, cxGridCustomView, cxGridCustomTableView, cxGridTableView,
  cxGridDBTableView, cxGrid, DBClient, cxCheckBox, cxCalendar, cxSplitter,
  RM_Dataset, RM_System, RM_Common, RM_Class, RM_GridReport, RM_e_Xls,StrUtils,
  Menus, cxTextEdit, cxDropDownEdit, cxButtonEdit;

type
  TfrmProductOrderLBNameSet11 = class(TForm)
    ToolBar1: TToolBar;
    TBRafresh: TToolButton;
    TBFind: TToolButton;
    TBPrint: TToolButton;
    TBClose: TToolButton;
    Panel1: TPanel;
    BegDate: TDateTimePicker;
    EndDate: TDateTimePicker;
    Label1: TLabel;
    Tv1: TcxGridDBTableView;
    cxGrid1Level1: TcxGridLevel;
    cxGrid1: TcxGrid;
    cxGridPopupMenu1: TcxGridPopupMenu;
    ADOQueryCmd: TADOQuery;
    ADOQueryMain: TADOQuery;
    ADOQueryTemp: TADOQuery;
    DataSource1: TDataSource;
    v1OrdDate: TcxGridDBColumn;
    v1DeliveryDate: TcxGridDBColumn;
    v1ConNo: TcxGridDBColumn;
    Order_Main: TClientDataSet;
    RM1: TRMGridReport;
    RMDBMain: TRMDBDataSet;
    RMXLSExport1: TRMXLSExport;
    v1CustomerNoName: TcxGridDBColumn;
    Label4: TLabel;
    CustomerNoName: TEdit;
    PopupMenu1: TPopupMenu;
    N2: TMenuItem;
    ToolButton1: TToolButton;
    Label9: TLabel;
    ConNo: TEdit;
    ADOQueryPrint: TADOQuery;
    CDS_Print: TClientDataSet;
    v1Column4: TcxGridDBColumn;
    Panel4: TPanel;
    Label14: TLabel;
    Panel10: TPanel;
    Image2: TImage;
    Button1: TButton;
    RadioGroup1: TRadioGroup;
    ToolButton2: TToolButton;
    ToolButton3: TToolButton;
    PiZhong: TEdit;
    ToolButton4: TToolButton;
    ToolButton5: TToolButton;
    v1khconNo: TcxGridDBColumn;
    v1SYRName: TcxGridDBColumn;
    Label2: TLabel;
    Label5: TLabel;
    KHconNo: TEdit;
    styleno: TEdit;
    v1FromPlace: TcxGridDBColumn;
    v1ConPerson1: TcxGridDBColumn;
    v1DlyNote: TcxGridDBColumn;
    TSel: TToolButton;
    v1PrtCodeName: TcxGridDBColumn;
    v1styleno: TcxGridDBColumn;
    v1SOrdDefStr4: TcxGridDBColumn;
    v1PRTColorNo: TcxGridDBColumn;
    v1PRTHX: TcxGridDBColumn;
    v1PRTMF: TcxGridDBColumn;
    v1PRTKZ: TcxGridDBColumn;
    v1PRTColor: TcxGridDBColumn;
    procedure FormDestroy(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormCreate(Sender: TObject);
    procedure TBCloseClick(Sender: TObject);
    procedure TBFindClick(Sender: TObject);
    procedure TBPrintClick(Sender: TObject);
    procedure TBRafreshClick(Sender: TObject);
    procedure OrderNoMChange(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure Tv1CellDblClick(Sender: TcxCustomGridTableView;
      ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
      AShift: TShiftState; var AHandled: Boolean);
    procedure CheckBox1Click(Sender: TObject);
    procedure CheckBox2Click(Sender: TObject);
    procedure Tv1StylesGetContentStyle(Sender: TcxCustomGridTableView;
      ARecord: TcxCustomGridRecord; AItem: TcxCustomGridTableItem;
      out AStyle: TcxStyle);
    procedure v1DeliveryDateCustomDrawCell(Sender: TcxCustomGridTableView;
      ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo;
      var ADone: Boolean);
    procedure ToolButton1Click(Sender: TObject);
    procedure OrderNoMKeyPress(Sender: TObject; var Key: Char);
    procedure ConNoKeyPress(Sender: TObject; var Key: Char);
    procedure Panel10MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure Button1Click(Sender: TObject);
    procedure Image2Click(Sender: TObject);
    procedure ToolButton2Click(Sender: TObject);
    procedure ToolButton3Click(Sender: TObject);
    procedure ToolButton4Click(Sender: TObject);
    procedure v1Column3PropertiesEditValueChanged(Sender: TObject);
    procedure v1Column1PropertiesEditValueChanged(Sender: TObject);
    procedure v1Column6PropertiesEditValueChanged(Sender: TObject);
    procedure v1Column6PropertiesButtonClick(Sender: TObject;
      AButtonIndex: Integer);
    procedure v1LengUnitPropertiesEditValueChanged(Sender: TObject);
    procedure TSelClick(Sender: TObject);
  private
    DQdate:TDateTime;
    procedure InitGrid();
    procedure InitForm();

    { Private declarations }
  public
    FFInt,FCloth:Integer;
    Canshu1:string;
    { Public declarations }
  end;

var
  frmProductOrderLBNameSet11: TfrmProductOrderLBNameSet11;
  newh:hwnd;
implementation
uses
  U_DataLink,U_OrderInPut,U_RTFun, U_OrderInPutPrice, U_ZDYHelp;

{$R *.dfm}

procedure TfrmProductOrderLBNameSet11.FormDestroy(Sender: TObject);
begin
  frmProductOrderLBNameSet11:=nil;
end;

procedure TfrmProductOrderLBNameSet11.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  Action:=caFree;
end;

procedure TfrmProductOrderLBNameSet11.FormCreate(Sender: TObject);
begin
  cxgrid1.Align:=alClient;
  //BegDate.DateTime:=SGetServerDateTime(ADOQueryTemp)-7;
  //EndDate.DateTime:=SGetServerDateTime(ADOQueryTemp);
  DQdate:=SGetServerDate(ADOQueryTemp);
end;

procedure TfrmProductOrderLBNameSet11.TBCloseClick(Sender: TObject);
begin
  Close;
  WriteCxGrid('标签设置3',Tv1,'生产指示单管理');
end;

procedure TfrmProductOrderLBNameSet11.InitGrid();
begin
  try
    ADOQueryMain.DisableControls;
    with ADOQueryMain do
    begin
      Close;
      sql.Clear;
      sql.add('select A.*,B.* from JYorderCon_Main A ');
      sql.add('inner join JYorderCon_Sub B on B.Mainid=A.Mainid ');
      SQL.Add('where A.OrdDate>='''+FormatDateTime('yyyy-MM-dd',BegDate.DateTime)+''' ');
      SQL.Add(' and A.OrdDate<'''+FormatDateTime('yyyy-MM-dd',enddate.DateTime+1)+''' ');
      if Trim(canshu1)<>'高权限'  then
      begin
        sql.Add('and (A.KeFu='''+Trim(DName)+'''');
        sql.Add(' or A.ConPerson1='''+Trim(DName)+''')');
      end;
      Open;
    end;
    SCreateCDS20(ADOQueryMain,Order_Main);
    SInitCDSData20(ADOQueryMain,Order_Main);
  finally
    ADOQueryMain.EnableControls;
  end;
end;

procedure TfrmProductOrderLBNameSet11.InitForm();
begin
  ReadCxGrid('标签设置3',Tv1,'生产指示单管理');
  BegDate.DateTime:=SGetServerDate10(ADOQueryTemp)-7;
  EndDate.DateTime:=SGetServerDate10(ADOQueryTemp);
  canShu1:=trim(DParameters1);
end;

procedure TfrmProductOrderLBNameSet11.TBFindClick(Sender: TObject);
begin
  if ADOQueryMain.Active=False then Exit;
  SDofilter(ADOQueryMain,SGetFilters(Panel1,1,2));
  SCreateCDS20(ADOQueryMain,Order_Main);
  SInitCDSData20(ADOQueryMain,Order_Main);
end;
procedure TfrmProductOrderLBNameSet11.TBPrintClick(Sender: TObject);
begin
  Panel4.Visible:=True;
end;

procedure TfrmProductOrderLBNameSet11.TBRafreshClick(Sender: TObject);
begin
  InitGrid();
end;

procedure TfrmProductOrderLBNameSet11.OrderNoMChange(Sender: TObject);
begin
  if ADOQueryMain.Active=False then Exit;
  SDofilter(ADOQueryMain,SGetFilters(Panel1,1,2));
  SCreateCDS20(ADOQueryMain,Order_Main);
  SInitCDSData20(ADOQueryMain,Order_Main);
end;

procedure TfrmProductOrderLBNameSet11.FormShow(Sender: TObject);
begin
  InitForm();
end;

procedure TfrmProductOrderLBNameSet11.Tv1CellDblClick(
  Sender: TcxCustomGridTableView;
  ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
  AShift: TShiftState; var AHandled: Boolean);
begin
  //if ToolButton1.Visible=False then Exit;
  //ToolButton1.Click;
  Tsel.click;
end;

procedure TfrmProductOrderLBNameSet11.CheckBox1Click(Sender: TObject);
begin
  InitGrid();
end;

procedure TfrmProductOrderLBNameSet11.CheckBox2Click(Sender: TObject);
begin
  TBRafresh.Click;
end;

procedure TfrmProductOrderLBNameSet11.Tv1StylesGetContentStyle(
  Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord;
  AItem: TcxCustomGridTableItem; out AStyle: TcxStyle);
var
  id,id10:Integer;
begin
  {try
    if Tv1.GroupedItemCount=0 then
    begin
      Id:=Tv1.GetColumnByFieldName('DeliveryDate').Index-tv1.GroupedItemCount;
      Id10:=Tv1.GetColumnByFieldName('SubStatus').Index-tv1.GroupedItemCount;
      if Trim(VarToStr(ARecord.Values[id]))='' then Exit;
      if Id<0 then Exit;
      if ARecord.Values[id10]='完成' then exit;
      if (ARecord.Values[id]-DQdate)>=4 then Exit;
      if ((ARecord.Values[id]-DQdate)>=0) and ((ARecord.Values[id]-DQdate)<4) then
        AStyle:=DataLink_.QHuangSe
      else
      if ARecord.Values[id]-DQdate<0 then
      begin
        AStyle:=DataLink_OrderManage.FenHongS;
      end;
    end else
    begin

    end;
  except
  end; }
end;

procedure TfrmProductOrderLBNameSet11.v1DeliveryDateCustomDrawCell(
  Sender: TcxCustomGridTableView; ACanvas: TcxCanvas;
  AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
begin
 { Id:=TV1.GetColumnByFieldName('DeliveryDate').Index;//;-TV1.GroupedItemCount;
  Id10:=TV1.GetColumnByFieldName('SubStatus').Index;
  if Id<0 then Exit;
  if AViewInfo.GridRecord.Values[Id10]='完成' then Exit;
  if AViewInfo.GridRecord.Values[Id]-SGetServerDate(ADOQueryTemp)>=4 then Exit;
  if ((AViewInfo.GridRecord.Values[id]-SGetServerDate10(ADOQueryTemp))>=0) and ((AViewInfo.GridRecord.Values[id]-SGetServerDate(ADOQueryTemp))<4) then
    ACanvas.Brush.Color:=clYellow
  else
  if (AViewInfo.GridRecord.Values[id])-(SGetServerDate10(ADOQueryTemp)<0) then
  begin
    ACanvas.Brush.Color:=clRed;
  end;
  begin
    ACanvas.Brush.Color:=clRed;
  end else
  if AViewInfo.GridRecord.Values[Id]='Purple' then
  begin
    ACanvas.Brush.Color:=clPurple;
  end else
  if AViewInfo.GridRecord.Values[Id]='Olive' then
  begin
    ACanvas.Brush.Color:=clOlive;
  end else
  if AViewInfo.GridRecord.Values[Id]='Teal' then
  begin
    ACanvas.Brush.Color:=clTeal;
  end else
  if AViewInfo.GridRecord.Values[Id]='Background' then
  begin
    ACanvas.Brush.Color:=clBackground;
  end;   }
end;

procedure TfrmProductOrderLBNameSet11.ToolButton1Click(Sender: TObject);
begin
  {if Order_Main.IsEmpty then Exit;
  try
    frmConInPutNX:=TfrmConInPutNX.Create(Application);
    with frmConInPutNX do
    begin
      PState:=1;
      FMainId:=Trim(Self.Order_Main.fieldbyname('MainId').AsString);
      ToolBar2.Visible:=False;
      TBSave.Visible:=False;
      Button1.Visible:=False;
      Button2.Visible:=False;
      if ShowModal=1 then
      begin

      end;
    end;
  finally
    frmConInPutNX.Free;
  end;}
end;

procedure TfrmProductOrderLBNameSet11.OrderNoMKeyPress(Sender: TObject;
  var Key: Char);
begin
  {if Key=#13 then
  begin
    if Length(OrderNoM.Text)<3 then Exit;
    try
      ADOQueryMain.DisableControls;
      with ADOQueryMain do
      begin
        Filtered:=False;
        Close;
        sql.Clear;
        sql.add('exec P_View_Order :begdate,:enddate,:WSql') ;
        begin
          Parameters.ParamByName('WSql').Value:=' and orderno like '''+'%'+Trim(OrderNoM.Text)+'%'+'''';
        end;
        Parameters.ParamByName('begdate').Value:='1899-01-01';
        Parameters.ParamByName('enddate').Value:='2050-01-01';
        ExecSQL;
        Open;
      end;
      SCreateCDS20(ADOQueryMain,Order_Main);
      SInitCDSData20(ADOQueryMain,Order_Main);
    finally
      ADOQueryMain.EnableControls;
    end;
  end;}
end;

procedure TfrmProductOrderLBNameSet11.ConNoKeyPress(Sender: TObject;
  var Key: Char);
begin
  if Key=#13 then
  begin
    if Length(conno.Text)<3 then Exit;
    try
      ADOQueryMain.DisableControls;
      with ADOQueryMain do
      begin
        Close;
        sql.Clear;
        sql.add('select A.*,B.* from JYorderCon_Main A ');
        sql.add('inner join JYorderCon_Sub B on B.Mainid=A.Mainid ');
        SQL.Add('where  A.ConNo like '''+'%'+trim(ConNo.Text)+'%'+'''');
        Open;
      end;
      SCreateCDS20(ADOQueryMain,Order_Main);
      SInitCDSData20(ADOQueryMain,Order_Main);
    finally
      ADOQueryMain.EnableControls;
    end;
  end;
end;

procedure TfrmProductOrderLBNameSet11.Panel10MouseMove(Sender: TObject;
  Shift: TShiftState; X, Y: Integer);
begin
  ReleaseCapture;
  TWinControl(Panel4).Perform(WM_SYSCOMMAND,$F012,0);
end;

procedure TfrmProductOrderLBNameSet11.Button1Click(Sender: TObject);
var
   fPrintFile:string;
   Porderno,LBName:string;
   i,j:Integer;
   OrderKg:Double;
begin
  if Order_Main.IsEmpty then Exit;
  LBName:=RadioGroup1.Items.Strings[RadioGroup1.ItemIndex];
  fPrintFile:= ExtractFilePath(Application.ExeName) + 'Report\'+Trim(LBName)+'.rmf' ;
  if RadioGroup1.ItemIndex=0 then
  begin
    with ADOQueryPrint do
    begin
      Close;
      sql.Clear;
      sql.Add('select A.*,B.*,ColorCount=(select isnull(Count(*),0) from JYOrder_Sub where MainId=A.MainId),  ');
      sql.add('ZQty=(select sum(PRTOrderQty) from JYOrder_Sub where MainId=A.MainId)');
      SQL.Add(', Case when B.OrderUnit=''M'' then Cast (dbo.F_Get_Order_MFKZ(A.MainId,''MF'') ');
      sql.Add(' *1.00/100*B.PRTOrderQty*dbo.F_Get_Order_MFKZ(A.MainId,''KZ'')/1000 as varchar(20))+''Kg'' ');
      SQL.Add(' when B.OrderUnit=''Y'' then Cast (dbo.F_Get_Order_MFKZ(A.MainId,''MF'')');
      sql.Add(' *1.00/100*B.PRTOrderQty*0.9144*dbo.F_Get_Order_MFKZ(A.MainId,''KZ'')/1000 as varchar(20))+''Kg'' ');
      sql.Add(' else '''' end as PRTOrderKgQtyStr ');
      sql.Add(' from JYOrder_Main A inner join JYOrder_Sub B on A.MainId=B.MainId ');
      sql.Add(' and A.MainId='''+Trim(Order_Main.fieldbyname('MainId').AsString)+'''');
      Open;
    end;

  end else
  begin
    with ADOQueryPrint do
    begin
      Close;
      sql.Clear;
      sql.Add('exec P_View_OrderSub :begdate,:enddate,:wsql  ');
      Parameters.ParamByName('WSql').Value:=' and A.MainId='''+Trim(Order_Main.fieldbyname('Mainid').AsString)+'''';
      Parameters.ParamByName('begdate').Value:='1899-01-01';
      Parameters.ParamByName('enddate').Value:='2050-01-01';
      Open;
    end;
    if Trim(ADOQueryPrint.FieldByName('PRTHX').AsString)<>'' then
    begin
      if Trim(LBName)='颜色样' then
      begin
        fPrintFile:= ExtractFilePath(Application.ExeName) + 'Report\颜色花型样.rmf' ;
      end;
    end;
  end;
  with ADOQueryTemp do
  begin
    Close;
    sql.Clear;
    sql.Add('select isnull(sum(PRTOrderKgQty),0) PRTOrderKgHZQty from(');
    sql.Add('select  ');
    SQL.Add(' Case when B.OrderUnit=''M'' then Cast(dbo.F_Get_Order_MFKZ(A.MainId,''MF'') ');
    sql.Add(' *1.00/100*B.PRTOrderQty*dbo.F_Get_Order_MFKZ(A.MainId,''KZ'')/1000 as decimal(18,2))');
    SQL.Add(' when B.OrderUnit=''Y'' then Cast(dbo.F_Get_Order_MFKZ(A.MainId,''MF'')');
    sql.Add(' *1.00/100*B.PRTOrderQty*0.9144*dbo.F_Get_Order_MFKZ(A.MainId,''KZ'')/1000 As decimal(18,2)) ');
    sql.Add(' else 0 end as PRTOrderKgQty');
    sql.Add(' from JYOrder_Main A inner join JYOrder_Sub B on A.MainId=B.MainId ');
    sql.Add(' and A.MainId='''+Trim(Order_Main.fieldbyname('MainId').AsString)+''')AA');
    Open;
  end;
  OrderKg:=ADOQueryTemp.fieldbyname('PRTOrderKgHZQty').Value;
  SCreateCDS20(ADOQueryPrint,CDS_Print);
  SInitCDSData20(ADOQueryPrint,CDS_Print);

  if FileExists(fPrintFile) then
  begin
    RM1.LoadFromFile(fPrintFile);
    if OrderKg>0 then
      RMVariables['OrderKg']:='/'+Trim(FloatToStr(OrderKg))+'Kg'
    else
      RMVariables['OrderKg']:='';
    RM1.ShowReport;
  end else
  begin
    Application.MessageBox(PChar('没有找'+ExtractFilePath(Application.ExeName)+'Report\'+Trim(LBName)+'.rmf'),'提示',0);
  end;
end;

procedure TfrmProductOrderLBNameSet11.Image2Click(Sender: TObject);
begin
  Panel4.Visible:=False;
end;

procedure TfrmProductOrderLBNameSet11.ToolButton2Click(Sender: TObject);
type
  TMyFunc = function(App:Tapplication; FormH:hwnd; FormID:integer;
                  Language: integer; WinStyle:integer;
                  GCode: Pchar; GName: Pchar; DataBase:Pchar;Title:PChar;
                  Parameters1:PChar;Parameters2:PChar;Parameters3:PChar;Parameters4:PChar;
                  Parameters5:PChar;Parameters6:PChar;Parameters7:PChar;Parameters8:PChar;
                  Parameters9:PChar;Parameters10:PChar;DataBaseStr:PChar):hwnd;stdcall;
var
  Tf: TMyFunc;
  Tp: TFarProc;
  Th:Thandle;
  LabInt,labname:String;
begin
  //if PPInt=2 then Exit;
  Ddatabase:=StringOfChar(' ', 32);
  Th := LoadLibrary('LabelSet.dll');
  if Th > 0 then
  begin
    try
      Tp := GetProcAddress(Th, 'GetDllForm');
      if Tp <> nil then
      begin
        Tf := TMyFunc(Tp);
        newh:=Tf(Application,0,2,0,0,
          PChar(DCode),
          PChar(DName),
          PChar(Ddatabase),
          PChar('标签模版设置'),
          PChar(''),
          PChar(''),
          '','','','','','','','',PChar(DConString)
          );
          if Trim(PChar(Ddatabase))<>'' then
          begin
            Ddatabase:=Trim(PChar(Ddatabase));
            LabInt:=Trim( LeftBStr(Ddatabase,Pos('|',Ddatabase)-1) ) ;
            labname:=Trim(RightBStr(Ddatabase,Length(Ddatabase)-Pos('|',Ddatabase) ) );
            with ADOQueryCmd do
            begin
              Close;
              sql.Clear;
              sql.Add('Update JYOrderCon_Main Set ConLBName='''+Trim(labname)+'''');
              sql.Add(' where Mainid='''+Trim(Order_Main.fieldbyname('Mainid').AsString)+'''');
              ExecSQL;
            end;
            with Order_Main do
            begin
              Edit;
              FieldByName('ConLbName').Value:=labname;
              Post;
            end;
          end;
      end
      else
      begin
        ShowMessage('打印执行错误');
      end;
    finally
    // FreeLibrary();
    end;
  end
  else
  begin
    ShowMessage('找不到'+Trim('LabelSet.dll'));
  end;
  tv1.Controller.EditingController.ShowEdit();
end;

procedure TfrmProductOrderLBNameSet11.ToolButton3Click(Sender: TObject);
var
  FPiZhong:string;
  FReal:Double;
begin
  if Trim(PiZhong.Text)='' then
  begin
    Application.MessageBox('皮重不能为空!','提示',0);
    Exit;
  end;
  if TryStrToFloat(PiZhong.Text,FReal)=False then
  begin
    Application.MessageBox('皮重非法数字!','提示',0);
    Exit;
  end;
  with ADOQueryCmd do
  begin
    Close;
    sql.Clear;
    sql.Add('Update JYOrderCon_Main Set PiZhong='+(PiZhong.Text));
    sql.Add(' where Mainid='''+Trim(Order_Main.fieldbyname('Mainid').AsString)+'''');
    ExecSQL;
  end;
  with Order_Main do
  begin
    Edit;
    FieldByName('PiZhong').Value:=PiZhong.Text;
    Post;
  end;
  tv1.Controller.EditingController.ShowEdit();
end;

procedure TfrmProductOrderLBNameSet11.ToolButton4Click(Sender: TObject);
type
  TMyFunc = function(App:Tapplication; FormH:hwnd; FormID:integer;
                  Language: integer; WinStyle:integer;
                  GCode: Pchar; GName: Pchar; DataBase:Pchar;Title:PChar;
                  Parameters1:PChar;Parameters2:PChar;Parameters3:PChar;Parameters4:PChar;
                  Parameters5:PChar;Parameters6:PChar;Parameters7:PChar;Parameters8:PChar;
                  Parameters9:PChar;Parameters10:PChar;DataBaseStr:PChar):hwnd;stdcall;
var
  Tf: TMyFunc;
  Tp: TFarProc;
  Th:Thandle;
  LabInt,labname:String;
begin
  //if PPInt=2 then Exit;
  Ddatabase:=StringOfChar(' ', 32);
  Th := LoadLibrary('LabelSet.dll');
  if Th > 0 then
  begin
    try
      Tp := GetProcAddress(Th, 'GetDllForm');
      if Tp <> nil then
      begin
        Tf := TMyFunc(Tp);
        newh:=Tf(Application,0,2,0,0,
          PChar(DCode),
          PChar(DName),
          PChar(Ddatabase),
          PChar('标签模版设置'),
          PChar(''),
          PChar(''),
          '','','','','','','','',PChar(DConString)
          );
          if Trim(PChar(Ddatabase))<>'' then
          begin
            Ddatabase:=Trim(PChar(Ddatabase));
            LabInt:=Trim( LeftBStr(Ddatabase,Pos('|',Ddatabase)-1) ) ;
            labname:=Trim(RightBStr(Ddatabase,Length(Ddatabase)-Pos('|',Ddatabase) ) );
            with ADOQueryCmd do
            begin
              Close;
              sql.Clear;
              sql.Add('Update JYOrderCon_Main Set ConNLBName='''+Trim(labname)+'''');
              sql.Add(' where Mainid='''+Trim(Order_Main.fieldbyname('Mainid').AsString)+'''');
              ExecSQL;
            end;
            with Order_Main do
            begin
              Edit;
              FieldByName('ConNLbName').Value:=labname;
              Post;
            end;
          end;
      end
      else
      begin
        ShowMessage('打印执行错误');
      end;
    finally
    // FreeLibrary();
    end;
  end
  else
  begin
    ShowMessage('找不到'+Trim('LabelSet.dll'));
  end;
 tv1.Controller.EditingController.ShowEdit();
end;


procedure TfrmProductOrderLBNameSet11.v1Column3PropertiesEditValueChanged(
  Sender: TObject);
var
  mvalues:string;
begin
  mvalues:=TCXTextEdit(Sender).Text;

  with Order_Main do
  begin
    edit;
    fieldbyname('ConNLBName').Value:=mvalues;
    post;
  end;
  tv1.Controller.EditingController.ShowEdit();
  IF trim(mvalues)='' then
  begin
        with ADOQueryCmd do
        begin
          Close;
          sql.Clear;
          sql.Add('Update JYOrderCon_Main Set ConNLBName='''' ');
          sql.Add('where Mainid='''+Trim(Order_Main.fieldbyname('Mainid').AsString)+'''');
          ExecSQL;
        end;
  end
end;

procedure TfrmProductOrderLBNameSet11.v1Column1PropertiesEditValueChanged(
  Sender: TObject);
var
  mvalues:string;
begin
  mvalues:=TCXTextEdit(Sender).Text;

  with Order_Main do
  begin
    edit;
    fieldbyname('ConLBName').Value:=mvalues;
    post;
  end;
  tv1.Controller.EditingController.ShowEdit();
  IF trim(mvalues)='' then
  begin
        with ADOQueryCmd do
        begin
          Close;
          sql.Clear;
          sql.Add('Update JYOrderCon_Main Set ConLBName='''' ');
          sql.Add('where Mainid='''+Trim(Order_Main.fieldbyname('Mainid').AsString)+'''');
          ExecSQL;
        end;
  end
end;
procedure TfrmProductOrderLBNameSet11.v1Column6PropertiesEditValueChanged(
  Sender: TObject);
var
  mvalues:string;
begin
  mvalues:=TCXTextEdit(Sender).Text;
        with ADOQueryCmd do
        begin
          Close;
          sql.Clear;
          sql.Add('Update JYOrder_Main Set XSType='''+trim(mvalues)+''' ');
          sql.Add('where Mainid='''+Trim(Order_Main.fieldbyname('Mainid').AsString)+'''');
          ExecSQL;
       end;
  with Order_Main do
  begin
    edit;
    fieldbyname('XSType').Value:=mvalues;
    post;
  end;


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

procedure TfrmProductOrderLBNameSet11.v1Column6PropertiesButtonClick(
  Sender: TObject; AButtonIndex: Integer);
begin
   try
    frmZDYHelp:=TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag:='xsType';
      flagname:='换算系数类型';
      if ShowModal=1 then
      begin
        with Order_Main do
        begin
         edit;
         fieldbyname('xsType').AsString:=Trim(ClientDataSet1.fieldbyname('ZdyName').AsString);
        end;
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TfrmProductOrderLBNameSet11.v1LengUnitPropertiesEditValueChanged(
  Sender: TObject);
var
  mvalues:string;
begin
  mvalues:=TCXTextEdit(Sender).Text;
        with ADOQueryCmd do
        begin
          Close;
          sql.Clear;
          sql.Add('Update JYOrder_Main Set LengUnit='''+trim(mvalues)+''' ');
          sql.Add('where Mainid='''+Trim(Order_Main.fieldbyname('Mainid').AsString)+'''');
          ExecSQL;
       end;
  with Order_Main do
  begin
    edit;
    fieldbyname('LengUnit').Value:=mvalues;
    post;
  end;
end;

procedure TfrmProductOrderLBNameSet11.TSelClick(Sender: TObject);
begin
  if Order_Main.isempty then exit;
  modalResult:=1;
end;

end.
