DEBRA szállítói számla feladás VOL2

This commit is contained in:
2020-09-07 22:56:48 +02:00
parent b1c2db4f35
commit 42147da6b7
10 changed files with 584 additions and 32 deletions
@@ -67,6 +67,7 @@
this.aMigrateInvoiceIn.TargetViewType = DevExpress.ExpressApp.ViewType.DetailView;
this.aMigrateInvoiceIn.ToolTip = null;
this.aMigrateInvoiceIn.TypeOfView = typeof(DevExpress.ExpressApp.DetailView);
this.aMigrateInvoiceIn.Execute += new DevExpress.ExpressApp.Actions.SimpleActionExecuteEventHandler(this.aMigrateInvoiceIn_Execute);
//
// Migration_VC
//
@@ -46,6 +46,7 @@ namespace Nuvolar.Module.BusinessObjects.Migration
if (_MigrationParameters.SQLType == eSQLType.MSSQL)
{
Sync_XPObjectType_MSSQL_MySQL(_ocur);
Sync_Country_MSSQL_MySQL(_ocur);
//Sync_HCategory_ChartOfAccounts_MSSQL_MySQL(_ocur);
//Sync_ChartOfAccounts_MSSQL_MySQL(_ocur);
//Sync_ChartOfAccountsYear_MSSQL_MySQL(_ocur);
@@ -59,13 +60,14 @@ namespace Nuvolar.Module.BusinessObjects.Migration
//Sync_CustomersGLParametersYear_MSSQL_MySQL(_ocur);
//Sync_Party_CustomersFrom_MSSQL_MySQL(_ocur);
Sync_PaymentOption_MSSQL_MySQL(_ocur);
//Sync_PaymentOption_MSSQL_MySQL(_ocur);
//Sync_LiquidAssets_MSSQL_MySQL(_ocur);
}
}
private void Sync_XPObjectType_MSSQL_MySQL(XPObjectSpace _ocur)
{
MakeObjectType<Country>(_ocur);
MakeObjectType<HCategory>(_ocur);
MakeObjectType<ChartOfAccounts>(_ocur);
MakeObjectType<ChartOfAccountsYear>(_ocur);
@@ -107,7 +109,105 @@ namespace Nuvolar.Module.BusinessObjects.Migration
}
return _return;
}
private void Sync_Country_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 Country t1 " +
" WHERE t1.GCRecord is null";
SqlCommand _SqlCommand = new SqlCommand(_SQL, _SqlConnection);
SqlDataReader _SqlDataReader = _SqlCommand.ExecuteReader();
int _ObjectType_OID = GetObjectTypeOID<Country>(_ocur);
if (_SqlDataReader.HasRows)
{
while (_SqlDataReader.Read())
{
string _MySQL = "SELECT count(*) FROM Country 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 Country (Oid,Name,PhoneCode,ObjectType,EUMember,ISOCode)" +
" SELECT @Oid,@Name,@PhoneCode,@ObjectType,@EUMember,@ISOCode";
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 = "@Name", DbType = DbType.String, Value = _SqlDataReader["Name"] });
_MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@PhoneCode", DbType = DbType.String, Value = _SqlDataReader["PhoneCode"] });
_MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@ObjectType", DbType = DbType.Int64, Value = _ObjectType_OID });
//_MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@Name_GB", DbType = DbType.String, Value = _SqlDataReader["Name_GB"] });
//_MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@ShortName", DbType = DbType.String, Value = _SqlDataReader["ShortName"] });
_MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@EUMember", DbType = DbType.Boolean, Value = _SqlDataReader["EUMember"] });
_MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@ISOCode", DbType = DbType.String, Value = _SqlDataReader["ISOCode"] });
_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_HCategory_ChartOfAccounts_MSSQL_MySQL(XPObjectSpace _ocur)
{
MigrationParameters _MigrationParameters = View.SelectedObjects[0] as MigrationParameters;
@@ -1135,9 +1235,9 @@ namespace Nuvolar.Module.BusinessObjects.Migration
{
_MySQL = " SET FOREIGN_KEY_CHECKS=0;" +
" INSERT INTO LiquidAssets (Oid,ShortName,Description,LiquidAssetsType,Description,Active,CurrencyName,IsRounding," +
" INSERT INTO LiquidAssets (Oid,ShortName,Description,CustomerFrom,LiquidAssetsType,Active,CurrencyName,IsRounding," +
" NoPrint,NoDocumentNumber,NoTimeCheck)" +
" SELECT @Oid,@ShortName,@Description,@LiquidAssetsType,@Description,@Active,@CurrencyName,@IsRounding," +
" SELECT @Oid,@ShortName,@Description,@CustomerFrom,@LiquidAssetsType,@Active,@CurrencyName,@IsRounding," +
" @NoPrint,@NoDocumentNumber,@NoTimeCheck;";
using (MySqlCommand _MySqlCommand_Insert = new MySqlCommand() { CommandText = _MySQL, Connection = _MySqlConnection })
{
@@ -1145,6 +1245,18 @@ namespace Nuvolar.Module.BusinessObjects.Migration
_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 = "@CustomerFrom", DbType = DbType.Guid, Value = _SqlDataReader["CustomerFrom"] });
_MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@LiquidAssetsType", DbType = DbType.String, Value = _SqlDataReader["LiquidAssetsType"] });
_MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@Active", DbType = DbType.Boolean, Value = _SqlDataReader["Active"] });
_MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@CurrencyName", DbType = DbType.Guid, Value = _SqlDataReader["CurrencyName"] });
_MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@IsRounding", DbType = DbType.Boolean, Value = _SqlDataReader["IsRounding"] });
_MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@NoPrint", DbType = DbType.Boolean, Value = _SqlDataReader["NoPrint"] });
_MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@NoDocumentNumber", DbType = DbType.Boolean, Value = _SqlDataReader["NoDocumentNumber"] });
_MySqlCommand_Insert.Parameters.Add(new MySqlParameter() { ParameterName = "@NoTimeCheck", DbType = DbType.Boolean, Value = _SqlDataReader["NoTimeCheck"] });
_MySqlCommand_Insert.ExecuteNonQuery();
}
}
@@ -1172,6 +1284,93 @@ namespace Nuvolar.Module.BusinessObjects.Migration
}
}
_SqlConnection.Close();
_MySqlConnection.Close();
_ocur.Session.ExecuteNonQuery("SET FOREIGN_KEY_CHECKS=1");
}
private void Sync_CurrencyName_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 CurrencyName 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 CurrencyName WHERE ShortName=@Shortname";
using (MySqlCommand _MySqlCommand = new MySqlCommand() { CommandText = _MySQL, Connection = _MySqlConnection })
{
_MySqlCommand.Parameters.Add(new MySqlParameter() { ParameterName = "@Shortname", DbType = DbType.Guid, Value = _SqlDataReader["ShortName"] });
object _Found = _MySqlCommand.ExecuteScalar();
if (_Found != null)
{
double _F;
IsNumeric(_Found, out _F);
if (_F == 0)
{
_MySQL = " SET FOREIGN_KEY_CHECKS=0;" +
" INSERT INTO CurrencyName (Oid,ShortName)" +
" SELECT @Oid,@ShortName,@Description;";
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.ExecuteNonQuery();
}
}
else // Ha már VAN
{
_MySQL = " SET FOREIGN_KEY_CHECKS=0;" +
" UPDATE CurrencyName SET Oid=@Oid" +
" WHERE ShortName=@ShortName";
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 = "@ShortName", DbType = DbType.String, Value = _SqlDataReader["ShortName"] });
_MySqlCommand_Update.ExecuteNonQuery();
}
}
}
}
}
}
}
_SqlConnection.Close();
_MySqlConnection.Close();
@@ -1293,6 +1492,12 @@ namespace Nuvolar.Module.BusinessObjects.Migration
XPObjectSpace _ocur = View.ObjectSpace as XPObjectSpace;
Sync_Invoice_Out_By_Date_MSSQL_MySQL(_ocur);
}
private void aMigrateInvoiceIn_Execute(object sender, SimpleActionExecuteEventArgs e)
{
MigrationParameters _MigrationParameters = View.SelectedObjects[0] as MigrationParameters;
XPObjectSpace _ocur = View.ObjectSpace as XPObjectSpace;
Sync_Invoice_In_By_Date_MSSQL_MySQL(_ocur);
}
#region Vevői számlák
private void Sync_Invoice_Out_By_Date_MSSQL_MySQL(XPObjectSpace _ocur)
@@ -1536,23 +1741,23 @@ namespace Nuvolar.Module.BusinessObjects.Migration
try
{
_GLRows = new GLRows(_uow);
_GLRows.GLHeader = _GLAccounts;
_GLRows.NoteRows = "ÉRTÉKESÍTÉS ÁFA";
_GLRows.DebitChartOfAccounts = _uow.GetObjectByKey<ChartOfAccounts>(_SqlDataReader["ChartOfAccountsT"]);
_GLRows.CreditChartOfAccounts = _uow.GetObjectByKey<ChartOfAccounts>(_SqlDataReader["ChartOfAccountsK"]);
_GLRows.AmountHUF = (double)_SqlDataReader["AmountVATHUF"];
_GLRows.AmountDEV = (double)_SqlDataReader["AmountVATDEV"];
_GLRows.VAT = _uow.GetObjectByKey<VAT>(_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();
_GLRows = new GLRows(_uow);
_GLRows.GLHeader = _GLAccounts;
_GLRows.NoteRows = "ÉRTÉKESÍTÉS ÁFA";
_GLRows.DebitChartOfAccounts = _uow.GetObjectByKey<ChartOfAccounts>(_SqlDataReader["ChartOfAccountsT"]);
_GLRows.CreditChartOfAccounts = _uow.GetObjectByKey<ChartOfAccounts>(_SqlDataReader["ChartOfAccountsK"]);
_GLRows.AmountHUF = (double)_SqlDataReader["AmountVATHUF"];
_GLRows.AmountDEV = (double)_SqlDataReader["AmountVATDEV"];
_GLRows.VAT = _uow.GetObjectByKey<VAT>(_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)
{
@@ -1568,7 +1773,7 @@ namespace Nuvolar.Module.BusinessObjects.Migration
}
}
}
GLFunctions.ReconfigurePCI(_uow, _GLAccounts.CustomersFrom, _GLAccounts.Customers, _GLAccounts.PartnerType, _GLAccounts.ConnectInfo);
@@ -1808,6 +2013,296 @@ namespace Nuvolar.Module.BusinessObjects.Migration
_MySqlConnection.Close();
_ocur.Session.ExecuteNonQuery("SET FOREIGN_KEY_CHECKS=1");
}
private void Sync_Address_One_MSSQL_MySQL(XPObjectSpace _ocur, string _Address_OID)
{
}
#endregion
#region Szállítói számlák
private void Sync_Invoice_In_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<User>(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 GLHeader t1 join GLAccounts t2 on t1.Oid = t2.Oid WHERE t1.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 GLHeader t1 join GLAccounts t2 on t1.Oid = t2.Oid " +
" WHERE t1.DateExecution>='{0}' AND t1.DateExecution <='{1}' AND t1.GCRecord IS NULL AND t1.IsEditable=False",
_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_In_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 IN : GLHeader {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_In_MSSQL_MySQL(XPObjectSpace _ocur,string _GLHeader_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<User>(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 GLHeader t1 JOIN GLAccounts t2 on t1.Oid=t2.Oid" +
" WHERE t1.GCRecord is null AND t1.Oid='{0}' AND t1.IsEditable=False", _GLHeader_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<GLAccounts>(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<Customers>(_SqlDataReader["Customers"]);
_GLAccounts.CustomersFrom = _uow.GetObjectByKey<CustomersFrom>(_SqlDataReader["CustomersFrom"]);
_GLAccounts.CurrencyName = _uow.GetObjectByKey<CurrencyName>(_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<PaymentOption>(_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<ChartOfAccounts>(_SqlDataReader["ChartOfAccountsT"]);
_GLRows.CreditChartOfAccounts = _uow.GetObjectByKey<ChartOfAccounts>(_SqlDataReader["ChartOfAccountsK"]);
_GLRows.AmountHUF = (double)_SqlDataReader["SumPriceHUF"];
_GLRows.AmountDEV = (double)_SqlDataReader["SumPriceDEV"];
_GLRows.VAT = _uow.GetObjectByKey<VAT>(_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<ChartOfAccounts>(_SqlDataReader["ChartOfAccountsT"]);
_GLRows.CreditChartOfAccounts = _uow.GetObjectByKey<ChartOfAccounts>(_SqlDataReader["ChartOfAccountsK"]);
_GLRows.AmountHUF = (double)_SqlDataReader["AmountVATHUF"];
_GLRows.AmountDEV = (double)_SqlDataReader["AmountVATDEV"];
_GLRows.VAT = _uow.GetObjectByKey<VAT>(_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
}
}
@@ -118,10 +118,10 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="aMigrateBaseObjects.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 95</value>
<value>17, 56</value>
</metadata>
<metadata name="aMigrateInvoiceOut.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 56</value>
<value>17, 95</value>
</metadata>
<metadata name="aMigrateInvoiceIn.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>343, 17</value>