Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Отчёт по практике.doc
Скачиваний:
5
Добавлен:
03.11.2018
Размер:
653.82 Кб
Скачать

Приложение 1

Form 1

//---------------------------------------------------------------------------

#include <vcl.h>

#pragma hdrstop

#include "stdio.h"

#include <comobj.hpp>

#include <utilcls.h>

#include "Unit1.h"

#include "Unit2.h"

#include "Unit3.h"

#include "Unit4.h"

#include "ABOUT.h"

//---------------------------------------------------------------------------

#pragma package(smart_init)

#pragma link "DBAccess"

#pragma link "MemDS"

#pragma link "MyAccess"

#pragma link "MyDacVcl"

#pragma link "DAScript"

#pragma link "MyScript"

#pragma resource "*.dfm"

TForm1 *Form1;

int ProjectToFind, PeopleToFind;

bool Grant;

//---------------------------------------------------------------------------

__fastcall TForm1::TForm1(TComponent* Owner)

: TForm(Owner)

{

}

//---------------------------------------------------------------------------

void __fastcall TForm1::FormCreate(TObject *Sender)

{

MyQuery1->Active=True;

MyQuery2->Close();

MyQuery2->SQL->Clear();

MyQuery2->SQL->Add("SELECT * FROM Jobs WHERE ProjectName='"+MyQuery1->FieldByName("ProjectName")->Text+"'");

MyQuery2->Active=True;

ShortDateFormat = "yyyy/mm/dd";

DateTimePicker1->Date=Now();

DateTimePicker2->Date=Now();

if(MyConnection1->Username=="manager" || MyConnection1->Username=="admin")

Grant=true;

else

Grant=false;

// заполнение комбобоксов

int Count;

MyQuery3->Close();

MyQuery3->SQL->Clear();

MyQuery3->SQL->Add("SELECT DISTINCT AccountManager FROM Projects");

MyQuery3->Open();

MyQuery3->FindFirst();

for(Count=0;Count<MyQuery3->RecordCount;Count++){

ComboBox2->Items->Add(MyQuery3->FieldByName("AccountManager")->Text);

//Form2->ComboBox2->Items->Add(MyQuery3->FieldByName("AccountManager")->Text);

MyQuery3->Next();

}

MyQuery3->Close();

MyQuery3->SQL->Clear();

MyQuery3->SQL->Add("SELECT DISTINCT Client FROM Projects");

MyQuery3->Open();

MyQuery3->FindFirst();

for(Count=0;Count<MyQuery3->RecordCount;Count++){

ComboBox3->Items->Add(MyQuery3->FieldByName("Client")->Text);

//Form2->ComboBox7->Items->Add(MyQuery3->FieldByName("Client")->Text);

MyQuery3->Next();

}

MyQuery3->Close();

MyQuery3->SQL->Clear();

MyQuery3->SQL->Add("SELECT DISTINCT ProjectManager FROM Projects");

MyQuery3->Open();

MyQuery3->FindFirst();

for(Count=0;Count<MyQuery3->RecordCount;Count++){

ComboBox6->Items->Add(MyQuery3->FieldByName("ProjectManager")->Text);

//Form2->ComboBox8->Items->Add(MyQuery3->FieldByName("ProjectManager")->Text);

MyQuery3->Next();

}

MyQuery3->Close();

}

//---------------------------------------------------------------------------

void __fastcall TForm1::N2Click(TObject *Sender)

{

bool RPP=false;

Form2->Caption="Добавление проекта";

Form2->ComboBox1->Text="";

Form2->ComboBox2->Text="";

Form2->ComboBox3->Text="";

Form2->ComboBox4->Text="";

Form2->ComboBox7->Text="";

Form2->ComboBox8->Text="";

Form2->ComboBox19->Text="";

for(int i=1; i<36; i++)

for(int j=0; j<10; j++)

if(j>=3&&j<=7)

Form2->StringGrid1->Cells[j][i]="0";

else

Form2->StringGrid1->Cells[j][i]="";

Form2->Edit1->Text="";

Form2->Edit2->Text="";

Form2->Edit3->Text="";

Form2->Edit22->Text="0";

Form2->CheckBox1->State=cbUnchecked;

ShortDateFormat = "yyyy/mm/dd";

Form2->MonthCalendar1->Date=Now(); //сброс календаря на текущую дату

Form2->MonthCalendar1->EndDate=Now();

Form2->Memo1->Text="";

//поиск первой свободной ячейки архива

Form2->MyQuery1->Close();

Form2->MyQuery1->SQL->Clear();

Form2->MyQuery1->SQL->Add("SELECT CellArch FROM Projects WHERE CellArch>0 ORDER BY CellArch ASC");

Form2->MyQuery1->Open();

Form2->DBGrid1->DataSource->DataSet->First();

for(int i=1; i<31; i++)

if(i==Form2->DBGrid1->Fields[0]->Text)

Form2->DBGrid1->DataSource->DataSet->Next();

else{

Form2->Edit22->Text=IntToStr(i);

break;}

if(Form2->ShowModal()==mrOk){

String Payment;

if(Form2->CheckBox1->State==cbChecked) Payment="да";

else Payment="нет";

if(Grant){

MyScript1->SQL->Clear();

if(Form2->ComboBox1->Text=="закрыт"){

if(Form2->Edit22->Text=="")

MyScript1->SQL->Add("INSERT INTO Projects (Number, ProjectName, AccountManager, ProjectManager, DateInsert, DateStart, DateEnd, DateClose, Client, ProjectStat, Pay, TypePay, ProjectSum, Comment, Time) VALUES (NULL , '"+Form2->Edit1->Text+"', '"+Form2->ComboBox2->Text+"', '"+Form2->ComboBox7->Text+"', '"+DateToStr(Now())+"', '"+Form2->Edit2->Text+"', '"+Form2->Edit3->Text+"', '"+DateToStr(Now())+"', '"+Form2->ComboBox8->Text+"', '"+Form2->ComboBox1->Text+"', '"+Payment+"', '"+Form2->ComboBox19->Text+"', '"+Form2->StringGrid2->Cells[0][0]+"', '"+Form2->Memo1->Text+"', NULL)");

else

MyScript1->SQL->Add("INSERT INTO Projects (Number, ProjectName, AccountManager, ProjectManager, DateInsert, DateStart, DateEnd, DateClose, Client, ProjectStat, Pay, CellArch, TypePay, ProjectSum, Comment, Time) VALUES (NULL , '"+Form2->Edit1->Text+"', '"+Form2->ComboBox2->Text+"', '"+Form2->ComboBox7->Text+"', '"+DateToStr(Now())+"', '"+Form2->Edit2->Text+"', '"+Form2->Edit3->Text+"', '"+DateToStr(Now())+"', '"+Form2->ComboBox8->Text+"', '"+Form2->ComboBox1->Text+"', '"+Payment+"', '"+Form2->Edit22->Text+"', '"+Form2->ComboBox19->Text+"', '"+Form2->StringGrid2->Cells[0][0]+"', '"+Form2->Memo1->Text+"', NULL)");

}

else{

if(Form2->Edit22->Text=="")

MyScript1->SQL->Add("INSERT INTO Projects (Number, ProjectName, AccountManager, ProjectManager, DateStart, DateEnd, Client, ProjectStat, Pay, TypePay, ProjectSum, Comment, Time) VALUES (NULL , '"+Form2->Edit1->Text+"', '"+Form2->ComboBox2->Text+"', '"+Form2->ComboBox7->Text+"', '"+DateToStr(Now())+"', '"+Form2->Edit2->Text+"', '"+Form2->Edit3->Text+"', '"+Form2->ComboBox8->Text+"', '"+Form2->ComboBox1->Text+"', '"+Payment+"', '"+Form2->ComboBox19->Text+"', '"+Form2->StringGrid2->Cells[0][0]+"', '"+Form2->Memo1->Text+"', NULL)");

else

MyScript1->SQL->Add("INSERT INTO Projects (Number, ProjectName, AccountManager, ProjectManager, DateInsert, DateStart, DateEnd, Client, ProjectStat, Pay, CellArch, TypePay, ProjectSum, Comment, Time) VALUES (NULL , '"+Form2->Edit1->Text+"', '"+Form2->ComboBox2->Text+"', '"+Form2->ComboBox7->Text+"', '"+DateToStr(Now())+"', '"+Form2->Edit2->Text+"', '"+Form2->Edit3->Text+"', '"+Form2->ComboBox8->Text+"', '"+Form2->ComboBox1->Text+"', '"+Payment+"', '"+Form2->Edit22->Text+"', '"+Form2->ComboBox19->Text+"', '"+Form2->StringGrid2->Cells[0][0]+"', '"+Form2->Memo1->Text+"', NULL)");

}

MyScript1->Execute();

MyQuery1->Refresh();

DBGrid1->DataSource->DataSet->First();

for (int i=1; i < 36; i++) {

if(Form2->StringGrid1->Cells[0][i]=="РПП" || Form2->StringGrid1->Cells[0][i]=="Рпп" || Form2->StringGrid1->Cells[0][i]=="рпп")

RPP=true;

if(Form2->StringGrid1->Cells[1][i]!=""){

if(Form2->StringGrid1->Cells[2][i]=="")

Form2->StringGrid1->Cells[2][i]="0";

if(Form2->StringGrid1->Cells[3][i]=="")

Form2->StringGrid1->Cells[3][i]="0";

MyScript1->SQL->Clear();

MyScript1->SQL->Add("INSERT INTO Jobs(ProjectName, Job, Staff, Status, Price, Days, Sum, Fond, Salary, PayStatus, Comment) VALUES ('"+Form2->Edit1->Text+"', '"+Form2->StringGrid1->Cells[0][i]+"', '"+Form2->StringGrid1->Cells[1][i]+"', '"+Form2->StringGrid1->Cells[2][i]+"', '"+StrToInt(Form2->StringGrid1->Cells[3][i])+"', '"+StrToInt(Form2->StringGrid1->Cells[4][i])+"', '"+StrToInt(Form2->StringGrid1->Cells[5][i])+"', '"+StrToInt(Form2->StringGrid1->Cells[6][i])+"', '"+StrToInt(Form2->StringGrid1->Cells[7][i])+"', '"+Form2->StringGrid1->Cells[8][i]+"', '"+Form2->StringGrid1->Cells[9][i]+"')");

MyScript1->Execute();

}

}

}

else

{

MyScript1->SQL->Clear();

if(Form2->ComboBox1->Text=="закрыт"){

if(Form2->Edit22->Text=="")

MyScript1->SQL->Add("INSERT INTO ProjectsView (Number, ProjectName, AccountManager, ProjectManager, DateInsert, DateStart, DateEnd, DateClose, Client, ProjectStat, Pay, TypePay, ProjectSum, Comment, Time) VALUES (NULL , '"+Form2->Edit1->Text+"', '"+Form2->ComboBox2->Text+"', '"+Form2->ComboBox7->Text+"', '"+DateToStr(Now())+"', '"+Form2->Edit2->Text+"', '"+Form2->Edit3->Text+"', '"+DateToStr(Now())+"', '"+Form2->ComboBox8->Text+"', '"+Form2->ComboBox1->Text+"', '"+Payment+"', '"+Form2->ComboBox19->Text+"', '"+Form2->StringGrid2->Cells[0][0]+"', '"+Form2->Memo1->Text+"', NULL)");

else

MyScript1->SQL->Add("INSERT INTO ProjectsView (Number, ProjectName, AccountManager, ProjectManager, DateInsert, DateStart, DateEnd, DateClose, Client, ProjectStat, Pay, CellArch, TypePay, ProjectSum, Comment, Time) VALUES (NULL , '"+Form2->Edit1->Text+"', '"+Form2->ComboBox2->Text+"', '"+Form2->ComboBox7->Text+"', '"+DateToStr(Now())+"', '"+Form2->Edit2->Text+"', '"+Form2->Edit3->Text+"', '"+DateToStr(Now())+"', '"+Form2->ComboBox8->Text+"', '"+Form2->ComboBox1->Text+"', '"+Payment+"', '"+Form2->Edit22->Text+"', '"+Form2->ComboBox19->Text+"', '"+Form2->StringGrid2->Cells[0][0]+"', '"+Form2->Memo1->Text+"', NULL)");

}

else{

if(Form2->Edit22->Text=="")

MyScript1->SQL->Add("INSERT INTO ProjectsView (Number, ProjectName, AccountManager, ProjectManager, DateStart, DateEnd, Client, ProjectStat, Pay, TypePay, ProjectSum, Comment, Time) VALUES (NULL , '"+Form2->Edit1->Text+"', '"+Form2->ComboBox2->Text+"', '"+Form2->ComboBox7->Text+"', '"+DateToStr(Now())+"', '"+Form2->Edit2->Text+"', '"+Form2->Edit3->Text+"', '"+Form2->ComboBox8->Text+"', '"+Form2->ComboBox1->Text+"', '"+Payment+"', '"+Form2->ComboBox19->Text+"', '"+Form2->StringGrid2->Cells[0][0]+"', '"+Form2->Memo1->Text+"', NULL)");

else

MyScript1->SQL->Add("INSERT INTO ProjectsView (Number, ProjectName, AccountManager, ProjectManager, DateInsert, DateStart, DateEnd, Client, ProjectStat, Pay, CellArch, TypePay, ProjectSum, Comment, Time) VALUES (NULL , '"+Form2->Edit1->Text+"', '"+Form2->ComboBox2->Text+"', '"+Form2->ComboBox7->Text+"', '"+DateToStr(Now())+"', '"+Form2->Edit2->Text+"', '"+Form2->Edit3->Text+"', '"+Form2->ComboBox8->Text+"', '"+Form2->ComboBox1->Text+"', '"+Payment+"', '"+Form2->Edit22->Text+"', '"+Form2->ComboBox19->Text+"', '"+Form2->StringGrid2->Cells[0][0]+"', '"+Form2->Memo1->Text+"', NULL)");

}

MyScript1->Execute();

MyQuery1->Refresh();

DBGrid1->DataSource->DataSet->First();

for (int i=1; i < 36; i++) {

if(Form2->StringGrid1->Cells[0][i]=="РПП" || Form2->StringGrid1->Cells[0][i]=="Рпп" || Form2->StringGrid1->Cells[0][i]=="рпп")

RPP=true;

if(Form2->StringGrid1->Cells[1][i]!=""){

if(Form2->StringGrid1->Cells[2][i]=="")

Form2->StringGrid1->Cells[2][i]="0";

if(Form2->StringGrid1->Cells[3][i]=="")

Form2->StringGrid1->Cells[3][i]="0";

MyScript1->SQL->Clear();

MyScript1->SQL->Add("INSERT INTO JobsView(ProjectName, Job, Staff, Status, Price, Days, Sum, Fond, Salary, PayStatus, Comment) VALUES ('"+Form2->Edit1->Text+"', '"+Form2->StringGrid1->Cells[0][i]+"', '"+Form2->StringGrid1->Cells[1][i]+"', '"+Form2->StringGrid1->Cells[2][i]+"', '"+StrToInt(Form2->StringGrid1->Cells[3][i])+"', '"+StrToInt(Form2->StringGrid1->Cells[4][i])+"', '"+StrToInt(Form2->StringGrid1->Cells[5][i])+"', '"+StrToInt(Form2->StringGrid1->Cells[6][i])+"', '"+StrToInt(Form2->StringGrid1->Cells[7][i])+"', '"+Form2->StringGrid1->Cells[8][i]+"', '"+Form2->StringGrid1->Cells[9][i]+"')");

MyScript1->Execute();

}

}

}

MyQuery2->Refresh();

if(RPP==false)

MessageBox(NULL, "Вы не добавили РПП, вы можете добавить РПП позднее.", "Обратите внимание!", MB_OK | MB_ICONWARNING);

}

}

