Разработка информационной системы "Учет и контроль заказов фирмы "Окна Марио"
Рассмотрение условий работы сотрудников фирмы "Окна Марио". Составление базы данных для проектирования информационной системы учета и контроля заказов. Разработка проекта. Произведенный расчет экономической эффективности и экологичности программы.
Рубрика | Программирование, компьютеры и кибернетика |
Вид | дипломная работа |
Язык | русский |
Дата добавления | 29.08.2014 |
Размер файла | 4,6 M |
Отправить свою хорошую работу в базу знаний просто. Используйте форму, расположенную ниже
Студенты, аспиранты, молодые ученые, использующие базу знаний в своей учебе и работе, будут вам очень благодарны.
connection.Close();
return cust;
}
// Добавление поставщика
public Supplier SetSupplier(Supplier supplier, string source)
{
SqlConnection connection = GetConnection(source);
string maxNumberQuery = String.Format(@"SELECT MAX(Id)
FROM [MariosWindows].[dbo].[Suppliers]");
var maxNumberCommand = new SqlCommand(maxNumberQuery, connection);
maxNumberCommand.CommandTimeout = 0;
int incrMaxNumber = Convert.ToInt32(maxNumberCommand.ExecuteScalar()) + 1;
string specificationsQuery = String.Format(
@"INSERT INTO Suppliers
VALUES ({0}, N'{1}',N'{2}',N'{3}',N'{4}')", incrMaxNumber, supplier.Name.Trim(), supplier.Address.Trim(),
supplier.INN, supplier.KPP);
var specificationsCommand = new SqlCommand(specificationsQuery, connection);
specificationsCommand.CommandTimeout = 0;
SqlDataReader reader = specificationsCommand.ExecuteReader();
supplier.Id = incrMaxNumber;
reader.Close();
connection.Close();
return supplier;
}
// Добавление комплектации
public void SetConfiguration(Configuration configuration, string source)
{
SqlConnection connection = GetConnection(source);
string maxNumberQuery = String.Format(@"SELECT MAX(Id)
FROM [MariosWindows].[dbo].[Configuration]");
var maxNumberCommand = new SqlCommand(maxNumberQuery, connection);
maxNumberCommand.CommandTimeout = 0;
int incrMaxNumber = Convert.ToInt32(maxNumberCommand.ExecuteScalar()) + 1;
string specificationsQuery = String.Format(
@"INSERT INTO Configuration
VALUES ({0}, {1},N'{2}',{3},{4}, {5}, N'{6}', null)", incrMaxNumber,configuration.IdSuppliers,
configuration.Name.Trim(),
configuration.PriceWithMargin, configuration.PriceSupplier, configuration.CountStore, configuration.Category);
var specificationsCommand = new SqlCommand(specificationsQuery, connection);
specificationsCommand.CommandTimeout = 0;
SqlDataReader reader = specificationsCommand.ExecuteReader();
reader.Close();
connection.Close();
}
// Добавление услуги
public void SetService(Service service, string source)
{
SqlConnection connection = GetConnection(source);
string maxNumberQuery = String.Format(@"SELECT MAX(Id)
FROM [MariosWindows].[dbo].[Services]");
var maxNumberCommand = new SqlCommand(maxNumberQuery, connection);
maxNumberCommand.CommandTimeout = 0;
int incrMaxNumber = Convert.ToInt32(maxNumberCommand.ExecuteScalar()) + 1;
string specificationsQuery = String.Format(
@"INSERT INTO Services
VALUES ({0}, N'{1}',{2},N'{3}')", incrMaxNumber, service.Name,
service.Cost, service.Category);
var specificationsCommand = new SqlCommand(specificationsQuery, connection);
specificationsCommand.CommandTimeout = 0;
SqlDataReader reader = specificationsCommand.ExecuteReader();
reader.Close();
connection.Close();
}
// Добавление сотрудников
public void SetEmployee(Employee employee, string source)
{
SqlConnection connection = GetConnection(source);
string maxNumberQuery = String.Format(@"SELECT MAX(Id)
FROM [MariosWindows].[dbo].[Employees]");
var maxNumberCommand = new SqlCommand(maxNumberQuery, connection);
maxNumberCommand.CommandTimeout = 0;
int incrMaxNumber = Convert.ToInt32(maxNumberCommand.ExecuteScalar()) + 1;
string specificationsQuery = String.Format(
@"INSERT INTO Employees
VALUES ({0}, N'{1}',N'{2}',N'{3}',N'{4}',N'{5}',N'{6}',N'{7}',N'{8}',N'{9}',N'{10}')", incrMaxNumber, employee.Name,
employee.Surname, employee.Patronomic,employee.PasportSeries, employee.PasportName,
employee.BusinessPhone, employee.Email, employee.Profession, employee.Birthday,employee.Address);
var specificationsCommand = new SqlCommand(specificationsQuery, connection);
specificationsCommand.CommandTimeout = 0;
SqlDataReader reader = specificationsCommand.ExecuteReader();
reader.Close();
connection.Close();
}
// Поиск всех объектов
public List<PlaceWork> GetPlaceWork(string source)
{
SqlConnection connection = GetConnection(source);
var placeWorks = new List<PlaceWork>();
string specificationsQuery = String.Format(
@"SELECT [Id]
,[Address]
,[Note]
FROM [MariosWindows].[dbo].[Objects]
ORDER BY [Address]");
var specificationsCommand = new SqlCommand(specificationsQuery, connection);
specificationsCommand.CommandTimeout = 0;
SqlDataReader reader = specificationsCommand.ExecuteReader();
while (reader.Read())
{
var placeWork = new PlaceWork();
placeWork.Id = Convert.ToInt32(reader[0]);
placeWork.Address = reader[1].ToString();
if (reader[2] != null)
placeWork.Note = reader[2].ToString();
else
placeWork.Note = string.Empty;
placeWorks.Add(placeWork);
}
reader.Close();
connection.Close();
return placeWorks;
}
// Поиск всех заказчиков
public List<Customer> GetCustomer(string source)
{
SqlConnection connection = GetConnection(source);
var customers = new List<Customer>();
string specificationsQuery = String.Format(
@"SELECT [Id]
,[Family]
,[Name]
,[Patronomic]
,[AddressResidence]
,[Phone1]
,[Phone2]
FROM [MariosWindows].[dbo].[Customer]
ORDER BY [Family],[Name]");
var specificationsCommand = new SqlCommand(specificationsQuery, connection);
specificationsCommand.CommandTimeout = 0;
SqlDataReader reader = specificationsCommand.ExecuteReader();
while (reader.Read())
{
var cust = new Customer();
cust.Id = Convert.ToInt32(reader[0]);
cust.Surname = reader[1].ToString();
cust.Name = reader[2].ToString();
if (reader[3] != null)
cust.Patronomyc = reader[3].ToString();
else
cust.Patronomyc = string.Empty;
if (reader[4] != null)
cust.Address = reader[4].ToString();
else
cust.Address = string.Empty;
cust.Phone1 = reader[5].ToString();
if (reader[6] != null)
cust.Phone2 = reader[6].ToString();
else
cust.Phone2 = string.Empty;
customers.Add(cust);
}
reader.Close();
connection.Close();
return customers;
}
// Добавление места работы
public PlaceWork SetPlaceWork(PlaceWork placeWork, string source)
{
SqlConnection connection = GetConnection(source);
string maxNumberQuery = String.Format(@"SELECT MAX(Id)
FROM [MariosWindows].[dbo].[Objects]");
var maxNumberCommand = new SqlCommand(maxNumberQuery, connection);
maxNumberCommand.CommandTimeout = 0;
int incrMaxNumber = Convert.ToInt32(maxNumberCommand.ExecuteScalar()) + 1;
string specificationsQuery = String.Format(
@"INSERT INTO Objects
VALUES ({0}, N'{1}',N'{2}')", incrMaxNumber, placeWork.Address.Trim(),
placeWork.Note);
var specificationsCommand = new SqlCommand(specificationsQuery, connection);
specificationsCommand.CommandTimeout = 0;
SqlDataReader reader = specificationsCommand.ExecuteReader();
placeWork.Id = incrMaxNumber;
reader.Close();
connection.Close();
return placeWork;
}
public void AddOrder(Order order, List<Service> services, List<Configuration> configurations, List<Employee> employees, string source)
{
SqlConnection connection = GetConnection(source);
string maxNumberQuery = String.Format(@"SELECT MAX(IdOrder)
FROM [MariosWindows].[dbo].[Orders]");
var maxNumberCommand = new SqlCommand(maxNumberQuery, connection);
maxNumberCommand.CommandTimeout = 0;
int incrMaxNumber = Convert.ToInt32(maxNumberCommand.ExecuteScalar()) + 1;
string specificationsQuery = String.Format(
@"INSERT INTO [MariosWindows].[dbo].[Orders]
([IdOrder]
,[IdObjectInstallation]
,[IdCustomer]
,[OrderNumber]
,[OrderDate]
,[TermPerfomance]
,[PaymentKind]
,[AdvancePayment]
,[TotalSum]
,[OrderPaid]
,[BeginWorkDate])
VALUES ({0}, {1},{2},'{3}','{4}','{5}','{6}',{7},{8},{9},'{10}')", incrMaxNumber, order.IdObjectInstallation,order.IdCustomer,order.Number,
order.Date.ToShortDateString(), order.TermPerfomance, order.PaymentKind, order.PaymentAdvance, order.TotalSum, Convert.ToInt32(order.OrderPaid), order.BeginWorkDate.ToShortDateString());
var specificationsCommand = new SqlCommand(specificationsQuery, connection);
specificationsCommand.CommandTimeout = 0;
SqlDataReader reader = specificationsCommand.ExecuteReader();
// cust.Id = incrMaxNumber;
reader.Close();
foreach (var service in services)
{
string specificationsQueryOrderService = String.Format(
@" INSERT INTO [MariosWindows].[dbo].[OrdersServices]
([idServices]
,[idOrder]
,[Count])
VALUES ({0}, {1},{2})", service.Id, incrMaxNumber, service.Count);
var specificationsCommandOrderService = new SqlCommand(specificationsQueryOrderService, connection);
specificationsCommandOrderService.CommandTimeout = 0;
SqlDataReader reader2 = specificationsCommandOrderService.ExecuteReader();
reader2.Close();
}
foreach (var configuration in configurations)
{
string specificationsQueryOrderConfiguration = String.Format(
@" INSERT INTO [MariosWindows].[dbo].[OrdersConfigurations]
([idConfiguration]
,[idOrder]
,[Count])
VALUES ({0}, {1},{2})", configuration.Id, incrMaxNumber, configuration.Count);
var specificationsCommandOrderConfiguration = new SqlCommand(specificationsQueryOrderConfiguration, connection);
specificationsCommandOrderConfiguration.CommandTimeout = 0;
SqlDataReader reader3 = specificationsCommandOrderConfiguration.ExecuteReader();
reader3.Close();
}
foreach (var employee in employees)
{
string specificationsQueryOrderEmployee = String.Format(
@" INSERT INTO [MariosWindows].[dbo].[EmployeesOrders]
([idEmployee]
,[idOrder])
VALUES ({0}, {1})", employee.Id, incrMaxNumber);
var specificationsCommandOrderEmployee = new SqlCommand(specificationsQueryOrderEmployee, connection);
specificationsCommandOrderEmployee.CommandTimeout = 0;
SqlDataReader reader4 = specificationsCommandOrderEmployee.ExecuteReader();
reader4.Close();
}
connection.Close();
}
public int IncrementNumberOrder(string source)
{
SqlConnection connection = GetConnection(source);
string maxNumberQuery = String.Format(@"SELECT MAX(OrderNumber)
FROM [MariosWindows].[dbo].[Orders]");
var maxNumberCommand = new SqlCommand(maxNumberQuery, connection);
maxNumberCommand.CommandTimeout = 0;
return Convert.ToInt32(maxNumberCommand.ExecuteScalar()) + 1;
}
// Поиск заказов
public List<Order> GetOrder(string val, string source)
{
SqlConnection connection = GetConnection(source);
var orders = new List<Order>();
var specificationsCommand = new SqlCommand(val, connection);
specificationsCommand.CommandTimeout = 0;
SqlDataReader reader = specificationsCommand.ExecuteReader();
while (reader.Read())
{
var order = new Order();
order.IdOrder = Convert.ToInt32(reader[0]);
order.Number = Convert.ToInt32(reader[1]);
order.Date = Convert.ToDateTime(reader[2]);
order.TermPerfomance = reader[3].ToString();
order.PaymentKind = reader[4].ToString();
order.PaymentAdvance = Convert.ToInt32(reader[5]);
order.TotalSum = Convert.ToInt32(reader[6]);
order.OrderPaid = Convert.ToBoolean(reader[7]);
order.BeginWorkDate = Convert.ToDateTime(reader[8]);
var customer = new Customer();
customer.Surname = reader[9].ToString();
customer.Name = reader[10].ToString();
customer.Patronomyc = reader[11].ToString();
customer.Address = reader[12].ToString();
customer.Phone1 = reader[13].ToString();
customer.Phone2 = reader[14].ToString();
order.customer = customer;
var placeWork = new PlaceWork();
placeWork.Address = reader[15].ToString();
placeWork.Note = reader[16].ToString();
order.placeWork = placeWork;
orders.Add(order);
}
reader.Close();
foreach (var order in orders)
{
var employees = new List<Employee>();
string query = String.Format(@"SELECT
em.Id,
em.Surname,
em.Name,
em.Patronymic,
em.BusinessPhone,
em.EMail,
em.PassportNumber,
em.PassportSeries,
em.Profession,
em.[Address],
em.Birthday,
eo.PersonHour
FROM Employees em INNER JOIN EmployeesOrders eo ON (em.Id = eo.IdEmployee)
WHERE eo.IdOrder = {0}" , order.IdOrder);
var specificationsEmployeesCommand = new SqlCommand(query, connection);
specificationsEmployeesCommand.CommandTimeout = 0;
SqlDataReader reader2 = specificationsEmployeesCommand.ExecuteReader();
while (reader2.Read())
{
var employee = new Employee();
employee.Id = Convert.ToInt32(reader2[0].ToString());
employee.Surname = reader2[1].ToString();
employee.Name = reader2[2].ToString();
employee.Patronomic = reader2[3].ToString();
employee.BusinessPhone = reader2[4].ToString();
employee.Email = reader2[5].ToString();
employee.PasportName = reader2[6].ToString();
employee.PasportSeries = reader2[7].ToString();
employee.Profession = reader2[8].ToString();
employee.Address = reader2[9].ToString();
employee.Birthday = Convert.ToDateTime(reader2[10]).Date;
if (reader2[11] != DBNull.Value)
employee.PersonHour = Convert.ToDouble(reader2[11]);
else
employee.PersonHour = 0;
employees.Add(employee);
}
order.Employees = employees;
reader2.Close();
var services = new List<Service>();
string specificationsServiceQuery = String.Format(
@"SELECT s.[Id]
,s.[ServicesKind]
,s.[Cost]
,s.[Category]
,so.Count
FROM [Services] s INNER JOIN OrdersServices so ON (s.Id = so.idServices)
WHERE so.IdOrder = {0}
ORDER BY Category", order.IdOrder);
var specificationsServiceCommand = new SqlCommand(specificationsServiceQuery, connection);
specificationsServiceCommand.CommandTimeout = 0;
SqlDataReader reader3 = specificationsServiceCommand.ExecuteReader();
while (reader3.Read())
{
var service = new Service();
service.Id = Convert.ToInt32(reader3[0]);
service.Name = reader3[1].ToString();
service.Cost = Convert.ToDouble(reader3[2].ToString());
service.Category = reader3[3].ToString();
service.Count = Convert.ToInt32(reader3[4]);
services.Add(service);
}
order.Services = services;
reader3.Close();
var configurations = new List<Configuration>();
string specificationsConfigurationQuery = String.Format(
@"SELECT conf.[Id]
,conf.[ConfigurationKind]
,conf.[PriceWithMargin]
,conf.[PriceSupplier]
,conf.[CountStore]
,conf.[Category]
,oc.Count
FROM [MariosWindows].[dbo].[Configuration] conf INNER JOIN OrdersConfigurations oc ON(conf.Id = oc.IdConfiguration)
WHERE oc.IdOrder = {0}
ORDER BY Category", order.IdOrder);
var specificationsConfigurationCommand = new SqlCommand(specificationsConfigurationQuery, connection);
specificationsConfigurationCommand.CommandTimeout = 0;
SqlDataReader reader4 = specificationsConfigurationCommand.ExecuteReader();
while (reader4.Read())
{
var configuration = new Configuration();
configuration.Id = Convert.ToInt32(reader4[0]);
configuration.Name = reader4[1].ToString();
configuration.PriceWithMargin = Convert.ToDouble(reader4[2].ToString());
configuration.PriceSupplier = Convert.ToDouble(reader4[3].ToString());
configuration.CountStore = Convert.ToInt32(reader4[4].ToString());
configuration.Category = reader4[5].ToString();
configuration.Count = Convert.ToInt32(reader4[6]);
configurations.Add(configuration);
}
order.Configurations = configurations;
reader4.Close();
}
connection.Close();
return orders;
}
// Получить список Поставщиков
public List<Supplier> GetSuppliers(string source)
{
var listSuppliers = new List<Supplier>();
SqlConnection connection = GetConnection(source);
string specificationsQuery = String.Format(
@"SELECT [Id]
,[Name]
,[Address]
,[INN]
,[KPP]
FROM [MariosWindows].[dbo].[Suppliers]
Order By Name");
var specificationsCommand = new SqlCommand(specificationsQuery, connection);
specificationsCommand.CommandTimeout = 0;
SqlDataReader reader = specificationsCommand.ExecuteReader();
while (reader.Read())
{
var supplier = new Supplier();
supplier.Id = Convert.ToInt32(reader[0]);
supplier.Name = reader[1].ToString();
supplier.Address = reader[2].ToString();
supplier.INN = reader[3].ToString();
supplier.KPP = reader[4].ToString();
listSuppliers.Add(supplier);
}
reader.Close();
connection.Close();
return listSuppliers;
}
}
class SqlFindOrder
{
private static string FindOrder = String.Format(@"SELECT o.IdOrder
,o.[OrderNumber]
,o.[OrderDate]
,o.[TermPerfomance]
,o.[PaymentKind]
,o.[AdvancePayment]
,o.[TotalSum]
,o.[OrderPaid]
,o.[BeginWorkDate]
,c.Family
,c.Name
,c.Patronomic
,c.AddressResidence
,c.Phone1
,c.Phone2
,obj.[Address]
,obj.Note
FROM [Orders] o INNER JOIN Customer c ON (o.IdCustomer = c.Id)
INNER JOIN [Objects] obj ON (obj.Id = o.IdObjectInstallation)");
public string Number = FindOrder + " WHERE o.OrderNumber";
public string Date = FindOrder + " WHERE o.[OrderDate]";
public string TermPerfomance = FindOrder + " WHERE o.[TermPerfomance]";
public string PaymentKind = FindOrder + " WHERE o.[PaymentKind]";
public string AdvancePayment = FindOrder + " WHERE o.[AdvancePayment]";
public string TotalSum = FindOrder + " WHERE o.TotalSum";
public string Address = FindOrder + " WHERE c.AddressResidence";
public string Surname = FindOrder + " WHERE c.Family";
public string BeginWorkDate = FindOrder + " WHERE o.[BeginWorkDate]";
}
}
Текст модуля MainForm
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
namespace MariosWindows
{
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
}
public bool admin = false;
readonly SqlOperation sqlOperation = new SqlOperation();
private SelectEmployeeForm selectEmployeeForm;
private AddServiceForm addServiceForm;
private AddConfigurationForm addConfigurationForm;
private AddCustomerForm addCustomerForm;
private AddObjectForm addObjectForm;
private FindOrderForm findOrderForm;
private AuthorizationAndSelectDBForm selectDBForm;
private Order order = new Order();
private string source = "";
private void buttonAddOrder_Click(object sender, EventArgs e)
{
var errorAdd = false;
if (comboBoxPaymentKind.Text == string.Empty)
{
labelPaymentKind.Text = "Вид оплаты:*";
labelPaymentKind.ForeColor = Color.Red;
errorAdd = true;
}
else
{
labelPaymentKind.Text = "Вид оплаты:";
labelPaymentKind.ForeColor = Color.Black;
}
if (textBoxAdvancePayment.Text == string.Empty)
{
labelAdvancePayment.Text = "Предоплата:*";
labelAdvancePayment.ForeColor = Color.Red;
errorAdd = true;
}
else
{
labelAdvancePayment.Text = "Предоплата:";
labelAdvancePayment.ForeColor = Color.Black;
}
if (textBoxTermPerfomance.Text == string.Empty)
{
labelTermPerfomance.Text = "Срок выполнения:*";
labelTermPerfomance.ForeColor = Color.Red;
errorAdd = true;
}
else
{
labelTermPerfomance.Text = "Срок выполнения:";
labelTermPerfomance.ForeColor = Color.Black;
}
if (listViewServices.Items.Count == 0)
{
groupBoxServices.Text = "Услуги*";
groupBoxServices.ForeColor = Color.Red;
errorAdd = true;
}
else
{
groupBoxServices.Text = "Услуги";
groupBoxServices.ForeColor = Color.Black;
}
if (listViewConfiguration.Items.Count == 0)
{
groupBoxConfigurations.Text = "Комплектация*";
groupBoxConfigurations.ForeColor = Color.Red;
errorAdd = true;
}
else
{
groupBoxConfigurations.Text = "Комплектация";
groupBoxConfigurations.ForeColor = Color.Black;
}
if (listViewEmployees.Items.Count == 0)
{
groupBoxMakes.Text = "Исполнители*";
groupBoxMakes.ForeColor = Color.Red;
errorAdd = true;
}
else
{
groupBoxMakes.Text = "Исполнители";
groupBoxMakes.ForeColor = Color.Black;
}
if (comboBoxCustomer.Text == string.Empty)
{
labelCustomer.Text = "Заказчик:*";
labelCustomer.ForeColor = Color.Red;
errorAdd = true;
}
else
{
labelCustomer.Text = "Заказчик:";
labelCustomer.ForeColor = Color.Black;
}
if (comboBoxObject.Text == string.Empty)
{
labelObject.Text = "Объект:*";
labelObject.ForeColor = Color.Red;
errorAdd = true;
}
else
{
labelObject.Text = "Объект:";
labelObject.ForeColor = Color.Black;
}
if (errorAdd)
{
MessageBox.Show("Ошибка ввода данных", "Нельзя добавить заказ", MessageBoxButtons.OK,
MessageBoxIcon.Information);
return;
}
var services = new List<Service>();
var configurations = new List<Configuration>();
var employees = new List<Employee>();
order.Number = Convert.ToInt32(textBoxNumberOrder.Text.Trim());
order.OrderPaid = checkBoxOrderPaid.Checked;
try
{
order.PaymentAdvance = Convert.ToDouble(textBoxAdvancePayment.Text);
}
catch (Exception)
{
labelAdvancePayment.Text = "Предоплата:*";
labelAdvancePayment.ForeColor = Color.Red;
MessageBox.Show("Неверный формат записи в поле 'Предоплата'! Введите число!", "Ошибка!", MessageBoxButtons.OK,
MessageBoxIcon.Error);
return;
}
order.PaymentKind = comboBoxPaymentKind.Text;
order.TermPerfomance = textBoxTermPerfomance.Text;
order.TotalSum = Convert.ToDouble(textBoxSummaryCost.Text);
if (order.TotalSum == 0)
{
MessageBox.Show("Ошибка ввода данных. Сумма заказа не может быть равна 0", "Нельзя добавить заказ", MessageBoxButtons.OK,
MessageBoxIcon.Information);
return;
}
if (order.TotalSum - order.PaymentAdvance<0)
{
MessageBox.Show("Ошибка ввода данных. Сумма заказа не может быть меньше предоплаты", "Нельзя добавить заказ", MessageBoxButtons.OK,
MessageBoxIcon.Information);
return;
}
order.Date = Convert.ToDateTime(dateTimePickerOrder.Text);
order.BeginWorkDate = Convert.ToDateTime(dateTimePickerBeginWork.Text);
foreach (ListViewItem item in listViewServices.Items)
{
services.Add((Service)item.Tag);
}
order.Services = services;
foreach (ListViewItem item in listViewConfiguration.Items)
{
configurations.Add((Configuration)item.Tag);
}
order.Configurations = configurations;
foreach (ListViewItem item in listViewEmployees.Items)
{
employees.Add((Employee)item.Tag);
}
order.Employees = employees;
sqlOperation.AddOrder(order, services, configurations, employees, source);
if(MessageBox.Show("Заказ успешно добавлен. Сформировать счет на оплату?", "Заказ сформирован", MessageBoxButtons.YesNo,MessageBoxIcon.Asterisk) == DialogResult.Yes)
{
var excelAppShet = new ExcelReader(@"C:\шаблоны\schet-na-oplatu.xls");
var fileShet = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
"schet-na-oplatu.xls");
var reportClass = new ReportClass();
reportClass.MakeReportShetNaOplatu(excelAppShet, order);
excelAppShet.SaveDocument(fileShet);
System.Diagnostics.Process.Start(fileShet);
}
}
private void buttonAddMaker_Click(object sender, EventArgs e)
{
selectEmployeeForm = new SelectEmployeeForm();
addEmployeeTimer.Start();
sqlOperation.GetConnection(source);
var employees = sqlOperation.GetEmployees( source);
selectEmployeeForm.Visible = true;
selectEmployeeForm.listViewObjectsMakes.Items.Clear();
for (int i= 0; i<employees.Count; i++)
{
var item = new ListViewItem((i+1).ToString());
item.SubItems.Add(employees[i].Surname + " " + employees[i].Name + " " + employees[i].Patronomic);
item.SubItems.Add(employees[i].Profession);
item.SubItems.Add(employees[i].BusinessPhone);
item.Tag = employees[i];
selectEmployeeForm.listViewFindObjects.Items.Add(item);
selectEmployeeForm.listViewFindObjects.Refresh();
}
}
private void addEmployeeTimer_Tick(object sender, EventArgs e)
{
if (selectEmployeeForm != null)
{
if (selectEmployeeForm.addEmployee && !selectEmployeeForm.Visible)
{
selectEmployeeForm.addEmployee = false;
for (int i = 0; i < selectEmployeeForm.listViewObjectsMakes.Items.Count; i++)
{
var item = new ListViewItem((listViewEmployees.Items.Count + 1).ToString());
item.SubItems.Add(selectEmployeeForm.listViewObjectsMakes.Items[i].SubItems[1].Text);
item.Tag = selectEmployeeForm.listViewObjectsMakes.Items[i].Tag;
listViewEmployees.Items.Add(item);
listViewEmployees.Refresh();
}
selectEmployeeForm.Close();
addEmployeeTimer.Stop();
}
}
}
private void buttonAddService_Click(object sender, EventArgs e)
{
addServiceForm = new AddServiceForm();
addServiceTimer.Start();
sqlOperation.GetConnection(source);
var servicesCategory = sqlOperation.GetServices( source);
addServiceForm.Visible = true;
addServiceForm.listViewObjectsServices.Items.Clear();
addServiceForm.categoryService = servicesCategory;
foreach (var listServices in servicesCategory.Values)
{
foreach (var service in listServices)
{
var item = new ListViewItem((addServiceForm.listViewFindObjects.Items.Count + 1).ToString());
item.SubItems.Add(service.Name);
item.SubItems.Add(service.Cost.ToString());
item.Tag = service;
addServiceForm.listViewFindObjects.Items.Add(item);
addServiceForm.listViewFindObjects.Refresh();
}
}
foreach (var category in servicesCategory.Keys)
{
addServiceForm.comboBoxCategory.Items.Add(category);
}
if (listViewServices.Items.Count > 0)
foreach (ListViewItem item in listViewServices.Items)
{
var itx = new ListViewItem((addServiceForm.listViewObjectsServices.Items.Count + 1).ToString());
itx.SubItems.Add(((Service)item.Tag).Name);
itx.SubItems.Add(((Service)item.Tag).SummaryCost.ToString());
itx.SubItems.Add(((Service)item.Tag).Count.ToString());
itx.Tag = (Service)item.Tag;
addServiceForm.listViewObjectsServices.Items.Add(itx);
}
}
private void addServiceTimer_Tick(object sender, EventArgs e)
{
if (addServiceForm != null)
{
if (addServiceForm.addService && !addServiceForm.Visible)
{
addServiceForm.addService = false;
listViewServices.Items.Clear();
for (int i = 0; i < addServiceForm.listViewObjectsServices.Items.Count; i++)
{
var item = new ListViewItem((listViewServices.Items.Count + 1).ToString());
item.SubItems.Add(((Service)addServiceForm.listViewObjectsServices.Items[i].Tag).Name);
item.SubItems.Add(((Service)addServiceForm.listViewObjectsServices.Items[i].Tag).SummaryCost.ToString());
item.SubItems.Add(((Service)addServiceForm.listViewObjectsServices.Items[i].Tag).Count.ToString());
item.Tag = addServiceForm.listViewObjectsServices.Items[i].Tag;
listViewServices.Items.Add(item);
listViewServices.Refresh();
}
addServiceForm.Close();
addServiceTimer.Stop();
}
}
}
private void buttonAddConfiguration_Click(object sender, EventArgs e)
{
addConfigurationForm = new AddConfigurationForm();
addConfigurationTimer.Start();
sqlOperation.GetConnection(source);
var configurationCategory = sqlOperation.GetConfiguration( source);
addConfigurationForm.Visible = true;
addConfigurationForm.listViewObjectsConfigurations.Items.Clear();
addConfigurationForm.categoryConfiguration = configurationCategory;
foreach (var listConfiguration in configurationCategory.Values)
{
foreach (var configuration in listConfiguration)
{
var item = new ListViewItem((addConfigurationForm.listViewFindObjects.Items.Count + 1).ToString());
item.SubItems.Add(configuration.Name);
item.SubItems.Add(configuration.PriceWithMargin.ToString());
item.Tag = configuration;
addConfigurationForm.listViewFindObjects.Items.Add(item);
addConfigurationForm.listViewFindObjects.Refresh();
}
}
foreach (var category in configurationCategory.Keys)
{
addConfigurationForm.comboBoxCategory.Items.Add(category);
}
if (listViewConfiguration.Items.Count > 0)
foreach (ListViewItem item in listViewConfiguration.Items)
{
var itx = new ListViewItem((addConfigurationForm.listViewObjectsConfigurations.Items.Count + 1).ToString());
itx.SubItems.Add(((Configuration)item.Tag).Name);
itx.SubItems.Add(((Configuration)item.Tag).SummaryCost.ToString());
itx.SubItems.Add(((Configuration)item.Tag).Count.ToString());
itx.Tag = (Configuration)item.Tag;
addConfigurationForm.listViewObjectsConfigurations.Items.Add(itx);
}
}
private void addConfigurationTimer_Tick(object sender, EventArgs e)
{
if (addConfigurationForm != null)
{
if (addConfigurationForm.addConfiguration && !addConfigurationForm.Visible)
{
addConfigurationForm.addConfiguration = false;
listViewConfiguration.Items.Clear();
for (int i = 0; i < addConfigurationForm.listViewObjectsConfigurations.Items.Count; i++)
{
var item = new ListViewItem((listViewConfiguration.Items.Count + 1).ToString());
item.SubItems.Add(((Configuration)addConfigurationForm.listViewObjectsConfigurations.Items[i].Tag).Name);
item.SubItems.Add(((Configuration)addConfigurationForm.listViewObjectsConfigurations.Items[i].Tag).SummaryCost.ToString());
item.SubItems.Add(((Configuration)addConfigurationForm.listViewObjectsConfigurations.Items[i].Tag).Count.ToString());
item.Tag = addConfigurationForm.listViewObjectsConfigurations.Items[i].Tag;
listViewConfiguration.Items.Add(item);
listViewConfiguration.Refresh();
}
addConfigurationForm.Close();
addConfigurationTimer.Stop();
}
}
}
private void buttonCalculateCost_Click(object sender, EventArgs e)
{
double summaryCost = 0;
if (listViewConfiguration.Items.Count > 0)
foreach (ListViewItem item in listViewConfiguration.Items)
{
summaryCost += ((Configuration)item.Tag).SummaryCost;
}
else
{
MessageBox.Show("Не задана комплектация", "Некорректная сумма", MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
if (listViewServices.Items.Count > 0)
foreach (ListViewItem item in listViewServices.Items)
{
summaryCost += ((Service)item.Tag).SummaryCost;
}
else
{
MessageBox.Show("Не заданы услуги", "Некорректная сумма", MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
textBoxSummaryCost.Text = summaryCost.ToString();
}
private void buttonSelectCustomer_Click(object sender, EventArgs e)
{
addCustomerTimer.Start();
addCustomerForm = new AddCustomerForm();
addCustomerForm.source = source;
addCustomerForm.Visible = true;
}
private void MainForm_Load(object sender, EventArgs e)
{
Hide();
try
{
sqlOperation.CheckConnection(source);
}
catch (Exception)
{
selectDBForm = new AuthorizationAndSelectDBForm();
selectDBForm.Visible = true;
timerSelectDB.Start();
MessageBox.Show("Не удалось подключиться к БД. Введите имя другой БД", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
Show();
this.Visible = true;
if (admin)
операцииToolStripMenuItem.Visible = true;
else
операцииToolStripMenuItem.Visible = false;
var customers = sqlOperation.GetCustomer(source);
foreach(var customer in customers)
{
comboBoxCustomer.Items.Add(customer.Surname.Trim() +" "+ customer.Name.Trim() + " "+customer.Patronomyc.Trim());
comboBoxCustomer.Tag = customers;
}
var placeWorks = sqlOperation.GetPlaceWork( source);
foreach (var placeWork in placeWorks)
{
comboBoxObject.Items.Add(placeWork.Address.Trim());
comboBoxObject.Tag = placeWorks;
}
textBoxNumberOrder.Text = sqlOperation.IncrementNumberOrder( source).ToString();
}
private void addCustomerTimer_Tick(object sender, EventArgs e)
{
if (addCustomerForm != null)
{
if (addCustomerForm.addCustomer && !addCustomerForm.Visible)
{
addCustomerForm.addCustomer = false;
comboBoxCustomer.Items.Clear();
var customers = sqlOperation.GetCustomer( source);
for (int i = 0; i < customers.Count; i++)
{
comboBoxCustomer.Items.Add(customers[i].Surname.Trim() + " " + customers[i].Name.Trim() + " " +
customers[i].Patronomyc.Trim());
}
comboBoxCustomer.Text = addCustomerForm.customer.Surname.Trim() + " " + addCustomerForm.customer.Name.Trim() + " " + addCustomerForm.customer.Patronomyc;
order.IdCustomer = addCustomerForm.customer.Id;
order.customer = addCustomerForm.customer;
addCustomerForm.Close();
addCustomerTimer.Stop();
}
}
}
private void buttonSelectObject_Click(object sender, EventArgs e)
{
addObjectTimer.Start();
addObjectForm = new AddObjectForm();
addObjectForm.source = source;
addObjectForm.Visible = true;
}
private void addObjectTimer_Tick(object sender, EventArgs e)
{
if (addObjectForm != null)
{
if (addObjectForm.addPlaceWork && !addObjectForm.Visible)
{
addObjectForm.addPlaceWork = false;
comboBoxObject.Items.Clear();
var placeWorks = sqlOperation.GetPlaceWork(source);
for (int i = 0; i < placeWorks.Count; i++)
{
comboBoxObject.Items.Add(placeWorks[i].Address.Trim());
}
comboBoxObject.Text = addObjectForm.placeWork.Address.Trim();
order.IdObjectInstallation = addObjectForm.placeWork.Id;
order.placeWork = addObjectForm.placeWork;
addObjectForm.Close();
addObjectTimer.Stop();
}
}
}
private void comboBoxCustomer_SelectedIndexChanged(object sender, EventArgs e)
{
foreach (Customer cust in (List<Customer>)comboBoxCustomer.Tag)
{
if ((cust.Surname.Trim() + " " + cust.Name.Trim() + " " + cust.Patronomyc) == comboBoxCustomer.Text)
{
order.IdCustomer = cust.Id;
order.customer = cust;
}
}
}
private void comboBoxObject_SelectedIndexChanged(object sender, EventArgs e)
{
foreach (PlaceWork placeWork in (List<PlaceWork>)comboBoxObject.Tag)
{
if ((placeWork.Address.Trim() == comboBoxObject.Text))
{
order.IdObjectInstallation = placeWork.Id;
order.placeWork = placeWork;
}
}
}
private void ToolStripMenuItemClose_Click(object sender, EventArgs e)
{
this.Close();
}
private void ToolStripMenuItemNewOrder_Click(object sender, EventArgs e)
{
textBoxAdvancePayment.Text = string.Empty;
textBoxNumberOrder.Text = sqlOperation.IncrementNumberOrder(source).ToString();
textBoxSummaryCost.Text = string.Empty;
textBoxTermPerfomance.Text = string.Empty;
comboBoxCustomer.Text = string.Empty;
comboBoxObject.Text = string.Empty;
comboBoxPaymentKind.Text = string.Empty;
listViewServices.Items.Clear();
listViewEmployees.Items.Clear();
listViewConfiguration.Items.Clear();
checkBoxOrderPaid.CheckState = CheckState.Unchecked;
}
private void ToolStripMenuItemFindOrder_Click(object sender, EventArgs e)
{
findOrderForm = new FindOrderForm();
findOrderForm.source = source;
findOrderForm.Visible = true;
}
private void toolStripTextBox1_Click(object sender, EventArgs e)
{
}
private void toolStripMenuItem2_Click(object sender, EventArgs e)
{
timerSelectDB.Start();
selectDBForm = new AuthorizationAndSelectDBForm();
selectDBForm.Visible = true;
}
private void timerSelectDB_Tick(object sender, EventArgs e)
{
if (selectDBForm != null)
{
if (selectDBForm.selectDB && !selectDBForm.Visible)
{
Show();
source = selectDBForm.textBoxSelectDB.Text.Trim();
var customers = sqlOperation.GetCustomer(source);
foreach (var customer in customers)
{
comboBoxCustomer.Items.Add(customer.Surname.Trim() + " " + customer.Name.Trim() + " " +
customer.Patronomyc.Trim());
comboBoxCustomer.Tag = customers;
}
var placeWorks = sqlOperation.GetPlaceWork(source);
foreach (var placeWork in placeWorks)
{
comboBoxObject.Items.Add(placeWork.Address.Trim());
comboBoxObject.Tag = placeWorks;
}
textBoxNumberOrder.Text = sqlOperation.IncrementNumberOrder(source).ToString();
timerSelectDB.Stop();
this.Visible = true;
}
}
}
private InsertSupplierForm insertSupplierForm;
private void добавитьПоставщикаToolStripMenuItem_Click(object sender, EventArgs e)
{
insertSupplierForm = new InsertSupplierForm();
timerInsertSupliers.Start();
insertSupplierForm.source = source;
insertSupplierForm.Visible = true;
}
private void timerInsertSupliers_Tick(object sender, EventArgs e)
{
if (insertSupplierForm != null)
{
if (insertSupplierForm.insertSupplier && !insertSupplierForm.Visible)
{
insertSupplierForm.Close();
timerInsertSupliers.Stop();
}
}
}
private InsertConfigurationForm insertConfigurationForm;
private void добавитьКомплектациюToolStripMenuItem_Click(object sender, EventArgs e)
{
insertConfigurationForm = new InsertConfigurationForm();
timerInsertConfiguration.Start();
insertConfigurationForm.source = source;
insertConfigurationForm.Visible = true;
var configurationCategory = sqlOperation.GetConfiguration(source);
foreach (var category in configurationCategory.Keys)
{
insertConfigurationForm.comboBoxCategory.Items.Add(category);
}
var configurationSuppliers = sqlOperation.GetSuppliers(source);
foreach (var sup in configurationSuppliers)
{
insertConfigurationForm.comboBoxSuppliers.Items.Add(sup.Id +"."+sup.Name);
}
}
private void timerInsertConfiguration_Tick(object sender, EventArgs e)
{
if (insertConfigurationForm != null)
{
if (insertConfigurationForm.insertConfiguration && !insertConfigurationForm.Visible)
{
insertConfigurationForm.Close();
timerInsertConfiguration.Stop();
}
}
}
private InsertServiceForm insertServiceForm;
private void добавитьУслугуToolStripMenuItem_Click(object sender, EventArgs e)
{
insertServiceForm = new InsertServiceForm();
insertServiceForm.source = source;
insertServiceForm.Visible = true;
var cserviceCategory = sqlOperation.GetServices(source);
foreach (var category in cserviceCategory.Keys)
{
insertServiceForm.comboBoxCategory.Items.Add(category);
}
}
public InsertEmployeeForm insertEmployeeForm;
private void добавитьСотрудникаToolStripMenuItem_Click(object sender, EventArgs e)
{
insertEmployeeForm = new InsertEmployeeForm();
insertEmployeeForm.source = source;
insertEmployeeForm.Visible = true;
}
}
}
Размещено на Allbest.ru
Подобные документы
Разработка автоматизированной информационной системы "Стол заказов" для учета регистрации заказов и информации о клиентах, ответственных лицах и товарах. Характеристики комплекса задач. Проект базы данных, построение логической и физической моделей.
курсовая работа [354,9 K], добавлен 18.12.2014Создание автоматизированной системы учета заказов и их выполнения в строительной фирме по ремонту квартир. Общие требования к информационной системе. Проектирование структуры базы данных. Построение ER-диаграммы. Реализация информационной системы.
курсовая работа [750,2 K], добавлен 24.03.2014Инфологическая модель задачи автоматизации и формирования заказов поставщикам, контроля состояния склада. Анализ ключей сущностей проектируемой базы данных, разработка и нормализация системы таблиц и форм. Механизм оформления заказов в базе данных.
курсовая работа [358,5 K], добавлен 26.11.2012Проектирование информационной системы. Описание бизнес-процесса работы ООО "Сервис-ТВ". Правила работы с автоматизированными информационными системами. Построение базы данных в среде OpenOffice. Методика расчета оценки экономической эффективности.
курсовая работа [3,4 M], добавлен 22.11.2012Требования к системе проектирования информационной системы финансового контроля. Информационное, программное и техническое обеспечение автоматизированной системы. Алгоритмы и модели работы базы данных, созданной в среде разработки Borland Delphi 7.0.
дипломная работа [1,2 M], добавлен 25.10.2013Выбор методологии проектирования и разработка информационной системы "Расчёт зарплаты" для предприятия ОАО РТП "Авторемонтник". Архитектурное проектирование базы данных информационной системы и разработка её интерфейса. Тестирование программного модуля.
дипломная работа [2,3 M], добавлен 25.05.2014Принципы проектирования базы данных. Разработка автоматизированной информационной системы для учета материалов хранящихся на складах, их движения по складам, контроля прихода, расхода и остатков материалов, а так же для выявления потребности в их закупке.
отчет по практике [4,9 M], добавлен 03.02.2013Разработка программного обеспечения для автоматизации процесса учета поступления и формирования заказов. Построение реляционной базы данных средствами Microsoft Access. Методы повышения эффективности организации информационных потоков на предприятии.
дипломная работа [1,9 M], добавлен 02.12.2012Создание информационной системы, предназначенной для оформления заказов на изготовление моделей и учет продажи готовых деталей. Составление запросов, реализуемых средствами системы управления базами банных MySQL. Разработка таблиц и схемы базы данных.
контрольная работа [1,4 M], добавлен 05.01.2013Разработка требований к программному обеспечению отдела воинского учета, методология проектирования информационной системы. Реализация и аттестация информационной системы, взаимодействие приложения с источниками данных, его экономическая эффективность.
дипломная работа [1,3 M], добавлен 30.11.2010