?? boxincome.pas
字號:
unit BoxIncome;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, NEOFORM, ExtCtrls, ToolWin, ComCtrls, StdCtrls, Buttons, Mask,
DBCtrls, RpBase, RpSystem, RpDefine, RpRave, RpCon, RpConDS, rvclass, rvcsstd, RvCsBars,
DB, ADODB, Grids, DBGrids;
type
TFrmBoxIncome = class(TGBKPForm)
GroupBox1: TGroupBox;
MemoBarcodeS: TMemo;
BitBtn1: TBitBtn;
Label1: TLabel;
DBEditBarCode: TDBEdit;
Label2: TLabel;
DBEditOrderID: TDBEdit;
Label3: TLabel;
DBEditDevName: TDBEdit;
Label4: TLabel;
DBEditCustomerName: TDBEdit;
Label5: TLabel;
DBEditpostdate: TDBEdit;
EdtBarCodeEnter: TEdit;
LabelMessage: TLabel;
RvProjectShipLabel: TRvProject;
RvSystemShipLabel: TRvSystem;
RvDataSetConnectionPack: TRvDataSetConnection;
Label6: TLabel;
DBMemoMemo: TDBMemo;
Label7: TLabel;
Label8: TLabel;
LabelThisCount: TLabel;
LabelTodayCount: TLabel;
QToday: TADOQuery;
ChkPreview: TCheckBox;
CheckBoxSetPrint: TCheckBox;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
GroupBox2: TGroupBox;
MemoPrintBarCode: TMemo;
procedure EdtBarCodeEnterKeyPress(Sender: TObject; var Key: Char);
procedure MemoBarcodeSDblClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
private
OrderIDstr: string;
DevNamestr: string;
CustomerNamestr: string;
postdatestr: string;
Memostr: string;
{ Private declarations }
public
function MessageAndSaveBarcodeInfo(infoType: string; OldInfo, newInfo: string): boolean;
function ContrastBarcodeInfo: boolean;
procedure SaveBarcodeInfo;
{ Public declarations }
end;
var
FrmBoxIncome: TFrmBoxIncome;
implementation
uses StockDataModel, PublicParameter;
{$R *.dfm}
procedure TFrmBoxIncome.EdtBarCodeEnterKeyPress(Sender: TObject;
var Key: Char);
var BarCodeTemp: string;
nums: string;
MyPage: TRavePage;
MyText: TRaveText;
I2of5BarCodeBoxPackBarcode: TRaveI2of5BarCode;
I2of5BarCodeBoxPackBarcode2: TRaveI2of5BarCode;
TextDevHardOptionS: TRavetext;
TextDevHardOptionS2: TRavetext;
begin
inherited;
LabelMessage.Caption := '';
LabelMessage.Refresh;
if key = #13 then //條碼完畢
begin
BarCodeTemp := copy(trim(EdtBarCodeEnter.Text), length(trim(EdtBarCodeEnter.Text)) - 13 + 1, 13); //掃描時前面多一個0????
if BarCodeTemp = '' then
begin
LabelMessage.Caption := '掃描失敗,請重新掃描!';
exit;
end;
if MemoBarcodeS.Lines.IndexOf(BarCodeTemp) >= 0 then
begin
LabelMessage.Caption := '此條碼剛掃描過,機器已經包裝,請重新掃描!';
EdtBarCodeEnter.Text := '';
exit;
end;
//定位并顯示信息
if not StockDM.QBarCodefind.Locate('BarCode', BarCodeTemp, []) then
begin
LabelMessage.Caption := '此機器還未生產,條碼還未生成,請重新掃描!';
EdtBarCodeEnter.Text := '';
exit;
end;
if StockDM.QBarCodefind.FieldValues['IsPack'] then
begin
LabelMessage.Caption := '此機器已經包裝,請重新掃描!';
EdtBarCodeEnter.Text := '';
exit;
end;
//StockDM.QOrders.Locate('OrderID', StockDM.QBarCodefind.FieldValues['OrderID'], []);
//進行其他檢查
if (MemoBarcodeS.Lines.Count = 0) and (MemoPrintBarCode.Lines.Count = 0) then
begin //是第一個時記下
if Application.MessageBox(pchar('請確定包裝機器是否正確?'), pchar('提示'), MB_YESNO) = IDYES then
begin
//記下原來所有值
SaveBarcodeInfo;
end;
end else
begin
if ContrastBarcodeInfo then
SaveBarcodeInfo //有改變并認為是正確的就記下
else exit; //是錯的就退出
end;
nums := StockDM.QBarCodefind.Fieldbyname('devHardOptions').AsString;
//先保存每次保存一個
StockDM.QBarCodefind.Edit; //已經定位
StockDM.QBarCodefind.FieldValues['IsPack'] := true;
StockDM.QBarCodefind.FieldValues['PackDate'] := FormatDateTime('yyyy-mm-dd',Date);
StockDM.QBarCodefind.FieldValues['PackTime'] := time;
StockDM.QBarCodefind.Post;
MemoPrintBarCode.Lines.Add(BarCodeTemp);
if MemoPrintBarCode.Lines.Count >= 2 then
begin
MemoBarcodeS.Lines.AddStrings(MemoPrintBarCode.Lines);
//自動 打印
RvProjectShipLabel.ProjectFile := CurPath + '\條碼\BoxPackBarCode.rav';
RvProjectShipLabel.Open;
with RvProjectShipLabel.ProjMan do
begin
MyPage := FindRaveComponent('ReportMain.Page1', nil) as TRavePage;
I2of5BarCodeBoxPackBarcode := FindRaveComponent('I2of5BarCodeBoxPackBarcode', MyPage) as TRaveI2of5BarCode;
I2of5BarCodeBoxPackBarcode2 := FindRaveComponent('I2of5BarCodeBoxPackBarcode2', MyPage) as TRaveI2of5BarCode;
I2of5BarCodeBoxPackBarcode.Text := MemoPrintBarCode.Lines[0]; //條碼
I2of5BarCodeBoxPackBarcode2.Text := MemoPrintBarCode.Lines[1]; //條碼
//I2of5BarCodeBoxPackBarcode.Text := MemoPrintBarCode.Lines[2]; //條碼
//I2of5BarCodeBoxPackBarcode2.Text := MemoPrintBarCode.Lines[3]; //條碼
//I2of5BarCode3.Reflect;
TextDevHardOptionS := FindRaveComponent('TextDevHardOptionS', MyPage) as TRaveText;
TextDevHardOptionS2 := FindRaveComponent('TextDevHardOptionS2', MyPage) as TRaveText;
TextDevHardOptions.Text := nums; //條碼
TextDevHardOptions2.Text := nums; //條碼
end;
if CheckBoxSetPrint.Checked then
RvSystemShipLabel.SystemSetups := [ssAllowSetup, ssAllowCopies, ssAllowDestPreview, ssAllowDestPrinter, ssAllowPrinterSetup, ssAllowPreviewSetup]
else
RvSystemShipLabel.SystemSetups := [];
if ChkPreview.Checked then RvSystemShipLabel.DefaultDest := rdPreview
else RvSystemShipLabel.DefaultDest := rdPrinter;
//RvSystemShipLabel.SystemSetups:=rdPrinter;
try //Canvas does not allow drawing //因為系統沒有打印機
RvProjectShipLabel.Execute; //是因為TCanvas的FHandle還沒有分配的時候就要求執行必須有FHandle才能進行的操作引起的,
except
ShowMessage('打印失敗請重新打印!');
Abort;
end;
MemoPrintBarCode.Clear;
end;
with QToday do
begin
close;
parameters.ParamByName('PackDate').Value := FormatDateTime('yyyy-mm-dd',Date);
open;
labeltodaycount.Caption := inttostr(RecordCount);
end;
labelThiscount.Caption := inttostr(MemoBarcodeS.Lines.Count);
EdtBarCodeEnter.text := '';
end;
EdtBarCodeEnter.SetFocus;
end;
//判斷值是否改變
function TFrmBoxIncome.ContrastBarcodeInfo: boolean;
begin
Result := true;
if OrderIDstr <> DBEditOrderID.Text then //訂單號不同
begin
if MessageAndSaveBarcodeInfo('訂單號', OrderIDstr, DBEditOrderID.Text) then
Result := true else Result := false;
exit;
end
else if CustomerNamestr <> DBEditCustomerName.Text then //客戶名稱
begin
if MessageAndSaveBarcodeInfo('客戶名稱', CustomerNamestr, DBEditCustomerName.Text) then
Result := true else Result := false;
exit;
end
else if DevNamestr <> DBEditDevName.Text then //機型
begin
if MessageAndSaveBarcodeInfo('機型', DevNamestr, DBEditDevName.Text) then
Result := true else Result := false;
exit;
end else if postdatestr <> DBEditpostdate.Text then //生產日期
begin
if MessageAndSaveBarcodeInfo('生產日期', postdatestr, DBEditpostdate.Text) then
Result := true else Result := false;
exit;
end
else if Memostr <> DBMemoMemo.Text then //配置說明
begin
if MessageAndSaveBarcodeInfo('配置說明', Memostr, DBMemoMemo.Text) then
Result := true else Result := false;
exit;
end
end;
function TFrmBoxIncome.MessageAndSaveBarcodeInfo(infoType: string; OldInfo, newInfo: string): boolean;
begin
Result := false;
if Application.MessageBox(pchar(infoType + '將由' + #13 + OldInfo + #13 + '改變為' + #13 + newInfo + #13 + '請確定包裝機器正確?'), pchar('提示'), MB_YESNO) = IDYES then
begin
Result := true;
//記下原來所有值
SaveBarcodeInfo;
end;
end;
//記下原來所有值
procedure TFrmBoxIncome.SaveBarcodeInfo;
begin
OrderIDstr := DBEditOrderID.Text;
DevNamestr := DBEditDevName.Text;
CustomerNamestr := DBEditCustomerName.Text;
postdatestr := DBEditpostdate.Text;
Memostr := DBMemoMemo.Text;
end;
procedure TFrmBoxIncome.MemoBarcodeSDblClick(Sender: TObject);
begin
inherited;
StockDM.QBarCodefind.Locate('BarCode', MemoBarcodeS.SelText, []);
end;
procedure TFrmBoxIncome.FormShow(Sender: TObject);
var iBegin: Cardinal;
begin
inherited;
EdtBarCodeEnter.SetFocus;
ActiveControl := EdtBarCodeEnter;
iBegin := GetTickCount; // GetTickCount() 取得當前系統時間的毫秒值
with StockDM.QBarCodefind do
begin
Close;
sql.Clear;
//sql.Add('select a.*,b.*,c.DevName,d.CustomerName,d.OrderDetail,d.OrderMemo from BarCode a,GBarCode b,DeviceType c,Orders d where a.GBarCodeID=b.GBarCodeID and a.Devnum=c.Devnum and a.OrderId=d.OrderID ');
sql.Add('select a.barCode,a.OrderID,a.CustomerName,a.Postdate,a.isPack,a.PackDate,a.PackTime,a.devHardOptions,c.DevName from BarCode a,DeviceType c where a.Devnum=c.Devnum');
Open; // distinct
end;
//if not StockDM.QOrders.Active then StockDM.QOrders.Active:=true;
iBegin := GetTickCount - iBegin; //
LabelMessage.Caption:='用時' + inttostr(iBegin) + '毫秒)'
end;
procedure TFrmBoxIncome.BitBtn1Click(Sender: TObject);
begin
inherited;
close;
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -