
- •Введение
- •1. Обзор и постановка задачи
- •Область применения роботизированных технологий
- •1.2 Промышленные роботы.
- •1.3 Автоматизированные складские системы.
- •1.4 Логические процессы в складском помещении
- •1.5 Функционирование роботизированной системы
- •1.6 Постановка задачи
- •2. Выбор средств автоматизации и инструментов для разработки прикладного программного обеспечения
- •2.1 Обзор современных решений
- •2.3 Выбор архитектуры разрабатываемого приложения
- •Новый лист.3. Разработка системы
- •3.1 Выбор готового комплексного решения для автоматизации складского хранения продукции.
- •3.2 Описание предметной области с помощью языка моделирования uml
- •3.3 Разработка программного модуля.
- •Заключение
- •Список литературы
- •Приложение.
Заключение
В ходе дипломного проектирования была произведены следующие работы:
- Анализ предметной области роботизированных систем для складского хранения;
- Постановка задач и целей для реализации проекта роботизированного склада;
- Обзор и выбор современных решений в данной области автоматизации;
- Разработка программного модуля для учета хранимой на складе продукции.
В технической части проекта рассмотрены варианты автоматизации склада на основе готовых решений.
В программной части проекта рассмотрен результат программного проектирования модуля.
Таким образом можно сделать заключение, что все поставленные в ходе дипломного проектирования цели и задачи были рассмотрены и раскрыты в полном объеме.
Список литературы
1. Автоматизированные информационные технологии в экономике: Учебник /Под ред. проф. Г.А. Титоренко.-М.: Компьютер, ЮНИТП, 2007 – 400 с.
2. Гайдамакин Н.А. Автоматизированные информационные системы, базы и банки данных. М: Гелиос АРВ, 2009.
3. Евдокимов В.В. и др. Экономическая информатика. /Учебник для вузов./ Под ред.д.э.н., профессора В.В. Евдокимова.-СПб.: Санкт-Петербург, 2007,-592 с.: ил.
4. Информационные системы в экономике. Базы данных: Учебное пособие. Чебоксары, 2007.
5. Петров В.Н. Информационные системы. СПб.: Питер, 2007.
6. Волгин В. В. Логистика хранения товаров. Практическое пособие; Дашков и Ко, 2010. - 368 c.
7. Дыбская В. В. Управление складированием в цепях поставок; Альфа-Пресс, 2009. - 720 c.
8. Таран С. А. Как организовать склад. Практические рекомендации профессионала; Альфа-Пресс, 2008. - 240 c.
9. Фразелли Эдвард Мировые стандарты складской логистики; Альпина Паблишер, 2012. - 330 c.
10. Гуриков С. Р. Введение в программирование на языке Visual C#; Форум, Инфра-М, 2013. - 448 c.
11. Мартин Р. С., Мартин М. Принципы, паттерны и методики гибкой разработки на языке C#; Символ-Плюс, 2011. - 768 c.
12. Шнайдер, Роберт Microsoft SQL Server 6.5. Проектирование высокопроизводительных баз данных; М.: Лори, 2010. - 361 c.
13. Яргер, Р.Дж.; Риз, Дж.; Кинг, Т. MySQL и mSQL: Базы данных для небольших предприятий и Интернета; СПб: Символ-Плюс, 2013. - 560 c.
14. Роботизированные технологические комплексы / Г.И. Костюк, О.О. Баранов, И.Г. Левченко, В.А. Фадеев - Учеб. Пособие. - Харьков. Нац. аэрокосмический университет "ХАИ", 2003. - 214с.
Приложение.
Исходный код
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
namespace Склад
{
class MySQLClass //класс взаимодействия с БД
{
private string[] resultarray = new string[1];// массив для результата запроса
private string ConnectionString = null;// строка соединения
private string DataSource = null;//источник данных
private string UserID = null;//логин
private string Password = null;// пароль
private string DataBaseName = null; имя БД
объекты соединения и выборки данных
private MySqlConnection Connection = null;
private MySqlCommand Command = null;
private MySqlDataReader DataReader = null;
private MySqlDataAdapter DataAdapter = null;
private DataSet DataSet = null;
объекты обработки и передачи данных
private MySqlDataAdapter[] DataAdapters = null;
private MySqlCommandBuilder[] CommandBuilders = null;
private DataTable[] DataTables = null;
private string[] DataGridViews = null;
private string[] SelectCommands = null;
конструктор класса
public MySQLClass(string UserID, string Password, string DataBaseName, string DataSource, string[] datagridviews, string[] selectcommands)
{
try
{
this.UserID = UserID;
this.Password = Password;
this.DataBaseName = DataBaseName;
this.DataSource = DataSource;
this.ConnectionString = "Data source=" + this.DataSource + ";UserId=" + this.UserID + ";Password=" + this.Password + ";database=" + this.DataBaseName + ";charset=utf8;";
Connection = new MySqlConnection(ConnectionString);
Command = new MySqlCommand();
Command.CommandText = "";
Command.Connection = this.Connection;
DataAdapter = new MySqlDataAdapter(Command.CommandText, this.Connection);
DataSet = new DataSet();
this.DataGridViews = new string[datagridviews.Length];
this.SelectCommands = new string[datagridviews.Length];
this.DataTables = new DataTable[datagridviews.Length];
this.DataAdapters = new MySqlDataAdapter[datagridviews.Length];
this.CommandBuilders = new MySqlCommandBuilder[datagridviews.Length];
for (int i = 0; i != datagridviews.Length; i++)
{
this.DataGridViews[i] = datagridviews[i];
this.SelectCommands[i] = selectcommands[i];
this.DataTables[i] = new DataTable();
this.DataAdapters[i] = new MySqlDataAdapter(selectcommands[i], this.Connection);
this.CommandBuilders[i] = new MySqlCommandBuilder(DataAdapters[i]);
//this.DataAdapters[i].UpdateCommand = CommandBuilders[i].GetUpdateCommand();
//this.DataAdapters[i].InsertCommand = CommandBuilders[i].GetInsertCommand();
//this.DataAdapters[i].DeleteCommand = CommandBuilders[i].GetDeleteCommand();
}
//DataAdapters[0].SelectCommand.CommandText = Command.CommandText;
}
catch (MySqlException exception)
{
MessageBox.Show(exception.ToString(), "Ошибка MySQL DataBase Class Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
Соединение с БД
public bool TryConnectToDataBase()
{
try
{
Command.CommandText = "SHOW DATABASES";
Command.Connection.Open();
DataReader = Command.ExecuteReader();
if (DataReader.HasRows)
{
return true;
}
else
{
return false;
}
}
catch (MySqlException exception)
{
MessageBox.Show(exception.ToString(), "Ошибка MySQL DataBase Class Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
finally
{
DataReader.Close();
if (Command.Connection.State == System.Data.ConnectionState.Open)
{
Command.Connection.Close();
}
}
}
Вывод данных в графический интерфейс
public int DataFromBaseToDataGridView(DataGridView datagridview, string operation)
{
int index = 0;
try
{
index = Array.IndexOf<string>(DataGridViews, datagridview.Name);
DataAdapters[index].SelectCommand.CommandText = SelectCommands[index];
switch (operation)
{
case "select":
DataTables[index].Clear();
DataAdapters[index].Fill(DataTables[index]);
//MessageBox.Show(DataAdapters[index].SelectCommand.CommandText);
datagridview.DataSource = DataTables[index];
break;
case "update":
DataTable changes = ((DataTable)datagridview.DataSource).GetChanges();
if (changes != null)
{
DataAdapters[index].UpdateCommand = CommandBuilders[index].GetUpdateCommand();
DataAdapters[index].InsertCommand = CommandBuilders[index].GetInsertCommand();
DataAdapters[index].DeleteCommand = CommandBuilders[index].GetDeleteCommand();
DataAdapters[index].Update(changes);
((DataTable)datagridview.DataSource).AcceptChanges();
}
DataTables[index] = null;
DataTables[index] = new DataTable();
DataAdapters[index].Fill(DataTables[index]);
datagridview.DataSource = DataTables[index];
//DataAdapters[index].Update(DataTables[index]);
break;
case "user_select":
DataAdapters[index].SelectCommand.CommandText = Command.CommandText;
DataTables[index].Clear();
DataAdapters[index].Fill(DataTables[index]);
datagridview.DataSource = DataTables[index];
break;
default:
break;
}
return DataTables[index].Rows.Count;
}
catch (Exception exception)
{
MessageBox.Show(exception.ToString(), "Ошибка MySQL DataBase Class Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
return 0;
}
finally
{
if (Command.Connection.State == System.Data.ConnectionState.Open)
{
Command.Connection.Close();
}
}
}
Обновление данных в БД
public int UpdateDataBaseFromDataGridView(DataGridView datagridview)
{
int index = 0;
try
{
datagridview.EndEdit();
index = Array.IndexOf<string>(DataGridViews, datagridview.Name);
DataAdapters[index].UpdateCommand = CommandBuilders[index].GetUpdateCommand();
DataAdapters[index].InsertCommand = CommandBuilders[index].GetInsertCommand();
//MessageBox.Show(DataAdapters[index].SelectCommand.CommandText + DataAdapters[index].SelectCommand.Connection.ToString());
return DataAdapters[index].Update(DataTables[index]);
}
catch (MySqlException exception)
{
MessageBox.Show(exception.ToString(), "Ошибка MySQL DataBase Class Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
return 0;
}
finally
{
if (Command.Connection.State == System.Data.ConnectionState.Open)
{
Command.Connection.Close();
}
}
}
Удаление данных
public int DeleteDataFromDataGridView(DataGridView datagridview)
{
int index = 0;
try
{
datagridview.EndEdit();
index = Array.IndexOf<string>(DataGridViews, datagridview.Name);
DataAdapters[index].DeleteCommand = CommandBuilders[index].GetDeleteCommand();
return DataAdapters[index].Update(DataTables[index]);
}
catch (MySqlException exception)
{
MessageBox.Show(exception.ToString(), "Ошибка MySQL DataBase Class Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
return 0;
}
finally
{
if (Command.Connection.State == System.Data.ConnectionState.Open)
{
Command.Connection.Close();
}
}
}
Выполнение запроса без возврата данных к базе
public int RunExecuteCommand()
{
try
{
Command.Connection.Open();
return Command.ExecuteNonQuery();
}
catch (MySqlException exception)
{
MessageBox.Show(exception.ToString(), "Ошибка MySQL DataBase Class Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
return 0;
}
finally
{
if (Command.Connection.State == System.Data.ConnectionState.Open)
{
Command.Connection.Close();
}
}
}
Выполнение запроса с возвратом результата к БД
public int RunResultCommand(ref string[] result)
{
int i = 0, k = 0;
try
{
DataAdapter.SelectCommand.CommandText = Command.CommandText;
DataSet.Reset();
DataAdapter.Fill(DataSet);
Command.Connection.Open();
DataReader = Command.ExecuteReader();
Array.Resize<string>(ref result, 0);
if (DataReader.HasRows)
{
Array.Resize<string>(ref result, DataSet.Tables[0].Rows.Count * DataSet.Tables[0].Columns.Count);
k = 0;
while (DataReader.Read())
{
for (i = 0; i != DataSet.Tables[0].Columns.Count; i++)
{
result[k] = DataReader.GetString(i);
k++;
}
}
return DataSet.Tables[0].Rows.Count;
}
else
{
return 0;
}
}
catch (MySqlException exception)
{
MessageBox.Show(exception.ToString(), "Ошибка MySQL DataBase Class Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
return 0;
}
finally
{
DataReader.Close();
if (Command.Connection.State == System.Data.ConnectionState.Open)
{
Command.Connection.Close();
}
}
}
Проверка уникальности значения в таблице
public bool CheckFieldValue(string table, string field, string value)
{
try
{
Command.CommandText = "SELECT `" + field + "` FROM `" + table + "` WHERE (`" + field + "` = '" + value + "')";
if (RunResultCommand(ref resultarray) >= 1)
{
if (resultarray[0].ToUpper() == value.ToUpper())
{
return true;
}
else
{
return false;
}
}
else
{
return false;
}
}
catch (Exception exception)
{
MessageBox.Show(exception.ToString(), "Ошибка MySQL DataBase Class Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
}
Вывод значения конкретного поля таблицы
public string GetFieldValueByOneParametr(string table, string field, string paramfield, string param)
{
try
{
Command.CommandText = "SELECT `" + field + "` FROM `" + table + "` WHERE (`" + paramfield + "` = '" + param + "')";
RunResultCommand(ref resultarray);
if (resultarray.Length > 0 && resultarray.Length < 2)
{
return resultarray[0];
}
else if (resultarray.Length >= 2)
{
MessageBox.Show("Более одного значения по параметру", "Нарушение уникальности данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
return "";
}
else
{
return "";
}
}
catch (Exception exception)
{
MessageBox.Show(exception.ToString(), "Ошибка MySQL DataBase Class Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
return "";
}
}
public string GetLastInsertedID()
{
try
{
return Command.LastInsertedId.ToString();
}
catch (Exception exception)
{
MessageBox.Show(exception.ToString(), "Ошибка MySQL DataBase Class Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
return "";
}
}
Обновить соединение с БД
public void RefreshConnectionString()
{
this.ConnectionString = "Data source=" + this.DataSource + ";UserId=" + this.UserID + ";Password=" + this.Password + ";database=" + this.DataBaseName + ";charset=utf8;";
this.Connection.ConnectionString = ConnectionString;
}
Проверка целостности БД
public bool Check_DataBase(string DataBaseName)
{
try
{
Command.CommandText = "SHOW DATABASES";
Command.Connection.Open();
DataReader = Command.ExecuteReader();
if (DataReader.HasRows)
{
while (DataReader.Read())
{
if (DataReader.GetString(0) == DataBaseName) { return true; }
}
return false;
}
else
{
return false;
}
}
catch (MySqlException exception)
{
MessageBox.Show(exception.ToString(), "Ошибка MySQL DataBase Class Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
finally
{
DataReader.Close();
if (Command.Connection.State == System.Data.ConnectionState.Open)
{
Command.Connection.Close();
}
}
}
Проверка целостности таблицы
public bool Check_Tables(string DataBaseName, string[] tables)
{
try
{
int i = 0;
bool[] check = new bool[tables.Length];
string message = "";
Command.CommandText = "SHOW TABLES FROM " + DataBaseName;
Command.Connection.Open();
DataReader = Command.ExecuteReader();
if (DataReader.HasRows)
{
for (i = 0; i != check.Length; i++)
{
check[i] = false;
//MessageBox.Show(tables[i] + " " + check[i].ToString());
}
while (DataReader.Read())
{
check[Array.IndexOf<string>(tables, DataReader.GetString(0))] = true;
//MessageBox.Show(DataReader.GetString(0));
}
for (i = 0; i != check.Length; i++)
{
if (!check[i])
{
message += "Не найдена таблица " + tables[i] + "\n";
}
}
if (message != "")
{
MessageBox.Show(message, "Ошибка MySQL DataBase Class Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
else
{
return true;
}
}
else
{
return false;
}
}
catch (MySqlException exception)
{
MessageBox.Show(exception.ToString(), "Ошибка MySQL DataBase Class Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
finally
{
DataReader.Close();
if (Command.Connection.State == System.Data.ConnectionState.Open)
{
Command.Connection.Close();
}
}
}
Свойства класса(исключают прямой доступ к полям класса)
public string dataSource
{
get { return DataSource; }
set { DataSource = value; }
}
public string userID
{
get { return UserID; }
set { UserID = value; }
}
public string password
{
get { return Password; }
set { Password = value; }
}
public string dataBaseName
{
get { return DataBaseName; }
set { DataBaseName = value; }
}
public string CommandText
{
get { return Command.CommandText; }
set { Command.CommandText = value; }
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Text.RegularExpressions;
namespace Склад
{
public partial class Form1 : Form
{
string[] ResultArray = new string[1];
string[] tables = { "positions", "goods", "enter_exit"};
string[] datagridviews = { "dataGridView1", "dataGridView2", "dataGridView3", "dataGridView4", "dataGridView5", "dataGridView6" };
string[] selectcommands = { "SELECT * FROM `positions`", "SELECT * FROM `goods`", "SELECT * FROM `goods`", "SELECT * FROM `positions`", "SELECT * FROM `goods`", "SELECT * FROM `enter_exit`" };
MySQLClass DB = null;
Вывод формы графического интерфейса
public Form1()
{
InitializeComponent();
DB = new MySQLClass("root", "", "sklad", "localhost", this.datagridviews, this.selectcommands);
}
Загрузка формы
private void Form1_Load(object sender, EventArgs e)
{
if (DB.TryConnectToDataBase())
{
if (DB.Check_DataBase("sklad"))
{
if (DB.Check_Tables("sklad", tables))
{
DB.DataFromBaseToDataGridView(dataGridView1, "select");
DB.DataFromBaseToDataGridView(dataGridView2, "select");
DB.DataFromBaseToDataGridView(dataGridView3, "select");
DB.DataFromBaseToDataGridView(dataGridView4, "select");
DB.DataFromBaseToDataGridView(dataGridView5, "select");
DB.DataFromBaseToDataGridView(dataGridView6, "select");
}
}
else
{
MessageBox.Show("Корневая База Данных не найдена", "Ошибка MySQL DataBase Class Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
else
{
MessageBox.Show("Подключение к Базе Данных не удалось", "Ошибка MySQL DataBase Class Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
Очистка полей формы от ввода данных
private void button1_Click(object sender, EventArgs e)
{
textBox1.Text = "";
textBox2.Text = "";
textBox3.Text = "";
textBox4.Text = "";
textBox20.Text = "";
textBox19.Text = "";
DB.DataFromBaseToDataGridView(dataGridView1, "select");
}
Проверка ввода в поле
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (!Char.IsDigit(e.KeyChar) && e.KeyChar != Convert.ToChar(8))
{
e.Handled = true;
}
}
Проверка ввода в поле
private void textBox3_KeyPress(object sender, KeyPressEventArgs e)
{
if (!(Char.IsDigit(e.KeyChar)) && !((e.KeyChar == '.') && (((TextBox)sender).Text.IndexOf(".") == -1) && (((TextBox)sender).Text.Length != 0)))
{
if (e.KeyChar != (char)Keys.Back)
{
e.Handled = true;
}
}
}
Проверка ввода в поле
private void textBox4_KeyPress(object sender, KeyPressEventArgs e)
{
if (!(Char.IsDigit(e.KeyChar)) && !((e.KeyChar == '.') && (((TextBox)sender).Text.IndexOf(".") == -1) && (((TextBox)sender).Text.Length != 0)))
{
if (e.KeyChar != (char)Keys.Back)
{
e.Handled = true;
}
}
}
Очистка полей формы от данных
private void button5_Click(object sender, EventArgs e)
{
textBox5.Text = "";
textBox6.Text = "";
textBox7.Text = "";
textBox8.Text = "";
textBox21.Text = "";
textBox22.Text = "";
}
Ввод новой позиции
private void button2_Click(object sender, EventArgs e)
{
if (textBox5.Text != "" && textBox6.Text != "" && textBox7.Text != "" && textBox21.Text != "" && textBox22.Text != "" && textBox8.Text == "")
{
DB.CommandText = "INSERT INTO `positions` (`id`, `name`, `volume_x`, `volume_y`, `volume_z`, `weight`)VALUES(NULL, '" + textBox7.Text.Trim() + "'," + textBox6.Text.Trim() + "," + textBox21.Text.Trim() + "," + textBox22.Text.Trim() + "," + textBox5.Text.Trim() + ")";
if (DB.RunExecuteCommand() >= 1)
{
DB.DataFromBaseToDataGridView(dataGridView1, "select");
}
}
else
{
MessageBox.Show("Вы заполнили не все данные", "Ошибка ввода данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
if(e.RowIndex >=0)
{
textBox7.Text = dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString();
textBox8.Text = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString();
textBox6.Text = dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString();
textBox5.Text = dataGridView1.Rows[e.RowIndex].Cells[5].Value.ToString();
textBox21.Text = dataGridView1.Rows[e.RowIndex].Cells[3].Value.ToString();
textBox22.Text = dataGridView1.Rows[e.RowIndex].Cells[4].Value.ToString();
}
}
Редактирование уже существующих позиций
private void button3_Click(object sender, EventArgs e)
{
if (textBox5.Text != "" && textBox6.Text != "" && textBox7.Text != "" && textBox8.Text != "" && textBox21.Text != "" && textBox22.Text != "")
{
DB.CommandText = "UPDATE `positions` SET `name` = '" + textBox7.Text.Trim() + "', `volume_x` = " + textBox6.Text.Trim() + ", `volume_y` = " + textBox21.Text.Trim() + ", `volume_z` = " + textBox22.Text.Trim() + ", `weight` = " + textBox5.Text.Trim() + " WHERE (`id` = " + textBox8.Text.Trim() + ")";
if (DB.RunExecuteCommand() >= 1)
{
textBox5.Text = "";
textBox6.Text = "";
textBox7.Text = "";
textBox8.Text = "";
textBox21.Text = "";
textBox22.Text = "";
DB.DataFromBaseToDataGridView(dataGridView1, "select");
}
}
else
{
MessageBox.Show("Вы заполнили не все данные", "Ошибка ввода данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
Проверка ввода в поле
private void textBox6_KeyPress(object sender, KeyPressEventArgs e)
{
if (!(Char.IsDigit(e.KeyChar)) && !((e.KeyChar == '.') && (((TextBox)sender).Text.IndexOf(".") == -1) && (((TextBox)sender).Text.Length != 0)))
{
if (e.KeyChar != (char)Keys.Back)
{
e.Handled = true;
}
}
}
Проверка ввода в поле
private void textBox5_KeyPress(object sender, KeyPressEventArgs e)
{
if (!(Char.IsDigit(e.KeyChar)) && !((e.KeyChar == '.') && (((TextBox)sender).Text.IndexOf(".") == -1) && (((TextBox)sender).Text.Length != 0)))
{
if (e.KeyChar != (char)Keys.Back)
{
e.Handled = true;
}
}
}
Удаление позиции
private void button4_Click(object sender, EventArgs e)
{
if (textBox5.Text != "" && textBox6.Text != "" && textBox7.Text != "" && textBox8.Text != "" && textBox21.Text != "" && textBox22.Text != "")
{
if (DB.CheckFieldValue("positions", "id", textBox8.Text))
{
if (MessageBox.Show("Удалить запись? После удаления, произведите удаление связанных записей", "Подтвердить удаление записи", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
{
DB.CommandText = "DELETE FROM `positions` WHERE(`id` = " + textBox8.Text + ")";
if (DB.RunExecuteCommand() >= 1)
{
textBox5.Text = "";
textBox6.Text = "";
textBox7.Text = "";
textBox8.Text = "";
textBox21.Text = "";
textBox22.Text = "";
DB.DataFromBaseToDataGridView(dataGridView1, "select");
}
}
}
else
{
MessageBox.Show("Такого значения нет в Базе Данных", "Некорректные данные при удалении", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
else
{
MessageBox.Show("Вы заполнили не все данные", "Ошибка ввода данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
Поиск позиции по коду
private void textBox1_TextChanged(object sender, EventArgs e)
{
if (textBox1.Text != "")
{
DB.CommandText = "SELECT * FROM `positions` WHERE(`id` = '" + textBox1.Text + "')";
DB.DataFromBaseToDataGridView(dataGridView1, "user_select");
}
else
{
DB.CommandText = "SELECT * FROM `positions`";
DB.DataFromBaseToDataGridView(dataGridView1, "select");
}
}
Поиск позиции по габаритам
private void textBox3_TextChanged(object sender, EventArgs e)
{
if (textBox3.Text != "" && textBox19.Text != "" && textBox20.Text != "")
{
DB.CommandText = "SELECT * FROM `positions` WHERE(`volume_x` = '" + textBox3.Text + "' AND `volume_y` = '" + textBox19.Text + "' AND `volume_z` = '" + textBox20.Text + "')";
DB.DataFromBaseToDataGridView(dataGridView1, "user_select");
}
else
{
DB.CommandText = "SELECT * FROM `positions`";
DB.DataFromBaseToDataGridView(dataGridView1, "select");
}
}
Поиск позиции по весу
private void textBox4_TextChanged(object sender, EventArgs e)
{
if (textBox4.Text != "")
{
DB.CommandText = "SELECT * FROM `positions` WHERE(`weight` = '" + textBox4.Text + "')";
DB.DataFromBaseToDataGridView(dataGridView1, "user_select");
}
else
{
DB.CommandText = "SELECT * FROM `positions`";
DB.DataFromBaseToDataGridView(dataGridView1, "select");
}
}
Поиск позиций по расположению
private void textBox2_TextChanged(object sender, EventArgs e)
{
if (textBox2.Text != "")
{
DB.CommandText = "SELECT * FROM `positions` WHERE(`name` = '" + textBox2.Text + "')";
DB.DataFromBaseToDataGridView(dataGridView1, "user_select");
}
else
{
DB.CommandText = "SELECT * FROM `positions`";
DB.DataFromBaseToDataGridView(dataGridView1, "select");
}
}
Очитка полей формы
private void button10_Click(object sender, EventArgs e)
{
textBox13.Text = "";
textBox14.Text = "";
textBox15.Text = "";
textBox16.Text = "";
textBox17.Text = "";
textBox23.Text = "";
textBox24.Text = "";
}
Очистка полей формы
private void button6_Click(object sender, EventArgs e)
{
textBox9.Text = "";
textBox10.Text = "";
textBox11.Text = "";
textBox12.Text = "";
textBox18.Text = "";
textBox25.Text = "";
textBox26.Text = "";
}
Проверка ввода в поле
private void textBox11_KeyPress(object sender, KeyPressEventArgs e)
{
if (!(Char.IsDigit(e.KeyChar)) && !((e.KeyChar == '.') && (((TextBox)sender).Text.IndexOf(".") == -1) && (((TextBox)sender).Text.Length != 0)))
{
if (e.KeyChar != (char)Keys.Back)
{
e.Handled = true;
}
}
}
Проверка ввода в поле
private void textBox9_KeyPress(object sender, KeyPressEventArgs e)
{
if (!(Char.IsDigit(e.KeyChar)) && !((e.KeyChar == '.') && (((TextBox)sender).Text.IndexOf(".") == -1) && (((TextBox)sender).Text.Length != 0)))
{
if (e.KeyChar != (char)Keys.Back)
{
e.Handled = true;
}
}
}
Проверка ввода в поле
private void textBox16_KeyPress(object sender, KeyPressEventArgs e)
{
if (!Char.IsDigit(e.KeyChar) && e.KeyChar != Convert.ToChar(8))
{
e.Handled = true;
}
}
Проверка ввода в поле
private void textBox14_KeyPress(object sender, KeyPressEventArgs e)
{
if (!(Char.IsDigit(e.KeyChar)) && !((e.KeyChar == '.') && (((TextBox)sender).Text.IndexOf(".") == -1) && (((TextBox)sender).Text.Length != 0)))
{
if (e.KeyChar != (char)Keys.Back)
{
e.Handled = true;
}
}
}
Проверка ввода в поле
private void textBox13_KeyPress(object sender, KeyPressEventArgs e)
{
if (!(Char.IsDigit(e.KeyChar)) && !((e.KeyChar == '.') && (((TextBox)sender).Text.IndexOf(".") == -1) && (((TextBox)sender).Text.Length != 0)))
{
if (e.KeyChar != (char)Keys.Back)
{
e.Handled = true;
}
}
}
Ввод нового объекта
private void button9_Click(object sender, EventArgs e)
{
if (textBox9.Text != "" && textBox11.Text != "" && textBox12.Text != "" && textBox18.Text != "" && textBox25.Text != "" && textBox26.Text != "" && textBox10.Text == "")
{
DB.CommandText = "INSERT INTO `goods` (`id`, `name`, `volume_x`, `volume_y`, `volume_z`, `weight`, `info`)VALUES(NULL, '" + textBox12.Text.Trim() + "'," + textBox11.Text.Trim() + "," + textBox25.Text.Trim() + "," + textBox26.Text.Trim() + "," + textBox9.Text.Trim() + ",'" + textBox18.Text.Trim() + "')";
if (DB.RunExecuteCommand() >= 1)
{
DB.DataFromBaseToDataGridView(dataGridView2, "select");
}
}
else
{
MessageBox.Show("Вы заполнили не все данные", "Ошибка ввода данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
Редактирование уже существующих объектов
private void button8_Click(object sender, EventArgs e)
{
if (textBox9.Text != "" && textBox11.Text != "" && textBox12.Text != "" && textBox18.Text != "" && textBox10.Text != "" && textBox25.Text != "" && textBox26.Text != "")
{
DB.CommandText = "UPDATE `goods` SET `name` = '" + textBox12.Text.Trim() + "', `volume_x` = " + textBox11.Text.Trim() + ", `volume_y` = " + textBox25.Text.Trim() + ", `volume_z` = " + textBox26.Text.Trim() + ", `weight` = " + textBox9.Text.Trim() + ", `info` = '" + textBox18.Text.Trim() + "' WHERE (`id` = " + textBox10.Text.Trim() + ")";
if (DB.RunExecuteCommand() >= 1)
{
textBox9.Text = "";
textBox10.Text = "";
textBox11.Text = "";
textBox12.Text = "";
textBox18.Text = "";
textBox25.Text = "";
textBox26.Text = "";
DB.DataFromBaseToDataGridView(dataGridView2, "select");
}
}
else
{
MessageBox.Show("Вы заполнили не все данные", "Ошибка ввода данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
Удаление объектов
private void button7_Click(object sender, EventArgs e)
{
if (textBox9.Text != "" && textBox11.Text != "" && textBox12.Text != "" && textBox18.Text != "" && textBox10.Text != "" && textBox25.Text != "" && textBox26.Text != "")
{
if (DB.CheckFieldValue("goods", "id", textBox10.Text))
{
if (!DB.CheckFieldValue("enter_exit", "good_id", textBox10.Text))
{
if (MessageBox.Show("Удалить запись? После удаления, произведите удаление связанных записей", "Подтвердить удаление записи", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
{
DB.CommandText = "DELETE FROM `goods` WHERE(`id` = " + textBox10.Text + ")";
if (DB.RunExecuteCommand() >= 1)
{
textBox9.Text = "";
textBox10.Text = "";
textBox11.Text = "";
textBox12.Text = "";
textBox18.Text = "";
textBox25.Text = "";
textBox26.Text = "";
DB.DataFromBaseToDataGridView(dataGridView2, "select");
}
}
}
else
{
MessageBox.Show("Чтобы удалить товар, произведите операцию выдачи товара со склада", "Невозможно удалить товар", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
else
{
MessageBox.Show("Такого значения нет в Базе Данных", "Некорректные данные при удалении", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
else
{
MessageBox.Show("Вы заполнили не все данные", "Ошибка ввода данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
Проверка ввода в поле
private void textBox21_KeyPress(object sender, KeyPressEventArgs e)
{
if (!(Char.IsDigit(e.KeyChar)) && !((e.KeyChar == '.') && (((TextBox)sender).Text.IndexOf(".") == -1) && (((TextBox)sender).Text.Length != 0)))
{
if (e.KeyChar != (char)Keys.Back)
{
e.Handled = true;
}
}
}
Проверка ввода в поле
private void textBox20_KeyPress(object sender, KeyPressEventArgs e)
{
if (!(Char.IsDigit(e.KeyChar)) && !((e.KeyChar == '.') && (((TextBox)sender).Text.IndexOf(".") == -1) && (((TextBox)sender).Text.Length != 0)))
{
if (e.KeyChar != (char)Keys.Back)
{
e.Handled = true;
}
}
}
Поиск позиций по габаритам(оптимизированный)
private void textBox19_TextChanged(object sender, EventArgs e)
{
if (textBox3.Text != "" && textBox19.Text != "" && textBox20.Text != "")
{
DB.CommandText = "SELECT * FROM `positions` WHERE(`volume_x` = '" + textBox3.Text + "' AND `volume_y` = '" + textBox19.Text + "' AND `volume_z` = '" + textBox20.Text + "')";
DB.DataFromBaseToDataGridView(dataGridView1, "user_select");
}
else
{
DB.CommandText = "SELECT * FROM `positions`";
DB.DataFromBaseToDataGridView(dataGridView1, "select");
}
}
Проверка ввода в поле
private void textBox23_KeyPress(object sender, KeyPressEventArgs e)
{
if (!(Char.IsDigit(e.KeyChar)) && !((e.KeyChar == '.') && (((TextBox)sender).Text.IndexOf(".") == -1) && (((TextBox)sender).Text.Length != 0)))
{
if (e.KeyChar != (char)Keys.Back)
{
e.Handled = true;
}
}
}
Проверка ввода в поле
private void textBox24_KeyPress(object sender, KeyPressEventArgs e)
{
if (!(Char.IsDigit(e.KeyChar)) && !((e.KeyChar == '.') && (((TextBox)sender).Text.IndexOf(".") == -1) && (((TextBox)sender).Text.Length != 0)))
{
if (e.KeyChar != (char)Keys.Back)
{
e.Handled = true;
}
}
}
Проверка ввода в поле
private void textBox25_KeyPress(object sender, KeyPressEventArgs e)
{
if (!(Char.IsDigit(e.KeyChar)) && !((e.KeyChar == '.') && (((TextBox)sender).Text.IndexOf(".") == -1) && (((TextBox)sender).Text.Length != 0)))
{
if (e.KeyChar != (char)Keys.Back)
{
e.Handled = true;
}
}
}
Проверка ввода в поле
private void textBox26_KeyPress(object sender, KeyPressEventArgs e)
{
if (!(Char.IsDigit(e.KeyChar)) && !((e.KeyChar == '.') && (((TextBox)sender).Text.IndexOf(".") == -1) && (((TextBox)sender).Text.Length != 0)))
{
if (e.KeyChar != (char)Keys.Back)
{
e.Handled = true;
}
}
}
Выбор оптимальной позиции для объекта
private void dataGridView2_CellClick(object sender, DataGridViewCellEventArgs e)
{
if (e.RowIndex >= 0)
{
textBox9.Text = dataGridView2.Rows[e.RowIndex].Cells[5].Value.ToString();
textBox10.Text = dataGridView2.Rows[e.RowIndex].Cells[0].Value.ToString();
textBox11.Text = dataGridView2.Rows[e.RowIndex].Cells[2].Value.ToString();
textBox12.Text = dataGridView2.Rows[e.RowIndex].Cells[1].Value.ToString();
textBox18.Text = dataGridView2.Rows[e.RowIndex].Cells[6].Value.ToString();
textBox25.Text = dataGridView2.Rows[e.RowIndex].Cells[3].Value.ToString();
textBox26.Text = dataGridView2.Rows[e.RowIndex].Cells[4].Value.ToString();
}
}
Поиск объектов по коду
private void textBox16_TextChanged(object sender, EventArgs e)
{
if (textBox16.Text != "")
{
DB.CommandText = "SELECT * FROM `goods` WHERE(`id` = '" + textBox16.Text + "')";
DB.DataFromBaseToDataGridView(dataGridView2, "user_select");
}
else
{
DB.CommandText = "SELECT * FROM `goods`";
DB.DataFromBaseToDataGridView(dataGridView2, "select");
}
}
Поиск объектов по наименованию
private void textBox15_TextChanged(object sender, EventArgs e)
{
if (textBox15.Text != "")
{
DB.CommandText = "SELECT * FROM `goods` WHERE(`name` = '" + textBox15.Text + "')";
DB.DataFromBaseToDataGridView(dataGridView2, "user_select");
}
else
{
DB.CommandText = "SELECT * FROM `goods`";
DB.DataFromBaseToDataGridView(dataGridView2, "select");
}
}
Поиск объектов по дополнительным данным
private void textBox17_TextChanged(object sender, EventArgs e)
{
if (textBox17.Text != "")
{
DB.CommandText = "SELECT * FROM `goods` WHERE(`info` LIKE '%" + textBox17.Text + "%')";
DB.DataFromBaseToDataGridView(dataGridView2, "user_select");
}
else
{
DB.CommandText = "SELECT * FROM `goods`";
DB.DataFromBaseToDataGridView(dataGridView2, "select");
}
}
Поиск объектов по весу
private void textBox13_TextChanged(object sender, EventArgs e)
{
if (textBox13.Text != "")
{
DB.CommandText = "SELECT * FROM `goods` WHERE(`weight` = '" + textBox13.Text + "')";
DB.DataFromBaseToDataGridView(dataGridView2, "user_select");
}
else
{
DB.CommandText = "SELECT * FROM `goods`";
DB.DataFromBaseToDataGridView(dataGridView2, "select");
}
}
Поиск объектов по габаритам
private void textBox14_TextChanged(object sender, EventArgs e)
{
if (textBox14.Text != "" && textBox23.Text != "" && textBox24.Text != "")
{
DB.CommandText = "SELECT * FROM `goods` WHERE(`volume_x` = '" + textBox14.Text + "' AND `volume_y` = '" + textBox23.Text + "' AND `volume_z` = '" + textBox24.Text + "')";
DB.DataFromBaseToDataGridView(dataGridView2, "user_select");
}
else
{
DB.CommandText = "SELECT * FROM `goods`";
DB.DataFromBaseToDataGridView(dataGridView2, "select");
}
}
Переход к форме поиска позиции для нового объекта
private void button14_Click(object sender, EventArgs e)
{
if (textBox9.Text != "" && textBox11.Text != "" && textBox12.Text != "" && textBox18.Text != "" && textBox10.Text != "" && textBox25.Text != "" && textBox26.Text != "")
{
textBox27.Text = textBox10.Text;
tabControl1.SelectedIndex = 0;
}
else
{
MessageBox.Show("Вы заполнили не все данные", "Ошибка ввода данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
Переход к форме поиска объектов
private void button15_Click(object sender, EventArgs e)
{
if (textBox5.Text != "" && textBox6.Text != "" && textBox7.Text != "" && textBox8.Text != "" && textBox21.Text != "" && textBox22.Text != "")
{
textBox28.Text = textBox8.Text;
tabControl1.SelectedIndex = 0;
}
else
{
MessageBox.Show("Вы заполнили не все данные", "Ошибка ввода данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
Поиск объектов по позиции
private void textBox28_TextChanged(object sender, EventArgs e)
{
if (textBox28.Text != "")
{
string query = "";
textBox29.Text = textBox6.Text;
textBox30.Text = textBox21.Text;
textBox32.Text = textBox22.Text;
textBox33.Text = textBox7.Text;
textBox31.Text = textBox5.Text;
DB.CommandText = "SELECT `good_id` FROM `enter_exit` WHERE(`pos_id` = '" + textBox28.Text + "')";
DB.RunResultCommand(ref ResultArray);
//MessageBox.Show(ResultArray.Length.ToString());
if (ResultArray.Length > 1)
{
query = "SELECT * FROM `goods` WHERE(`id` = " + ResultArray[0];
for (int i = 1; i != ResultArray.Length; i++)
{
query += " OR `id` = " + ResultArray[i];
}
query += ")";
}
else if (ResultArray.Length == 1)
{
query = "SELECT * FROM `goods` WHERE(`id` = " + ResultArray[0] + ")";
}
else
{
query = "SELECT * FROM `goods` WHERE(`id` = -1)";
}
DB.CommandText = query;
DB.DataFromBaseToDataGridView(dataGridView4, "user_select");
//MessageBox.Show(query);
if(dataGridView4.Rows.Count >0)
{
textBox34.Text = dataGridView4.Rows.Count.ToString();
double weight = 0;
double volume = 0;
for(int i = 0; i!=dataGridView4.Rows.Count; i++)
{
volume += (Convert.ToDouble(dataGridView4.Rows[i].Cells[2].Value.ToString()) * Convert.ToDouble(dataGridView4.Rows[i].Cells[3].Value.ToString()) * Convert.ToDouble(dataGridView4.Rows[i].Cells[4].Value.ToString()));
weight += Convert.ToDouble(dataGridView4.Rows[i].Cells[5].Value.ToString());
}
textBox35.Text = volume.ToString();
textBox36.Text = weight.ToString();
}
else
{
textBox34.Text = "0";
textBox35.Text = "0";
textBox36.Text = "0";
}
}
else
{
textBox29.Text = "";
textBox30.Text = "";
textBox32.Text = "";
textBox33.Text = "";
textBox31.Text = "";
textBox34.Text = "";
textBox35.Text = "";
textBox36.Text = "";
}
}
Вывод данных на формы
private void button12_Click(object sender, EventArgs e)
{
DB.DataFromBaseToDataGridView(dataGridView4, "select");
}
Оптимизированный Поиск позиций по габаритам, весу, расположению и по возможности вместить еще один объект(если на позиции уже присутствуют другие объекты) одновременно и закрепление объекта за наиболее подходящей позиции
private void button11_Click(object sender, EventArgs e)
{
if (textBox27.Text != "" && textBox28.Text != "")
{
double weight = 0;
double volume_x = 0;
double volume_y = 0;
double volume_z = 0;
double obj_weight = 0;
double obj_volume_x = 0;
double obj_volume_y = 0;
double obj_volume_z = 0;
if (dataGridView4.Rows.Count > 0)
{
if (!DB.CheckFieldValue("enter_exit", "good_id", textBox27.Text))
{
weight = Convert.ToDouble(textBox31.Text);
volume_x = Convert.ToDouble(textBox32.Text);
volume_y = Convert.ToDouble(textBox30.Text);
volume_z = Convert.ToDouble(textBox29.Text);
obj_weight = Convert.ToDouble(dataGridView3.Rows[0].Cells[5].Value.ToString());
obj_volume_x = Convert.ToDouble(dataGridView3.Rows[0].Cells[2].Value.ToString());
obj_volume_y = Convert.ToDouble(dataGridView3.Rows[0].Cells[3].Value.ToString());
obj_volume_z = Convert.ToDouble(dataGridView3.Rows[0].Cells[4].Value.ToString());
for (int i = 0; i != dataGridView4.Rows.Count; i++)
{
volume_x -= (Convert.ToDouble(dataGridView4.Rows[i].Cells[2].Value.ToString()));
volume_y -= (Convert.ToDouble(dataGridView4.Rows[i].Cells[3].Value.ToString()));
volume_z -= (Convert.ToDouble(dataGridView4.Rows[i].Cells[4].Value.ToString()));
weight -= Convert.ToDouble(dataGridView4.Rows[i].Cells[5].Value.ToString());
}
if ((weight >= obj_weight - 1))
{
if ((volume_x >= obj_volume_x) && (volume_y >= obj_volume_y) && (volume_z >= obj_volume_z))
{
DB.CommandText = "INSERT INTO `enter_exit` (`id`, `pos_id`, `good_id`)VALUES(NULL, " + textBox28.Text.Trim() + "," + textBox27.Text.Trim() + ")";
if (DB.RunExecuteCommand() >= 1)
{
MessageBox.Show("Объект отправлен на склад", "Ввод объекта на склад", MessageBoxButtons.OK, MessageBoxIcon.Information);
string h = textBox28.Text;
textBox28.Text = "";
textBox28.Text = h;
}
}
else
{
MessageBox.Show("Объект не подходит по габаритам на выбранную позицию", "Обнаружена несовместимость", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
else
{
MessageBox.Show("Объект не подходит по весу на выбранную позицию", "Обнаружена несовместимость", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
else
{
MessageBox.Show("Выбранный объект уже на складе", "Объект уже на складе", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
else
{
if (!DB.CheckFieldValue("enter_exit", "good_id", textBox27.Text))
{
weight = Convert.ToDouble(textBox31.Text);
volume_x = Convert.ToDouble(textBox32.Text);
volume_y = Convert.ToDouble(textBox30.Text);
volume_z = Convert.ToDouble(textBox29.Text);
obj_weight = Convert.ToDouble(dataGridView3.Rows[0].Cells[5].Value.ToString());
obj_volume_x = Convert.ToDouble(dataGridView3.Rows[0].Cells[2].Value.ToString());
obj_volume_y = Convert.ToDouble(dataGridView3.Rows[0].Cells[3].Value.ToString());
obj_volume_z = Convert.ToDouble(dataGridView3.Rows[0].Cells[4].Value.ToString());
if ((weight >= obj_weight - 1))
{
if ((volume_x >= obj_volume_x) && (volume_y >= obj_volume_y) && (volume_z >= obj_volume_z))
{
DB.CommandText = "INSERT INTO `enter_exit` (`id`, `pos_id`, `good_id`)VALUES(NULL, " + textBox28.Text.Trim() + "," + textBox27.Text.Trim() + ")";
if (DB.RunExecuteCommand() >= 1)
{
string h = textBox28.Text;
textBox28.Text = "";
textBox28.Text = h;
MessageBox.Show("Объект отправлен на склад", "Ввод объекта на склад", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
else
{
MessageBox.Show("Объект не подходит по габаритам на выбранную позицию", "Обнаружена несовместимость", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
else
{
MessageBox.Show("Объект не подходит по весу на выбранную позицию", "Обнаружена несовместимость", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
else
{
MessageBox.Show("Выбранный объект уже на складе", "Объект уже на складе", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
else
{
MessageBox.Show("Вы заполнили не все данные", "Ошибка ввода данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
Проверка позиции по габаритам(для простого поиска)
public bool CheckXYZ(double[] obj, double[] pos)
{
BubbleSort(ref obj);
BubbleSort(ref pos);
MessageBox.Show(obj[0].ToString() + " " + obj[1].ToString() + " " + obj[2].ToString() + " " + pos[0].ToString() + " " + pos[1].ToString() + " " + pos[2].ToString());
if (pos[0] >= obj[0] - 1 && pos[1] >= obj[1] - 1 && pos[2] >= obj[2] - 1)
{
return true;
}
else
{
return false;
}
}
Сортировка подобранных позиций по наиболее близкому расположению
public void BubbleSort(ref double[] mas)
{
double buf;
for (int i = 0; i < mas.Length - 1; i++)
{
for (int j = i + 1; j < mas.Length; j++)
{
if (mas[i] > mas[j])
{
buf = mas[i];
mas[i] = mas[j];
mas[j] = buf;
}
}
}
}
private void button12_Click_1(object sender, EventArgs e)
{
if (textBox9.Text != "" && textBox11.Text != "" && textBox12.Text != "" && textBox18.Text != "" && textBox10.Text != "" && textBox25.Text != "" && textBox26.Text != "")
{
tabControl1.SelectedIndex = 1;
textBox37.Text = textBox10.Text;
}
else
{
MessageBox.Show("Вы заполнили не все данные", "Ошибка ввода данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
Выгрузка товара из учета на складе
private void button13_Click_1(object sender, EventArgs e)
{
if (textBox37.Text != "" && dataGridView5.Rows.Count > 0 && dataGridView6.Rows.Count > 0)
{
DB.CommandText = "DELETE FROM `enter_exit` WHERE(`good_id` = " + textBox37.Text + ")";
if (DB.RunExecuteCommand() >= 1)
{
DB.CommandText = "DELETE FROM `goods` WHERE(`id` = " + textBox37.Text + ")";
if (DB.RunExecuteCommand() >= 1)
{
textBox37.Text = "";
DB.DataFromBaseToDataGridView(dataGridView2, "select");
MessageBox.Show("Объект отправлен на выдачу", "Объект найден", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
else if (textBox37.Text != "" && dataGridView5.Rows.Count > 0 && dataGridView6.Rows.Count <= 0)
{
MessageBox.Show("Данного объекта нет на складе", "Объект не найден", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}