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

📄 stockfindinfo.pas

📁 是一款针对啤酒行业的销售进销存管理系统,包括基本的进货,销售,库存
💻 PAS
📖 第 1 页 / 共 2 页
字号:
                  dbgrid.Cells[0,i]:='';
                  dbgrid.Cells[1,i]:='';
                  dbgrid.Cells[2,i]:='';
                  dbgrid.Cells[3,i]:='';
                  dbgrid.Cells[4,i]:='';
                  dbgrid.Cells[5,i]:='';
                  dbgrid.Cells[6,i]:='';
                  dbgrid.Cells[7,i]:='';
                  dbgrid.Cells[8,i]:='';
               end;
               dbgrid.RowCount:=2;
               exit;
            end;
      end;
      if (strList.Count>0) then
      begin
          strWhere2:=DeleteLastSubstring(' and ',strSql);
      end;
      /////////
      if (strList1.count=0) and (strList.Count>0) then
      begin
         strSearch1:='SELECT * FROM intoTable  where  '+strWhere2;
      end;
      if (strList1.count>0) and (strList.Count>0) then
      begin
         strSearch1:='SELECT * FROM  intoTable  where  '+strWhere1+'  and  '+strWhere2;
      end;
      if (strList1.count>0) and (strList.Count=0) then
      begin
         strSearch1:='SELECT * FROM intoTable  where  '+strWhere1;
      end;
      //showmessage(strSearch1);
      /////////////
      for i:=1 to dbgrid.rowcount-2 do
      begin
         dbgrid.Cells[0,i]:='';
         dbgrid.Cells[1,i]:='';
         dbgrid.Cells[2,i]:='';
         dbgrid.Cells[3,i]:='';
         dbgrid.Cells[4,i]:='';
         dbgrid.Cells[5,i]:='';
         dbgrid.Cells[6,i]:='';
         dbgrid.Cells[7,i]:='';
         dbgrid.Cells[8,i]:='';
     end;
     dbgrid.RowCount:=2;
      /////////////

      //FillValueToListview(query1,strSearch1,0,dbgrid);
      //////显示记录/////
      Query3:=RunSqlOfAdo(query1,strSearch1);
      if Query3.RecordCount<>0 then
      begin
         i:=1;
         //DBgrid.RowCount:=Query3.RecordCount+2;
         while not Query3.Eof do
         begin
            Dbgrid.Cells[0,i]:=query3.fieldByname('billcode').AsString;
            Dbgrid.Cells[1,i]:=query3.fieldByname('ProductCode').AsString;
            Dbgrid.Cells[2,i]:=query3.fieldByname('ProductName').AsString;
            Dbgrid.Cells[3,i]:=query3.fieldByname('Rule').AsString;
            Dbgrid.Cells[4,i]:=query3.fieldByname('Capacity').AsString;
            Dbgrid.Cells[5,i]:=query3.fieldByname('Unit').AsString;
            Dbgrid.Cells[6,i]:=query3.fieldByname('Price').AsString;
            Dbgrid.Cells[7,i]:=query3.fieldByname('ProductNum').AsString;
            Dbgrid.Cells[8,i]:=query3.fieldByname('ProductSum').AsString;
           // Dbgrid.Cells[0,i]:=query3.fieldByname('billcode').AsString;
           // Dbgrid.Cells[0,i]:=query3.fieldByname('billcode').AsString;
            Query3.Next;
            inc(i);
            DBgrid.RowCount:= DBgrid.RowCount+1;
         end;
      end;
      ////////////////////
      ////////显示日期//2005-6-2////
      for i:=0 to DBgrid.RowCount-2 do
      begin
          strSql:='SELECT *  FROM  BillTable  WHERE  BillCode="'+DBgrid.Cells[0,i+1]+'"';
          Query3:=RunSqlOfAdo(query1,strSql);
          if Query3.RecordCount<>0 then
          begin
             while not Query3.Eof do
             begin
                 DBgrid.Cells[9,i+1]:=query3.fieldByname('billdate').AsString;
                 query3.Next;
             end;
          end;
      end;
      //////////
      ///计算合计/////////
      tmpTotal[0]:=0;
      tmpTotal[1]:=0;
      for i:=1 to DBgrid.rowcount-2 do
      begin
          tmpTotal[0]:=tmpTotal[0]+strToFloat(DBgrid.cells[7,i]);
          tmpTotal[1]:=tmpTotal[1]+strToFloat(DBgrid.cells[8,i]);
      end;
      DBgrid.Cells[0,DBgrid.RowCount-1]:='合计:';
      DBgrid.Cells[7,DBgrid.RowCount-1]:=FloatTostr(tmpTotal[0]);
      DBgrid.Cells[8,DBgrid.RowCount-1]:=FloatTostr(tmpTotal[1]);
      ////添加报表数据////
      strDelete:='DELETE * FROM  ReportIntoTable';
      RunNonSql(query1,strDelete);
      for i:=1 to DBgrid.RowCount-1 do
      begin
          strInsert:='INSERT INTO  ReportIntoTable(billcode,productcode,productName,rule,capacity,unit,price,productNum,productSum) VALUES("'+DBgrid.cells[0,i]+'","'+DBgrid.Cells[1,i]+'","'+DBgrid.Cells[2,i]+'","'+DBgrid.Cells[3,i]+'","'+DBgrid.Cells[4,i]+'","'+DBgrid.Cells[5,i]+'","'+DBgrid.Cells[6,i]+'","'+DBgrid.Cells[7,i]+'","'+DBgrid.Cells[8,i]+'")';
          RunNonSql(query1,strInsert);
      end;
       ///统计各值//////
      price_arg:=0;
      Amount_Sum:=0;
      Money_Sum:=0;
      //Showmessage(intToStr(dbgrid.rowcount));
      ////计算平均单价///
      if dbgrid.rowcount>2 then
      begin
         for i:=1 to Dbgrid.RowCount-2 do
         begin
             price_arg:=price_arg+strToFloat(dbgrid.cells[6,i]);
         end;
         edit2.Text:=formatfloat('0.00',(price_arg)/(dbgrid.rowcount-2));

        ////计算总数量///
         for i:=1 to Dbgrid.RowCount-2 do
         begin
             Amount_Sum:=Amount_Sum+strToFloat(dbgrid.cells[7,i]);
         end;
         edit3.Text:=FloatToStr((Amount_Sum));
          ////计算总金额///
         for i:=1 to Dbgrid.RowCount-2 do
         begin
             Money_Sum:=Money_Sum+strToFloat(dbgrid.cells[8,i]);
         end;
         edit4.Text:=FloatToStr((Money_Sum));

      end;
      
end;////结束

procedure TStockFind.PicButton7Click(Sender: TObject);
begin
  close;
end;

procedure TStockFind.DBgridDrawCell(Sender: TObject; ACol, ARow: Integer;
  Rect: TRect; State: TGridDrawState);
begin
     if (Arow=(Dbgrid.rowcount-1)) then
        begin
           DBgrid.Canvas.Brush.color:=rgb(255,255,206);
           dbgrid.Canvas.Brush.Style:=bssolid;
           dbgrid.Canvas.Font.Size:=11;
           dbgrid.canvas.Font.Style:=[fsbold];
           //dbgrid.Canvas.font.Color:=rgb(255,255,255);
           dbgrid.Canvas.FillRect(Rect);
           DBgrid.Canvas.TextOut(rect.left,rect.Top,dbgrid.Cells[Acol,Arow]);
        end;
end;

procedure TStockFind.PicButton5Click(Sender: TObject);
var
   TitleName:TStringList;
   ColWidth,ColumnWidth:Array of Integer;
   i:integer;
   LineWidth:integer;
begin
      TitleName:=TStringList.Create;
      //ColWidth:=TStringList.Create;
      TitleName.Add('进货单号');
      TitleName.Add('产品编码');
      TitleName.Add('产品名称');
      TitleName.Add('规格');
      TitleName.Add('容量');
      TitleName.Add('计量单位');
      TitleName.Add('单价');
      TitleName.Add('数量');
      TitleName.Add('总金额');

      //TitleName.Add('搭赠金额');
      SetReportTitle('进货情况报表');
      SetTableName('ReportIntoTable'); ////设置报表的表名
      SetColumnTitle(TitleName);////设置报表列的标题
      /////设置动态数组的长度////
      setlength(colwidth,GetFieldCount(AdoTable1));
      setlength(columnwidth,GetFieldCount(AdoTable1)+1);
      for i:=0 to  GetFieldCount(AdoTable1)-1 do
      begin
          Colwidth[i]:=10;
          //ColumnWidth[i]:=60;
      end;
      ////设置输出内容的列宽度
      ColumnWidth[1]:=90;
      ColumnWidth[2]:=80;
      ColumnWidth[3]:=100;
      ColumnWidth[4]:=70;
      ColumnWidth[5]:=70;
      ColumnWidth[6]:=80;
      ColumnWidth[7]:=70;
      ColumnWidth[8]:=80;
      ColumnWidth[9]:=80;
     
      //ColumnWidth[14]:=80;
      ////计算表格水平线的宽度
      lineWidth:=0;
      for i:=1 to GetFieldCount(AdoTable1) do
      begin
          LineWidth:=LineWidth+ColumnWidth[i];
      end;
      SetHorizontalLineWidth(LineWidth); ///设置表格水平线的宽度
      SetIntegerCol(false);
      CreateList(sender,AdoTable1,picbutton5,colwidth,columnWidth);
end;

procedure TStockFind.PicButton2Click(Sender: TObject);
var
  v,sheet,range:variant;
  i,j:integer;
  TitleName:string;
  FileName:string;
begin
     v:=createoleobject('excel.application');
     v.visible:=true;
     v.workbooks.add(-4167);
     v.workbooks[1].sheets[1].name:='saleFind';
     sheet:=v.workbooks[1].sheets['saleFind'];
     range:=Sheet.range[sheet.cells[1,1],sheet.cells[1,9]];
     //sheet.caption:='sdfgsdfsd';
     range.select;
     range.merge;
     range.HorizontalAlignment:=3;
     range.font.size:=19;
     range.font.bold:=2;
     TitleName:='进货查询统计情况表';
     Sheet.range[sheet.cells[1,1],sheet.cells[1,9]]:=TitleName;
        for i:=1 to DBgrid.RowCount do
        begin
            for j:=1 to 10 do
            begin
                v.workbooks[1].sheets[1].cells[i+1,j]:=Dbgrid.Cells[j-1,i-1];
            end;
        end;
     

    //range.select;
    v.workbooks[1].sheets[1].cells[DBgrid.RowCount+2,1]:='制表人:';
    v.workbooks[1].sheets[1].cells[DBgrid.RowCount+2,4]:='审核人:';
     v.workbooks[1].sheets[1].cells[DBgrid.RowCount+2,7]:='制表日期:';
    range:=Sheet.range[sheet.cells[2,1],sheet.cells[DBgrid.RowCount+1,9]];
    range.select;

    range.borders.linestyle:=xlcontinuous;
    //range.borders.linewidth:=3;
    range.font.size:=14;
    //sheet.charttype:=
    Filename:=extractFilePath(paramStr(0))+'\saleTotal.xls';
    {if FileExists(FileName) then
    begin
       DeleteFile(FileName);
       v.workbooks[1].saveas(FileName);
    end
    else
       v.workbooks[1].saveas(FileName);
       }
end;

end.

⌨️ 快捷键说明

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