⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stock_contract.pas

📁 适合行业为眼镜业
💻 PAS
📖 第 1 页 / 共 3 页
字号:
      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 Tfrm_Stock_Contract.StringGrid1SetEditText(Sender: TObject; ACol,
  ARow: Integer; const Value: String);
var
    tempstr:string;
    i:integer;
begin
    if ((StringGrid1.Cells[3,ARow]<>'') and  (StringGrid1.Cells[4,ARow]<>'' ))then
    try
     StringGrid1.Cells[5,ARow]:=FloatTostr(StrToFloat(StringGrid1.Cells[3,ARow])*StrToFloat(StringGrid1.Cells[4,ARow]));
    except
      showmessage('你输入的数据有误,请重新输入!');
    end;
end;
procedure Tfrm_Stock_Contract.FormShow(Sender: TObject);
var
    i,icount,k:integer;
    tt,yy,temppos:integer;
    tempstr:widestring;
begin
    zdflag:=false;
   init;
    //加载行号
    for i:=1 to StringGrid1.RowCount-1 do
    begin
        StringGrid1.Cells[0,i]:=IntTostr(i); //表示第0列第i行
    end;
    if (Public_Do='Business_Draft_0002') then
    begin
      tempstr:='Select a.*,b.*,c.* from Stock_Contract as a ,Stock_Contract_detail as b, goods_code as c where c.goods_no=b.goods_no and a.Contract_No=b.Contract_No and a.Contract_No='+''''+trim(List_No)+'''';
      dmmain.CDSquery2.Data:=null;
      dmmain.CDSquery2.Close;
       //wy edit 3-14   begin
      dmmain.CDSquery2.Data:=adisp.resultrecord(tempstr);
      if not dmmain.CDSquery2.IsEmpty then       //返回记录集为空时在往下走要报错,Wy
      begin
          dmmain.CDSquery2.Open;
          k:=dmmain.CDSquery2.RecordCount;
          StringGrid1.RowCount:=k+1;
          //自动加载STRINGGRID的行数

          //******************
          speedbutton3.Enabled:=false;//修改时,不能再次转单
          spbyd.Enabled:=false;
          ////////////////////////
          Edit1.Text:=ForMatDateTime('yyyy''-''mm''-''dd',dmmain.CDSquery2.FieldValues['Copy_Date']);
          Edit2.Text:=dmmain.CDSquery2.FieldValues['Contract_No'];
          Edit3.Date :=dmmain.CDSquery2.fieldbyname('Arrive_Date').AsDateTime;
          Edit4.Text:=dmmain.CDSquery2.FieldValues['wldw'];
          Edit5.Text:=dmmain.CDSquery2.FieldValues['transactor'];
          Edit7.Text:=dmmain.CDSquery2.FieldValues['Proposer'];
          Edit8.Text:=dmmain.CDSquery2.FieldValues['resume'];
          Edit9.Text:=dmmain.CDSquery2.FieldValues['Remark'];
          wldwno:=dmmain.CDSquery2.Fieldbyname('wldw_no').AsString;
          for k:=1 to dmmain.CDSquery2.RecordCount  do //wy edit;
          begin
            StringGrid1.Cells[0,K]:=IntTostr(k); //表示第0列第i行的名称
            StringGrid1.Cells[1,k]:=trim(dmmain.CDSquery2.FieldValues['Goods_NO']);//商品编号
            StringGrid1.Cells[2,k]:=trim(dmmain.CDSquery2.FieldValues['Goods_Name']);//商品名称
            StringGrid1.Cells[3,k]:=trim(dmmain.CDSquery2.FieldValues['Price']);//单价   // wg and wy edit;
            StringGrid1.Cells[4,k]:=trim(dmmain.CDSquery2.FieldValues['Goods_amount']);//数量
            StringGrid1.Cells[5,k]:=trim(dmmain.CDSquery2.FieldValues['Money']);//金额
            StringGrid1.Cells[6,k]:=trim(dmmain.CDSquery2.FieldValues['type']); //类别名称
            StringGrid1.Cells[7,k]:=trim(dmmain.CDSquery2.FIELDBYNAME('PROVIDER').AsString); //生产厂家
            StringGrid1.Cells[8,k]:=trim(dmmain.CDSquery2.FieldValues['remark']); //备注说明
            StringGrid1.Cells[9,k]:=trim(dmmain.CDSquery2.FieldValues['Orders']); //预定申请编号说明
            dmmain.CDSquery2.Next;
          end;
          GetDataPrint(dmmain.cdsprintmaster,dmmain.CDSquery2);
      end else
      begin
          application.MessageBox('此合同已不存在,请核对后更正!',pchar(application.Title),mb_iconinformation);
      end;
  end;      //end;
end;


procedure Tfrm_Stock_Contract.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
   DMMAIN.CDSquery2.Close;
  dmmain.CDSquery2.Data:=null;
   DMMAIN.CDSexecsql.Close;
  dmmain.CDSexecsql.Data:=null;
  dmmain.cdsprintmaster.Close;
  dmmain.cdsprintmaster.Data:=null;
  dmmain.cdsStock_contract_detail.Close;
  dmmain.cdsStock_contract_detail.Data:=null;
  dmmain.cdsStock_contract.Close;
  dmmain.cdsStock_contract.Data:=null;
    Action:=cafree;
end;

procedure Tfrm_Stock_Contract.Cmd_DeleteClick(Sender: TObject);
begin
  deletegridrows(stringgrid1,prow);
end;


procedure Tfrm_Stock_Contract.Cmd_AddClick(Sender: TObject);
var
    i:integer;
begin
    StringGrid1.RowCount:=StringGrid1.RowCount+1;
    Total_Count:=StringGrid1.RowCount;
    for i:=1 to StringGrid1.RowCount-1 do
    begin
        StringGrid1.Cells[0,i]:=IntTostr(i); //表示第0列第i行
    end;
end;

procedure Tfrm_Stock_Contract.StringGrid1SelectCell(Sender: TObject; ACol,
  ARow: Integer; var CanSelect: Boolean);
begin
  pcol:=acol;
  prow:=arow;
end;

procedure Tfrm_Stock_Contract.SpeedButton2Click(Sender: TObject);
var
  user:widestring;
  flag:olevariant;
begin
  if trim(stringgrid1.Cells[1,1])='' then exit;
  no:=trim(edit2.Text);
  typed:='采购合同';
  user:=trim(Handle_No);
  flag:=adisp.receipted(no,typed,user,1,Handle_Part);
  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;
end;

procedure Tfrm_Stock_Contract.StringGrid1KeyPress(Sender: TObject;
  var Key: Char);
begin
  if trim(StringGrid1.Cells[1,StringGrid1.Row])='' then exit;
  if pcol in [3,4,8] then
  begin
    if not (key in ['0'..'9',#8,'.']) then
    begin
      key:=#0;
    end else
    begin
      if key<>#8 then
      begin
        IF PCOL=3 THEN
        begin
          if StringGrid1.Cells[3,prow]<>'0' then
          begin
            StringGrid1.Cells[3,prow]:=StringGrid1.Cells[3,prow]+key;
          end else
          begin
            StringGrid1.Cells[3,prow]:=key;
          end;
        end;
        if pcol=4 then
        begin
          if StringGrid1.Cells[4,prow]<>'0' then
          begin
            StringGrid1.Cells[4,prow]:=StringGrid1.Cells[4,prow]+key;
          end else
          begin
            StringGrid1.Cells[4,prow]:=key;
          end;
        end;
        StringGrid1.Cells[5,prow]:=floattostr(strtofloat(StringGrid1.Cells[3,prow])*strtofloat(StringGrid1.Cells[4,prow]));
      end else
      begin
        if pcol=3 then
        begin
          StringGrid1.Cells[3,prow]:=copy(StringGrid1.Cells[3,prow],1,length(StringGrid1.Cells[3,prow])-1);   //减去最后数字
          if  StringGrid1.Cells[3,prow]='' then
          begin
            StringGrid1.Cells[3,prow]:='0';
          end;
          StringGrid1.Cells[5,prow]:=floattostr(strtofloat(StringGrid1.Cells[3,prow])*strtofloat(StringGrid1.Cells[4,prow]));
        end;
        if pcol=4 then
        begin
          StringGrid1.Cells[4,prow]:=copy(StringGrid1.Cells[4,prow],1,length(StringGrid1.Cells[4,prow])-1);   //减去最后数字
          if  StringGrid1.Cells[4,prow]='' then
          begin
            StringGrid1.Cells[4,prow]:='0';
          end;
          if trim(StringGrid1.Cells[4,prow])='0' then
          begin
            StringGrid1.Cells[5,prow]:='0';
          end else
          begin
            StringGrid1.Cells[5,prow]:=floattostr(strtofloat(StringGrid1.Cells[3,prow])*strtofloat(StringGrid1.Cells[4,prow]));
          end;
        end;
      end;
    end;
  end else
  begin
    application.MessageBox('只能输入商品单价,数量,说明!',pchar(application.Title),mb_iconinformation);
    exit;
  end;
end;

procedure Tfrm_Stock_Contract.StringGrid1MouseMove(Sender: TObject;
  Shift: TShiftState; X, Y: Integer);
var
  gs,i:integer;
  zjmoney:double;
begin
  gs:=0;
  zjmoney:=0.00;
  if trim(stringgrid1.Cells[1,1])='' then exit;
  for i:=1 to stringgrid1.RowCount -1 do
  begin
    if (trim(stringgrid1.Cells[4,i])<>'') then
    begin
      gs:=gs+strtoint(stringgrid1.Cells[4,i]);
    end;
    if (trim(stringgrid1.Cells[5,i])<>'') then
    begin
      zjmoney:=zjmoney+strtofloat(stringgrid1.Cells[5,i]);
    end;
  end;
  lbgs.Caption:=format('%11d',[gs]);
  lbzj.Caption :=format('%11.'+inttostr(len)+'f',[zjmoney]);
end;

procedure Tfrm_Stock_Contract.SpeedButton3Click(Sender: TObject);
begin
  zdflag:=true;
 dlgmsggoods:=tdlgmsggoods.Create(self);
 dlgmsggoods.model:=0;
 dlgmsggoods.ShowModal;
 dlgmsggoods.Free;
end;

procedure Tfrm_Stock_Contract.Cmd_PrintClick(Sender: TObject);
begin
  if dmmain.cdsprintmaster.IsEmpty then exit;
  fastrepxf:=tfastrepxf.Create(self);
  fastrepxf.filenames:='Contract.ini';
  fastrepxf.ShowModal;
  fastrepxf.Free;
end;

procedure Tfrm_Stock_Contract.spbydClick(Sender: TObject);
begin
  dlgmsggoods:=tdlgmsggoods.Create(self);
  dlgmsggoods.model:=2;
  dlgmsggoods.ShowModal;
  dlgmsggoods.Free;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -