📄 unitly.~pas
字号:
edtzdr.text:=frmMain.StrOperat;
dtpLy.Date:=now;
with ADOQuery_sql do
begin
//添加部门代码
close;
sql.clear;
sql.add('select * from Department order by Dept_id');
open;
setlength(listDept,recordcount);
setlength(listDeptName,recordcount);
cbbDept.Items.clear;
for i:=0 to recordcount - 1 do
begin
listDept[i]:=fieldbyname('Dept_id').asstring;
listDeptName[i]:=fieldbyname('Dept_name').asstring;
cbbDept.items.Add(listDept[i]+' '+listDeptName[i]);
next;
end;
//添加库房代码
close;
sql.clear;
sql.add('select * from StoreRoom order by Storeroom_zip');
open;
setlength(listKf,recordcount);
setlength(listKfmc,recordcount);
cbbKf.Items.clear;
for i:=0 to recordcount - 1 do
begin
listKf[i]:=fieldbyname('Storeroom_zip').asstring;
listKfmc[i]:=fieldbyname('Storeroom_name').asstring;
cbbKf.items.Add(listKf[i]+' '+listKfmc[i]);
next;
end;
end;
end;
procedure TfrmLy.edtCkdhKeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then
begin
key:=#0;
perform(cm_dialogkey,vk_tab,0);
end;
end;
procedure TfrmLy.edtBzKeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then
begin
key:=#0;
btnSave.setfocus;
end;
end;
procedure TfrmLy.FormShow(Sender: TObject);
var
str:string;
begin
str:=' select a.Xh,a.Ly_Bill,a.Plan_id, '+
' a.Mate_Code,b.Mate_Name,b.Mate_Type, '+
' a.Dept_id,a.Out_Date, '+
' a.KfNo,a.KwNo,a.Out_Type,a.Out_Amount,a.Out_Price,a.Out_Zj,a.Out_Post, '+
' b.Stoc_Amount,b.Mate_TotalPrice, '+
' a.Checker,a.Out_man,a.Oper_id,a.Out_memo '+
' from Mate_Ly a '+
' left outer join Mate_Basic b on a.Mate_Code=b.Mate_Code order by a.Xh ';
with dm.qry_Ly do
begin
close;
sql.clear;
sql.add(str);
open;
end;
end;
procedure TfrmLy.cbbKfExit(Sender: TObject);
var
i:integer;
begin
if cbbkf.text='' then begin
cbbKw.items.Clear;
cbbKw.Text:='';
exit;
end;
if btnCancel.Focused then
begin
btnCancel.onclick(sender);
exit;
end;
if btnClose.focused then
begin
btnClose.OnClick(Sender);
exit;
end;
//
with ADOQuery_sql do
begin
close;
sql.clear;
sql.add('select * from Storeposition where Storeroom_zip='+quotedstr(copy(cbbkf.text,1,2)));
sql.add('order by StorePlace_zip');
open;
setlength(listKw,recordcount);
cbbKw.Items.clear;
for i:=0 to recordcount - 1 do
begin
listKw[i]:=fieldbyname('Storeplace_zip').asstring;
cbbKw.items.Add(listKw[i]+' '+fieldbyname('Storeplace_name').asstring);
next;
end;
end;
end;
procedure TfrmLy.edtWlbmExit(Sender: TObject);
begin
if btnCancel.Focused then
begin
btnCancel.onclick(sender);
exit;
end;
if btnClose.focused then
begin
btnClose.OnClick(Sender);
exit;
end;
//
with ADOQuery_sql do
begin
close;
sql.Clear;
sql.Add('select * from mate_basic where (mate_code='''+trim(edtWlbm.text)+''') and (mate_class between ''101'' and ''606'') or (mate_class like ''CCC'' )');
Open;
end;
if ADOQuery_sql.recordcount>0 then
begin
edtWlmc.text:=trim(ADOQuery_sql.fieldByName('Mate_Name').asstring);
edtType.text:=trim(ADOQuery_sql.fieldByName('Mate_Type').asstring);
edtPrice.text:=trim(ADOQuery_sql.fieldByName('Mate_Price').asstring);
edtStockNum.text:=trim(ADOQuery_sql.fieldByName('Stoc_Amount').asstring);
edtStockZJ.text:=trim(ADOQuery_sql.fieldByName('Mate_TotalPrice').asstring);
end else
begin
application.messagebox(' 基础物料中不存在该物料编码, '#13#10'请重新输入!','提示',mb_ok+mb_iconwarning);
edtWlbm.text:='';
edtWlbm.setfocus;
exit;
end;
end;
procedure TfrmLy.edtNumExit(Sender: TObject);
begin
edtTotalPrice.text:=FloatToStr(StrToFloat(edtNum.text)*StrToFloat(edtPrice.text));
edtTotalPrice.enabled:=false;
edtTotalPrice.color:=clInfoBk;
end;
procedure TfrmLy.dsLyDataChange(Sender: TObject; Field: TField);
var
str:string;
i:integer;
begin
//----------Gys -----------Dept_id
edtCkdh.text:=dm.qry_Ly.fieldbyname('Ly_Bill').asstring;
edtJhbh.text:=dm.qry_Ly.fieldbyname('Plan_id').asstring;
edtwlbm.text:=dm.qry_Ly.fieldbyname('Mate_Code').asstring;
edtWlmc.text:=dm.qry_Ly.fieldbyname('Mate_Name').asstring;
edtType.text:=dm.qry_Ly.fieldbyname('Mate_Type').asstring;
if dm.qry_Ly.fieldbyname('Out_Date').IsNull then
dtpLy.Date:=now
else
dtpLy.date:=dm.qry_Ly.fieldbyname('Out_Date').asdatetime;
edtStockNum.text:=dm.qry_Ly.fieldbyname('Stoc_Amount').asstring;
edtStockZJ.text:=dm.qry_Ly.fieldbyname('Mate_TotalPrice').asstring;
edtNum.text:=dm.qry_Ly.fieldbyname('Out_Amount').asstring;
edtPrice.text:=dm.qry_Ly.fieldbyname('Out_Price').asstring;
edtTotalPrice.text:=dm.qry_Ly.fieldbyname('Out_Zj').asstring;
edtSpr.text:=dm.qry_Ly.fieldbyname('Checker').asstring;
edtLyr.text:=dm.qry_Ly.fieldbyname('Out_man').asstring;
edtZdr.text:=dm.qry_Ly.fieldbyname('Oper_id').asstring;
edtBz.text:=dm.qry_Ly.fieldbyname('Out_Memo').asstring;
//---------部门-----------------------
cbbDept.itemindex:=-1;
str:=DM.qry_Ly.FieldByName('Dept_id').asstring;
if high(listDept)>=0 then
begin
for i:=0 to high(listDept) do
begin
if listDept[i]=str then
begin
cbbDept.itemindex:=i;
break;
end;
end;
end;
//---------库房-----------------------
cbbKf.itemindex:=-1;
str:=DM.qry_Ly.FieldByName('KfNo').asstring;
if high(listKf)>=0 then
begin
for i:=0 to high(listKf) do
begin
if listKf[i]=str then
begin
cbbKf.itemindex:=i;
break;
end;
end;
end;
//---------库位-----------------------
cbbKw.itemindex:=-1;
str:=DM.qry_Ly.FieldByName('KwNo').asstring;
if high(listKw)>=0 then
begin
for i:=0 to high(listKw) do
begin
if listKw[i]=str then
begin
cbbKw.itemindex:=i;
break;
end;
end;
end;
//
//库存数量、库存总价--这里的代码影响基础物料打开后的数据显示
{ with ADOQuery_sql do
begin
close;
sql.Clear;
sql.Add('select * from mate_basic where mate_code='''+trim(edtWlbm.text)+''' ');
open;
end;
if ADOQuery_sql.RecordCount>0 then
begin
edtStockNum.text:=ADOQuery_sql.fieldbyname('Stoc_Amount').asstring;
edtStockZJ.text:=ADOQuery_sql.fieldbyname('Mate_TotalPrice').asstring;
end; }
end;
procedure TfrmLy.btnGzClick(Sender: TObject);
var
seltotal,i:integer;
myprocess:Tfrmprocess;
begin
//根据入库单号、入库标志可直接判断出该单据是否已经过帐
with dm.qry_LyGz do
begin
close;
sql.Clear;
sql.Add('select * from Mate_Ly where (Ly_bill='''+trim(edtCkdh.text)+''') and (Out_post=''Y'') ');
open;
end;
if dm.qry_LyGz.recordcount>0 then
begin
application.MessageBox('该单据已经过帐!','警告',mb_ok+mb_iconwarning);
exit;
end else //下面是没有过帐
begin
//用1个存储过程进行过帐,更新对应的入库单号的数量、核算价格、和入库单的过帐标志
if not btnadd.Enabled then
begin
application.MessageBox('注意:'+#13#10+' 请先保存或取消当前未完成的工作!','警告',mb_ok+mb_iconwarning);
exit;
end;
seltotal:=DBGrid1.SelectedRows.Count;
if seltotal=0 then
begin
application.MessageBox('注意:'+#13#10+' 请先选择要过帐的单据记录!','提示',mb_ok+mb_iconinformation);
exit;
end else//选项不为空
begin
//显示进度条
myprocess:=Tfrmprocess.create(application);
try
myprocess.show;
myprocess.setposition(0);
//获得选中的记录
for i:=0 to seltotal - 1 do
begin
DM.qry_Ly.Bookmark:=DBGrid1.SelectedRows.Items[i];
//-------------------过帐--------------------------
with dm.sp_LyGz do
begin
dm.sp_LyGz.ProcedureName:='Ly_CkGz;1';
Parameters.Refresh;
Parameters.ParamByName('@Ckdh').value:=edtCkdh.Text;
ExecProc;
end;
myprocess.closeprocess;
DBGrid1.SelectedRows.Clear;
DM.qry_Ly.close;
DM.qry_Ly.open;
application.MessageBox('所选出库单已全部过帐成功!!','提示',mb_ok+mb_iconinformation);
end ;//end for
finally
myprocess.Free;
end; //end try
end;
end;
dm.qry_Ly.Close;
dm.qry_Ly.Open;
end;
procedure TfrmLy.sbtncodeClick(Sender: TObject);
begin
frmSelectCodeNameType:=TfrmSelectCodeNameType.create(self);
frmSelectCodeNameType.show;
end;
procedure TfrmLy.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
if trim(dm.qry_Ly.FieldByName('Out_Post').AsString)='N' then
begin
DBGrid1.Canvas.Font.Color:=clGreen;
DBGrid1.DefaultDrawColumnCell(Rect,DataCol,Column,State);
end;
//以突出显示当前选中的行
if ((state=[gdSelected]) or (State=[gdSelected,gdFocused])) then
begin
DBGrid1.Canvas.Brush.Color:=clSkyBlue;
DBGrid1.Canvas.Pen.Mode:=pmmask;
DBGrid1.DefaultDrawColumnCell(Rect,DataCol,Column,State);
end;
end;
procedure TfrmLy.edtCkdhExit(Sender: TObject);
begin
if dm.qry_Ly.Locate('Out_Bill',edtCkdh.text ,[loCaseInsensitive]) then
begin
application.MessageBox('注意:'+#13+' 领料单号重复,请重新输入!','警告',mb_ok+mb_iconwarning);
edtCkdh.text:='';
clear(frmLy);
edtCkdh.SetFocus;
exit;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -