Разработка инвестиционного проекта ОАО "Завод по производству труб большого диаметра"

Case key of

      chr(48),chr(49),chr(50),chr(51),chr(52),chr(53),chr(54), chr(55),chr(56),chr(57),chr(44):;

   else key:=chr(0); end;

end;

end.



unit normgenerator;


interface


uses

  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

  Dialogs, Grids, StdCtrls, ExtCtrls, ComCtrls, Buttons, Menus;

procedure normgen(var num1,num2 : real);

type

  TForm7 = class(TForm)

    PageControl1: TPageControl;

    TabSheet1: TTabSheet;

    GroupBox1: TGroupBox;

    Label2: TLabel;

    StringGrid1: TStringGrid;

    StringGrid2: TStringGrid;

    MainMenu1: TMainMenu;

    N1: TMenuItem;

    N2: TMenuItem;

    N3: TMenuItem;

    N4: TMenuItem;

    N5: TMenuItem;

    N6: TMenuItem;

    N7: TMenuItem;

    Label1: TLabel;

    TabSheet2: TTabSheet;

    StringGrid3: TStringGrid;

    SaveDialog1: TSaveDialog;

    OpenDialog1: TOpenDialog;

    procedure FormCreate(Sender: TObject);

    procedure N7Click(Sender: TObject);

    procedure StringGrid1Exit(Sender: TObject);

    procedure StringGrid2Exit(Sender: TObject);

    procedure N3Click(Sender: TObject);

    procedure N2Click(Sender: TObject);

   

  private

    { Private declarations }

  public

    { Public declarations }

  end;


var

  Form7: TForm7;

  i,j, ndvar : integer;  {число дтерм. перем-х проекта}

  Svar : array[1..500,1..20] of real;{массив значений сгенерированных сл.вел}

  Xvar : array[1..40,1..20] of real; {массив сл.перемен-х проекта}

  Dvar : array[1..20,1..20] of real; {массив детермиированных перем-х ден. потоков}

implementation


uses Risk, Cov;


{$R *.dfm}


procedure normgen(var num1,num2 : real);

var

  r1,r2,svar : real;

begin

     Repeat

          r1:=2*random-1;

          r2:=2*random-1;

          svar:=Sqr(r1)+Sqr(r2);

     Until (svar<1);

     svar:=sqrt((-2*ln(svar))/svar);

     num1:=r1*svar;

     num2:=r2*svar;

end;


procedure TForm7.N2Click(Sender: TObject);

Var

 Myfile : Textfile;

 Date : String;

begin

  If (OpenDialog1.Execute)  then begin

     AssignFile(Myfile,Opendialog1.FileName);

     Try Reset(myFile);

     Except

          Showmessage('Ошибка при чтении файла!'); Exit;

     end;

     ReadLn(MyFile,Date);StringGrid1.ColCount:=StrToInt(Date);

     ReadLn(MyFile,Date);StringGrid1.RowCount:=StrToInt(Date);

     ReadLn(MyFile,Date);StringGrid2.ColCount:=StrToInt(Date);

     ReadLn(MyFile,Date);StringGrid2.RowCount:=StrToInt(Date);

     For i:=0 to StringGrid1.ColCount do  begin

        For j:=0 to StringGrid1.RowCount do begin

            ReadLn(MyFile,Date);

            StringGrid1.Cells[i,j]:=Date;

        end;

      end;

      For i:=0 to StringGrid2.ColCount do begin

        For j:=0 to StringGrid2.RowCount do begin

             ReadLn(MyFile,Date);

             StringGrid2.Cells[i,j]:=Date;

        end;

      End;

      Closefile(myFile);

  end

  else Begin Showmessage('Файл не найден!'); Exit;end;

end;



procedure TForm7.FormCreate(Sender: TObject);

begin

   StringGrid1.Cells[0,1]:='+'; StringGrid1.Cells[0,3]:='-'; StringGrid1.Cells[0,5]:='-';

   StringGrid2.Cells[0,1]:='+';   StringGrid2.Cells[0,2]:='+'; StringGrid2.Cells[0,3]:='-'; StringGrid2.Cells[0,4]:='-';

   StringGrid1.Cells[1,1]:='Доходы от реализации продукции';

   StringGrid1.Cells[1,3]:='Эксплутационные затраты';

   StringGrid1.Cells[1,5]:='Налоги';

   StringGrid2.Cells[1,1]:='Возмещение НДС по инвестициям';

   StringGrid2.Cells[1,2]:='Амортизация';

   StringGrid2.Cells[1,3]:='Инвестиции';

   StringGrid2.Cells[1,4]:='Прирост оборотных средств';

   StringGrid1.Cells[1,0]:='Название';

   StringGrid1.Cells[2,0]:='Инт-л';

   StringGrid2.Cells[1,0]:='Название';

   i:=1;

   While (i<=StringGrid1.ColCount) do begin

       StringGrid1.Cells[2,i]:='Мин.';

       StringGrid1.Cells[2,i+1]:='Макс.';

       i:=i+2;

   end;

   For i:=3 to StringGrid1.ColCount do begin

       StringGrid1.Cells[i,0]:=IntToStr(i-2);

       StringGrid2.Cells[i-1,0]:=IntToStr(i-2);

       StringGrid3.Cells[i-2,0]:=IntToStr(i-2);

   end;

   For i:=1 to 500 do begin

       Stringgrid3.Cells[0,i]:=IntToStr(i);

   end;

end;


procedure TForm7.N7Click(Sender: TObject);

var

   nvar,nn1,nn2,sv1,sv2 : real; //число стох.пер-х проекта,сл.числа,коэф-ты для прироста об.ср-в.

   kvar : integer;


begin

    nvar:=StringGrid1.RowCount-1;

    For j:=1 to 20 do begin

        Simd[j]:=0;

    end;

    For i:=1 to 500 do begin

        For j:=1 to 20 do begin

            Svar[i,j]:=0;

        end;

    end;

    For i:=1 to 20 do begin

        For j:=1 to 20 do begin

            Covar[i,j]:=0;

        end;

    end;

    for i:=1 to (StringGrid1.ColCount-3) do begin

        j:=1;

        While j<=(nvar-1) do begin

             kvar:=1;

             While kvar<=500 do begin

                  normgen(nn1,nn2);

                  nn1:=Xvar[j,i]+nn1*Xvar[j+1,i];

                  nn2:=Xvar[j,i]+nn2*Xvar[j+1,i];

                  if StringGrid1.Cells[0,j]='-' then begin

                                                         nn1:=-nn1;

                                                         nn2:=-nn2;

                                                     end;

                  if j=5 then begin

                             if Xvar[j,i]<>0 then begin

                                sv1:=nn1/Xvar[j,i];

                                sv2:=nn2/Xvar[j,i];

                             end else begin sv1:=0; sv2:=0; end;

                                Svar[kvar,i]:=Svar[kvar,i]+sv1*Dvar[4,i];

                                Svar[kvar+1,i]:=Svar[kvar+1,i]+sv2*Dvar[4,i];

                              end;

                  Svar[kvar,i]:=Svar[kvar,i]+nn1;

                  Svar[kvar+1,i]:=Svar[kvar+1,i]+nn2;

                  kvar:=kvar+2;

             end;

             j:=j+2;

        end;

        for j:=1 to 500 do begin

            For kvar:=1 to ndvar do begin

               if kvar <>4 then Svar[j,i]:=Svar[j,i]+Dvar[kvar,i];

            end;

        end;

    end;

    For i:=1 to StringGrid1.Colcount-3 do begin

        For j:=1 to 500 do begin

            StringGrid3.Cells[i,j]:=FloatToStr(Svar[j,i]);

            Simd[i]:=Simd[i]+Svar[j,i];

        end;

        Simd[i]:=Simd[i]/500;

        Form8.StringGrid3.Cells[i-1,1]:=FloatToStrF(Simd[i],ffFixed,9,2);

    end;


    For i:=1 to StringGrid1.ColCount-3 do begin

        For j:=i to StringGrid1.ColCount-3 do begin

            For kvar:=1 to 500 do begin

                Covar[i,j]:=Covar[i,j]+((Svar[kvar,i]-Simd[i])*(Svar[kvar,j]-Simd[j]));

            end;

            Covar[i,j]:=Covar[i,j]/500;

            Form3.StringGrid1.Cells[j,i]:=FloatToStrF(Covar[i,j],ffFixed,12,2);

            Form3.StringGrid1.Cells[i,j]:=FloatToStrF(Covar[i,j],ffFixed,12,2);

        end;

    end;

end;


procedure TForm7.StringGrid1Exit(Sender: TObject);

begin

   Try

        For j:=3 to StringGrid1.ColCount-1 do begin

            i:=1;

            While i<=StringGrid1.RowCount-1 do begin

                Xvar[i,j-2]:=StrToFloat(StringGrid1.Cells[j,i]);

                Xvar[i,j-2]:=(Xvar[i,j-2]+StrToFloat(StringGrid1.Cells[j,i+1]))/2;

                Xvar[i+1,j-2]:=Xvar[i,j-2]-StrToFloat(StringGrid1.Cells[j,i]);

                i:=i+2;

            end;

        end;

    except

       ShowMessage('Неправельный ввод данных!');

       FocusControl(StringGrid1);

    end;

end;


procedure TForm7.StringGrid2Exit(Sender: TObject);

var

   nn1 : real;

begin

  Try

      For j:=2 to StringGrid2.ColCount-1 do begin

        For i:=1 to StringGrid2.RowCount-1 do begin

               Dvar[i,j-1]:=StrToFloat(StringGrid2.Cells[j,i]);

               If StringGrid2.Cells[0,i]='-' then Dvar[i,j-1]:=-Dvar[i,j-1]

        end;

      end;

    Except

        ShowMessage('Неправельный ввод данных!');

        FocusControl(StringGrid2);

    end;

    ndvar:=StringGrid2.RowCount-1;

end;


procedure TForm7.N3Click(Sender: TObject);

Var

 Myfile : Textfile;

 Date : String;

begin

If (saveDialog1.Execute) then begin

     AssignFile(Myfile,Savedialog1.FileName);

     Try Rewrite(myFile);

     Except

          Showmessage('Ошибка при чтении файла!'); Exit;

     end;

     Date:=IntToStr(StringGrid1.ColCount);WriteLn(MyFile,Date);

     Date:=IntToStr(StringGrid1.RowCount);WriteLn(MyFile,Date);

     Date:=IntToStr(StringGrid2.ColCount);WriteLn(MyFile,Date);

     Date:=IntToStr(StringGrid2.RowCount);WriteLn(MyFile,Date);

     For i:=0 to StringGrid1.ColCount do begin

         for j:=0 to StringGrid1.RowCount do begin

             Date:=StringGrid1.Cells[i,j];

             WriteLn(Myfile,Date);

         end;

     end;

     For i:=0 to StringGrid2.ColCount do begin

       For j:=0 to StringGrid2.RowCount do begin

             Date:=StringGrid2.Cells[i,j];

             WriteLn(Myfile,Date);

       end;

     end;

     Closefile(myFile);

  end

  else Begin Showmessage('Ошибка!'); Exit;end;

end;

end.



 


Страницы: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25



Реклама
В соцсетях
рефераты скачать рефераты скачать рефераты скачать рефераты скачать рефераты скачать рефераты скачать рефераты скачать