📄 fm_scrap.pas
字号:
exit;
end;
if not dmmain.CDSscrap.Active then dmmain.CDSscrap.Open;
if Public_Do='damage_0001' then
begin
dmmain.CDSscrap.Insert;
dmmain.CDSscrap.FieldByName('s_code').AsString:=trim(edtcode.Text );
dmmain.CDSscrap.FieldByName('s_shop').AsString:=trim(Handle_Part); //5-19
dmmain.CDSscrap.FieldByName('s_newdate').AsString:=formatdatetime('yyyy''-''mm''-''dd',date);
dmmain.CDSscrap.FieldByName('s_newman').AsString:=trim(edtnewmen.Text );
dmmain.CDSscrap.FieldByName('s_remark').AsString:=trim(edtremakt.Text);
dmmain.CDSscrap.FieldByName('s_operater').AsString:=trim(cmbg.Text);
dmmain.CDSscrap.FieldByName('s_auditer').AsString:=trim(cmbc.Text);
////////add auditer//////////////////////
dmmain.CDSscrap.FieldByName('s_state').AsString:='0';
/////////////////////////////////////////
dmmain.CDSscrap.Post;
if not dmmain.CDSscrapdetail.Active then dmmain.CDSscrapdetail.Open;
j:=sgorder.RowCount-1;
for i:=1 to j do
begin
with dmmain.CDSscrapdetail do
begin
insert;
fieldbyname('sd_scode').AsString:=trim(edtcode.Text);
fieldbyname('sd_ccode').AsString:=trim(sgorder.Cells[1,i]);
fieldbyname('sd_cname').AsString:=trim(sgorder.Cells[2,i]);
fieldbyname('sd_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
//ApplyUpdates(-1);
//dmmain.cdsOrderDetail.ApplyUpdates(-1);
loadborlanced(dmmain.cdsReceipt);
loadborlanced(dmmain.CDSscrap);
loadborlanced(dmmain.CDSscrapdetail);
if flags='2' then
begin
sql:='update dp_checkdetail set cd_state='+''''+'5'+''''+' where cd_ccount>0 and cd_state='+''''+'2'+''''+' 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;
except
//加入负载容错
application.MessageBox('服务器终止服务!',pchar(application.Title),mb_iconwarning);
savefromdata(dmmain.CDSscrap,'scrap');
savefromdata(dmmain.cdsscrapDetail,'scrapdetail');
exit;
end;
init;
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;
if dmmain.CDSexecsql.Active then dmmain.CDSexecsql.close;
temp:='select * from dp_scrap where sd_scode'+''''+trim(list_no)+'''';
dmmain.CDSexecsql.Data:=null;
dmmain.CDSexecsql.Data :=adisp.execSql(temp);
dmmain.CDSexecsql.Open;
dmmain.CDSexecsql.edit;
dmmain.CDSexecsql.FieldByName('s_newdate').AsString:=formatdatetime('yyyy''-''mm''-''dd',date);
dmmain.CDSexecsql.FieldByName('s_newman').AsString:=trim(edtnewmen.Text );
dmmain.CDSexecsql.FieldByName('s_remark').AsString:=trim(edtremakt.Text);
dmmain.CDSexecsql.FieldByName('s_operater').AsString:=trim(cmbg.Text);
dmmain.CDSexecsql.FieldByName('s_auditer').AsString:=trim(cmbc.Text);
////////add auditer//////////////////////
dmmain.CDSexecsql.FieldByName('s_state').AsString:='0';
/////////////////////////////////////////
dmmain.CDSexecsql.Post;
try
dmmain.CDSexecsql.ApplyUpdates(-1);
except
application.MessageBox('服务器终止服务!',pchar(application.Title),mb_iconwarning);
exit;
end;
if dmmain.CDSexecsql.Active then dmmain.CDSexecsql.close;
temp:='select * from dp_scrapdetail where sd_scode'+''''+trim(list_no)+'''';
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('sd_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;
end;
procedure TfmScrap.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 TfmScrap.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 TfmScrap.N2Click(Sender: TObject);
var
i :integer;
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 //只是清除第二行的内容
begin
sgorder.Rows[sgorder.Row].Clear;
if StockNum_List.Count>0 then
StockNum_List.Clear;
end;
//ydy add
if sgorder.RowCount > 2 then
begin
//ydy changed
deleteRow(sgorder.row ); ///是对的
if StockNum_List.Count>0 then
StockNum_List.Delete(sgorder.row-1); //从0开始
memo1.Lines := StockNum_List; ///test
// sgorder.RowCount:=sgorder.RowCount-1;
end;
end;
///2004-4-14 删除以后重新写编号
for i:=1 to sgorder.RowCount-1 do
begin
sgorder.Cells[0,i] := inttostr(i);
end;
//汇总计算
TotalCount;
end;
//删除一行
procedure TfmScrap.DeleteRow(Row: Integer);
var
i : integer;
begin
//最后一行直接删除
if (Row = sgorder.RowCount-1) and (row >1) then
Sgorder.RowCount := Sgorder.RowCount - 1;
//自动上移
if (Row < Sgorder.RowCount) and (Row > Sgorder.FixedRows-1) then
begin
if Row < Sgorder.RowCount - 1 then
begin
for i := Row to Sgorder.RowCount-1 do
Sgorder.Rows[i] := Sgorder.Rows[i+1];
Sgorder.RowCount := Sgorder.RowCount - 1;
end;
end;
end;
procedure TfmScrap.FormCreate(Sender: TObject);
begin
inherited;
StockNum_List := Tstringlist.create; ///用于存放一组数据各自的库存数量
end;
procedure TfmScrap.FormDestroy(Sender: TObject);
begin
inherited;
StockNum_List.Free;
end;
////汇总计算
procedure TFmScrap.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 TFmScrap.ClearGrid;
var
i,j:integer;
begin
///////////ydy add to clear the stringgrid
with sgorder do
begin
for i:=1 to colCount do
for j:=1 to rowCount do
cells[i,j]:='';
end;
sgorder.RowCount := 2;
end;
procedure TfmScrap.BitBtn2Click(Sender: TObject);
var
user,wldwname,remarks:widestring;
flag,inmethod,intof:olevariant;
bz,i:integer;
totals:double;
begin
if Public_Do='damage_0001' then exit;
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
////修改库存,写出库单
bz:=2;
try
ipubtemp.stock(bz,stockid,Handle_Man,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(9,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 TfmScrap.FormClose(Sender: TObject; var Action: TCloseAction);
begin
dmmain.CDSexecsql.Close;
dmmain.CDSexecsql.Data:=null;
dmmain.cdsprintmaster.Close;
dmmain.cdsprintmaster.Data:=null;
dmmain.CDSscrap.Close;
dmmain.CDSscrap.Data:=null;
dmmain.CDSscrapdetail.Close;
dmmain.CDSscrapdetail.Data:=null;
inherited;
end;
procedure TfmScrap.btnprintClick(Sender: TObject);
begin
inherited;
if dmmain.cdsprintmaster.IsEmpty then exit;
fastrepxf:=tfastrepxf.Create(self);
fastrepxf.filenames:='Scrap.ini';
fastrepxf.ShowModal;
fastrepxf.Free;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -