Unregistered
|
| Код |
#include <vcl.h> #pragma hdrstop
#include "Main.h" #include "TextEdit.h" #include "Zadaniya.h" #include "functions.h"//здесь эта функция лежит #include <ctime> #include <string> #include <stdio.h> #include <stdlib.h> //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TMainForm *MainForm;
struct zadachi { char a[15]; } data, gde, chto;
struct telefon { char a[20]; } imya, telefon;
struct denr { char a[20]; } name, dat;
//void zpd(int,int,int,int,int,int,int,int); //zpd - zapolnenie propushennyh dnej
//--------------------------------------------------------------------------- __fastcall TMainForm::TMainForm(TComponent* Owner) : TForm(Owner) { } //---------------------------------------------------------------------------
int tekpoz; //tekpoz - tekushaya poziciya redaktirovaniya (1=tel, 0=zadachi, 2=DenR) int colwidzad[3];//colwidzad[3] - shirina kazdogo stolbca v zadachah; int colwidtel[3];//colwidzad[3] - shirina kazdogo stolbca v telefonnoj knige;
void __fastcall TMainForm::FormCreate(TObject *Sender) { int stroki, tabraz, flday=0, flmonth=0, kolvozap=0; // flday, flmonth - flagi na den' i mesyac int dneyzap; //skolko zney sey4as zapisanno v tablicu char td[20];//td - tekushaya data; tekpoz=0; MainStringGrid->FixedCols=0; ZadSpeedButton->Flat=True; AddstrButton->Visible=True; DelstrButton->Visible=True; MainStringGrid->Cells[0][0]="Äàòà"; MainStringGrid->Cells[1][0]="Ãäå áûë"; MainStringGrid->Cells[2][0]="×òî äåëàë"; MainMonthCalendar->Date=Date(); Word Day, Month, Year; TDateTime dtPresent = Now(); DecodeDate(dtPresent, Year, Month, Day); if(Day>=1 && Day<=9) flday=1; if(Month>=1 && Month<=9) flmonth=1; FILE *fp; if(FileExists("zadachi.dat")) if((fp=fopen("zadachi.dat","rb"))==NULL) ShowMessage("Îøèáêà ïðè îêðûòèè ôàéëà \"zadachi.dat\""); else {fseek(fp, 2*sizeof(int), SEEK_SET); fread(&tekpoz, -sizeof(int), 1, fp); //chtenie pozicii raboty; // ShowMessage("tekpoz="+IntToStr(tekpoz)); fclose(fp); } else; // ShowMessage("FileNotExists"); //+++++++++++++++++++++++++++++++++ if(tekpoz==0) if((fp=fopen("zadachi.dat","rb"))==NULL) {ShowMessage("Îøèáêà ïðè îêðûòèè ôàéëà \"zadachi.dat\""); if(flday==1) MainStringGrid->Cells[0][1]="0"; MainStringGrid->Cells[0][1]=MainStringGrid->Cells[0][1]+IntToStr(Day)+"."; if(flmonth==1) MainStringGrid->Cells[0][1]=MainStringGrid->Cells[0][1]+"0"; MainStringGrid->Cells[0][1]=MainStringGrid->Cells[0][1]+IntToStr(Month)+"."+IntToStr(Year); } else { register int i=0; fseek(fp, sizeof(int), SEEK_SET); fread(&stroki, sizeof(int), 1, fp); // stroki - kol-vo strok v tablice // ShowMessage("stroki="+IntToStr(stroki)); fseek(fp, sizeof(int), SEEK_CUR); fread(&kolvozap, sizeof(int), 1, fp); MainStringGrid->RowCount=kolvozap+1; i=1; for(int k=1;k<=kolvozap;k++) //kolvozap+1 t.k. 1-ya stroka - nazvaniya; { fread(&data, sizeof(data), 1, fp); //chtenie daty MainStringGrid->Cells[0][i]=data.a; fread(&gde, sizeof(gde), 1, fp); //chtenie mesta MainStringGrid->Cells[1][i]=gde.a; fread(&chto, sizeof(chto), 1, fp); //chtenie del MainStringGrid->Cells[2][i]=chto.a; if(i>1) {int dentek=0, denlast=0, kolvoprop=0; dentek=atoi(MainStringGrid->Cells[0][i].c_str()); denlast=atoi(MainStringGrid->Cells[0][i-1].c_str()); char mesteks[3], meslasts[3]; mesteks[0]=(MainStringGrid->Cells[0][i])[4]; mesteks[1]=(MainStringGrid->Cells[0][i])[5]; mesteks[2]='c'; //c - zdes' T.K. meslasts[0]=(MainStringGrid->Cells[0][i-1])[4]; meslasts[1]=(MainStringGrid->Cells[0][i-1])[5]; meslasts[2]='c'; int meslast=0, mestek=0; meslast=atoi(meslasts); mestek=atoi(mesteks); char yearteks[5], yearlasts[5]; yearteks[0]=(MainStringGrid->Cells[0][i])[7]; yearteks[1]=(MainStringGrid->Cells[0][i])[8]; yearteks[2]=(MainStringGrid->Cells[0][i])[9]; yearteks[3]=(MainStringGrid->Cells[0][i])[10]; yearteks[4]='c'; yearlasts[0]=(MainStringGrid->Cells[0][i-1])[7]; yearlasts[1]=(MainStringGrid->Cells[0][i-1])[8]; yearlasts[2]=(MainStringGrid->Cells[0][i-1])[9]; yearlasts[3]=(MainStringGrid->Cells[0][i-1])[10]; yearlasts[4]='c'; int yearlast=0, yeartek=0; yearlast=atoi(yearlasts); yeartek=atoi(yearteks); kolvoprop=ord(dentek, denlast, mestek, meslast, yeartek, yearlast); MainForm->MainStringGrid->RowCount=MainForm->MainStringGrid->RowCount+kolvoprop; if(kolvoprop>0) {i+=kolvoprop-1; for(int j=0; j<3; j++) MainForm->MainStringGrid->Cells[j][i]=MainForm->MainStringGrid->Cells[j][i-kolvoprop+1]; zpd(i-kolvoprop+1, kolvoprop, dentek, denlast, mestek, meslast, yeartek, yearlast); } } i++; } fseek(fp, -sizeof(int)*3, SEEK_END); fread(colwidzad, sizeof(int)*3, 1, fp);//4tenie shiriny for(int j=0;j<3;j++) MainStringGrid->ColWidths[j]=colwidzad[j]; }
|
и | Код | void zpd(int,int,int,int,int,int,int,int); void zpd(int i,int kolvoprop,int dentek,int denlast,int mestek,int meslast,int yeartek,int yearlast) //zpd - zapolnenie propushennyh dnej { int lastvisyear=-1;
denlast++; //----------------lastyear lastvisyear=visyear(yearlast,yeartek); //---------------- for(;meslast!=mestek || denlast!=dentek || yearlast!=yeartek;) {for(;meslast==1 || meslast==3 || meslast==5 || meslast==7 || meslast==8 || meslast==10 || meslast==12;) if(denlast<=31) { MainForm->MainStringGrid->Cells[0][i]=""; if(denlast>=1 && denlast<=9) MainForm->MainStringGrid->Cells[0][i]="0"; MainForm->MainStringGrid->Cells[0][i]=MainForm->MainStringGrid->Cells[0][i]+IntToStr(denlast); MainForm->MainStringGrid->Cells[0][i]=MainForm->MainStringGrid->Cells[0][i]+"."; if(meslast>=1 && meslast<=9) MainForm->MainStringGrid->Cells[0][i]=MainForm->MainStringGrid->Cells[0][i]+"0"; MainForm->MainStringGrid->Cells[0][i]=MainForm->MainStringGrid->Cells[0][i]+IntToStr(meslast); MainForm->MainStringGrid->Cells[0][i]=MainForm->MainStringGrid->Cells[0][i]+"."; MainForm->MainStringGrid->Cells[0][i]=MainForm->MainStringGrid->Cells[0][i]+IntToStr(yearlast); if(i==MainForm->MainStringGrid->RowCount) MainForm->MainStringGrid->RowCount++; denlast++; i++; if(meslast==mestek && denlast==dentek && yearlast==yeartek) {i--; break; } } else {denlast=1; if(meslast<12) meslast++; else {meslast=1; yearlast++; //----------------lastyear lastvisyear=visyear(yearlast,yeartek); //---------------- } } } if(meslast!=mestek && denlast!=dentek && yearlast!=yeartek) {for(;meslast==4 || meslast==6 || meslast==9 || meslast==11;) if(denlast<=30) { if(denlast>=1 && denlast<=9) MainForm->MainStringGrid->Cells[0][i]="0"; MainForm->MainStringGrid->Cells[0][i]=MainForm->MainStringGrid->Cells[0][i]+IntToStr(denlast); MainForm->MainStringGrid->Cells[0][i]=MainForm->MainStringGrid->Cells[0][i]+"."; if(meslast>=1 && meslast<=9) MainForm->MainStringGrid->Cells[0][i]=MainForm->MainStringGrid->Cells[0][i]+"0"; MainForm->MainStringGrid->Cells[0][i]=MainForm->MainStringGrid->Cells[0][i]+IntToStr(meslast); MainForm->MainStringGrid->Cells[0][i]=MainForm->MainStringGrid->Cells[0][i]+"."; MainForm->MainStringGrid->Cells[0][i]=MainForm->MainStringGrid->Cells[0][i]+IntToStr(yearlast); if(i==MainForm->MainStringGrid->RowCount) MainForm->MainStringGrid->RowCount++; denlast++; i++; if(meslast==mestek && denlast==dentek && yearlast==yeartek) break; }
else {denlast=1; if(meslast<12) meslast++; else {meslast=1; yearlast++; //----------------lastyear lastvisyear=visyear(yearlast,yeartek); //---------------- } } } for(;meslast==2;) {if(lastvisyear==1) if(denlast<=29) { if(denlast>=1 && denlast<=9) MainForm->MainStringGrid->Cells[0][i]="0"; MainForm->MainStringGrid->Cells[0][i]=MainForm->MainStringGrid->Cells[0][i]+IntToStr(denlast); MainForm->MainStringGrid->Cells[0][i]=MainForm->MainStringGrid->Cells[0][i]+"."; if(meslast>=1 && meslast<=9) MainForm->MainStringGrid->Cells[0][i]=MainForm->MainStringGrid->Cells[0][i]+"0"; MainForm->MainStringGrid->Cells[0][i]=MainForm->MainStringGrid->Cells[0][i]+IntToStr(meslast); MainForm->MainStringGrid->Cells[0][i]=MainForm->MainStringGrid->Cells[0][i]+"."; MainForm->MainStringGrid->Cells[0][i]=MainForm->MainStringGrid->Cells[0][i]+IntToStr(yearlast); if(i==MainForm->MainStringGrid->RowCount) MainForm->MainStringGrid->RowCount++; denlast++; i++; if(meslast==mestek && denlast==dentek && yearlast==yeartek) break; } else {denlast=1; meslast++; } if(lastvisyear==0) if(denlast<=28) { if(denlast>=1 && denlast<=9) MainForm->MainStringGrid->Cells[0][i]="0"; MainForm->MainStringGrid->Cells[0][i]=MainForm->MainStringGrid->Cells[0][i]+IntToStr(denlast); MainForm->MainStringGrid->Cells[0][i]=MainForm->MainStringGrid->Cells[0][i]+"."; if(meslast>=1 && meslast<=9) MainForm->MainStringGrid->Cells[0][i]=MainForm->MainStringGrid->Cells[0][i]+"0"; MainForm->MainStringGrid->Cells[0][i]=MainForm->MainStringGrid->Cells[0][i]+IntToStr(meslast); MainForm->MainStringGrid->Cells[0][i]=MainForm->MainStringGrid->Cells[0][i]+"."; MainForm->MainStringGrid->Cells[0][i]=MainForm->MainStringGrid->Cells[0][i]+IntToStr(yearlast); if(i==MainForm->MainStringGrid->RowCount) MainForm->MainStringGrid->RowCount++; denlast++; i++; if(meslast==mestek && denlast==dentek && yearlast==yeartek) break; } else {denlast=1; meslast++; } }
}
|
Это сообщение отредактировал(а) FallenAngel - 5.11.2007, 01:32
|