//---------------------------------------------------------------------------

void __fastcall TForm1::DBGrid1DblClick(TObject *Sender)

{

Form2->Caption="Редактирование проекта: "+DBGrid1->Fields[1]->Text;

Form2->ComboBox1->Text="";

Form2->ComboBox2->Text="";

Form2->ComboBox3->Text="";

Form2->ComboBox4->Text="";

Form2->ComboBox7->Text="";

Form2->ComboBox8->Text="";

Form2->ComboBox19->Text="";

ShortDateFormat = "yyyy/mm/dd";

for(int i=1; i<36; i++)

for(int j=0; j<10; j++)

if(j>=3&&j<=7)

Form2->StringGrid1->Cells[j][i]="0";

else

Form2->StringGrid1->Cells[j][i]="";

Form2->Edit1->Text="";

Form2->Edit2->Text="";

Form2->Edit3->Text="";

Form2->Edit22->Text="0";

Form2->MonthCalendar1->Date=Now(); //сброс календаря на текущую дату

Form2->MonthCalendar1->EndDate=Now();

Form2->Edit1->Text=MyQuery1->FieldByName("ProjectName")->Text;

String OldNameProj=MyQuery1->FieldByName("ProjectName")->Text;

Form2->ComboBox2->Text=MyQuery1->FieldByName("AccountManager")->Text;

Form2->ComboBox7->Text=MyQuery1->FieldByName("ProjectManager")->Text;

Form2->Edit2->Text=MyQuery1->FieldByName("DateStart")->Text;

Form2->Edit3->Text=MyQuery1->FieldByName("DateEnd")->Text;

if(Form2->Edit2->Text!="")

Form2->MonthCalendar1->Date=StrToDate(Form2->Edit2->Text); // Form2->Edit2->Text.FormatString("dd.mm.yyyy") );

if(Form2->Edit3->Text!="")

Form2->MonthCalendar1->EndDate=StrToDate(Form2->Edit3->Text);

Form2->ComboBox8->Text=MyQuery1->FieldByName("Client")->Text;

Form2->ComboBox1->Text=MyQuery1->FieldByName("ProjectStat")->Text;

String OldStatus=MyQuery1->FieldByName("ProjectStat")->Text;

if(MyQuery1->FieldByName("Pay")->Text=="да") Form2->CheckBox1->State=cbChecked;

else Form2->CheckBox1->State=cbUnchecked;

Form2->Edit22->Text=MyQuery1->FieldByName("CellArch")->Text;

Form2->ComboBox19->Text=MyQuery1->FieldByName("TypePay")->Text;

//Form2->Edit20->Text=MyQuery1->FieldByName("ProjectSum")->Text;

Form2->Memo1->Text=MyQuery1->FieldByName("Comment")->Text;

String OldStaff[36];

String OldWork[36];

DBGrid2->DataSource->DataSet->First();

int j=1;

do{

Form2->StringGrid1->Cells[0][j]=DBGrid2->Fields[0]->Text;

OldStaff[j]=DBGrid2->Fields[1]->Text;

OldWork[j]=DBGrid2->Fields[0]->Text;

Form2->StringGrid1->Cells[1][j]=DBGrid2->Fields[1]->Text;

Form2->StringGrid1->Cells[2][j]=DBGrid2->Fields[2]->Text;

Form2->StringGrid1->Cells[3][j]=DBGrid2->Fields[3]->Text;

Form2->StringGrid1->Cells[4][j]=DBGrid2->Fields[4]->Text;

Form2->StringGrid1->Cells[5][j]=DBGrid2->Fields[5]->Text;

Form2->StringGrid1->Cells[6][j]=DBGrid2->Fields[6]->Text;

Form2->StringGrid1->Cells[7][j]=DBGrid2->Fields[7]->Text;

Form2->StringGrid1->Cells[8][j]=DBGrid2->Fields[8]->Text;

Form2->StringGrid1->Cells[9][j]=DBGrid2->Fields[9]->Text;

DBGrid2->DataSource->DataSet->Next();

j++;

}

while(j<DBGrid2->DataSource->DataSet->RecordCount+1);

DBGrid2->DataSource->DataSet->First();

if(Form2->ShowModal()==mrOk){

String Payment;

if(Form2->CheckBox1->State==cbChecked) Payment="да";

else Payment="нет";

if(Grant){ //пользователи с правами работают через таблицы

MyScript1->SQL->Clear();

if(Form2->ComboBox1->Text=="закрыт"&&OldStatus!="закрыт"){

if(Form2->Edit22->Text==""||Form2->Edit22->Text=="0")

MyScript1->SQL->Add("UPDATE Projects SET ProjectName = '"+Form2->Edit1->Text+"', AccountManager = '"+Form2->ComboBox2->Text+"', ProjectManager = '"+Form2->ComboBox7->Text+"', DateStart = '"+Form2->Edit2->Text+"', DateEnd = '"+Form2->Edit3->Text+"', DateClose = '"+DateToStr(Now())+"', Client = '"+Form2->ComboBox8->Text+"', ProjectStat = '"+Form2->ComboBox1->Text+"', Pay = '"+Payment+"', CellArch = 0, TypePay = '"+Form2->ComboBox19->Text+"', ProjectSum = '"+Form2->StringGrid2->Cells[0][0]+"', Comment = '"+Form2->Memo1->Text+"' WHERE Number = "+DBGrid1->Fields[0]->Text);

else

MyScript1->SQL->Add("UPDATE Projects SET ProjectName = '"+Form2->Edit1->Text+"', AccountManager = '"+Form2->ComboBox2->Text+"', ProjectManager = '"+Form2->ComboBox7->Text+"', DateStart = '"+Form2->Edit2->Text+"', DateEnd = '"+Form2->Edit3->Text+"', DateClose = '"+DateToStr(Now())+"', Client = '"+Form2->ComboBox8->Text+"', ProjectStat = '"+Form2->ComboBox1->Text+"', Pay = '"+Payment+"', CellArch = '"+Form2->Edit22->Text+"', TypePay = '"+Form2->ComboBox19->Text+"', ProjectSum = '"+Form2->StringGrid2->Cells[0][0]+"', Comment = '"+Form2->Memo1->Text+"' WHERE Number = "+DBGrid1->Fields[0]->Text);

}

else{

if(Form2->Edit22->Text==""||Form2->Edit22->Text=="0")

MyScript1->SQL->Add("UPDATE Projects SET ProjectName = '"+Form2->Edit1->Text+"', AccountManager = '"+Form2->ComboBox2->Text+"', ProjectManager = '"+Form2->ComboBox7->Text+"', DateStart = '"+Form2->Edit2->Text+"', DateEnd = '"+Form2->Edit3->Text+"', Client = '"+Form2->ComboBox8->Text+"', ProjectStat = '"+Form2->ComboBox1->Text+"', Pay = '"+Payment+"', CellArch = 0, TypePay = '"+Form2->ComboBox19->Text+"', ProjectSum = '"+Form2->StringGrid2->Cells[0][0]+"', Comment = '"+Form2->Memo1->Text+"' WHERE Number = "+DBGrid1->Fields[0]->Text);

else

MyScript1->SQL->Add("UPDATE Projects SET ProjectName = '"+Form2->Edit1->Text+"', AccountManager = '"+Form2->ComboBox2->Text+"', ProjectManager = '"+Form2->ComboBox7->Text+"', DateStart = '"+Form2->Edit2->Text+"', DateEnd = '"+Form2->Edit3->Text+"', Client = '"+Form2->ComboBox8->Text+"', ProjectStat = '"+Form2->ComboBox1->Text+"', Pay = '"+Payment+"', CellArch = '"+Form2->Edit22->Text+"', TypePay = '"+Form2->ComboBox19->Text+"', ProjectSum = '"+Form2->StringGrid2->Cells[0][0]+"', Comment = '"+Form2->Memo1->Text+"' WHERE Number = "+DBGrid1->Fields[0]->Text);

}

MyScript1->Execute();

MyQuery1->Refresh();

for(int i=1; i<36; i++){

if(Form2->StringGrid1->Cells[0][i]!=""&&OldWork[i]!=""){

MyScript1->SQL->Clear();

MyScript1->SQL->Add("UPDATE Jobs SET ProjectName = '"+Form2->Edit1->Text+"', Job = '"+Form2->StringGrid1->Cells[0][i]+"', Staff = '"+Form2->StringGrid1->Cells[1][i]+"', Status = '"+Form2->StringGrid1->Cells[2][i]+"', Price = "+StrToInt(Form2->StringGrid1->Cells[3][i])+", Days = "+StrToInt(Form2->StringGrid1->Cells[4][i])+", Sum = "+StrToInt(Form2->StringGrid1->Cells[5][i])+", Fond = "+StrToInt(Form2->StringGrid1->Cells[6][i])+", Salary = "+StrToInt(Form2->StringGrid1->Cells[7][i])+", PayStatus = '"+Form2->StringGrid1->Cells[8][i]+"', Comment = '"+Form2->StringGrid1->Cells[9][i]+"' WHERE ProjectName = '"+OldNameProj+"' AND Staff = '"+OldStaff[i]+"' AND Job = '"+OldWork[i]+"'");

MyScript1->Execute();

}

else if(Form2->StringGrid1->Cells[0][i]!=""&&OldWork[i]==""){

MyScript1->SQL->Clear();

MyScript1->SQL->Add("INSERT INTO Jobs(ProjectName, Job, Staff, Status, Price, Days, Sum, Fond, Salary, PayStatus, Comment) VALUES ('"+Form2->Edit1->Text+"', '"+Form2->StringGrid1->Cells[0][i]+"', '"+Form2->StringGrid1->Cells[1][i]+"', '"+Form2->StringGrid1->Cells[2][i]+"', '"+StrToInt(Form2->StringGrid1->Cells[3][i])+"', '"+StrToInt(Form2->StringGrid1->Cells[4][i])+"', '"+StrToInt(Form2->StringGrid1->Cells[5][i])+"', '"+StrToInt(Form2->StringGrid1->Cells[6][i])+"', '"+StrToInt(Form2->StringGrid1->Cells[7][i])+"', '"+Form2->StringGrid1->Cells[8][i]+"', '"+Form2->StringGrid1->Cells[9][i]+"')");

MyScript1->Execute();

}

}

}

else //если нет прав то через View

{

MyScript1->SQL->Clear();

if(Form2->ComboBox1->Text=="закрыт"&&OldStatus!="закрыт"){

if(Form2->Edit22->Text==""||Form2->Edit22->Text=="0")

MyScript1->SQL->Add("UPDATE ProjectsView SET ProjectName = '"+Form2->Edit1->Text+"', AccountManager = '"+Form2->ComboBox2->Text+"', ProjectManager = '"+Form2->ComboBox7->Text+"', DateStart = '"+Form2->Edit2->Text+"', DateEnd = '"+Form2->Edit3->Text+"', DateClose = '"+DateToStr(Now())+"', Client = '"+Form2->ComboBox8->Text+"', ProjectStat = '"+Form2->ComboBox1->Text+"', Pay = '"+Payment+"', CellArch = 0, TypePay = '"+Form2->ComboBox19->Text+"', ProjectSum = '"+Form2->StringGrid2->Cells[0][0]+"', Comment = '"+Form2->Memo1->Text+"' WHERE Number = "+DBGrid1->Fields[0]->Text);

else

MyScript1->SQL->Add("UPDATE ProjectsView SET ProjectName = '"+Form2->Edit1->Text+"', AccountManager = '"+Form2->ComboBox2->Text+"', ProjectManager = '"+Form2->ComboBox7->Text+"', DateStart = '"+Form2->Edit2->Text+"', DateEnd = '"+Form2->Edit3->Text+"', DateClose = '"+DateToStr(Now())+"', Client = '"+Form2->ComboBox8->Text+"', ProjectStat = '"+Form2->ComboBox1->Text+"', Pay = '"+Payment+"', CellArch = '"+Form2->Edit22->Text+"', TypePay = '"+Form2->ComboBox19->Text+"', ProjectSum = '"+Form2->StringGrid2->Cells[0][0]+"', Comment = '"+Form2->Memo1->Text+"' WHERE Number = "+DBGrid1->Fields[0]->Text);

}

else{

if(Form2->Edit22->Text==""||Form2->Edit22->Text=="0")

MyScript1->SQL->Add("UPDATE ProjectsView SET ProjectName = '"+Form2->Edit1->Text+"', AccountManager = '"+Form2->ComboBox2->Text+"', ProjectManager = '"+Form2->ComboBox7->Text+"', DateStart = '"+Form2->Edit2->Text+"', DateEnd = '"+Form2->Edit3->Text+"', Client = '"+Form2->ComboBox8->Text+"', ProjectStat = '"+Form2->ComboBox1->Text+"', Pay = '"+Payment+"', CellArch = 0, TypePay = '"+Form2->ComboBox19->Text+"', ProjectSum = '"+Form2->StringGrid2->Cells[0][0]+"', Comment = '"+Form2->Memo1->Text+"' WHERE Number = "+DBGrid1->Fields[0]->Text);

else

MyScript1->SQL->Add("UPDATE ProjectsView SET ProjectName = '"+Form2->Edit1->Text+"', AccountManager = '"+Form2->ComboBox2->Text+"', ProjectManager = '"+Form2->ComboBox7->Text+"', DateStart = '"+Form2->Edit2->Text+"', DateEnd = '"+Form2->Edit3->Text+"', Client = '"+Form2->ComboBox8->Text+"', ProjectStat = '"+Form2->ComboBox1->Text+"', Pay = '"+Payment+"', CellArch = '"+Form2->Edit22->Text+"', TypePay = '"+Form2->ComboBox19->Text+"', ProjectSum = '"+Form2->StringGrid2->Cells[0][0]+"', Comment = '"+Form2->Memo1->Text+"' WHERE Number = "+DBGrid1->Fields[0]->Text);

}

MyScript1->Execute();

MyQuery1->Refresh();

for(int i=1; i<36; i++){

if(Form2->StringGrid1->Cells[0][i]!=""&&OldWork[i]!=""){

MyScript1->SQL->Clear();

MyScript1->SQL->Add("UPDATE JobsView SET ProjectName = '"+Form2->Edit1->Text+"', Job = '"+Form2->StringGrid1->Cells[0][i]+"', Staff = '"+Form2->StringGrid1->Cells[1][i]+"', Status = '"+Form2->StringGrid1->Cells[2][i]+"', Price = "+StrToInt(Form2->StringGrid1->Cells[3][i])+", Days = "+StrToInt(Form2->StringGrid1->Cells[4][i])+", Sum = "+StrToInt(Form2->StringGrid1->Cells[5][i])+", Fond = "+StrToInt(Form2->StringGrid1->Cells[6][i])+", Salary = "+StrToInt(Form2->StringGrid1->Cells[7][i])+", PayStatus = '"+Form2->StringGrid1->Cells[8][i]+"', Comment = '"+Form2->StringGrid1->Cells[9][i]+"' WHERE ProjectName = '"+OldNameProj+"' AND Staff = '"+OldStaff[i]+"' AND Job = '"+OldWork[i]+"'");

MyScript1->Execute();

}

else if(Form2->StringGrid1->Cells[0][i]!=""&&OldWork[i]==""){

MyScript1->SQL->Clear();

MyScript1->SQL->Add("INSERT INTO JobsView(ProjectName, Job, Staff, Status, Price, Days, Sum, Fond, Salary, PayStatus, Comment) VALUES ('"+Form2->Edit1->Text+"', '"+Form2->StringGrid1->Cells[0][i]+"', '"+Form2->StringGrid1->Cells[1][i]+"', '"+Form2->StringGrid1->Cells[2][i]+"', '"+StrToInt(Form2->StringGrid1->Cells[3][i])+"', '"+StrToInt(Form2->StringGrid1->Cells[4][i])+"', '"+StrToInt(Form2->StringGrid1->Cells[5][i])+"', '"+StrToInt(Form2->StringGrid1->Cells[6][i])+"', '"+StrToInt(Form2->StringGrid1->Cells[7][i])+"', '"+Form2->StringGrid1->Cells[8][i]+"', '"+Form2->StringGrid1->Cells[9][i]+"')");

MyScript1->Execute();

}

}

if(OldStatus=="закрыт")

MessageBox(NULL, "У вас нет прав для изменения закрытых проектов! Изменения не будут сохранены!", "Внимание!", MB_OK | MB_ICONWARNING);

}

MyQuery2->Refresh();

}

}

