⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ordertobarcode.pas

📁 Barcode And LabelPrint
💻 PAS
📖 第 1 页 / 共 3 页
字号:
  //StockDM.QGBarCode.Active := true;
  DBGridEh1.DataSource := nil;
  case printCopies of
    1: begin
        printCopies := 2;
        BitBtnPrintBarcode.Caption := '打印第二份条码';
      end;
    //2: begin
    //   printCopies := 3;
     //   BitBtnPrintBarcode.Caption := '打印第三份条码';
    //  end;
  else begin
      printCopies := 0;
      BitBtnPrintBarcode.Caption := '打印条码'; //补打本订单
      StockDM.QSQLBarCode.Filtered := false;
      StockDM.QGBarCode.Filtered := false;
      BitBtnPrintBarcode.Enabled := false;
      BitBtn1.Enabled := false;
    end;
  end;




end;

procedure TFrmOrderToBarCode.setPaterSize(Length, Width: smallint);
var
  ADevice, ADriver, APort: array[0..255] of char;
  DeviceHandle: THandle;
  DevMode: PDeviceMode;
begin
  Printer.GetPrinter(ADevice, ADriver, APort, DeviceHandle);
  if DeviceHandle = 0 then
  begin
    Printer.PrinterIndex := Printer.PrinterIndex;
    Printer.GetPrinter(ADevice, ADriver, APort, DeviceHandle);
  end;
  if DeviceHandle = 0 then
    raise Exception.Create('不能加载打印机!')
  else
    DevMode := GlobalLock(DeviceHandle);
  //设置
  if DevMode <> nil then
  begin
    with DevMode^ do
    begin
   //dmFields:=dmFields or DM_PAPERLENGTH;
   //dmPaperLength:=Length;
   //dmFields:=dmFields or DM_PAPERWIDTH;
   //dmPaperWidth:=Width;
      dmFields := dmFields or
        DM_PAPERSIZE
        or DM_PAPERWIDTH
        or DM_PAPERLENGTH;
      dmPaperSize := DMPAPER_USER; //DMPAPER_USER;//256
     // dmPaperLength :=8*25.4;//220;
     // dmPaperWidth := 3*25.4;
      //ResetDC(DeviceHandle,DevMode); //使设置的参数发挥作用
    end;
  end;
  Printer.SetPrinter(ADevice, ADriver, APort, DeviceHandle); //test
  if not DeviceHandle = 0 then
    GlobalUnlock(DeviceHandle);


end;

procedure TFrmOrderToBarCode.EdtOrderIDKeyPress(Sender: TObject;
  var Key: Char);
