ПЗ (1218909), страница 12
Текст из файла (страница 12)
{
DictionaryUpdateFlag = true;
DictionaryNametextBox.Text = Dictionary_Data_listView.SelectedItems[0].SubItems[1].Text;
DictionaryNumbertextBox.Text = Dictionary_Data_listView.SelectedItems[0].SubItems[0].Text;
if (Dictionaries_listBox.SelectedIndex == 0)//Если изменяем запись справочника "Номенклатура"
{
DictionaryDopcomboBox.Items.Clear();
DictionaryDopcomboBox.Items.Add("ГСМ");
DictionaryDopcomboBox.Items.Add("Лесопродукция");
DictionaryDopcomboBox.Items.Add("Расходные материалы");
DictionaryDopcomboBox.Items.Add("Оборудование");
if (Dictionary_Data_listView.SelectedItems[0].SubItems[2].Text == "ГСМ")
{
DictionaryDopcomboBox.SelectedIndex = 0;
}
if (Dictionary_Data_listView.SelectedItems[0].SubItems[2].Text == "Лесопродукция")
{
DictionaryDopcomboBox.SelectedIndex = 1;
}
if (Dictionary_Data_listView.SelectedItems[0].SubItems[2].Text == "Расходные материалы")
{
DictionaryDopcomboBox.SelectedIndex = 2;
}
if (Dictionary_Data_listView.SelectedItems[0].SubItems[2].Text == "Оборудование")
{
DictionaryDopcomboBox.SelectedIndex = 3;
}
DictionaryDopcomboBox.Visible = true;
DictionaryDoplabel.Visible = true;
DictionaryDoplabel.Visible = true;
DictionaryDoplabel.Text = "Тип:";
}
if (Dictionaries_listBox.SelectedIndex == 5)//Если изменяем запись справочника "Объекты хранения и переработки"
{
DictionaryDopcomboBox.Items.Clear();
DictionaryDopcomboBox.Items.Add("Место хранения сырья");
DictionaryDopcomboBox.Items.Add("Производственный участок");
DictionaryDopcomboBox.Items.Add("Склад готовой продукции");
if (Dictionary_Data_listView.SelectedItems[0].SubItems[2].Text == "Место хранения сырья")
{
DictionaryDopcomboBox.SelectedIndex = 0;
}
if (Dictionary_Data_listView.SelectedItems[0].SubItems[2].Text == "Производственный участок")
{
DictionaryDopcomboBox.SelectedIndex = 1;
}
if (Dictionary_Data_listView.SelectedItems[0].SubItems[2].Text == "Склад готовой продукции")
{
DictionaryDopcomboBox.SelectedIndex = 2;
}
DictionaryDopcomboBox.Visible = true;
DictionaryDoplabel.Visible = true;
DictionaryDoplabel.Visible = true;
DictionaryDoplabel.Text = "Тип:";
}
if (Dictionaries_listBox.SelectedIndex == 2)//Если изменяем запись справочника "Сотрудники"
{
DictionaryDoplabel.Visible = true;
DictionaryDoplabel.Text = "Телефон:";
Dictionary_Phone_textBox.Visible = true;
Dictionary_Phone_textBox.Text = Dictionary_Data_listView.SelectedItems[0].SubItems[2].Text;
}
DictionaryEditbutton.Visible = false;
DictionaryNamelabel.Visible = true;
DictionaryNametextBox.Visible = true;
DictionaryNumberlabel.Visible = true;
DictionaryNumbertextBox.Visible = true;
DictionarySavebutton.Visible = true;
DictionaryAddbutton.Visible = false;
DictionaryCanselbutton.Visible = true;
DictionaryDeletebutton.Visible = false;
}
}
public void FullWarehouseCarLocationComboBox()
//Заполнить выпадающие списки складов, машин и делянок
{
//Очистим списки
ID_warehouse_listBox.Items.Clear();
ID_location_listBox.Items.Clear();
ID_car_listBox.Items.Clear();
Into_doc_warehouse_comboBox.Items.Clear();
Into_doc_location_comboBox.Items.Clear();
Into_doc_car_comboBox.Items.Clear();
Sales_doc_warehouse_comboBox.Items.Clear();
MinimalsWarehousecomboBox.Items.Clear();
Brigade_locations_comboBox.Items.Clear();
Demand_Warehouse_comboBox.Items.Clear();
//Получим запросом данные по складам
string sqlText = "SELECT * FROM warehouses";//Текст SQL запроса
MySqlConnection MySQLConnection = new MySqlConnection(ConnectionString);//Создадим соединение
try
{
MySQLConnection.Open();//Откроем соединение с БД
MySqlCommand MySQLCommand = new MySqlCommand(sqlText, MySQLConnection);
MySqlDataReader Reader = MySQLCommand.ExecuteReader();
while (Reader.Read())//Построчно перебираем результат запроса
{
ID_warehouse_listBox.Items.Add(Convert.ToString(Reader.GetInt32(0)));
if(MaintabControl.SelectedIndex==1)//Если активна вкладка "Поступления"
{
Into_doc_warehouse_comboBox.Items.Add(Reader.GetString(1));
}
if (MaintabControl.SelectedIndex == 3)//Если активна вкладка "Продажи"
{
Sales_doc_warehouse_comboBox.Items.Add(Reader.GetString(1));
}
if (MaintabControl.SelectedIndex == 7)//Если активна вкладка "Минимальные запасы"
{
MinimalsWarehousecomboBox.Items.Add(Reader.GetString(1));
}
if (MaintabControl.SelectedIndex == 6)//Если активна вкладка "Заявки"
{
Demand_Warehouse_comboBox.Items.Add(Reader.GetString(1));
}
}
}
catch { }
//Получим запросом данные по транспортным средствам
sqlText = "SELECT * FROM cars";//Текст SQL запроса
MySQLConnection = new MySqlConnection(ConnectionString);//Создадим соединение
try
{
MySQLConnection.Open();//Откроем соединение с БД
MySqlCommand MySQLCommand = new MySqlCommand(sqlText, MySQLConnection);
MySqlDataReader Reader = MySQLCommand.ExecuteReader();
while (Reader.Read())//Построчно перебираем результат запроса
{
ID_car_listBox.Items.Add(Convert.ToString(Reader.GetInt32(0)));
if (MaintabControl.SelectedIndex == 1)//Если активна вкладка "Поступления"
{
Into_doc_car_comboBox.Items.Add(Reader.GetString(1));
}
}
}
catch { }
//Получим запросом данные по транспортным средствам
sqlText = "SELECT * FROM locations";//Текст SQL запроса
MySQLConnection = new MySqlConnection(ConnectionString);//Создадим соединение
try
{
MySQLConnection.Open();//Откроем соединение с БД
MySqlCommand MySQLCommand = new MySqlCommand(sqlText, MySQLConnection);
MySqlDataReader Reader = MySQLCommand.ExecuteReader();
while (Reader.Read())//Построчно перебираем результат запроса
{
ID_location_listBox.Items.Add(Convert.ToString(Reader.GetInt32(0)));
if (MaintabControl.SelectedIndex == 1)//Если активна вкладка "Поступления"
{
Into_doc_location_comboBox.Items.Add(Reader.GetString(1));
}
if (MaintabControl.SelectedIndex == 5)//Если активна вкладка "Производство"
{
Brigade_locations_comboBox.Items.Add(Reader.GetString(1));
}
}
}
catch { }
}
public void UpdateIntoDocs()
//Получим данные по документам поступления и выведем их в таблицу
{
ID_Into_docs_listBox.Items.Clear();
Into_docs_listView.Items.Clear();
string sqlText = @"SELECT ID_doc,DocNumber,DocDate,WarehouseName,CarName,LocationName FROM into_doc
LEFT JOIN warehouses ON warehouses.ID_warehouse=into_doc.ID_warehouse
LEFT JOIN cars ON cars.ID_car=into_doc.ID_car
LEFT JOIN locations ON locations.ID_location=into_doc.ID_location";//Текст SQL запроса
MySqlConnection MySQLConnection = new MySqlConnection(ConnectionString);//Создадим соединение
MySQLConnection.Open();//Откроем соединение с БД
MySqlCommand MySQLCommand = new MySqlCommand(sqlText, MySQLConnection);
MySqlDataReader Reader = MySQLCommand.ExecuteReader();
while (Reader.Read())//Построчно перебираем результат запроса
{
ID_Into_docs_listBox.Items.Add(Convert.ToString(Reader.GetInt32(0)));
ListViewItem Into_doc_Item = new ListViewItem(Reader.GetString(1));
Into_doc_Item.SubItems.Add(Reader.GetDateTime(2).ToShortDateString());
try{
Into_doc_Item.SubItems.Add(Reader.GetString(3));
}
catch{
Into_doc_Item.SubItems.Add(" ");
}
try{
Into_doc_Item.SubItems.Add(Reader.GetString(4));
}
catch{
Into_doc_Item.SubItems.Add(" ");
}
try{
Into_doc_Item.SubItems.Add(Reader.GetString(5));
}
catch{
Into_doc_Item.SubItems.Add(" ");
}
Into_docs_listView.Items.Add(Into_doc_Item);
}
}
public void UpdateOutDocs()
//Получим данные по документам поступления и выведем их в таблицу
{
ID_Into_docs_listBox.Items.Clear();
Into_docs_listView.Items.Clear();
string sqlText = @"SELECT ID_doc,DocNumber,DocDate,WarehouseName,CarName,LocationName FROM out_doc
LEFT JOIN warehouses ON warehouses.ID_warehouse=out_doc.ID_warehouse
LEFT JOIN cars ON cars.ID_car=out_doc.ID_car
LEFT JOIN locations ON locations.ID_location=out_doc.ID_location";//Текст SQL запроса
MySqlConnection MySQLConnection = new MySqlConnection(ConnectionString);//Создадим соединение
try
{
MySQLConnection.Open();//Откроем соединение с БД
MySqlCommand MySQLCommand = new MySqlCommand(sqlText, MySQLConnection);
MySqlDataReader Reader = MySQLCommand.ExecuteReader();
while (Reader.Read())//Построчно перебираем результат запроса
{
ID_Into_docs_listBox.Items.Add(Convert.ToString(Reader.GetInt32(0)));
ListViewItem Out_doc_Item = new ListViewItem(Reader.GetString(1));
Out_doc_Item.SubItems.Add(Reader.GetDateTime(2).ToShortDateString());
try
{
Out_doc_Item.SubItems.Add(Reader.GetString(3));
}
catch
{
Out_doc_Item.SubItems.Add(" ");
}
try
{
Out_doc_Item.SubItems.Add(Reader.GetString(4));
}
catch
{
Out_doc_Item.SubItems.Add(" ");
}
try
{
Out_doc_Item.SubItems.Add(Reader.GetString(5));
}
catch
{
Out_doc_Item.SubItems.Add(" ");
}
Into_docs_listView.Items.Add(Out_doc_Item);
}
}
catch { }
}
private void Into_doc_Add_button_Click(object sender, EventArgs e)
//Нажатие кнопки "Добавить документ поступления"
{
//Установим видимость элементов и заполним выпадающие списки
Into_doc_Number_textBox.Visible = true;
Into_doc_Save_button.Visible = true;
Into_doc_warehouse_comboBox.Visible = true;
Into_doc_location_comboBox.Visible = true;
Into_doc_car_comboBox.Visible = true;
Into_Data_listView.Visible = true;
IntoData_Add_button.Visible = true;
IntoData_Del_button.Visible = true;
Into_Data_listView.Visible = true;
Into_doc_Cancel_button.Visible = true;
Into_Number_label.Visible = true;
Into_date_label.Visible = true;
Into_warehouse_label.Visible = true;
Into_car_label.Visible = true;
Into_location_label.Visible = true;
Into_doc_dateTimePicker.Visible = true;
FullWarehouseCarLocationComboBox();
ID_into_Data_listBox.Items.Clear();
Into_Data_listView.Items.Clear();
}
private void FullDemandsList()
//Заполнить список заявок на согласование
{
DemandsToDecidelistView.Items.Clear();//Очистим список заявок
string sqlText = @"SELECT ID_demand,DocDate,WarehouseName FROM demands
JOIN warehouses ON warehouses.ID_warehouse=demands.ID_warehouse WHERE demands.DemandState=0";//Текст SQL запроса
MySqlConnection MySQLConnection = new MySqlConnection(ConnectionString);//Создадим соединение
try
{
MySQLConnection.Open();//Откроем соединение с БД
MySqlCommand MySQLCommand = new MySqlCommand(sqlText, MySQLConnection);
MySqlDataReader Reader = MySQLCommand.ExecuteReader();
while (Reader.Read())//Построчно перебираем результат запроса
{
ListViewItem Demand_Item = new ListViewItem(Convert.ToString(Reader.GetInt32(0)));
Demand_Item.SubItems.Add(Reader.GetDateTime(1).ToShortDateString());
Demand_Item.SubItems.Add(Reader.GetString(2));
DemandsToDecidelistView.Items.Add(Demand_Item);
}
}















