📄 outform.pas
字号:
unit outForm;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, FR_E_HTML2, FR_E_CSV, FR_E_RTF, frexpimg, frOLEExl, FR_Class,
FR_E_TXT, FR_DSet, FR_DBSet, DB, ADODB, StdCtrls, DBCtrls, DBCtrlsEh,
Mask, Buttons, Grids, DBGrids;
type
TstockOut = class(TForm)
grp1: TGroupBox;
grp2: TGroupBox;
dbgrd1: TDBGrid;
grp3: TGroupBox;
Label1: TLabel;
add: TBitBtn;
BitBtn2: TBitBtn;
BitBtn3: TBitBtn;
savebtn: TBitBtn;
canbtn: TBitBtn;
BitBtn7: TBitBtn;
BitBtn8: TBitBtn;
BitBtn9: TBitBtn;
BitBtn10: TBitBtn;
grp4: TGroupBox;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
Label11: TLabel;
Label12: TLabel;
Label13: TLabel;
Label14: TLabel;
Label16: TLabel;
Label17: TLabel;
DBEdit1: TDBEdit;
DBEdit5: TDBEdit;
dbqty: TDBEdit;
DBEdit8: TDBEdit;
DBEdit11: TDBEdit;
DBEdit12: TDBEdit;
DBEdit13: TDBEdit;
dbdate: TDBDateTimeEditEh;
DBEdit10: TDBEdit;
DBEdit15: TDBEdit;
Adoconstractoutput: TADOQuery;
constractoutput_ds: TDataSource;
stock_rpt: TfrReport;
frDBDataSet1: TfrDBDataSet;
frTextExport1: TfrTextExport;
frOLEExcelExport1: TfrOLEExcelExport;
frJPEGExport1: TfrJPEGExport;
frRTFExport1: TfrRTFExport;
frCSVExport1: TfrCSVExport;
frHTML2Export1: TfrHTML2Export;
comb_product: TDBComboBox;
product_name: TDBEdit;
dbmoney: TDBComboBox;
ADO_Product: TADOTable;
ADO_money: TADOTable;
ADO_unit: TADOTable;
dbunit: TDBComboBox;
Label15: TLabel;
ado_temp: TADOQuery;
Ado_Mtr_updt: TADOQuery;
Ado_Mtr_Updt_BOM: TADOQuery;
Mtr_check: TADOQuery;
ADO_ProductfParentID: TWideStringField;
ADO_unitfUnitCode: TWideStringField;
ADO_unitfbaseUnits: TWideStringField;
ADO_moneyfMoneyCode: TWideStringField;
RefUnit: TDBComboBox;
out_put: TfrReport;
dataset_stock: TfrDBDataSet;
Ado_stock: TADOQuery;
ds_stock: TDataSource;
weightUnit: TDBEdit;
measureunit: TDBEdit;
stocktxt: TLabel;
outputtxt: TLabel;
stocktxt2: TLabel;
outputtxt2: TLabel;
stock_ado: TADOQuery;
QProducts: TADOQuery;
updtostockin: TADOQuery;
updtostock: TADOQuery;
procedure addClick(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure savebtnClick(Sender: TObject);
procedure BitBtn3Click(Sender: TObject);
procedure canbtnClick(Sender: TObject);
procedure BitBtn10Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure comb_productChange(Sender: TObject);
procedure AdoconstractoutputAfterPost(DataSet: TDataSet);
procedure AdoconstractoutputBeforePost(DataSet: TDataSet);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;
var
stockOut: TstockOut;
implementation
uses MainFm;
{$R *.dfm}
procedure TstockOut.addClick(Sender: TObject);
begin
Adoconstractoutput.Append;
savebtn.Enabled:=true;
dbdate.Value:=now();
add.Enabled:=False;
canbtn.Enabled:=true;
end;
procedure TstockOut.BitBtn2Click(Sender: TObject);
begin
if messagebox(Handle,PChar('sure to delete?'),'warning',mb_iconwarning+mb_yesno)=IDYES then
Adoconstractoutput.Delete;
end;
procedure TstockOut.savebtnClick(Sender: TObject);
begin //check the stock if not exist the product then msg can't continue
// if spGetProducts.Locate('fID',(Sender as TField).AsInteger,[]) then
// QDetail.FieldByName('fTotalQty').AsFloat := spGetProducts.fieldbyName('rSumQty').AsFloat;
//if QProducts.Locate('fID',(Sender as TField).AsInteger,[]) then
// QDetail.FieldByName('fPrePrice').AsFloat := QProducts.fieldbyName('fPrePrice').AsFloat
// else
// Raise Exception.Create('无此产品!')
with stock_ado do
stock_ado.Close;
stock_ado.SQL.Clear;
stock_ado.sql.Text:='select fweightqty,fmeasureqty,fmeasureUnit,fweightUnit from tContractstock where fProductID like '+''''+ Adoconstractoutput.fieldbyname('fProductID').AsString+'''';
stock_ado.Open;
stocktxt.Caption:='库存量:'+stock_ado.fieldbyname('fmeasureqty').AsString;
stocktxt2.Caption:='库重量'+ stock_ado.fieldbyname('fweightqty').AsString;
outputtxt.Caption:='出库量:'+Adoconstractoutput.fieldbyname('fmeasureqty').AsString;
outputtxt2.Caption:='出库重'+ Adoconstractoutput.fieldbyname('fweightqty').AsString;
if (trim(comb_product.Text)<>'') and (trim(product_name.text)<>'') and (trim(dbqty.text)<>'') and (trim(measureunit.text)<>'') then
begin
if stock_ado.fieldbyname('fmeasureqty').AsVariant<Adoconstractoutput.fieldbyname('fmeasureqty').AsVariant then
begin
showmessage('注:库存量不够!现该产品库存量只:'+stocktxt.Caption+stock_ado.fieldbyname('fmeasureUnit').AsString);
// showmessage(stocktxt.Caption);
if messagebox(Handle,PChar('sure to save?'),'warning',mb_iconwarning+mb_yesno)=IDYES then
begin
Adoconstractoutput.Post;
savebtn.Enabled:=false;
add.Enabled:=true;
canbtn.Enabled:=true;
end;
end
else
begin
// showmessage('measuer save successed!');
Adoconstractoutput.Post;
savebtn.Enabled:=false;
add.Enabled:=true;
end;
if stock_ado.fieldbyname('fweightqty').AsVariant<Adoconstractoutput.fieldbyname('fweightqty').AsVariant then
begin
showmessage('注:库存量不够!现该产品库存量只:'+stocktxt2.Caption+stock_ado.fieldbyname('fweightUnit').AsString);
// showmessage(stocktxt.Caption);
if messagebox(Handle,PChar('sure to save?'),'warning',mb_iconwarning+mb_yesno)=IDYES then
begin
// Adoconstractoutput.Post;
savebtn.Enabled:=false;
add.Enabled:=true;
end;
end
else
begin
// showmessage('weight save successed!');
// Adoconstractoutput.Post;
savebtn.Enabled:=false;
add.Enabled:=true;
end;
end
else
begin
showmessage('please check the information if intact');
end;
end;
procedure TstockOut.BitBtn3Click(Sender: TObject);
begin
Adoconstractoutput.Edit;
savebtn.Enabled:=true;
canbtn.Enabled:=true;
end;
procedure TstockOut.canbtnClick(Sender: TObject);
begin
Adoconstractoutput.Cancel;
end;
procedure TstockOut.BitBtn10Click(Sender: TObject);
begin
out_put.ShowReport;
end;
procedure TstockOut.FormCreate(Sender: TObject);
var i:integer;
begin
with ado_product do
if ado_product.RecordCount>0 then
begin
ado_product.first;
for i:=0 to ado_product.RecordCount-1 do
begin
comb_product.Items.Add(ado_product.fieldbyname('fParentID').AsString);
ado_product.Next;
end;
end;
with ado_unit do
if ado_unit.RecordCount>0 then
begin
ado_unit.First;
for i:=0 to ado_unit.RecordCount-1 do
begin
dbunit.Items.Add(ado_unit.fieldbyname('fUnitCode').AsString);
refunit.Items.Add(ado_unit.fieldbyname('fbaseUnits').AsString);
ado_unit.Next;
end;
end;
with ado_money do
if ado_money.RecordCount>0 then
begin
ado_money.First;
for i:=0 to ado_money.RecordCount-1 do
begin
dbmoney.Items.Add(ado_money.fieldbyname('fMoneyCode').AsString);
ado_money.Next;
end;
end;
end;
procedure TstockOut.comb_productChange(Sender: TObject);
begin
with ado_temp do
ado_temp.Close;
ado_temp.SQL.Clear; //check the product from the tcontractstock then ok
ado_temp.SQL.Add('select fParentName,fMeasureUnit,fWeightUnit from tProductCode where fParentID like '''+'%'+comb_product.Text+'%'+'''');
ado_temp.open;
// edit1.Text:=ado_temp.SQL.text;
product_name.Text:=ado_temp.fieldbyname('fParentName').AsString;
dbunit.Items.Text:=ado_temp.fieldbyname('fMeasureUnit').AsString;
RefUnit.Items.Text:=ado_temp.fieldbyname('fWeightUnit').AsString;
measureunit.Text:=ado_temp.fieldbyname('fMeasureUnit').AsString;
weightUnit.Text:=ado_temp.fieldbyname('fWeightUnit').AsString;
//end;
end;
procedure TstockOut.AdoconstractoutputAfterPost(DataSet: TDataSet);
begin //updtMtrQtybyBOM update the tMaterialOutput table after the tcontractoutput reference BOM
with ado_temp do
begin
ado_temp.Close; //update tContractOutput record and update the tContractstock
ado_temp.Prepared:=false;
ado_temp.SQL.Text:='updtStockQtybyOutput'+ ''''+Adoconstractoutput.fieldbyname('fProductID').AsString+'''';
// QStorage.Close;
// QStorage.Prepared:=False;
// QStorage.SQL.Text:='updtStockQtybyInput'+ ''''+adoconstractinput.fieldbyname('fProductID').AsString+'''';
// QStorage.Parameters.ParamByName('@fProduct').Value:=
// AdoconstractInput.fieldbyname('fProductID').AsString;
ado_temp.Prepared:=True;
ado_temp.ExecSQL;
end;
// with updtostockin do //the procedure is wrong, just update that by the stock in
// begin //and trim by the output then ok
// updtostockin.Close;
// updtostockin.Prepared:=false;
// updtostockin.SQL.Text:='updtStockINbyOutInput'+''''+Adoconstractoutput.fieldbyname('fProductID').AsString+'''';
// updtostockin.Prepared:=true;
// updtostockin.ExecSQL;
// end;
with updtostock do
begin
updtostock.Close;
updtostock.Prepared:=false;
updtostock.SQL.Text:='updtProductStockbyOutput'+''''+Adoconstractoutput.fieldbyname('fProductID').AsString+'''';
updtostock.Prepared:=true;
updtostock.execSQL;
end;
end;
procedure TstockOut.AdoconstractoutputBeforePost(DataSet: TDataSet);
begin
if QProducts.Locate('fProductID',Adoconstractoutput.fieldbyname('fProductID').AsString,[]) then
begin
// QDetail.FieldByName('fPrePrice').AsFloat := QProducts.fieldbyName('fPrePrice').AsFloat
with ado_temp do
ado_temp.Close;
ado_temp.SQL.Clear;
ado_temp.sql.Text:='select fweightqty,fmeasureqty,fmeasureUnit,fweightUnit from tContractstock where fProductID like '+''''+ Adoconstractoutput.fieldbyname('fProductID').AsString+'''';
Ado_temp.Open;
stocktxt.Caption:='库存量:'+ado_temp.fieldbyname('fmeasureqty').AsString;
stocktxt2.Caption:='库重量:'+ ado_temp.fieldbyname('fweightqty').AsString;
outputtxt.Caption:='出库量:'+Adoconstractoutput.fieldbyname('fmeasureqty').AsString;
outputtxt2.Caption:='出库重:'+ Adoconstractoutput.fieldbyname('fweightqty').AsString;
if ado_temp.fieldbyname('fmeasureqty').AsVariant<Adoconstractoutput.fieldbyname('fmeasureqty').AsVariant then
begin
// showmessage('注:库存量不够!现该产品库存量只:'+stocktxt.Caption+ado_temp.fieldbyname('fmeasureUnit').AsString);
// showmessage(stocktxt.Caption);
end
else
showmessage('measuer save successed!');
if ado_temp.fieldbyname('fweightqty').AsVariant<Adoconstractoutput.fieldbyname('fweightqty').AsVariant then
begin
// showmessage('注:库存量不够!现该产品库存量只:'+stocktxt2.Caption+ado_temp.fieldbyname('fweightUnit').AsString);
// showmessage(stocktxt.Caption);
end
else
showmessage('weight save successed!')
end
else
begin
Raise Exception.Create('成品库存中无此产品库存,请确认资料之准确性!');
comb_product.SetFocus;
end;
end;
procedure TstockOut.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if Adoconstractoutput.State in [dsInsert,dsEdit] then
// if Ado_Material.Modified then
begin
if MessageBox(Handle, PChar('数据未保存,确定要退出吗?'), MsgQst, Msg2YNWARN) = IDYES then
// if MessageBox(Handle,pchar('warning'),mB_iconQuestion,mb_YESNO)=IDyes then
// self.Hide;
Action:=caHide
// end
else
Action:=caNone;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -