Пример #1
0
        protected static FR_L6SR_GSRHIfRH_1646 Execute(DbConnection Connection, DbTransaction Transaction, P_L6SR_GSRHIfRH_1646 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_L6SR_GSRHIfRH_1646();

            P_L5SR_GRaPHfRH_1636 param = new P_L5SR_GRaPHfRH_1636();
            param.ReceiptHeaderID = Parameter.ReceiptHeaderID;

            var receceiptHeader = cls_Get_ReceiptHeader_and_ProcurmentHeader_for_ReceiptHeaderID.Invoke(Connection, Transaction, param, securityTicket).Result;

            if (receceiptHeader == null)
            {
                return(returnValue);
            }

            var accountsParam = new List <Guid>();

            if (receceiptHeader.IsQualityControlPerformed)
            {
                accountsParam.Add(receceiptHeader.QualityControlPerformed_ByAccount_RefID);
            }
            if (receceiptHeader.IsTakenIntoStock)
            {
                accountsParam.Add(receceiptHeader.TakenIntoStock_ByAccount_RefID);
            }
            if (receceiptHeader.IsPriceConditionsManuallyCleared)
            {
                accountsParam.Add(receceiptHeader.PriceConditionsManuallyCleared_ByAccount_RefID);
            }
            if (receceiptHeader.IsReceiptForwardedToBookkeeping)
            {
                accountsParam.Add(receceiptHeader.ReceiptForwardedToBookkeeping_ByAccount_RefID);
            }

            var accounts = new List <CL2_AC_GADNoAfT_1621>();

            if (accountsParam.Count() != 0)
            {
                accounts = cls_Get_AllDisplayNames_of_Accounts_for_TenantID.Invoke(Connection, Transaction, securityTicket).Result.ToList();
            }

            #region Supplier Info

            var supplierInfo = new L5ALSU_GSfToS_1546();
            if (receceiptHeader.ProvidingSupplier_RefID != Guid.Empty)
            {
                P_L5ALSU_GSfToS_1546 supplierParam = new P_L5ALSU_GSfToS_1546();
                supplierParam.CMN_BPT_SupplierID = receceiptHeader.ProvidingSupplier_RefID;

                supplierInfo = cls_Get_Suppliers_for_TenantID_or_SupplierID.Invoke(Connection, Transaction, supplierParam, securityTicket).Result.SingleOrDefault();
            }

            #endregion

            #region BillInfo

            ORM_ORD_PRC_SPB_SupplierBill_Header billHeader = new ORM_ORD_PRC_SPB_SupplierBill_Header();

            if (receceiptHeader.IsReceiptForwardedToBookkeeping)
            {
                var receiptToSupplierBillHeader = ORM_ORD_PRC_SPB_SupplierBill_2_ReceiptHeader.Query.Search(Connection, Transaction,
                                                                                                            new ORM_ORD_PRC_SPB_SupplierBill_2_ReceiptHeader.Query()
                {
                    LOG_RCP_Receipt_Header_RefID = receceiptHeader.LOG_RCP_Receipt_HeaderID,
                    IsDeleted = false
                }).SingleOrDefault();

                if (receiptToSupplierBillHeader != null)
                {
                    billHeader = ORM_ORD_PRC_SPB_SupplierBill_Header.Query.Search(Connection, Transaction,
                                                                                  new ORM_ORD_PRC_SPB_SupplierBill_Header.Query()
                    {
                        ORD_PRC_SPB_SupplierBill_HeaderID = receiptToSupplierBillHeader.ORD_PRC_SPB_SupplierBill_Header_RefID,
                        IsDeleted = false
                    }).SingleOrDefault();
                }
            }

            #endregion

            returnValue.Result = new L6SR_GSRHIfRH_1646();
            returnValue.Result.LOG_RCP_Receipt_HeaderID = receceiptHeader.LOG_RCP_Receipt_HeaderID;

            returnValue.Result.ProcurementOrder_Number = receceiptHeader.ProcurementOrder_Number;
            returnValue.Result.ReceiptNumber           = receceiptHeader.ReceiptNumber;

            returnValue.Result.ProvidingSupplier_RefID = receceiptHeader.ProvidingSupplier_RefID;
            returnValue.Result.SupplierName            = supplierInfo.CompanyName_Line1;
            returnValue.Result.SupplierType            = supplierInfo.SupplierType_Name.CopyContents(ORM_CMN_BPT_Supplier_Type.TableName);

            returnValue.Result.BillNumber      = billHeader.SupplierBillNumber;
            returnValue.Result.BillDate        = billHeader.DateOnBill;
            returnValue.Result.PaymentDeadline = billHeader.PaymentTargetDate;

            returnValue.Result.IsQualityControlPerformed = receceiptHeader.IsQualityControlPerformed;
            returnValue.Result.QualityControlPerformed_ByAccount_RefID = receceiptHeader.QualityControlPerformed_ByAccount_RefID;
            returnValue.Result.QualityControlPerformed_By     = accounts.Where(i => i.USR_AccountID == receceiptHeader.QualityControlPerformed_ByAccount_RefID).Select(j => j.DisplayName).SingleOrDefault();
            returnValue.Result.QualityControlPerformed_AtDate = receceiptHeader.QualityControlPerformed_AtDate;

            returnValue.Result.IsTakenIntoStock = receceiptHeader.IsTakenIntoStock;
            returnValue.Result.TakenIntoStock_ByAccount_RefID = receceiptHeader.TakenIntoStock_ByAccount_RefID;
            returnValue.Result.TakenIntoStock_ByAccount_By    = accounts.Where(i => i.USR_AccountID == receceiptHeader.TakenIntoStock_ByAccount_RefID).Select(j => j.DisplayName).SingleOrDefault();
            returnValue.Result.TakenIntoStock_AtDate          = receceiptHeader.TakenIntoStock_AtDate;

            returnValue.Result.IsPriceConditionsManuallyCleared = receceiptHeader.IsPriceConditionsManuallyCleared;
            returnValue.Result.PriceConditionsManuallyCleared_ByAccount_RefID = receceiptHeader.PriceConditionsManuallyCleared_ByAccount_RefID;
            returnValue.Result.PriceConditionsManuallyCleared_By     = accounts.Where(i => i.USR_AccountID == receceiptHeader.PriceConditionsManuallyCleared_ByAccount_RefID).Select(j => j.DisplayName).SingleOrDefault();
            returnValue.Result.PriceConditionsManuallyCleared_AtDate = receceiptHeader.PriceConditionsManuallyCleared_AtDate;

            returnValue.Result.IsReceiptForwardedToBookkeeping = receceiptHeader.IsReceiptForwardedToBookkeeping;
            returnValue.Result.ReceiptForwardedToBookkeeping_ByAccount_RefID = receceiptHeader.ReceiptForwardedToBookkeeping_ByAccount_RefID;
            returnValue.Result.ReceiptForwardedToBookkeeping_By     = accounts.Where(i => i.USR_AccountID == receceiptHeader.ReceiptForwardedToBookkeeping_ByAccount_RefID).Select(j => j.DisplayName).SingleOrDefault();
            returnValue.Result.ReceiptForwardedToBookkeeping_AtDate = receceiptHeader.ReceiptForwardedToBookkeeping_AtDate;



            return(returnValue);

            #endregion UserCode
        }
Пример #2
0
 ///<summary>
 /// Invokes the method for the given Connection, and Transaction, leaving them open/not commited if no exceptions occured
 ///<summary>
 public static FR_L6SR_GSRHIfRH_1646 Invoke(DbConnection Connection, DbTransaction Transaction, P_L6SR_GSRHIfRH_1646 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
 {
     return(Invoke(Connection, Transaction, null, Parameter, securityTicket));
 }
Пример #3
0
        ///<summary>
        /// Method Invocation of wrapper classes
        ///<summary>
        protected static FR_L6SR_GSRHIfRH_1646 Invoke(DbConnection Connection, DbTransaction Transaction, string ConnectionString, P_L6SR_GSRHIfRH_1646 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            bool cleanupConnection  = Connection == null;
            bool cleanupTransaction = Transaction == null;

            FR_L6SR_GSRHIfRH_1646 functionReturn = new FR_L6SR_GSRHIfRH_1646();

            try
            {
                if (cleanupConnection == true)
                {
                    Connection = CSV2Core_MySQL.Support.DBSQLSupport.CreateConnection(ConnectionString);
                    Connection.Open();
                }
                if (cleanupTransaction == true)
                {
                    Transaction = Connection.BeginTransaction();
                }

                functionReturn = Execute(Connection, Transaction, Parameter, securityTicket);

                #region Cleanup Connection/Transaction
                //Commit the transaction
                if (cleanupTransaction == true)
                {
                    Transaction.Commit();
                }
                //Close the connection
                if (cleanupConnection == true)
                {
                    Connection.Close();
                }
                #endregion
            }
            catch (Exception ex)
            {
                try
                {
                    if (cleanupTransaction == true && Transaction != null)
                    {
                        Transaction.Rollback();
                    }
                }
                catch { }

                try
                {
                    if (cleanupConnection == true && Connection != null)
                    {
                        Connection.Close();
                    }
                }
                catch { }

                throw new Exception("Exception occured in method cls_Get_StockReceiptHeaderInfo_for_ReceiptHeaderID", ex);
            }
            return(functionReturn);
        }
Пример #4
0
 ///<summary>
 /// Opens the connection/transaction for the given connectionString, and closes them when complete
 ///<summary>
 public static FR_L6SR_GSRHIfRH_1646 Invoke(string ConnectionString, P_L6SR_GSRHIfRH_1646 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
 {
     return(Invoke(null, null, ConnectionString, Parameter, securityTicket));
 }