//---------------------------------------------------------------------------

void __fastcall TForm1::N4Click(TObject *Sender)

{

Close();

}

//---------------------------------------------------------------------------

void __fastcall TForm1::DBGrid1DrawColumnCell(TObject *Sender, const TRect &Rect,

int DataCol, TColumn *Column, TGridDrawState State)

{

if ((MyQuery1->FieldByName("ProjectStat")->Text=="закрыт")&&(Column->FieldName=="ProjectStat"))

{

DBGrid1->Canvas->Brush->Color=clFuchsia;

DBGrid1->Canvas->Font->Color=clBlack;

DBGrid1->Canvas->FillRect(Rect);

if (Column->Alignment==taRightJustify)

{

DBGrid1->Canvas->TextOut(Rect.Right-2-

DBGrid1->Canvas->TextWidth(Column->Field->Text),

Rect.Top+2,Column->Field->Text);

}

else

{

DBGrid1->Canvas->TextOut(Rect.Left+2,Rect.Top+2,Column->Field->Text);

}

}

if ((MyQuery1->FieldByName("ProjectStat")->Text=="сдан")&&(Column->FieldName=="ProjectStat"))

{

DBGrid1->Canvas->Brush->Color=clLime;

DBGrid1->Canvas->Font->Color=clBlack;

DBGrid1->Canvas->FillRect(Rect);

if (Column->Alignment==taRightJustify)

{

DBGrid1->Canvas->TextOut(Rect.Right-2-

DBGrid1->Canvas->TextWidth(Column->Field->Text),

Rect.Top+2,Column->Field->Text);

}

else

{

DBGrid1->Canvas->TextOut(Rect.Left+2,Rect.Top+2,Column->Field->Text);

}

}

if ((MyQuery1->FieldByName("ProjectStat")->Text=="в работе")&&(Column->FieldName=="ProjectStat"))

{

DBGrid1->Canvas->Brush->Color=clYellow;

DBGrid1->Canvas->Font->Color=clBlack;

DBGrid1->Canvas->FillRect(Rect);

if (Column->Alignment==taRightJustify)

{

DBGrid1->Canvas->TextOut(Rect.Right-2-

DBGrid1->Canvas->TextWidth(Column->Field->Text),

Rect.Top+2,Column->Field->Text);

}

else

{

DBGrid1->Canvas->TextOut(Rect.Left+2,Rect.Top+2,Column->Field->Text);

}

}

if ((MyQuery1->FieldByName("ProjectStat")->Text=="отменен")&&(Column->FieldName=="ProjectStat"))

{

DBGrid1->Canvas->Brush->Color=clRed;

DBGrid1->Canvas->Font->Color=clBlack;

DBGrid1->Canvas->FillRect(Rect);

if (Column->Alignment==taRightJustify)

{

DBGrid1->Canvas->TextOut(Rect.Right-2-

DBGrid1->Canvas->TextWidth(Column->Field->Text),

Rect.Top+2,Column->Field->Text);

}

else

{

DBGrid1->Canvas->TextOut(Rect.Left+2,Rect.Top+2,Column->Field->Text);

}

}

if ((MyQuery1->FieldByName("ProjectStat")->Text=="открыт")&&(Column->FieldName=="ProjectStat"))

{

DBGrid1->Canvas->Brush->Color=clBlue;

DBGrid1->Canvas->Font->Color=clHighlightText;

DBGrid1->Canvas->FillRect(Rect);

if (Column->Alignment==taRightJustify)

{

DBGrid1->Canvas->TextOut(Rect.Right-2-

DBGrid1->Canvas->TextWidth(Column->Field->Text),

Rect.Top+2,Column->Field->Text);

}

else

{

DBGrid1->Canvas->TextOut(Rect.Left+2,Rect.Top+2,Column->Field->Text);

}

}

Graphics::TBitmap *Im1;

Im1= new Graphics::TBitmap;

if

(Column->FieldName=="Pay")

{

DBGrid1->Canvas->Brush->Color=clWhite;

DBGrid1->Canvas->FillRect(Rect);

if (MyQuery1->FieldByName("Pay")->Text=="да")

{

ImageList1->GetBitmap(1,Im1);

}

else

{

ImageList1->GetBitmap(0,Im1);

}

DBGrid1->Canvas->Draw((Rect.Left+Rect.Right-Im1->Width)/2,Rect.Top,Im1);

}

}

//---------------------------------------------------------------------------

void __fastcall TForm1::DBGrid1TitleClick(TColumn *Column)

{

if(MyQuery1->SQL->Strings[MyQuery1->SQL->Count-1]!=""){

MyQuery1->Close();

if(MyQuery1->SQL->Strings[MyQuery1->SQL->Count-1]=="ORDER BY "+DBGrid1->Columns->Items[Column->Index]->FieldName+" DESC")

MyQuery1->SQL->Strings[MyQuery1->SQL->Count-1]="ORDER BY "+DBGrid1->Columns->Items[Column->Index]->FieldName+" ASC";

else

MyQuery1->SQL->Strings[MyQuery1->SQL->Count-1]="ORDER BY "+DBGrid1->Columns->Items[Column->Index]->FieldName+" DESC";

MyQuery1->Open();

}

}

//---------------------------------------------------------------------------

void __fastcall TForm1::N5Click(TObject *Sender)

{

String SQLOld[10]; //запись предыдущего запроса

int SqlRowCount,SqlCount=MyQuery1->SQL->Count;

for(SqlRowCount=0; SqlRowCount<SqlCount; SqlRowCount++)

SQLOld[SqlRowCount]=MyQuery1->SQL->Strings[SqlRowCount];

MyQuery1->Close();

MyQuery1->SQL->Clear();

MyQuery1->SQL->Add("SELECT * FROM Projects WHERE CellArch>0 ORDER BY CellArch ASC");

MyQuery1->Open();

Variant app ;

Variant books ;

Variant book ;

Variant sheet ;

AnsiString sFile = GetCurrentDir()+"\\table.xlt";

//...

app = CreateOleObject("Excel.Application");

books = app.OlePropertyGet("Workbooks");

try

{ //Попытка открытия

Procedure Open("Open");

books.Exec(Open << sFile);

}

catch(...)

{ //Попытка не удалась

MessageBox(NULL,"Ошибка открытия шаблона Excel!",

"Ошибка",MB_OK | MB_ICONERROR); }

book = books.OlePropertyGet("item",1);

sheet= book.OlePropertyGet("WorkSheets",1);

app.OlePropertySet("Visible", 1);

//...

DBGrid1->DataSource->DataSet->First();

int j=0;

do{

sheet.OlePropertyGet("Cells").OlePropertyGet("Item",4+j,1).OlePropertySet("Value", DBGrid1->Fields[10]->Text.t_str());

sheet.OlePropertyGet("Cells").OlePropertyGet("Item",4+j,2).OlePropertySet("Value", DBGrid1->Fields[1]->Text.t_str());

sheet.OlePropertyGet("Cells").OlePropertyGet("Item",4+j,4).OlePropertySet("Value", DBGrid1->Fields[13]->Text.t_str());

DBGrid1->DataSource->DataSet->Next();

j++;

}

while(j<DBGrid1->DataSource->DataSet->RecordCount);

MyQuery1->Close();

MyQuery1->SQL->Clear();

for(SqlRowCount=0; SqlRowCount<SqlCount; SqlRowCount++)

MyQuery1->SQL->Add(SQLOld[SqlRowCount]); //возвращение предыдущего запроса

MyQuery1->Open();

}

//---------------------------------------------------------------------------

void __fastcall TForm1::N7Click(TObject *Sender)

{

AboutBox->ShowModal();

}

//---------------------------------------------------------------------------

void __fastcall TForm1::N9Click(TObject *Sender)

{

Form3->Show();

}

//---------------------------------------------------------------------------

void __fastcall TForm1::N10Click(TObject *Sender)

{

Form4->Show();

}

//---------------------------------------------------------------------------

void __fastcall TForm1::FormResize(TObject *Sender)

{

/*DBGrid1->Height=Form1->Height-291;

DBGrid2->Top=Form1->Height-229;

Image2->Top=Form1->Height-213;

SpeedButton1->Top=Height-115; */

}

//---------------------------------------------------------------------------

void __fastcall TForm1::Button3Click(TObject *Sender)

{

MyQuery1->Close();

MyQuery1->SQL->Clear();

MyQuery1->SQL->Add("SELECT * FROM Projects");

if(CheckBox1->Checked==true)

MyQuery1->SQL->Add("WHERE ProjectStat!='закрыт' AND ProjectStat!='отменен'");

if(CheckBox2->Checked==true){

if(CheckBox1->Checked==false)

MyQuery1->SQL->Add("WHERE AccountManager='"+ComboBox2->Text+"'");

else

MyQuery1->SQL->Add("AND AccountManager='"+ComboBox2->Text+"'");

}

if(CheckBox3->Checked==true){

if(CheckBox1->Checked==true || CheckBox2->Checked==true)

MyQuery1->SQL->Add("AND Client='"+ComboBox3->Text+"'");

else

MyQuery1->SQL->Add("WHERE Client='"+ComboBox3->Text+"'");

}

if(CheckBox4->Checked==true){

if(CheckBox1->Checked==true || CheckBox2->Checked==true || CheckBox3->Checked==true)

MyQuery1->SQL->Add("AND Pay='"+ComboBox5->Text+"'");

else

MyQuery1->SQL->Add("WHERE Pay='"+ComboBox5->Text+"'");

}

if(CheckBox5->Checked==true){

if(CheckBox1->Checked==true || CheckBox2->Checked==true || CheckBox3->Checked==true || CheckBox4->Checked==true)

if(ComboBox4->Text=="открытия")

MyQuery1->SQL->Add("AND DateInsert>='"+DateToStr(DateTimePicker1->Date)+"' AND DateInsert<='"+DateToStr(DateTimePicker2->Date)+"'");

else

MyQuery1->SQL->Add("AND DateClose>='"+DateToStr(DateTimePicker1->Date)+"' AND DateClose<='"+DateToStr(DateTimePicker2->Date)+"'");

else

if(ComboBox4->Text=="открытия")

MyQuery1->SQL->Add("WHERE DateInsert>='"+DateToStr(DateTimePicker1->Date)+"' AND DateInsert<='"+DateToStr(DateTimePicker2->Date)+"'");

else

MyQuery1->SQL->Add("WHERE DateClose>='"+DateToStr(DateTimePicker1->Date)+"' AND DateClose<='"+DateToStr(DateTimePicker2->Date)+"'");

}

if(CheckBox6->Checked==true){

if(CheckBox1->Checked==true || CheckBox2->Checked==true || CheckBox3->Checked==true || CheckBox4->Checked==true || CheckBox5->Checked==true)

MyQuery1->SQL->Add("AND ProjectStat='"+ComboBox1->Text+"'");

else

MyQuery1->SQL->Add("WHERE ProjectStat='"+ComboBox1->Text+"'");

}

if(CheckBox7->Checked==true){

if(CheckBox1->Checked==true || CheckBox2->Checked==true || CheckBox3->Checked==true || CheckBox4->Checked==true || CheckBox5->Checked==true || CheckBox6->Checked==true)

MyQuery1->SQL->Add("AND ProjectManager='"+ComboBox6->Text+"'");

else

MyQuery1->SQL->Add("WHERE ProjectManager='"+ComboBox6->Text+"'");

}

MyQuery1->SQL->Add("ORDER BY Number DESC");

MyQuery1->Open();

DBGrid1->SetFocus();

}

//---------------------------------------------------------------------------

void __fastcall TForm1::MyQuery1AfterScroll(TDataSet *DataSet)

{

MyQuery2->Close();

MyQuery2->SQL->Clear();

MyQuery2->SQL->Add("SELECT * FROM Jobs WHERE ProjectName='"+MyQuery1->FieldByName("ProjectName")->Text+"'");

MyQuery2->Open();

}

//---------------------------------------------------------------------------

void __fastcall TForm1::N12Click(TObject *Sender)

{

MyScript1->SQL->Clear();

if(Grant)

MyScript1->SQL->Add("UPDATE Projects SET Pay = 'да' WHERE ProjectName = '"+MyQuery1->FieldByName("ProjectName")->Text+"'");

else

MyScript1->SQL->Add("UPDATE ProjectsView SET Pay = 'да' WHERE ProjectName = '"+MyQuery1->FieldByName("ProjectName")->Text+"'");

MyScript1->Execute();

MyQuery1->Refresh();

}

//---------------------------------------------------------------------------

void __fastcall TForm1::N13Click(TObject *Sender)

{

MyScript1->SQL->Clear();

if(Grant)

MyScript1->SQL->Add("UPDATE Projects SET Pay = 'нет' WHERE ProjectName = '"+MyQuery1->FieldByName("ProjectName")->Text+"'");

else

MyScript1->SQL->Add("UPDATE ProjectsView SET Pay = 'нет' WHERE ProjectName = '"+MyQuery1->FieldByName("ProjectName")->Text+"'");

MyScript1->Execute();

MyQuery1->Refresh();

}

//---------------------------------------------------------------------------

void __fastcall TForm1::N15Click(TObject *Sender)

{

MyScript1->SQL->Clear();

if(Grant)

MyScript1->SQL->Add("UPDATE Projects SET ProjectStat = 'открыт' WHERE ProjectName = '"+MyQuery1->FieldByName("ProjectName")->Text+"'");

else

MyScript1->SQL->Add("UPDATE ProjectsView SET ProjectStat = 'открыт' WHERE ProjectName = '"+MyQuery1->FieldByName("ProjectName")->Text+"'");

MyScript1->Execute();

MyQuery1->Refresh();

}

//---------------------------------------------------------------------------

void __fastcall TForm1::N16Click(TObject *Sender)

{

MyScript1->SQL->Clear();

if(Grant)

MyScript1->SQL->Add("UPDATE Projects SET ProjectStat = 'в работе' WHERE ProjectName = '"+MyQuery1->FieldByName("ProjectName")->Text+"'");

else

MyScript1->SQL->Add("UPDATE ProjectsView SET ProjectStat = 'в работе' WHERE ProjectName = '"+MyQuery1->FieldByName("ProjectName")->Text+"'");

MyScript1->Execute();

MyQuery1->Refresh();

}

//---------------------------------------------------------------------------

void __fastcall TForm1::N17Click(TObject *Sender)

{

MyScript1->SQL->Clear();

if(Grant)

MyScript1->SQL->Add("UPDATE Projects SET ProjectStat = 'сдан' WHERE ProjectName = '"+MyQuery1->FieldByName("ProjectName")->Text+"'");

else

MyScript1->SQL->Add("UPDATE ProjectsView SET ProjectStat = 'сдан' WHERE ProjectName = '"+MyQuery1->FieldByName("ProjectName")->Text+"'");

MyScript1->Execute();

MyQuery1->Refresh();

}

//---------------------------------------------------------------------------

void __fastcall TForm1::N18Click(TObject *Sender)

{

if(Grant){

MyScript1->SQL->Clear();

MyScript1->SQL->Add("UPDATE Projects SET ProjectStat = 'закрыт' WHERE ProjectName = '"+MyQuery1->FieldByName("ProjectName")->Text+"'");

MyScript1->Execute();

MyQuery1->Refresh();}

}

//---------------------------------------------------------------------------

void __fastcall TForm1::N19Click(TObject *Sender)

{

MyScript1->SQL->Clear();

if(Grant)

MyScript1->SQL->Add("UPDATE Projects SET ProjectStat = 'отменен' WHERE ProjectName = '"+MyQuery1->FieldByName("ProjectName")->Text+"'");

else

MyScript1->SQL->Add("UPDATE ProjectsView SET ProjectStat = 'отменен' WHERE ProjectName = '"+MyQuery1->FieldByName("ProjectName")->Text+"'");

MyScript1->Execute();

MyQuery1->Refresh();

}

