Дипломная работа: Автоматизация обработки заявок ООО «Пилснаб»

Внимание! Если размещение файла нарушает Ваши авторские права, то обязательно сообщите нам
101
Приложение. Листинги основных программных модулей
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using ERP2.GeneralClasses;
using ERP2.Modules.Proposal.Templates;
using DevExpress.XtraTab;
using ERP2.Util;
using ERP2.Modules.DocFlowBase;
using System.Transactions;
using ERP2.Modules.Proposal.Resources;
using System.IO;
using System.Reflection;
using Microsoft.Office.Interop.Excel;
using System.Globalization;
using System.Threading;
using DevExpress.XtraEditors.Controls;
using ERP2.Modules.Proposal.Material;
namespace ERP2.Modules.Proposal.MaterialWithoutStorage
{
public partial class WSMaterialsForm :
DevExpress.XtraEditors.XtraForm
{
#region GlobalVaribles
User currUser;
decimal propID;
int specificationID;
bool cloneFlag = false;
private bool _readonly;
public bool ReadOnly
{
get
{
return _readonly;
}
set
{
_readonly = value;
}
}
#endregion
#region Constructors
public WSMaterialsForm()
{
InitializeComponent();
dateEditDelivery.Properties.MinValue = DateTime.Today;
102
}
//NewDoc
public WSMaterialsForm(User user, int kindOfProposal) : this()
{
currUser = user;
this.specificationID = kindOfProposal;
ChangeTitle();
ChangeVisibleOfComponents(true);
LoadDataNewDoc();
NewDoc();
FillDocAndUserInfoControl();
pS_WS_MaterialsItemsBindingSource.Filter = "ProposalID = "
+ propID;
}
//EditDoc
public WSMaterialsForm(User user, decimal docID, int
kindOfProposal) : this()
{
propID = docID;
currUser = user;
this.specificationID = kindOfProposal;
ChangeTitle();
LoadData();
LoadCurrentData();
FillDocAndUserInfoControl();
pS_WS_MaterialsItemsBindingSource.Filter = "ProposalID = "
+ propID;
}
#endregion
#region CustomMethods
void LoadData()
{
this.rEF_UNITSTableAdapter.Fill(this.proposalDataSet.REF_UNITS);
this.pS_WS_REF_ProjectsTableAdapter.Fill(this.proposalDataSet.PS_WS_RE
F_Projects);
this.vW_PS_Proposal_EmployeesTableAdapter.Fill(this.proposalDataSet.VW
_PS_Proposal_Employees);
this.pS_WS_MaterialItemTableAdapter.FillByProcedure(this.proposalDataS
et.PS_WS_MaterialItem);
this.vW_PS_WS_MaterialsTableAdapter.Fill(this.proposalDataSet.VW_PS_WS
_Materials);
this.pS_WS_MaterialsItemsTableAdapter.Fill(this.proposalDataSet.PS_WS_
MaterialsItems);
this.pS_TM_OrderTableAdapter.Fill(this.proposalDataSet.PS_TM_Order);
this.pRODUCTS_TYPESTableAdapter.Fill(this.proposalDataSet.PRODUCTS_TYP
ES);
this.gOSTSTableAdapter.Fill(this.proposalDataSet.GOSTS);
103
this.fIRM_MANUFACTURERTableAdapter.Fill(this.proposalDataSet.FIRM_MANU
FACTURER);
}
void LoadDataNewDoc()
{
this.rEF_UNITSTableAdapter.Fill(this.proposalDataSet.REF_UNITS);
this.pS_WS_REF_ProjectsTableAdapter.Fill(this.proposalDataSet.PS_WS_RE
F_Projects);
this.vW_PS_Proposal_EmployeesTableAdapter.Fill(this.proposalDataSet.VW
_PS_Proposal_Employees);
this.pS_WS_MaterialItemTableAdapter.FillByProcedure(this.proposalDataS
et.PS_WS_MaterialItem);
this.vW_PS_WS_MaterialsTableAdapter.Fill(this.proposalDataSet.VW_PS_WS
_Materials);
this.pS_TM_OrderTableAdapter.Fill(this.proposalDataSet.PS_TM_Order);
this.pRODUCTS_TYPESTableAdapter.Fill(this.proposalDataSet.PRODUCTS_TYP
ES);
this.gOSTSTableAdapter.Fill(this.proposalDataSet.GOSTS);
this.fIRM_MANUFACTURERTableAdapter.Fill(this.proposalDataSet.FIRM_MANU
FACTURER);
}
void ChangeVisibleOfComponents(bool flag)
{
simpleButtonImportInfo.Visible = flag;
simpleButtonClone.Visible = flag;
xtraTabPage2.PageVisible = flag;
}
void LoadCurrentData()
{
var haveDocs =
DocFlowBaseManager.haveAttachedDocs(currUser,
MainManagerTemplate._docType, propID);
labelControlFileWarning.Visible = haveDocs;
pS_WS_MaterialsTableAdapter.FillByProposalID(proposalDataSet.PS_WS_Mat
erials, propID);
}
void FillDocAndUserInfoControl()
{
var myUserControl = new
DocAndUserInfoControlTemplate(currUser);
myUserControl.Dock = DockStyle.Fill;
xtraUserControlDocAndUserTemp.Controls.Add(myUserControl);
myUserControl.SetBindings(pSWSMaterialsBindingSource,
vW_PS_Proposal_EmployeesBindingSource,
GetEmployeerBindingSourcePosition());
}
104
int GetEmployeerBindingSourcePosition()
{
var row =
(ProposalDataSet.PS_WS_MaterialsRow)((DataRowView)pSWSMaterialsBinding
Source.Current).Row;
return vW_PS_Proposal_EmployeesBindingSource.Position =
vW_PS_Proposal_EmployeesBindingSource.Find("ID", (int)row.OwnerID); ;
}
void ChangeTitle()
{
if (specificationID == 2) this.Text =
WSMaterialFormRes.FormTitle;
}
void NewDoc()
{
try
{
var row =
(ProposalDataSet.PS_WS_MaterialsRow)((DataRowView)pSWSMaterialsBinding
Source.AddNew()).Row;
row.OwnerID = currUser.Id_employee;
row.DateOfCreation = DateTime.Now;
row.StatusID =
DocFlowBaseManager.getInitStatusID(currUser,
Material.MainManagerTemplate._docType);
row.ID = currUser.GetNewID("PS_WS_Materials");
row.DocNumber = (int)row.ID;
row.SpecificationID = specificationID;
propID = row.ID;
}
catch (Exception ex)
{
UIUtil.ShowErrorBox(UtilDictionary.DataLoadFailedFormat(ex.Message));
}
SetRegexOnGMIL();
}
void GetCloneMaterialItems(decimal clonePropID)
{
pS_WS_MaterialsItemsBindingSource.Filter = "ProposalID = "
+ clonePropID;
var mibs = pS_WS_MaterialsItemsBindingSource.List;
foreach (DataRowView refRow in mibs)
{
var rowM =
(ProposalDataSet.PS_WS_MaterialsItemsRow)(refRow).Row;
var rowMN =
(ProposalDataSet.PS_WS_MaterialsItemsRow)((DataRowView)pS_WS_Materials
ItemsBindingSource.AddNew()).Row;
rowMN.ID = currUser.GetNewID("PS_WS_MaterialsItems");
rowMN.MaterialItemID = rowM.MaterialItemID;
pSWSMaterialItemBindingSource.Position =
pSWSMaterialItemBindingSource.Find("ID", rowM.MaterialItemID);
105
var rowMI =
(ProposalDataSet.PS_WS_MaterialItemRow)((DataRowView)pSWSMaterialItemB
indingSource.Current).Row;
rowMI.UsingCount++;
rowMN.ProposalID = propID;
rowMN.UnitID = rowM.UnitID;
rowMN.Description = rowM.Description;
rowMN.DeliveredCount = 0;
rowMN.Count = rowM.Count;
}
pS_WS_MaterialsItemsBindingSource.EndEdit();
pS_WS_MaterialsItemsBindingSource.Filter = "ProposalID = "
+ propID;
}
public void ChangeVisibleAndEnabledProperties(bool[]
VisibleSections, bool[] EnabledSections)
{
if (VisibleSections[0])
{
xtraTabPage1.PageVisible = true;
}
if (VisibleSections[1])
{
xtraTabPage2.PageVisible = true;
}
if (VisibleSections[2])
{
simpleButtonImportInfo.Visible = true;
simpleButtonClone.Visible = true;
}
if (EnabledSections[0] == false || _readonly == true)
{
OrdersearchLookUpEdit.Properties.ReadOnly = true;
OrdersearchLookUpEdit.Properties.Buttons[1].Enabled =
false;
lookUpEditProjects.Properties.ReadOnly = true;
lookUpEditProjects.Properties.Buttons[1].Enabled =
false;
searchLookUpEditGmil.Properties.ReadOnly = true;
dateEditDelivery.Properties.ReadOnly = true;
gridControlMaterials.UseEmbeddedNavigator = false;
}
if (EnabledSections[1] == false || _readonly == true)
{
gridView2.OptionsBehavior.Editable = false;
}
if (EnabledSections[2] == false || _readonly == true)
{
simpleButtonImportInfo.Enabled = false;
simpleButtonClone.Enabled = false;
}
if (_readonly)
{
Источник: https://baza.diplomsite.ru/previewfile/1897