begin
  inherited;
  if (not (Key in ['0'..'9', #8])) then Key := #0;
end;

procedure TFrmOrderToBarCode.ComboBoxDevNameCloseUp(Sender: TObject);
var
  NumS, Enames: string;
begin
  inherited;
  //if StockDM.QDeviceType.Active = false then StockDM.QDeviceType.Active := true;
  //if StockDM.QDevAndOptions.Active=false then StockDM.QDevAndOptions.Active:=true;
  //if StockDM.QDevHardOptions.Active=false then StockDM.QDevHardOptions.Active:=true;

//etDevHardOptionsNumAndEName(NumS,Enames);
//MemoMemo.Text:=Enames;
end;

function TFrmOrderToBarCode.GetDevHardOptionsNumAndEName: string;
//var sqlstr: string;
var i: integer;
begin
{  NumS := '';
  Enames := '';

  sqlstr := Format('SELECT a.Devnum,a.DevName,a.Descri,c.Num,c.Ename,c.Zname,c.memo FROM deviceType a, DevAndOptions b,DevHardOptions c where a.devNum=b.devnum and b.Num=c.Num and a.Devname=''%s''', [DevName]);
  with StockDM.QDevAndOptions do
  begin
    close;
    SQL.Clear;
    SQL.add(sqlstr);
    open;
    while not eof do
    begin
      NumS := NumS + copy('00' + FieldValues['Num'], length(FieldValues['Num']) + 1, 2); //+','
      Enames := Enames + '/' + FieldValues['EName'];
      next;
    end;
//NumS:=copy(NumS,2,maxint);
    NumS := copy(NumS, 1, 20); //最多10个功能配置
    Enames := copy(Enames, 2, maxint);
    end;   }


  for i := 0 to LSTOpts.Count - 1 do
  begin
    if LSTOpts.Checked[i] then
    begin
      Result := Result + '/' + copy(LSTOpts.Items[i], 1, pos(',', LSTOpts.Items[i]) - 1);
      //QDevAndOptions.Append;
      //QDevAndOptions.FieldValues['DevNum'] := DBEdtDevNum.Text;
      //QDevHardOptions.Locate('Ename', copy(LSTOpts.Items[i], 1, pos(',', LSTOpts.Items[i]) - 1), []); //VarArrayOf([LSTOpts.Items[i]])
      //QDevAndOptions.FieldValues['Num'] := QDevHardOptions.FieldValues['Num'];
      //QDevAndOptions.Post;
    end;
  end;
  Result := copy(Result, 2, maxint);
end;

procedure TFrmOrderToBarCode.DevHardOptionsENameToLSTOpts(EName: string);
var tempstr: string;
  i: integer;
begin
  for i := 0 to LSTOpts.Count - 1 do
  begin
    if LSTOpts.Checked[i] then
    begin
      LSTOpts.Checked[i] := false;
      //Result := Result + '/' + copy(LSTOpts.Items[i], 1, pos(',', LSTOpts.Items[i]) - 1);
    end;
  end;

  while true do
  begin
    if EName = '' then Break;
    if pos('/', EName) >= 1 then
    begin
      tempstr := copy(EName, 1, pos('/', EName) - 1);
      EName := copy(EName, pos('/', EName) + 1, MaxInt);
    end
    else
    begin
      tempstr := EName;
      EName := '';
    end;

    for i := 0 to LSTOpts.Count - 1 do
    begin
      if copy(LSTOpts.Items[i], 1, pos(',', LSTOpts.Items[i]) - 1) = tempstr then
      begin
        LSTOpts.Checked[i] := true;
      end;
    end;

  end;


end;



procedure TFrmOrderToBarCode.ComboBoxDevNameSelect(Sender: TObject);

begin
  inherited;
  //if StockDM.QDeviceType.Active = false then StockDM.QDeviceType.Active := true;
  //if StockDM.QDevAndOptions.Active=false then StockDM.QDevAndOptions.Active:=true;
  //if StockDM.QDevHardOptions.Active=false then StockDM.QDevHardOptions.Active:=true;

//GetDevHardOptionsNumAndEName(NumS,Enames);
//MemoMemo.Text:=Enames;
end;

procedure TFrmOrderToBarCode.ComboBoxDevNameExit(Sender: TObject);
var
  NumS, Enames: string;
begin
  inherited;
  // GetDevHardOptionsNumAndEName(ComboBoxDevName.Text, NumS, Enames);
  //StringGridOrder.Cells[3, StringGridOrder.row] := Enames;
end;

procedure TFrmOrderToBarCode.BitBtn2Click(Sender: TObject);
begin
  inherited;
  close;
end;



procedure TFrmOrderToBarCode.BitBtn3Click(Sender: TObject);
var i: byte;
begin
  inherited;
  EdtPanPrincipal.Text := '';
  EdtPanAuditing.Text := '';
  EdtSellPrincipal.Text := '';
  EdtPanTab.Text := '';
  EdtOrderID.Text := '';
  EdtDevName.Text := '';
  MemoOrderDetail.Text := '';
  MemoOrderMemo.Text := '';
  EdtCustomer.Text := '';
  fcTreeViewBarCode.Items.Clear;
  for i := 1 to StringGridOrder.RowCount - 1 do
  begin
    StringGridOrder.Cells[1, i] := '';
    StringGridOrder.Cells[2, i] := '';
    StringGridOrder.Cells[3, i] := '';
  end;
end;

procedure TFrmOrderToBarCode.LSTOptsDblClick(Sender: TObject);
begin
  inherited;
  LSTOpts.Visible := false;
end;

procedure TFrmOrderToBarCode.BitBtnRePrintClick(Sender: TObject);

begin
  inherited;
  if StockDM.QSQLBarCode.RecordCount > 1000 then exit;
  if StockDM.QSQLBarCode.RecordCount <= 0 then
  begin
    ShowMessage('没有可打印条码.请重新设置!');
    StockDM.QGBarCode.Filtered := false;
    BitBtnPrintBarcode.Enabled := false;
    exit;
  end;

  if messagedlg('请保证补打条件设置输入正确!', mtinformation, [mbok, mbno], 0) = mrNO then
  begin
    StockDM.QGBarCode.Filtered := false;
    BitBtnPrintBarcode.Enabled := false;
    exit;
  end;

  BitBtnPrintBarcodeClick(Sender);
  BitBtnRePrint.Enabled := false;
end;

procedure TFrmOrderToBarCode.RadioGroupRePrintTypeClick(Sender: TObject);
begin
  inherited;
//  ShowMessage('RadioGroupRePrintTypeClick');
  DateTimePickerRepPostDate.Enabled := RadioGroupRePrintType.ItemIndex <= 1; //2
  EdtRePOrderID.Enabled := RadioGroupRePrintType.ItemIndex <= 1; //2
  ComboBoxRePDevType.Enabled := ((RadioGroupRePrintType.ItemIndex <= 1) and (RadioGroupRePrintType.ItemIndex >= 1));
  EdtRePStartBarCode.Enabled := RadioGroupRePrintType.ItemIndex = 2; //((RadioGroupRePrintType.ItemIndex<=2)and (RadioGroupRePrintType.ItemIndex>=1));;
  EdtRePBarCode.Enabled := RadioGroupRePrintType.ItemIndex = 3;

  if DateTimePickerRepPostDate.Enabled then DateTimePickerRepPostDate.Color := clWindow else DateTimePickerRepPostDate.Color := $00C8D0D4;
  if EdtRePOrderID.Enabled then EdtRePOrderID.Color := clWindow else EdtRePOrderID.Color := $00C8D0D4;
  if ComboBoxRePDevType.Enabled then ComboBoxRePDevType.Color := clWindow else ComboBoxRePDevType.Color := $00C8D0D4;
  if EdtRePStartBarCode.Enabled then EdtRePStartBarCode.Color := clWindow else EdtRePStartBarCode.Color := $00C8D0D4;
  if EdtRePBarCode.Enabled then EdtRePBarCode.Color := clWindow else EdtRePBarCode.Color := $00C8D0D4;

  EdtRePSEndBarCode.Enabled := EdtRePStartBarCode.Enabled;
  EdtRePSEndBarCode.Color := EdtRePStartBarCode.Color;
end;

procedure TFrmOrderToBarCode.BitBtn4Click(Sender: TObject);
var isInputInfo: boolean;
begin
  inherited;
  DBGridEh1.DataSource := StockDM.DSSQLBarCode;
  isInputInfo := true;
  if (EdtRePOrderID.Enabled) and (EdtRePOrderID.Text = '') then isInputInfo := false;
  if (EdtRePStartBarCode.Enabled) and (EdtRePStartBarCode.Text = '') then isInputInfo := false;
  if (EdtRePSEndBarCode.Enabled) and (EdtRePSEndBarCode.Text = '') then isInputInfo := false;
  if (EdtRePBarCode.Enabled) and (EdtRePBarCode.Text = '') then isInputInfo := false;
  if (ComboBoxRePDevType.Enabled) and (ComboBoxRePDevType.Text = '') then isInputInfo := false;

  if not isInputInfo then
  begin
    ShowMessage('补打条件设置输入不全,请检查');
    exit;
  end;

  if not StockDM.QDeviceType.Active then StockDM.QDeviceType.Active := true;
  if not StockDM.QGBarCode.Active then StockDM.QGBarCode.Active := true;
  if not StockDM.QSQLBarCode.Active then StockDM.QSQLBarCode.Active := true;
  case RadioGroupRePrintType.ItemIndex of
    0: begin //条码
        StockDM.QGBarCode.close;
        StockDM.QGBarCode.Filter := 'OrderID=' + EdtRePOrderID.Text + ' and UPDateDate =' + FormatDateTime('yyyy-mm-dd',DateTimePickerRepPostDate.Date) + ''; //过滤此订单的所有条码,准备打印
        StockDM.QGBarCode.Filtered := true;
        StockDM.QGBarCode.Active := true;

        StockDM.QSQLBarCode.close;
        StockDM.QSQLBarCode.Filter := 'OrderID=' + EdtRePOrderID.Text + ' and PostDate =' + FormatDateTime('yyyy-mm-dd',DateTimePickerRepPostDate.Date) + ''; //过滤此订单的所有条码,准备打印
        StockDM.QSQLBarCode.Filtered := true;
        StockDM.QSQLBarCode.Active := true;

      end;
    1: begin
    //  Filter := 'OrderID=' + EdtOrderID.Text + ' and  UPDateDate=' + FormatDateTime('yyyy-mm-dd',date) + ''; //过滤此

        StockDM.QDeviceType.Locate('DevName', ComboBoxRePDevType.Text, []);
        StockDM.QGBarCode.close;
        StockDM.QGBarCode.Filter := 'OrderID=' + EdtRePOrderID.Text + ' and DevNum =' + StockDM.QDeviceType.FieldValues['DevNum'] + ' and UPDateDate =' + FormatDateTime('yyyy-mm-dd',DateTimePickerRepPostDate.Date) + ''; //过滤此订单的所有条码,准备打印
        StockDM.QGBarCode.Filtered := true;
        StockDM.QGBarCode.Active := true;

        StockDM.QSQLBarCode.close;
        StockDM.QSQLBarCode.Filter := 'OrderID=' + EdtRePOrderID.Text + ' and DevNum =' + StockDM.QDeviceType.FieldValues['DevNum'] + ' and PostDate =' + FormatDateTime('yyyy-mm-dd',DateTimePickerRepPostDate.Date) + ''; //过滤此订单的所有条码,准备打印
        StockDM.QSQLBarCode.Filtered := true;
        StockDM.QSQLBarCode.Active := true;

      end;
    2: begin

        if copy(EdtRePStartBarCode.Text, 1, 9) <> copy(EdtRePSendBarCode.Text, 1, 9) then
        begin
          ShowMessage('起始与终止条码不是同订单,同机型的条码,无法查询,请重输!!');
          EdtRePStartBarCode.SetFocus;
          Exit;
        end;
       if StockDM.QSQLBarCode.Locate('BarCode', EdtRePStartBarCode.Text, []) then
       begin
        StockDM.QGBarCode.close;
        StockDM.QGBarCode.Filter := 'OrderID=' + StockDM.QSQLBarCode.FieldValues['OrderID'] + ' and DevNum =' + StockDM.QSQLBarCode.FieldValues['DevNum'] + ' and UPDateDate =' + StockDM.QSQLBarCode.FieldValues['PostDate'] + ''; //过滤此订单的所有条码,准备打印
        StockDM.QGBarCode.Filtered := true;
        StockDM.QGBarCode.Filtered := true;
        StockDM.QGBarCode.Active := true;

        StockDM.QSQLBarCode.close; //>=                                           <=
        StockDM.QSQLBarCode.Filter := 'BarCode >= ''' + EdtRePStartBarCode.Text + ''' and BarCode <= ''' + EdtRePSEndBarCode.Text + ''''; //过滤此订单的所有条码,准备打印
        StockDM.QSQLBarCode.Filtered := true;
        StockDM.QSQLBarCode.Active := true;
       end;



      end;
    3: begin

        StockDM.QSQLBarCode.Locate('BarCode', EdtRePBarCode.Text, []);
        StockDM.QGBarCode.close;
        StockDM.QGBarCode.Filter := 'OrderID=' + StockDM.QSQLBarCode.FieldValues['OrderID'] + ' and DevNum =' + StockDM.QSQLBarCode.FieldValues['DevNum'] + ' and UPDateDate =' + StockDM.QSQLBarCode.FieldValues['PostDate'] + ''; //过滤此订单的所有条码,准备打印
        StockDM.QGBarCode.Filtered := true;
        StockDM.QGBarCode.Active := true;

        StockDM.QSQLBarCode.close;
        StockDM.QSQLBarCode.Filter := 'BarCode=' + EdtRePBarCode.Text + ''; //过滤此订单的所有条码,准备打印
        StockDM.QSQLBarCode.Filtered := true;
        StockDM.QSQLBarCode.Active := true;
      end;
  end;
  if StockDM.QSQLBarCode.RecordCount >= 0 then
    BitBtnRePrint.Enabled := true;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -