?? invhistory.pas
字號(hào):
dm_inventory.ReadInventory2(True, FList, tmpWdate[0],tmpWdate[1]);
if SetListView(0, -1) > 0 then ListView.TopItem.Selected := True;
end;
procedure TfrmInvHistory.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
ListView.SetFocus;
if not(UpdateProc) then CanClose := false;
if CanClose then begin
frmInvHistory.Free;
CanClose := true;
end;
dm_Inventory.Delete_NullMaterial;
end;
procedure TfrmInvHistory.FormClose(Sender: TObject; var Action: TCloseAction);
begin
//inherited;
Action := caHide;
end;
procedure TfrmInvHistory.FormDestroy(Sender: TObject);
begin
inherited;
//
end;
procedure TfrmInvHistory.ControlExit(Sender: TObject);
var CtrlList: PCONTROL_LIST;
Target: Pointer;
begin
if FSelectedItem = nil then Exit;
if FSelectedItem.Data = nil then Exit;
try CtrlList := GetCtrlListTarget(Sender as TWinControl); //--
except Exit;
end;
if CtrlList = nil then Exit;
if CtrlList.Address = nil then SetCtrlListAddress(CtrlList);
Target := FSelectedItem.Data;
if not ReturnValueToVariable(Target, CtrlList) then begin //--
FCloseQuery := False;
ReturnValueFromTag(CtrlList);
try CtrlList^.Target.SetFocus;
except;
end;
end;
MakeItemCaption(FSelectedItem);
end;
procedure TfrmInvHistory.ControlChange(Sender: TObject);
var CtrlList: PCONTROL_LIST;
lcP: PINVENTORY;
WRID: LongInt;
iBool: Boolean;
begin
if FSelectedItem = nil then Exit;
try CtrlList := GetCtrlListTarget(Sender as TWinControl);
except Exit;
end;
if CtrlList = nil then Exit;
if not FOnUndo then SetUndoBuffer( Sender as TWinControl );
lcP := FSelectedItem.Data;
SetUpdateList(lcP^.REC_ID, CtrlList^.Address, CtrlList^.UpdateIndex, 0, lcP);
//////////////////////////////////
if Sender = edtStkID then
edtStkName.Text := dm_Inventory.GetStockName(trim(edtStkID.Text));
if Sender = edtCode then begin
WRID := dm_Inventory.GetMaterialRID(TEdit(Sender).Text);
edtName.Text := dm_Inventory.GetMaterialName(WRID);
lblUType.Caption := dm_Inventory.GetUnitTypeName(WRID);
//////////////////////////
lcp^.MAT_RID := WRID;
end;
if sender = edtIssGuageID then begin
iBool := dm_Inventory.REC_IDProc(0, edtCode, WRID, -1);
if not(iBool) then Exit;
edtIssGuageName.Text := dm_Inventory.Get_GuageName(WRID,Trunc(edtIssGuageID.Value));
end;
//--
if (Sender=edtUPrice)or(Sender=edtQuantity) then
lblTPrice.Caption := FormatFloat('#,##0.00', UserDecimalDefine(RoundTo(edtUPrice.Value,-2)*RoundTo(edtQuantity.Value,-2)+RoundTo(edtMakePrice.Value,-2),2));
if sender = edtUseQuantity then
lblUseAmount.Caption := FormatFloat('#,##0.00', abs(RoundTo(edtUPrice.Value,-2) * RoundTo(edtUseQuantity.Value,-2) + RoundTo(edtMakePrice.Value,-2)));
if Sender = edtSuplierCode then
lblSupplierNM.Text := dm_Inventory.GetShigenName(Trunc(edtSuplierCode.Value));
if Sender = edtMakerCode then
lblMakerNM.Text := dm_Inventory.GetShigenName(Trunc(edtMakerCode.Value));
if Sender = edtMatOutID then begin
case lcp^.KIND of
0: edtOutIDName.Text := dm_Inventory.Get_IOIDName(trim(edtMatOutID.Text),1);
1: edtOutIDName.Text := dm_Inventory.Get_IOIDName(trim(edtMatOutID.Text),2);
2: edtOutIDName.Text := dm_Inventory.Get_IOIDName(trim(edtMatOutID.Text),3);
3: edtOutIDName.Text := dm_Inventory.Get_IOIDName(trim(edtMatOutID.Text),4);
4: edtOutIDName.Text := GetMultiLingalMsg(90249,'Balance Stock In');
end;
end;
if Sender = edtRecEmpID then
edtRecEmpName.Text := dm_Inventory.Get_EmpName(trim(edtRecEmpID.Text));
if Sender = edtInputEmpID then
edtInputEmpName.Text := dm_Inventory.Get_EmpName(trim(edtInputEmpID.Text));
end;
function TfrmInvHistory.ReturnValueToVariable(Target: Pointer; CtrlList: PCONTROL_LIST): Boolean;
procedure TotalPriceProc(FlgMinus: Boolean);
var View: TINVENTORY;
lcP: PINVENTORY;
begin
lcP := Target;
Double(CtrlList^.Address^):=(CtrlList^.Target as TEx2NumEdit).Value;
if (FlgMinus)and((lcP^.KIND=1)or(lcP^.KIND=2)) then
Double(CtrlList^.Address^):=Double(CtrlList^.Address^) * -1;
case lcp^.KIND of
0: begin
lcp^.USE_QUANTITY := 0;
lcP^.TTL_PRICE := RoundTo(lcP^.UNT_PRICE,-2) * RoundTo(lcP^.QUANTITY,-2)+RoundTo(lcP^.MAK_PRICE,-2);
lblTPrice.Caption := FormatFloat('#,##0.00', Abs(UserDecimalDefine(lcP^.TTL_PRICE,2)));
lcp^.USE_AMOUNT := RoundTo(lcp^.UNT_PRICE,-2) * RoundTo(lcp^.USE_QUANTITY,-2)+RoundTo(lcP^.MAK_PRICE,-2);
lblUseAmount.Caption := FormatFloat('#,##0.00', abs(RoundTo(lcP^.USE_AMOUNT,-2)));
end;
1: begin
lcp^.USE_QUANTITY := lcP^.QUANTITY;
lcP^.TTL_PRICE := RoundTo(lcP^.UNT_PRICE,-2) * RoundTo(lcP^.QUANTITY,-2)+RoundTo(lcP^.MAK_PRICE,-2);
lblTPrice.Caption := FormatFloat('#,##0.00', Abs(UserDecimalDefine(lcP^.TTL_PRICE,2)));
lcp^.USE_AMOUNT := RoundTo(lcp^.UNT_PRICE,-2) * RoundTo(lcp^.USE_QUANTITY,-2)+RoundTo(lcP^.MAK_PRICE,-2);
lblUseAmount.Caption := FormatFloat('#,##0.00', abs(RoundTo(lcP^.USE_AMOUNT,-2)));
end;
2: begin
lcp^.USE_QUANTITY := 0;
lcP^.TTL_PRICE := RoundTo(lcP^.UNT_PRICE,-2) * RoundTo(lcP^.QUANTITY,-2);
lblTPrice.Caption := FormatFloat('#,##0.00', Abs(UserDecimalDefine(lcP^.TTL_PRICE,2)));
lcp^.USE_AMOUNT := RoundTo(lcp^.UNT_PRICE,-2) * RoundTo(lcp^.USE_QUANTITY,-2);
lblUseAmount.Caption := FormatFloat('#,##0.00', abs(RoundTo(lcP^.USE_AMOUNT,-2)));
end;
else begin
lcp^.USE_QUANTITY := 0;
lcP^.TTL_PRICE := RoundTo(lcP^.UNT_PRICE,-2) * RoundTo(lcP^.QUANTITY,-2);
lblTPrice.Caption := FormatFloat('#,##0.00', Abs(UserDecimalDefine(lcP^.TTL_PRICE,-2)));
lcp^.USE_AMOUNT := RoundTo(lcp^.UNT_PRICE,-2) * RoundTo(lcp^.USE_QUANTITY,-2);
lblUseAmount.Caption := FormatFloat('#,##0.00', abs(RoundTo(lcP^.USE_AMOUNT,-2)));
end;
end;
SetUpdateList(lcP^.REC_ID, @lcP^.TTL_PRICE, LongInt(@View.TTL_PRICE)-LongInt(@View), 0, lcP);
SetUpdateList(lcP^.REC_ID, @lcP^.USE_QUANTITY, LongInt(@View.USE_QUANTITY)-LongInt(@View), 0, lcP);
SetUpdateList(lcP^.REC_ID, @lcP^.USE_AMOUNT, LongInt(@View.USE_AMOUNT)-LongInt(@View), 0, lcP);
end;
var View: TINVENTORY;
WDate: TDateTime;
WCD,MatRID,WRID: LongInt;
WTmpStr: string;
lcp: PINVENTORY;
begin
Result := True;
//////////////////////
if CtrlList^.UpdateIndex = Longint(@View.STK_ID)-Longint(@View) then
begin
WTmpStr := (CtrlList^.Target as TCustomEdit).Text;
Result := dm_Inventory.Get_StockCheck(WTmpStr,edtStkName);
if not(Result) then Exit;
StrPCopy(PChar(CtrlList^.Address), WTmpStr);
end else
if CtrlList^.UpdateIndex=Longint(@View.DATE)-Longint(@View) then begin
Result := dm_inventory.DateProc((CtrlList^.Target as TEdit), WDate);
if not(Result) then Exit;
TDateTime(CtrlList^.Address^) := WDate;
end else
if CtrlList^.UpdateIndex = Longint(@View.PAPERNO)-Longint(@View) then
StrPCopy(PChar(CtrlList^.Address), (CtrlList^.Target as TCustomEdit).Text)
else
if CtrlList^.UpdateIndex=Longint(@View.MAT_RID)-Longint(@View) then begin
Result := dm_Inventory.REC_IDProc(0, (CtrlList^.Target as TEdit), WRID, -1);
if not(Result) then Exit;
LongInt(CtrlList^.Address^) := WRID;
MatRID := WRID;
edtName.Text := dm_Inventory.GetMaterialName(WRID);
lblUType.Caption := dm_Inventory.GetUnitTypeName(WRID);
end else
if CtrlList^.UpdateIndex=Longint(@View.MAT_NM)-Longint(@View) then
StrPCopy(PChar(CtrlList^.Address), (CtrlList^.Target as TCustomEdit).Text)
else
if CtrlList^.UpdateIndex = Longint(@View.GUAGE_ID)-Longint(@View) then begin
Result := dm_Inventory.REC_IDProc(0, edtCode, WRID, -1);
if not(Result) then Exit;
MATRID := WRID;
WCD := Trunc((CtrlList^.Target as TEx2NumEdit).Value);
Result := dm_Inventory.Get_GuageCheck(MatRID,WCD, edtIssGuageName);
if not(Result) then Exit;
LongInt(CtrlList^.Address^) := WCD;
end else
if CtrlList^.UpdateIndex=Longint(@View.UNT_PRICE)-Longint(@View) then
TotalPriceProc(False)
else
if CtrlList^.UpdateIndex=Longint(@View.QUANTITY)-Longint(@View) then
TotalPriceProc(True)
else
if CtrlList^.UpdateIndex=Longint(@View.MAK_PRICE)-Longint(@View) then
TotalPriceProc(false)
else
if CtrlList^.UpdateIndex = Longint(@View.USE_GUAGE)-Longint(@View) then
StrPCopy(PChar(CtrlList^.Address), (CtrlList^.Target as TCustomEdit).Text)
else
if CtrlList^.UpdateIndex = Longint(@View.USE_QUANTITY)-Longint(@View) then
begin
if abs(lcp^.USE_QUANTITY) > abs(lcp^.QUANTITY) then begin
MessageDlg('Use Quantity > Out Quantity',mtError,[mbOK],0);
exit;
end else TotalPriceProc(true);
end
else
if CtrlList^.UpdateIndex=Longint(@View.ODR_RID)-Longint(@View) then begin
Result := dm_Inventory.REC_IDProc(1, (CtrlList^.Target as TEdit), WRID, -1);
if not(Result) then Exit;
LongInt(CtrlList^.Address^) := WRID;
end else
if CtrlList^.UpdateIndex=Longint(@View.PAT_RID)-Longint(@View) then begin
Result := dm_Inventory.REC_IDProc(2, (CtrlList^.Target as TEdit), WRID, lcP^.ODR_RID);
if not(Result) then Exit;
LongInt(CtrlList^.Address^) := WRID;
end else //--
if CtrlList^.UpdateIndex=Longint(@View.HAT_RID)-Longint(@View) then begin
Result := dm_Inventory.REC_IDProc(3, (CtrlList^.Target as TEdit), WRID, -1);
if not(Result) then Exit;
if WRID <0 then WRID := 0;
LongInt(CtrlList^.Address^) := WRID;
end else
if CtrlList^.UpdateIndex=Longint(@View.HAT_CODE)-Longint(@View) then
StrPCopy(PChar(CtrlList^.Address), (CtrlList^.Target as TCustomEdit).Text)
else
if CtrlList^.UpdateIndex = Longint(@View.SUP_CD)-Longint(@View) then begin
WCD := Trunc((CtrlList^.Target as TEx2NumEdit).Value);
Result := dm_Inventory.MasterProc(WCD, lblSupplierNM);
if not(Result) then Exit;
LongInt(CtrlList^.Address^) := WCD;
end else
if CtrlList^.UpdateIndex = Longint(@View.MAK_CD)-Longint(@View) then begin
WCD := Trunc((CtrlList^.Target as TEx2NumEdit).Value);
Result := dm_Inventory.MasterProc(WCD, lblMakerNM);
if not(Result) then Exit;
LongInt(CtrlList^.Address^) := WCD;
end else
if CtrlList^.UpdateIndex = Longint(@View.Inout_id)-Longint(@View) then
begin
WTmpStr := (CtrlList^.Target as TCustomEdit).Text;
case lcp^.KIND of
0: Result := dm_Inventory.InOut_IDProc(WTmpStr,1, edtOutIDName);
1: Result := dm_Inventory.InOut_IDProc(WTmpStr,2, edtOutIDName);
2: Result := dm_Inventory.InOut_IDProc(WTmpStr,3, edtOutIDName);
3: Result := dm_Inventory.InOut_IDProc(WTmpStr,4, edtOutIDName);
4: Result := true;
end;
if not(Result) then Exit;
StrPCopy(PChar(CtrlList^.Address), WTmpStr)
end else
if CtrlList^.UpdateIndex=Longint(@View.RECIEVE_EMPID)-Longint(@View) then
begin
WTmpStr := (CtrlList^.Target as TCustomEdit).Text;
Result := dm_Inventory.Emp_IDProc(WTmpStr, edtRecEmpName);
if not(Result) then Exit;
StrPCopy(PChar(CtrlList^.Address), WTmpStr)
end else
if CtrlList^.UpdateIndex=Longint(@View.input_empid)-Longint(@View) then
begin
WTmpStr := (CtrlList^.Target as TCustomEdit).Text;
Result := dm_Inventory.Emp_IDProc(WTmpStr, edtInputEmpName);
if not(Result) then Exit;
StrPCopy(PChar(CtrlList^.Address), WTmpStr)
end else
if CtrlList^.UpdateIndex=Longint(@View.invoice_no)-Longint(@View) then
StrPCopy(PChar(CtrlList^.Address), (CtrlList^.Target as TCustomEdit).Text)
else
if CtrlList^.UpdateIndex=Longint(@View.ISS_PAPERNO)-Longint(@View) then
StrPCopy(PChar(CtrlList^.Address), (CtrlList^.Target as TCustomEdit).Text)
else
if CtrlList^.UpdateIndex=Longint(@View.SEQUAL_NO)-Longint(@View) then
StrPCopy(PChar(CtrlList^.Address), (CtrlList^.Target as TCustomEdit).Text)
else
if CtrlList^.UpdateIndex = Longint(@View.NOTE)-Longint(@View) then
StrPCopy(PChar(CtrlList^.Address), (CtrlList^.Target as TCustomEdit).Text);
end;
procedure TfrmInvHistory.SetData(Item: Pointer);
var lcP: PINVENTORY;
EnablFlg: Boolean;
begin
lcP := Item;
if (Item=nil) then begin
SetNull;
Exit;
end;
case lcP^.KIND of
0: lblKind.Caption := GetMultiLingalMsg(90104, 'In');
1: lblKind.Caption := GetMultiLingalMsg(90105, 'Out');
2: lblKind.Caption := GetMultiLingalMsg(90098, 'Return');
3: lblKind.Caption := GetMultiLingalMsg(90099, 'Tune');
4: lblKind.Caption := GetMultiLingalMsg(90248,'Balance')
else lblKind.Caption := '';
end;
edtStkID.Text := lcp^.STK_ID;
edtStkName.Text := dm_inventory.GetStockName(edtStkID.Text);
edtDate.Text := FormatDateTime('yy/mm/dd', lcP^.DATE);
edtPaperNo.Text := lcp^.PAPERNO;
edtCode.Text := dm_inventory.GetMaterialCode(lcP^.MAT_RID);
edtName.Text := lcP^.MAT_NM;
edtIssGuageID.Value := lcp^.GUAGE_ID;
edtIssGuageName.Text := dm_inventory.Get_GuageName(lcp^.MAT_RID,lcp^.GUAGE_ID);
edtUPrice.Value := RoundTo(lcP^.UNT_PRICE,-2);
edtQuantity.Value := Abs(RoundTo(lcP^.QUANTITY,-2));
edtMakePrice.Value := abs(RoundTo(lcp^.MAK_PRICE,-2));
lblUType.Caption := dm_inventory.GetUnitTypeName(lcp^.MAT_RID);
lblTPrice.Caption := FormatFloat('#,##0.00', Abs(UserDecimalDefine(lcP^.TTL_PRICE,2)));
edtUseGuageName.Text := lcp^.USE_GUAGE;
if lcp^.KIND = 3 then
edtUseQuantity.Value := RoundTo(lcp^.USE_QUANTITY,-2)
else
edtUseQuantity.Value := abs(RoundTo(lcp^.USE_QUANTITY,-2));
lblUseAmount.Caption := FormatFloat('#,##0.00', Abs(RoundTo(lcP^.USE_AMOUNT,-2)));
if lcP^.HAT_RID <= 0 then edtOrderSerial.Text := ''
else edtOrderSerial.Text := Format('%d', [lcP^.HAT_RID]);
edtHatCode.Text := lcp^.HAT_CODE;
edtMoldID.Text := dm_inventory.GetOrderNo(lcp^.ODR_RID);
edtPartID.Text := dm_inventory.GetPartCode(lcp^.ODR_RID,lcp^.PAT_RID);
edtSequalNo.Text := lcp^.SEQUAL_NO;
edtSuplierCode.Value := lcp^.SUP_CD;
lblSupplierNM.Text := dm_inventory.GetShigenName(lcp^.SUP_CD);
edtMakerCode.Value := lcp^.MAK_CD;
lblMakerNM.Text := dm_inventory.GetShigenName(lcp^.MAK_CD);
edtMatOutID.Text := lcp^.INOUT_ID;
case lcp^.KIND of
0: edtOutIDName.Text := dm_Inventory.Get_IOIDName(trim(edtMatOutID.Text),1);
1: edtOutIDName.Text := dm_Inventory.Get_IOIDName(trim(edtMatOutID.Text),2);
2: edtOutIDName.Text := dm_Inventory.Get_IOIDName(trim(edtMatOutID.Text),3);
3: edtOutIDName.Text := dm_Inventory.Get_IOIDName(trim(edtMatOutID.Text),4);
4: edtOutIDName.Text := GetMultiLingalMsg(90249,'Balance Stock In');
end;
edtRecEmpID.Text := lcP^.recieve_EmpID;
edtRecEmpName.Text := dm_Inventory.Get_EmpName(trim(edtRecEmpID.Text));
edtInputEmpID.Text := lcP^.input_empid;
edtInputEmpName.Text := dm_Inventory.Get_EmpName(trim(edtInputEmpID.Text));
edtInvoiceNo.Text := lcp^.invoice_no;
edtIssPaper.Text := lcp^.ISS_PAPERNO;
edtNote.Text := lcp^.NOTE;
EnablFlg := True;
if EnablFlg then
begin
if frmMain.IniData.isTuneQty then Set_EditReadOnly((1<>1),lcp^.KIND, lcp^.IS_ACCOUNT, lcp^.IS_CLOSE)
else Set_EditReadOnly((1=1),lcp^.KIND, lcp^.IS_ACCOUNT, lcp^.IS_CLOSE);
{
if lcP^.KIND = 0 then btnReturnGoods.Enabled := true
else btnReturnGoods.Enabled := False; }
end;
end;
procedure TfrmInvHistory.SetNull;
begin
FSelectedItem := nil;
lblKind.Caption := '';
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -