📄 fm_overflow.pas
字号:
begin
if sgorder.Cells[4,prow]<>'' then
begin
sgorder.Cells[7,prow]:=floattostrf(strtofloat(sgorder.Cells[3,prow])* strtofloat(sgorder.Cells[4,prow]),ffFixed,11,2); //无折扣单价
end ;
end else
begin
sgorder.Cells[7,prow]:='0';
end;
end;
//汇总计算
TotalCount;
end;
procedure TfmOverflow.btnSaveClick(Sender: TObject);
var
i,j:integer;
sql,temp:widestring;
begin
inherited;
if (trim(cmbg.Text)='') or (trim(cmbc.Text)='') then
begin
application.MessageBox('请选择报损经手人或审核人!',pchar(application.Title),mb_iconinformation);
cmbg.SetFocus;
exit;
end;
if trim(sgorder.Cells[1,1])='' then
begin
application.MessageBox('请选择报损商品明细!',pchar(application.Title),mb_iconinformation);
exit;
end;
if Public_Do='Overflow_0001' then
begin
dmmain.cdsOverflow.Insert;
dmmain.cdsOverflow.FieldByName('o_code').AsString:=trim(edtcode.Text );
dmmain.cdsOverflow.FieldByName('o_shop').AsString:=trim(Handle_Part);//修改 5-19
dmmain.cdsOverflow.FieldByName('o_newdate').AsString:=formatdatetime('yyyy''-''mm''-''dd',date);
dmmain.cdsOverflow.FieldByName('o_newman').AsString:=trim(edtnewmen.Text );
dmmain.cdsOverflow.FieldByName('o_remark').AsString:=trim(edtremakt.Text);
dmmain.cdsOverflow.FieldByName('o_operater').AsString:=trim(cmbg.Text);
dmmain.cdsOverflow.FieldByName('o_auditer').AsString:=trim(cmbc.Text);
////////add auditer//////////////////////
dmmain.cdsOverflow.FieldByName('o_state').AsString:='0';
/////////////////////////////////////////
dmmain.cdsOverflow.Post;
j:=sgorder.RowCount-1;
for i:=1 to j do
begin
with dmmain.cdsOverflowdetail do
begin
insert;
fieldbyname('od_ocode').AsString:=trim(edtcode.Text);
fieldbyname('od_ccode').AsString:=trim(sgorder.Cells[1,i]);
fieldbyname('od_cname').AsString:=trim(sgorder.Cells[2,i]);
fieldbyname('od_ccount').AsString:=trim(sgorder.Cells[4,i]);
post;
end;
end;
dmmain.cdsReceipt.Close;
dmmain.cdsReceipt.Open;
dmmain.cdsReceipt.Append;
dmmain.cdsReceipt.FieldByName('Receipt_NO').AsString:=Trim(Edtcode.Text);
dmmain.cdsReceipt.FieldByName('Receipt_Name').AsString:='库存报溢单';
dmmain.cdsReceipt.FieldByName('Copy_Date').AsString:=Trim(Edtnewdate.Text);
dmmain.cdsReceipt.FieldByName('Proposer').AsString:=Trim(edtnewmen.Text);
dmmain.cdsReceipt.FieldByName('Check_Result').Asinteger:=0;
dmmain.cdsReceipt.FieldByName('Flag_Sign').AsString:='草稿';
dmmain.cdsReceipt.FieldByName('Condense').AsString:=Trim(edtremakt.Text);
dmmain.cdsReceipt.FieldByName('Re_part').AsString:=trim(Handle_Part);
dmmain.cdsReceipt.Post;
try
if flag='2' then
begin
sql:='update dp_checkdetail set cd_state='+''''+'5'+''''+' where cd_ccount>0 and cd_state='+''''+'1'+''''+' and cd_checkcode in (select c_code from dp_check where c_shop='+''''+trim(Handle_Part)+''''+' )';
ipubtemp.scrapsate(sql);//盘点单盘赢; wg edit 2004-2-26
end;
loadborlanced(dmmain.cdsReceipt);
loadborlanced(dmmain.cdsOverflow);
loadborlanced(dmmain.cdsOverflowdetail);
except
application.MessageBox('服务器发生故障!',pchar(application.Title),mb_iconwarning);
exit;
end;
end else
begin //修改
if not bedit then
begin
if trim(Handle_Man)<>trim(edtnewmen.Text) then
begin
Application.MessageBox('不能修改数据!',pchar(application.Title),mb_iconinformation);
exit;
end;
end;
temp:='select * from dp_Overflow where od_ocode='+''''+trim(list_no)+'''';
if dmmain.CDSexecsql.Active then dmmain.CDSexecsql.Close;
dmmain.CDSexecsql.data:=null;
dmmain.CDSexecsql.Data :=adisp.execSql(temp);
dmmain.CDSexecsql.Open;
dmmain.CDSexecsql.edit;
dmmain.CDSexecsql.FieldByName('o_newdate').AsString:=formatdatetime('yyyy''-''mm''-''dd',date);
dmmain.CDSexecsql.FieldByName('o_newman').AsString:=trim(edtnewmen.Text );
dmmain.CDSexecsql.FieldByName('o_remark').AsString:=trim(edtremakt.Text);
dmmain.CDSexecsql.FieldByName('o_operater').AsString:=trim(cmbg.Text);
dmmain.CDSexecsql.FieldByName('o_auditer').AsString:=trim(cmbc.Text);
dmmain.CDSexecsql.Post;
try
dmmain.CDSexecsql.ApplyUpdates(-1);
except
application.MessageBox('服务器终止服务!',pchar(application.Title),mb_iconwarning);
exit;
end;
temp:='select * from dp_Overflowdetail where od_ocode='+''''+trim(list_no)+'''';
if dmmain.CDSexecsql.Active then dmmain.CDSexecsql.Close;
dmmain.CDSexecsql.data:=null;
dmmain.CDSexecsql.Data:=adisp.execSql(temp);
dmmain.CDSexecsql.Open;
j:=sgorder.RowCount-1;
for i:=1 to j do
begin
with dmmain.CDSexecsql do
begin
edit;
fieldbyname('od_ccode').AsString:=trim(sgorder.Cells[1,i]);
fieldbyname('od_cname').AsString:=trim(sgorder.Cells[2,i]);
fieldbyname('od_ccount').AsString:=trim(sgorder.Cells[4,i]);
post;
end;
end;
try
dmmain.CDSexecsql.ApplyUpdates(-1);
except
application.MessageBox('服务器终止服务!',pchar(application.Title),mb_iconwarning);
exit;
end;
end;
close;
end;
procedure TfmOverflow.N1Click(Sender: TObject);
var
rows:integer;
begin
inherited;
rows:=sgorder.RowCount-1;
if (trim(sgorder.Cells[1,rows])<>'') and (trim(sgorder.Cells[4,rows])<>'') then
begin
sgorder.RowCount:=sgorder.RowCount+1;
sgorder.Rows[sgorder.RowCount-1].Text:='';
end;
end;
procedure TfmOverflow.N2Click(Sender: TObject);
begin
inherited;
if sgorder.RowCount=1 then
begin
Application.MessageBox('没有记录可以删除!','提示信息',mb_iconwarning);
exit;
end;
if Application.MessageBox('确实要删除记录吗?','提示信息',mb_iconquestion+mb_yesno)=idyes then
begin
//ydy add
if sgorder.RowCount = 2 then //只是清除第二行的内容
sgorder.Rows[sgorder.Row].Clear;
//ydy add
if sgorder.RowCount > 2 then
begin
//ydy changed
deleteRow(sgorder.row);
// sgorder.RowCount:=sgorder.RowCount-1;
end;
end;
//汇总计算
TotalCount;
end;
procedure TfmOverflow.sgorderDrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
var
s:string;
r:TRect;
begin
inherited;
//ydy add 设置显示颜色
with Sender as Tstringgrid do
begin
if gdSelected in State then
Canvas.Brush.Color:= clTeal; //clyellow;//clRed;
Canvas.TextRect(Rect,Rect.Left,Rect.Top,' '+Cells[ACol,ARow]);
if gdFocused in State then
Canvas.DrawFocusRect(Rect);
end;
//不但水平居中,还垂直居中
with Sender as Tstringgrid do
begin
Canvas.FillRect(Rect);
s:=Cells[ACol,ARow];
r:=Rect;
DrawText(Canvas.Handle,PChar(s),Length(s),r,DT_CENTER or DT_SINGLELINE or DT_VCENTER);
end;
end;
////汇总计算
procedure TfmOverflow.TotalCount;
var
i:integer;
begin
edttotals.caption :='0';
EdtTotalCount.caption :='0';
for i:= 1 to sgorder.RowCount -1 do
begin
//合计金额
if sgorder.Cells[7,i] <>'' then
begin
edttotals.caption := floattostrf(strtofloat(edttotals.caption)+strtofloat( sgorder.Cells[7,i]),ffFixed,11,2);
end;
if sgorder.Cells[4,i] <>'' then
begin
//合计数量
EdtTotalCount.caption :=floattostr(strtofloat(edttotalcount.caption) + strtofloat(sgorder.Cells[4,i]));
end;
end;
end;
procedure TfmOverflow.BitBtn2Click(Sender: TObject);
var
user,wldwname,remarks:widestring;
flag,inmethod,intof:olevariant;
flagd,i:integer;
totals:double;
begin
if trim(sgorder.Cells[1,1])='' then exit;
no:=trim(edtcode.Text);
typed:='库存报溢单';
user:=trim(Handle_No);
flag:=adisp.receipted(no,typed,user,1,Handle_Part);
if flag='3' then //
begin
///修改库存,写入库单////
flagd:=1;
try
ipubtemp.stock(flagd,stockid,user,part_no); //wg edit 4-8
totals:=0;
for i:=1 to sgorder.RowCount-1 do //写财务主表;
begin
if trim(sgorder.Cells[8,i])='' then sgorder.Cells[8,i]:='0';
totals:=totals+(strtofloat(sgorder.Cells[8,i])* strtofloat(sgorder.Cells[4,i])); //已结算金额
end;
wldwname:='无';
wldwno:='无';
remarks:='从:'+shopid+'仓库 库存报溢';
intof:=ipubtemp.MoneyTable(10,no,totals,user,user,user,wldwno,wldwname,shopid,remarks);
if vartostr(intof)='1' then
begin
flag:='3';
end else
begin
flag:='2';
end;
except
application.MessageBox('服务器发生故障!',pchar(application.Title),mb_iconwarning);
exit;
end;
end;
if flag='1' then
begin
application.MessageBox('审核成功!',pchar(application.Title),mb_iconinformation);
close;
exit;
end;
if flag='2' then
begin
application.MessageBox('无权进行进行审核',pchar(application.Title),mb_iconinformation);
exit;
end;
if flag='3' then
begin
application.MessageBox('审核完毕!',pchar(application.Title),mb_iconinformation);
close;
exit;
end;
if flag='4' then
begin
application.MessageBox('反审核完毕!',pchar(application.Title),mb_iconinformation);
exit;
end;
if flag='5' then
begin
application.MessageBox('反审核成功!',pchar(application.Title),mb_iconinformation);
exit;
end;
if flag='6' then
begin
application.MessageBox('单据过帐后,不能进行审核或反审核!',pchar(application.Title),mb_iconinformation);
exit;
end;
inherited;
end;
procedure TfmOverflow.FormClose(Sender: TObject; var Action: TCloseAction);
begin
dmmain.CDSexecsql.Close;
dmmain.CDSexecsql.Data:=null;
dmmain.cdsprintmaster.Close;
dmmain.cdsprintmaster.Data:=null;
dmmain.cdsOverflow.Close;
dmmain.cdsOverflow.Data:=null;
dmmain.cdsOverflowdetail.Close;
dmmain.cdsOverflowdetail.Data:=null;
inherited;
end;
procedure TfmOverflow.btnprintClick(Sender: TObject);
begin
inherited;
if dmmain.cdsprintmaster.IsEmpty then exit;
fastrepxf:=tfastrepxf.Create(self);
fastrepxf.filenames:='OverFlow.ini';
fastrepxf.ShowModal;
fastrepxf.Free;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -