From b1c2db4f3578bb6f055e558cf8499de2b2295526 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szab=C3=B3=20Iv=C3=A1n?= Date: Fri, 4 Sep 2020 14:36:45 +0200 Subject: [PATCH] =?UTF-8?q?Migr=C3=A1ci=C3=B3=20Debr=C3=A1nak=202.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BusinessObjects/Migration/MigrationLog.cs | 50 + .../Migration/MigrationParameters.cs | 14 + .../Migration/Migration_VC.Designer.cs | 29 + .../BusinessObjects/Migration/Migration_VC.cs | 1242 ++++++++++++++++- .../Migration/Migration_VC.resx | 8 +- .../Model.DesignedDiffs.Localization.hu.xafml | 23 + .../Model.DesignedDiffs.xafml | 3 + .../Nuvolar.Module.CSharp.csproj | 5 + .../Properties/AssemblyInfo.cs | 2 +- .../FinancialTransactions/GLEnums.vb | 5 + 10 files changed, 1364 insertions(+), 17 deletions(-) create mode 100644 Nuvolar.Module.CSharp/BusinessObjects/Migration/MigrationLog.cs diff --git a/Nuvolar.Module.CSharp/BusinessObjects/Migration/MigrationLog.cs b/Nuvolar.Module.CSharp/BusinessObjects/Migration/MigrationLog.cs new file mode 100644 index 0000000..0dc859d --- /dev/null +++ b/Nuvolar.Module.CSharp/BusinessObjects/Migration/MigrationLog.cs @@ -0,0 +1,50 @@ +using System; +using DevExpress.Xpo; +using DevExpress.Persistent.Base; +using DevExpress.Persistent.BaseImpl; + +namespace Nuvolar.Module.BusinessObjects.Migration +{ + [DefaultClassOptions,NavigationItem(false),CreatableItem(false)] + + public class MigrationLog : BaseObject + { + public MigrationLog(Session session) + : base(session) + { + } + public override void AfterConstruction() + { + base.AfterConstruction(); + + } + + private DateTime _DateCreated; + private User _UserCreated; + private string _ShortName; + private string _Description; + + public DateTime DateCreated + { + get { return _DateCreated; } + set { SetPropertyValue(nameof(DateCreated), ref _DateCreated, value); } + } + public User UserCreated + { + get { return _UserCreated; } + set { SetPropertyValue(nameof(UserCreated), ref _UserCreated, value); } + } + public string ShortName + { + get { return _ShortName; } + set { SetPropertyValue(nameof(ShortName), ref _ShortName, value); } + } + [Size(-1)] + public string Description + { + get { return _Description; } + set { SetPropertyValue(nameof(Description), ref _Description, value); } + } + + } +} \ No newline at end of file diff --git a/Nuvolar.Module.CSharp/BusinessObjects/Migration/MigrationParameters.cs b/Nuvolar.Module.CSharp/BusinessObjects/Migration/MigrationParameters.cs index b97261f..5b247bf 100644 --- a/Nuvolar.Module.CSharp/BusinessObjects/Migration/MigrationParameters.cs +++ b/Nuvolar.Module.CSharp/BusinessObjects/Migration/MigrationParameters.cs @@ -34,6 +34,9 @@ namespace Nuvolar.Module.BusinessObjects.Migration private string _SQLPassword; private string _SQLDatabase; + private DateTime _DateFrom; + private DateTime _DateTo; + public string SQLServer { get { return _SQLServer; } @@ -65,5 +68,16 @@ namespace Nuvolar.Module.BusinessObjects.Migration set { SetPropertyValue(nameof(SQLDatabase), ref _SQLDatabase, value); } } + public DateTime DateFrom + { + get { return _DateFrom; } + set { SetPropertyValue(nameof(DateFrom), ref _DateFrom, value); } + } + public DateTime DateTo + { + get { return _DateTo; } + set { SetPropertyValue(nameof(DateTo), ref _DateTo, value); } + } + } } \ No newline at end of file diff --git a/Nuvolar.Module.CSharp/BusinessObjects/Migration/Migration_VC.Designer.cs b/Nuvolar.Module.CSharp/BusinessObjects/Migration/Migration_VC.Designer.cs index 97236ad..f713a53 100644 --- a/Nuvolar.Module.CSharp/BusinessObjects/Migration/Migration_VC.Designer.cs +++ b/Nuvolar.Module.CSharp/BusinessObjects/Migration/Migration_VC.Designer.cs @@ -30,6 +30,8 @@ { this.components = new System.ComponentModel.Container(); this.aMigrateBaseObjects = new DevExpress.ExpressApp.Actions.SimpleAction(this.components); + this.aMigrateInvoiceOut = new DevExpress.ExpressApp.Actions.SimpleAction(this.components); + this.aMigrateInvoiceIn = new DevExpress.ExpressApp.Actions.SimpleAction(this.components); // // aMigrateBaseObjects // @@ -43,14 +45,41 @@ this.aMigrateBaseObjects.TypeOfView = typeof(DevExpress.ExpressApp.DetailView); this.aMigrateBaseObjects.Execute += new DevExpress.ExpressApp.Actions.SimpleActionExecuteEventHandler(this.aMigrateBaseObjects_Execute); // + // aMigrateInvoiceOut + // + this.aMigrateInvoiceOut.Caption = "aMigrate Invoice Out"; + this.aMigrateInvoiceOut.ConfirmationMessage = null; + this.aMigrateInvoiceOut.Id = "aMigrateInvoiceOut"; + this.aMigrateInvoiceOut.TargetObjectType = typeof(Nuvolar.Module.BusinessObjects.Migration.MigrationParameters); + this.aMigrateInvoiceOut.TargetViewNesting = DevExpress.ExpressApp.Nesting.Root; + this.aMigrateInvoiceOut.TargetViewType = DevExpress.ExpressApp.ViewType.DetailView; + this.aMigrateInvoiceOut.ToolTip = null; + this.aMigrateInvoiceOut.TypeOfView = typeof(DevExpress.ExpressApp.DetailView); + this.aMigrateInvoiceOut.Execute += new DevExpress.ExpressApp.Actions.SimpleActionExecuteEventHandler(this.aMigrateInvoiceOut_Execute); + // + // aMigrateInvoiceIn + // + this.aMigrateInvoiceIn.Caption = "aMigrate Invoice In"; + this.aMigrateInvoiceIn.ConfirmationMessage = null; + this.aMigrateInvoiceIn.Id = "aMigrateInvoiceIn"; + this.aMigrateInvoiceIn.TargetObjectType = typeof(Nuvolar.Module.BusinessObjects.Migration.MigrationParameters); + this.aMigrateInvoiceIn.TargetViewNesting = DevExpress.ExpressApp.Nesting.Root; + this.aMigrateInvoiceIn.TargetViewType = DevExpress.ExpressApp.ViewType.DetailView; + this.aMigrateInvoiceIn.ToolTip = null; + this.aMigrateInvoiceIn.TypeOfView = typeof(DevExpress.ExpressApp.DetailView); + // // Migration_VC // this.Actions.Add(this.aMigrateBaseObjects); + this.Actions.Add(this.aMigrateInvoiceOut); + this.Actions.Add(this.aMigrateInvoiceIn); } #endregion private DevExpress.ExpressApp.Actions.SimpleAction aMigrateBaseObjects; + private DevExpress.ExpressApp.Actions.SimpleAction aMigrateInvoiceOut; + private DevExpress.ExpressApp.Actions.SimpleAction aMigrateInvoiceIn; } } diff --git a/Nuvolar.Module.CSharp/BusinessObjects/Migration/Migration_VC.cs b/Nuvolar.Module.CSharp/BusinessObjects/Migration/Migration_VC.cs index da81ffc..52f05bf 100644 --- a/Nuvolar.Module.CSharp/BusinessObjects/Migration/Migration_VC.cs +++ b/Nuvolar.Module.CSharp/BusinessObjects/Migration/Migration_VC.cs @@ -1,27 +1,16 @@ using System; -using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.Globalization; -using System.Linq; using System.Reflection; -using System.Text; using DevExpress.Data.Filtering; using DevExpress.ExpressApp; using DevExpress.ExpressApp.Actions; -using DevExpress.ExpressApp.Editors; -using DevExpress.ExpressApp.Layout; -using DevExpress.ExpressApp.Model.NodeGenerators; -using DevExpress.ExpressApp.SystemModule; -using DevExpress.ExpressApp.Templates; -using DevExpress.ExpressApp.Utils; using DevExpress.ExpressApp.Xpo; -using DevExpress.Persistent.Base; using DevExpress.Persistent.BaseImpl; -using DevExpress.Persistent.Validation; -using DevExpress.PivotGrid.Criteria; using DevExpress.Xpo; using MySql.Data.MySqlClient; +using Nuvolar.Module.Win; namespace Nuvolar.Module.BusinessObjects.Migration { @@ -56,13 +45,22 @@ namespace Nuvolar.Module.BusinessObjects.Migration if (_MigrationParameters.SQLType == eSQLType.MSSQL) { - //Sync_XPObjectType_MSSQL_MySQL(_ocur); + Sync_XPObjectType_MSSQL_MySQL(_ocur); //Sync_HCategory_ChartOfAccounts_MSSQL_MySQL(_ocur); //Sync_ChartOfAccounts_MSSQL_MySQL(_ocur); //Sync_ChartOfAccountsYear_MSSQL_MySQL(_ocur); - Sync_HCategory_Controlling_MSSQL_MySQL(_ocur); + //Sync_HCategory_Controlling_MSSQL_MySQL(_ocur); //Sync_Controlling_MSSQL_MySQL(_ocur); + //Sync_ControllingYear_MSSQL_MySQL(_ocur); + //Sync_VAT_MSSQL_MySQL(_ocur); + //Sync_VATYear_MSSQL_MySQL(_ocur); + //Sync_CustomersGLParameters_MSSQL_MySQL(_ocur); + //Sync_CustomersGLParametersYear_MSSQL_MySQL(_ocur); + + //Sync_Party_CustomersFrom_MSSQL_MySQL(_ocur); + Sync_PaymentOption_MSSQL_MySQL(_ocur); + //Sync_LiquidAssets_MSSQL_MySQL(_ocur); } } @@ -73,6 +71,17 @@ namespace Nuvolar.Module.BusinessObjects.Migration MakeObjectType(_ocur); MakeObjectType(_ocur); MakeObjectType(_ocur); + MakeObjectType(_ocur); + MakeObjectType(_ocur); + MakeObjectType(_ocur); + MakeObjectType(_ocur); + MakeObjectType(_ocur); + MakeObjectType(_ocur); + MakeObjectType(_ocur); + MakeObjectType(_ocur); + MakeObjectType(_ocur); + MakeObjectType(_ocur); + } private void MakeObjectType(XPObjectSpace _ocur) { @@ -551,7 +560,7 @@ namespace Nuvolar.Module.BusinessObjects.Migration _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@RequireCars", DbType = DbType.Boolean, Value = _SqlDataReader["RequireCars"] }); _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@RequireHRPerson", DbType = DbType.Boolean, Value = _SqlDataReader["RequireHRPerson"] }); _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@RequirePhones", DbType = DbType.Boolean, Value = _SqlDataReader["RequirePhones"] }); - + _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@COCAboveAmount", DbType = DbType.Double, Value = _SqlDataReader["COCAboveAmount"] }); _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@Controllingdirection", DbType = DbType.Int64, Value = _SqlDataReader["Controllingdirection"] }); _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@ReinvoiceDescription", DbType = DbType.String, Value = _SqlDataReader["ReinvoiceDescription"] }); @@ -587,6 +596,686 @@ namespace Nuvolar.Module.BusinessObjects.Migration } + } + _SqlConnection.Close(); + _MySqlConnection.Close(); + _ocur.Session.ExecuteNonQuery("SET FOREIGN_KEY_CHECKS=1"); + } + private void Sync_ControllingYear_MSSQL_MySQL(XPObjectSpace _ocur) + { + MigrationParameters _MigrationParameters = View.SelectedObjects[0] as MigrationParameters; + _ocur.Session.ExecuteNonQuery("SET FOREIGN_KEY_CHECKS=0"); + string _ConnectionStringMSSQL = string.Format(" User ID={0}; " + + " Password={1};" + + " Pooling=false;" + + " Data Source={2};" + + " Initial Catalog={3}", + _MigrationParameters.SQLUser, + _MigrationParameters.SQLPassword, + _MigrationParameters.SQLServer, + _MigrationParameters.SQLDatabase); + + + + SqlConnection _SqlConnection = new SqlConnection(_ConnectionStringMSSQL); + MySqlConnection _MySqlConnection = new MySqlConnection(Nuvolar.Module.GeneralFunction.GLOBAL_ConnectionString.Replace("XpoProvider=MySql;", "")); + + _SqlConnection.Open(); + _MySqlConnection.Open(); + if (_SqlConnection.State == ConnectionState.Open) + { + + + string _SQL = " select t1.* " + + " from ControllingYear t1 " + + " WHERE t1.GCRecord is null"; + SqlCommand _SqlCommand = new SqlCommand(_SQL, _SqlConnection); + SqlDataReader _SqlDataReader = _SqlCommand.ExecuteReader(); + + if (_SqlDataReader.HasRows) + { + while (_SqlDataReader.Read()) + { + string _MySQL = "SELECT count(*) FROM ControllingYear WHERE Oid=@Oid"; + using (MySqlCommand _MySqlCommand = new MySqlCommand() { CommandText = _MySQL, Connection = _MySqlConnection }) + { + _MySqlCommand.Parameters.Add(new MySqlParameter() { ParameterName = "@Oid", DbType = DbType.Guid, Value = _SqlDataReader["Oid"] }); + + object _Found = _MySqlCommand.ExecuteScalar(); + + if (_Found != null) + { + double _F; + IsNumeric(_Found, out _F); + if (_F == 0) + { + + _MySQL = " SET FOREIGN_KEY_CHECKS=0;" + + " INSERT INTO ControllingYear (Oid,Controlling,AccountYear,ChartOfAccounts,ChartOfAccounts2)" + + " SELECT @Oid,@Controlling,@AccountYear,@ChartOfAccounts,@ChartOfAccounts2;"; + using (MySqlCommand _MySqlCommand_Insert = new MySqlCommand() { CommandText = _MySQL, Connection = _MySqlConnection }) + { + _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@Oid", DbType = DbType.Guid, Value = _SqlDataReader["Oid"] }); + _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@Controlling", DbType = DbType.Guid, Value = _SqlDataReader["Controlling"] }); + _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@AccountYear", DbType = DbType.Int64, Value = _SqlDataReader["AccountYear"] }); + _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@ChartOfAccounts", DbType = DbType.Guid, Value = _SqlDataReader["ChartOfAccounts"] }); + _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@ChartOfAccounts2", DbType = DbType.Guid, Value = _SqlDataReader["ChartOfAccounts2"] }); + + _MySqlCommand_Insert.ExecuteNonQuery(); + } + } + else // Ha már VAN + { + //_MySQL = " SET FOREIGN_KEY_CHECKS=0;" + + // " UPDATE HCategory SET Name=@Name," + + // " Parent=@Parent " + + // " WHERE Oid=@Oid"; + //using (MySqlCommand _MySqlCommand_Update = new MySqlCommand() { CommandText = _MySQL, Connection = _MySqlConnection }) + //{ + + // _MySqlCommand_Update.Parameters.Add(new MySqlParameter() { ParameterName = "@Oid", DbType = DbType.Guid, Value = _SqlDataReader["Oid"] }); + // _MySqlCommand_Update.Parameters.Add(new MySqlParameter() { ParameterName = "@Parent", DbType = DbType.Guid, Value = _SqlDataReader["Parent"] }); + // _MySqlCommand_Update.Parameters.Add(new MySqlParameter() { ParameterName = "@Name", DbType = DbType.String, Value = _SqlDataReader["Name"] }); + + // _MySqlCommand_Update.ExecuteNonQuery(); + //} + + } + } + } + + } + } + + + } + _SqlConnection.Close(); + _MySqlConnection.Close(); + _ocur.Session.ExecuteNonQuery("SET FOREIGN_KEY_CHECKS=1"); + } + private void Sync_VAT_MSSQL_MySQL(XPObjectSpace _ocur) + { + MigrationParameters _MigrationParameters = View.SelectedObjects[0] as MigrationParameters; + _ocur.Session.ExecuteNonQuery("SET FOREIGN_KEY_CHECKS=0"); + string _ConnectionStringMSSQL = string.Format(" User ID={0}; " + + " Password={1};" + + " Pooling=false;" + + " Data Source={2};" + + " Initial Catalog={3}", + _MigrationParameters.SQLUser, + _MigrationParameters.SQLPassword, + _MigrationParameters.SQLServer, + _MigrationParameters.SQLDatabase); + + + + SqlConnection _SqlConnection = new SqlConnection(_ConnectionStringMSSQL); + MySqlConnection _MySqlConnection = new MySqlConnection(Nuvolar.Module.GeneralFunction.GLOBAL_ConnectionString.Replace("XpoProvider=MySql;", "")); + + _SqlConnection.Open(); + _MySqlConnection.Open(); + if (_SqlConnection.State == ConnectionState.Open) + { + + + string _SQL = " select t1.* " + + " from VAT t1 " + + " WHERE t1.GCRecord is null"; + SqlCommand _SqlCommand = new SqlCommand(_SQL, _SqlConnection); + SqlDataReader _SqlDataReader = _SqlCommand.ExecuteReader(); + + if (_SqlDataReader.HasRows) + { + while (_SqlDataReader.Read()) + { + string _MySQL = "SELECT count(*) FROM VAT WHERE Oid=@Oid"; + using (MySqlCommand _MySqlCommand = new MySqlCommand() { CommandText = _MySQL, Connection = _MySqlConnection }) + { + _MySqlCommand.Parameters.Add(new MySqlParameter() { ParameterName = "@Oid", DbType = DbType.Guid, Value = _SqlDataReader["Oid"] }); + + object _Found = _MySqlCommand.ExecuteScalar(); + + if (_Found != null) + { + double _F; + IsNumeric(_Found, out _F); + if (_F == 0) + { + + _MySQL = " SET FOREIGN_KEY_CHECKS=0;" + + " INSERT INTO VAT (Oid,ShortName,Description,KeyValue,ClaimState,Active,InversState,InversKeyValue,DefaultForBusinnes," + + " DefaultForExternalEUNoVAT,DefaultForExternalOther,DefaultForInversVAT,VATBag)" + + " SELECT @Oid,@ShortName,@Description,@KeyValue,@ClaimState,@Active,@InversState,@InversKeyValue,@DefaultForBusinnes," + + " @DefaultForExternalEUNoVAT,@DefaultForExternalOther,@DefaultForInversVAT,@VATBag;"; + using (MySqlCommand _MySqlCommand_Insert = new MySqlCommand() { CommandText = _MySQL, Connection = _MySqlConnection }) + { + _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@Oid", DbType = DbType.Guid, Value = _SqlDataReader["Oid"] }); + _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@ShortName", DbType = DbType.String, Value = _SqlDataReader["ShortName"] }); + _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@Description", DbType = DbType.String, Value = _SqlDataReader["Description"] }); + _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@KeyValue", DbType = DbType.Double, Value = _SqlDataReader["KeyValue"] }); + _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@ClaimState", DbType = DbType.Boolean, Value = _SqlDataReader["ClaimState"] }); + _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@Active", DbType = DbType.Boolean, Value = _SqlDataReader["Active"] }); + _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@InversState", DbType = DbType.Boolean, Value = _SqlDataReader["InversState"] }); + _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@InversKeyValue", DbType = DbType.Double, Value = _SqlDataReader["InversKeyValue"] }); + _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@DefaultForBusinnes", DbType = DbType.Boolean, Value = _SqlDataReader["DefaultForBusinnes"] }); + _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@DefaultForExternalEUNoVAT", DbType = DbType.Boolean, Value = _SqlDataReader["DefaultForExternalEUNoVAT"] }); + _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@DefaultForExternalOther", DbType = DbType.Boolean, Value = _SqlDataReader["DefaultForExternalOther"] }); + _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@DefaultForInversVAT", DbType = DbType.Boolean, Value = _SqlDataReader["DefaultForInversVAT"] }); + _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@VATBag", DbType = DbType.String, Value = _SqlDataReader["VATBag"] }); + + + _MySqlCommand_Insert.ExecuteNonQuery(); + } + } + else // Ha már VAN + { + //_MySQL = " SET FOREIGN_KEY_CHECKS=0;" + + // " UPDATE HCategory SET Name=@Name," + + // " Parent=@Parent " + + // " WHERE Oid=@Oid"; + //using (MySqlCommand _MySqlCommand_Update = new MySqlCommand() { CommandText = _MySQL, Connection = _MySqlConnection }) + //{ + + // _MySqlCommand_Update.Parameters.Add(new MySqlParameter() { ParameterName = "@Oid", DbType = DbType.Guid, Value = _SqlDataReader["Oid"] }); + // _MySqlCommand_Update.Parameters.Add(new MySqlParameter() { ParameterName = "@Parent", DbType = DbType.Guid, Value = _SqlDataReader["Parent"] }); + // _MySqlCommand_Update.Parameters.Add(new MySqlParameter() { ParameterName = "@Name", DbType = DbType.String, Value = _SqlDataReader["Name"] }); + + // _MySqlCommand_Update.ExecuteNonQuery(); + //} + + } + } + } + + } + } + + + } + _SqlConnection.Close(); + _MySqlConnection.Close(); + _ocur.Session.ExecuteNonQuery("SET FOREIGN_KEY_CHECKS=1"); + } + private void Sync_VATYear_MSSQL_MySQL(XPObjectSpace _ocur) + { + MigrationParameters _MigrationParameters = View.SelectedObjects[0] as MigrationParameters; + _ocur.Session.ExecuteNonQuery("SET FOREIGN_KEY_CHECKS=0"); + string _ConnectionStringMSSQL = string.Format(" User ID={0}; " + + " Password={1};" + + " Pooling=false;" + + " Data Source={2};" + + " Initial Catalog={3}", + _MigrationParameters.SQLUser, + _MigrationParameters.SQLPassword, + _MigrationParameters.SQLServer, + _MigrationParameters.SQLDatabase); + + string _MySQL = ""; + + SqlConnection _SqlConnection = new SqlConnection(_ConnectionStringMSSQL); + MySqlConnection _MySqlConnection = new MySqlConnection(Nuvolar.Module.GeneralFunction.GLOBAL_ConnectionString.Replace("XpoProvider=MySql;", "")); + + _SqlConnection.Open(); + _MySqlConnection.Open(); + if (_SqlConnection.State == ConnectionState.Open) + { + + + string _SQL = " select t1.* " + + " from VATYear t1 " + + " WHERE t1.GCRecord is null AND t1.AccountYear >=2020"; + SqlCommand _SqlCommand = new SqlCommand(_SQL, _SqlConnection); + SqlDataReader _SqlDataReader = _SqlCommand.ExecuteReader(); + + if (_SqlDataReader.HasRows) + { + while (_SqlDataReader.Read()) + { + _MySQL = "SELECT count(*) FROM VATYear WHERE Oid=@Oid"; + using (MySqlCommand _MySqlCommand = new MySqlCommand() { CommandText = _MySQL, Connection = _MySqlConnection }) + { + _MySqlCommand.Parameters.Add(new MySqlParameter() { ParameterName = "@Oid", DbType = DbType.Guid, Value = _SqlDataReader["Oid"] }); + + object _Found = _MySqlCommand.ExecuteScalar(); + + if (_Found != null) + { + double _F; + IsNumeric(_Found, out _F); + if (_F == 0) + { + + _MySQL = " SET FOREIGN_KEY_CHECKS=0;" + + " INSERT INTO VATYear (Oid,VAT,AccountYear,ChartOfAccountsOut,ChartOfAccountsIn)" + + " SELECT @Oid,@VAT,@AccountYear,@ChartOfAccountsOut,@ChartOfAccountsIn;"; + using (MySqlCommand _MySqlCommand_Insert = new MySqlCommand() { CommandText = _MySQL, Connection = _MySqlConnection }) + { + _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@Oid", DbType = DbType.Guid, Value = _SqlDataReader["Oid"] }); + _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@VAT", DbType = DbType.Guid, Value = _SqlDataReader["VAT"] }); + _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@AccountYear", DbType = DbType.Int64, Value = _SqlDataReader["AccountYear"] }); + _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@ChartOfAccountsOut", DbType = DbType.Guid, Value = _SqlDataReader["ChartOfAccountsOut"] }); + _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@ChartOfAccountsIn", DbType = DbType.Guid, Value = _SqlDataReader["ChartOfAccountsIn"] }); + + _MySqlCommand_Insert.ExecuteNonQuery(); + } + } + else // Ha már VAN + { + //_MySQL = " SET FOREIGN_KEY_CHECKS=0;" + + // " UPDATE HCategory SET Name=@Name," + + // " Parent=@Parent " + + // " WHERE Oid=@Oid"; + //using (MySqlCommand _MySqlCommand_Update = new MySqlCommand() { CommandText = _MySQL, Connection = _MySqlConnection }) + //{ + + // _MySqlCommand_Update.Parameters.Add(new MySqlParameter() { ParameterName = "@Oid", DbType = DbType.Guid, Value = _SqlDataReader["Oid"] }); + // _MySqlCommand_Update.Parameters.Add(new MySqlParameter() { ParameterName = "@Parent", DbType = DbType.Guid, Value = _SqlDataReader["Parent"] }); + // _MySqlCommand_Update.Parameters.Add(new MySqlParameter() { ParameterName = "@Name", DbType = DbType.String, Value = _SqlDataReader["Name"] }); + + // _MySqlCommand_Update.ExecuteNonQuery(); + //} + + } + } + } + + } + } + + + } + _MySQL = " UPDATE VATYear set ChartOfAccountsOut=NULL where ChartOfAccountsOut NOT IN (select Oid from HCategory);" + + " UPDATE VATYear set ChartOfAccountsIn=NULL where ChartOfAccountsIn NOT IN (select Oid from HCategory);"; + using (MySqlCommand _MySqlCommand_Insert = new MySqlCommand() { CommandText = _MySQL, Connection = _MySqlConnection }) + { + _MySqlCommand_Insert.ExecuteNonQuery(); + } + _SqlConnection.Close(); + _MySqlConnection.Close(); + _ocur.Session.ExecuteNonQuery("SET FOREIGN_KEY_CHECKS=1"); + } + private void Sync_CustomersGLParameters_MSSQL_MySQL(XPObjectSpace _ocur) + { + MigrationParameters _MigrationParameters = View.SelectedObjects[0] as MigrationParameters; + _ocur.Session.ExecuteNonQuery("SET FOREIGN_KEY_CHECKS=0"); + string _ConnectionStringMSSQL = string.Format(" User ID={0}; " + + " Password={1};" + + " Pooling=false;" + + " Data Source={2};" + + " Initial Catalog={3}", + _MigrationParameters.SQLUser, + _MigrationParameters.SQLPassword, + _MigrationParameters.SQLServer, + _MigrationParameters.SQLDatabase); + + + + SqlConnection _SqlConnection = new SqlConnection(_ConnectionStringMSSQL); + MySqlConnection _MySqlConnection = new MySqlConnection(Nuvolar.Module.GeneralFunction.GLOBAL_ConnectionString.Replace("XpoProvider=MySql;", "")); + + _SqlConnection.Open(); + _MySqlConnection.Open(); + if (_SqlConnection.State == ConnectionState.Open) + { + + + string _SQL = " select t1.* " + + " from CustomersGLParameters t1 " + + " WHERE t1.GCRecord is null"; + SqlCommand _SqlCommand = new SqlCommand(_SQL, _SqlConnection); + SqlDataReader _SqlDataReader = _SqlCommand.ExecuteReader(); + + if (_SqlDataReader.HasRows) + { + while (_SqlDataReader.Read()) + { + string _MySQL = "SELECT count(*) FROM CustomersGLParameters WHERE Oid=@Oid"; + using (MySqlCommand _MySqlCommand = new MySqlCommand() { CommandText = _MySQL, Connection = _MySqlConnection }) + { + _MySqlCommand.Parameters.Add(new MySqlParameter() { ParameterName = "@Oid", DbType = DbType.Guid, Value = _SqlDataReader["Oid"] }); + + object _Found = _MySqlCommand.ExecuteScalar(); + + if (_Found != null) + { + double _F; + IsNumeric(_Found, out _F); + if (_F == 0) + { + + _MySQL = " SET FOREIGN_KEY_CHECKS=0;" + + " INSERT INTO CustomersGLParameters (Oid,ShortName,DefaultforBusiness)" + + " SELECT @Oid,@ShortName,@DefaultForBusiness;"; + using (MySqlCommand _MySqlCommand_Insert = new MySqlCommand() { CommandText = _MySQL, Connection = _MySqlConnection }) + { + _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@Oid", DbType = DbType.Guid, Value = _SqlDataReader["Oid"] }); + _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@ShortName", DbType = DbType.String, Value = _SqlDataReader["ShortName"] }); + _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@DefaultForBusiness", DbType = DbType.Boolean, Value = _SqlDataReader["DefaultForBusiness"] }); + + + _MySqlCommand_Insert.ExecuteNonQuery(); + } + } + else // Ha már VAN + { + //_MySQL = " SET FOREIGN_KEY_CHECKS=0;" + + // " UPDATE HCategory SET Name=@Name," + + // " Parent=@Parent " + + // " WHERE Oid=@Oid"; + //using (MySqlCommand _MySqlCommand_Update = new MySqlCommand() { CommandText = _MySQL, Connection = _MySqlConnection }) + //{ + + // _MySqlCommand_Update.Parameters.Add(new MySqlParameter() { ParameterName = "@Oid", DbType = DbType.Guid, Value = _SqlDataReader["Oid"] }); + // _MySqlCommand_Update.Parameters.Add(new MySqlParameter() { ParameterName = "@Parent", DbType = DbType.Guid, Value = _SqlDataReader["Parent"] }); + // _MySqlCommand_Update.Parameters.Add(new MySqlParameter() { ParameterName = "@Name", DbType = DbType.String, Value = _SqlDataReader["Name"] }); + + // _MySqlCommand_Update.ExecuteNonQuery(); + //} + + } + } + } + + } + } + + + } + _SqlConnection.Close(); + _MySqlConnection.Close(); + _ocur.Session.ExecuteNonQuery("SET FOREIGN_KEY_CHECKS=1"); + } + private void Sync_CustomersGLParametersYear_MSSQL_MySQL(XPObjectSpace _ocur) + { + MigrationParameters _MigrationParameters = View.SelectedObjects[0] as MigrationParameters; + _ocur.Session.ExecuteNonQuery("SET FOREIGN_KEY_CHECKS=0"); + string _ConnectionStringMSSQL = string.Format(" User ID={0}; " + + " Password={1};" + + " Pooling=false;" + + " Data Source={2};" + + " Initial Catalog={3}", + _MigrationParameters.SQLUser, + _MigrationParameters.SQLPassword, + _MigrationParameters.SQLServer, + _MigrationParameters.SQLDatabase); + + string _MySQL = ""; + + SqlConnection _SqlConnection = new SqlConnection(_ConnectionStringMSSQL); + MySqlConnection _MySqlConnection = new MySqlConnection(Nuvolar.Module.GeneralFunction.GLOBAL_ConnectionString.Replace("XpoProvider=MySql;", "")); + + _SqlConnection.Open(); + _MySqlConnection.Open(); + if (_SqlConnection.State == ConnectionState.Open) + { + + + string _SQL = " select t1.* " + + " from CustomersGLParametersYear t1 " + + " WHERE t1.GCRecord is null AND t1.AccountYear >=2020"; + SqlCommand _SqlCommand = new SqlCommand(_SQL, _SqlConnection); + SqlDataReader _SqlDataReader = _SqlCommand.ExecuteReader(); + + if (_SqlDataReader.HasRows) + { + while (_SqlDataReader.Read()) + { + _MySQL = "SELECT count(*) FROM CustomersGLParametersYear WHERE Oid=@Oid"; + using (MySqlCommand _MySqlCommand = new MySqlCommand() { CommandText = _MySQL, Connection = _MySqlConnection }) + { + _MySqlCommand.Parameters.Add(new MySqlParameter() { ParameterName = "@Oid", DbType = DbType.Guid, Value = _SqlDataReader["Oid"] }); + + object _Found = _MySqlCommand.ExecuteScalar(); + + if (_Found != null) + { + double _F; + IsNumeric(_Found, out _F); + if (_F == 0) + { + + _MySQL = " SET FOREIGN_KEY_CHECKS=0;" + + " INSERT INTO CustomersGLParametersYear (Oid,CustomersGLParameters,AccountYear,ChartOfAccountsOut,ChartOfAccountsIn,ChartOfAccountsNo)" + + " SELECT @Oid,@CustomersGLParameters,@AccountYear,@ChartOfAccountsOut,@ChartOfAccountsIn,@ChartOfAccountsNo;"; + using (MySqlCommand _MySqlCommand_Insert = new MySqlCommand() { CommandText = _MySQL, Connection = _MySqlConnection }) + { + _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@Oid", DbType = DbType.Guid, Value = _SqlDataReader["Oid"] }); + _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@CustomersGLParameters", DbType = DbType.Guid, Value = _SqlDataReader["CustomersGLParameters"] }); + _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@AccountYear", DbType = DbType.Int64, Value = _SqlDataReader["AccountYear"] }); + _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@ChartOfAccountsOut", DbType = DbType.Guid, Value = _SqlDataReader["ChartOfAccountsOut"] }); + _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@ChartOfAccountsIn", DbType = DbType.Guid, Value = _SqlDataReader["ChartOfAccountsIn"] }); + _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@ChartOfAccountsNo", DbType = DbType.Guid, Value = _SqlDataReader["ChartOfAccountsNo"] }); + + _MySqlCommand_Insert.ExecuteNonQuery(); + } + } + else // Ha már VAN + { + //_MySQL = " SET FOREIGN_KEY_CHECKS=0;" + + // " UPDATE HCategory SET Name=@Name," + + // " Parent=@Parent " + + // " WHERE Oid=@Oid"; + //using (MySqlCommand _MySqlCommand_Update = new MySqlCommand() { CommandText = _MySQL, Connection = _MySqlConnection }) + //{ + + // _MySqlCommand_Update.Parameters.Add(new MySqlParameter() { ParameterName = "@Oid", DbType = DbType.Guid, Value = _SqlDataReader["Oid"] }); + // _MySqlCommand_Update.Parameters.Add(new MySqlParameter() { ParameterName = "@Parent", DbType = DbType.Guid, Value = _SqlDataReader["Parent"] }); + // _MySqlCommand_Update.Parameters.Add(new MySqlParameter() { ParameterName = "@Name", DbType = DbType.String, Value = _SqlDataReader["Name"] }); + + // _MySqlCommand_Update.ExecuteNonQuery(); + //} + + } + } + } + + } + } + + + } + _MySQL = " UPDATE CustomersGLParametersYear set ChartOfAccountsOut=NULL where ChartOfAccountsOut NOT IN (select Oid from HCategory);" + + " UPDATE CustomersGLParametersYear set ChartOfAccountsIn=NULL where ChartOfAccountsIn NOT IN (select Oid from HCategory);" + + " UPDATE CustomersGLParametersYear set ChartOfAccountsNo=NULL where ChartOfAccountsNo NOT IN (select Oid from HCategory);"; + using (MySqlCommand _MySqlCommand_Insert = new MySqlCommand() { CommandText = _MySQL, Connection = _MySqlConnection }) + { + _MySqlCommand_Insert.ExecuteNonQuery(); + } + _SqlConnection.Close(); + _MySqlConnection.Close(); + _ocur.Session.ExecuteNonQuery("SET FOREIGN_KEY_CHECKS=1"); + } + private void Sync_LiquidAssets_MSSQL_MySQL(XPObjectSpace _ocur) + { + MigrationParameters _MigrationParameters = View.SelectedObjects[0] as MigrationParameters; + _ocur.Session.ExecuteNonQuery("SET FOREIGN_KEY_CHECKS=0"); + string _ConnectionStringMSSQL = string.Format(" User ID={0}; " + + " Password={1};" + + " Pooling=false;" + + " Data Source={2};" + + " Initial Catalog={3}", + _MigrationParameters.SQLUser, + _MigrationParameters.SQLPassword, + _MigrationParameters.SQLServer, + _MigrationParameters.SQLDatabase); + + + + SqlConnection _SqlConnection = new SqlConnection(_ConnectionStringMSSQL); + MySqlConnection _MySqlConnection = new MySqlConnection(Nuvolar.Module.GeneralFunction.GLOBAL_ConnectionString.Replace("XpoProvider=MySql;", "")); + + _SqlConnection.Open(); + _MySqlConnection.Open(); + if (_SqlConnection.State == ConnectionState.Open) + { + + + string _SQL = " select t1.* " + + " from LiquidAssets t1 " + + " WHERE t1.GCRecord is null"; + SqlCommand _SqlCommand = new SqlCommand(_SQL, _SqlConnection); + SqlDataReader _SqlDataReader = _SqlCommand.ExecuteReader(); + + if (_SqlDataReader.HasRows) + { + while (_SqlDataReader.Read()) + { + string _MySQL = "SELECT count(*) FROM LiquidAssets WHERE Oid=@Oid"; + using (MySqlCommand _MySqlCommand = new MySqlCommand() { CommandText = _MySQL, Connection = _MySqlConnection }) + { + _MySqlCommand.Parameters.Add(new MySqlParameter() { ParameterName = "@Oid", DbType = DbType.Guid, Value = _SqlDataReader["Oid"] }); + + object _Found = _MySqlCommand.ExecuteScalar(); + + if (_Found != null) + { + double _F; + IsNumeric(_Found, out _F); + if (_F == 0) + { + + _MySQL = " SET FOREIGN_KEY_CHECKS=0;" + + " INSERT INTO LiquidAssets (Oid,ShortName,Description,LiquidAssetsType,Description,Active,CurrencyName,IsRounding," + + " NoPrint,NoDocumentNumber,NoTimeCheck)" + + " SELECT @Oid,@ShortName,@Description,@LiquidAssetsType,@Description,@Active,@CurrencyName,@IsRounding," + + " @NoPrint,@NoDocumentNumber,@NoTimeCheck;"; + using (MySqlCommand _MySqlCommand_Insert = new MySqlCommand() { CommandText = _MySQL, Connection = _MySqlConnection }) + { + _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@Oid", DbType = DbType.Guid, Value = _SqlDataReader["Oid"] }); + _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@ShortName", DbType = DbType.String, Value = _SqlDataReader["ShortName"] }); + _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@Description", DbType = DbType.String, Value = _SqlDataReader["Description"] }); + + _MySqlCommand_Insert.ExecuteNonQuery(); + } + } + else // Ha már VAN + { + //_MySQL = " SET FOREIGN_KEY_CHECKS=0;" + + // " UPDATE HCategory SET Name=@Name," + + // " Parent=@Parent " + + // " WHERE Oid=@Oid"; + //using (MySqlCommand _MySqlCommand_Update = new MySqlCommand() { CommandText = _MySQL, Connection = _MySqlConnection }) + //{ + + // _MySqlCommand_Update.Parameters.Add(new MySqlParameter() { ParameterName = "@Oid", DbType = DbType.Guid, Value = _SqlDataReader["Oid"] }); + // _MySqlCommand_Update.Parameters.Add(new MySqlParameter() { ParameterName = "@Parent", DbType = DbType.Guid, Value = _SqlDataReader["Parent"] }); + // _MySqlCommand_Update.Parameters.Add(new MySqlParameter() { ParameterName = "@Name", DbType = DbType.String, Value = _SqlDataReader["Name"] }); + + // _MySqlCommand_Update.ExecuteNonQuery(); + //} + + } + } + } + + } + } + + + } + _SqlConnection.Close(); + _MySqlConnection.Close(); + _ocur.Session.ExecuteNonQuery("SET FOREIGN_KEY_CHECKS=1"); + } + private void Sync_PaymentOption_MSSQL_MySQL(XPObjectSpace _ocur) + { + MigrationParameters _MigrationParameters = View.SelectedObjects[0] as MigrationParameters; + _ocur.Session.ExecuteNonQuery("SET FOREIGN_KEY_CHECKS=0"); + string _ConnectionStringMSSQL = string.Format(" User ID={0}; " + + " Password={1};" + + " Pooling=false;" + + " Data Source={2};" + + " Initial Catalog={3}", + _MigrationParameters.SQLUser, + _MigrationParameters.SQLPassword, + _MigrationParameters.SQLServer, + _MigrationParameters.SQLDatabase); + + + + SqlConnection _SqlConnection = new SqlConnection(_ConnectionStringMSSQL); + MySqlConnection _MySqlConnection = new MySqlConnection(Nuvolar.Module.GeneralFunction.GLOBAL_ConnectionString.Replace("XpoProvider=MySql;", "")); + + _SqlConnection.Open(); + _MySqlConnection.Open(); + if (_SqlConnection.State == ConnectionState.Open) + { + + + string _SQL = " select t1.* " + + " from PaymentOption t1 " + + " WHERE t1.GCRecord is null"; + SqlCommand _SqlCommand = new SqlCommand(_SQL, _SqlConnection); + SqlDataReader _SqlDataReader = _SqlCommand.ExecuteReader(); + + if (_SqlDataReader.HasRows) + { + while (_SqlDataReader.Read()) + { + string _MySQL = "SELECT count(*) FROM PaymentOption WHERE Oid=@Oid"; + using (MySqlCommand _MySqlCommand = new MySqlCommand() { CommandText = _MySQL, Connection = _MySqlConnection }) + { + _MySqlCommand.Parameters.Add(new MySqlParameter() { ParameterName = "@Oid", DbType = DbType.Guid, Value = _SqlDataReader["Oid"] }); + + object _Found = _MySqlCommand.ExecuteScalar(); + + if (_Found != null) + { + double _F; + IsNumeric(_Found, out _F); + if (_F == 0) + { + + _MySQL = " SET FOREIGN_KEY_CHECKS=0;" + + " INSERT INTO PaymentOption (Oid,ShortName,Description,PayMode,PayDay,DefaultForBusinnes,Shortname_GB,Description_GB," + + " DatePaymentMode,IsControlling_InCash,Controlling_InCash)" + + " SELECT @Oid,@ShortName,@Description,@PayMode,@PayDay,@DefaultForBusinnes,@ShortName_GB,@Description_GB," + + " @DatePaymentMode,@IsControlling_InCash,@Controlling_InCash;"; + using (MySqlCommand _MySqlCommand_Insert = new MySqlCommand() { CommandText = _MySQL, Connection = _MySqlConnection }) + { + _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@Oid", DbType = DbType.Guid, Value = _SqlDataReader["Oid"] }); + _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@ShortName", DbType = DbType.String, Value = _SqlDataReader["ShortName"] }); + _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@Description", DbType = DbType.String, Value = _SqlDataReader["Description"] }); + + _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@PayMode", DbType = DbType.Int64, Value = _SqlDataReader["PayMode"] }); + _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@PayDay", DbType = DbType.Int64, Value = _SqlDataReader["PayDay"] }); + _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@DefaultForBusinnes", DbType = DbType.Boolean, Value = _SqlDataReader["DefaultForBusinnes"] }); + + _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@ShortName_GB", DbType = DbType.String, Value = _SqlDataReader["ShortName_GB"] }); + _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@Description_GB", DbType = DbType.String, Value = _SqlDataReader["Description_GB"] }); + _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@DatePaymentMode", DbType = DbType.Int64, Value = _SqlDataReader["DatePaymentMode"] }); + + _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@IsControlling_InCash", DbType = DbType.Boolean, Value = _SqlDataReader["IsControlling_InCash"] }); + _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@Controlling_InCash", DbType = DbType.Guid, Value = _SqlDataReader["Controlling_InCash"] }); + + + _MySqlCommand_Insert.ExecuteNonQuery(); + } + } + else // Ha már VAN + { + //_MySQL = " SET FOREIGN_KEY_CHECKS=0;" + + // " UPDATE HCategory SET Name=@Name," + + // " Parent=@Parent " + + // " WHERE Oid=@Oid"; + //using (MySqlCommand _MySqlCommand_Update = new MySqlCommand() { CommandText = _MySQL, Connection = _MySqlConnection }) + //{ + + // _MySqlCommand_Update.Parameters.Add(new MySqlParameter() { ParameterName = "@Oid", DbType = DbType.Guid, Value = _SqlDataReader["Oid"] }); + // _MySqlCommand_Update.Parameters.Add(new MySqlParameter() { ParameterName = "@Parent", DbType = DbType.Guid, Value = _SqlDataReader["Parent"] }); + // _MySqlCommand_Update.Parameters.Add(new MySqlParameter() { ParameterName = "@Name", DbType = DbType.String, Value = _SqlDataReader["Name"] }); + + // _MySqlCommand_Update.ExecuteNonQuery(); + //} + + } + } + } + + } + } + + } _SqlConnection.Close(); _MySqlConnection.Close(); @@ -597,5 +1286,528 @@ namespace Nuvolar.Module.BusinessObjects.Migration bool isNum = Double.TryParse(Convert.ToString(Expression), NumberStyles.Any, NumberFormatInfo.InvariantInfo, out retNum); return isNum; } + + private void aMigrateInvoiceOut_Execute(object sender, SimpleActionExecuteEventArgs e) + { + MigrationParameters _MigrationParameters = View.SelectedObjects[0] as MigrationParameters; + XPObjectSpace _ocur = View.ObjectSpace as XPObjectSpace; + Sync_Invoice_Out_By_Date_MSSQL_MySQL(_ocur); + } + + #region Vevői számlák + private void Sync_Invoice_Out_By_Date_MSSQL_MySQL(XPObjectSpace _ocur) + { + MigrationParameters _MigrationParameters = View.SelectedObjects[0] as MigrationParameters; + WaitFormClass _WaitFormClass = new WaitFormClass(); + UnitOfWork _uow_log = new UnitOfWork(_ocur.Session.DataLayer); + User _CurrentUser = _uow_log.GetObjectByKey(SecuritySystem.CurrentUserId); + + string _ConnectionStringMSSQL = string.Format(" User ID={0}; " + + " Password={1};" + + " Pooling=false;" + + " Data Source={2};" + + " Initial Catalog={3}", + _MigrationParameters.SQLUser, + _MigrationParameters.SQLPassword, + _MigrationParameters.SQLServer, + _MigrationParameters.SQLDatabase); + string _SQL = ""; + object _Count = null; + + SqlConnection _SqlConnection = new SqlConnection(_ConnectionStringMSSQL); + MySqlConnection _MySqlConnection = new MySqlConnection(Nuvolar.Module.GeneralFunction.GLOBAL_ConnectionString.Replace("XpoProvider=MySql;", "")); + + _SqlConnection.Open(); + _MySqlConnection.Open(); + if (_SqlConnection.State == ConnectionState.Open) + { + + _SQL = string.Format(" select count(*) FROM InvoiceHeader t1 WHERE DateExecution>='{0}' AND t1.DateExecution <='{1}'", + _MigrationParameters.DateFrom.Date.ToString("yyyy-MM-dd"), _MigrationParameters.DateTo.Date.ToString("yyyy-MM-dd")); + using (SqlCommand _SqlCommand = new SqlCommand(_SQL, _SqlConnection)) + { + _Count = _SqlCommand.ExecuteScalar(); + } + + if (_Count != null) + { + _SQL = string.Format(" select t1.Oid FROM InvoiceHeader t1 WHERE DateExecution>='{0}' AND t1.DateExecution <='{1}'", + _MigrationParameters.DateFrom.Date.ToString("yyyy-MM-dd"), _MigrationParameters.DateTo.Date.ToString("yyyy-MM-dd")); + + using (SqlCommand _SqlCommand = new SqlCommand(_SQL, _SqlConnection)) + { + SqlDataReader _SqlDataReader = _SqlCommand.ExecuteReader(); + + if (_SqlDataReader.HasRows) + { + _WaitFormClass.Initwork(1, 1, (int)_Count); + while (_SqlDataReader.Read()) + { + try + { + this.Sync_Invoice_Out_MSSQL_MySQL(_ocur, _SqlDataReader["Oid"].ToString().Trim()); + _WaitFormClass.DoWork(); + } + catch (Exception ex) + { + MigrationLog _MigrationLog = new MigrationLog(_uow_log); + _MigrationLog.UserCreated = _CurrentUser; + _MigrationLog.ShortName = string.Format("ERROR INVOICE OUT : InvoiceHeader {0}", _SqlDataReader["Oid"].ToString().Trim()); + _MigrationLog.DateCreated = DateTime.Now; + _MigrationLog.Description = ex.Message; + _uow_log.CommitChanges(); + } + } + _WaitFormClass.FinalWork(); + } + } + } + } + _SqlConnection.Close(); + _MySqlConnection.Close(); + } + private void Sync_Invoice_Out_MSSQL_MySQL(XPObjectSpace _ocur, string _InvoiceHeader_OID) + { + + MigrationParameters _MigrationParameters = View.SelectedObjects[0] as MigrationParameters; + _ocur.Session.ExecuteNonQuery("SET FOREIGN_KEY_CHECKS=0"); + UnitOfWork _uow = new UnitOfWork(_ocur.Session.DataLayer); + UnitOfWork _uow_log = new UnitOfWork(_ocur.Session.DataLayer); + User _CurrentUser = _uow_log.GetObjectByKey(SecuritySystem.CurrentUserId); + string _ConnectionStringMSSQL = string.Format(" User ID={0}; " + + " Password={1};" + + " Pooling=true;" + + " Data Source={2};" + + " Initial Catalog={3}", + _MigrationParameters.SQLUser, + _MigrationParameters.SQLPassword, + _MigrationParameters.SQLServer, + _MigrationParameters.SQLDatabase); + + + + SqlConnection _SqlConnection = new SqlConnection(_ConnectionStringMSSQL); + MySqlConnection _MySqlConnection = new MySqlConnection(Nuvolar.Module.GeneralFunction.GLOBAL_ConnectionString.Replace("XpoProvider=MySql;", "")); + + _SqlConnection.Open(); + _MySqlConnection.Open(); + if (_SqlConnection.State == ConnectionState.Open) + { + + GLAccounts _GLAccounts = null; + GLRows _GLRows = null; + + /// Számla fejléc adatok rögzítése + string _SQL = string.Format(" SELECT t1.Oid,t1.DocumentNumber,t1.PaymentOption,t1.ConnectInfo,t1.CustomersFrom,t1.Customers,t1.DateCreated,t1.DateExecution,t1.DatePayment,t1.TotalBruttoHUF,t1.TotalBruttoDEV," + + " t1.CurrencyName" + + " FROM InvoiceHeader t1 " + + " WHERE t1.GCRecord is null AND t1.Oid='{0}'", _InvoiceHeader_OID); + using (SqlCommand _SqlCommand = new SqlCommand(_SQL, _SqlConnection)) + { + using (SqlDataReader _SqlDataReader = _SqlCommand.ExecuteReader()) + { + if (_SqlDataReader.HasRows) + { + while (_SqlDataReader.Read()) + { + this.Sync_Party_Customers_One_MSSQL_MySQL(_ocur, _SqlDataReader["Customers"].ToString().Trim()); + + try + { + + + _GLAccounts = _uow.FindObject(CriteriaOperator.Parse("Customers.Oid = ? AND CustomersFrom.Oid = ? AND PartnerType = 0 AND DocumentNumber = ? AND ConnectInfo = ?", + _SqlDataReader["Customers"], _SqlDataReader["CustomersFrom"], _SqlDataReader["DocumentNumber"], _SqlDataReader["ConnectInfo"])); + if (_GLAccounts == null) + { + _GLAccounts = new GLAccounts(_uow); + } + + _GLAccounts.PartnerType = ePartnerType.eReceivables; + _GLAccounts.DocumentNumber = _SqlDataReader["DocumentNumber"].ToString().Trim(); + _GLAccounts.ConnectInfo = _SqlDataReader["ConnectInfo"].ToString().Trim(); + _GLAccounts.Customers = _uow.GetObjectByKey(_SqlDataReader["Customers"]); + _GLAccounts.CustomersFrom = _uow.GetObjectByKey(_SqlDataReader["CustomersFrom"]); + _GLAccounts.CurrencyName = _uow.GetObjectByKey(_SqlDataReader["CurrencyName"]); + _GLAccounts.IsEditable = false; + _GLAccounts.DateCreated = (DateTime)_SqlDataReader["DateCreated"]; + _GLAccounts.DateExecution = (DateTime)_SqlDataReader["DateExecution"]; + _GLAccounts.DatePayment = (DateTime)_SqlDataReader["DatePayment"]; + _GLAccounts.AmountHUFBrutto = (double)_SqlDataReader["TotalBruttoHUF"]; + _GLAccounts.AmountDEVBrutto = (double)_SqlDataReader["TotalBruttoDEV"]; + _GLAccounts.PaymentOption = _uow.GetObjectByKey(_SqlDataReader["PaymentOption"]); + _uow.CommitChanges(); + } + catch (Exception ex) + { + MigrationLog _MigrationLog = new MigrationLog(_uow_log); + _MigrationLog.UserCreated = _CurrentUser; + _MigrationLog.ShortName = string.Format("ERROR GLAccounts: {0}", _SqlDataReader["DocumentNumber"].ToString().Trim()); + _MigrationLog.DateCreated = DateTime.Now; + _MigrationLog.Description = ex.Message; + _uow_log.CommitChanges(); + } + } + } + } + } + + _uow.ExecuteNonQuery(string.Format("DELETE FROM GLDetails WHERE GLRows IN (SELECT Oid FROM GLRows WHERE GLHeader = '{0}')", _GLAccounts.Oid.ToString())); + _uow.ExecuteNonQuery(string.Format("DELETE FROM GLRows WHERE GLHeader = '{0}'", _GLAccounts.Oid.ToString())); + /// Számla nettó sorok rögzítése + _SQL = string.Format(" SELECT sum(t1.SumPriceHUF) AS SumPriceHUF,sum(t1.SumPriceDEV) AS SumPriceDEV,t1.VAT,t1.Controlling,t3.Name,Max(t5.ChartOfAccountsOut) AS ChartOfAccountsT, " + + " MAX(t7.ChartOfAccounts) AS ChartOfAccountsK,Max(t4.DocumentNumber) AS DocumentNumber " + + + " FROM InvoiceRows t1 left join Controlling t2 on " + + " t1.Controlling = t2.Oid left join HCategory t3 on " + + " t2.Oid = t3.Oid LEFT JOIN InvoiceHeader t4 on" + + " t1.InvoiceHeader = t4.Oid LEFT JOIN Customers t6 ON " + + " t4.Customers = t6.Oid LEFT JOIN CustomersGLParametersYear t5 on" + + " t5.AccountYear=Year(t4.DateExecution) AND t6.CustomersGLParameters = t5.CustomersGLParameters" + + " LEFT JOIN ControllingYear t7 ON" + + " t1.Controlling=t7.Controlling AND t7.AccountYear=Year(t4.DateExecution)" + + + " WHERE t1.InvoiceHeader ='{0}' AND t1.GCRecord IS NULL AND t7.GCRecord IS NULL AND t5.GCRecord IS NULL" + + " GROUP BY t1.Controlling,t3.Name,t1.VAT", _InvoiceHeader_OID); + using (SqlCommand _SqlCommand = new SqlCommand(_SQL, _SqlConnection)) + { + using (SqlDataReader _SqlDataReader = _SqlCommand.ExecuteReader()) + { + + if (_SqlDataReader.HasRows) + { + while (_SqlDataReader.Read()) + { + try + { + _GLRows = new GLRows(_uow); + _GLRows.GLHeader = _GLAccounts; + _GLRows.NoteRows = "ÉRTÉKESÍTÉS NETTÓ"; + _GLRows.DebitChartOfAccounts = _uow.GetObjectByKey(_SqlDataReader["ChartOfAccountsT"]); + _GLRows.CreditChartOfAccounts = _uow.GetObjectByKey(_SqlDataReader["ChartOfAccountsK"]); + _GLRows.AmountHUF = (double)_SqlDataReader["SumPriceHUF"]; + _GLRows.AmountDEV = (double)_SqlDataReader["SumPriceDEV"]; + _GLRows.VAT = _uow.GetObjectByKey(_SqlDataReader["VAT"]); + _GLRows.GLRowsTypeVAT = eGLRowsTypeVAT.eNettoRow; + _GLRows.GLRowsType = eGLRowsType.eNormal; + _GLRows.PartnerType = ePartnerType.eReceivables; + _GLRows.Customer = _GLAccounts.Customers; + _GLRows.ConnectInfo = _GLAccounts.ConnectInfo; + _GLRows.DateVAT = _GLAccounts.DateExecution; + _GLRows.DateExecution = _GLAccounts.DateExecution; + _uow.CommitChanges(); + } + catch (Exception ex) + { + MigrationLog _MigrationLog = new MigrationLog(_uow_log); + _MigrationLog.UserCreated = _CurrentUser; + _MigrationLog.ShortName = string.Format("ERROR GLRows Netto: {0}", _SqlDataReader["DocumentNumber"].ToString().Trim()); + _MigrationLog.DateCreated = DateTime.Now; + _MigrationLog.Description = ex.Message; + _uow_log.CommitChanges(); + } + } + + } + } + + } + + /// Számla ÁFA rögzítése ... + _SQL = string.Format(" SELECT t1.VAT,t4.ChartOfAccountsOut As ChartOfAccountsT,t5.ChartOfAccountsOut As ChartOfAccountsK," + + " t1.AmountBruttoDEV,t1.AmountBruttoHUF,t1.AmountVATDEV,t1.AmountVATHUF,t1.AmountNettoHUF,t1.AmountNettoDEV" + + " FROM InvoiceVATRows t1 join InvoiceHeader t2 ON" + + " t1.InvoiceHeader = t2.Oid LEFT JOIN Customers t3 ON" + + " t2.Customers=t3.Oid LEFT JOIN CustomersGLParametersYear t4 ON" + + " Year(t2.DateExecution) = t4.AccountYear AND t4.CustomersGLParameters = t3.CustomersGLParameters LEFT JOIN VATYear t5 on" + + " Year(t2.DateExecution) = t5.AccountYear AND t1.VAT=t5.VAT" + + " WHERE t2.Oid = '{0}' AND t1.GCRecord IS NULL", _InvoiceHeader_OID); + using (SqlCommand _SqlCommand = new SqlCommand(_SQL, _SqlConnection)) + { + using (SqlDataReader _SqlDataReader = _SqlCommand.ExecuteReader()) + { + + if (_SqlDataReader.HasRows) + { + while (_SqlDataReader.Read()) + { + if ((double)_SqlDataReader["AmountVATHUF"] > 0.00) + { + try + { + + + _GLRows = new GLRows(_uow); + _GLRows.GLHeader = _GLAccounts; + _GLRows.NoteRows = "ÉRTÉKESÍTÉS ÁFA"; + _GLRows.DebitChartOfAccounts = _uow.GetObjectByKey(_SqlDataReader["ChartOfAccountsT"]); + _GLRows.CreditChartOfAccounts = _uow.GetObjectByKey(_SqlDataReader["ChartOfAccountsK"]); + _GLRows.AmountHUF = (double)_SqlDataReader["AmountVATHUF"]; + _GLRows.AmountDEV = (double)_SqlDataReader["AmountVATDEV"]; + _GLRows.VAT = _uow.GetObjectByKey(_SqlDataReader["VAT"]); + _GLRows.GLRowsTypeVAT = eGLRowsTypeVAT.eVATRow; + _GLRows.GLRowsType = eGLRowsType.eNormal; + _GLRows.PartnerType = ePartnerType.eReceivables; + _GLRows.Customer = _GLAccounts.Customers; + _GLRows.ConnectInfo = _GLAccounts.ConnectInfo; + _GLRows.DateVAT = _GLAccounts.DateExecution; + _GLRows.DateExecution = _GLAccounts.DateExecution; + _uow.CommitChanges(); + } + catch (Exception ex) + { + MigrationLog _MigrationLog = new MigrationLog(_uow_log); + _MigrationLog.UserCreated = _CurrentUser; + _MigrationLog.ShortName = string.Format("ERROR GLRows VAT: {0}", _SqlDataReader["DocumentNumber"].ToString().Trim()); + _MigrationLog.DateCreated = DateTime.Now; + _MigrationLog.Description = ex.Message; + _uow_log.CommitChanges(); + } + } + } + + } + } + + } + + GLFunctions.ReconfigurePCI(_uow, _GLAccounts.CustomersFrom, _GLAccounts.Customers, _GLAccounts.PartnerType, _GLAccounts.ConnectInfo); + _uow.CommitChanges(); + } + _SqlConnection.Close(); + _MySqlConnection.Close(); + _ocur.Session.ExecuteNonQuery("SET FOREIGN_KEY_CHECKS=1"); + + } + #endregion + + #region Partner szinkronizálása + private void Sync_Party_CustomersFrom_MSSQL_MySQL(XPObjectSpace _ocur) + { + MigrationParameters _MigrationParameters = View.SelectedObjects[0] as MigrationParameters; + _ocur.Session.ExecuteNonQuery("SET FOREIGN_KEY_CHECKS=0"); + string _ConnectionStringMSSQL = string.Format(" User ID={0}; " + + " Password={1};" + + " Pooling=false;" + + " Data Source={2};" + + " Initial Catalog={3}", + _MigrationParameters.SQLUser, + _MigrationParameters.SQLPassword, + _MigrationParameters.SQLServer, + _MigrationParameters.SQLDatabase); + + + + SqlConnection _SqlConnection = new SqlConnection(_ConnectionStringMSSQL); + MySqlConnection _MySqlConnection = new MySqlConnection(Nuvolar.Module.GeneralFunction.GLOBAL_ConnectionString.Replace("XpoProvider=MySql;", "")); + + _SqlConnection.Open(); + _MySqlConnection.Open(); + if (_SqlConnection.State == ConnectionState.Open) + { + int _ObjectType_OID = GetObjectTypeOID(_ocur); + + string _SQL = " SELECT t1.Oid,t1.ObjectType, " + + " t2.FullName,t2.Profile,t2.Email,t2.WebSite,t2.Description,t2.Name," + + " t3.CustomerNumber,t3.VATNumber,t3.VATNumberEU,t3.CustomersGLParameters " + + " from Party t1 JOIN Organization t2 on" + + " t1.Oid=t2.Oid JOIN Customers t3 on" + + " t1.Oid=t3.Oid JOIN CustomersFrom t4 on" + + " t1.Oid=t4.Oid" + + " where t1.GCRecord is null AND t1.Oid in (SELECT Oid FROM CustomersFrom)"; + SqlCommand _SqlCommand = new SqlCommand(_SQL, _SqlConnection); + SqlDataReader _SqlDataReader = _SqlCommand.ExecuteReader(); + + if (_SqlDataReader.HasRows) + { + while (_SqlDataReader.Read()) + { + string _MySQL = "SELECT count(*) FROM Party WHERE Oid=@Oid"; + using (MySqlCommand _MySqlCommand = new MySqlCommand() { CommandText = _MySQL, Connection = _MySqlConnection }) + { + _MySqlCommand.Parameters.Add(new MySqlParameter() { ParameterName = "@Oid", DbType = DbType.Guid, Value = _SqlDataReader["Oid"] }); + + object _Found = _MySqlCommand.ExecuteScalar(); + + if (_Found != null) + { + double _F; + IsNumeric(_Found, out _F); + if (_F == 0) + { + + _MySQL = " START TRANSACTION; " + + " SET FOREIGN_KEY_CHECKS=0;" + + " INSERT INTO Party (Oid,ObjectType)" + + " SELECT @Oid,@ObjectType;" + + " INSERT INTO Organization (Oid,FullName,Profile,Email,WebSite,Description,Name)" + + " SELECT @Oid,@FullName,@Profile,@Email,@WebSite,@Description,@Name;" + + " INSERT INTO Customers (Oid,CustomerNumber,VATNumber,VATNumberEU,CustomersGLParameters)" + + " SELECT @Oid,@CustomerNumber,@VATNumber,@VATNumberEU,@CustomersGLParameters;" + + " INSERT INTO CustomersFrom (Oid)" + + " SELECT @Oid;" + + " COMMIT;"; + using (MySqlCommand _MySqlCommand_Insert = new MySqlCommand() { CommandText = _MySQL, Connection = _MySqlConnection }) + { + _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@Oid", DbType = DbType.Guid, Value = _SqlDataReader["Oid"] }); + _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@ObjectType", DbType = DbType.Int64, Value = _ObjectType_OID }); + + _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@FullName", DbType = DbType.String, Value = _SqlDataReader["FullName"] }); + _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@Profile", DbType = DbType.String, Value = _SqlDataReader["Profile"] }); + _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@Email", DbType = DbType.String, Value = _SqlDataReader["Email"] }); + _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@WebSite", DbType = DbType.String, Value = _SqlDataReader["WebSite"] }); + _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@Description", DbType = DbType.String, Value = _SqlDataReader["Description"] }); + _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@Name", DbType = DbType.String, Value = _SqlDataReader["Name"] }); + + _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@CustomerNumber", DbType = DbType.String, Value = _SqlDataReader["CustomerNumber"] }); + _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@VATNumber", DbType = DbType.String, Value = _SqlDataReader["VATNumber"] }); + _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@VATNumberEU", DbType = DbType.String, Value = _SqlDataReader["VATNumberEU"] }); + _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@CustomersGLParameters", DbType = DbType.Guid, Value = _SqlDataReader["CustomersGLParameters"] }); + + _MySqlCommand_Insert.ExecuteNonQuery(); + } + } + else // Ha már VAN + { + //_MySQL = " SET FOREIGN_KEY_CHECKS=0;" + + // " UPDATE HCategory SET Name=@Name," + + // " Parent=@Parent " + + // " WHERE Oid=@Oid"; + //using (MySqlCommand _MySqlCommand_Update = new MySqlCommand() { CommandText = _MySQL, Connection = _MySqlConnection }) + //{ + + // _MySqlCommand_Update.Parameters.Add(new MySqlParameter() { ParameterName = "@Oid", DbType = DbType.Guid, Value = _SqlDataReader["Oid"] }); + // _MySqlCommand_Update.Parameters.Add(new MySqlParameter() { ParameterName = "@Parent", DbType = DbType.Guid, Value = _SqlDataReader["Parent"] }); + // _MySqlCommand_Update.Parameters.Add(new MySqlParameter() { ParameterName = "@Name", DbType = DbType.String, Value = _SqlDataReader["Name"] }); + + // _MySqlCommand_Update.ExecuteNonQuery(); + //} + + } + } + } + + } + } + + + } + _SqlConnection.Close(); + _MySqlConnection.Close(); + _ocur.Session.ExecuteNonQuery("SET FOREIGN_KEY_CHECKS=1"); + } + private void Sync_Party_Customers_One_MSSQL_MySQL(XPObjectSpace _ocur, string _Customers_OID) + { + MigrationParameters _MigrationParameters = View.SelectedObjects[0] as MigrationParameters; + _ocur.Session.ExecuteNonQuery("SET FOREIGN_KEY_CHECKS=0"); + string _ConnectionStringMSSQL = string.Format(" User ID={0}; " + + " Password={1};" + + " Pooling=false;" + + " Data Source={2};" + + " Initial Catalog={3}", + _MigrationParameters.SQLUser, + _MigrationParameters.SQLPassword, + _MigrationParameters.SQLServer, + _MigrationParameters.SQLDatabase); + + + + SqlConnection _SqlConnection = new SqlConnection(_ConnectionStringMSSQL); + MySqlConnection _MySqlConnection = new MySqlConnection(Nuvolar.Module.GeneralFunction.GLOBAL_ConnectionString.Replace("XpoProvider=MySql;", "")); + + _SqlConnection.Open(); + _MySqlConnection.Open(); + if (_SqlConnection.State == ConnectionState.Open) + { + int _ObjectType_OID = GetObjectTypeOID(_ocur); + + string _SQL = string.Format(" SELECT t1.Oid,t1.ObjectType, " + + " t2.FullName,t2.Profile,t2.Email,t2.WebSite,t2.Description,t2.Name," + + " t3.CustomerNumber,t3.VATNumber,t3.VATNumberEU,t3.CustomersGLParameters " + + " from Party t1 JOIN Organization t2 on" + + " t1.Oid=t2.Oid JOIN Customers t3 on" + + " t1.Oid=t3.Oid" + + " where t1.GCRecord is null AND t1.Oid in (SELECT Oid FROM Customers) AND t1.Oid ='{0}'", _Customers_OID); + + SqlCommand _SqlCommand = new SqlCommand(_SQL, _SqlConnection); + SqlDataReader _SqlDataReader = _SqlCommand.ExecuteReader(); + + if (_SqlDataReader.HasRows) + { + while (_SqlDataReader.Read()) + { + string _MySQL = "SELECT count(*) FROM Party WHERE Oid=@Oid"; + using (MySqlCommand _MySqlCommand = new MySqlCommand() { CommandText = _MySQL, Connection = _MySqlConnection }) + { + _MySqlCommand.Parameters.Add(new MySqlParameter() { ParameterName = "@Oid", DbType = DbType.Guid, Value = _SqlDataReader["Oid"] }); + + object _Found = _MySqlCommand.ExecuteScalar(); + + if (_Found != null) + { + double _F; + IsNumeric(_Found, out _F); + if (_F == 0) + { + + _MySQL = " START TRANSACTION; " + + " SET FOREIGN_KEY_CHECKS=0;" + + " INSERT INTO Party (Oid,ObjectType)" + + " SELECT @Oid,@ObjectType;" + + " INSERT INTO Organization (Oid,FullName,Profile,Email,WebSite,Description,Name)" + + " SELECT @Oid,@FullName,@Profile,@Email,@WebSite,@Description,@Name;" + + " INSERT INTO Customers (Oid,CustomerNumber,VATNumber,VATNumberEU,CustomersGLParameters)" + + " SELECT @Oid,@CustomerNumber,@VATNumber,@VATNumberEU,@CustomersGLParameters;" + + " COMMIT;"; + using (MySqlCommand _MySqlCommand_Insert = new MySqlCommand() { CommandText = _MySQL, Connection = _MySqlConnection }) + { + _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@Oid", DbType = DbType.Guid, Value = _SqlDataReader["Oid"] }); + _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@ObjectType", DbType = DbType.Int64, Value = _ObjectType_OID }); + + _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@FullName", DbType = DbType.String, Value = _SqlDataReader["FullName"] }); + _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@Profile", DbType = DbType.String, Value = _SqlDataReader["Profile"] }); + _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@Email", DbType = DbType.String, Value = _SqlDataReader["Email"] }); + _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@WebSite", DbType = DbType.String, Value = _SqlDataReader["WebSite"] }); + _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@Description", DbType = DbType.String, Value = _SqlDataReader["Description"] }); + _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@Name", DbType = DbType.String, Value = _SqlDataReader["Name"] }); + + _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@CustomerNumber", DbType = DbType.String, Value = _SqlDataReader["CustomerNumber"] }); + _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@VATNumber", DbType = DbType.String, Value = _SqlDataReader["VATNumber"] }); + _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@VATNumberEU", DbType = DbType.String, Value = _SqlDataReader["VATNumberEU"] }); + _MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@CustomersGLParameters", DbType = DbType.Guid, Value = _SqlDataReader["CustomersGLParameters"] }); + + _MySqlCommand_Insert.ExecuteNonQuery(); + } + } + else // Ha már VAN + { + //_MySQL = " SET FOREIGN_KEY_CHECKS=0;" + + // " UPDATE HCategory SET Name=@Name," + + // " Parent=@Parent " + + // " WHERE Oid=@Oid"; + //using (MySqlCommand _MySqlCommand_Update = new MySqlCommand() { CommandText = _MySQL, Connection = _MySqlConnection }) + //{ + + // _MySqlCommand_Update.Parameters.Add(new MySqlParameter() { ParameterName = "@Oid", DbType = DbType.Guid, Value = _SqlDataReader["Oid"] }); + // _MySqlCommand_Update.Parameters.Add(new MySqlParameter() { ParameterName = "@Parent", DbType = DbType.Guid, Value = _SqlDataReader["Parent"] }); + // _MySqlCommand_Update.Parameters.Add(new MySqlParameter() { ParameterName = "@Name", DbType = DbType.String, Value = _SqlDataReader["Name"] }); + + // _MySqlCommand_Update.ExecuteNonQuery(); + //} + + } + } + } + + } + } + + + } + _SqlConnection.Close(); + _MySqlConnection.Close(); + _ocur.Session.ExecuteNonQuery("SET FOREIGN_KEY_CHECKS=1"); + } + #endregion } } diff --git a/Nuvolar.Module.CSharp/BusinessObjects/Migration/Migration_VC.resx b/Nuvolar.Module.CSharp/BusinessObjects/Migration/Migration_VC.resx index 5469170..4de492a 100644 --- a/Nuvolar.Module.CSharp/BusinessObjects/Migration/Migration_VC.resx +++ b/Nuvolar.Module.CSharp/BusinessObjects/Migration/Migration_VC.resx @@ -118,7 +118,13 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - 17, 17 + 17, 95 + + + 17, 56 + + + 343, 17 False diff --git a/Nuvolar.Module.CSharp/Model.DesignedDiffs.Localization.hu.xafml b/Nuvolar.Module.CSharp/Model.DesignedDiffs.Localization.hu.xafml index 6758111..1c48494 100644 --- a/Nuvolar.Module.CSharp/Model.DesignedDiffs.Localization.hu.xafml +++ b/Nuvolar.Module.CSharp/Model.DesignedDiffs.Localization.hu.xafml @@ -4,6 +4,9 @@ + + + @@ -20,6 +23,9 @@ + + + @@ -58,6 +64,23 @@ + + + + + + + + + + + + + + + + + diff --git a/Nuvolar.Module.CSharp/Model.DesignedDiffs.xafml b/Nuvolar.Module.CSharp/Model.DesignedDiffs.xafml index c04017d..971cf3c 100644 --- a/Nuvolar.Module.CSharp/Model.DesignedDiffs.xafml +++ b/Nuvolar.Module.CSharp/Model.DesignedDiffs.xafml @@ -5,6 +5,9 @@ + + + diff --git a/Nuvolar.Module.CSharp/Nuvolar.Module.CSharp.csproj b/Nuvolar.Module.CSharp/Nuvolar.Module.CSharp.csproj index a00bc00..b16194b 100644 --- a/Nuvolar.Module.CSharp/Nuvolar.Module.CSharp.csproj +++ b/Nuvolar.Module.CSharp/Nuvolar.Module.CSharp.csproj @@ -248,6 +248,7 @@ PCIEdit_VC.cs + Component @@ -488,6 +489,10 @@ + + {98539DCF-BF11-4158-AEC0-4B008A404A0E} + Nuvolar.Module.Win + {60bf693f-7dea-4cf6-85bd-ea96829d79dd} Nuvolar.Module diff --git a/Nuvolar.Module.CSharp/Properties/AssemblyInfo.cs b/Nuvolar.Module.CSharp/Properties/AssemblyInfo.cs index 502efad..708a4f2 100644 --- a/Nuvolar.Module.CSharp/Properties/AssemblyInfo.cs +++ b/Nuvolar.Module.CSharp/Properties/AssemblyInfo.cs @@ -28,5 +28,5 @@ using System.Runtime.InteropServices; // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("20.1.4.1002")] +[assembly: AssemblyVersion("20.1.4.1005")] diff --git a/Nuvolar.Module/BusinessObjects/Financial/FinancialObjects/FinancialTransactions/GLEnums.vb b/Nuvolar.Module/BusinessObjects/Financial/FinancialObjects/FinancialTransactions/GLEnums.vb index 6b55b07..888d672 100644 --- a/Nuvolar.Module/BusinessObjects/Financial/FinancialObjects/FinancialTransactions/GLEnums.vb +++ b/Nuvolar.Module/BusinessObjects/Financial/FinancialObjects/FinancialTransactions/GLEnums.vb @@ -57,6 +57,11 @@ Public Enum eCashType eNormal = 1 eCorrectionHUF = 2 End Enum +''' +''' 1: Szállító +''' 0: Vevő +''' -1: Nincs beállítva +''' Public Enum ePartnerType eNotSet = -1 ePayabels = 1 'Szállítók