Диплом: Автоматизация управления процессом отгрузки товара в ИП «Диденков А.Н.»

Внимание! Если размещение файла нарушает Ваши авторские права, то обязательно сообщите нам
117
InitializeComponent();
}
private void buttonGoReport_Click(object sender, EventArgs e)
{
this.движенияТоваровTableAdapter.Fill(this.dbstorageDataSet.ДвиженияТоваров,
dateTimePickerBegin.Value, dateTimePickerEnd.Value);
ReportParameter p1 = new ReportParameter("ReportParameterTimeBegin",
dateTimePickerBegin.Value.ToString());
ReportParameter p2 = new ReportParameter("ReportParameterTimeEnd",
dateTimePickerEnd.Value.ToString());
reportViewer1.LocalReport.SetParameters(new ReportParameter[] { p1, p2
});
this.reportViewer1.RefreshReport();
}
}
}
DocLog.cs
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;
namespace Storage.Forms.Docs
{
public partial class DocLog : Form
{
private DateTime TimeintervalBegin = DateTime.MinValue;
private DateTime TimeintervalEnd = DateTime.MaxValue;
public DocLog()
{
InitializeComponent();
}
//=========================================
// Свойства
//=========================================
//=========================================
// Методы
//=========================================
// Обновить список документов
private void ViewDocs()
{
// Запомнить документ на котором находится курсор
int idDoc = GetId();
// Обновить журнал
DateTime sqlTimeintervalBegin = TimeintervalBegin;
if (sqlTimeintervalBegin == DateTime.MinValue) sqlTimeintervalBegin =
new DateTime(1753, 1, 1, 12, 00, 00);
this.журналДокументовСписокTableAdapter.Fill(this.dbstorageDataSet.ЖурналДокументовС
писок, sqlTimeintervalBegin, TimeintervalEnd);
// Поместить курсор в строку
int itemFound = журналДокументовСписокBindingSource.Find("Код", idDoc);
журналДокументовСписокBindingSource.Position = itemFound;
}
// Показать табличную часть
private void ViewDocTable()
{
BindingSource bindingSource = журналДокументовСписокBindingSource;
118
if (bindingSource.Current != null)
{
int id =
Convert.ToInt32(((DataRowView)bindingSource.Current).Row["Код"]);
this.документТаблЧастьTableAdapter.Fill(this.dbstorageDataSet.ДокументТаблЧасть,
id);
}
}
// Открыть документ на редактирование
private void EditDoc()
{
int typeDoc = GetTypeDoc();
int idDoc = GetId();
switch (typeDoc)
{
case 2:// Приходная накладная
DocPN frmPN = new DocPN(idDoc);
frmPN.ShowDialog();
if (frmPN.DialogResult == DialogResult.OK)
{
ViewDocs();
}
break;
case 3:// Возвратная накладная
DocVN frmVN = new DocVN(idDoc);
frmVN.ShowDialog();
if (frmVN.DialogResult == DialogResult.OK)
{
ViewDocs();
}
break;
case 4:// Заказ
DocZK frmZK = new DocZK(idDoc);
frmZK.ShowDialog();
if (frmZK.DialogResult == DialogResult.OK)
{
ViewDocs();
}
break;
case 5:// Расходная накладная
DocRN frmRN = new DocRN(idDoc);
frmRN.ShowDialog();
if (frmRN.DialogResult == DialogResult.OK)
{
ViewDocs();
}
break;
case 6:// Заказ поставщику
DocZKP frmZKP = new DocZKP(idDoc);
frmZKP.ShowDialog();
if (frmZKP.DialogResult == DialogResult.OK)
{
ViewDocs();
}
break;
}
}
// Провести выделенный документ
private void AcceptDoc()
{
int idDoc = GetId();
if (DBControl.execДокументПровести(idDoc) > 0)
{
ViewDocs();
119
}
else
{
MessageBox.Show("Невозможно провести документ!");
}
}
// Отключить проводки текущему документу
private void UnAcceptDoc()
{
int idDoc = GetId();
DBControl.execДокументОтключитьПроводки(idDoc);
ViewDocs();
}
// Удалить документ
private void DelDoc()
{
int idDoc = GetId();
DBControl.execДокументУдалить(idDoc);
ViewDocs();
}
// Получить тип текущего документа
private int GetTypeDoc()
{
BindingSource bindingSource = журналДокументовСписокBindingSource;
if (bindingSource.Current != null)
{
int id =
Convert.ToInt32(((DataRowView)bindingSource.Current).Row["Тип"]);
return id;
}
return -1;
}
// Вернуть код выбранного элемента
private int GetId()
{
BindingSource bindingSource = журналДокументовСписокBindingSource;
if (bindingSource.Current != null)
{
int id =
Convert.ToInt32(((DataRowView)bindingSource.Current).Row["Код"]);
return id;
}
return -1;
}
// Создание расходной накладной
private void CreateDocRN()
{
BindingSource bindingSource = журналДокументовСписокBindingSource;
int typeDoc =
Convert.ToInt32(((DataRowView)bindingSource.Current).Row["Тип"]);
int statusDoc =
Convert.ToInt32(((DataRowView)bindingSource.Current).Row["СтатусКод"]);
if (typeDoc != 4)
{
MessageBox.Show("Необходимо выбрать документ заказ для которого
создается расходная накладная!");
}
else if (statusDoc != 2)
{
MessageBox.Show("Чтобы создать расходную накладную, необходимо
провести документ-заказ");
}
else
{
DocRN frm = new DocRN();
120
int idBaseDoc = GetId();
frm.SetBaseDoc(idBaseDoc);
frm.ShowDialog();
if (frm.DialogResult == DialogResult.OK)
{
ViewDocs();
}
}
}
//=========================================
// События
//=========================================
private void toolStripButton1_Click(object sender, EventArgs e)
{
DocPN frm = new DocPN();
frm.ShowDialog();
if (frm.DialogResult == DialogResult.OK)
{
ViewDocs();
}
}
private void DocLog_Load(object sender, EventArgs e)
{
// TODO: данная строка кода позволяет загрузить данные в таблицу
"dbstorageDataSet.ЖурналДокументовСписок". При необходимости она может быть
перемещена или удалена.
//this.журналДокументовСписокTableAdapter.Fill(this.dbstorageDataSet.ЖурналДокументо
вСписок);
ViewDocs();
}
private void журналДокументовСписокBindingSource_PositionChanged(object
sender, EventArgs e)
{
ViewDocTable();
}
private void toolStripButtonEditDoc_Click(object sender, EventArgs e)
{
EditDoc();
}
private void toolStripButtonAcceptDoc_Click(object sender, EventArgs e)
{
AcceptDoc();
}
private void toolStripButtonUnAcceptDoc_Click(object sender, EventArgs e)
{
UnAcceptDoc();
}
private void toolStripButtonDelDoc_Click(object sender, EventArgs e)
{
DelDoc();
}
private void toolStripButtonTimeInterval_Click(object sender, EventArgs e)
{
DocLogTimeInterval frm = new DocLogTimeInterval(TimeintervalBegin,
TimeintervalEnd);
frm.ShowDialog();
if (frm.DialogResult == DialogResult.OK)
{
TimeintervalBegin = frm.TimeintervalBegin;
TimeintervalEnd = frm.TimeintervalEnd;
ViewDocs();
}
}
private void toolStripButtonAddVN_Click(object sender, EventArgs e)
121
{
DocVN frm = new DocVN();
frm.ShowDialog();
if (frm.DialogResult == DialogResult.OK)
{
ViewDocs();
}
}
private void toolStripButtonAddZakazPok_Click(object sender, EventArgs e)
{
DocZK frm = new DocZK();
frm.ShowDialog();
if (frm.DialogResult == DialogResult.OK)
{
ViewDocs();
}
}
private void toolStripButtonAddRN_Click(object sender, EventArgs e)
{
CreateDocRN();
}
private void toolStripButtonAddZakaz_Click(object sender, EventArgs e)
{
DocZKP frm = new DocZKP();
frm.ShowDialog();
if (frm.DialogResult == DialogResult.OK)
{
ViewDocs();
}
}
}
}
DocPN.cs
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 Storage.Forms.Spr;
namespace Storage.Forms.Docs
{
public partial class DocPN : Form
{
private const int TypeDoc = 2;
private int idDoc = -1;
private int idContragent = -1;
private int idStatusDoc = -1;
private int idBaseDoc = 0;
private List<String> delitems = new List<String>();
public DocPN()
{
InitializeComponent();
FillFields();
}
public DocPN(int id)
{
InitializeComponent();
idDoc = id;
FillFields(idDoc);
122
FillTableDoc(idDoc);
}
//=========================================
// Свойства
//=========================================
//=========================================
// Методы
//=========================================
// Заполнить поля для нового документа
private void FillFields()
{
// Номер документа
textBoxNDoc.Text = "Новый";
// Дата документа
dateTimePickerDocDate.Value = DateTime.Now;
// Статус
DataSet data = DBControl.execСтатусДокумента(-1);// Получить данные из
таблицы БД
foreach (DataRow row in data.Tables[0].Rows)
{
idStatusDoc = Convert.ToInt32(row["Код"]);
textBoxStatus.Text = Convert.ToString(row["Наименование"]);
}
}
// Заполнить поля для документа id
private void FillFields(int id)
{
// Получить реквизиты документа
DataSet data = DBControl.execДокументРеквизиты(id);
// Отобразить реквизиты документа
foreach (DataRow row in data.Tables[0].Rows)
{
textBoxNDoc.Text = Convert.ToString(row["НомерДок"]);
dateTimePickerDocDate.Value = Convert.ToDateTime(row["Дата"]);
textBoxStatus.Text = Convert.ToString(row["НаименованиеСтатус"]);
idStatusDoc = Convert.ToInt32(row["Статус"]);
textBoxContr.Text = Convert.ToString(row["НаименованиеКонтрагент"]);
idContragent = Convert.ToInt32(row["Контрагент"]);
textBoxComment.Text = Convert.ToString(row["Комментарий"]);
idBaseDoc = Convert.ToInt32(row["ДокОснование"]);
}
}
// Заполнить табличную часть
private void FillTableDoc(int id)
{
// Получить табличную часть документа
DataSet data = DBControl.execДокументТаблЧасть(id);
// Отобразить табличную часть документа
foreach (DataRow row in data.Tables[0].Rows)
{
// Получить данные из источника
String idtabl = Convert.ToString(row["Код"]);
String idgoods = Convert.ToString(row["КодТов"]);
String articul = Convert.ToString(row["Артикул"]);
String name = Convert.ToString(row["Наименование"]);
String cena = Convert.ToString(row["Цена"]);
String count = Convert.ToString(row["Колич"]);
//String sum = Convert.ToString(row["Сумма"]);
Double sum = Convert.ToDouble(row["Сумма"]);
// Отобразить в табличной части
DataGridViewCell cel1 = new DataGridViewTextBoxCell();//Код
DataGridViewCell cel2 = new DataGridViewTextBoxCell();//КодТов
DataGridViewCell cel3 = new DataGridViewTextBoxCell();//Артикул
DataGridViewCell cel4 = new DataGridViewTextBoxCell();//Наименование
123
DataGridViewCell cel5 = new DataGridViewTextBoxCell();//Цена
DataGridViewCell cel6 = new DataGridViewTextBoxCell();//Колич
DataGridViewCell cel7 = new DataGridViewTextBoxCell();//Сумма
cel1.Value = idtabl;
cel2.Value = idgoods;
cel3.Value = articul;
cel4.Value = name;
cel5.Value = cena;
cel6.Value = count;
cel7.Value = sum;
//cel5.Value = Y[i].ToString("F");
DataGridViewRow dgrow = new DataGridViewRow();
dgrow.Cells.AddRange(cel1, cel2, cel3, cel4, cel5, cel6, cel7);
dataGridViewTableDoc.Rows.Add(dgrow);
}
// Отобразить сумму документа
textBoxSum.Text = DBControl.execДокументСумма(id);
}
// Добавить строку в табличную часть
private void AddItemToTable(int id)
{
// Получить данные о товаре
DataSet data = DBControl.execТоварыТовар(id);
// Отобразить товар в табличной части
foreach (DataRow row in data.Tables[0].Rows)
{
// Получить данные из источника
String idtabl = "-1";
String idgoods = Convert.ToString(row["Код"]);
String articul = Convert.ToString(row["Артикул"]);
String name = Convert.ToString(row["Наименование"]);
String cena = Convert.ToString(row["Цена"]);
String count = "1";
String sum = Convert.ToString(row["Цена"]);
// Отобразить в табличной части
DataGridViewCell cel1 = new DataGridViewTextBoxCell();//Код
DataGridViewCell cel2 = new DataGridViewTextBoxCell();//КодТов
DataGridViewCell cel3 = new DataGridViewTextBoxCell();//Артикул
DataGridViewCell cel4 = new DataGridViewTextBoxCell();//Наименование
DataGridViewCell cel5 = new DataGridViewTextBoxCell();//Цена
DataGridViewCell cel6 = new DataGridViewTextBoxCell();//Колич
DataGridViewCell cel7 = new DataGridViewTextBoxCell();//Сумма
cel1.Value = idtabl;
cel2.Value = idgoods;
cel3.Value = articul;
cel4.Value = name;
cel5.Value = cena;
cel6.Value = count;
cel7.Value = sum;
//cel5.Value = Y[i].ToString("F");
DataGridViewRow dgrow = new DataGridViewRow();
dgrow.Cells.AddRange(cel1, cel2, cel3, cel4, cel5, cel6, cel7);
dataGridViewTableDoc.Rows.Add(dgrow);
}
}
// Удалить строку из табличной части
private void DelItemFromTable()
{
int nrow=dataGridViewTableDoc.SelectedCells[0].RowIndex;
String idstr = (String)dataGridViewTableDoc.Rows[nrow].Cells[0].Value;
if (idstr != "-1") delitems.Add(idstr);
dataGridViewTableDoc.Rows.RemoveAt(nrow);
}
// Перерасчет суммы документа
private void RecalcSumDoc()
124
{
Double sum = 0;
foreach (DataGridViewRow row in dataGridViewTableDoc.Rows)
{
Double sumrow = Convert.ToDouble(row.Cells[6].Value);
sum += sumrow;
}
textBoxSum.Text = sum.ToString("F");
}
// Проверка документа
private Boolean CheckDoc()
{
if (idContragent < 0)
{
MessageBox.Show("Не выбран контрагент!");
return false;
}
return true;
}
// Сохранить заголовочную часть
private void SaveTitleDoc()
{
DataTable dataTable = new DataTable();
dataTable.Columns.Add(new DataColumn("Код",
System.Type.GetType("System.Int32")));
dataTable.Columns.Add(new DataColumn("НомерДок",
System.Type.GetType("System.String")));
dataTable.Columns.Add(new DataColumn("Дата",
System.Type.GetType("System.DateTime")));
dataTable.Columns.Add(new DataColumn("Тип",
System.Type.GetType("System.Int32")));
dataTable.Columns.Add(new DataColumn("Контрагент",
System.Type.GetType("System.Int32")));
dataTable.Columns.Add(new DataColumn("Статус",
System.Type.GetType("System.Int32")));
dataTable.Columns.Add(new DataColumn("ДокОснование",
System.Type.GetType("System.Int32")));
dataTable.Columns.Add(new DataColumn("Комментарий",
System.Type.GetType("System.String")));
DataRow dataRow = dataTable.NewRow();
dataRow["Код"] = idDoc;
dataRow["НомерДок"] = textBoxNDoc.Text;
dataRow["Дата"] = dateTimePickerDocDate.Value;
dataRow["Тип"] = TypeDoc;
dataRow["Контрагент"] = idContragent;
dataRow["Статус"] = idStatusDoc;
dataRow["ДокОснование"] = idBaseDoc;
dataRow["Комментарий"] = textBoxComment.Text;
dataTable.Rows.Add(dataRow);
DataSet data = new DataSet();// Для данных заголовочной части
data.Tables.Add(dataTable);
idDoc = DBControl.execДокументЗаголовокСохранить(data);
if (idDoc < 0)
{
MessageBox.Show("Ошибка при сохранении документа!");
}
}
// Сохранить табличную часть
private void SaveTableDoc()
{
if (idDoc > 0)
{
DataTable dataTable = new DataTable();
dataTable.Columns.Add(new DataColumn("Код",
System.Type.GetType("System.String")));
125
dataTable.Columns.Add(new DataColumn("КодДок",
System.Type.GetType("System.String")));
dataTable.Columns.Add(new DataColumn("КодТов",
System.Type.GetType("System.String")));
dataTable.Columns.Add(new DataColumn("Колич",
System.Type.GetType("System.String")));
dataTable.Columns.Add(new DataColumn("Цена",
System.Type.GetType("System.String")));
foreach (DataGridViewRow row in dataGridViewTableDoc.Rows)
{
DataRow dataRow = dataTable.NewRow();
dataRow["Код"] = Convert.ToString(row.Cells[0].Value);
dataRow["КодДок"] = idDoc.ToString();
dataRow["КодТов"] = Convert.ToString(row.Cells[1].Value);
dataRow["Колич"] = Convert.ToString(row.Cells[5].Value);
dataRow["Цена"] = Convert.ToString(row.Cells[4].Value);
dataTable.Rows.Add(dataRow);
}
DataSet data = new DataSet();// Для данных заголовочной части
data.Tables.Add(dataTable);
DBControl.execДокументТаблицаСохранить(data);
DBControl.execДокументТаблицаУдалить(delitems);
}
}
// Сохранить документ
private void SaveDoc()
{
SaveTitleDoc();
SaveTableDoc();
}
//=========================================
// События
//=========================================
private void buttonSelectКонтрагент_Click(object sender, EventArgs e)
{
FormSprPartners frm = new FormSprPartners(true);
frm.ShowDialog();
if (frm.DialogResult == DialogResult.OK)
{
idContragent = frm.SelectId;
textBoxContr.Text = frm.SelectName;
}
}
private void toolStripButtonAdd_Click(object sender, EventArgs e)
{
FormSprGoods frm = new FormSprGoods(true);
frm.ShowDialog();
if (frm.DialogResult == DialogResult.OK)
{
AddItemToTable(frm.SelectId);
RecalcSumDoc();
}
}
private void toolStripButtonDel_Click(object sender, EventArgs e)
{
DelItemFromTable();
RecalcSumDoc();
}
private void dataGridViewTableDoc_CellValueChanged(object sender,
DataGridViewCellEventArgs e)
{
if ((e.ColumnIndex == 4 || e.ColumnIndex == 5) && (e.RowIndex >= 0))
{
126
Double cena =
Convert.ToDouble(dataGridViewTableDoc.Rows[e.RowIndex].Cells[4].Value);
Double count =
Convert.ToDouble(dataGridViewTableDoc.Rows[e.RowIndex].Cells[5].Value);
Double sum = cena * count;
dataGridViewTableDoc.Rows[e.RowIndex].Cells[6].Value =
sum.ToString("F");
RecalcSumDoc();
}
}
private void DocPN_FormClosing(object sender, FormClosingEventArgs e)
{
Boolean checkDoc = CheckDoc();
if ((DialogResult == DialogResult.OK) && !checkDoc) e.Cancel = true;
if ((DialogResult == DialogResult.OK) && checkDoc) SaveDoc();
}
}
}
DocVN.cs
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 Storage.Forms.Spr;
namespace Storage.Forms.Docs
{
public partial class DocVN : Form
{
private const int TypeDoc = 3;
private int idDoc = -1;
private int idContragent = -1;
private int idStatusDoc = -1;
private int idBaseDoc = 0;
private List<String> delitems = new List<String>();
public DocVN()
{
InitializeComponent();
FillFields();
}
public DocVN(int id)
{
InitializeComponent();
idDoc = id;
FillFields(idDoc);
FillTableDoc(idDoc);
}
//=========================================
// Свойства
//=========================================
//=========================================
// Методы
//=========================================
// Заполнить поля для нового документа
private void FillFields()
{
// Номер документа
textBoxNDoc.Text = "Новый";
// Дата документа

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

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