unit U_ProductOrderLBNameSet;

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, cxLookAndFeels, cxLookAndFeelPainters, cxNavigator,
  dxSkinsCore, dxSkinBlack, dxSkinBlue, dxSkinBlueprint, dxSkinCaramel,
  dxSkinCoffee, dxSkinDarkRoom, dxSkinDarkSide, dxSkinDevExpressDarkStyle,
  dxSkinDevExpressStyle, dxSkinFoggy, dxSkinGlassOceans,
  dxSkinHighContrast, dxSkiniMaginary, dxSkinLilian, dxSkinLiquidSky,
  dxSkinLondonLiquidSky, dxSkinMcSkin, dxSkinMetropolis,
  dxSkinMetropolisDark, dxSkinMoneyTwins, dxSkinOffice2007Black,
  dxSkinOffice2007Blue, dxSkinOffice2007Green, dxSkinOffice2007Pink,
  dxSkinOffice2007Silver, dxSkinOffice2010Black, dxSkinOffice2010Blue,
  dxSkinOffice2010Silver, dxSkinOffice2013DarkGray,
  dxSkinOffice2013LightGray, dxSkinOffice2013White, dxSkinPumpkin,
  dxSkinSeven, dxSkinSevenClassic, dxSkinSharp, dxSkinSharpPlus,
  dxSkinSilver, dxSkinSpringTime, dxSkinStardust, dxSkinSummer2008,
  dxSkinTheAsphaltWorld, dxSkinsDefaultPainters, dxSkinValentine,
  dxSkinVS2010, dxSkinWhiteprint, dxSkinXmas2008Blue, dxSkinscxPCPainter;

type
  TfrmProductOrderLBNameSet = class(TForm)
    ToolBar1: TToolBar;
    TBRafresh: TToolButton;
    TBFind: 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;
    Label3: TLabel;
    OrderNoM: TEdit;
    v1OrderNo: TcxGridDBColumn;
    v1OrdDate: TcxGridDBColumn;
    v1DeliveryDate: TcxGridDBColumn;
    v1ConNo: TcxGridDBColumn;
    v1MPRTSpec: TcxGridDBColumn;
    Order_Main: TClientDataSet;
    RM1: TRMGridReport;
    RMDBMain: TRMDBDataSet;
    RMXLSExport1: TRMXLSExport;
    Label4: TLabel;
    CustomerNoName: TEdit;
    v1MPRTCodeName: TcxGridDBColumn;
    v1MPRTMF: TcxGridDBColumn;
    PopupMenu1: TPopupMenu;
    N2: TMenuItem;
    ToolButton1: TToolButton;
    Label8: TLabel;
    MPRTCodeName: TEdit;
    Label9: TLabel;
    ConNo: TEdit;
    v1MPRTKZ: TcxGridDBColumn;
    v1OrdDefStr1: TcxGridDBColumn;
    Label10: TLabel;
    MPRTSpec: TEdit;
    Label11: TLabel;
    MPRTCode: TEdit;
    Label12: TLabel;
    MPRTKZ: TEdit;
    Label13: TLabel;
    MPRTMF: TEdit;
    ADOQueryPrint: TADOQuery;
    CDS_Print: TClientDataSet;
    v1Column4: TcxGridDBColumn;
    v1Column1: TcxGridDBColumn;
    v1Column2: TcxGridDBColumn;
    ToolButton2: TToolButton;
    ToolButton3: TToolButton;
    PiZhong: TEdit;
    ToolButton4: TToolButton;
    v1Column3: TcxGridDBColumn;
    v1Column5: TcxGridDBColumn;
    ToolButton5: TToolButton;
    v1Column6: TcxGridDBColumn;
    v1Column7: TcxGridDBColumn;
    ToolButton6: TToolButton;
    ToolButton7: TToolButton;
    v1Column8: TcxGridDBColumn;
    v1Column9: TcxGridDBColumn;
    ToolButton8: TToolButton;
    v1Column10: TcxGridDBColumn;
    ToolButton9: TToolButton;
    v1Column11: TcxGridDBColumn;
    Tv1Column1: TcxGridDBColumn;
    ToolButton10: TToolButton;
    ToolButton11: TToolButton;
    ToolButton12: TToolButton;
    Tv1Column2: TcxGridDBColumn;
    Tv1Column3: TcxGridDBColumn;
    TbMaChiset: TToolButton;
    Tv1machi: 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 TBRafreshClick(Sender: TObject);
    procedure OrderNoMChange(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure CheckBox1Click(Sender: TObject);
    procedure CheckBox2Click(Sender: TObject);
    procedure Tv1StylesGetContentStyle(Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord; AItem: TcxCustomGridTableItem; out AStyle: TcxStyle);
    procedure ToolButton1Click(Sender: TObject);
    procedure ConNoKeyPress(Sender: TObject; var Key: Char);
    procedure ToolButton2Click(Sender: TObject);
    procedure ToolButton3Click(Sender: TObject);
    procedure ToolButton4Click(Sender: TObject);
    procedure v1Column3PropertiesEditValueChanged(Sender: TObject);
    procedure v1Column1PropertiesEditValueChanged(Sender: TObject);
    procedure ToolButton5Click(Sender: TObject);
    procedure v1Column6PropertiesEditValueChanged(Sender: TObject);
    procedure Tv1CellDblClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean);
    procedure ToolButton6Click(Sender: TObject);
    procedure ToolButton7Click(Sender: TObject);
    procedure v1Column8PropertiesChange(Sender: TObject);
    procedure ToolButton8Click(Sender: TObject);
    procedure ToolButton9Click(Sender: TObject);
    procedure ToolButton10Click(Sender: TObject);
    procedure ToolButton11Click(Sender: TObject);
    procedure ToolButton12Click(Sender: TObject);
    procedure TbMaChisetClick(Sender: TObject);
  private
    DQdate: TDateTime;
    procedure InitGrid();
    procedure InitForm();

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