//---------------------------------------------------------------------------

void __fastcall TForm1::N20Click(TObject *Sender)

{

Form2->Caption="Добавление проекта";

Form2->ComboBox1->Text="";

Form2->ComboBox2->Text="";

Form2->ComboBox3->Text="";

Form2->ComboBox4->Text="";

Form2->ComboBox7->Text="";

Form2->ComboBox8->Text="";

Form2->ComboBox19->Text="";

ShortDateFormat = "yyyy/mm/dd";

for(int i=1; i<36; i++)

for(int j=0; j<10; j++)

if(j>=3&&j<=7)

Form2->StringGrid1->Cells[j][i]="0";

else

Form2->StringGrid1->Cells[j][i]="";

Form2->Edit1->Text="";

Form2->Edit2->Text="";

Form2->Edit3->Text="";

Form2->Edit22->Text="0";

Form2->MonthCalendar1->Date=Now(); //сброс календаря на текущую дату

Form2->MonthCalendar1->EndDate=Now();

Form2->Edit1->Text=MyQuery1->FieldByName("ProjectName")->Text;

Form2->ComboBox2->Text=MyQuery1->FieldByName("AccountManager")->Text;

Form2->ComboBox7->Text=MyQuery1->FieldByName("ProjectManager")->Text;

Form2->Edit2->Text=MyQuery1->FieldByName("DateStart")->Text;

Form2->Edit3->Text=MyQuery1->FieldByName("DateEnd")->Text;

if(Form2->Edit2->Text!="")

Form2->MonthCalendar1->Date=StrToDate(Form2->Edit2->Text); // Form2->Edit2->Text.FormatString("dd.mm.yyyy") );

if(Form2->Edit3->Text!="")

Form2->MonthCalendar1->EndDate=StrToDate(Form2->Edit3->Text);

Form2->ComboBox8->Text=MyQuery1->FieldByName("Client")->Text;

Form2->ComboBox1->Text=MyQuery1->FieldByName("ProjectStat")->Text;

if(MyQuery1->FieldByName("Pay")->Text=="да") Form2->CheckBox1->State=cbChecked;

else Form2->CheckBox1->State=cbUnchecked;

Form2->ComboBox19->Text=MyQuery1->FieldByName("TypePay")->Text;

//Form2->Edit20->Text=MyQuery1->FieldByName("ProjectSum")->Text;

Form2->Memo1->Text=MyQuery1->FieldByName("Comment")->Text;

//поиск первой свободной ячейки архива

Form2->MyQuery1->Close();

Form2->MyQuery1->SQL->Clear();

Form2->MyQuery1->SQL->Add("SELECT CellArch FROM Projects WHERE CellArch>0 ORDER BY CellArch ASC");

Form2->MyQuery1->Open();

Form2->DBGrid1->DataSource->DataSet->First();

for(int i=1; i<31; i++)

if(i==Form2->DBGrid1->Fields[0]->Text)

Form2->DBGrid1->DataSource->DataSet->Next();

else{

Form2->Edit22->Text=IntToStr(i);

break;}

DBGrid2->DataSource->DataSet->First();

int j=1;

do{

Form2->StringGrid1->Cells[0][j]=DBGrid2->Fields[0]->Text;

Form2->StringGrid1->Cells[1][j]=DBGrid2->Fields[1]->Text;

Form2->StringGrid1->Cells[2][j]=DBGrid2->Fields[2]->Text;

Form2->StringGrid1->Cells[3][j]=DBGrid2->Fields[3]->Text;

Form2->StringGrid1->Cells[4][j]=DBGrid2->Fields[4]->Text;

Form2->StringGrid1->Cells[5][j]=DBGrid2->Fields[5]->Text;

Form2->StringGrid1->Cells[6][j]=DBGrid2->Fields[6]->Text;

Form2->StringGrid1->Cells[7][j]=DBGrid2->Fields[7]->Text;

Form2->StringGrid1->Cells[8][j]=DBGrid2->Fields[8]->Text;

Form2->StringGrid1->Cells[9][j]=DBGrid2->Fields[9]->Text;

DBGrid2->DataSource->DataSet->Next();

j++;

}

while(j<DBGrid2->DataSource->DataSet->RecordCount+1);

if(Form2->ShowModal()==mrOk){

String Payment;

if(Form2->CheckBox1->State==cbChecked) Payment="да";

else Payment="нет";

MyScript1->SQL->Clear();

if(Grant){

if(Form2->ComboBox1->Text=="закрыт"){

if(Form2->Edit22->Text=="")

MyScript1->SQL->Add("INSERT INTO Projects (Number, ProjectName, AccountManager, ProjectManager, DateInsert, DateStart, DateEnd, DateClose, Client, ProjectStat, Pay, TypePay, ProjectSum, Comment, Time) VALUES (NULL , '"+Form2->Edit1->Text+"', '"+Form2->ComboBox2->Text+"', '"+Form2->ComboBox7->Text+"', '"+DateToStr(Now())+"', '"+Form2->Edit2->Text+"', '"+Form2->Edit3->Text+"', '"+DateToStr(Now())+"', '"+Form2->ComboBox8->Text+"', '"+Form2->ComboBox1->Text+"', '"+Payment+"', '"+Form2->ComboBox19->Text+"', '"+Form2->StringGrid2->Cells[0][0]+"', '"+Form2->Memo1->Text+"', NULL)");

else

MyScript1->SQL->Add("INSERT INTO Projects (Number, ProjectName, AccountManager, ProjectManager, DateInsert, DateStart, DateEnd, DateClose, Client, ProjectStat, Pay, CellArch, TypePay, ProjectSum, Comment, Time) VALUES (NULL , '"+Form2->Edit1->Text+"', '"+Form2->ComboBox2->Text+"', '"+Form2->ComboBox7->Text+"', '"+DateToStr(Now())+"', '"+Form2->Edit2->Text+"', '"+Form2->Edit3->Text+"', '"+DateToStr(Now())+"', '"+Form2->ComboBox8->Text+"', '"+Form2->ComboBox1->Text+"', '"+Payment+"', '"+Form2->Edit22->Text+"', '"+Form2->ComboBox19->Text+"', '"+Form2->StringGrid2->Cells[0][0]+"', '"+Form2->Memo1->Text+"', NULL)");

}

else{

if(Form2->Edit22->Text=="")

MyScript1->SQL->Add("INSERT INTO Projects (Number, ProjectName, AccountManager, ProjectManager, DateStart, DateEnd, Client, ProjectStat, Pay, TypePay, ProjectSum, Comment, Time) VALUES (NULL , '"+Form2->Edit1->Text+"', '"+Form2->ComboBox2->Text+"', '"+Form2->ComboBox7->Text+"', '"+DateToStr(Now())+"', '"+Form2->Edit2->Text+"', '"+Form2->Edit3->Text+"', '"+Form2->ComboBox8->Text+"', '"+Form2->ComboBox1->Text+"', '"+Payment+"', '"+Form2->ComboBox19->Text+"', '"+Form2->StringGrid2->Cells[0][0]+"', '"+Form2->Memo1->Text+"', NULL)");

else

MyScript1->SQL->Add("INSERT INTO Projects (Number, ProjectName, AccountManager, ProjectManager, DateInsert, DateStart, DateEnd, Client, ProjectStat, Pay, CellArch, TypePay, ProjectSum, Comment, Time) VALUES (NULL , '"+Form2->Edit1->Text+"', '"+Form2->ComboBox2->Text+"', '"+Form2->ComboBox7->Text+"', '"+DateToStr(Now())+"', '"+Form2->Edit2->Text+"', '"+Form2->Edit3->Text+"', '"+Form2->ComboBox8->Text+"', '"+Form2->ComboBox1->Text+"', '"+Payment+"', '"+Form2->Edit22->Text+"', '"+Form2->ComboBox19->Text+"', '"+Form2->StringGrid2->Cells[0][0]+"', '"+Form2->Memo1->Text+"', NULL)");

}

}

else

{

if(Form2->ComboBox1->Text=="закрыт"){

if(Form2->Edit22->Text=="")

MyScript1->SQL->Add("INSERT INTO ProjectsView (Number, ProjectName, AccountManager, ProjectManager, DateInsert, DateStart, DateEnd, DateClose, Client, ProjectStat, Pay, TypePay, ProjectSum, Comment, Time) VALUES (NULL , '"+Form2->Edit1->Text+"', '"+Form2->ComboBox2->Text+"', '"+Form2->ComboBox7->Text+"', '"+DateToStr(Now())+"', '"+Form2->Edit2->Text+"', '"+Form2->Edit3->Text+"', '"+DateToStr(Now())+"', '"+Form2->ComboBox8->Text+"', '"+Form2->ComboBox1->Text+"', '"+Payment+"', '"+Form2->ComboBox19->Text+"', '"+Form2->StringGrid2->Cells[0][0]+"', '"+Form2->Memo1->Text+"', NULL)");

else

MyScript1->SQL->Add("INSERT INTO ProjectsView (Number, ProjectName, AccountManager, ProjectManager, DateInsert, DateStart, DateEnd, DateClose, Client, ProjectStat, Pay, CellArch, TypePay, ProjectSum, Comment, Time) VALUES (NULL , '"+Form2->Edit1->Text+"', '"+Form2->ComboBox2->Text+"', '"+Form2->ComboBox7->Text+"', '"+DateToStr(Now())+"', '"+Form2->Edit2->Text+"', '"+Form2->Edit3->Text+"', '"+DateToStr(Now())+"', '"+Form2->ComboBox8->Text+"', '"+Form2->ComboBox1->Text+"', '"+Payment+"', '"+Form2->Edit22->Text+"', '"+Form2->ComboBox19->Text+"', '"+Form2->StringGrid2->Cells[0][0]+"', '"+Form2->Memo1->Text+"', NULL)");

}

else{

if(Form2->Edit22->Text=="")

MyScript1->SQL->Add("INSERT INTO ProjectsView (Number, ProjectName, AccountManager, ProjectManager, DateStart, DateEnd, Client, ProjectStat, Pay, TypePay, ProjectSum, Comment, Time) VALUES (NULL , '"+Form2->Edit1->Text+"', '"+Form2->ComboBox2->Text+"', '"+Form2->ComboBox7->Text+"', '"+DateToStr(Now())+"', '"+Form2->Edit2->Text+"', '"+Form2->Edit3->Text+"', '"+Form2->ComboBox8->Text+"', '"+Form2->ComboBox1->Text+"', '"+Payment+"', '"+Form2->ComboBox19->Text+"', '"+Form2->StringGrid2->Cells[0][0]+"', '"+Form2->Memo1->Text+"', NULL)");

else

MyScript1->SQL->Add("INSERT INTO ProjectsView (Number, ProjectName, AccountManager, ProjectManager, DateInsert, DateStart, DateEnd, Client, ProjectStat, Pay, CellArch, TypePay, ProjectSum, Comment, Time) VALUES (NULL , '"+Form2->Edit1->Text+"', '"+Form2->ComboBox2->Text+"', '"+Form2->ComboBox7->Text+"', '"+DateToStr(Now())+"', '"+Form2->Edit2->Text+"', '"+Form2->Edit3->Text+"', '"+Form2->ComboBox8->Text+"', '"+Form2->ComboBox1->Text+"', '"+Payment+"', '"+Form2->Edit22->Text+"', '"+Form2->ComboBox19->Text+"', '"+Form2->StringGrid2->Cells[0][0]+"', '"+Form2->Memo1->Text+"', NULL)");

}

}

MyScript1->Execute();

MyQuery1->Refresh();

DBGrid1->DataSource->DataSet->First();

bool RPP=false;

for (int i=1; i < 36; i++) {

if(Form2->StringGrid1->Cells[0][i]=="РПП" || Form2->StringGrid1->Cells[0][i]=="Рпп" || Form2->StringGrid1->Cells[0][i]=="рпп")

RPP=true;

if(Form2->StringGrid1->Cells[1][i]!=""){

if(Form2->StringGrid1->Cells[2][i]=="")

Form2->StringGrid1->Cells[2][i]="0";

if(Form2->StringGrid1->Cells[3][i]=="")

Form2->StringGrid1->Cells[3][i]="0";

MyScript1->SQL->Clear();

if(Grant)

MyScript1->SQL->Add("INSERT INTO Jobs(ProjectName, Job, Staff, Status, Price, Days, Sum, Fond, Salary, PayStatus, Comment) VALUES ('"+Form2->Edit1->Text+"', '"+Form2->StringGrid1->Cells[0][i]+"', '"+Form2->StringGrid1->Cells[1][i]+"', '"+Form2->StringGrid1->Cells[2][i]+"', '"+StrToInt(Form2->StringGrid1->Cells[3][i])+"', '"+StrToInt(Form2->StringGrid1->Cells[4][i])+"', '"+StrToInt(Form2->StringGrid1->Cells[5][i])+"', '"+StrToInt(Form2->StringGrid1->Cells[6][i])+"', '"+StrToInt(Form2->StringGrid1->Cells[7][i])+"', '"+Form2->StringGrid1->Cells[8][i]+"', '"+Form2->StringGrid1->Cells[9][i]+"')");

else

MyScript1->SQL->Add("INSERT INTO JobsView(ProjectName, Job, Staff, Status, Price, Days, Sum, Fond, Salary, PayStatus, Comment) VALUES ('"+Form2->Edit1->Text+"', '"+Form2->StringGrid1->Cells[0][i]+"', '"+Form2->StringGrid1->Cells[1][i]+"', '"+Form2->StringGrid1->Cells[2][i]+"', '"+StrToInt(Form2->StringGrid1->Cells[3][i])+"', '"+StrToInt(Form2->StringGrid1->Cells[4][i])+"', '"+StrToInt(Form2->StringGrid1->Cells[5][i])+"', '"+StrToInt(Form2->StringGrid1->Cells[6][i])+"', '"+StrToInt(Form2->StringGrid1->Cells[7][i])+"', '"+Form2->StringGrid1->Cells[8][i]+"', '"+Form2->StringGrid1->Cells[9][i]+"')");

MyScript1->Execute();

}

}

MyQuery2->Refresh();

if(RPP==false)

MessageBox(NULL, "Вы не добавили РПП, вы можете добавить РПП позднее.", "Обратите внимание!", MB_OK | MB_ICONWARNING);

}

}

//---------------------------------------------------------------------------

void __fastcall TForm1::ComboBox1Change(TObject *Sender)

{

if(CheckBox6->Checked==true) Form1->Button3->Click();

}

//---------------------------------------------------------------------------

void __fastcall TForm1::ComboBox2Change(TObject *Sender)

{

if(CheckBox2->Checked==true) Form1->Button3->Click();

}

//---------------------------------------------------------------------------

void __fastcall TForm1::ComboBox3Change(TObject *Sender)

{

if(CheckBox3->Checked==true) Form1->Button3->Click();

}

//---------------------------------------------------------------------------

void __fastcall TForm1::ComboBox6Change(TObject *Sender)

{

if(CheckBox7->Checked==true) Form1->Button3->Click();

}

//---------------------------------------------------------------------------

void __fastcall TForm1::ComboBox4Change(TObject *Sender)

{

if(CheckBox5->Checked==true) Form1->Button3->Click();

}

//---------------------------------------------------------------------------

void __fastcall TForm1::DateTimePicker1Change(TObject *Sender)

{

if(CheckBox5->Checked==true) Form1->Button3->Click();

}

//---------------------------------------------------------------------------

void __fastcall TForm1::DateTimePicker2Change(TObject *Sender)

{

if(CheckBox5->Checked==true) Form1->Button3->Click();

}

//---------------------------------------------------------------------------

void __fastcall TForm1::ComboBox5Change(TObject *Sender)

{

if(CheckBox4->Checked==true) Form1->Button3->Click();

}

//---------------------------------------------------------------------------

void __fastcall TForm1::N21Click(TObject *Sender)

{

MyScript1->SQL->Clear();

if(Grant)

MyScript1->SQL->Add("UPDATE Jobs SET PayStatus = 'да' WHERE ProjectName = '"+MyQuery2->FieldByName("ProjectName")->Text+"' AND Staff = '"+MyQuery2->FieldByName("Staff")->Text+"' AND Job = '"+MyQuery2->FieldByName("Job")->Text+"'");

else

MyScript1->SQL->Add("UPDATE JobsView SET PayStatus = 'да' WHERE ProjectName = '"+MyQuery2->FieldByName("ProjectName")->Text+"' AND Staff = '"+MyQuery2->FieldByName("Staff")->Text+"' AND Job = '"+MyQuery2->FieldByName("Job")->Text+"'");

MyScript1->Execute();

MyQuery2->Refresh();

}

//---------------------------------------------------------------------------

void __fastcall TForm1::N22Click(TObject *Sender)

{

MyScript1->SQL->Clear();

if(Grant)

MyScript1->SQL->Add("UPDATE Jobs SET PayStatus = 'нет' WHERE ProjectName = '"+MyQuery2->FieldByName("ProjectName")->Text+"' AND Staff = '"+MyQuery2->FieldByName("Staff")->Text+"' AND Job = '"+MyQuery2->FieldByName("Job")->Text+"'");

else

MyScript1->SQL->Add("UPDATE JobsView SET PayStatus = 'нет' WHERE ProjectName = '"+MyQuery2->FieldByName("ProjectName")->Text+"' AND Staff = '"+MyQuery2->FieldByName("Staff")->Text+"' AND Job = '"+MyQuery2->FieldByName("Job")->Text+"'");

MyScript1->Execute();

MyQuery2->Refresh();

}

//---------------------------------------------------------------------------

void __fastcall TForm1::DBGrid2DblClick(TObject *Sender)

{

Form3->Show();

Form3->ComboBox1->Text=MyQuery2->FieldByName("Staff")->Text;

Form3->Button2->Click();

}

//---------------------------------------------------------------------------

void __fastcall TForm1::DBGrid2DrawColumnCell(TObject *Sender, const TRect &Rect,

int DataCol, TColumn *Column, TGridDrawState State)

{

Graphics::TBitmap *Im1;

Im1= new Graphics::TBitmap;

if

(Column->FieldName=="PayStatus")

{

DBGrid2->Canvas->Brush->Color=clWhite;

DBGrid2->Canvas->FillRect(Rect);

if (MyQuery2->FieldByName("PayStatus")->Text=="да")

{

ImageList1->GetBitmap(1,Im1);

}

else

{

ImageList1->GetBitmap(0,Im1);

}

DBGrid2->Canvas->Draw((Rect.Left+Rect.Right-Im1->Width)/2,Rect.Top,Im1);

}

}

//---------------------------------------------------------------------------

void __fastcall TForm1::MyQuery2AfterOpen(TDataSet *DataSet)

{

MyQuery2->FindFirst();

int sum1=0, sum2=0, sum3=0;

for(int j=0; j<MyQuery2->RecordCount; j++){

if(MyQuery2->FieldByName("Sum")->Text!="")

sum1=StrToInt(MyQuery2->FieldByName("Sum")->Text)+sum1;

if(MyQuery2->FieldByName("Fond")->Text!="")

sum2=StrToInt(MyQuery2->FieldByName("Fond")->Text)+sum2;

if(MyQuery2->FieldByName("Salary")->Text!="")

sum3=StrToInt(MyQuery2->FieldByName("Salary")->Text)+sum3;

MyQuery2->FindNext();

}

StringGrid2->Cells[0][0]=IntToStr(sum3);

StringGrid2->Cells[1][0]=IntToStr(sum2);

StringGrid2->Cells[2][0]=IntToStr(sum1);

MyQuery2->FindFirst();

}

