Файл: Министерство просвещения российской федерации федеральное государственное бюджетное.doc
ВУЗ: Не указан
Категория: Не указан
Дисциплина: Не указана
Добавлен: 27.04.2024
Просмотров: 47
Скачиваний: 0
ВНИМАНИЕ! Если данный файл нарушает Ваши авторские права, то обязательно сообщите нам.
ПРИЛОЖЕНИЕ
Код главной формы написанный на Embarcadero Rad Studio C++Builder 10.2.2 представлен ниже (Безруков В.А., 2009).
//---------------------------------------------------------------------------
#include
#pragma hdrstop
#include "Unit1.h"
#include "Unit2.h"
#include "Unit3.h"
#include "Unit5.h"
#include "Unit7.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner) {}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
{
if (isConnected) {
Form3->Show(); }
Else {
Form1->UserName = "";
Form1->isConnected = false;
Form3->Show(); } }
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Form2->Show();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{ if (Form1->isConnected == true) {
this->Button1->Enabled = true;
this->Button2->Enabled = true;
this->Button4->Enabled = true;
} else {
this->Button1->Enabled = false;
this->Button2->Enabled = false;
this->Button4->Enabled = false;
} this->ADOConnection1->Connected = true; }
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{ Form5->Show(); }
//---------------------------------------------------------------------------
void __fastcall TForm1::Button4Click(TObject *Sender)
{ Form7->Show(); }
//---------------------------------------------------------------------------
Отрывок код главной формы «Информация» написанный на Embarcadero Rad Studio C++Builder 10.2.2 представлен ниже.
//---------------------------------------------------------------------------
#include
#include
#include
#pragma hdrstop
#include "Unit1.h"
#include "Unit2.h"
#include "Unit4.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm2 *Form2;
//---------------------------------------------------------------------------
__fastcall TForm2::TForm2(TComponent* Owner)
: TForm(Owner) { }
//---------------------------------------------------------------------------
void __fastcall TForm2::Button1Click(TObject *Sender)
{ if (Form1->UserName == "Coadmin") {
Form4->DBGrid1->ReadOnly = true;
Form4->DBNavigator1->Visible = false;
Form4->DBNavigator2->Visible = false;
Form4->DBNavigator3->Visible = true; }
if (Form1->UserName == "Admin") {
Form4->DBGrid1->ReadOnly = false;
Form4->DBNavigator1->Visible = true;
Form4->DBNavigator2->Visible = false;
Form4->DBNavigator3->Visible = false;
}
Form4->Show();
Form4->ADOTable1->Active = false;
Form4->ADOTable1->Connection = Form1->ADOConnection1;
Form4->ADOTable1->TableName = "Данные_о_деталях";
Form4->ADOTable1->Active = true;
Form4->DataSource1->DataSet = Form4->ADOTable1;
Form4->DBGrid1->DataSource = Form4->DataSource1;
Form4->DBNavigator1->DataSource = Form4->DataSource1;
Form4->DBNavigator2->DataSource = Form4->DataSource1;
Form4->Caption = Form4->ADOTable1->TableName;
for (int i = 0; i < Form4->DBGrid1->Columns->Count-1; i++)
{ Form4->DBGrid1->Columns->Items[i]->Width=80; } }
//---------------------------------------------------------------------------
Отрывок код главной формы «Информация» с кнопками экспорта данных в Excel, представлен ниже.
//---------------------------------------------------------------------------
void __fastcall TForm2::Button9Click(TObject *Sender)
{ if (Form1->UserName == "Coadmin") {
Form4->DBGrid1->ReadOnly = false;
Form4->DBNavigator1->Visible = false;
Form4->DBNavigator2->Visible = true;
Form4->DBNavigator3->Visible = false; }
if (Form1->UserName == "Admin") {
Form4->DBGrid1->ReadOnly = false;
Form4->DBNavigator1->Visible = true;
Form4->DBNavigator2->Visible = false;
Form4->DBNavigator3->Visible = false;
}
Form4->Show();
Form4->ADOTable1->Active = false;
Form4->ADOTable1->Connection = Form1->ADOConnection1;
Form4->ADOTable1->TableName = "Сотрудники";
Form4->ADOTable1->Active = true;
Form4->DataSource1->DataSet = Form4->ADOTable1;
Form4->DBGrid1->DataSource = Form4->DataSource1;
Form4->DBNavigator1->DataSource = Form4->DataSource1;
Form4->DBNavigator2->DataSource = Form4->DataSource1;
Form4->Caption = Form4->ADOTable1->TableName;
for (int i = 0; i < Form4->DBGrid1->Columns->Count-1; i++)
{ Form4->DBGrid1->Columns->Items[i]->Width=80; }
int k=1,sum=0;;
bool fStart;
if (!fStart)
{ try {
ShowMessage("Test");
vVarApp=CreateOleObject("Excel.Application");
fStart=true;
vVarBooks=vVarApp.OlePropertyGet("Workbooks");
vVarApp.OlePropertySet("SheetsInNewWorkbook",1);
vVarBooks.OleProcedure("Add");
vVarBook=vVarBooks.OlePropertyGet("Item",1);
vVarSheets=vVarBook.OlePropertyGet("Worksheets");
vVarSheet=vVarSheets.OlePropertyGet("Item",1);
vVarSheet.OleProcedure("Activate");
for (int i = 1; i <= Form4->ADOTable1->RecordCount;i++)
//ADOQuery1->RecordCount; i++) {
for (int j = 1; j <= Form4->ADOTable1->FieldCount; j++) {
vVarCell=vVarSheet.OlePropertyGet("Cells").OlePropertyGet("Item",k+5,j);
vVarCell.OlePropertySet("Value",(WideString)Form4->ADOTable1->Fields->Fields[j-1]->AsWideString);
ris_excel();
vVarCell.OlePropertyGet("Borders",7).OlePropertySet("LineStyle",1);
vVarCell.OlePropertyGet("Borders",8).OlePropertySet("LineStyle",1);
vVarCell.OlePropertyGet("Borders",9).OlePropertySet("LineStyle",1);
vVarCell.OlePropertyGet("Borders",10).OlePropertySet("LineStyle",1);
vVarCell.OlePropertyGet("Borders",7).OlePropertySet("Weight",2);
vVarCell.OlePropertyGet("Borders",10).OlePropertySet("Weight",2);
vVarCell.OlePropertyGet("Borders",7).OlePropertySet("ColorIndex",1);
vVarCell.OlePropertyGet("Borders",10).OlePropertySet("ColorIndex",1);
vVarSheet.OlePropertyGet("Columns").OlePropertyGet("Item",j).OleProcedure("AutoFit");
}
k++;
Form4->ADOTable1->Next(); }
vVarApp.OlePropertySet("Visible",true);
fStart=false; }
catch(...)
{ ShowMessage("Невозможно создать книгу Excel");
return; } } }
//---------------------------------------------------------------------------
Отрывок кода формы «Фоновый режим» представлен ниже.
//---------------------------------------------------------------------------
#include
#pragma hdrstop
#include "Unit1.h"
#include "Unit4.h"
#include "Unit5.h"
#include "Unit6.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm5 *Form5;
//---------------------------------------------------------------------------
__fastcall TForm5::TForm5(TComponent* Owner)
: TForm(Owner) {
}
//---------------------------------------------------------------------------
void __fastcall TForm5::Button2Click(TObject *Sender)
{
Form6->Show();
Form6->ADOTable1->Active = false;
Form6->ADOTable1->ConnectionString = Form1->ADOConnection1->ConnectionString;
Form6->ADOTable1->TableName = "Учет_деталей_в_работе_Участок_1";
Form6->Caption = Form6->ADOTable1->TableName;
Form6->ADOTable1->Active = true;
Form6->DataSource1->DataSet = Form6->ADOTable1;
Form6->DBGrid1->ReadOnly = true;
Form6->DBGrid1->DataSource = Form6->DataSource1;
for (int i = 0; i < Form6->DBGrid1->Columns->Count-1; i++)
{ Form6->DBGrid1->Columns->Items[i]->Width=100; } }
//---------------------------------------------------------------------------
Отрывок кода формы «Учет и контроль деталей» представлен ниже.
//---------------------------------------------------------------------------
#include
#pragma hdrstop
#include "Unit1.h"
#include "Unit4.h"
#include "Unit5.h"
#include "Unit6.h"
#include "Unit7.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm7 *Form7;
//---------------------------------------------------------------------------
__fastcall TForm7::TForm7(TComponent* Owner)
: TForm(Owner) { }
//---------------------------------------------------------------------------
void __fastcall TForm7::Button1Click(TObject *Sender)
{
Form6->Show();
Form6->ADOTable1->Active = false;
Form6->ADOTable1->ConnectionString = Form1->ADOConnection1->ConnectionString;
Form6->ADOTable1->TableName = "Межцеховой_учет_деталей_Участок_1";
Form6->Caption = Form6->ADOTable1->TableName;
Form6->ADOTable1->Active = true;
Form6->DataSource1->DataSet = Form6->ADOTable1;
Form6->DBGrid1->ReadOnly = true;
Form6->DBGrid1->DataSource = Form6->DataSource1;
for (int i = 0; i < Form6->DBGrid1->Columns->Count-1; i++)
{ Form6->DBGrid1->Columns->Items[i]->Width=100; } }
//----------------------------------------------------------------------------
Код формы авторизации представлен ниже (Культин, Н.,2015).
//---------------------------------------------------------------------------
#include
#pragma hdrstop
#include "Unit3.h"
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm3 *Form3;
//---------------------------------------------------------------------------
__fastcall TForm3::TForm3(TComponent* Owner)
: TForm(Owner) { }
//---------------------------------------------------------------------------
void __fastcall TForm3::Button1Click(TObject *Sender)
{ if ((Edit1->Text == "Admin") && (Edit2->Text == "123")) {
Form1->UserName = "Admin";
Form1->isConnected = true;
Form1->Button3->Caption = "Cмена пользователя (" + Form1->UserName + ")";
this->Close(); }
else if ((Edit1->Text == "Coadmin") && (Edit2->Text == "456"))
{
Form1->UserName = "Coadmin";
Form1->isConnected = true;
Form1->Button3->Caption = "Cмена пользователя (" + Form1->UserName + ")";
this->Close();
} else if ((Edit1->Text == "User") && (Edit2->Text == "321")) {
Form1->UserName = "User";
Form1->isConnected = true;
Form1->Button3->Caption = "Cмена пользователя (" + Form1->UserName + ")";
this->Close(); }
else if ((Edit1->Text == "") && (Edit2->Text == "") or (Edit1->Text == "") or (Edit2->Text == ""))
{ ShowMessage("Не введены логин или пароль"); }
Else { ShowMessage("Неверный логин или пароль"); } }
//---------------------------------------------------------------------------
void __fastcall TForm3::FormClose(TObject *Sender, TCloseAction &Action)
{ if (Form1->isConnected == true) {
if (Form1->UserName == "Admin") {
Form1->Button1->Enabled = true;
Form1->Button2->Enabled = true;
Form1->Button4->Enabled = true; }
else if (Form1->UserName == "Coadmin") {
Form1->Button1->Enabled = true;
Form1->Button2->Enabled = true;
Form1->Button4->Enabled = false; }
else if (Form1->UserName == "User")
{
Form1->Button1->Enabled = false;
Form1->Button2->Enabled = true;
Form1->Button4->Enabled = false;
} }
else
{
Form1->Button1->Enabled = false;
Form1->Button2->Enabled = false;
Form1->Button3->Caption = "Авторизация";
Form1->Button4->Enabled = false;
} }
//---------------------------------------------------------------------------
void __fastcall TForm3::Button2Click(TObject *Sender)
{
Form1->isConnected = false;
Form3->Close();
}
//---------------------------------------------------------------------------
1 2 3 4