Разработка автоматизированной системы для магазина автозапчастей

Построение концептуальной (инфологической) модели базы данных. Выбор языка и среды программирования, требования к клиентскому приложению. Выбор шаблонов проектирования, UML диаграмма классов с учетом выбранных шаблонов. Тестирование слайдера "Slick".

Рубрика Программирование, компьютеры и кибернетика
Вид дипломная работа
Язык русский
Дата добавления 10.07.2017
Размер файла 2,5 M

Отправить свою хорошую работу в базу знаний просто. Используйте форму, расположенную ниже

Студенты, аспиранты, молодые ученые, использующие базу знаний в своей учебе и работе, будут вам очень благодарны.

}

UserCount->Text = login;

}

catch (Exception^ ex) {

MessageBox::Show(ex->Message);

}

}

private: System::Void txt_login_Enter(System::Object^ sender, System::EventArgs^ e) {

try {

combo_login->Items->Clear();

MySqlDataReader^ myReader = ConnToDB::getSingleton()->doSQLCommand("select login from autorun2.users1;");

ArrayList^ names = gcnew ArrayList();

while (myReader->Read()) {

names->Add(myReader->GetString("login"));

}

for each (String^ name in names) {

combo_login->Items->Add(name);

}

}

catch (Exception^ ex) {

MessageBox::Show(ex->Message);

}

}

private: System::Void combo_ID2_Enter(System::Object^ sender, System::EventArgs^ e) {

try {

combo_ID2->Items->Clear();

MySqlDataReader^ myReader = ConnToDB::getSingleton()->doSQLCommand("select Код_резерва from autorun2.Резервирование where Логин = '" + this->combo_login->Text + "' ;");

ArrayList^ names = gcnew ArrayList();

while (myReader->Read()) {

names->Add(myReader->GetString("Код_резерва"));

}

for each (String^ name in names) {

combo_ID2->Items->Add(name);

}

}

catch (Exception^ ex) {

MessageBox::Show(ex->Message);

}

}

private: System::Void button1_Click_1(System::Object^ sender, System::EventArgs^ e) {

if (combo_ID2->Text != "" || txt_tov2->Text != "") {

try {

MySqlDataReader^ myReader = ConnToDB::getSingleton()->doSQLCommand("Insert into autorun2.Продажа (Покупатель,Назв_товара,Категория_тов,Брэнд,Количество,Сумма) values ('" + this->txt_fio1->Text + "','" + this->txt_tov2->Text + "','" + this->txt_categ->Text + "','" + this->txt_brend->Text + "','" + this->textBox6->Text + "',replace('" + this->txt_sum1->Text + "',',','.'));");

while (myReader->Read()) {

}

}

catch (Exception^ ex) {

MessageBox::Show(ex->Message);

}

try {

MySqlDataReader^ myReader = ConnToDB::getSingleton()->doSQLCommand("Delete from autorun2.Резервирование where Код_резерва = '" + this->combo_ID2->Text + "';");

while (myReader->Read()) {

}

MessageBox::Show("Продано!");

}

catch (Exception^ ex) {

MessageBox::Show(ex->Message);

}

ConnToDB::getSingleton()->fillTable(dataGridView3, "select * from autorun2.Резервирование where Логин = '" + this->combo_login->Text + "' ;");

}

else if (txt_tov2->Text == "") {

MessageBox::Show("На выбранного покупателя ничего не зарезервировано!");

}

else if (combo_ID2->Text == "") {

MessageBox::Show("Заполните поля для продажи!");

}

combo_login->Text = "";

combo_ID2->Text = "";

}

private: System::Void combo_login_TextChanged(System::Object^ sender, System::EventArgs^ e) {

ConnToDB::getSingleton()->fillTable(dataGridView3, "select * from autorun2.Резервирование where Логин = '" + this->combo_login->Text + "' ;");

combo_ID2->Enabled = true;

}

private: System::Void combo_ID2_TextChanged(System::Object^ sender, System::EventArgs^ e) {

try {

MySqlDataReader^ myReader = ConnToDB::getSingleton()->doSQLCommand("select Количество from autorun2.Резервирование where Код_резерва='" + this->combo_ID2->Text + "';");

String^ count;

while (myReader->Read()) {

count = myReader->GetString("Количество");

}

textBox6->Text = count;

}

catch (Exception^ ex) {

MessageBox::Show(ex->Message);

}

try {

MySqlDataReader^ myReader = ConnToDB::getSingleton()->doSQLCommand("select ФИО from autorun2.Резервирование where Код_резерва='" + this->combo_ID2->Text + "';");

String^ fio;

while (myReader->Read()) {

fio = myReader->GetString("ФИО");

}

txt_fio1->Text = fio;

}

catch (Exception^ ex) {

MessageBox::Show(ex->Message);

}

try {

MySqlDataReader^ myReader = ConnToDB::getSingleton()->doSQLCommand("select Название_товара from autorun2.Резервирование where Код_резерва='" + this->combo_ID2->Text + "';");

String^ name2;

while (myReader->Read()) {

name2 = myReader->GetString("Название_товара");

}

txt_tov2->Text = name2;

}

catch (Exception^ ex) {

MessageBox::Show(ex->Message);

}

try {

MySqlDataReader^ myReader = ConnToDB::getSingleton()->doSQLCommand("select Бренд from autorun2.Резервирование where Код_резерва='" + this->combo_ID2->Text + "';");

String^ brend;

while (myReader->Read()) {

brend = myReader->GetString("Бренд");

}

txt_brend->Text = brend;

}

catch (Exception^ ex) {

MessageBox::Show(ex->Message);

}

try {

MySqlDataReader^ myReader = ConnToDB::getSingleton()->doSQLCommand("select Сумма from autorun2.Резервирование where Код_резерва='" + this->combo_ID2->Text + "';");

String^ sum;

while (myReader->Read()) {

sum = myReader->GetString("Сумма");

}

txt_sum1->Text = sum;

}

catch (Exception^ ex) {

MessageBox::Show(ex->Message);

}

try {

MySqlDataReader^ myReader = ConnToDB::getSingleton()->doSQLCommand("select Категория_тов from autorun2.Резервирование where Код_резерва='" + this->combo_ID2->Text + "';");

String^ categ;

while (myReader->Read()) {

categ = myReader->GetString("Категория_тов");

}

txt_categ->Text = categ;

}

catch (Exception^ ex) {

MessageBox::Show(ex->Message);

}

try {

MySqlDataReader^ myReader = ConnToDB::getSingleton()->doSQLCommand("select Код_тов from autorun2.Резервирование where Код_резерва='" + this->combo_ID2->Text + "';");

String^ id;

while (myReader->Read()) {

id = myReader->GetString("Код_тов");

}

txtID->Text = id;

}

catch (Exception^ ex) {

MessageBox::Show(ex->Message);

}

}

private: System::Void Остатки_Enter(System::Object^ sender, System::EventArgs^ e) {

ConnToDB::getSingleton()->fillTable(dataGridView4, "select Код_товара as 'Код товара', Категория as 'Категория', Брэнд, Название_товара as 'Наименование товара', Стоимость_закупки as 'Стоимость закупки', Стоимость_продажи as 'Стоимость продажи', Остаток_шт as 'Остаток шт.',Для_авто as 'Для автомобиля', Размеры, Характеристики from autorun2.Товары where Остаток_шт<=8 order by Остаток_шт;");

ConnToDB::getSingleton()->fillTable(dataGridView5, "select Код_товара as 'Код товара', Категория as 'Категория', Брэнд, Название_товара as 'Наименование товара', Стоимость_закупки as 'Стоимость закупки', Стоимость_продажи as 'Стоимость продажи', Остаток_шт as 'Остаток шт.',Для_авто as 'Для автомобиля', Размеры, Характеристики from autorun2.Товары where Остаток_шт=0 order by Остаток_шт;");

}

