private static List <ORM_BIL_BillHeader_MethodOfPayment> Search(Query query, string connectionString, DbConnection connection, DbTransaction transaction) { CSV2Core.Core.Interfaces.IManagedConnection managedConnection = new CSV2Core_MySQL.MySQLManagedConnection(); List <ORM_BIL_BillHeader_MethodOfPayment> items; try { managedConnection.set(connectionString, connection, transaction); var loader = new CSV2Core_MySQL.Dictionaries.MultiTable.Loader.DictionaryLoader(managedConnection.getConnection(), managedConnection.getTransaction()); DbCommand command = managedConnection.manage(query.CreateSelectQuery(TableName)); query.SetParameters(command); items = new List <ORM_BIL_BillHeader_MethodOfPayment>(); var reader = new CSV2Core_MySQL.Support.DBSQLReader(command.ExecuteReader()); reader.SetOrdinals(new string[] { "BIL_BillHeader_MethodOfPaymentID", "BIL_BillHeader_RefID", "ACC_PAY_Type_RefID", "IsPreferredMethodOfPayment", "SequenceNumber", "Creation_Timestamp", "Tenant_RefID", "IsDeleted" }); while (reader.Read()) { ORM_BIL_BillHeader_MethodOfPayment item = new ORM_BIL_BillHeader_MethodOfPayment(); //0:Parameter BIL_BillHeader_MethodOfPaymentID of type Guid item.BIL_BillHeader_MethodOfPaymentID = reader.GetGuid(0); //1:Parameter BIL_BillHeader_RefID of type Guid item.BIL_BillHeader_RefID = reader.GetGuid(1); //2:Parameter ACC_PAY_Type_RefID of type Guid item.ACC_PAY_Type_RefID = reader.GetGuid(2); //3:Parameter IsPreferredMethodOfPayment of type Boolean item.IsPreferredMethodOfPayment = reader.GetBoolean(3); //4:Parameter SequenceNumber of type int item.SequenceNumber = reader.GetInteger(4); //5:Parameter Creation_Timestamp of type DateTime item.Creation_Timestamp = reader.GetDate(5); //6:Parameter Tenant_RefID of type Guid item.Tenant_RefID = reader.GetGuid(6); //7:Parameter IsDeleted of type Boolean item.IsDeleted = reader.GetBoolean(7); item.Status_IsAlreadySaved = true; item.Status_IsDirty = false; items.Add(item); } reader.Close(); loader.Load(); managedConnection.commit(); } catch (Exception ex) { managedConnection.rollback(); throw; } return(items); }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5CO_CBH_1606 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); ORM_BIL_BillHeader billHeader = null; ORM_BIL_BillHeader_2_BillStatus billHeader2BillStatus = null; ORM_CMN_UniversalContactDetail universalContactDetail = null; var BillParam = Parameter.Bill_Parameter.BillHeaderData; #region Preloading data ORM_USR_Account account = new ORM_USR_Account(); account.Load(Connection, Transaction, securityTicket.AccountID); var customer = ORM_CMN_BPT_CTM_Customer.Query.Search(Connection, Transaction, new ORM_CMN_BPT_CTM_Customer.Query() { CMN_BPT_CTM_CustomerID = BillParam.BillingReceiverCustomer.CMN_BPT_CTM_CustomerID }).SingleOrDefault(); List <L3ACAAD_GCAfT_1612> customerAddresses = cls_Get_CustomerAddresses_for_CustomerID.Invoke(Connection, Transaction, new P_L3ACAAD_GCAfCID_1612 { CustomerID = BillParam.BillingReceiverCustomer.CMN_BPT_CTM_CustomerID }, securityTicket).Result.ToList(); L3ACAAD_GCAfT_1612 customerAddress = customerAddresses.Where(x => x.AddressID == BillParam.BillingAddressID).SingleOrDefault(); var incrNumberParam = new P_L2NR_GaIINfUA_1454() { GlobalStaticMatchingID = EnumUtils.GetEnumDescription(ENumberRangeUsageAreaType.BillNumber) }; var billNumber = cls_Get_and_Increase_IncreasingNumber_for_UsageArea.Invoke(Connection, Transaction, incrNumberParam, securityTicket).Result.Current_IncreasingNumber; #endregion #region Universal Contact Detail universalContactDetail = new ORM_CMN_UniversalContactDetail() { CMN_UniversalContactDetailID = Guid.NewGuid(), Country_639_1_ISOCode = customerAddress.Country_639_1_ISOCode, Country_Name = customerAddress.Country_Name, Street_Name = customerAddress.Street_Name, Street_Number = customerAddress.Street_Number, Town = customerAddress.Town, ZIP = customerAddress.ZIP, Tenant_RefID = account.Tenant_RefID, CompanyName_Line1 = BillParam.BillingReceiverCustomer.DisplayName, First_Name = BillParam.BillingReceiverCustomer.FirstName, Last_Name = BillParam.BillingReceiverCustomer.LastName, IsCompany = BillParam.BillingReceiverCustomer.IsCompany }; universalContactDetail.Save(Connection, Transaction); #endregion #region Bill Header billHeader = new ORM_BIL_BillHeader { BIL_BillHeaderID = Guid.NewGuid(), BillNumber = billNumber, CreatedBy_BusinessParticipant_RefID = account.BusinessParticipant_RefID, BillRecipient_BuisnessParticipant_RefID = customer.Ext_BusinessParticipant_RefID, TotalValue_BeforeTax = 0, TotalValue_IncludingTax = 0, BillingAddress_UCD_RefID = universalContactDetail.CMN_UniversalContactDetailID, DateOnBill = BillParam.BillingDate, BillComment = BillParam.Comment, Currency_RefID = cls_Get_DefaultCurrency_for_Tenant.Invoke(Connection, Transaction, securityTicket).Result.CMN_CurrencyID, BillHeader_PaymentCondition_RefID = Parameter.Bill_Parameter.BillHeaderData.PaymentTargetID, Tenant_RefID = securityTicket.TenantID }; billHeader.Save(Connection, Transaction); #endregion #region Method of Payment var methodOfPayment = new CL1_BIL.ORM_BIL_BillHeader_MethodOfPayment { BIL_BillHeader_MethodOfPaymentID = Guid.NewGuid(), ACC_PAY_Type_RefID = Parameter.Bill_Parameter.BillHeaderData.PaymentTypeID, BIL_BillHeader_RefID = billHeader.BIL_BillHeaderID, IsPreferredMethodOfPayment = true, SequenceNumber = 0, Tenant_RefID = securityTicket.TenantID }; methodOfPayment.Save(Connection, Transaction); #endregion #region Bill Status - Created var statusCreated = ORM_BIL_BillStatus.Query.Search(Connection, Transaction, new ORM_BIL_BillStatus.Query() { GlobalPropertyMatchingID = EnumUtils.GetEnumDescription(EBillStatus.Created), Tenant_RefID = account.Tenant_RefID, IsDeleted = false }).Single(); billHeader2BillStatus = new ORM_BIL_BillHeader_2_BillStatus { AssignmentID = Guid.NewGuid(), BIL_BillHeader_RefID = billHeader.BIL_BillHeaderID, BIL_BillStatus_RefID = statusCreated.BIL_BillStatusID, Tenant_RefID = account.Tenant_RefID, IsCurrentStatus = true }; billHeader2BillStatus.Save(Connection, Transaction); #endregion returnValue.Result = billHeader.BIL_BillHeaderID; return(returnValue); #endregion UserCode }