//---------------------------------------------------------------------------

void __fastcall TForm1::MyQuery2AfterRefresh(TDataSet *DataSet)

{

MyQuery2->FindFirst();

int sum1=0, sum2=0, sum3=0;

for(int j=0; j<MyQuery2->RecordCount; j++){

if(MyQuery2->FieldByName("Sum")->Text!="")

sum1=StrToInt(MyQuery2->FieldByName("Sum")->Text)+sum1;

if(MyQuery2->FieldByName("Fond")->Text!="")

sum2=StrToInt(MyQuery2->FieldByName("Fond")->Text)+sum2;

if(MyQuery2->FieldByName("Salary")->Text!="")

sum3=StrToInt(MyQuery2->FieldByName("Salary")->Text)+sum3;

MyQuery2->FindNext();

}

StringGrid2->Cells[0][0]=IntToStr(sum3);

StringGrid2->Cells[1][0]=IntToStr(sum2);

StringGrid2->Cells[2][0]=IntToStr(sum1);

DBGrid2->DataSource->DataSet->RecNo = PeopleToFind;

}

//---------------------------------------------------------------------------

void __fastcall TForm1::MyQuery1AfterOpen(TDataSet *DataSet)

{

MyQuery1->FindFirst();

int sum=0;

for(int j=0; j<MyQuery1->RecordCount; j++){

if(MyQuery1->FieldByName("ProjectSum")->Text!="")

sum=StrToInt(MyQuery1->FieldByName("ProjectSum")->Text)+sum;

MyQuery1->FindNext();

}

Edit1->Text=IntToStr(sum);

MyQuery1->FindFirst();

}

//---------------------------------------------------------------------------

void __fastcall TForm1::MyQuery1AfterRefresh(TDataSet *DataSet)

{

MyQuery1->FindFirst();

int sum=0;

for(int j=0; j<MyQuery1->RecordCount; j++){

if(MyQuery1->FieldByName("ProjectSum")->Text!="")

sum=StrToInt(MyQuery1->FieldByName("ProjectSum")->Text)+sum;

MyQuery1->FindNext();

}

Edit1->Text=IntToStr(sum);

//MyQuery1->FindFirst();

DBGrid1->DataSource->DataSet->RecNo=ProjectToFind;

}

//---------------------------------------------------------------------------

void __fastcall TForm1::Button2Click(TObject *Sender)

{

//int check;

if(Edit2->Text!=""){

MyQuery1->Close();

MyQuery1->SQL->Clear();

MyQuery1->SQL->Add("SELECT * FROM Projects WHERE Number LIKE '%"+Edit2->Text+"%' OR CellArch LIKE '%"+Edit2->Text+"%' OR ProjectSum LIKE '%"+Edit2->Text+"%' OR");

MyQuery1->SQL->Add("ProjectName LIKE '%"+Edit2->Text+"%' OR AccountManager LIKE '%"+Edit2->Text+"%' OR ProjectManager LIKE '%"+Edit2->Text+"%' OR");

MyQuery1->SQL->Add("DateInsert LIKE '%"+Edit2->Text+"%' OR DateStart LIKE '%"+Edit2->Text+"%' OR DateEnd LIKE '%"+Edit2->Text+"%' OR DateClose LIKE '%"+Edit2->Text+"%' OR");

MyQuery1->SQL->Add("Client LIKE '%"+Edit2->Text+"%' OR Comment LIKE '%"+Edit2->Text+"%' OR TypePay LIKE '%"+Edit2->Text+"%'");

MyQuery1->SQL->Add("ORDER BY Number DESC");

MyQuery1->Open();

CheckBox1->Enabled=false;

CheckBox2->Enabled=false;

CheckBox3->Enabled=false;

CheckBox4->Enabled=false;

CheckBox5->Enabled=false;

CheckBox6->Enabled=false;

CheckBox7->Enabled=false;

Button4->Visible=true;}

else

MessageBox(NULL, "Пойди туда, знаю куда, найди то, не знаю что?", "Ахтунг!", MB_OK | MB_ICONWARNING);

}

//---------------------------------------------------------------------------

void __fastcall TForm1::Button4Click(TObject *Sender)

{

Edit2->Text="";

CheckBox1->Enabled=true;

CheckBox2->Enabled=true;

CheckBox3->Enabled=true;

CheckBox4->Enabled=true;

CheckBox5->Enabled=true;

CheckBox6->Enabled=true;

CheckBox7->Enabled=true;

Button3->Click();

Button4->Visible=false;

}

//---------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)

{

CheckBox2->Checked=false;

CheckBox3->Checked=false;

CheckBox4->Checked=false;

CheckBox5->Checked=false;

CheckBox6->Checked=false;

CheckBox7->Checked=false;

Button3->Click();

}

//---------------------------------------------------------------------------

void __fastcall TForm1::MyQuery1BeforeRefresh(TDataSet *DataSet)

{

ProjectToFind = DBGrid1->DataSource->DataSet->RecNo;

}

//---------------------------------------------------------------------------

void __fastcall TForm1::MyQuery2BeforeRefresh(TDataSet *DataSet)

{

PeopleToFind = DBGrid2->DataSource->DataSet->RecNo;

}

//---------------------------------------------------------------------------

void __fastcall TForm1::N23Click(TObject *Sender)

{

MyQuery1->Refresh();

MyQuery2->Refresh();

}

//---------------------------------------------------------------------------

void __fastcall TForm1::Excel1Click(TObject *Sender)

{

if(DBGrid1->DataSource->DataSet->RecordCount<=0)

throw Exception("Нет данных для вывода в Excel, возможно следует поменять параметры фильтрования!");

ProjectToFind = DBGrid1->DataSource->DataSet->RecNo; //если был выбран проект, то выбрать его после вывода в Excel

Variant app ;

Variant books ;

Variant book ;

Variant sheet ;

AnsiString sFile = GetCurrentDir()+"\\proj.xlt";

//...

app = CreateOleObject("Excel.Application");

books = app.OlePropertyGet("Workbooks");

try

{ //Попытка открытия

Procedure Open("Open");

books.Exec(Open << sFile);

}

catch(...)

{ //Попытка не удалась

MessageBox(NULL,"Ошибка открытия шаблона Excel!",

"Ошибка",MB_OK | MB_ICONERROR); }

book = books.OlePropertyGet("item",1);

sheet= book.OlePropertyGet("WorkSheets",1);

app.OlePropertySet("Visible", 1);

//...

DBGrid1->DataSource->DataSet->First();

int j=0;

do{

sheet.OlePropertyGet("Cells").OlePropertyGet("Item",2+j,1).OlePropertySet("Value", DBGrid1->Fields[0]->Text.t_str());

sheet.OlePropertyGet("Cells").OlePropertyGet("Item",2+j,2).OlePropertySet("Value", DBGrid1->Fields[1]->Text.t_str());

sheet.OlePropertyGet("Cells").OlePropertyGet("Item",2+j,3).OlePropertySet("Value", DBGrid1->Fields[2]->Text.t_str());

sheet.OlePropertyGet("Cells").OlePropertyGet("Item",2+j,4).OlePropertySet("Value", DBGrid1->Fields[3]->Text.t_str());

sheet.OlePropertyGet("Cells").OlePropertyGet("Item",2+j,5).OlePropertySet("Value", DBGrid1->Fields[4]->Text.t_str());

sheet.OlePropertyGet("Cells").OlePropertyGet("Item",2+j,6).OlePropertySet("Value", DBGrid1->Fields[5]->Text.t_str());

sheet.OlePropertyGet("Cells").OlePropertyGet("Item",2+j,7).OlePropertySet("Value", DBGrid1->Fields[6]->Text.t_str());

sheet.OlePropertyGet("Cells").OlePropertyGet("Item",2+j,8).OlePropertySet("Value", DBGrid1->Fields[7]->Text.t_str());

sheet.OlePropertyGet("Cells").OlePropertyGet("Item",2+j,9).OlePropertySet("Value", DBGrid1->Fields[8]->Text.t_str());

sheet.OlePropertyGet("Cells").OlePropertyGet("Item",2+j,10).OlePropertySet("Value", DBGrid1->Fields[9]->Text.t_str());

sheet.OlePropertyGet("Cells").OlePropertyGet("Item",2+j,11).OlePropertySet("Value", DBGrid1->Fields[10]->Text.t_str());

sheet.OlePropertyGet("Cells").OlePropertyGet("Item",2+j,12).OlePropertySet("Value", DBGrid1->Fields[11]->Text.t_str());

sheet.OlePropertyGet("Cells").OlePropertyGet("Item",2+j,13).OlePropertySet("Value", DBGrid1->Fields[12]->Text.t_str());

sheet.OlePropertyGet("Cells").OlePropertyGet("Item",2+j,14).OlePropertySet("Value", DBGrid1->Fields[13]->Text.t_str());

sheet.OlePropertyGet("Cells").OlePropertyGet("Item",2+j,15).OlePropertySet("Value", DBGrid1->Fields[14]->Text.t_str());

DBGrid1->DataSource->DataSet->Next();

j++;

}

while(j<DBGrid1->DataSource->DataSet->RecordCount);

DBGrid1->DataSource->DataSet->RecNo = ProjectToFind;

}

//---------------------------------------------------------------------------

38