Диплом: Автоматизация деятельности торговой компании ООО "Энкор инструмент Воронеж"

Внимание! Если размещение файла нарушает Ваши авторские права, то обязательно сообщите нам
127
this->button2->UseVisualStyleBackColor = true;
this->button2->Click += gcnew System::EventHandler(this,
&tovari::button2_Click);
//
// button1
//
this->button1->Location = System::Drawing::Point(657, 358);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(209, 23);
this->button1->TabIndex = 6;
this->button1->Text = L"Сохранить изменения";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(this,
&tovari::button1_Click);
//
// textBox3
//
this->textBox3->Location = System::Drawing::Point(708, 248);
this->textBox3->Name = L"textBox3";
this->textBox3->Size = System::Drawing::Size(158, 20);
this->textBox3->TabIndex = 5;
//
// label5
//
this->label5->AutoSize = true;
this->label5->Location = System::Drawing::Point(654, 290);
this->label5->Name = L"label5";
this->label5->Size = System::Drawing::Size(44, 13);
this->label5->TabIndex = 4;
this->label5->Text = L"Фирма";
//
// textBox2
//
this->textBox2->Location = System::Drawing::Point(708, 217);
this->textBox2->Name = L"textBox2";
this->textBox2->Size = System::Drawing::Size(158, 20);
this->textBox2->TabIndex = 3;
//
// label4
//
this->label4->AutoSize = true;
this->label4->Location = System::Drawing::Point(654, 255);
this->label4->Name = L"label4";
this->label4->Size = System::Drawing::Size(48, 13);
this->label4->TabIndex = 2;
this->label4->Text = L"Артикул";
//
// textBox1
//
this->textBox1->Location = System::Drawing::Point(708, 186);
this->textBox1->Name = L"textBox1";
this->textBox1->Size = System::Drawing::Size(158, 20);
this->textBox1->TabIndex = 1;
//
// label3
//
128
this->label3->AutoSize = true;
this->label3->Location = System::Drawing::Point(654, 193);
this->label3->Name = L"label3";
this->label3->Size = System::Drawing::Size(38, 13);
this->label3->TabIndex = 0;
this->label3->Text = L"Товар";
//
// label2
//
this->label2->AutoSize = true;
this->label2->Location = System::Drawing::Point(12, 177);
this->label2->Name = L"label2";
this->label2->Size = System::Drawing::Size(131, 13);
this->label2->TabIndex = 3;
this->label2->Text = L"Товары в данной группе";
//
// grd1
//
this->grd1->AllowUserToAddRows = false;
this->grd1->AllowUserToDeleteRows = false;
this->grd1->AllowUserToResizeRows = false;
this->grd1->BackgroundColor =
System::Drawing::SystemColors::GradientInactiveCaption;
this->grd1->ColumnHeadersHeightSizeMode =
System::Windows::Forms::DataGridViewColumnHeadersHeightSizeMode::AutoSize;
this->grd1->Columns->AddRange(gcnew cli::array<
System::Windows::Forms::DataGridViewColumn^ >(5) {this->Column1,
this->Column2, this->Column3, this->Column4, this->Column5});
this->grd1->Location = System::Drawing::Point(15, 193);
this->grd1->MultiSelect = false;
this->grd1->Name = L"grd1";
this->grd1->ReadOnly = true;
this->grd1->RowHeadersWidth = 50;
this->grd1->SelectionMode =
System::Windows::Forms::DataGridViewSelectionMode::FullRowSelect;
this->grd1->Size = System::Drawing::Size(608, 306);
this->grd1->TabIndex = 0;
this->grd1->CellClick += gcnew
System::Windows::Forms::DataGridViewCellEventHandler(this, &tovari::grd1_CellClick);
//
// Column6
//
this->Column6->Frozen = true;
this->Column6->HeaderText = L"ID";
this->Column6->Name = L"Column6";
this->Column6->ReadOnly = true;
this->Column6->Visible = false;
this->Column6->Width = 5;
//
// Column7
//
this->Column7->Frozen = true;
this->Column7->HeaderText = L"Группа товаров";
this->Column7->Name = L"Column7";
this->Column7->ReadOnly = true;
this->Column7->Width = 520;
129
//
// Column1
//
this->Column1->Frozen = true;
this->Column1->HeaderText = L"ID";
this->Column1->Name = L"Column1";
this->Column1->ReadOnly = true;
this->Column1->Visible = false;
this->Column1->Width = 5;
//
// Column2
//
this->Column2->Frozen = true;
this->Column2->HeaderText = L"Товар";
this->Column2->Name = L"Column2";
this->Column2->ReadOnly = true;
this->Column2->Width = 220;
//
// Column3
//
this->Column3->Frozen = true;
this->Column3->HeaderText = L"Цена";
this->Column3->Name = L"Column3";
this->Column3->ReadOnly = true;
//
// Column4
//
this->Column4->Frozen = true;
this->Column4->HeaderText = L"Артикул";
this->Column4->Name = L"Column4";
this->Column4->ReadOnly = true;
//
// Column5
//
this->Column5->Frozen = true;
this->Column5->HeaderText = L"Фирма";
this->Column5->Name = L"Column5";
this->Column5->ReadOnly = true;
//
// tovari
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(887, 514);
this->Controls->Add(this->label6);
this->Controls->Add(this->textBox2);
this->Controls->Add(this->label1);
this->Controls->Add(this->textBox3);
this->Controls->Add(this->textBox4);
this->Controls->Add(this->label2);
this->Controls->Add(this->label4);
this->Controls->Add(this->button1);
this->Controls->Add(this->label5);
this->Controls->Add(this->button2);
this->Controls->Add(this->button3);
this->Controls->Add(this->grd2);
130
this->Controls->Add(this->grd1);
this->Controls->Add(this->textBox1);
this->Controls->Add(this->label3);
this->Name = L"tovari";
this->Text = L"Редактирование товаров";
this->Load += gcnew System::EventHandler(this, &tovari::tovari_Load);
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->grd2))-
>EndInit();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->grd1))-
>EndInit();
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
private: System::Void tovari_Load(System::Object^ sender, System::EventArgs^ e) {
int boundWidth = GetSystemMetrics(SM_CXSCREEN);
int boundHeight = GetSystemMetrics(SM_CYSCREEN);
int x = boundWidth - this->Width;
int y = boundHeight - this->Height;
this->Location = Point(x/2, y/2);
zagrusit_gruppi_tovarov();
}
private: System::Void grd2_CellClick(System::Object^ sender,
System::Windows::Forms::DataGridViewCellEventArgs^ e) {
zagrusit_tovari();
}
private: System::Void grd1_CellClick(System::Object^ sender,
System::Windows::Forms::DataGridViewCellEventArgs^ e) {
zagrusit_tovar();
}
private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e) {
dobavit_zapis();
}
private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {
udalit_zapis();
}
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
obnovit_zapis();
}
};
}
#include "StdAfx.h"
#include "tovari.h"
using namespace enkor;
namespace enkor
{
void tovari::zagrusit_gruppi_tovarov()
{
String ^sql;
131
list_structure out_data = gcnew list_structure();
sql = "select gruppi_tovarov.kod_gruppi, gruppi_tovarov.nazvanie_gruppi from
gruppi_tovarov";
bool res = mF->selectFromDb(sql, %out_data);
if(!res)
MessageBox::Show("Ошибка\r\nНе могу прочитать данные о группах
товаров");
else
{
grd2->Rows->Clear();
for(int i=0; i<out_data.Count; i++)
{
grd2->Rows->Add("", "");
grd2->Rows[i]->HeaderCell->Value = Convert::ToString(i+1);
grd2->Rows[i]->Cells[0]->Value = out_data[i][0];
grd2->Rows[i]->Cells[1]->Value = out_data[i][1];
}
}
grd2->Columns[0]->Visible = false;
zagrusit_tovari();
}
void tovari::zagrusit_tovari()
{
int row = grd2->SelectedCells[0]->RowIndex;
IDgruppi = Convert::ToInt32(grd2->Rows[row]->Cells[0]->Value);
String ^sql;
list_structure out_data = gcnew list_structure();
sql = "select tovari.kod_tovara, tovari.nazvanie_tovara, tovari.cena, tovari.artikul,
tovari.firma from tovari where tovari.kod_gruppi="+Convert::ToString(IDgruppi);
bool res = mF->selectFromDb(sql, %out_data);
if(!res)
MessageBox::Show("Ошибка\r\nНе могу прочитать данные о товарах в
группе");
else
{
grd1->Rows->Clear();
for(int i=0; i<out_data.Count; i++)
{
grd1->Rows->Add("", "", "", "", "");
grd1->Rows[i]->HeaderCell->Value = Convert::ToString(i+1);
grd1->Rows[i]->Cells[0]->Value = out_data[i][0];
grd1->Rows[i]->Cells[1]->Value = out_data[i][1];
grd1->Rows[i]->Cells[2]->Value = out_data[i][2];
grd1->Rows[i]->Cells[3]->Value = out_data[i][3];
grd1->Rows[i]->Cells[4]->Value = out_data[i][4];
}
}
grd1->Columns[0]->Visible = false;
zagrusit_tovar();
132
}
void tovari::zagrusit_tovar()
{
int row = grd1->SelectedCells[0]->RowIndex;
tovarID = Convert::ToInt32(grd1->Rows[row]->Cells[0]->Value);
String ^sql;
list_structure out_data = gcnew list_structure();
sql = "select tovari.kod_tovara, tovari.nazvanie_tovara, tovari.cena, tovari.artikul,
tovari.firma from tovari where tovari.kod_tovara="+Convert::ToString(tovarID);
bool res = mF->selectFromDb(sql, %out_data);
if(!res)
MessageBox::Show("Ошибка\r\nНе могу прочитать выделенный товар");
else
{
textBox1->Text = out_data[0][1];
textBox2->Text = out_data[0][2];
textBox3->Text = out_data[0][3];
textBox4->Text = out_data[0][4];
}
}
void tovari::dobavit_zapis()
{
String ^ newName = textBox1->Text;
String ^ newPrice = textBox2->Text;
String ^ newCode = textBox3->Text;
String ^ newBrand = textBox4->Text;
String ^sql = "insert into tovari(name, cena, code, brand, kod_gruppi)
values('"+newName+"', "+newPrice+", '"+newCode+"', '"+newBrand+"',
"+Convert::ToString(IDgruppi)+")";
mF->insertInDb(sql);
zagrusit_tovari();
}
void tovari::udalit_zapis()
{
if (MessageBox::Show("Вы уверены, что хотите удалить запись?", "Удаление",
MessageBoxButtons::YesNo, MessageBoxIcon::Question) ==
System::Windows::Forms::DialogResult::No)
return;
String ^sql = "delete from tovari where
tovari.kod_tovara="+Convert::ToString(tovarID);
mF->requestDb(sql);
zagrusit_tovari();
}
void tovari::obnovit_zapis()
{
String ^ newName = textBox1->Text;
String ^ newPrice = textBox2->Text;
String ^ newCode = textBox3->Text;
String ^ newBrand = textBox4->Text;
133
String ^sql = "update tovari set tovari.nazvanie_tovara='"+newName+"',
tovari.cena="+newPrice+", tovari.artikul='"+newCode+"', tovari.firma='"+newBrand+"' where
tovari.kod_tovara="+Convert::ToString(tovarID);
mF->requestDb(sql);
zagrusit_tovari();
}
}

Смотрите также:

"Автоматизация обработки заявок ООО "Проектно-Строительная Компания"
"Автоматизация процесса аттестации персонала для ООО "Нэт Бай Нэт Холдинг"
"Анализ интернет-активности конкурентов ( на примере конкурентов "Газпром нефть")
"Бухгалтерский учёт и аудит расчётов с подотчётними лицами в организации на примере ООО "ЛОЦ 10""
«Психологическое сопровождение персонала в организации на примере ООО «Крокус»
Cовершенствование деловой оценки персонала в организации (на примере ООО "Даймонд кейтеринг развитие")
IPO - инструмент финансирования деятельности организации. На примере ПАО «Нефтяная компания «Лукойл»
PR как средство продвижения организации (на примере ПАО "Тамбовский завод "Комсомолец им. Н.С. Артемова")
PR-коммуникации в сфере общественного питания (на примере кафе-кондитерской «Cream Cheese»)
SMM как средство повышения эффективности работы учреждений социокультурной сферы (на примере Малого театра)