private: System::Void button22_Click_2(System::Object^ sender, System::EventArgs^ e) {

//выполняем sql запрос к базе для добавления введенных данных на сервер в базу

if (comboSkidka->Text == "5") {

try {

MySqlDataReader^ myReader = ConnToDB::getSingleton()->doSQLCommand("update autorun2.товары set Стоимость_продажи=Стоимость_продажи-Стоимость_продажи*0.05 where Название_товара='" + this->lbl_mask_name->Text + "' and Брэнд ='" + this->lbl_brend_mask->Text + "';");

while (myReader->Read()) {

}

MessageBox::Show("На товар'" + this->lbl_mask_name->Text + "' производителя '" + this->lbl_brend_mask->Text + "' установлена скидка 5%");

}

catch (Exception^ ex) {

MessageBox::Show(ex->Message);

}

}

if (comboSkidka->Text == "10") {

try {

MySqlDataReader^ myReader = ConnToDB::getSingleton()->doSQLCommand("update autorun2.товары set Стоимость_продажи=Стоимость_продажи-Стоимость_продажи*0.1 where Название_товара='" + this->lbl_mask_name->Text + "' and Брэнд ='" + this->lbl_brend_mask->Text + "';");

while (myReader->Read()) {

}

MessageBox::Show("На товар'" + this->lbl_mask_name->Text + "' производителя '" + this->lbl_brend_mask->Text + "' установлена скидка 10%");

}

catch (Exception^ ex) {

MessageBox::Show(ex->Message);

}

}

if (comboSkidka->Text == "15") {

try {

MySqlDataReader^ myReader = ConnToDB::getSingleton()->doSQLCommand("update autorun2.товары set Стоимость_продажи=Стоимость_продажи-Стоимость_продажи*0.15 where Название_товара='" + this->lbl_mask_name->Text + "' and Брэнд ='" + this->lbl_brend_mask->Text + "';");

while (myReader->Read()) {

}

MessageBox::Show("На товар'" + this->lbl_mask_name->Text + "' производителя '" + this->lbl_brend_mask->Text + "' установлена скидка 15%");

}

catch (Exception^ ex) {

MessageBox::Show(ex->Message);

}

}

if (comboSkidka->Text == "20") {

try {

MySqlDataReader^ myReader = ConnToDB::getSingleton()->doSQLCommand("update autorun2.товары set Стоимость_продажи=Стоимость_продажи-Стоимость_продажи*0.2 where Название_товара='" + this->lbl_mask_name->Text + "' and Брэнд ='" + this->lbl_brend_mask->Text + "';");

while (myReader->Read()) {

}

MessageBox::Show("На товар'" + this->lbl_mask_name->Text + "' производителя '" + this->lbl_brend_mask->Text + "' установлена скидка 20%");

}

catch (Exception^ ex) {

MessageBox::Show(ex->Message);

}

}

if (comboSkidka->Text == "25") {

try {

MySqlDataReader^ myReader = ConnToDB::getSingleton()->doSQLCommand("update autorun2.товары set Стоимость_продажи=Стоимость_продажи-Стоимость_продажи*0.25 where Название_товара='" + this->lbl_mask_name->Text + "' and Брэнд ='" + this->lbl_brend_mask->Text + "';");

while (myReader->Read()) {

}

MessageBox::Show("На товар'" + this->lbl_mask_name->Text + "' производителя '" + this->lbl_brend_mask->Text + "' установлена скидка 25%");

}

catch (Exception^ ex) {

MessageBox::Show(ex->Message);

}

}

if (comboSkidka->Text == "50") {

try {

MySqlDataReader^ myReader = ConnToDB::getSingleton()->doSQLCommand("update autorun2.товары set Стоимость_продажи=Стоимость_продажи-Стоимость_продажи*0.5 where Название_товара='" + this->lbl_mask_name->Text + "' and Брэнд ='" + this->lbl_brend_mask->Text + "';");

while (myReader->Read()) {

}

MessageBox::Show("На товар'" + this->lbl_mask_name->Text + "' производителя '" + this->lbl_brend_mask->Text + "' установлена скидка 50%");

}

catch (Exception^ ex) {

MessageBox::Show(ex->Message);

}

}

if (comboSkidka->Text == "70") {

try {

MySqlDataReader^ myReader = ConnToDB::getSingleton()->doSQLCommand("update autorun2.товары set Стоимость_продажи=Стоимость_продажи-Стоимость_продажи*0.7 where Название_товара='" + this->lbl_mask_name->Text + "' and Брэнд ='" + this->lbl_brend_mask->Text + "';");

while (myReader->Read()) {

}

MessageBox::Show("На товар'" + this->lbl_mask_name->Text + "' производителя '" + this->lbl_brend_mask->Text + "' установлена скидка 70%");

}

catch (Exception^ ex) {

MessageBox::Show(ex->Message);

}

}

comboSkidka->Text = "";

}

};

}

