Delphi Dünyası Facebook'ta

Kodbank İndir

! CODEBANK 2012 !

İNDİRMEK&DETAYLI BİLGİ ALMAK İÇİN BURAYI TIKLAYINIZ.

Gönderen Konu: Film Seanslarını Hesaplama  (Okunma sayısı 1132 defa)

0 Üye ve 1 Ziyaretçi konuyu incelemekte.

Çevrimdışı dynamo

  • Delphi 3 Level 4
  • ****
  • İleti: 137
  • Rep: +3/-1
Film Seanslarını Hesaplama
« : 16 Nisan 2007 16:24:55 »
Filmin Başlama Saati ,İlk yarı süresi ve 2. yarı sürelerini alarak 6 seansını hesaplama işlemini yapıp excel'e alalım.

İlk yarı Süresi şu şekilde İlk Yarı=Reklam+Fragman+Filmin İlk Yarısı+Film Arası formüle edelim.İkinci Yarı ise  İkinci Yarı=Filmin İkinci Yarısı+Seans Arası.

Başlama Saati-->11:00 ,1.yarı 75 dk, 2.yarı 85 dk olsun. hesaplama işlemi:

Kod: [Seç]
procedure TForm1.FormCreate(Sender: TObject);
var i:integer;
begin
   stringGrid1.ColCount:=7;
   stringGrid1.RowCount:=4;
   stringGrid1.Cols[0].Add('SEANS');
   for i:=1 to 7 do
      stringGrid1.Cols[i].Add(inttostr(i));
   stringGrid1.Rows[1].Add('BAŞLAMA');
   stringGrid1.Rows[2].Add('ARA');
   stringGrid1.Rows[3].Add('BİTİŞ');
end;

procedure TForm1.Button1Click(Sender: TObject);
var time1:TDateTime;
    st,dk,sn,sl:word;
    dkkalan,ilky,ikinciy,x:word;
    stformat:string;