var
//  frmProductOrderLBNameSet: TfrmProductOrderLBNameSet;
  newh: hwnd;

implementation

uses
  U_DataLink, U_OrderInPut, U_Fun, U_LabelList;

{$R *.dfm}

procedure TfrmProductOrderLBNameSet.FormDestroy(Sender: TObject);
begin
//  frmProductOrderLBNameSet:=nil;
end;

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

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

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

procedure TfrmProductOrderLBNameSet.InitGrid();
begin
  try
    ADOQueryMain.DisableControls;
    with ADOQueryMain do
    begin
      Filtered := False;
      Close;
      sql.Clear;
      sql.add('exec P_View_Order :begdate,:enddate,:WSql');
      if Trim(canshu1) = '低权限' then
      begin
        Parameters.ParamByName('WSql').Value := ' and Filler=''' + Trim(DName) + '''';
      end
      else
      begin
        Parameters.ParamByName('WSql').Value := '';
      end;
      Parameters.ParamByName('begdate').Value := FormatDateTime('yyyy-MM-dd', BegDate.DateTime);
      Parameters.ParamByName('enddate').Value := FormatDateTime('yyyy-MM-dd', enddate.DateTime + 1);
      ExecSQL;
      Open;
    end;
    SCreateCDS20(ADOQueryMain, Order_Main);
    SInitCDSData20(ADOQueryMain, Order_Main);
  finally
    ADOQueryMain.EnableControls;
  end;
end;

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

procedure TfrmProductOrderLBNameSet.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 TfrmProductOrderLBNameSet.TBRafreshClick(Sender: TObject);
begin
  InitGrid();
end;

procedure TfrmProductOrderLBNameSet.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 TfrmProductOrderLBNameSet.FormShow(Sender: TObject);
begin
  InitForm();
end;

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

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

procedure TfrmProductOrderLBNameSet.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 TfrmProductOrderLBNameSet.ToolButton1Click(Sender: TObject);
begin
  if Order_Main.IsEmpty then
    Exit;
  try
    frmOrderInPut := TfrmOrderInPut.Create(Application);
    with frmOrderInPut do
    begin
      PState := 1;
      FMainId := Trim(Self.Order_Main.fieldbyname('MainId').AsString);
      ToolBar2.Visible := False;
      TBSave.Visible := False;
      ScrollBox1.Enabled := False;
      Tv1.OptionsSelection.CellSelect := False;
      if ShowModal = 1 then
      begin

      end;
    end;
  finally
    frmOrderInPut.Free;
  end;
end;

procedure TfrmProductOrderLBNameSet.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
        Filtered := False;
        Close;
        sql.Clear;
        sql.add('exec P_View_Order :begdate,:enddate,:WSql');
        begin
          Parameters.ParamByName('WSql').Value := ' and conno like ''' + '%' + Trim(conno.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 TfrmProductOrderLBNameSet.ToolButton2Click(Sender: TObject);
var
  MLBName: string;
begin
  if Order_Main.IsEmpty then
  Exit;
  try
    frmLabelList := TfrmLabelList.Create(Application);
    with frmLabelList do
    begin
      if ShowModal = 1 then
      begin
        MLBName := Trim(ADOQueryLabel.fieldbyname('labelCaption').AsString);
      end;
    end;
  finally
    frmLabelList.Free;
  end;
  while Order_Main.Locate('SSel', True, []) do
  begin
    with ADOQueryCmd do
    begin
      Close;
      sql.Clear;
      sql.Add('Update JYOrder_Main Set LBName=''' + MLBName + '''');
      sql.Add(' where Mainid=''' + Trim(self.Order_Main.fieldbyname('Mainid').AsString) + '''');
      ExecSQL;
    end;
    with Order_Main do
    begin
      Edit;
      FieldByName('SSel').Value := False;
      FieldByName('LBName').Value := MLBName;
      Post;
    end;
    Next;
  end;
  tv1.Controller.EditingController.ShowEdit();
end;

procedure TfrmProductOrderLBNameSet.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 JYOrder_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 TfrmProductOrderLBNameSet.ToolButton4Click(Sender: TObject);
var
  maxno: string;
begin
  try
    frmLabelList := TfrmLabelList.Create(Application);
    with frmLabelList do
    begin
      if ShowModal = 1 then
      begin
        with ADOQueryCmd do
        begin
          Close;
          sql.Clear;
          sql.Add('Update JYOrder_Main Set NLBName=''' + Trim(ADOQueryLabel.fieldbyname('labelCaption').AsString) + '''');
          sql.Add(' where Mainid=''' + Trim(self.Order_Main.fieldbyname('Mainid').AsString) + '''');
          ExecSQL;
        end;
        TBRafresh.Click;
      end;
    end;
  finally
    frmLabelList.Free;
  end;
end;

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

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

procedure TfrmProductOrderLBNameSet.v1Column1PropertiesEditValueChanged(Sender: TObject);
var
  mvalues, FFieldName: string;
begin
  mvalues := TCXTextEdit(Sender).Text;
  FFieldName := Trim(Tv1.Controller.FocusedColumn.DataBinding.FilterFieldName);
  with Order_Main do
  begin
    edit;
    fieldbyname(FFieldName).Value := mvalues;
    post;
  end;
  tv1.Controller.EditingController.ShowEdit();
  if trim(mvalues) = '' then
  begin
    with ADOQueryCmd do
    begin
      Close;
      sql.Clear;
      sql.Add('Update JYOrder_Main Set' + Trim(FFieldName) + '='''' ');
      sql.Add('where Mainid=''' + Trim(Order_Main.fieldbyname('Mainid').AsString) + '''');
      ExecSQL;
    end;
  end
end;

procedure TfrmProductOrderLBNameSet.ToolButton5Click(Sender: TObject);
var
  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;
  Order_Main.First;
  while not Order_Main.eof do
  begin
    if Order_Main.FieldByName('SSel').Value = true then
    begin
      with ADOQueryCmd do
      begin
        Close;
        sql.Clear;
        sql.Add('Update JYOrder_Main Set XS=' + (PiZhong.Text));
        sql.Add(' where Mainid=''' + Trim(Order_Main.fieldbyname('Mainid').AsString) + '''');
        ExecSQL;
      end;
      with Order_Main do
      begin
        Edit;
        FieldByName('XS').Value := PiZhong.Text;
//        FieldByName('SSel').Value := false;
        Post;
      end;
    end;
    Order_Main.Next;
  end;

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

procedure TfrmProductOrderLBNameSet.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 TfrmProductOrderLBNameSet.Tv1CellDblClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean);
begin
  if Order_Main.IsEmpty then
    exit;
  ToolButton1.Click;
end;

procedure TfrmProductOrderLBNameSet.ToolButton6Click(Sender: TObject);
var
  fPrintFile: string;
  Txt, fImagePath: string;
  Moudle: THandle;
  Makebar: TMakebar;
  Mixtext: TMixtext;
begin
  if Order_Main.IsEmpty then
    exit;
  if trim(Order_Main.fieldbyname('LBName').AsString) = '' then
    exit;
  with ADOQueryPrint do
  begin
    Close;
    SQL.Clear;
    sql.Add('exec P_Print_Cs_Roll ');
    sql.Add('@mainID=''' + trim(Order_Main.fieldbyname('mainID').AsString) + ''' ');
    Open;
  end;
  try
    Moudle := LoadLibrary('MakeQRBarcode.dll');
    @Makebar := GetProcAddress(Moudle, 'Make');
    @Mixtext := GetProcAddress(Moudle, 'MixText');
    Txt := Trim(ADOQueryPrint.fieldbyname('MJID').AsString);
    fImagePath := ExtractFilePath(Application.ExeName) + 'image\temp.bmp';
    if not DirectoryExists(pchar(ExtractFilePath(Application.ExeName) + 'image')) then
      CreateDirectory(pchar(ExtractFilePath(Application.ExeName) + 'image'), nil);
    if FileExists(fImagePath) then
      DeleteFile(fImagePath);
    Makebar(pchar(Txt), Length(Txt), 3, 3, 0, PChar(fImagePath), 3);
  except
    application.MessageBox('条形码生成失败！', '提示信息', MB_ICONERROR);
    exit;
  end;

  fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\' + Trim(Order_Main.fieldbyname('LBName').AsString) + '.rmf';
  if FileExists(fPrintFile) then
  begin
    RMVariables['QRBARCODE'] := fImagePath;
    RM1.LoadFromFile(fPrintFile);
    RM1.ShowReport;
  end
  else
  begin
    Application.MessageBox(PChar('没有找到' + trim(fPrintFile)), '提示信息', 0);
  end;
end;

procedure TfrmProductOrderLBNameSet.ToolButton7Click(Sender: TObject);
var
  fPrintFile: string;
  Txt, fImagePath: string;
  Moudle: THandle;
  Makebar: TMakebar;
  Mixtext: TMixtext;
begin
  if Order_Main.IsEmpty then
    exit;
  if trim(Order_Main.fieldbyname('NLBName').AsString) = '' then
    exit;
  with ADOQueryPrint do
  begin
    Close;
    SQL.Clear;
    sql.Add('exec P_Print_Cs_Bao ');
    sql.Add('@mainID=''' + trim(Order_Main.fieldbyname('mainID').AsString) + ''' ');
    Open;
  end;
  try
    Moudle := LoadLibrary('MakeQRBarcode.dll');
    @Makebar := GetProcAddress(Moudle, 'Make');
    @Mixtext := GetProcAddress(Moudle, 'MixText');
    Txt := Trim(ADOQueryPrint.fieldbyname('MJID').AsString);
    fImagePath := ExtractFilePath(Application.ExeName) + 'image\temp.bmp';
    if not DirectoryExists(pchar(ExtractFilePath(Application.ExeName) + 'image')) then
      CreateDirectory(pchar(ExtractFilePath(Application.ExeName) + 'image'), nil);
    if FileExists(fImagePath) then
      DeleteFile(fImagePath);
    Makebar(pchar(Txt), Length(Txt), 3, 3, 0, PChar(fImagePath), 3);
  except
    application.MessageBox('条形码生成失败！', '提示信息', MB_ICONERROR);
    exit;
  end;

  fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\' + Trim(Order_Main.fieldbyname('NLBName').AsString) + '.rmf';
  if FileExists(fPrintFile) then
  begin
    RMVariables['QRBARCODE'] := fImagePath;
    RM1.LoadFromFile(fPrintFile);
    RM1.ShowReport;
  end
  else
  begin
    Application.MessageBox(PChar('没有找到' + trim(fPrintFile)), '提示信息', 0);
  end;
end;

procedure TfrmProductOrderLBNameSet.v1Column8PropertiesChange(Sender: TObject);
var
  mvalues: string;
begin
  mvalues := TCXTextEdit(Sender).Text;
  with Order_Main do
  begin
    edit;
    fieldbyname('Orddefstr15').Value := mvalues;
    post;
  end;
  tv1.Controller.EditingController.ShowEdit();

  with ADOQueryCmd do
  begin
    Close;
    sql.Clear;
    sql.Add('Update JYOrder_Main Set Orddefstr15=''' + trim(mvalues) + ''' ');
    sql.Add('where Mainid=''' + Trim(Order_Main.fieldbyname('Mainid').AsString) + '''');
    ExecSQL;
  end;
end;

procedure TfrmProductOrderLBNameSet.ToolButton8Click(Sender: TObject);
var
  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;
  Order_Main.First;
  while not Order_Main.eof do
  begin
    if Order_Main.FieldByName('SSel').Value = true then
    begin
      with ADOQueryCmd do
      begin
        Close;
        sql.Clear;
        sql.Add('Update JYOrder_Main Set KongJia=' + (PiZhong.Text));
        sql.Add(' where Mainid=''' + Trim(Order_Main.fieldbyname('Mainid').AsString) + '''');
        ExecSQL;
      end;
      with Order_Main do
      begin
        Edit;
        FieldByName('KongJia').Value := PiZhong.Text;
//        FieldByName('SSel').Value := false;
        Post;
      end;
    end;
    Order_Main.Next;
  end;

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

procedure TfrmProductOrderLBNameSet.ToolButton9Click(Sender: TObject);
var
  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;
  Order_Main.First;
  while not Order_Main.eof do
  begin
    if Order_Main.FieldByName('SSel').Value = true then
    begin
      with ADOQueryCmd do
      begin
        Close;
        sql.Clear;
        sql.Add('Update JYOrder_Main Set BaoZhuangDai=' + (PiZhong.Text));
        sql.Add(' where Mainid=''' + Trim(Order_Main.fieldbyname('Mainid').AsString) + '''');
        ExecSQL;
      end;
      with Order_Main do
      begin
        Edit;
        FieldByName('BaoZhuangDai').Value := PiZhong.Text;
//        FieldByName('SSel').Value := false;
        Post;
      end;
    end;
    Order_Main.Next;
  end;

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

procedure TfrmProductOrderLBNameSet.ToolButton10Click(Sender: TObject);
var
  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;
  Order_Main.First;
  while not Order_Main.eof do
  begin
    if Order_Main.FieldByName('SSel').Value = true then
    begin
      with ADOQueryCmd do
      begin
        Close;
        sql.Clear;
        sql.Add('Update JYOrder_Main Set KongJiawei=' + (PiZhong.Text));
        sql.Add(' where Mainid=''' + Trim(Order_Main.fieldbyname('Mainid').AsString) + '''');
        ExecSQL;
      end;
      with Order_Main do
      begin
        Edit;
        FieldByName('KongJiawei').Value := PiZhong.Text;
//        FieldByName('SSel').Value := false;
        Post;
      end;
    end;
    Order_Main.Next;

  end;

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

procedure TfrmProductOrderLBNameSet.ToolButton11Click(Sender: TObject);
var
  FPiZhong:string;
  FReal:Double;
begin
 IF Order_Main.IsEmpty then exit;
  if Order_Main.Locate('SSel',True,[])=False then
  begin
    Application.MessageBox('没有选择数据！','提示',0);
    Exit;
  end;
  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 order_Main do
  begin
    first;
    While not Eof do
    begin
      if order_Main.FieldByName('Ssel').AsBoolean=true then
      begin
        with ADOQueryCmd do
        begin
          Close;
          sql.Clear;
          sql.Add('Update JYOrder_main Set CDWS='+Trim(PiZhong.Text));
          sql.Add(' where mainID='''+Trim(Order_Main.fieldbyname('mainID').AsString)+'''');
          ExecSQL;
        end;
        with Order_Main do
        begin
          Edit;
          FieldByName('CDWS').Value:=PiZhong.Text;
          Post;
        end;
      end;
      next;
    end;
  end;
//  CheckBox1.Checked:=False;
//  with Order_Main do
//  begin
//    DisableControls;
//    first;
//    while not Eof do
//    begin
//      edit;
//      fieldbyname('Ssel').AsBoolean:=False;
//      post;
//      next;
//    end;
//    first;
//    EnableControls;
//  end;
end;

procedure TfrmProductOrderLBNameSet.ToolButton12Click(Sender: TObject);
var
  FPiZhong:string;
  FReal:Double;
begin
 IF Order_Main.IsEmpty then exit;
  if Order_Main.Locate('SSel',True,[])=False then
  begin
    Application.MessageBox('没有选择数据！','提示',0);
    Exit;
  end;
  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 order_Main do
  begin
    first;
    While not Eof do
    begin
      if order_Main.FieldByName('Ssel').AsBoolean=true then
      begin
        with ADOQueryCmd do
        begin
          Close;
          sql.Clear;
          sql.Add('Update JYOrder_main Set XSWS='+Trim(PiZhong.Text));
          sql.Add(' where mainID='''+Trim(Order_Main.fieldbyname('mainID').AsString)+'''');
          ExecSQL;
        end;
        with Order_Main do
        begin
          Edit;
          FieldByName('XSWS').Value:=PiZhong.Text;
          Post;
        end;
      end;
      next;
    end;
  end;
//  CheckBox1.Checked:=False;
//  with Order_Main do
//  begin
//    DisableControls;
//    first;
//    while not Eof do
//    begin
//      edit;
//      fieldbyname('Ssel').AsBoolean:=False;
//      post;
//      next;
//    end;
//    first;
//    EnableControls;
//  end;
end;

procedure TfrmProductOrderLBNameSet.TbMaChisetClick(Sender: TObject);
var
  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;
  Order_Main.First;
  while not Order_Main.eof do
  begin
    if Order_Main.FieldByName('SSel').Value = true then
    begin
      with ADOQueryCmd do
      begin
        Close;
        sql.Clear;
        sql.Add('Update JYOrder_Main Set machi=' + (PiZhong.Text));
        sql.Add(' where Mainid=''' + Trim(Order_Main.fieldbyname('Mainid').AsString) + '''');
        ExecSQL;
      end;
      with Order_Main do
      begin
        Edit;
        FieldByName('machi').Value := PiZhong.Text;
//        FieldByName('SSel').Value := false;
        Post;
      end;
    end;
    Order_Main.Next;
  end;

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

end.