Приложение 3

Программный код ConnToDB.cpp:

#include "stdafx.h"

#include "ConnToDB.h"

ConnToDB::ConnToDB() {

//соединяемся с БД

System::String^ connString = L"datasource=localhost;port=3306; username=root;password=160795ad";

connection = gcnew MySql::Data::MySqlClient::MySqlConnection(connString);

connection->Open();

}

ConnToDB^ ConnToDB::getSingleton() {

if (instance == nullptr) {

instance = gcnew ConnToDB();

}

return instance;

}

MySql::Data::MySqlClient::MySqlConnection^ ConnToDB::getConnection() {

return connection;

}

MySql::Data::MySqlClient::MySqlDataReader^ ConnToDB::doSQLCommand(System::String^ command) {

closeReader();

reader = getSQLCommand(command)->ExecuteReader();

return reader;

}

MySql::Data::MySqlClient::MySqlCommand^ ConnToDB::getSQLCommand(System::String^ command) {

return gcnew MySql::Data::MySqlClient::MySqlCommand(command, connection);

}

void ConnToDB::closeReader() {

if (reader != nullptr && !reader->IsClosed) {

reader->Close();

}

if (connection->State == System::Data::ConnectionState::Closed) {

connection->Open();

}

}

void ConnToDB::fillTable(System::Windows::Forms::DataGridView^ table, System::String^ command) {

try {closeReader();

MySql::Data::MySqlClient::MySqlDataAdapter^ sda = gcnew MySql::Data::MySqlClient::MySqlDataAdapter(getSQLCommand(command));

System::Data::DataTable^ dbdataset = gcnew System::Data::DataTable();

sda->Fill(dbdataset);

System::Windows::Forms::BindingSource^ bSource = gcnew System::Windows::Forms::BindingSource();

bSource->DataSource = dbdataset;

table->DataSource = bSource;

sda->Update(dbdataset);

}

catch (System::Exception^ ex) {

System::Windows::Forms::MessageBox::Show(ex->Message);

}

}

ConnToDB::~ConnToDB() {connection->Close();

}

Приложение 4

Программный код DateAdapter.cpp:

#include "stdafx.h"

#include "DateAdapter.h"

using namespace AutoRUNapp;

DateAdapter::DateAdapter(DateTimePicker^ datePicker) : picker(datePicker) {}

System::String ^ AutoRUNapp::DateAdapter::getDate() {

return picker->Value.ToString("yyyy-MM-dd");

}

Приложение 5

Программный код Command.h:

#pragma once

namespace AutoRUNapp {

using namespace System::Windows::Forms;

public ref class Command abstract {

public:

virtual ~Command() {}

virtual void execute() = 0;

virtual void undo() = 0;

};

public ref class NavigateCommand : public Command {

private:

WebBrowser^ browser;

System::String^ url;

public:

NavigateCommand(WebBrowser^ browser, System::String^ url) : browser(browser), url(url) {}

~NavigateCommand() {}

void execute() override {

browser->Navigate(url);

}

void undo() override {

browser->GoBack();

}

};

public ref class ForwardCommand : public Command {

private:

WebBrowser^ browser;

public:

ForwardCommand(WebBrowser^ browser) : browser(browser) {}

~ForwardCommand() {}

void execute() override {

browser->GoForward();

}

void undo() override {

browser->GoBack();

}

};

public ref class BackCommand : public Command {

private:

WebBrowser^ browser;

public:

BackCommand(WebBrowser^ browser) : browser(browser) {}

~BackCommand() {}

void execute() override {

browser->GoBack();

}

void undo() override {

browser->GoForward();

}

};

}

Размещено на Allbest.ru


Подобные документы

Работы в архивах красиво оформлены согласно требованиям ВУЗов и содержат рисунки, диаграммы, формулы и т.д.
PPT, PPTX и PDF-файлы представлены только в архивах.
Рекомендуем скачать работу.