begin
   if Edit1.Text='' then begin
      showmessage('Filmin başlama saatini girmelisiniz.');
      Edit1.SetFocus;
      exit;
   end;
   if Edit2.Text='' then begin
      showmessage('Filmin ilk yarısını dakika olarak girmelisiniz.');
      Edit2.SetFocus;
      exit;
   end;
   if Edit3.Text='' then begin
      showmessage('Filmin ikinci yarısını dakika olarak girmelisiniz.');
      Edit3.SetFocus;
      exit;
   end;
   ilky:=strtoint(Edit2.Text);
   ikinciy:=strtoint(Edit3.Text);
   //-----------------------------------------------------------------------
   //cells[1,1] 1. seans başlama saati
   stringGrid1.Cells[1,1]:=Edit1.Text;
   //cells[1,2] 1. seans ara
   time1:=strtoDateTime(stringGrid1.Cells[1,1]);
   decodetime(time1,st,dk,sn,sl);
   x:=dk+ilky;
   if (x>=0) and (x<60) then begin
      st:=st;
      dk:=x;
   end
   else if x=60 then begin
      st:=st+1;
      dk:=0;
   end
   else if (x>60) and (x<120) then begin
      st:=st+1;
      dk:=Abs(x-60);
   end
   else if  x=120 then begin
      st:=st+2;
      dk:=0;
   end
   else if (x>120) and (x<180) then begin
      st:=st+2;
      dk:=Abs(x-120);
   end;

   //st ifadesi 24 ve üzerinde ise ayarla
   if st=24 then st:=0;
   if st=25 then st:=1;
   if st=26 then st:=2;
   if st=27 then st:=3;
   if st=28 then st:=4;
   if st in [0..9] then
      stformat:='0'+inttostr(st)
   else
      stformat:=inttostr(st);
   //dakikayı iki basamaklı notasyonda ayarla
   if  (dk in [0..9]) then
      stringGrid1.Cells[1,2]:=stformat+':'+'0'+inttostr(dk)
   else
      stringGrid1.Cells[1,2]:=stformat+':'+inttostr(dk);
   //cells[1,3] 1.seans ikinci yarı
   time1:=strtoDateTime(stringGrid1.Cells[1,2]);
   decodetime(time1,st,dk,sn,sl);
   x:=dk+ikinciy;
   if (x>=0) and (x<60) then begin
      st:=st;
      dk:=x;
   end
   else if x=60 then begin
      st:=st+1;
      dk:=0;
   end
   else if (x>60) and (x<120) then begin
      st:=st+1;
      dk:=Abs(x-60);
   end
   else if  x=120 then begin
      st:=st+2;
      dk:=0;
   end
   else if (x>120) and (x<180) then begin
      st:=st+2;
      dk:=Abs(x-120);
   end;
   //st ifadesi 24 ve üzerinde ise ayarla
   if st=24 then st:=0;
   if st=25 then st:=1;
   if st=26 then st:=2;
   if st=27 then st:=3;
   if st=28 then st:=4;
   if st in [0..9] then
      stformat:='0'+inttostr(st)
   else
      stformat:=inttostr(st);
   //dakikayı iki basamaklı notasyonda ayarla
   if  (dk in [0..9]) then
      stringGrid1.Cells[1,3]:=stformat+':'+'0'+inttostr(dk)
   else
      stringGrid1.Cells[1,3]:=stformat+':'+inttostr(dk);
   //---------------------------------------------------------------------------
   //cells[2,1] 2. seans başlama saati
   stringGrid1.Cells[2,1]:=stringGrid1.Cells[1,3];
   //cells[2,2] 2. seans ara
   time1:=strtoDateTime(stringGrid1.Cells[2,1]);
   decodetime(time1,st,dk,sn,sl);
   x:=dk+ilky;
   if (x>=0) and (x<60) then begin
      st:=st;
      dk:=x;
   end
   else if x=60 then begin
      st:=st+1;
      dk:=0;
   end
   else if (x>60) and (x<120) then begin
      st:=st+1;
      dk:=Abs(x-60);
   end
   else if  x=120 then begin
      st:=st+2;
      dk:=0;
   end
   else if (x>120) and (x<180) then begin
      st:=st+2;
      dk:=Abs(x-120);
   end;
   //st ifadesi 24 ve üzerinde ise ayarla
   if st=24 then st:=0;
   if st=25 then st:=1;
   if st=26 then st:=2;
   if st=27 then st:=3;
   if st=28 then st:=4;
   if st in [0..9] then
      stformat:='0'+inttostr(st)
   else
      stformat:=inttostr(st);
   //dakikayı iki basamaklı notasyonda ayarla
   if  (dk in [0..9]) then
      stringGrid1.Cells[2,2]:=stformat+':'+'0'+inttostr(dk)
   else
      stringGrid1.Cells[2,2]:=stformat+':'+inttostr(dk);
   //cells[2,3] 2. seans  ikinci yarı
   time1:=strtoDateTime(stringGrid1.Cells[2,2]);
   decodetime(time1,st,dk,sn,sl);
   x:=dk+ikinciy;
   if (x>=0) and (x<60) then begin
      st:=st;
      dk:=x;
   end
   else if x=60 then begin
      st:=st+1;
      dk:=0;
   end
   else if (x>60) and (x<120) then begin
      st:=st+1;
      dk:=Abs(x-60);
   end
   else if  x=120 then begin
      st:=st+2;
      dk:=0;
   end
   else if (x>120) and (x<180) then begin
      st:=st+2;
      dk:=Abs(x-120);
   end;
   //st ifadesi 24 ve üzerinde ise ayarla
   if st=24 then st:=0;
   if st=25 then st:=1;
   if st=26 then st:=2;
   if st=27 then st:=3;
   if st=28 then st:=4;
   if st in [0..9] then
      stformat:='0'+inttostr(st)
   else
      stformat:=inttostr(st);
   //dakikayı iki basamaklı notasyonda ayarla
   if  (dk in [0..9]) then
      stringGrid1.Cells[2,3]:=stformat+':'+'0'+inttostr(dk)
   else
      stringGrid1.Cells[2,3]:=stformat+':'+inttostr(dk);
   //---------------------------------------------------------------------------
   //cells[3,1] 3. seans başlama saati
   stringGrid1.Cells[3,1]:=stringGrid1.Cells[2,3];
   //cells[3,2] 3. seans ara
   time1:=strtoDateTime(stringGrid1.Cells[3,1]);
   decodetime(time1,st,dk,sn,sl);
   x:=dk+ilky;
   if (x>=0) and (x<60) then begin
      st:=st;
      dk:=x;
   end
   else if x=60 then begin
      st:=st+1;
      dk:=0;
   end
   else if (x>60) and (x<120) then begin
      st:=st+1;
      dk:=Abs(x-60);
   end
   else if  x=120 then begin
      st:=st+2;
      dk:=0;
   end
   else if (x>120) and (x<180) then begin
      st:=st+2;
      dk:=Abs(x-120);
   end;
   //st ifadesi 24 ve üzerinde ise ayarla
   if st=24 then st:=0;
   if st=25 then st:=1;
   if st=26 then st:=2;
   if st=27 then st:=3;
   if st=28 then st:=4;
   if st in [0..9] then
      stformat:='0'+inttostr(st)
   else
      stformat:=inttostr(st);
   //dakikayı iki basamaklı notasyonda ayarla
   if  (dk in [0..9]) then
      stringGrid1.Cells[3,2]:=stformat+':'+'0'+inttostr(dk)
   else
   stringGrid1.Cells[3,2]:=stformat+':'+inttostr(dk);
   //cells[3,3] 3. seans  ikinci yarı
   time1:=strtoDateTime(stringGrid1.Cells[3,2]);
   decodetime(time1,st,dk,sn,sl);
   x:=dk+ikinciy;
   if (x>=0) and (x<60) then begin
      st:=st;
      dk:=x;
   end
   else if x=60 then begin
      st:=st+1;
      dk:=0;
   end
   else if (x>60) and (x<120) then begin
      st:=st+1;
      dk:=Abs(x-60);
   end
   else if  x=120 then begin
      st:=st+2;
      dk:=0;
   end
   else if (x>120) and (x<180) then begin
      st:=st+2;
      dk:=Abs(x-120);
   end;
   //st ifadesi 24 ve üzerinde ise ayarla
   if st=24 then st:=0;
   if st=25 then st:=1;
   if st=26 then st:=2;
   if st=27 then st:=3;
   if st=28 then st:=4;
   if st in [0..9] then
      stformat:='0'+inttostr(st)
   else
      stformat:=inttostr(st);
   //dakikayı iki basamaklı notasyonda ayarla}
   if  (dk in [0..9]) then
      stringGrid1.Cells[3,3]:=stformat+':'+'0'+inttostr(dk)
   else
      stringGrid1.Cells[3,3]:=stformat+':'+inttostr(dk);
   //---------------------------------------------------------------------------
   //cells[4,1] 4. seans başlama saati
   stringGrid1.Cells[4,1]:=stringGrid1.Cells[3,3];
   //cells[4,2] 4. seans ara
   time1:=strtoDateTime(stringGrid1.Cells[4,1]);
   decodetime(time1,st,dk,sn,sl);
   x:=dk+ilky;
   if (x>=0) and (x<60) then begin
      st:=st;
      dk:=x;
   end
   else if x=60 then begin
      st:=st+1;
      dk:=0;
   end
   else if (x>60) and (x<120) then begin
      st:=st+1;
      dk:=Abs(x-60);
   end
   else if  x=120 then begin
      st:=st+2;
      dk:=0;
   end
   else if (x>120) and (x<180) then begin
      st:=st+2;
      dk:=Abs(x-120);
   end;
   //st ifadesi 24 ve üzerinde ise ayarla
   if st=24 then st:=0;
   if st=25 then st:=1;
   if st=26 then st:=2;
   if st=27 then st:=3;
   if st=28 then st:=4;
   if st in [0..9] then
      stformat:='0'+inttostr(st)
   else
      stformat:=inttostr(st);
   //dakikayı iki basamaklı notasyonda ayarla
   if  (dk in [0..9]) then
      stringGrid1.Cells[4,2]:=stformat+':'+'0'+inttostr(dk)
   else
      stringGrid1.Cells[4,2]:=stformat+':'+inttostr(dk);
   //cells[4,3] 4. seans  ikinci yarı
   time1:=strtoDateTime(stringGrid1.Cells[4,2]);
   decodetime(time1,st,dk,sn,sl);
   x:=dk+ikinciy;
   if (x>=0) and (x<60) then begin
      st:=st;
      dk:=x;
   end
   else if x=60 then begin
      st:=st+1;
      dk:=0;
   end
   else if (x>60) and (x<120) then begin
      st:=st+1;
      dk:=Abs(x-60);
   end
   else if  x=120 then begin
      st:=st+2;
      dk:=0;
   end
   else if (x>120) and (x<180) then begin
      st:=st+2;
      dk:=Abs(x-120);
   end;
   //st ifadesi 24 ve üzerinde ise ayarla
   if st=24 then st:=0;
   if st=25 then st:=1;
   if st=26 then st:=2;
   if st=27 then st:=3;
   if st=28 then st:=4;
   if st in [0..9] then
      stformat:='0'+inttostr(st)
   else
      stformat:=inttostr(st);
   //dakikayı iki basamaklı notasyonda ayarla
   if  (dk in [0..9]) then
      stringGrid1.Cells[4,3]:=stformat+':'+'0'+inttostr(dk)
   else
      stringGrid1.Cells[4,3]:=stformat+':'+inttostr(dk);
   //---------------------------------------------------------------------------
   //cells[5,1] 5. seans başlama saati
   stringGrid1.Cells[5,1]:=stringGrid1.Cells[4,3];
   //cells[5,2] 5. seans ara
   time1:=strtoDateTime(stringGrid1.Cells[5,1]);
   decodetime(time1,st,dk,sn,sl);
   x:=dk+ilky;
   if (x>=0) and (x<60) then begin
      st:=st;
      dk:=x;
   end
   else if x=60 then begin
      st:=st+1;
      dk:=0;
   end
   else if (x>60) and (x<120) then begin
      st:=st+1;
      dk:=Abs(x-60);
   end
   else if  x=120 then begin
      st:=st+2;
      dk:=0;
   end
   else if (x>120) and (x<180) then begin
      st:=st+2;
      dk:=Abs(x-120);
   end;
   //st ifadesi 24 ve üzerinde ise ayarla
   if st=24 then st:=0;
   if st=25 then st:=1;
   if st=26 then st:=2;
   if st=27 then st:=3;
   if st=28 then st:=4;
   if st in [0..9] then
      stformat:='0'+inttostr(st)
   else
      stformat:=inttostr(st);
   //dakikayı iki basamaklı notasyonda ayarla
   if  (dk in [0..9]) then
      stringGrid1.Cells[5,2]:=stformat+':'+'0'+inttostr(dk)
   else
      stringGrid1.Cells[5,2]:=stformat+':'+inttostr(dk);
   //cells[5,3] 5. seans  ikinci yarı
   time1:=strtoDateTime(stringGrid1.Cells[5,2]);
   decodetime(time1,st,dk,sn,sl);
   x:=dk+ikinciy;
   if (x>=0) and (x<60) then begin
      st:=st;
      dk:=x;
   end
   else if x=60 then begin
      st:=st+1;
      dk:=0;
   end
   else if (x>60) and (x<120) then begin
      st:=st+1;
      dk:=Abs(x-60);
   end
   else if  x=120 then begin
      st:=st+2;
      dk:=0;
   end
   else if (x>120) and (x<180) then begin
      st:=st+2;
      dk:=Abs(x-120);
   end;
   //st ifadesi 24 ve üzerinde ise ayarla
   if st=24 then st:=0;
   if st=25 then st:=1;
   if st=26 then st:=2;
   if st=27 then st:=3;
   if st=28 then st:=4;
   if st in [0..9] then
      stformat:='0'+inttostr(st)
   else
      stformat:=inttostr(st);
   //dakikayı iki basamaklı notasyonda ayarla
   if  (dk in [0..9]) then
      stringGrid1.Cells[5,3]:=stformat+':'+'0'+inttostr(dk)
   else
      stringGrid1.Cells[5,3]:=stformat+':'+inttostr(dk);
   //---------------------------------------------------------------------------
   //cells[6,1] 6. seans başlama saati
   stringGrid1.Cells[6,1]:=stringGrid1.Cells[5,3];
   //cells[6,2] 6. seans ara
   time1:=strtoDateTime(stringGrid1.Cells[6,1]);
   decodetime(time1,st,dk,sn,sl);
   x:=dk+ilky;
   if (x>=0) and (x<60) then begin
      st:=st;
      dk:=x;
   end
   else if x=60 then begin
      st:=st+1;
      dk:=0;
   end
   else if (x>60) and (x<120) then begin
      st:=st+1;
      dk:=Abs(x-60);
   end
   else if  x=120 then begin
      st:=st+2;
      dk:=0;
   end
   else if (x>120) and (x<180) then begin
      st:=st+2;
      dk:=Abs(x-120);
   end;
   //st ifadesi 24 ve üzerinde ise ayarla
   if st=24 then st:=0;
   if st=25 then st:=1;
   if st=26 then st:=2;
   if st=27 then st:=3;
   if st=28 then st:=4;
   if st in [0..9] then
      stformat:='0'+inttostr(st)
   else
      stformat:=inttostr(st);
   //dakikayı iki basamaklı notasyonda ayarla
   if  (dk in [0..9]) then
      stringGrid1.Cells[6,2]:=stformat+':'+'0'+inttostr(dk)
   else
      stringGrid1.Cells[6,2]:=stformat+':'+inttostr(dk);
   //cells[6,3] 6. seans  ikinci yarı
   time1:=strtoDateTime(stringGrid1.Cells[6,2]);
   decodetime(time1,st,dk,sn,sl);
   x:=dk+ikinciy;
   if (x>=0) and (x<60) then begin
      st:=st;
      dk:=x;
   end
   else if x=60 then begin
      st:=st+1;
      dk:=0;
   end
   else if (x>60) and (x<120) then begin
      st:=st+1;
      dk:=Abs(x-60);
   end
   else if  x=120 then begin
      st:=st+2;
      dk:=0;
   end
   else if (x>120) and (x<180) then begin
      st:=st+2;
      dk:=Abs(x-120);
   end;
   //st ifadesi 24 ve üzerinde ise ayarla
   if st=24 then st:=0;
   if st=25 then st:=1;
   if st=26 then st:=2;
   if st=27 then st:=3;
   if st=28 then st:=4;
   if st in [0..9] then
      stformat:='0'+inttostr(st)
   else
      stformat:=inttostr(st);
   //dakikayı iki basamaklı notasyonda ayarla
   if  (dk in [0..9]) then
      stringGrid1.Cells[6,3]:=stformat+':'+'0'+inttostr(dk)
   else
      stringGrid1.Cells[6,3]:=stformat+':'+inttostr(dk);
end;


her seferde StringGrid1 te hücreleri [1,1],[1,2]... alıp hesaplamaları yapıyor.Bu uzun işlemi tek bir fonksiyonda yapacak zamanım olmadı...

5 seansın StringGrid'teki değerlerini  PopupMenu ile seçip kopyalıyalım:

StringGrid1.PopupMenu:=PopupMenu1;

kopyalam işlemini bu kod ile yapıyoruz:

Kod: [Seç]
procedure TForm1.m11Click(Sender: TObject);
var
 i,j,LeftCell,TopCell : Integer;
   BottomCell, RightCell : Integer;
   TextBuf : String;
   SysClip : TClipBoard;
begin
   SysClip := TClipBoard.Create;
   //trap the Control-C or Control-c keys
  // if (Shift = [ssCtrl]) and ((Key = 67) or (Key = 99)) then begin
      //get the coordinates of the selected region of the grid
      LeftCell := StringGrid1.Selection.Left;
      TopCell := StringGrid1.Selection.Top;
      BottomCell := StringGrid1.Selection.Bottom;
      RightCell := StringGrid1.Selection.Right;
      //The variable TextBuf is used to hold the information that will to to the clipboard
      TextBuf := '';
      //for all of the selected cells, copy the contents to
      //TextBuf and separate lines by returns and cells by tabs
      for i := TopCell to BottomCell do begin
         for j := LeftCell to RightCell do begin
            if j = LeftCell then
               TextBuf := TextBuf + StringGrid1.Cells[j,i]
            else
               TextBuf := TextBuf + #09 + StringGrid1.Cells[j,i];
         end;
         TextBuf := TextBuf + #13#10;
      end;
      //Now move the contents of TextBuf to the windows clipboard
      SysClip.AsText := TextBuf;
      //destroy the clipboard object , this does not affect
      //the contents in the Windows clipboard
      SysClip.Destroy;
   //end;

end;


program:


excel'e kopyalama:


« Son Düzenleme: 16 Nisan 2007 17:20:11 by Fatih »