using System; using System.Linq; using DevExpress.Xpo; using DevExpress.Data.Filtering; using DevExpress.Persistent.Base; using System.Collections.Generic; using DevExpress.Persistent.BaseImpl; using System.IO; using System.Reflection; using Microsoft.VisualBasic.FileIO; using Nuvolar.Module.Controllers; using DevExpress.XtraReports.UI; using DevExpress.Xpo.DB; using Nuvolar.Module; using Microsoft.VisualBasic; using DevExpress.ExpressApp.Xpo; using System.Text.RegularExpressions; namespace Nuvolar.Module.BusinessObjects { [DefaultClassOptions,NavigationItem(false),CreatableItem(false),NonPersistent] public class NewCustomersFrom : BaseObject { public event EventHandler InitWork; public event EventHandler DoWork; public event EventHandler FinalWork; protected virtual void OnInitWork(WorkEventArgs e) { EventHandler handler= InitWork; if (handler != null) { handler(this, e); } } protected virtual void OnDoWork(WorkEventArgs e) { EventHandler handler = DoWork; if (handler != null) { handler(this, e); } } protected virtual void OnFinalWork(WorkEventArgs e) { EventHandler handler = FinalWork; if (handler != null) { handler(this, e); } } public NewCustomersFrom(Session session) : base(session) { } public NewCustomersFrom(CustomersFrom _customersFrom,Session session) : base(session) { CustomersFrom = _customersFrom; } public override void AfterConstruction() { base.AfterConstruction(); this.IsDemoProducts = false; this.IsDemoInvoice = false; this.Invoice_FromDate = new DateTime(2015, 01, 01); this.Invoice_ToDate = new DateTime(2015, 12, 31); this.Invoice_MinNumberPerDay = 10; this.Invoice_MaxNumberPerDay = 20; this.Invoice_MinNumberRow = 5; this.Invoice_MaxNumberRow = 30; this.OfferOut_FromDate = new DateTime(2015, 01, 01); this.OfferOut_ToDate = new DateTime(2015, 12, 31); this.OfferOut_MinNumberPerDay = 10; this.OfferOut_MaxNumberPerDay = 20; this.OfferOut_MinNumberRow = 5; this.OfferOut_MaxNumberRow = 30; } private CustomersFrom _CustomersFrom; private string _FullName; private string _CustomerNumber; private string _City; private string _ZipPostal; private string _Street; private string _StateProvince; private Country _Country; private string _Prefix; //A különböző sorszámok prefix tagja private string _Bank_ShortName; private string _Bank_AccountNumber; private string _Bank_IBAN; private string _Bank_SWIFT; private bool _IsDemoProducts; private bool _IsDemoProducts1; private bool _IsDemoProducts2; private bool _IsDemoProducts3; private bool _IsDemoCustomersOrder; private bool _IsDemoCustomers; private bool _IsDemoContacts; private bool _IsDemoInvoice; private DateTime _Invoice_FromDate; //Számla teljesítés kezdő dátuma private DateTime _Invoice_ToDate; // Számla teljesítés vég dátuma private int _Invoice_MinNumberPerDay; // ? darab naponta (minimum) private int _Invoice_MaxNumberPerDay; // ? darab naponta (maximum) private int _Invoice_MinNumberRow; // ? sor van egy számlán (minimum) private int _Invoice_MaxNumberRow; // ? sor van egy számlán (maximum) private bool _IsDemoOfferOut; private DateTime _OfferOut_FromDate; //Kimenő árajánlat teljesítés kezdő dátuma private DateTime _OfferOut_ToDate; // Kimenő árajánlat teljesítés vég dátuma private int _OfferOut_MinNumberPerDay; // ? darab naponta (minimum) private int _OfferOut_MaxNumberPerDay; // ? darab naponta (maximum) private int _OfferOut_MinNumberRow; // ? sor van egy számlán (minimum) private int _OfferOut_MaxNumberRow; // ? sor van egy számlán (maximum) private bool _IsDemoDeliveryNoteIn; private DateTime _DeliveryNoteIn_FromDate; //Bejövő szállítólevél teljesítés kezdő dátuma private DateTime _DeliveryNoteIn_ToDate; // Bejövő szállítólevél teljesítés vég dátuma private int _DeliveryNoteIn_MinNumberPerDay; // ? darab naponta (minimum) private int _DeliveryNoteIn_MaxNumberPerDay; // ? darab naponta (maximum) private int _DeliveryNoteIn_MinNumberRow; // ? sor van egy számlán (minimum) private int _DeliveryNoteIn_MaxNumberRow; // ? sor van egy számlán (maximum) public CustomersFrom CustomersFrom { get { return _CustomersFrom; } set { SetPropertyValue("CustomersFrom", ref _CustomersFrom, value); } } public string FullName { get { return _FullName; } set { SetPropertyValue("FullName", ref _FullName, value); } } public string CustomerNumber { get { return _CustomerNumber; } set { SetPropertyValue("CustomerNumber", ref _CustomerNumber, value); } } public string City { get { return _City; } set { SetPropertyValue("City", ref _City, value); } } public string ZipPostal { get { return _ZipPostal; } set { SetPropertyValue("ZipPostal", ref _ZipPostal, value); } } public Country Country { get { return _Country; } set { SetPropertyValue("Country", ref _Country, value); } } public string Prefix { get { return _Prefix; } set { SetPropertyValue("Prefix", ref _Prefix, value); } } public string StateProvince { get { return _StateProvince; } set { SetPropertyValue("StateProvince", ref _StateProvince, value); } } public string Street { get { return _Street; } set { SetPropertyValue("Street", ref _Street, value); } } public string Bank_ShortName { get { return _Bank_ShortName; } set { SetPropertyValue("Bank_ShortName", ref _Bank_ShortName, value); } } public string Bank_AccountNumber { get { return _Bank_AccountNumber; } set { SetPropertyValue("Bank_AccountNumber", ref _Bank_AccountNumber, value); } } public string Bank_IBAN { get { return _Bank_IBAN; } set { SetPropertyValue("Bank_IBAN", ref _Bank_IBAN, value); } } public string Bank_SWIFT { get { return _Bank_SWIFT; } set { SetPropertyValue("Bank_SWIFT", ref _Bank_SWIFT, value); } } public bool IsDemoProducts { get { return _IsDemoProducts; } set { SetPropertyValue("IsDemoProducts", ref _IsDemoProducts, value); } } public bool IsDemoProducts1 { get { return _IsDemoProducts1; } set { SetPropertyValue("IsDemoProducts1", ref _IsDemoProducts1, value); } } public bool IsDemoProducts2 { get { return _IsDemoProducts2; } set { SetPropertyValue("IsDemoProducts2", ref _IsDemoProducts2, value); } } public bool IsDemoProducts3 { get { return _IsDemoProducts3; } set { SetPropertyValue("IsDemoProducts3", ref _IsDemoProducts3, value); } } public bool IsDemoCustomersOrder { get { return _IsDemoCustomersOrder; } set { SetPropertyValue("IsDemoCustomersOrder", ref _IsDemoCustomersOrder, value); } } public bool IsDemoCustomers { get { return _IsDemoCustomers; } set { SetPropertyValue("IsDemoCustomers", ref _IsDemoCustomers, value); } } public bool IsDemoContacts { get { return _IsDemoContacts; } set { SetPropertyValue("IsDemoContacts", ref _IsDemoContacts, value); } } #region IsDemoInvoice properties public bool IsDemoInvoice { get { return _IsDemoInvoice; } set { SetPropertyValue("IsDemoInvoice", ref _IsDemoInvoice, value); } } public DateTime Invoice_FromDate { get { return _Invoice_FromDate; } set { SetPropertyValue("Invoice_FromDate", ref _Invoice_FromDate, value); } } public DateTime Invoice_ToDate { get { return _Invoice_ToDate; } set { SetPropertyValue("Invoice_ToDate", ref _Invoice_ToDate, value); } } public int Invoice_MinNumberPerDay { get { return _Invoice_MinNumberPerDay; } set { SetPropertyValue("Invoice_MinNumberPerDay", ref _Invoice_MinNumberPerDay, value); } } public int Invoice_MaxNumberPerDay { get { return _Invoice_MaxNumberPerDay; } set { SetPropertyValue("Invoice_MaxNumberPerDay", ref _Invoice_MaxNumberPerDay, value); } } public int Invoice_MinNumberRow { get { return _Invoice_MinNumberRow; } set { SetPropertyValue("Invoice_MinNumberRow", ref _Invoice_MinNumberRow, value); } } public int Invoice_MaxNumberRow { get { return _Invoice_MaxNumberRow; } set { SetPropertyValue("Invoice_MaxNumberRow", ref _Invoice_MaxNumberRow, value); } } #endregion #region IsDemoOfferOut properties public bool IsDemoOfferOut { get { return _IsDemoOfferOut; } set { SetPropertyValue("IsDemoOfferOut", ref _IsDemoOfferOut, value); } } public DateTime OfferOut_FromDate { get { return _OfferOut_FromDate; } set { SetPropertyValue("OfferOut_FromDate", ref _OfferOut_FromDate, value); } } public DateTime OfferOut_ToDate { get { return _OfferOut_ToDate; } set { SetPropertyValue("OfferOut_ToDate", ref _OfferOut_ToDate, value); } } public int OfferOut_MinNumberPerDay { get { return _OfferOut_MinNumberPerDay; } set { SetPropertyValue("OfferOut_MinNumberPerDay", ref _OfferOut_MinNumberPerDay, value); } } public int OfferOut_MaxNumberPerDay { get { return _OfferOut_MaxNumberPerDay; } set { SetPropertyValue("OfferOut_MaxNumberPerDay", ref _OfferOut_MaxNumberPerDay, value); } } public int OfferOut_MinNumberRow { get { return _OfferOut_MinNumberRow; } set { SetPropertyValue("OfferOut_MinNumberRow", ref _OfferOut_MinNumberRow, value); } } public int OfferOut_MaxNumberRow { get { return _OfferOut_MaxNumberRow; } set { SetPropertyValue("OfferOut_MaxNumberRow", ref _OfferOut_MaxNumberRow, value); } } #endregion #region IsDemoDeliveryNoteIn properties public bool IsDeliveryNoteIn { get { return _IsDemoDeliveryNoteIn; } set { SetPropertyValue("IsDemoDeliveryNoteIn", ref _IsDemoDeliveryNoteIn, value); } } public DateTime DeliveryNoteIn_FromDate { get { return _DeliveryNoteIn_FromDate; } set { SetPropertyValue("DeliveryNoteIn_FromDate", ref _DeliveryNoteIn_FromDate, value); } } public DateTime DeliveryNoteIn_ToDate { get { return _DeliveryNoteIn_ToDate; } set { SetPropertyValue("DeliveryNoteIn_ToDate", ref _DeliveryNoteIn_ToDate, value); } } public int DeliveryNoteIn_MinNumberPerDay { get { return _DeliveryNoteIn_MinNumberPerDay; } set { SetPropertyValue("DeliveryNoteIn_MinNumberPerDay", ref _DeliveryNoteIn_MinNumberPerDay, value); } } public int DeliveryNoteIn_MaxNumberPerDay { get { return _DeliveryNoteIn_MaxNumberPerDay; } set { SetPropertyValue("DeliveryNoteIn_MaxNumberPerDay", ref _DeliveryNoteIn_MaxNumberPerDay, value); } } public int DeliveryNoteIn_MinNumberRow { get { return _DeliveryNoteIn_MinNumberRow; } set { SetPropertyValue("DeliveryNoteIn_MinNumberRow", ref _DeliveryNoteIn_MinNumberRow, value); } } public int DeliveryNoteIn_MaxNumberRow { get { return _DeliveryNoteIn_MaxNumberRow; } set { SetPropertyValue("DeliveryNoteIn_MaxNumberRow", ref _DeliveryNoteIn_MaxNumberRow, value); } } #endregion public void AddNewCustomersFrom() { // Saját cég hozzáadása a következő módszer szerint // 1. Számlatükör beállítása, ha nincs // 2. Kontrollszámok generálása számlatükörből, ha nincs // 3. ÁFA kódok beállítása, ha nincs // 4. Mennyiségi egységek beállítása, ha nincs // 5. Partner főkönyvi kategória beállítása, ha nincs // 6. GIRO info felvitele CSV-ből // 7. Országok beállítása CSV-ből // 8. Saját cég felvitele // 9. Folyamatmenedzsment beállítása, ha nincs // 10. Iktatási tipusok beállítása, ha nincs // 11. Nyomtatványok betöltése // 12. Pénztár, bank , kompenzáció, vegyes sorszámok és paraméterek // 13. Kimenő számla tipus beállítása, ha nincs // 14. Raktári mozgási paraméterek, raktárak beállítása // 15. Árajánlat paraméter beállítások // 16. Bejövő megrendelés paraméter beállítások // 17. Bejövő szállítólevél paraméterek beállítása // 18. Kimenő szállítólevél paraméterek beállítása // 19. Fizetési opciók // 20. VTSZ számok // 21. PDA kollekció paraméterek // 22. Munkalap típusok generálása // 23. ZIP HU kódok beállítása CSV. // 24. Személyzeti törzs felvitele GenerateZIPHU(); GenerateNames(); GenerateVTSZ(); GenerateChartOfAccounts(); // 1. GenerateControlling(); // 2. GenerateVAT(); // 3. GenerateUnits(); // 4. GenerateCustomersGLParameters(); // 5. GenerateGIROInfo(); // 6. GenerateCountry(); // 7. GenerateCustomersFrom(); // 8. GenerateWorkflowSystem(); // 9. GenerateRegistryType(); // 10. GenerateReports(); // 11. GenerateReportsV2(); // 11. GenerateBankCassaCompensation(); // 12. GenerateInvoiceType(); // 13. //GenerateStorage(); // 14. //GenerateOfferOut(); // 15. //GenerateDeliveryNoteOut(); //18. //GenerateDeliveryNoteIn(); // 17. //GenerateOrderIn(); //16. //GeretatePaymentOptions(); // 19. //GeneratePDAParameters(); //GenerateWorkSheet(); //GenerateHRPerson(); ////---------------- DEMO adatok készítése ------ } public void GenerateDEMOData(XPObjectSpace _onew) { GenerateDEMOProducts(); GenerateDEMOProducts1(); GenerateDEMOProducts2(); GenerateDEMOProducts3(); GenerateDEMOCustomers(); GenerateDEMOCustomersOrder(); if (this.IsDemoContacts) { GenerateDEMOContacts(); } if (this.IsDemoInvoice) { GenerateDEMOSimpleInvoice(_onew); } if (this.IsDemoOfferOut) { GenerateDEMOSOfferOut(_onew); } if (this._IsDemoDeliveryNoteIn) { GenerateDEMODeliveryNoteIn(_onew); } } // DEMO adatok generálása ----------------------------- #region DEMO DATA private void GenerateDEMOProducts3() { if (this.IsDemoProducts3) { VAT _VAT0 = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='0 %'")); VAT _VAT5 = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='5 %'")); VAT _VAT18 = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='18 %'")); VAT _VAT27 = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='27 %'")); Units _U_CS = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='CS'")); Units _U_DB = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='DB'")); Units _U_DOB = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='DOB'")); Units _U_GARN = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='GARN'")); Units _U_KART = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='KART'")); Units _U_KG = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='KG'")); Units _U_KLT = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='KLT'")); Units _U_LIT = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='LIT'")); Units _U_REK = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='REK'")); Units _U_TÁL = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='TÁL'")); Units _U_TAS = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='TAS'")); Units _U_TEK = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='TEK'")); Units _U_TME = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='TME'")); Units _U_VÖD = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='VÖD'")); int _Limit = 12334;//165015 StreamReader _textStreamReader; string _StrBuffer; Assembly _assembly = Assembly.GetExecutingAssembly(); _textStreamReader = new StreamReader(_assembly.GetManifestResourceStream("Nuvolar.Module.CSV.Products3.csv"), System.Text.Encoding.Default); _StrBuffer = _textStreamReader.ReadToEnd(); using (TextFieldParser parser = new TextFieldParser(new StringReader(_StrBuffer))) { parser.TextFieldType = Microsoft.VisualBasic.FileIO.FieldType.Delimited; parser.SetDelimiters(";"); WorkEventArgs _WorkEventArgs = new WorkEventArgs { Count = _Limit, CurrentValue = 1, Message = "Terméktörzs generálása" }; OnInitWork(_WorkEventArgs); int i = 0; while (!parser.EndOfData) { i++; if (i > _Limit) { break; } try { string[] columns = parser.ReadFields(); ProductsGroups _ProductsGroupsMain = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("Name=?", columns[8])); if (_ProductsGroupsMain == null) { _ProductsGroupsMain = new ProductsGroups(Session); } _ProductsGroupsMain.ShortName = columns[8]; _ProductsGroupsMain.Name = columns[8]; _ProductsGroupsMain.Description = columns[8]; ProductsGroups _ProductsGroups = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("Name=?", columns[9])); if (_ProductsGroups == null) { _ProductsGroups = new ProductsGroups(Session); } _ProductsGroups.ShortName = columns[9]; _ProductsGroups.Name = columns[9]; _ProductsGroups.Parent = _ProductsGroupsMain; _ProductsGroups.Description = columns[9]; Products _Products = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ProductNumber=?", columns[0])); if (_Products == null) { _Products = new Products(Session); } _Products.ProductNumber = columns[0]; _Products.ShortName = columns[4]; _Products.ListPriceOutHUF = double.Parse(columns[5]); _Products.ProductGroups = _ProductsGroups; switch (columns[6].Trim()) { case "CS": _Products.Units = _U_CS; break; case "DB": _Products.Units = _U_DB; break; case "DOB": _Products.Units = _U_DOB; break; case "GARN": _Products.Units = _U_GARN; break; case "KART": _Products.Units = _U_KART; break; case "KG": _Products.Units = _U_KG; break; case "KLT": _Products.Units = _U_KLT; break; case "LIT": _Products.Units = _U_LIT; break; case "REK": _Products.Units = _U_REK; break; case "TÁL": _Products.Units = _U_TÁL; break; case "TAS": _Products.Units = _U_TAS; break; case "TEK": _Products.Units = _U_TEK; break; case "TME": _Products.Units = _U_TME; break; case "VÖD": _Products.Units = _U_VÖD; break; default: _Products.Units = _U_DB; break; } switch (columns[7]) { case "0,18": _Products.VAT = _VAT18; break; case "0,27": _Products.VAT = _VAT27; break; case "0,05": _Products.VAT = _VAT5; break; default: _Products.VAT = _VAT0; break; } if (columns[1] == "") { string _Barcode = GeneralFunction.AlignStr(i.ToString(), GeneralFunction.eDirection.Left, "0", 5); _Barcode = "5991019" + _Barcode; _Barcode = GeneralFunction.EAN13Generator(_Barcode); ProductsBarcodes _ProductsBarcodes = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("Products.ProductNumber=? and Barcode=? and BarcodeType='EAN'", _Products.ProductNumber, _Barcode)); if (_ProductsBarcodes == null) { _ProductsBarcodes = new ProductsBarcodes(Session); } _ProductsBarcodes.Products = _Products; _ProductsBarcodes.Barcode = _Barcode; _ProductsBarcodes.BarcodeType = "EAN"; _ProductsBarcodes.Multiplier = 1; } _WorkEventArgs.CurrentValue += 1; OnDoWork(_WorkEventArgs); } catch (Exception) { //throw; } } OnFinalWork(_WorkEventArgs); } } this.LoadProducts2Pictures(); this.LoadLocations(); } private void GenerateDEMOProducts2() { if (this.IsDemoProducts2) { VAT _VAT0 = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='0 %'")); VAT _VAT5 = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='5 %'")); VAT _VAT18 = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='18 %'")); VAT _VAT27 = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='27 %'")); Units _U_CS = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='CS'")); Units _U_DB = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='DB'")); Units _U_DOB = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='DOB'")); Units _U_GARN = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='GARN'")); Units _U_KART = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='KART'")); Units _U_KG = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='KG'")); Units _U_KLT = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='KLT'")); Units _U_LIT = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='LIT'")); Units _U_REK = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='REK'")); Units _U_TÁL = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='TÁL'")); Units _U_TAS = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='TAS'")); Units _U_TEK = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='TEK'")); Units _U_TME = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='TME'")); Units _U_VÖD = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='VÖD'")); int _Limit = 37;//165015 StreamReader _textStreamReader; string _StrBuffer; Assembly _assembly = Assembly.GetExecutingAssembly(); _textStreamReader = new StreamReader(_assembly.GetManifestResourceStream("Nuvolar.Module.CSV.Products2.csv"), System.Text.Encoding.Default); _StrBuffer = _textStreamReader.ReadToEnd(); using (TextFieldParser parser = new TextFieldParser(new StringReader(_StrBuffer))) { parser.TextFieldType = Microsoft.VisualBasic.FileIO.FieldType.Delimited; parser.SetDelimiters(";"); WorkEventArgs _WorkEventArgs = new WorkEventArgs { Count = _Limit, CurrentValue = 1, Message = "Terméktörzs generálása" }; OnInitWork(_WorkEventArgs); int i = 0; while (!parser.EndOfData) { i++; if (i > _Limit) { break; } try { string[] columns = parser.ReadFields(); ProductsGroups _ProductsGroupsMain2 = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("Name=?", columns[8])); if (_ProductsGroupsMain2 == null) { _ProductsGroupsMain2 = new ProductsGroups(Session); } _ProductsGroupsMain2.ShortName = columns[8]; _ProductsGroupsMain2.Name = columns[8]; _ProductsGroupsMain2.Parent = null; _ProductsGroupsMain2.Description = columns[8]; ProductsGroups _ProductsGroupsMain = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("Name=?", columns[9])); if (_ProductsGroupsMain == null) { _ProductsGroupsMain = new ProductsGroups(Session); } _ProductsGroupsMain.ShortName = columns[9]; _ProductsGroupsMain.Name = columns[9]; _ProductsGroupsMain.Parent = _ProductsGroupsMain2; _ProductsGroupsMain.Description = columns[9]; ProductsGroups _ProductsGroups = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("Name=?", columns[10])); if (_ProductsGroups == null) { _ProductsGroups = new ProductsGroups(Session); } _ProductsGroups.ShortName = columns[10]; _ProductsGroups.Name = columns[10]; _ProductsGroups.Parent = _ProductsGroupsMain; _ProductsGroups.Description = columns[10]; Products _Products = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ProductNumber=?", columns[0])); if (_Products == null) { _Products = new Products(Session); } _Products.ProductNumber = columns[0]; _Products.ShortName = columns[4]; _Products.ListPriceOutHUF = double.Parse(columns[5]); _Products.ProductGroups = _ProductsGroups; switch (columns[6].Trim()) { case "CS": _Products.Units = _U_CS; break; case "DB": _Products.Units = _U_DB; break; case "DOB": _Products.Units = _U_DOB; break; case "GARN": _Products.Units = _U_GARN; break; case "KART": _Products.Units = _U_KART; break; case "KG": _Products.Units = _U_KG; break; case "KLT": _Products.Units = _U_KLT; break; case "LIT": _Products.Units = _U_LIT; break; case "REK": _Products.Units = _U_REK; break; case "TÁL": _Products.Units = _U_TÁL; break; case "TAS": _Products.Units = _U_TAS; break; case "TEK": _Products.Units = _U_TEK; break; case "TME": _Products.Units = _U_TME; break; case "VÖD": _Products.Units = _U_VÖD; break; default: _Products.Units = _U_DB; break; } switch (columns[7]) { case "0,18": _Products.VAT = _VAT18; break; case "0,27": _Products.VAT = _VAT27; break; case "0,05": _Products.VAT = _VAT5; break; default: _Products.VAT = _VAT0; break; } if (columns[1] != "") { ProductsBarcodes _ProductsBarcodes = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("Products.ProductNumber=? and Barcode=? and BarcodeType='EAN'", _Products.ProductNumber, columns[1])); if (_ProductsBarcodes == null) { _ProductsBarcodes = new ProductsBarcodes(Session); } _ProductsBarcodes.Products = _Products; _ProductsBarcodes.Barcode = columns[1]; _ProductsBarcodes.BarcodeType = "EAN"; _ProductsBarcodes.Multiplier = 1; } _WorkEventArgs.CurrentValue += 1; OnDoWork(_WorkEventArgs); } catch (Exception) { //throw; } } OnFinalWork(_WorkEventArgs); } } this.LoadProducts2Pictures(); this.LoadLocations(); } private void LoadLocations() { Storage _Storage = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='1. Raktár' and CustomersFrom=?", _CustomersFrom)); ; const int _Limit = 9;//165015 StreamReader _textStreamReader; string _StrBuffer; Assembly _assembly = Assembly.GetExecutingAssembly(); _textStreamReader = new StreamReader(_assembly.GetManifestResourceStream("Nuvolar.Module.CSV.Locations.csv"), System.Text.Encoding.Default); _StrBuffer = _textStreamReader.ReadToEnd(); using (TextFieldParser parser = new TextFieldParser(new StringReader(_StrBuffer))) { parser.TextFieldType = Microsoft.VisualBasic.FileIO.FieldType.Delimited; parser.SetDelimiters(";"); WorkEventArgs _WorkEventArgs = new WorkEventArgs { Count = _Limit, CurrentValue = 1, Message = "Lokációk generálása" }; OnInitWork(_WorkEventArgs); int i = 0; while (!parser.EndOfData) { i++; if (i > _Limit) { break; } try { string[] columns = parser.ReadFields(); StorageLocation _StorageLocation= Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("Storage=? and ShortName=?", _Storage, columns[0])); if (_StorageLocation == null) { _StorageLocation = new StorageLocation(Session); } _StorageLocation.Storage = _Storage; _StorageLocation.ShortName = columns[0]; _StorageLocation.Barcode = columns[1]; _WorkEventArgs.CurrentValue += 1; OnDoWork(_WorkEventArgs); } catch (Exception) { //throw; } } OnFinalWork(_WorkEventArgs); } } private void LoadProducts2Pictures() { Assembly _assembly = Assembly.GetExecutingAssembly(); foreach (var resourceName in _assembly.GetManifestResourceNames()) { if (resourceName.ToString().Contains("Nuvolar.Module.Demo.Images.Products")) { string _ProductNumber = resourceName.ToString().Replace("Nuvolar.Module.Demo.Images.Products", "").Substring(1, 6); Products _Products= Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ProductNumber=?", _ProductNumber)); if (_Products !=null) { StreamReader _StreamReader= new StreamReader(_assembly.GetManifestResourceStream(resourceName.ToString()), System.Text.Encoding.Default); _Products.Picture_FullSize = (System.Drawing.Image)System.Drawing.Image.FromStream(_StreamReader.BaseStream, true,true); ProductsPictures _ProductsPictures = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("Products.ProductNumber=? and RowIndex=?",_Products.ProductNumber, int.Parse(resourceName.ToString().Replace("Nuvolar.Module.Demo.Images.Products", "").Substring(8,1)))); if (_ProductsPictures==null) { _ProductsPictures = new ProductsPictures(Session); } _ProductsPictures.Products = _Products; _ProductsPictures.RowIndex = int.Parse(resourceName.ToString().Replace("Nuvolar.Module.Demo.Images.Products", "").Substring(8, 1)); _ProductsPictures.Picture = (System.Drawing.Image)System.Drawing.Image.FromStream(_StreamReader.BaseStream, true, true); } } if (resourceName.ToString().Contains("Nuvolar.Module.Demo.Images.ProductsGroups")) { string _ShortName = resourceName.ToString().Replace("Nuvolar.Module.Demo.Images.ProductsGroups.", ""); _ShortName = _ShortName.Replace(".jpg",""); _ShortName = _ShortName.Replace("_", " "); _ShortName = _ShortName.Replace("!", ", "); ProductsGroups _ProductsGroups = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("Name=?", _ShortName)); if (_ProductsGroups != null) { StreamReader _StreamReader = new StreamReader(_assembly.GetManifestResourceStream(resourceName.ToString()), System.Text.Encoding.Default); _ProductsGroups.Picture = (System.Drawing.Image)System.Drawing.Image.FromStream(_StreamReader.BaseStream, true, true); } } } } private void GenerateDEMOProducts1() { if (this.IsDemoProducts1) { VAT _VAT0 = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='0 %'")); VAT _VAT5 = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='5 %'")); VAT _VAT18 = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='18 %'")); VAT _VAT27 = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='27 %'")); Units _U_CS = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='CS'")); Units _U_DB = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='DB'")); Units _U_DOB = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='DOB'")); Units _U_GARN = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='GARN'")); Units _U_KART = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='KART'")); Units _U_KG = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='KG'")); Units _U_KLT = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='KLT'")); Units _U_LIT = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='LIT'")); Units _U_REK = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='REK'")); Units _U_TÁL = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='TÁL'")); Units _U_TAS = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='TAS'")); Units _U_TEK = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='TEK'")); Units _U_TME = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='TME'")); Units _U_VÖD = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='VÖD'")); int _Limit = 25299;//165015 StreamReader _textStreamReader; string _StrBuffer; Assembly _assembly = Assembly.GetExecutingAssembly(); _textStreamReader = new StreamReader(_assembly.GetManifestResourceStream("Nuvolar.Module.CSV.Products1.csv"), System.Text.Encoding.Default); _StrBuffer = _textStreamReader.ReadToEnd(); using (TextFieldParser parser = new TextFieldParser(new StringReader(_StrBuffer))) { parser.TextFieldType = Microsoft.VisualBasic.FileIO.FieldType.Delimited; parser.SetDelimiters(";"); WorkEventArgs _WorkEventArgs = new WorkEventArgs { Count = _Limit, CurrentValue = 1,Message="Terméktörzs generálása" }; OnInitWork(_WorkEventArgs); int i = 0; while (!parser.EndOfData) { i++; if (i > _Limit) { break; } try { string[] columns = parser.ReadFields(); ProductsGroups _ProductsGroupsMain= Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("Name=?", columns[9])); if (_ProductsGroupsMain == null) { _ProductsGroupsMain = new ProductsGroups(Session); } _ProductsGroupsMain.ShortName = columns[9]; _ProductsGroupsMain.Name = columns[9]; _ProductsGroupsMain.Parent = null; _ProductsGroupsMain.Description = columns[9]; ProductsGroups _ProductsGroups = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("Name=?", columns[8])); if (_ProductsGroups == null) { _ProductsGroups = new ProductsGroups(Session); } _ProductsGroups.ShortName = columns[8]; _ProductsGroups.Name = columns[8]; _ProductsGroups.Parent = _ProductsGroupsMain; _ProductsGroups.Description = columns[8]; Products _Products = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ProductNumber=?", columns[0])); if (_Products == null) { _Products = new Products(Session); } _Products.ProductNumber = columns[0]; _Products.ShortName = columns[4]; _Products.ListPriceOutHUF = double.Parse(columns[5]); _Products.ProductGroups = _ProductsGroups; switch (columns[6].Trim()) { case "CS": _Products.Units = _U_CS; break; case "DB": _Products.Units = _U_DB; break; case "DOB": _Products.Units = _U_DOB; break; case "GARN": _Products.Units = _U_GARN; break; case "KART": _Products.Units = _U_KART; break; case "KG": _Products.Units = _U_KG; break; case "KLT": _Products.Units = _U_KLT; break; case "LIT": _Products.Units = _U_LIT; break; case "REK": _Products.Units = _U_REK; break; case "TÁL": _Products.Units = _U_TÁL; break; case "TAS": _Products.Units = _U_TAS; break; case "TEK": _Products.Units = _U_TEK; break; case "TME": _Products.Units = _U_TME; break; case "VÖD": _Products.Units = _U_VÖD; break; default: _Products.Units = _U_DB; break; } switch (columns[7]) { case "0,18": _Products.VAT = _VAT18; break; case "0,27": _Products.VAT = _VAT27; break; case "0,05": _Products.VAT = _VAT5; break; default: _Products.VAT = _VAT0; break; } if (columns[1] != "") { ProductsBarcodes _ProductsBarcodes = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("Products.ProductNumber=? and Barcode=? and BarcodeType='EAN'", _Products.ProductNumber, columns[1])); if (_ProductsBarcodes == null) { _ProductsBarcodes = new ProductsBarcodes(Session); } _ProductsBarcodes.Products = _Products; _ProductsBarcodes.Barcode = columns[1]; _ProductsBarcodes.BarcodeType = "EAN"; _ProductsBarcodes.Multiplier = 1; } _WorkEventArgs.CurrentValue += 1; OnDoWork(_WorkEventArgs); } catch (Exception) { //throw; } } OnFinalWork(_WorkEventArgs); } } } private void GenerateDEMOProducts() { if (this.IsDemoProducts) { VAT _VAT0 = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='0 %'")); VAT _VAT5 = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='5 %'")); VAT _VAT18 = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='18 %'")); VAT _VAT27 = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='27 %'")); Units _U_CS = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='CS'")); Units _U_DB = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='DB'")); Units _U_DOB = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='DOB'")); Units _U_GARN = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='GARN'")); Units _U_KART = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='KART'")); Units _U_KG = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='KG'")); Units _U_KLT = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='KLT'")); Units _U_LIT = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='LIT'")); Units _U_REK = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='REK'")); Units _U_TÁL = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='TÁL'")); Units _U_TAS = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='TAS'")); Units _U_TEK = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='TEK'")); Units _U_TME = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='TME'")); Units _U_VÖD = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='VÖD'")); int _Limit = 165015;//165015 StreamReader _textStreamReader; string _StrBuffer; Assembly _assembly = Assembly.GetExecutingAssembly(); _textStreamReader = new StreamReader(_assembly.GetManifestResourceStream("Nuvolar.Module.CSV.Products.csv")); _StrBuffer = _textStreamReader.ReadToEnd(); using (TextFieldParser parser = new TextFieldParser(new StringReader(_StrBuffer))) { parser.TextFieldType = Microsoft.VisualBasic.FileIO.FieldType.Delimited; parser.SetDelimiters(";"); WorkEventArgs _WorkEventArgs = new WorkEventArgs { Count = _Limit, CurrentValue = 1 }; OnInitWork(_WorkEventArgs); int i = 0; while (!parser.EndOfData) { i++; if (i > _Limit) { break; } try { _WorkEventArgs.CurrentValue += 1; OnDoWork(_WorkEventArgs); string[] columns = parser.ReadFields(); string _SQL = ""; Guid _ProductsBarcodes_Oid = Guid.Empty; Guid _Products_Oid = Guid.Empty; Guid _Units_Oid = Guid.Empty; Guid _VAT_Oid = Guid.Empty; bool _Exists = false; _SQL = string.Format("select Oid from Products Where ProductNumber='{0}'", columns[0]); SelectedData _SelectedData = Session.ExecuteQuery(_SQL); foreach (SelectStatementResultRow _SelectStatementResultRow in _SelectedData.ResultSet[0].Rows) { _Products_Oid = Guid.Parse(_SelectStatementResultRow.Values[0].ToString()); _Exists = true; } if (_Exists == false) { #region Units switch (columns[6].Trim()) { case "CS": _Units_Oid = _U_CS.Oid; break; case "DB": _Units_Oid = _U_DB.Oid; break; case "DOB": _Units_Oid = _U_DOB.Oid; break; case "GARN": _Units_Oid = _U_GARN.Oid; break; case "KART": _Units_Oid = _U_KART.Oid; break; case "KG": _Units_Oid = _U_KG.Oid; break; case "KLT": _Units_Oid = _U_KLT.Oid; break; case "LIT": _Units_Oid = _U_LIT.Oid; break; case "REK": _Units_Oid = _U_REK.Oid; break; case "TÁL": _Units_Oid = _U_TÁL.Oid; break; case "TAS": _Units_Oid = _U_TAS.Oid; break; case "TEK": _Units_Oid = _U_TEK.Oid; break; case "TME": _Units_Oid = _U_TME.Oid; break; case "VÖD": _Units_Oid = _U_VÖD.Oid; break; default: _Units_Oid = _U_DB.Oid; break; } #endregion #region VAT switch (columns[7]) { case "0,18": _VAT_Oid = _VAT18.Oid; break; case "0,27": _VAT_Oid = _VAT27.Oid; break; case "0,05": _VAT_Oid = _VAT5.Oid; break; default: _VAT_Oid = _VAT0.Oid; break; } #endregion _Products_Oid = Guid.NewGuid(); _SQL = string.Format("insert Products (Oid,ProductNumber,ShortName,ListPriceOutHUF,VAT,Units) select '{0}','{1}','{2}',{3},'{4}','{5}'", _Products_Oid.ToString(), columns[0], columns[4].Replace("'", ""), columns[5], _VAT_Oid.ToString(), _Units_Oid.ToString()); Session.ExecuteNonQuery(_SQL); } if (columns[1] != "") { _Exists = false; _SQL = string.Format("select Oid from ProductsBarcodes Where Barcode='{0}' and Products='{1}' and BarcodeType='EAN'", columns[1], _Products_Oid.ToString()); _SelectedData = Session.ExecuteQuery(_SQL); foreach (SelectStatementResultRow _SelectStatementResultRow in _SelectedData.ResultSet[0].Rows) { _ProductsBarcodes_Oid = Guid.Parse(_SelectStatementResultRow.Values[0].ToString()); _Exists = true; } if (_Exists == false) { _ProductsBarcodes_Oid = Guid.NewGuid(); _SQL = string.Format("insert ProductsBarcodes(Oid,Products,Barcode,BarcodeType,Multiplier)" + "select '{0}','{1}','{2}','{3}',{4}", _ProductsBarcodes_Oid.ToString(), _Products_Oid.ToString(), columns[1], "EAN", 1 ); Session.ExecuteNonQuery(_SQL); } } if (columns[2] != "") { _Exists = false; _SQL = string.Format("select Oid from ProductsBarcodes Where Barcode='{0}' and Products='{1}' and BarcodeType='FAST'", columns[2], _Products_Oid.ToString()); _SelectedData = Session.ExecuteQuery(_SQL); foreach (SelectStatementResultRow _SelectStatementResultRow in _SelectedData.ResultSet[0].Rows) { _ProductsBarcodes_Oid = Guid.Parse(_SelectStatementResultRow.Values[0].ToString()); _Exists = true; } if (_Exists == false) { _ProductsBarcodes_Oid = Guid.NewGuid(); _SQL = string.Format("insert ProductsBarcodes(Oid,Products,Barcode,BarcodeType,Multiplier)" + "select '{0}','{1}','{2}','{3}',{4}", _ProductsBarcodes_Oid.ToString(), _Products_Oid.ToString(), columns[2], "FAST", 1 ); Session.ExecuteNonQuery(_SQL); } } if (columns[3] != "") { _Exists = false; _SQL = string.Format("select Oid from ProductsBarcodes Where Barcode='{0}' and Products='{1}' and BarcodeType='PLU'", columns[3], _Products_Oid.ToString()); _SelectedData = Session.ExecuteQuery(_SQL); foreach (SelectStatementResultRow _SelectStatementResultRow in _SelectedData.ResultSet[0].Rows) { _ProductsBarcodes_Oid = Guid.Parse(_SelectStatementResultRow.Values[0].ToString()); _Exists = true; } if (_Exists == false) { _ProductsBarcodes_Oid = Guid.NewGuid(); _SQL = string.Format("insert ProductsBarcodes(Oid,Products,Barcode,BarcodeType,Multiplier)" + "select '{0}','{1}','{2}','{3}',{4}", _ProductsBarcodes_Oid.ToString(), _Products_Oid.ToString(), columns[3], "PLU", 1 ); Session.ExecuteNonQuery(_SQL); } } } catch (Exception ex) { //OnFinalWork(_WorkEventArgs); //throw new Exception(ex.Message); } } OnFinalWork(_WorkEventArgs); } } } private void GenerateDEMOCustomers() { if (this.IsDemoCustomers) { CustomersGLParameters _CustomersGLParameters= Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='Belföldi'")); Country _Country= Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='HU'")); int _Limit = 1000;//165015 StreamReader _textStreamReader; string _StrBuffer; Assembly _assembly = Assembly.GetExecutingAssembly(); _textStreamReader = new StreamReader(_assembly.GetManifestResourceStream("Nuvolar.Module.CSV.Customers.csv"), System.Text.Encoding.Default); _StrBuffer = _textStreamReader.ReadToEnd(); using (TextFieldParser parser = new TextFieldParser(new StringReader(_StrBuffer))) { parser.TextFieldType = Microsoft.VisualBasic.FileIO.FieldType.Delimited; parser.SetDelimiters(";"); WorkEventArgs _WorkEventArgs = new WorkEventArgs { Count = _Limit, CurrentValue = 1, Message="Ügyfelek létrehozása" }; OnInitWork(_WorkEventArgs); int i = 0; while (!parser.EndOfData) { i++; if (i > _Limit) { break; } try { string[] columns = parser.ReadFields(); Customers _Customers = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("VATNumber=?", columns[4])); if (_Customers == null) { _Customers = new Customers(Session); } _Customers.CustomerNumber = "DEMO-V-"+i.ToString(); _Customers.FullName = columns[2]; _Customers.Name = columns[2]; _Customers.VATNumber = columns[4]; _Customers.CustomersGLParameters = _CustomersGLParameters; Address _Address = Session.FindObject
(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ZipPostal=? and Street=?", columns[0],columns[1])); if (_Address == null) { _Address = new Address(Session); } _Address.Country = _Country; ZIPHU _ZIPHU=Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("Zip=?", columns[0])); if (_ZIPHU == null) { _ZIPHU = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("Zip=1139")); } _Address.City = _ZIPHU.City; _Address.ZipPostal = columns[0]; _Address.Street = columns[1]; _Customers.Address1 = _Address; if (_Customers.CustomerBankAccounts.Count > 0) { _Customers.CustomerBankAccounts[0].AccountNumber = columns[3]; } else { _Customers.CustomerBankAccounts.Add(new CustomerBankAccounts(Session) {AccountNumber=columns[3],Customers=_Customers }); } _WorkEventArgs.CurrentValue += 1; OnDoWork(_WorkEventArgs); } catch (Exception) { //throw; } } OnFinalWork(_WorkEventArgs); } } } private void GenerateDEMOContacts() { XPCollection _Names_Collection = new XPCollection(Session, CriteriaOperator.Parse("1=1")); XPCollection _ZIPHU_Collection = new XPCollection(Session, CriteriaOperator.Parse("1=1")); XPCollection _Customers_Collection = new XPCollection(Session, CriteriaOperator.Parse("1=1")); Random RandomGenNames = new Random(); Random RandomGenZIPHU = new Random(); int _NamesCount = _Names_Collection.Count(); int _ZIPHUCount = _ZIPHU_Collection.Count(); WorkEventArgs _WorkEventArgs = new WorkEventArgs { Count = _Customers_Collection.Count, CurrentValue = 1, Message = "DEMO kapcsolatok létrehozása" }; OnInitWork(_WorkEventArgs); foreach (Customers _Customers in _Customers_Collection) { if (_Customers.Contacts.Count==0) { int _RandomNamesCount = RandomGenNames.Next(1, _NamesCount); int _RandomZIPHUCount = RandomGenZIPHU.Next(1, _ZIPHUCount); Contacts _Contacts = new Contacts(Session); _Contacts.FirstName = _Names_Collection[_RandomNamesCount].Names; _Contacts.LastName = _ZIPHU_Collection[_RandomZIPHUCount].City; _Contacts.Email = string.Format("{0}.{1}@{2}.nuvolar.hu",_Contacts.FirstName,_Contacts.LastName,Regex.Replace(_Customers.Name, @"[^\u0020-\u007E]", string.Empty).Substring(1,4).Trim().ToLower()).ToLower(); _Contacts.Customers = _Customers; _Customers.Contacts.Add(_Contacts); _RandomNamesCount = RandomGenNames.Next(1, _NamesCount); _RandomZIPHUCount = RandomGenZIPHU.Next(1, _ZIPHUCount); _Contacts = new Contacts(Session); _Contacts.FirstName = _Names_Collection[_RandomNamesCount].Names; _Contacts.LastName = _ZIPHU_Collection[_RandomZIPHUCount].City; _Contacts.Email = string.Format("{0}.{1}@{2}.nuvolar.hu", _Contacts.FirstName, _Contacts.LastName, Regex.Replace(_Customers.Name, @"[^\u0020-\u007E]", string.Empty).Substring(1, 4).Trim().ToLower()).ToLower(); _Contacts.Customers = _Customers; _Customers.Contacts.Add(_Contacts); _WorkEventArgs.CurrentValue += 1; OnDoWork(_WorkEventArgs); } } OnFinalWork(_WorkEventArgs); } private void GenerateDEMOCustomersOrder() { if (this.IsDemoCustomersOrder) { CustomersGLParameters _CustomersGLParameters = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='Belföldi'")); Country _Country = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='HU'")); int _Limit = 20;//165015 StreamReader _textStreamReader; string _StrBuffer; Assembly _assembly = Assembly.GetExecutingAssembly(); _textStreamReader = new StreamReader(_assembly.GetManifestResourceStream("Nuvolar.Module.CSV.CustomersOrder.csv"), System.Text.Encoding.Default); _StrBuffer = _textStreamReader.ReadToEnd(); using (TextFieldParser parser = new TextFieldParser(new StringReader(_StrBuffer))) { parser.TextFieldType = Microsoft.VisualBasic.FileIO.FieldType.Delimited; parser.SetDelimiters(";"); WorkEventArgs _WorkEventArgs = new WorkEventArgs { Count = _Limit, CurrentValue = 1, Message = "Beszállítók létrehozása" }; OnInitWork(_WorkEventArgs); int i = 0; while (!parser.EndOfData) { i++; if (i > _Limit) { break; } try { string[] columns = parser.ReadFields(); CustomersOrder _CustomersOrder = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("VATNumber=?", columns[4])); if (_CustomersOrder == null) { _CustomersOrder = new CustomersOrder(Session); } _CustomersOrder.CustomerNumber = "DEMO-B-" + i.ToString(); _CustomersOrder.FullName = columns[2]; _CustomersOrder.Name = columns[2]; _CustomersOrder.VATNumber = columns[4]; _CustomersOrder.CustomersGLParameters = _CustomersGLParameters; Address _Address = Session.FindObject
(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ZipPostal=? and Street=?", columns[0], columns[1])); if (_Address == null) { _Address = new Address(Session); } _Address.Country = _Country; ZIPHU _ZIPHU = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("Zip=?", columns[0])); if (_ZIPHU == null) { _ZIPHU = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("Zip=1139")); } _Address.City = _ZIPHU.City; _Address.ZipPostal = columns[0]; _Address.Street = columns[1]; _CustomersOrder.Address1 = _Address; if (_CustomersOrder.CustomerBankAccounts.Count > 0) { _CustomersOrder.CustomerBankAccounts[0].AccountNumber = columns[3]; } else { _CustomersOrder.CustomerBankAccounts.Add(new CustomerBankAccounts(Session) { AccountNumber = columns[3], Customers = (Customers)_CustomersOrder }); } #region NumberGenerator1 NumberGenerator _NumberGenerator1 = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName=?", _CustomersOrder.CustomerNumber)); if (_NumberGenerator1 == null) { _NumberGenerator1 = new NumberGenerator(Session); } _NumberGenerator1.ShortName = _CustomersOrder.CustomerNumber; _NumberGenerator1.PrefixString = _CustomersOrder.CustomerNumber; _NumberGenerator1.PrefixTag = "-"; _NumberGenerator1.SuffixString = "-"; NumberGeneratorGroups _NumberGeneratorGroups = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='Beszállítói dokumentum sorszámok'")); if (_NumberGeneratorGroups == null) { _NumberGeneratorGroups = new NumberGeneratorGroups(Session); _NumberGeneratorGroups.ShortName = "Beszállítói dokumentum sorszámok"; _NumberGeneratorGroups.Description = "Beszállítói dokumentum sorszámok"; } _NumberGenerator1.NumberGeneratorGroups = _NumberGeneratorGroups; #endregion if (_CustomersOrder.CustomersOrderDocuments.Count > 0) { _CustomersOrder.CustomersOrderDocuments[0].NumberGenerator = _NumberGenerator1; _CustomersOrder.CustomersOrderDocuments[0].CurrencyName = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='HUF'")); _CustomersOrder.CustomersOrderDocuments[0].OrderOutMainType = eOrderOutMainType.eFromProducts; _CustomersOrder.CustomersOrderDocuments[0].ReportData = null; } else { CustomersOrderDocuments _CustomersOrderDocuments = new CustomersOrderDocuments(Session); _CustomersOrderDocuments.CustomersOrder = _CustomersOrder; _CustomersOrderDocuments.NumberGenerator = _NumberGenerator1; _CustomersOrderDocuments.CurrencyName = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='HUF'")); _CustomersOrderDocuments.OrderOutMainType = eOrderOutMainType.eFromProducts; _CustomersOrderDocuments.ReportData = null; } _WorkEventArgs.CurrentValue += 1; OnDoWork(_WorkEventArgs); } catch (Exception ex) { int j; string ss; ss = ex.Message; j = 0; } } OnFinalWork(_WorkEventArgs); } } } private void GenerateDEMOSimpleInvoice(XPObjectSpace _onew) { DateTime _StartDate = this.Invoice_FromDate; DateTime _CurDate = this.Invoice_FromDate; long _DateDiff = DateAndTime.DateDiff(DateInterval.Day, this.Invoice_FromDate, this.Invoice_ToDate); int i = 0; Random RandomGenDay = new Random(); Random RandomGenRows = new Random(); Random RandomGenProducts = new Random(); Random RandomGenCustomers = new Random(); Random RandomGenQTT = new Random(); Random RandomAverage = new Random(); XPCollection _Products_Collection = new XPCollection(_onew.Session, CriteriaOperator.Parse("ListPriceOutHUF>20000 and ListPriceOutHUF<30000")); XPCollection _Customers_Collection = new XPCollection(_onew.Session, CriteriaOperator.Parse("CustomerNumber like 'DEMO-V-%'")); int _CustomersCount = _Customers_Collection.Count; int _ProductsCount = _Products_Collection.Count; InvoiceType _InvoiceType = _onew.Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='Kimenő vevői számla' and CustomersFrom=?",CustomersFrom)); BankInformation _BankInformation = _onew.Session.FindObject(CriteriaOperator.Parse("AccountNumber=?",CustomersFrom.CustomerBankAccounts[0].AccountNumber)); PaymentOption _PaymentOption= _onew.Session.FindObject(CriteriaOperator.Parse("Description='Átutalás (8 nap)'")); CurrencyName _CurrencyName = _onew.Session.FindObject(CriteriaOperator.Parse("ShortName='HUF'")); WorkEventArgs _WorkEventArgs = new WorkEventArgs { Count = (int)_DateDiff, CurrentValue = 1, Message = "DEMO számlák létrehozása" }; OnInitWork(_WorkEventArgs); while (_CurDate _Products_Collection = new XPCollection(_onew.Session, CriteriaOperator.Parse("ListPriceOutHUF>20000 and ListPriceOutHUF<30000")); XPCollection _Customers_Collection = new XPCollection(_onew.Session, CriteriaOperator.Parse("CustomerNumber like 'DEMO-V-%'")); int _CustomersCount = _Customers_Collection.Count; int _ProductsCount = _Products_Collection.Count; OfferOutParameters _OfferOutParameters = _onew.Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='Kimenő árajánlat paraméter' and CustomersFrom=?", CustomersFrom)); BankInformation _BankInformation = _onew.Session.FindObject(CriteriaOperator.Parse("AccountNumber=?", CustomersFrom.CustomerBankAccounts[0].AccountNumber)); CurrencyName _CurrencyName = _onew.Session.FindObject(CriteriaOperator.Parse("ShortName='HUF'")); PaymentOption _PaymentOption = _onew.Session.FindObject(CriteriaOperator.Parse("Description='Átutalás (8 nap)'")); WorkEventArgs _WorkEventArgs = new WorkEventArgs { Count = (int)_DateDiff, CurrentValue = 1, Message = "DEMO számlák létrehozása" }; OnInitWork(_WorkEventArgs); while (_CurDate < this.OfferOut_ToDate) { if (_CurDate.DayOfWeek == DayOfWeek.Saturday || _CurDate.DayOfWeek == DayOfWeek.Sunday) { } else { int _RandomDayCount = RandomGenDay.Next(OfferOut_MinNumberPerDay, OfferOut_MaxNumberPerDay); for (int j = 0; j < _RandomDayCount; j++) { // Számla fejléc --------------------------------------------------------- int _RandomCustomersCount = RandomGenCustomers.Next(1, _CustomersCount); OfferOutHeader _OfferOutHeader = new OfferOutHeader(_onew.Session); _OfferOutHeader.CurrencyName = _CurrencyName; _OfferOutHeader.Customers = _Customers_Collection[_RandomCustomersCount]; _OfferOutHeader.CustomersFrom = this.CustomersFrom; _OfferOutHeader.Contact = _OfferOutHeader.Customers.Contacts[0]; _OfferOutHeader.DateCreated = _CurDate; _OfferOutHeader.DateDue = _CurDate; _OfferOutHeader.DateExecution = _CurDate; _OfferOutHeader.DatePayment = _CurDate; _OfferOutHeader.Description = ""; _OfferOutHeader.IsEditable = true; _OfferOutHeader.IsStorno = false; _OfferOutHeader.OfferOutParameters = _OfferOutParameters; _OfferOutHeader.OfferOutState = eOfferOutState.eInProgress; _OfferOutHeader.OtherCostPercent = 85.0; _OfferOutHeader.PaymentOption = _PaymentOption; // Számla sorok ---------------------------------------------------------- int _RandomRowsCount = RandomGenRows.Next(OfferOut_MinNumberRow, OfferOut_MaxNumberRow); for (int k = 0; k < _RandomRowsCount; k++) { OfferOutRows _OfferOutRows = new OfferOutRows(_onew.Session); int _RandomProductsCount = RandomGenProducts.Next(1, _ProductsCount); int _RandomQTT = RandomGenQTT.Next(1, 15); int _RandomAverage = RandomAverage.Next(65, 89); Products _Products = _Products_Collection[_RandomProductsCount]; _OfferOutRows.OfferOutHeader = _OfferOutHeader; _OfferOutRows.Description = ""; _OfferOutRows.FinalPriceHUF = _Products.ListPriceOutHUF; _OfferOutRows.ListPriceHUF = _Products.ListPriceOutHUF; _OfferOutRows.Product = _Products; _OfferOutRows.RowType = eRowType.IsProduct; _OfferOutRows.QTT = _RandomQTT; _OfferOutRows.RowIndex = k; _OfferOutRows.ShortName = _Products.ShortName; _OfferOutRows.Units = _Products.Units; _OfferOutRows.VAT = _Products.VAT; _OfferOutRows.SumPriceHUF = _OfferOutRows.QTT * _OfferOutRows.ListPriceHUF; } _onew.CommitChanges(); } } _CurDate = _CurDate.AddDays(1); i++; _WorkEventArgs.CurrentValue = i; OnDoWork(_WorkEventArgs); } OnFinalWork(_WorkEventArgs); } private void GenerateDEMODeliveryNoteIn(XPObjectSpace _onew) { DateTime _StartDate = this.DeliveryNoteIn_FromDate; DateTime _CurDate = this.DeliveryNoteIn_FromDate; long _DateDiff = DateAndTime.DateDiff(DateInterval.Day, this.DeliveryNoteIn_FromDate, this.DeliveryNoteIn_ToDate); int i = 0; Random RandomGenDay = new Random(); Random RandomGenRows = new Random(); Random RandomGenProducts = new Random(); Random RandomGenCustomers = new Random(); Random RandomGenQTT = new Random(); Random RandomAverage = new Random(); Random RandomDocumentNumberIn = new Random(); XPCollection _Products_Collection = new XPCollection(_onew.Session, CriteriaOperator.Parse("ListPriceOutHUF>20000 and ListPriceOutHUF<30000")); XPCollection _CustomersOrder_Collection = new XPCollection(_onew.Session, CriteriaOperator.Parse("1=1")); int _CustomersOrderCount = _CustomersOrder_Collection.Count; int _ProductsCount = _Products_Collection.Count; DeliveryNoteInType _DeliveryNoteInType = _onew.Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='Szállítólevél (belföldi ÁFÁ-s)' and CustomersFrom=?", CustomersFrom)); BankInformation _BankInformation = _onew.Session.FindObject(CriteriaOperator.Parse("AccountNumber=?", CustomersFrom.CustomerBankAccounts[0].AccountNumber)); CurrencyName _CurrencyName = _onew.Session.FindObject(CriteriaOperator.Parse("ShortName='HUF'")); PaymentOption _PaymentOption = _onew.Session.FindObject(CriteriaOperator.Parse("Description='Átutalás (8 nap)'")); WorkEventArgs _WorkEventArgs = new WorkEventArgs { Count = (int)_DateDiff, CurrentValue = 1, Message = "DEMO szállítólevelek létrehozása" }; OnInitWork(_WorkEventArgs); while (_CurDate < this.DeliveryNoteIn_ToDate) { if (_CurDate.DayOfWeek == DayOfWeek.Saturday || _CurDate.DayOfWeek == DayOfWeek.Sunday) { } else { int _RandomDayCount = RandomGenDay.Next(DeliveryNoteIn_MinNumberPerDay, DeliveryNoteIn_MaxNumberPerDay); for (int j = 0; j < _RandomDayCount; j++) { // Számla fejléc --------------------------------------------------------- int _RandomCustomersCount = RandomGenCustomers.Next(1, _CustomersOrderCount); int _RandomDocumentNumberInCount = RandomDocumentNumberIn.Next(555555, 999999); DeliveryNoteInHeader _DeliveryNoteInHeader = new DeliveryNoteInHeader(_onew.Session); _DeliveryNoteInHeader.CurrencyName = _CurrencyName; _DeliveryNoteInHeader.Customers = _CustomersOrder_Collection[_RandomCustomersCount]; _DeliveryNoteInHeader.CustomersFrom = this.CustomersFrom; _DeliveryNoteInHeader.DateCreated = _CurDate; _DeliveryNoteInHeader.DateExecution = _CurDate; _DeliveryNoteInHeader.DatePayment = _CurDate; _DeliveryNoteInHeader.IsEditable = false; _DeliveryNoteInHeader.IsStorno = false; _DeliveryNoteInHeader.DeliveryNoteInType = _DeliveryNoteInType; _DeliveryNoteInHeader.PaymentOption = _PaymentOption; _DeliveryNoteInHeader.CurrencyRate = 1; _DeliveryNoteInHeader.DocumentNumberIn = string.Format("{0}-{1}-{2}",_RandomDocumentNumberInCount.ToString(),_CurDate.Month.ToString(),_CurDate.Year.ToString()); // Szállítólevél sorok ---------------------------------------------------------- int _RandomRowsCount = RandomGenRows.Next(DeliveryNoteIn_MinNumberRow, DeliveryNoteIn_MaxNumberRow); for (int k = 0; k < _RandomRowsCount; k++) { DeliveryNoteInRows _DeliveryNoteInRows = new DeliveryNoteInRows(_onew.Session); int _RandomProductsCount = RandomGenProducts.Next(1, _ProductsCount); int _RandomQTT = RandomGenQTT.Next(1, 15); int _RandomAverage = RandomAverage.Next(65, 89); Products _Products = _Products_Collection[_RandomProductsCount]; _DeliveryNoteInRows.DeliveryNoteInHeader = _DeliveryNoteInHeader; _DeliveryNoteInRows.ListPriceHUF = _Products.ListPriceOutHUF*0.85; _DeliveryNoteInRows.Products = _Products; _DeliveryNoteInRows.QTT = _RandomQTT; _DeliveryNoteInRows.RowIndex = k; _DeliveryNoteInRows.Units = _Products.Units; _DeliveryNoteInRows.VAT = _Products.VAT; _DeliveryNoteInRows.WeightMode = eWeightMode.eTotalWeightperQuantity; } _onew.CommitChanges(); } } _CurDate = _CurDate.AddDays(1); i++; _WorkEventArgs.CurrentValue = i; OnDoWork(_WorkEventArgs); } OnFinalWork(_WorkEventArgs); } #endregion // Törzs adatok generálása ---------------------------- #region STOCK private void GenerateHRPerson() { string[,] _HRPersonParam = { {"feher.tamas@nuvolar.hu", "Fehér","Tamás", "feher.tamas", "Pénzügyi munkatárs" }, {"nagy.gabriella@nuvolar.hu", "Nagy","Gabriella", "nagy.gabriella", "Raktárvezető"}, {"fekete.ilona@nuvolar.hu", "Fekete","Ilona", "fekete.ilona", "Raktáros"}, {"piros.tamás@nuvolar.hu", "Piros","Tamás", "piros.tamas", "Értékesítési munkatárs"}, {"kék.ibolya@nuvolar.hu", "Kék","Ibolya", "kek.ibolya", "Értékesítési vezető"}, {"főnök.zoltán@nuvolar.hu", "Főnök","Zoltán", "fonok.zoltan", "Ügyvezető"}, {"report.designer@nuvolar.hu", "Report","Designer", "report.designer", "Nyomtatvány tervező"}, {"kiss.janos@nuvolar.hu", "Kiss","János", "kiss.janos", "Értékesítési munkatárs"} }; for (int i = 0; i < 5; i++) { Role _AdminRole = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("Name='Administrators'")); User _User= Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction,CriteriaOperator.Parse("UserName=?", _HRPersonParam[i, 3])); if (_User==null) { _User = new User(Session); } _User.UserName = _HRPersonParam[i, 3]; _User.FirstName = _HRPersonParam[i, 2]; _User.LastName = _HRPersonParam[i, 1]; ; _User.Email = _HRPersonParam[i, 0]; ; if (_User.Roles.Count==0) { _User.Roles.Add(_AdminRole); } _User.Save(); HRPerson _HRPerson= Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("User.UserName=?", _User.UserName)); if (_HRPerson==null) { _HRPerson = new HRPerson(Session); } _HRPerson.User = _User; _HRPerson.Email = _HRPersonParam[i, 0]; _HRPerson.FirstName = _HRPersonParam[i, 2]; _HRPerson.LastName = _HRPersonParam[i, 1]; _HRPerson.Job = _HRPersonParam[i, 4]; _HRPerson.Save(); } } private void GenerateNames() { XPCollection _Names_Collection = new XPCollection(PersistentCriteriaEvaluationBehavior.InTransaction, Session, CriteriaOperator.Parse("1=1")); if (_Names_Collection.Count == 0) { int i = 1; StreamReader _textStreamReader; string _StrBuffer; Assembly _assembly = Assembly.GetExecutingAssembly(); _textStreamReader = new StreamReader(_assembly.GetManifestResourceStream("Nuvolar.Module.CSV.Names.csv"), System.Text.Encoding.Default); _StrBuffer = _textStreamReader.ReadToEnd(); StringReader _StringReader = new StringReader(_StrBuffer); using (TextFieldParser parser = new TextFieldParser(_StringReader)) { parser.TextFieldType = Microsoft.VisualBasic.FileIO.FieldType.Delimited; parser.SetDelimiters(","); WorkEventArgs _WorkEventArgs = new WorkEventArgs { Count = 3574, CurrentValue = 1,Message="Nevek beállítása ..." }; OnInitWork(_WorkEventArgs); while (!parser.EndOfData) { try { string[] columns = parser.ReadFields(); Names _Names = new Names(Session); _Names.ID = i; _Names.Names = columns[0]; _Names.Save(); i += 1; _WorkEventArgs.CurrentValue += 1; OnDoWork(_WorkEventArgs); } catch (Exception ex) { string expmsg = ex.Message; } } OnFinalWork(_WorkEventArgs); } } } private void GenerateZIPHU() { XPCollection _ZIPHU_Collection = new XPCollection(PersistentCriteriaEvaluationBehavior.InTransaction, Session, CriteriaOperator.Parse("1=1")); if (_ZIPHU_Collection.Count == 0) { int i = 1; StreamReader _textStreamReader; string _StrBuffer; Assembly _assembly = Assembly.GetExecutingAssembly(); _textStreamReader = new StreamReader(_assembly.GetManifestResourceStream("Nuvolar.Module.CSV.ZIPHU.csv"), System.Text.Encoding.Default); _StrBuffer = _textStreamReader.ReadToEnd(); StringReader _StringReader = new StringReader(_StrBuffer); using (TextFieldParser parser = new TextFieldParser(_StringReader)) { parser.TextFieldType = Microsoft.VisualBasic.FileIO.FieldType.Delimited; parser.SetDelimiters(","); WorkEventArgs _WorkEventArgs = new WorkEventArgs { Count = 3574, CurrentValue = 1,Message="Irányítószámok beállítása" }; OnInitWork(_WorkEventArgs); while (!parser.EndOfData) { try { string[] columns = parser.ReadFields(); ZIPHU _ZIPHU = new ZIPHU(Session); _ZIPHU.ID = i; _ZIPHU.City = columns[1]; _ZIPHU.Zip = columns[0]; _ZIPHU.County = columns[2]; _ZIPHU.Save(); i += 1; _WorkEventArgs.CurrentValue += 1; OnDoWork(_WorkEventArgs); } catch (Exception ex) { string expmsg = ex.Message; } } OnFinalWork(_WorkEventArgs); } } } private void GenerateWorkSheet() { string[,] _WorkSheetTypeParam = { {"1. Szervíz munkalap", "Szervíz munkalap sorszám","W-SZ", "-", "-","false","" }, {"2. Karbantartási munkalap","Karbantartási munkalap sorszám","W-K", "-", "-","false",""}, {"3. Garanciális munkalap","Garanciális munkalap sorszám","W-G", "-", "-","false",""} }; for (int i = 0; i < 3; i++) { WorkSheetType _WorkSheetType = Session.FindObject(CriteriaOperator.Parse("ShortName=?",_WorkSheetTypeParam[i,0])); if (_WorkSheetType==null) { _WorkSheetType = new WorkSheetType(Session); } #region NumberGenerator1 NumberGenerator _NumberGenerator1 = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName=?", _WorkSheetTypeParam[i, 1])); if (_NumberGenerator1 == null) { _NumberGenerator1 = new NumberGenerator(Session); } _NumberGenerator1.ShortName = _WorkSheetTypeParam[i, 1]; _NumberGenerator1.PrefixString = _WorkSheetTypeParam[i, 2]; _NumberGenerator1.PrefixTag = _WorkSheetTypeParam[i, 3]; _NumberGenerator1.SuffixString = _WorkSheetTypeParam[i, 4]; NumberGeneratorGroups _NumberGeneratorGroups = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='Üzleti tranzakciók paraméterei'")); if (_NumberGeneratorGroups == null) { _NumberGeneratorGroups = new NumberGeneratorGroups(Session); _NumberGeneratorGroups.ShortName = "Üzleti tranzakciók paraméterei"; _NumberGeneratorGroups.Description = "Üzleti tranzakciók paraméterei"; } _NumberGenerator1.NumberGeneratorGroups = _NumberGeneratorGroups; #endregion _WorkSheetType.NumberGenerator = _NumberGenerator1; _WorkSheetType.CustomersFrom = _CustomersFrom; _WorkSheetType.Description = _WorkSheetTypeParam[i, 0]; _WorkSheetType.IsOperationalLog = bool.Parse(_WorkSheetTypeParam[i, 5]); _WorkSheetType.OperationalLogDescription = _WorkSheetTypeParam[i, 6]; _WorkSheetType.ShortName = _WorkSheetTypeParam[i, 0]; _WorkSheetType.Save(); } } private void GeneratePDAParameters() { string[,] _PDAParam = { { "1. Leltár", "1. PDA kollekció (leltár)","PDA-L", "-", "-" }, { "2. Kitárolás", "1. PDA kollekció (kitárolás)","PDA-K", "-", "-"}, { "3. Betárolás", "1. PDA kollekció (betárolás)","PDA-B", "-", "-"}, }; for (int i = 0; i < 3; i++) { StoragePDAParameters _StoragePDAParameters=Session.FindObject(CriteriaOperator.Parse("ShortName=?",_PDAParam[i,0])); if (_StoragePDAParameters==null) { _StoragePDAParameters = new StoragePDAParameters(Session); } _StoragePDAParameters.CustomersFrom = _CustomersFrom; _StoragePDAParameters.ShortName = _PDAParam[i,0]; _StoragePDAParameters.DeleteAfterImport = false; _StoragePDAParameters.ImportPath = ""; _StoragePDAParameters.ReportLocationIn = null; _StoragePDAParameters.ReportLocationOut = null; #region NumberGenerator1 NumberGenerator _NumberGenerator1 = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName=?", _PDAParam[i, 1])); if (_NumberGenerator1 == null) { _NumberGenerator1 = new NumberGenerator(Session); } _NumberGenerator1.ShortName = _PDAParam[i, 1]; _NumberGenerator1.PrefixString = _PDAParam[i, 2]; _NumberGenerator1.PrefixTag = _PDAParam[i, 3]; _NumberGenerator1.SuffixString = _PDAParam[i, 4]; NumberGeneratorGroups _NumberGeneratorGroups = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='Raktári tranzakciók paraméterei'")); if (_NumberGeneratorGroups == null) { _NumberGeneratorGroups = new NumberGeneratorGroups(Session); _NumberGeneratorGroups.ShortName = "Raktári tranzakciók paraméterei"; _NumberGeneratorGroups.Description = "Raktári tranzakciók paraméterei"; } _NumberGenerator1.NumberGeneratorGroups = _NumberGeneratorGroups; #endregion _StoragePDAParameters.NumberGenerator = _NumberGenerator1; } } private void GenerateVTSZ() { XPCollection _CustomsTariffs_Collection = new XPCollection(PersistentCriteriaEvaluationBehavior.InTransaction, Session, CriteriaOperator.Parse("1=1")); if (_CustomsTariffs_Collection.Count == 0) { StreamReader _textStreamReader; string _StrBuffer; Assembly _assembly = Assembly.GetExecutingAssembly(); _textStreamReader = new StreamReader(_assembly.GetManifestResourceStream("Nuvolar.Module.CSV.CustomsTariffs.csv")); _StrBuffer = _textStreamReader.ReadToEnd(); using (TextFieldParser parser = new TextFieldParser(new StringReader(_StrBuffer))) { parser.TextFieldType = Microsoft.VisualBasic.FileIO.FieldType.Delimited; parser.SetDelimiters("\t"); WorkEventArgs _WorkEventArgs = new WorkEventArgs { Count = 9430, CurrentValue = 1,Message="VTSZ beállítása" }; OnInitWork(_WorkEventArgs); while (!parser.EndOfData) { try { string[] columns = parser.ReadFields(); CustomsTariffs _CustomsTariffs = new CustomsTariffs(Session); _CustomsTariffs.CustomsTariffNumber = columns[0]; if (columns[1].Length>255) { columns[1] = columns[1].Substring(0, 254); } _CustomsTariffs.Description = columns[1]; _CustomsTariffs.Save(); _WorkEventArgs.CurrentValue += 1; OnDoWork(_WorkEventArgs); } catch (Exception ex) { string expmsg=ex.Message; } } OnFinalWork(_WorkEventArgs); } } } private void GeretatePaymentOptions() { string[,] _PaymentOptionParam = { { "Átutalás", "Átutalás (0 nap)","1", "0", "Transfer", "0", "false" }, { "Átutalás", "Átutalás (8 nap)","1", "8", "Transfer", "0", "true" }, { "Átutalás", "Átutalás (30 nap)","1", "30", "Transfer", "0", "false" }, { "Készpénz", "Készpénz","0", "0", "Transfer", "0", "false" } }; for (int i = 0; i < 3; i++) { PaymentOption _PaymentOption = Session.FindObject(CriteriaOperator.Parse("Description=?", _PaymentOptionParam[i, 1])); if (_PaymentOption== null) { _PaymentOption = new PaymentOption(Session); } _PaymentOption.ShortName = _PaymentOptionParam[i, 0]; _PaymentOption.Description = _PaymentOptionParam[i, 1]; _PaymentOption.PayMode = (ePayMode)int.Parse(_PaymentOptionParam[i, 2]); _PaymentOption.PayDay = int.Parse(_PaymentOptionParam[i, 3]); _PaymentOption.ShortName_GB = _PaymentOptionParam[i, 4]; _PaymentOption.DatePaymentMode = (eDatePaymentMode)int.Parse(_PaymentOptionParam[i, 5]); _PaymentOption.DefaultForBusinnes = bool.Parse(_PaymentOptionParam[i, 6]); } } private void GenerateStorage() { string[,] _StorageParam = { { "1. Raktár", "Betárolási sorszám 1. raktár","BETÁR-1", "-", "-", "Kitárolási sorszám 1. raktár","KITÁR-1","-","-", "Betárolási sorszám (stornó) 1. raktár","BETÁR-1-S", "-", "-", "Kitárolási sorszám (stornó) 1. raktár","KITÁR-1-S","-","-" }, { "2. Raktár", "Betárolási sorszám 2. raktár","BETÁR-2", "-", "-", "Kitárolási sorszám 2. raktár","KITÁR-2","-","-", "Betárolási sorszám (stornó) 2. raktár","BETÁR-2-S", "-", "-", "Kitárolási sorszám (stornó) 2. raktár","KITÁR-2-S","-","-" } }; for (int i = 0; i < 2; i++) { Storage _Storage = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName=? and CustomersFrom=?", _StorageParam[i,0],_CustomersFrom)); if (_Storage==null) { _Storage = new Storage(Session); } _Storage.ShortName = _StorageParam[i, 0]; _Storage.CustomersFrom = _CustomersFrom; _Storage.Description = _StorageParam[i, 0]; #region NumberGenerator1 NumberGenerator _NumberGenerator1 = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName=?", _StorageParam[i, 1])); if (_NumberGenerator1 == null) { _NumberGenerator1 = new NumberGenerator(Session); } _NumberGenerator1.ShortName = _StorageParam[i, 1]; _NumberGenerator1.PrefixString = _StorageParam[i, 2]; _NumberGenerator1.PrefixTag = _StorageParam[i, 3]; _NumberGenerator1.SuffixString = _StorageParam[i, 4]; NumberGeneratorGroups _NumberGeneratorGroups = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='Raktári tranzakciók paraméterei'")); if (_NumberGeneratorGroups == null) { _NumberGeneratorGroups = new NumberGeneratorGroups(Session); _NumberGeneratorGroups.ShortName = "Raktári tranzakciók paraméterei"; _NumberGeneratorGroups.Description = "Raktári tranzakciók paraméterei"; } _NumberGenerator1.NumberGeneratorGroups = _NumberGeneratorGroups; #endregion _Storage.NumberGeneratorIn = _NumberGenerator1; #region NumberGenerator2 NumberGenerator _NumberGenerator2 = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName=?", _StorageParam[i, 5])); if (_NumberGenerator2 == null) { _NumberGenerator2 = new NumberGenerator(Session); } _NumberGenerator2.ShortName = _StorageParam[i, 5]; _NumberGenerator2.PrefixString = _StorageParam[i, 6]; _NumberGenerator2.PrefixTag = _StorageParam[i, 7]; _NumberGenerator2.SuffixString = _StorageParam[i, 8]; _NumberGenerator2.NumberGeneratorGroups = _NumberGeneratorGroups; #endregion _Storage.NumberGeneratorOut = _NumberGenerator2; #region NumberGenerator3 NumberGenerator _NumberGenerator3 = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName=?", _StorageParam[i, 9])); if (_NumberGenerator3 == null) { _NumberGenerator3 = new NumberGenerator(Session); } _NumberGenerator3.ShortName = _StorageParam[i, 9]; _NumberGenerator3.PrefixString = _StorageParam[i, 10]; _NumberGenerator3.PrefixTag = _StorageParam[i, 11]; _NumberGenerator3.SuffixString = _StorageParam[i, 12]; _NumberGenerator3.NumberGeneratorGroups = _NumberGeneratorGroups; #endregion _Storage.NumberGeneratorInS = _NumberGenerator3; #region NumberGenerator4 NumberGenerator _NumberGenerator4 = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName=?", _StorageParam[i, 13])); if (_NumberGenerator4 == null) { _NumberGenerator4 = new NumberGenerator(Session); } _NumberGenerator4.ShortName = _StorageParam[i, 13]; _NumberGenerator4.PrefixString = _StorageParam[i, 14]; _NumberGenerator4.PrefixTag = _StorageParam[i, 15]; _NumberGenerator4.SuffixString = _StorageParam[i, 16]; _NumberGenerator4.NumberGeneratorGroups = _NumberGeneratorGroups; #endregion _Storage.NumberGeneratorOutS = _NumberGenerator4; _Storage.ReportIn = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ReportName='Betárolási bizonylat'")); _Storage.ReportOut = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ReportName='Kitárolási bizonylat'")); _Storage.ReportInventory = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ReportName='Leltár'")); // StorageMoveType generálása string[,] _StorageMoveTypeParam = { { "Normál értékesítés", "0","1" }, { "Normál felhasználás", "1","1" }, { "Leltár (többlet kivezetés)", "3","1" }, { "Leltár (hiány bevételezés)", "3","0" }, { "Selejtezés (kivezetés)", "4","1" }, { "Gyártás (gyártásba kiadás)", "5","1" }, { "Gyártás (gyártásból bevétel)", "5","0" }, { "Raktárközi (átadás)", "6","1" }, { "Raktárközi (fogadás)", "6","0" }, { "Eszköz (kiadás)", "2","1" }, { "Eszköz (visszavétel)", "2","0" }, { "Normál bevételezés", "7","0" }, { "Jóváírás értékesítés", "8","0" }, { "Szállítói visszárú", "9","1" }, { "Egységek közti mozgás (kiadás)", "10","1" }, { "Egységek közti mozgás (bevétel)", "10","0" }, { "Páros korrekció (kiadás)", "11","1" }, { "Páros korrekció (bevétel)", "11","0" } }; for (int j = 0; j < 18; j++) { Session.ExecuteNonQuery("update StorageMoveType set MoveDirection=0 where MoveDirection is null"); StorageMoveType _StorageMoveType = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("Storage=? and MoveType=? and MoveDirection=?", _Storage, _StorageMoveTypeParam[j,1], _StorageMoveTypeParam[j,2])); if (_StorageMoveType == null) { _StorageMoveType = new StorageMoveType(Session); } _StorageMoveType.Storage = _Storage; _StorageMoveType.MoveType = (eMoveType)int.Parse(_StorageMoveTypeParam[j,1]); _StorageMoveType.ShortName = _StorageMoveTypeParam[j,0]; _StorageMoveType.MoveDirection = (eMoveDirection)int.Parse(_StorageMoveTypeParam[j, 2]); } } } private void GenerateDeliveryNoteIn() { string[,] _DeliveryNoteInTypeParam = { {"Szállítólevél (belföldi ÁFÁ-s)","0","true","false","BE-SZLEV-0","-","-" }, {"Szállítólevél (EU-ból ÁFÁ-s)","1","true","false","BE-SZLEV-1","-","-" }, {"Szállítólevél (EU-ból nem ÁFÁ-s)","2","true","false","BE-SZLEV-2","-","-" }, {"Szállítólevél (EU-n kívül nem ÁFÁ-s)","3","true","false","BE-SZLEV-3","-","-" } }; for (int i = 0; i < 4; i++) { DeliveryNoteInType _DeliveryNoteInType = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName=?", _DeliveryNoteInTypeParam[i, 0])); if (_DeliveryNoteInType==null) { _DeliveryNoteInType = new DeliveryNoteInType(Session); } #region NumberGenerator NumberGenerator _NumberGenerator = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName=?", _DeliveryNoteInTypeParam[i, 0])); if (_NumberGenerator == null) { _NumberGenerator = new NumberGenerator(Session); } _NumberGenerator.ShortName = _DeliveryNoteInTypeParam[i, 0]; _NumberGenerator.PrefixString = _DeliveryNoteInTypeParam[i, 4]; _NumberGenerator.PrefixTag = _DeliveryNoteInTypeParam[i, 5]; _NumberGenerator.SuffixString = _DeliveryNoteInTypeParam[i, 6]; NumberGeneratorGroups _NumberGeneratorGroups = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='Üzleti tranzakciók paraméterei'")); if (_NumberGeneratorGroups == null) { _NumberGeneratorGroups = new NumberGeneratorGroups(Session); _NumberGeneratorGroups.ShortName = "Üzleti tranzakciók paraméterei"; _NumberGeneratorGroups.Description = "Üzleti tranzakciók paraméterei"; } _NumberGenerator.NumberGeneratorGroups = _NumberGeneratorGroups; #endregion _DeliveryNoteInType.ShortName = _DeliveryNoteInTypeParam[i, 0]; _DeliveryNoteInType.Description = _DeliveryNoteInTypeParam[i, 0]; _DeliveryNoteInType.NumberGenerator = _NumberGenerator; _DeliveryNoteInType.ImportMode = (eImportMode)int.Parse(_DeliveryNoteInTypeParam[i, 1]); _DeliveryNoteInType.CustomersFrom = _CustomersFrom; _DeliveryNoteInType.IsPrice = Boolean.Parse(_DeliveryNoteInTypeParam[i, 2]); _DeliveryNoteInType.IsOrderOut = Boolean.Parse(_DeliveryNoteInTypeParam[i, 3]); _DeliveryNoteInType.RegistryType= Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='Bejővő szállítói számla'")); } } private void GenerateDeliveryNoteOut() { string[,] _DeliveryNoteOutTypeParam = { {"Kimenő szállítólevél","HUF","KI-SZLEV","-","-","true" } }; for (int i = 0; i < 1; i++) { DeliveryNoteOutType _DeliveryNoteOutType = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName=?", _DeliveryNoteOutTypeParam[i, 0])); if (_DeliveryNoteOutType == null) { _DeliveryNoteOutType = new DeliveryNoteOutType(Session); } #region NumberGenerator NumberGenerator _NumberGenerator = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName=?", _DeliveryNoteOutTypeParam[i, 0])); if (_NumberGenerator == null) { _NumberGenerator = new NumberGenerator(Session); } _NumberGenerator.ShortName = _DeliveryNoteOutTypeParam[i, 0]; _NumberGenerator.PrefixString = _DeliveryNoteOutTypeParam[i, 2]; _NumberGenerator.PrefixTag = _DeliveryNoteOutTypeParam[i, 3]; _NumberGenerator.SuffixString = _DeliveryNoteOutTypeParam[i, 4]; NumberGeneratorGroups _NumberGeneratorGroups = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='Üzleti tranzakciók paraméterei'")); if (_NumberGeneratorGroups == null) { _NumberGeneratorGroups = new NumberGeneratorGroups(Session); _NumberGeneratorGroups.ShortName = "Üzleti tranzakciók paraméterei"; _NumberGeneratorGroups.Description = "Üzleti tranzakciók paraméterei"; } _NumberGenerator.NumberGeneratorGroups = _NumberGeneratorGroups; #endregion _DeliveryNoteOutType.ShortName = _DeliveryNoteOutTypeParam[i, 0]; _DeliveryNoteOutType.Description = _DeliveryNoteOutTypeParam[i, 0]; _DeliveryNoteOutType.NumberGenerator = _NumberGenerator; _DeliveryNoteOutType.IsPrice = Boolean.Parse(_DeliveryNoteOutTypeParam[i, 5]); _DeliveryNoteOutType.CurrencyName = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName=?",_DeliveryNoteOutTypeParam[i,1])); _DeliveryNoteOutType.ReportDataV2 = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("DisplayName='Kimenő szállítólevél'")); } } private void GenerateOrderIn() { string[,] _OrderInParam = { {"Bejövő megrendelés HUF","HUF","HUF","1. Raktár", "91 BELFÖLDI ÉRTÉKESÍTÉS ÁRBEVÉTELE", "453 Vevőktől kapott előlegek", "91 BELFÖLDI ÉRTÉKESÍTÉS ÁRBEVÉTELE", "BE-MGR","-","-","true","0", "Bejövő megrendelés visszaigazolása", "BE-MGR-IG","-","-", "Kimenő vevői számla","Kimenő vevői előlegszámla" } }; for (int i = 0; i < 1; i++) { OrderInParameters _OrderInParameters = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName=?",_OrderInParam[i,0])); if (_OrderInParameters==null) { _OrderInParameters = new OrderInParameters(Session); } _OrderInParameters.CustomersFrom = _CustomersFrom; _OrderInParameters.ShortName = _OrderInParam[i, 0]; _OrderInParameters.Description = _OrderInParam[i, 0]; _OrderInParameters.StorageMoveType = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("Storage.ShortName=? and ShortName='Normál értékesítés'", _OrderInParam[i, 3])); _OrderInParameters.CurrencyName = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName=?", _OrderInParam[i,1])); _OrderInParameters.CurrencyName_Invoice = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName=?", _OrderInParam[i, 2])); _OrderInParameters.Controlling_Rows_Default = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("Name=?", _OrderInParam[i, 4])); _OrderInParameters.Controlling_InvoiceAdvance_Default = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("Name=?", _OrderInParam[i, 5])); _OrderInParameters.Controlling_OtherRows_Default = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("Name=?", _OrderInParam[i, 6])); _OrderInParameters.InvoiceType = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName=?", _OrderInParam[i, 16])); _OrderInParameters.InvoiceTypeAdvanced = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName=?", _OrderInParam[i, 17])); _OrderInParameters.BankInformation = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("AccountNumber=?",_Bank_AccountNumber)); _OrderInParameters.ExportMode = (eExportMode)int.Parse(_OrderInParam[i, 11]); #region NumberGenerator NumberGenerator _NumberGenerator = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName=?", _OrderInParam[i, 0])); if (_NumberGenerator == null) { _NumberGenerator = new NumberGenerator(Session); } _NumberGenerator.ShortName = _OrderInParam[i, 0]; _NumberGenerator.PrefixString = _OrderInParam[i, 7]; _NumberGenerator.PrefixTag = _OrderInParam[i, 8]; _NumberGenerator.SuffixString = _OrderInParam[i, 9]; NumberGeneratorGroups _NumberGeneratorGroups = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='Üzleti tranzakciók paraméterei'")); if (_NumberGeneratorGroups == null) { _NumberGeneratorGroups = new NumberGeneratorGroups(Session); _NumberGeneratorGroups.ShortName = "Üzleti tranzakciók paraméterei"; _NumberGeneratorGroups.Description = "Üzleti tranzakciók paraméterei"; } _NumberGenerator.NumberGeneratorGroups = _NumberGeneratorGroups; #endregion _OrderInParameters.NumberGenerator = _NumberGenerator; #region NumberGeneratorAcknowledgement _NumberGenerator = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName=?", _OrderInParam[i, 12])); if (_NumberGenerator == null) { _NumberGenerator = new NumberGenerator(Session); } _NumberGenerator.ShortName = _OrderInParam[i, 12]; _NumberGenerator.PrefixString = _OrderInParam[i, 13]; _NumberGenerator.PrefixTag = _OrderInParam[i, 14]; _NumberGenerator.SuffixString = _OrderInParam[i, 15]; _NumberGenerator.NumberGeneratorGroups = _NumberGeneratorGroups; #endregion _OrderInParameters.NumberGeneratorAcknowledgement = _NumberGenerator; _OrderInParameters.ReportDataAcknowledgement = null; } } private void GenerateOfferOut() { OfferOutParameters _OfferOutParameters = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='Kimenő árajánlat paraméter'")); if (_OfferOutParameters == null) { _OfferOutParameters = new OfferOutParameters(Session); } _OfferOutParameters.CustomersFrom = _CustomersFrom; _OfferOutParameters.OfferOutMainType = eOfferOutMainType.eFromProducts; _OfferOutParameters.OfferOutMainType2 = eOfferOutMainType2.eOfferDetail; _OfferOutParameters.ShortName = "Kimenő árajánlat paraméter"; #region NumberGenerator NumberGenerator _NumberGenerator = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName=?", "Kimenő árajánlat paraméter")); if (_NumberGenerator == null) { _NumberGenerator = new NumberGenerator(Session); } _NumberGenerator.ShortName = "Kimenő árajánlat paraméter"; _NumberGenerator.PrefixString = "KI-AJ"; _NumberGenerator.PrefixTag = "-"; _NumberGenerator.SuffixString = "-"; NumberGeneratorGroups _NumberGeneratorGroups = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName=?", "Üzleti tranzakciók paraméterei")); if (_NumberGeneratorGroups == null) { _NumberGeneratorGroups = new NumberGeneratorGroups(Session); _NumberGeneratorGroups.ShortName = "Üzleti tranzakciók paraméterei"; _NumberGeneratorGroups.Description = "Üzleti tranzakciók paraméterei"; } _NumberGenerator.NumberGeneratorGroups = _NumberGeneratorGroups; #endregion _OfferOutParameters.NumberGenerator = _NumberGenerator; _OfferOutParameters.IsGenerateNumber_First = true; _OfferOutParameters.Description = "Kimenő árajánlat paraméter"; _OfferOutParameters.ReportData = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ReportName='Kimenő árajánlat'")); _OfferOutParameters.ReportData1 = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ReportName='Kimenő árajánlat (ár nélkül)'")); } private void GenerateBankCassaCompensation() { #region Bank LiquidAssets _LiquidAssets = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName=? and LiquidAssetsType=1 and CustomerFrom=?", Bank_ShortName,_CustomersFrom)); if (_LiquidAssets==null) { _LiquidAssets = new LiquidAssets(Session); } _LiquidAssets.Active = true; _LiquidAssets.CurrencyName= Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='HUF'")); _LiquidAssets.LiquidAssetsType = eLiquidAssetsType.NormalBank; _LiquidAssets.CustomerFrom = _CustomersFrom; _LiquidAssets.ShortName = Bank_ShortName; _LiquidAssets.Description = Bank_ShortName; _LiquidAssets.IsRounding = false; LiquidAssetsYear _LiquidAssetsYear=Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("LiquidAssets=?", _LiquidAssets)); if (_LiquidAssetsYear == null) { _LiquidAssetsYear = new LiquidAssetsYear(Session); } _LiquidAssetsYear.LiquidAssets = _LiquidAssets; _LiquidAssetsYear.AccountYear = DateTime.Now.Year; _LiquidAssetsYear.ChartOfAccounts = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("AccountYear=? and AccountNumber='384'", _LiquidAssetsYear.AccountYear)); BankInformation _BankInformation=Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction,CriteriaOperator.Parse("LiquidAssests=?", _LiquidAssets)); if (_BankInformation == null) { _BankInformation = new BankInformation(Session); } _BankInformation.LiquidAssests = _LiquidAssets; _BankInformation.AccountNumber = Bank_AccountNumber; _BankInformation.CurrencyName = _LiquidAssets.CurrencyName; _BankInformation.IBAN = Bank_IBAN; _BankInformation.SWIFT = Bank_SWIFT; CustomerBankAccounts _CustomerBankAccounts=Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("Customers.Oid=? and AccountNumber=?", _CustomersFrom.Oid,_BankInformation.AccountNumber)); if (_CustomerBankAccounts == null) { _CustomerBankAccounts = new CustomerBankAccounts(Session); } _CustomerBankAccounts.Customers = (CustomersFrom)_CustomersFrom; _CustomerBankAccounts.AccountNumber = _BankInformation.AccountNumber; _CustomerBankAccounts.AutomaticProcessing = false; _CustomerBankAccounts.IBAN = _BankInformation.IBAN; _CustomerBankAccounts.ShortName = _BankInformation.LiquidAssests.ShortName; #endregion #region Cassa _LiquidAssets = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='Fő pénztár' and LiquidAssetsType=0 and CustomerFrom=?",_CustomersFrom)); if (_LiquidAssets == null) { _LiquidAssets = new LiquidAssets(Session); } _LiquidAssets.Active = true; _LiquidAssets.CurrencyName = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='HUF'")); _LiquidAssets.LiquidAssetsType = eLiquidAssetsType.NormalCheckout; _LiquidAssets.CustomerFrom = _CustomersFrom; _LiquidAssets.ShortName = "Fő pénztár"; _LiquidAssets.Description = "Fő pénztár"; _LiquidAssets.IsRounding = true; NumberGeneratorGroups _NumberGeneratorGroups = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName=?", "Pénzügyi sorszámok")); if (_NumberGeneratorGroups == null) { _NumberGeneratorGroups = new NumberGeneratorGroups(Session); _NumberGeneratorGroups.ShortName = "Pénzügyi sorszámok"; _NumberGeneratorGroups.Description = "Pénzügyi sorszámok"; } NumberGenerator _NumberGeneratorIn= Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction,CriteriaOperator.Parse("ShortName='Befizetési pénztárbizonylat fő pénztár'")); if (_NumberGeneratorIn ==null) { _NumberGeneratorIn = new NumberGenerator(Session); } _NumberGeneratorIn.ShortName = "Befizetési pénztárbizonylat fő pénztár"; _NumberGeneratorIn.PrefixString = "BEF-FŐ"; _NumberGeneratorIn.PrefixTag = "-"; _NumberGeneratorIn.SuffixString = "-"; _NumberGeneratorIn.NumberGeneratorGroups = _NumberGeneratorGroups; NumberGenerator _NumberGeneratorOut = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='Kifizetési pénztárbizonylat fő pénztár'")); if (_NumberGeneratorOut == null) { _NumberGeneratorOut = new NumberGenerator(Session); } _NumberGeneratorOut.ShortName = "Kifizetési pénztárbizonylat fő pénztár"; _NumberGeneratorOut.PrefixString = "KIF-FŐ"; _NumberGeneratorOut.PrefixTag = "-"; _NumberGeneratorOut.SuffixString = "-"; _NumberGeneratorOut.NumberGeneratorGroups = _NumberGeneratorGroups; _LiquidAssets.NumberGeneratorIn = _NumberGeneratorIn; _LiquidAssets.NumberGeneratorOut = _NumberGeneratorOut; _LiquidAssets.ReportDataV2 = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("DisplayName='Pénztári bizonylat'")); _LiquidAssets.ReportData = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ReportName='Pénztári bizonylat'")); _LiquidAssets.ReportData_Return = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ReportName='Időszaki pénztárösszesítő'")); _LiquidAssetsYear = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("LiquidAssets=?", _LiquidAssets)); if (_LiquidAssetsYear == null) { _LiquidAssetsYear = new LiquidAssetsYear(Session); } _LiquidAssetsYear.LiquidAssets = _LiquidAssets; _LiquidAssetsYear.AccountYear = DateTime.Now.Year; _LiquidAssetsYear.ChartOfAccounts = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("AccountYear=? and AccountNumber='3811'", _LiquidAssetsYear.AccountYear)); _LiquidAssetsYear.ChartOfAccountsPlus = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("AccountYear=? and AccountNumber='9662'", _LiquidAssetsYear.AccountYear)); _LiquidAssetsYear.ChartOfAccountsMinus = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("AccountYear=? and AccountNumber='8662'", _LiquidAssetsYear.AccountYear)); #endregion #region Compensation //COMPENSATION _LiquidAssets = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName=? and LiquidAssetsType=3 and CustomerFrom=?", "Kompenzáció", _CustomersFrom)); if (_LiquidAssets == null) { _LiquidAssets = new LiquidAssets(Session); } _LiquidAssets.Active = true; _LiquidAssets.CurrencyName = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='HUF'")); _LiquidAssets.LiquidAssetsType = eLiquidAssetsType.Compensatory; _LiquidAssets.CustomerFrom = _CustomersFrom; _LiquidAssets.ShortName = "Kompenzáció"; _LiquidAssets.Description = "Kompenzáció"; _LiquidAssets.IsRounding = false; NumberGenerator _NumberGeneratorCompensation = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='Kompenzáció'")); if (_NumberGeneratorCompensation == null) { _NumberGeneratorCompensation = new NumberGenerator(Session); } _NumberGeneratorCompensation.ShortName = "Kompenzáció"; _NumberGeneratorCompensation.PrefixString = "KOMP"; _NumberGeneratorCompensation.PrefixTag = "-"; _NumberGeneratorCompensation.SuffixString = "-"; _NumberGeneratorCompensation.NumberGeneratorGroups = _NumberGeneratorGroups; _LiquidAssets.NumberGeneratorIn = _NumberGeneratorCompensation; _LiquidAssets.NumberGeneratorOut = _NumberGeneratorCompensation; _LiquidAssets.ReportDataV2 = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("DisplayName='Kompenzációs bizonylat'")); _LiquidAssets.ReportData = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ReportName='Kompenzációs bizonylat'")); _LiquidAssetsYear = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("LiquidAssets=?", _LiquidAssets)); if (_LiquidAssetsYear == null) { _LiquidAssetsYear = new LiquidAssetsYear(Session); } _LiquidAssetsYear.LiquidAssets = _LiquidAssets; _LiquidAssetsYear.AccountYear = DateTime.Now.Year; _LiquidAssetsYear.ChartOfAccounts = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("AccountYear=? and AccountNumber='389'", _LiquidAssetsYear.AccountYear)); #endregion #region Mixed GLMixedNG _GLMixedNG = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("_CustomersFrom=?", _CustomersFrom)); if (_GLMixedNG == null) { _GLMixedNG = new GLMixedNG(Session); } _GLMixedNG.CustomersFrom = _CustomersFrom; NumberGenerator _NG= Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='Vegyes könyvelési bizonylat'")); if (_NG == null) { _NG = new NumberGenerator(Session); } _NG.ShortName = "Vegyes könyvelési bizonylat"; _NG.PrefixString = "VN"; _NG.PrefixTag = "-"; _NG.SuffixString = "-"; _NG.NumberGeneratorGroups = _NumberGeneratorGroups; _GLMixedNG.NumberGenerator = _NG; _NG = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='Vegyes könyvelési bizonylat (árfolyam)'")); if (_NG == null) { _NG = new NumberGenerator(Session); } _NG.ShortName = "Vegyes könyvelési bizonylat (árfolyam)"; _NG.PrefixString = "VN-ÁRF"; _NG.PrefixTag = "-"; _NG.SuffixString = "-"; _NG.NumberGeneratorGroups = _NumberGeneratorGroups; _GLMixedNG.NumberGenerator_RateDiff = _NG; _NG = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='Vegyes könyvelési bizonylat (átértékelés)'")); if (_NG == null) { _NG = new NumberGenerator(Session); } _NG.ShortName = "Vegyes könyvelési bizonylat (átértékelés)"; _NG.PrefixString = "VN-ÁTÉRT"; _NG.PrefixTag = "-"; _NG.SuffixString = "-"; _NG.NumberGeneratorGroups = _NumberGeneratorGroups; _GLMixedNG.NumberGenerator_Revaluation = _NG; _NG = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='Vegyes könyvelési bizonylat (elengedés)'")); if (_NG == null) { _NG = new NumberGenerator(Session); } _NG.ShortName = "Vegyes könyvelési bizonylat (elengedés)"; _NG.PrefixString = "VN-ELENG"; _NG.PrefixTag = "-"; _NG.SuffixString = "-"; _NG.NumberGeneratorGroups = _NumberGeneratorGroups; _GLMixedNG.NumberGenerator_Rounding = _NG; _NG = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='Vegyes könyvelési bizonylat (kamatlevél)'")); if (_NG == null) { _NG = new NumberGenerator(Session); } _NG.ShortName = "Vegyes könyvelési bizonylat (kamatlevél)"; _NG.PrefixString = "VN-KLV"; _NG.PrefixTag = "-"; _NG.SuffixString = "-"; _NG.NumberGeneratorGroups = _NumberGeneratorGroups; _GLMixedNG.NumberGenerator_LateCharges = _NG; #endregion } private void GenerateReports() { string[,] _ReportDataParameters = { { "Vevői számla ÁFA", "Nuvolar.Module.Repx.rptInvoiceSubreport.repx", "Nuvolar.Module.InvoiceVATRows,Nuvolar.Module" }, { "Vevői számla", "Nuvolar.Module.Repx.rptInvoice.repx", "Nuvolar.Module.InvoiceRows,Nuvolar.Module" }, { "Etikett", "Nuvolar.Module.Repx.rptEtikett.repx", "Nuvolar.Module.ProductsBarcodes,Nuvolar.Module" }, { "Felszólítás-felmondás", "Nuvolar.Module.Repx.rptFinancialAbort.repx", "Nuvolar.Module.LiquidAssetsReturnRows,Nuvolar.Module" }, { "Felszólítás-figyelmeztetés", "Nuvolar.Module.Repx.rptFinancialAlert.repx", "Nuvolar.Module.LiquidAssetsReturnRows,Nuvolar.Module" }, { "Felszólítás-alriport", "Nuvolar.Module.Repx.rptFinancialSubreport.repx", "Nuvolar.Module.LiquidAssetsReturnRows,Nuvolar.Module" }, { "Felszólítás-emlékeztető", "Nuvolar.Module.Repx.rptFinancialWarning.repx", "Nuvolar.Module.LiquidAssetsReturnRows,Nuvolar.Module" }, { "Időszaki pénztárösszesítő", "Nuvolar.Module.Repx.rptCassareport.repx", "Nuvolar.Module.LiquidAssetsReturnRows,Nuvolar.Module" }, { "Pénztári bizonylat", "Nuvolar.Module.Repx.rptCassa.repx", "Nuvolar.Module.GLRows,Nuvolar.Module" }, { "Kompenzációs bizonylat","Nuvolar.Module.Repx.rptCompensation.repx","Nuvolar.Module.GLRows,Nuvolar.Module" }, { "Kimenő árajánlat ÁFA","Nuvolar.Module.Repx.rptOfferOutSubreport.repx","Nuvolar.Module.OfferOutVATRows,Nuvolar.Module" }, { "Kimenő árajánlat (ár nélkül)","Nuvolar.Module.Repx.rptOfferOutNoprice.repx","Nuvolar.Module.OfferOutRows,Nuvolar.Module" }, { "Kimenő árajánlat","Nuvolar.Module.Repx.rptOfferOut.repx","Nuvolar.Module.OfferOutRows,Nuvolar.Module" }, { "Kimenő szállítólevél","Nuvolar.Module.Repx.rptDeliveryNoteOut.repx","Nuvolar.Module.DeliveryNoteOutRows,Nuvolar.Module" }, { "Betárolási bizonylat","Nuvolar.Module.Repx.rptStorageIn.repx","Nuvolar.Module.StorageInRows,Nuvolar.Module" }, { "Kitárolási bizonylat","Nuvolar.Module.Repx.rptStorageOut.repx","Nuvolar.Module.StorageOutRowsInRows,Nuvolar.Module" }, { "Leltár","Nuvolar.Module.Repx.rptInventory.repx","Nuvolar.Module.InventorySC,Nuvolar.Module" } }; for (int i = 0; i < 17; i++) { ReportData _ReportDataSubReport = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ReportName=?",_ReportDataParameters[i,0])); if (_ReportDataSubReport == null) { _ReportDataSubReport = new ReportData(Session, Type.GetType(_ReportDataParameters[i, 2])); } StreamReader _textStreamReader; string _StrBuffer; Assembly _assembly = Assembly.GetExecutingAssembly(); _textStreamReader = new StreamReader(_assembly.GetManifestResourceStream(_ReportDataParameters[i, 1])); _StrBuffer = _textStreamReader.ReadToEnd(); _ReportDataSubReport.SetMemberValue("Content", System.Text.Encoding.UTF8.GetBytes(_StrBuffer)); _ReportDataSubReport.ReportName = _ReportDataParameters[i, 0]; _ReportDataSubReport.IsInplaceReport = false; } } private void GenerateReportsV2() { string[,] _ReportDataParameters = { { "Vevői számla ÁFA", "Nuvolar.Module.Repx.rptInvoiceSubreport.repx", "Nuvolar.Module.InvoiceVATRows,Nuvolar.Module" }, { "Vevői számla", "Nuvolar.Module.Repx.rptInvoice.repx", "Nuvolar.Module.InvoiceRows,Nuvolar.Module" }, { "Etikett", "Nuvolar.Module.Repx.rptEtikett.repx", "Nuvolar.Module.ProductsBarcodes,Nuvolar.Module" }, { "Felszólítás-felmondás", "Nuvolar.Module.Repx.rptFinancialAbort.repx", "Nuvolar.Module.LiquidAssetsReturnRows,Nuvolar.Module" }, { "Felszólítás-figyelmeztetés", "Nuvolar.Module.Repx.rptFinancialAlert.repx", "Nuvolar.Module.LiquidAssetsReturnRows,Nuvolar.Module" }, { "Felszólítás-alriport", "Nuvolar.Module.Repx.rptFinancialSubreport.repx", "Nuvolar.Module.LiquidAssetsReturnRows,Nuvolar.Module" }, { "Felszólítás-emlékeztető", "Nuvolar.Module.Repx.rptFinancialWarning.repx", "Nuvolar.Module.LiquidAssetsReturnRows,Nuvolar.Module" }, { "Időszaki pénztárösszesítő", "Nuvolar.Module.Repx.rptCassareport.repx", "Nuvolar.Module.LiquidAssetsReturnRows,Nuvolar.Module" }, { "Pénztári bizonylat", "Nuvolar.Module.Repx.rptCassa.repx", "Nuvolar.Module.GLRows,Nuvolar.Module" }, { "Kompenzációs bizonylat","Nuvolar.Module.Repx.rptCompensation.repx","Nuvolar.Module.GLRows,Nuvolar.Module" }, { "Kimenő árajánlat ÁFA","Nuvolar.Module.Repx.rptOfferOutSubreport.repx","Nuvolar.Module.OfferOutVATRows,Nuvolar.Module" }, { "Kimenő árajánlat (ár nélkül)","Nuvolar.Module.Repx.rptOfferOutNoprice.repx","Nuvolar.Module.OfferOutRows,Nuvolar.Module" }, { "Kimenő árajánlat","Nuvolar.Module.Repx.rptOfferOut.repx","Nuvolar.Module.OfferOutRows,Nuvolar.Module" }, { "Kimenő szállítólevél","Nuvolar.Module.Repx.rptDeliveryNoteOut.repx","Nuvolar.Module.DeliveryNoteOutRows,Nuvolar.Module" }, { "Betárolási bizonylat","Nuvolar.Module.Repx.rptStorageIn.repx","Nuvolar.Module.StorageInRows,Nuvolar.Module" }, { "Kitárolási bizonylat","Nuvolar.Module.Repx.rptStorageOut.repx","Nuvolar.Module.StorageOutRowsInRows,Nuvolar.Module" }, { "Leltár","Nuvolar.Module.Repx.rptInventory.repx","Nuvolar.Module.InventorySC,Nuvolar.Module" } }; for (int i = 0; i < 17; i++) { ReportDataV2 _ReportDataSubReport = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("DisplayName=?", _ReportDataParameters[i, 0])); if (_ReportDataSubReport == null) { _ReportDataSubReport = new ReportDataV2(Session, Type.GetType(_ReportDataParameters[i, 2])); } StreamReader _textStreamReader; string _StrBuffer; Assembly _assembly = Assembly.GetExecutingAssembly(); _textStreamReader = new StreamReader(_assembly.GetManifestResourceStream(_ReportDataParameters[i, 1])); _StrBuffer = _textStreamReader.ReadToEnd(); _ReportDataSubReport.SetMemberValue("Content", System.Text.Encoding.UTF8.GetBytes(_StrBuffer)); _ReportDataSubReport.DisplayName = _ReportDataParameters[i, 0]; _ReportDataSubReport.IsInplaceReport = false; } } private void GenerateInvoiceType() { string[,] _InvoiceTypeTypeParam = { { "2","Kimenő vevői számla", "Számla sorszámok","SZLA","-","-","Vevői számla","Kimenő vevői proforma számla","PROF","-","-","91 BELFÖLDI ÉRTÉKESÍTÉS ÁRBEVÉTELE" }, { "1","Kimenő vevői előlegszámla", "Számla sorszámok","SZLE","-","-","Vevői számla","Kimenő vevői proforma számla","PROF","-","-","453 Vevőktől kapott előlegek"}}; for (int i = 0; i < 2; i++) { InvoiceType _InvoiceType= Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName=? and CustomersFrom=?", _InvoiceTypeTypeParam[i, 1],_CustomersFrom)); if (_InvoiceType == null) { _InvoiceType = new InvoiceType(Session); } _InvoiceType.InvoiceTypeBase = (eInvoiceTypeBase)int.Parse(_InvoiceTypeTypeParam[i, 0]); _InvoiceType.ShortName = _InvoiceTypeTypeParam[i, 1]; _InvoiceType.CustomersFrom = _CustomersFrom; _InvoiceType.CustomerBankAccounts = _CustomersFrom.CustomerBankAccounts[0]; #region NumberGenerator NumberGenerator _NumberGenerator = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName=?", _InvoiceTypeTypeParam[i, 1])); if (_NumberGenerator == null) { _NumberGenerator = new NumberGenerator(Session); } _NumberGenerator.ShortName = _InvoiceTypeTypeParam[i, 1]; _NumberGenerator.PrefixString = _InvoiceTypeTypeParam[i, 3]; _NumberGenerator.PrefixTag = _InvoiceTypeTypeParam[i, 4]; _NumberGenerator.SuffixString = _InvoiceTypeTypeParam[i, 5]; NumberGeneratorGroups _NumberGeneratorGroups = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName=?", _InvoiceTypeTypeParam[i,2])); if (_NumberGeneratorGroups == null) { _NumberGeneratorGroups = new NumberGeneratorGroups(Session); _NumberGeneratorGroups.ShortName = _InvoiceTypeTypeParam[i, 2]; _NumberGeneratorGroups.Description = _InvoiceTypeTypeParam[i, 2]; } _NumberGenerator.NumberGeneratorGroups = _NumberGeneratorGroups; #endregion _InvoiceType.NumberGenerator = _NumberGenerator; #region NumberGeneratorProforma _NumberGenerator = null; if (_InvoiceTypeTypeParam[i,7]!="") { _NumberGenerator = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName=?", _InvoiceTypeTypeParam[i, 7])); if (_NumberGenerator == null) { _NumberGenerator = new NumberGenerator(Session); } _NumberGenerator.ShortName = _InvoiceTypeTypeParam[i, 7]; _NumberGenerator.PrefixString = _InvoiceTypeTypeParam[i, 8]; _NumberGenerator.PrefixTag = _InvoiceTypeTypeParam[i, 9]; _NumberGenerator.SuffixString = _InvoiceTypeTypeParam[i, 10]; _NumberGeneratorGroups = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName=?", _InvoiceTypeTypeParam[i,2])); if (_NumberGeneratorGroups == null) { _NumberGeneratorGroups = new NumberGeneratorGroups(Session); _NumberGeneratorGroups.ShortName = _InvoiceTypeTypeParam[i, 2]; _NumberGeneratorGroups.Description = _InvoiceTypeTypeParam[i, 2]; } _NumberGenerator.NumberGeneratorGroups = _NumberGeneratorGroups; } #endregion _InvoiceType.NumberGeneratorProforma = _NumberGenerator; _InvoiceType.ReportDataV2 = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction,CriteriaOperator.Parse("DisplayName=?",_InvoiceTypeTypeParam[i, 6])); _InvoiceType.WorkflowSystem = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction,CriteriaOperator.Parse("ShortName=?", "Kimenő vevői számla")); _InvoiceType.ControllingDefault = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction,CriteriaOperator.Parse("Name=?", _InvoiceTypeTypeParam[i, 11])); } } private void GenerateRegistryType() { string[,] _RegistryTypeParam = { { "Bejővő szállítói számla", "0","0","-1","IKT-BE-SZLA","-" }, { "Bejővő szállítói előleg bekérő", "3","0","-1","IKT-BE-EBK","-" }, { "Bejővő szállítói előleg számla", "2","0","-1","IKT-BE-ESZLA","-" }, { "Bejövő levelek", "1","0","-1","IKT-BE-LEV","-" }, { "Kimenő levelek", "1","1","-1","IKT-KI-LEV","-" }}; for (int i = 0; i < 5; i++) { NumberGenerator _NumberGenerator = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName=?", _RegistryTypeParam[i, 0])); if (_NumberGenerator==null) { _NumberGenerator = new NumberGenerator(Session); } _NumberGenerator.ShortName = _RegistryTypeParam[i, 0]; _NumberGenerator.PrefixString = _RegistryTypeParam[i, 4]; _NumberGenerator.PrefixTag = _RegistryTypeParam[i, 5]; _NumberGenerator.SuffixString = _RegistryTypeParam[i, 5]; NumberGeneratorGroups _NumberGeneratorGroups= Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName=?", "Iktatási sorszámok")); if (_NumberGeneratorGroups == null) { _NumberGeneratorGroups = new NumberGeneratorGroups(Session); _NumberGeneratorGroups.ShortName = "Iktatási sorszámok"; _NumberGeneratorGroups.Description = "Iktatási sorszámok"; } _NumberGenerator.NumberGeneratorGroups = _NumberGeneratorGroups; RegistryType _RegistryType = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName=?", _RegistryTypeParam[i, 0])); if (_RegistryType ==null) { _RegistryType = new RegistryType(Session); } _RegistryType.ShortName = _RegistryTypeParam[i, 0]; _RegistryType.NumberGenerator = _NumberGenerator; _RegistryType.CustomersFrom = _CustomersFrom; _RegistryType.RegistryMainType = (eRegistryMainType)int.Parse(_RegistryTypeParam[i, 1]); _RegistryType.RegistryDirection = (eRegistryDirection)int.Parse(_RegistryTypeParam[i, 2]); _RegistryType.RegistryCRMType = (eRegistryCRMType)int.Parse(_RegistryTypeParam[i, 3]); _RegistryType.AutomaticSetResponsible = true; _RegistryType.WorkflowSystem = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName=?", _RegistryTypeParam[i, 0])); } #region TechnicalContractTemplate ContractTemplate _ContractTemplate = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName='Technikai szerződés sablon' and IsTechnical=True")); if (_ContractTemplate==null) { _ContractTemplate = new ContractTemplate(Session); } _ContractTemplate.CustomersFrom = _CustomersFrom; _ContractTemplate.ShortName = "Technikai szerződés sablon"; _ContractTemplate.PartnerType = ePartnerType.ePayabels; _ContractTemplate.IsTechnical = true; _ContractTemplate.IsCRM = false; NumberGenerator _NumberGeneratorT = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName=?", "Technikai szerződés sablon")); if (_NumberGeneratorT == null) { _NumberGeneratorT = new NumberGenerator(Session); } _NumberGeneratorT.ShortName = "Technikai szerződés sablon"; _NumberGeneratorT.PrefixString = "TECH-SZS"; _NumberGeneratorT.PrefixTag = "-"; _NumberGeneratorT.SuffixString = "-"; NumberGeneratorGroups _NumberGeneratorGroupsT = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName=?", "Szerződés sorszámok")); if (_NumberGeneratorGroupsT == null) { _NumberGeneratorGroupsT = new NumberGeneratorGroups(Session); _NumberGeneratorGroupsT.ShortName = "Szerződés sorszámok"; _NumberGeneratorGroupsT.Description = "Szerződés sorszámok"; } _NumberGeneratorT.NumberGeneratorGroups = _NumberGeneratorGroupsT; _ContractTemplate.NumberGenerator = _NumberGeneratorT; #endregion } private void GenerateWorkflowSystem() { string[,] _WorkflowSystemParam = { { "Bejővő szállítói számla", "1" }, { "Kimenő vevői számla", "0" }, { "Bejövő levelek", "1" }, { "Kimenő levelek", "0" }, { "Bejővő szállítói előleg bekérő", "1" }, { "Bejővő szállítói előleg számla" ,"1"} }; string[,,] _WorkflowSystemStepParam = { { {"1","1. Számla iktatása + ÁFA + kontír","5","false","false"},{ "2", "2. Számla könyvelése", "5", "true","true" } }, { {"1","1. Számla kiállítás + könyvelés", "4", "true", "true" }, {"-1","","","","" } }, { {"1","1. Levél iktatása","0","false","false"}, { "2", "2. Levél irattározása", "0", "true","true" } }, { {"1","1. Levél iktatása","0","false","false"},{ "2", "2. Levél irattározása", "0", "true","true" } }, { {"1","1. Előlegbekérő iktatása","0","false","false"},{ "2", "2. Jóváhagyás utalásra", "0", "true","true" } }, { {"1","1. Számla iktatása + ÁFA + kontír","5","false","false"},{ "2", "2. Számla könyvelése", "5", "true","true" }} }; for (int i = 0; i < 6; i++) { WorkflowSystem _WorkflowSystem = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName=?", _WorkflowSystemParam[i,0])); if (_WorkflowSystem==null) { _WorkflowSystem = new WorkflowSystem(Session); } _WorkflowSystem.CustomersFrom = _CustomersFrom; _WorkflowSystem.ShortName = _WorkflowSystemParam[i, 0]; _WorkflowSystem.PartnerType = (ePartnerType)int.Parse(_WorkflowSystemParam[i, 1]); _WorkflowSystem.Description = _WorkflowSystem.ShortName; for (int j = 0; j < 2; j++) { if (int.Parse(_WorkflowSystemStepParam[i, j, 0])>0) { WorkflowSystemSteps _WorkflowSystemSteps = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName=? and WorkflowSystem=?", _WorkflowSystemStepParam[i, j, 1], _WorkflowSystem)); if (_WorkflowSystemSteps == null) { _WorkflowSystemSteps = new WorkflowSystemSteps(Session); } _WorkflowSystemSteps.WorkflowSystem = _WorkflowSystem; _WorkflowSystemSteps.ShortName = _WorkflowSystemStepParam[i, j, 1]; _WorkflowSystemSteps.TaskDescription = _WorkflowSystemStepParam[i, j, 1]; _WorkflowSystemSteps.StepIndex = int.Parse(_WorkflowSystemStepParam[i, j, 0]); _WorkflowSystemSteps.IsLastStep = bool.Parse(_WorkflowSystemStepParam[i, j, 3]); _WorkflowSystemSteps.IsReadyForImport = bool.Parse(_WorkflowSystemStepParam[i, j, 4]); _WorkflowSystemSteps.StepFinancialType=(eStepFinancialType)int.Parse(_WorkflowSystemStepParam[i, j, 2]); } } } } private void GenerateCustomersFrom() { _CustomersFrom = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("1=1")); if (_CustomersFrom == null) { _CustomersFrom = new CustomersFrom(Session); _CustomersFrom.CustomerNumber = CustomerNumber; _CustomersFrom.Name = FullName; _CustomersFrom.FullName = FullName; _CustomersFrom.CustomersGLParameters = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName=?", "Belföldi")); Address _Address = Session.FindObject
(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("Country=? And City=? And ZipPostal=? And Street=? And StateProvince=?", Country, City, ZipPostal, Street, StateProvince)); if (_Address == null) { _Address = new Address(Session); } _Address.Country = Country; _Address.City = City; _Address.ZipPostal = ZipPostal; _Address.Street = _Street; _Address.StateProvince = StateProvince; _CustomersFrom.Address1 = _Address; _CustomersFrom.IsDefault = true; } } private void GenerateCountry() { XPCollection _Country_Collection = new XPCollection(PersistentCriteriaEvaluationBehavior.InTransaction, Session, CriteriaOperator.Parse("1=1")); if (_Country_Collection.Count == 0) { StreamReader _textStreamReader; string _StrBuffer; Assembly _assembly = Assembly.GetExecutingAssembly(); _textStreamReader = new StreamReader(_assembly.GetManifestResourceStream("Nuvolar.Module.CSV.Country.csv")); _StrBuffer = _textStreamReader.ReadToEnd(); using (TextFieldParser parser = new TextFieldParser(new StringReader(_StrBuffer))) { parser.TextFieldType = Microsoft.VisualBasic.FileIO.FieldType.Delimited; parser.SetDelimiters(";"); WorkEventArgs _WorkEventArgs = new WorkEventArgs { Count = 242, CurrentValue = 1 ,Message ="Országok betöltése ..."}; OnInitWork(_WorkEventArgs); while (!parser.EndOfData) { try { string[] columns = parser.ReadFields(); Country _Country = new Country(Session); _Country.SetMemberValue("ShortName", columns[0].ToString()); _Country.SetMemberValue("Name", columns[1].ToString()); _Country.SetMemberValue("Name_GB", columns[2].ToString()); _WorkEventArgs.CurrentValue += 1; OnDoWork(_WorkEventArgs); } catch (Exception) { throw; } } OnFinalWork(_WorkEventArgs); } } } private void GenerateGIROInfo() { XPCollection _GIROInfo_Collection = new XPCollection(PersistentCriteriaEvaluationBehavior.InTransaction, Session, CriteriaOperator.Parse("1=1")); if (_GIROInfo_Collection.Count == 0) { StreamReader _textStreamReader; string _StrBuffer; Assembly _assembly = Assembly.GetExecutingAssembly(); _textStreamReader = new StreamReader(_assembly.GetManifestResourceStream("Nuvolar.Module.CSV.GIROINFO.csv")); _StrBuffer = _textStreamReader.ReadToEnd(); using (TextFieldParser parser = new TextFieldParser(new StringReader(_StrBuffer))) { parser.TextFieldType = Microsoft.VisualBasic.FileIO.FieldType.Delimited; parser.SetDelimiters(";"); WorkEventArgs _WorkEventArgs = new WorkEventArgs { Count = 4653, CurrentValue = 1 }; OnInitWork(_WorkEventArgs); while (!parser.EndOfData) { try { string[] columns = parser.ReadFields(); GIROInfo _GIROInfo = new GIROInfo(Session); _GIROInfo.GIROID = columns[0]; _GIROInfo.ShortName = columns[1]; _GIROInfo.Address = columns[2]; _GIROInfo.Save(); _WorkEventArgs.CurrentValue += 1; OnDoWork(_WorkEventArgs); } catch (Exception) { throw; } } OnFinalWork(_WorkEventArgs); } } } private void GenerateCustomersGLParameters() { string[] _CustomersGLParametersShortName = { "Belföldi", "Külföldi" }; bool[] _CustomersGLParametersDefaultForBusiness = { true, false}; string[] _CustomersGLParametersAccountNumberIn = { "4541", "311" }; string[] _CustomersGLParametersAccountNumberOut = { "4542", "316" }; for (int i = 0; i < 2; i++) { CustomersGLParameters _CustomersGLParameters = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName=?", _CustomersGLParametersShortName[i])); if (_CustomersGLParameters==null) { _CustomersGLParameters = new CustomersGLParameters(Session); _CustomersGLParameters.ShortName = _CustomersGLParametersShortName[i]; _CustomersGLParameters.DefaultforBusiness = _CustomersGLParametersDefaultForBusiness[i]; _CustomersGLParameters.Save(); CustomersGLParametersYear _CustomersGLParametersYear=Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("CustomersGLParameters=?", _CustomersGLParameters)); if (_CustomersGLParametersYear==null) { _CustomersGLParametersYear = new CustomersGLParametersYear(Session); _CustomersGLParametersYear.AccountYear = DateTime.Now.Year; _CustomersGLParametersYear.CustomersGLParameters = _CustomersGLParameters; _CustomersGLParametersYear.ChartOfAccountsIn= Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("AccountYear=? and AccountNumber=?", _CustomersGLParametersYear.AccountYear, _CustomersGLParametersAccountNumberIn[i])); _CustomersGLParametersYear.ChartOfAccountsOut = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("AccountYear=? and AccountNumber=?", _CustomersGLParametersYear.AccountYear, _CustomersGLParametersAccountNumberOut[i])); _CustomersGLParametersYear.Save(); } } } } private void GenerateUnits() { string[] _UnitsShortNameHUF = { "DB", "ÓRA", "KG", "M", "HÓNAP", "NM", "LITER", "M3","CS","DOB", "GARN","KART","KLT","LIT","REK","TÁL","TAS","TEK","TME","VÖD" }; string[] _UnitsShortNameENG = { "pcs.", "Hour", "kg", "m", "Month", "qm", "Liter", "M3","pack","box", "GARN","KART","KLT","LIT","REK","TÁL","TAS","TEK","TME","VÖD" }; bool[] _UnitsDefaultForBusiness = { true, false, false, false, false, false, false, false, false, false, false, false,false, false, false, false, false, false, false, false}; for (int i = 0; i <20; i++) { Units _Units = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName=?", _UnitsShortNameHUF[i])); if (_Units==null) { _Units = new Units(Session); } _Units.ShortName = _UnitsShortNameHUF[i]; _Units.ShortName_Gb = _UnitsShortNameENG[i]; _Units.DefaultForBusinnes = _UnitsDefaultForBusiness[i]; _Units.Description = _UnitsShortNameHUF[i]; _Units.Save(); } } private void GenerateChartOfAccounts() { XPCollection _ChartOfAccounts_Collection = new XPCollection(PersistentCriteriaEvaluationBehavior.InTransaction,Session, CriteriaOperator.Parse("1=1")); if (_ChartOfAccounts_Collection.Count==0) { ChartOfAccountsYear _ChartOfAccountsYear = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction,CriteriaOperator.Parse("AccountYear=?",DateTime.Now.Year)); if (_ChartOfAccountsYear==null) { _ChartOfAccountsYear = new ChartOfAccountsYear(Session); _ChartOfAccountsYear.AccountYear = DateTime.Now.Year; _ChartOfAccountsYear.IsClosed = false; _ChartOfAccountsYear.Save(); } StreamReader _textStreamReader; string _StrBuffer; Assembly _assembly = Assembly.GetExecutingAssembly(); _textStreamReader = new StreamReader(_assembly.GetManifestResourceStream("Nuvolar.Module.CSV.ChartOfAccounts.csv")); _StrBuffer = _textStreamReader.ReadToEnd(); using (TextFieldParser parser = new TextFieldParser(new StringReader(_StrBuffer))) { parser.TextFieldType = Microsoft.VisualBasic.FileIO.FieldType.Delimited; parser.SetDelimiters(";"); WorkEventArgs _WorkEventArgs = new WorkEventArgs { Count = 682, CurrentValue = 1 }; OnInitWork(_WorkEventArgs); while (!parser.EndOfData) { try { string[] columns = parser.ReadFields(); ChartOfAccounts _ChartOfAccounts = new ChartOfAccounts(Session) { AccountYear = DateTime.Now.Year, AccountNumber = columns[0], Name = string.Format("{0} {1}", columns[0], columns[1]) }; _ChartOfAccounts.Save(); _WorkEventArgs.CurrentValue += 1; OnDoWork(_WorkEventArgs); } catch (Exception) { throw; } } OnFinalWork(_WorkEventArgs); } } } private void GenerateVAT() { string[] _VATShortName = { "27 %", "18 %", "5 %", "0 %","FAD" }; double[] _VATKeyValue = { 0.27,0.18,0.5,0.0,0.0 }; double[] _VATInversKeyValue = { 0.0, 0.0, 0.0, 0.0,0.27 }; bool[] _VATDefaultForBusiness = { true, false, false, false, false }; bool[] _VATInversState = { false, false, false, false, true }; WorkEventArgs _WorkEventArgs = new WorkEventArgs { Count = 5, CurrentValue = 1 }; OnInitWork(_WorkEventArgs); for (int i = 0; i < 5; i++) { OnDoWork(_WorkEventArgs); VAT _VAT = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("ShortName=?",_VATShortName[i])); if (_VAT == null) { _VAT = new VAT(Session); _VAT.DefaultForBusinnes = _VATDefaultForBusiness[i]; _VAT.ShortName = _VATShortName[i]; _VAT.KeyValue = _VATKeyValue[i]; _VAT.InversKeyValue = _VATInversKeyValue[i]; _VAT.ClaimState = true; _VAT.Active = true; _VAT.DefaultForExternalEUNoVAT = false; _VAT.DefaultForExternalOther = false; _VAT.Description = _VATShortName[i]; _VAT.InversState = _VATInversState[i]; } VATYear _VATYear = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("VAT=?", _VAT)); if (_VATYear == null) { _VATYear = new VATYear(Session); _VATYear.AccountYear = DateTime.Now.Year; _VATYear.VAT = _VAT; _VATYear.ChartOfAccountsIn = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("AccountYear=? and AccountNumber=?", _VATYear.AccountYear, "466")); _VATYear.ChartOfAccountsOut = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, CriteriaOperator.Parse("AccountYear=? and AccountNumber=?", _VATYear.AccountYear, "467")); } } OnFinalWork(_WorkEventArgs); } private void GenerateControlling() { XPCollection _Controlling_Collection = new XPCollection(PersistentCriteriaEvaluationBehavior.InTransaction, Session, CriteriaOperator.Parse("1=1")); if (_Controlling_Collection.Count > 0) { return; } XPCollection _ChartOfAccounts_Collection = new XPCollection(PersistentCriteriaEvaluationBehavior.InTransaction,Session, CriteriaOperator.Parse("AccountYear=?", DateTime.Now.Date.Year)); Controlling _Controlling; Controlling _Controlling_Parent; ControllingYear _ControllingYear; _ChartOfAccounts_Collection.Sorting.Add(new SortProperty("AccountNumber", DevExpress.Xpo.DB.SortingDirection.Ascending)); WorkEventArgs _WorkEventArgs = new WorkEventArgs { Count = _ChartOfAccounts_Collection.Count, CurrentValue = 1 }; OnInitWork(_WorkEventArgs); foreach (ChartOfAccounts _ChartOfAccounts in _ChartOfAccounts_Collection) { _Controlling = Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction,CriteriaOperator.Parse("Name=?", _ChartOfAccounts.Name)); if (_Controlling == null) { _Controlling = new Controlling(Session); } _Controlling.Name = _ChartOfAccounts.Name; _Controlling_Parent = null; if (_ChartOfAccounts.Parent != null) { _Controlling_Parent =Session.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction,CriteriaOperator.Parse("Name=?", _ChartOfAccounts.Parent.Name)); } if (_Controlling_Parent != null) { _Controlling.Parent = _Controlling_Parent; } _Controlling.Save(); XPCollection _ControllingYear_Collection = new XPCollection(PersistentCriteriaEvaluationBehavior.InTransaction,Session, CriteriaOperator.Parse("Controlling=?", _Controlling)); if (_ControllingYear_Collection.Count <= 0) { _ControllingYear = new ControllingYear(Session); _ControllingYear.Controlling = _Controlling; _ControllingYear.AccountYear = DateTime.Now.Date.Year; _ControllingYear.ChartOfAccounts = _ChartOfAccounts; _ControllingYear.ChartOfAccounts2 = _ChartOfAccounts; } switch (_ChartOfAccounts.AccountNumber.Substring(0, 1)) { case "5": case "8": _Controlling.Controllingdirection = eControllingDirection.eOut; break; case "9": _Controlling.Controllingdirection = eControllingDirection.eIn; break; default: _Controlling.Controllingdirection = eControllingDirection.eNotSet; break; } _Controlling.Save(); _WorkEventArgs.CurrentValue += 1; OnDoWork(_WorkEventArgs); } OnFinalWork(_WorkEventArgs); } #endregion } }