public static bool UpdateTempStatus(
            List <int> lstRefNumbers,
            StateStatus TempStatus,
            string storeNumber,
            bool bFlag,
            List <string> refType,
            out string errorCode,
            out string errorText)
        {
            //Set default output values
            errorCode = string.Empty;
            errorText = string.Empty;

            //Verify that the accessor is valid
            if (GlobalDataAccessor.Instance == null ||
                GlobalDataAccessor.Instance.OracleDA == null)
            {
                errorCode = "GetTempStatus";
                errorText = "Invalid desktop session or data accessor instance";
                BasicExceptionHandler.Instance.AddException("GetTempStatus", new ApplicationException("Cannot execute the UpdateTempStatus update stored procedure"));
                return(false);
            }

            //Get data accessor object
            var dA = GlobalDataAccessor.Instance.OracleDA;

            //Create input list
            List <OracleProcParam> inParams = new List <OracleProcParam>();

            OracleProcParam maskParam = new OracleProcParam(ParameterDirection.Input, DataTypeConstants.PawnDataType.LISTSTRING, "p_ref_numbers", lstRefNumbers.Count);

            foreach (int i in lstRefNumbers)
            {
                maskParam.AddValue(i.ToString());
            }
            inParams.Add(maskParam);

            if (TempStatus == StateStatus.BLNK)
            {
                inParams.Add(new OracleProcParam("p_temp_status", ""));
            }
            else
            {
                inParams.Add(new OracleProcParam("p_temp_status", TempStatus.ToString()));
            }
            inParams.Add(new OracleProcParam("p_store_number", storeNumber));
            inParams.Add(new OracleProcParam("p_flag", (bFlag ? "Y" : "N")));
            inParams.Add(new OracleProcParam("p_updated_by", GlobalDataAccessor.Instance.DesktopSession.UserName));
            inParams.Add(new OracleProcParam("p_ref_type", true, refType));

            //Setup ref cursor array
            List <PairType <string, string> > refCursors = new List <PairType <string, string> >();

            refCursors.Add(new PairType <string, string>("r_temp_status", "temp_status"));

            DataSet outputDataSet;
            //Create output data set names
            bool retVal = false;

            try
            {
                retVal = dA.issueSqlStoredProcCommand(
                    "ccsowner", "SERVICE_PAWN_LOANS", "Update_temp_status",
                    inParams, refCursors, "o_error_code", "o_error_text",
                    out outputDataSet);
            }
            catch (OracleException oEx)
            {
                errorCode = "UpdateTempStatusFailed";
                errorText = "Invocation of UpdateTempStatus stored proc failed";
                BasicExceptionHandler.Instance.AddException("OracleException thrown when invoking UpdateTempStatus stored proc", oEx);
                return(false);
            }

            //See if retVal is false
            if (retVal == false)
            {
                errorCode = dA.ErrorCode;
                errorText = dA.ErrorDescription;
                return(false);
            }
            else
            {
                errorCode = "0";
                errorText = string.Empty;
                return(true);
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="storeNumber"></param>
        /// <param name="refType"></param>
        /// <param name="refNumber"></param>
        /// <param name="transitionData"></param>
        /// <param name="tempStatus"></param>
        /// <param name="transDate"></param>
        /// <param name="errorCode"></param>
        /// <param name="errorText"></param>
        /// <returns></returns>
        public static bool SetLoanTransition(
            string storeNumber,
            ProductType refType,
            int refNumber,
            string transitionData,
            StateStatus tempStatus,
            DateTime transDate,
            out string errorCode,
            out string errorText)
        {
            //Set default output values
            errorCode = string.Empty;
            errorText = string.Empty;

            //Verify that the accessor is valid
            if (GlobalDataAccessor.Instance.DesktopSession == null ||
                GlobalDataAccessor.Instance.OracleDA == null)
            {
                errorCode = "InsertLoanTransition";
                errorText = "Invalid desktop session or data accessor instance";
                BasicExceptionHandler.Instance.AddException("SetLoanTransition",
                                                            new ApplicationException(
                                                                "Cannot execute the InsertLoanTransition update stored procedure"));
                return(false);
            }
            if (string.IsNullOrEmpty(transitionData))
            {
                errorCode = "InsertLoanTransition";
                errorText = "No Transition data sent to insert";
                BasicExceptionHandler.Instance.AddException("SetLoanTransition",
                                                            new ApplicationException(
                                                                "Cannot execute the InsertLoanTransition update stored procedure"));
                return(false);
            }

            //Get data accessor object
            OracleDataAccessor dA = GlobalDataAccessor.Instance.OracleDA;

            //Create input list
            List <OracleProcParam> inParams = new List <OracleProcParam>();

            inParams.Add(new OracleProcParam("p_ref_type", (int)refType));
            inParams.Add(new OracleProcParam("p_ref_number", refNumber));
            inParams.Add(new OracleProcParam("p_ref_store", storeNumber));
            inParams.Add(new OracleProcParam("p_trans_data", transitionData, true));
            inParams.Add(new OracleProcParam("p_trans_type", tempStatus.ToString()));
            OracleProcParam.TimeStampType tsType = OracleProcParam.TimeStampType.TIMESTAMP_TZ;
            inParams.Add(new OracleProcParam("p_trans_date", transDate, tsType));
            inParams.Add(new OracleProcParam("p_created_by", GlobalDataAccessor.Instance.DesktopSession.UserName));

            //Create output data set names
            bool retVal;

            try
            {
                DataSet outputDataSet;
                retVal = dA.issueSqlStoredProcCommand(
                    "ccsowner", "PAWN_STORE_PROCS", "insert_loan_transition",
                    inParams, null, "o_error_code", "o_error_text",
                    out outputDataSet);
            }
            catch (OracleException oEx)
            {
                errorCode = "InsertLoanTransitionFailed";
                errorText = "Invocation of InsertLoanTransition stored proc failed";
                BasicExceptionHandler.Instance.AddException(
                    "OracleException thrown when invoking InsertLoanTransition stored proc", oEx);
                return(false);
            }

            //See if retVal is false
            if (retVal == false)
            {
                errorCode = dA.ErrorCode;
                errorText = dA.ErrorDescription;
                return(false);
            }
            errorCode = "0";
            errorText = string.Empty;
            return(true);
        }
        /// <summary>
        /// Get all the pawn loans based on the id number passed
        /// </summary>
        /// <param name="storeNumber"></param>
        /// <param name="pawnLoanStatus"></param>
        /// <param name="TempStatus"></param>
        /// <param name="date"></param>
        /// <param name="bGetCustomerInfo"></param>
        /// <param name="pawnLoans"></param>
        /// <param name="pawnApplications"></param>
        /// <param name="customerVOs"></param>
        /// <param name="errorCode"></param>
        /// <param name="errorText"></param>
        /// <returns></returns>
        public static bool GetStoreLoans(
            string storeNumber,
            ProductStatus pawnLoanStatus,
            StateStatus TempStatus,
            DateTime date,
            bool bGetCustomerInfo,
            out List <PawnLoan> pawnLoans,
            out List <PawnAppVO> pawnApplications,
            out List <CustomerVO> customerVOs,
            out string errorCode,
            out string errorText)
        {
            //Set default output params
            pawnLoans        = new List <PawnLoan>();
            pawnApplications = new List <PawnAppVO>();
            customerVOs      = new List <CustomerVO>();
            errorCode        = string.Empty;
            errorText        = string.Empty;

            if (GlobalDataAccessor.Instance == null ||
                GlobalDataAccessor.Instance.OracleDA == null)
            {
                errorCode = "GetStoreLoansFailed";
                errorText = "Invalid desktop session or data accessor";
                return(false);
            }

            //Get data accessor object
            OracleDataAccessor     dA       = GlobalDataAccessor.Instance.OracleDA;
            List <OracleProcParam> inParams = new List <OracleProcParam>();

            //Add store number
            inParams.Add(new OracleProcParam("p_store_number", storeNumber));
            inParams.Add(new OracleProcParam("p_status", pawnLoanStatus.ToString()));
            inParams.Add(new OracleProcParam("p_date", date));
            if (TempStatus != StateStatus.BLNK)
            {
                inParams.Add(new OracleProcParam("p_temp_type", TempStatus.ToString()));
            }
            else
            {
                inParams.Add(new OracleProcParam("p_temp_type", "0"));
            }

            List <PairType <string, string> > refCursArr = new List <PairType <string, string> >();

            refCursArr.Add(new PairType <string, string>("o_pawn_app", PAWN_APP));
            refCursArr.Add(new PairType <string, string>("o_pawn_loan", PAWN_LOAN));
            refCursArr.Add(new PairType <string, string>("o_pawn_mdselist", PAWN_MDSE_LIST));
            refCursArr.Add(new PairType <string, string>("o_pawn_gunlist", PAWN_GUN_LIST));
            refCursArr.Add(new PairType <string, string>("o_pawn_mdhistlist", PAWN_MDHIST_LIST));
            refCursArr.Add(new PairType <string, string>("o_pawn_otherdsclist", PAWN_OTHERDSC_LIST));
            refCursArr.Add(new PairType <string, string>("o_pawn_receiptdetlist", PAWN_RECEIPTDET_LIST));
            refCursArr.Add(new PairType <string, string>("o_pawn_feelist", PAWN_FEE_LIST));
            DataSet outputDataSet;
            bool    retVal = false;

            try
            {
                retVal = dA.issueSqlStoredProcCommand(
                    "ccsowner", "pawn_store_procs",
                    "get_store_loans", inParams,
                    refCursArr, "o_return_code",
                    "o_return_text",
                    out outputDataSet);
            }
            catch (Exception oEx)
            {
                BasicExceptionHandler.Instance.AddException("Calling get_store_loans stored procedure", oEx);
                errorCode = " -- GetStoreLoans failed";
                errorText = " --- Exception: " + oEx.Message;
                return(false);
            }

            if (retVal == false)
            {
                errorCode = dA.ErrorCode;
                errorText = dA.ErrorDescription;
                return(false);
            }
            else
            {
                if (outputDataSet != null && outputDataSet.IsInitialized)
                {
                    if (outputDataSet.Tables != null && outputDataSet.Tables.Count > 0)
                    {
                        try
                        {
                            CustomerLoans.ParseDataSet(outputDataSet, out pawnLoans, out pawnApplications);
                            if (CollectionUtilities.isEmpty(pawnLoans) ||
                                CollectionUtilities.isEmpty(pawnApplications))
                            {
                                errorCode = "Parsing the data from the stored procedure failed";
                                errorText = "Pawn Loans or the PawnApplications object is null";
                                return(false);
                            }

                            if (bGetCustomerInfo)
                            {
                                customerVOs.AddRange(pawnLoans.Select(pLoan => CustomerProcedures.getCustomerDataByCustomerNumber(GlobalDataAccessor.Instance.DesktopSession, pLoan.CustomerNumber)));
                            }

                            return(true);
                        }
                        catch (Exception ex)
                        {
                            errorCode = "Parsing the data from the stored procedure failed";
                            errorText = ex.Message;
                            return(false);
                        }
                    }
                    else
                    {
                        errorText = "No records found.";
                        return(false);
                    }
                }
            }

            errorCode = "GETSTOREDLOANSFAIL";
            errorText = "Operation failed";
            return(false);
        }
        public static bool GetLoanTransition(
            string storeNumber,
            int refNumber,
            ProductType refType,
            StateStatus transType,
            out List <PFI_TransitionData> transitionData,
            out decimal statusCode,
            out string errorCode,
            out string errorText)
        {
            //Set default output values
            errorCode = string.Empty;
            errorText = string.Empty;
            DataSet outputDataSet = null;

            transitionData = new List <PFI_TransitionData>();
            statusCode     = 0;

            //Verify that the accessor is valid
            if (GlobalDataAccessor.Instance.DesktopSession == null ||
                GlobalDataAccessor.Instance.OracleDA == null)
            {
                errorCode = "GetLoanTransition";
                errorText = "Invalid desktop session or data accessor instance";
                BasicExceptionHandler.Instance.AddException("GetLoanTransition", new ApplicationException("Cannot execute the Get_Loan_Transition stored procedure"));
                return(false);
            }

            //Get data accessor object
            OracleDataAccessor dA = GlobalDataAccessor.Instance.OracleDA;

            //Create input list
            List <OracleProcParam> inParams = new List <OracleProcParam>();

            inParams.Add(refType == ProductType.ALL
                         ? new OracleProcParam("p_ref_type", "")
                         : new OracleProcParam("p_ref_type", (int)refType));
            inParams.Add(new OracleProcParam("p_ref_number", refNumber));
            inParams.Add(new OracleProcParam("p_ref_store", storeNumber));
            inParams.Add(new OracleProcParam("p_trans_type", transType.ToString()));
            inParams.Add(new OracleProcParam("o_status_code", OracleDbType.Decimal, DBNull.Value, ParameterDirection.Output, 1));

            //Setup ref cursor array
            List <PairType <string, string> > refCursors = new List <PairType <string, string> >();

            refCursors.Add(new PairType <string, string>("o_transition_data", "transition_data"));

            //Create output data set names
            bool retVal = false;

            try
            {
                //    retVal = dA.issueSqlStoredProcCommand(
                //        "ccsowner", "PAWN_STORE_PROCS", "Get_Loan_Transition",
                //        inParams, refCursors, "o_error_code", "o_error_text",
                //        out outputDataSet);
                retVal = dA.issueSqlStoredProcCommand(
                    "ccsowner", "PAWN_STORE_PROCS", "Get_Loan_Transition",
                    inParams, refCursors, "o_error_code", "o_error_text",
                    out outputDataSet);
            }
            catch (OracleException oEx)
            {
                errorCode = "GetLoanTransitionFailed";
                errorText = "Invocation of Get_Loan_Transition stored proc failed";
                BasicExceptionHandler.Instance.AddException("OracleException thrown when invoking Get_Loan_Transition stored proc", oEx);
                return(false);
            }

            //See if retVal is false
            if (retVal == false)
            {
                errorCode = dA.ErrorCode;
                errorText = dA.ErrorDescription;
                return(false);
            }
            errorCode = "0";
            errorText = string.Empty;

            //Get the Data
            if (outputDataSet.Tables != null && outputDataSet.Tables.Count > 0)
            {
                DataRow statusRow = outputDataSet.Tables["OUTPUT"].Rows[0];

                if (statusRow != null && statusRow.ItemArray.Length > 0)
                {
                    object nextNumObj = statusRow.ItemArray.GetValue(1);
                    if (nextNumObj != null)
                    {
                        string nextNumStr = (string)nextNumObj;
                        statusCode = Utilities.GetDecimalValue(nextNumStr);
                    }
                }

                if (outputDataSet.Tables["transition_data"] != null)
                {
                    foreach (DataRow dataRow in outputDataSet.Tables["transition_data"].Rows)
                    {
                        string   sData     = Utilities.GetStringValue(dataRow["transdata"]);
                        DateTime transDate = Utilities.GetDateTimeValue(dataRow["trans_date"], DateTime.MinValue);

                        PFI_TransitionData tData = new PFI_TransitionData();
                        tData.pfiLoan        = Utilities.DeSerialize <PFI_ProductData>(sData);
                        tData.TransitionDate = transDate;

                        transitionData.Add(tData);
                    }
                }
            }

            return(true);
        }
Example #5
0
 public static string GetKeyName(this StateStatus status) => status.ToString("g").ToLower();