public IList <ClientNote> LoadClientNotesFor(int clientId)
        {
            IList <ClientNote> notes = new List <ClientNote>();

            using (SqlConnection connection = CreateConnection())
            {
                using (SqlDataReader dataReader = SqlHelper.ExecuteReader(connection,
                                                                          CommandType.StoredProcedure,
                                                                          "NotesClient_LoadForAClient",
                                                                          CreateNotesClientPerm_LoadForAClientParameters
                                                                              (clientId)))
                {
                    CleverReader cleverReader = new CleverReader(dataReader);
                    while (cleverReader.Read())
                    {
                        string parsedNotes = CustomerNotesParser.Parse(cleverReader.ToString("notes"));

                        ClientNote note = new ClientNote(
                            cleverReader.FromBigInteger("NotesID"),
                            cleverReader.ToDate("Created"),
                            ActivityType.Parse(cleverReader.ToInteger("ActivityTypeId")),
                            NoteType.Parse(cleverReader.ToInteger("NoteTypeId")),
                            parsedNotes,
                            cleverReader.ToInteger("CreatedBy"),
                            cleverReader.ToString("EmployeeName"),
                            cleverReader.FromBigInteger("ClientID"),
                            cleverReader.ToInteger("ModifiedBy"),
                            cleverReader.ToString("ModifiedByEmployeeName"),
                            cleverReader.ToDate("Modified"));
                        notes.Add(note);
                    }
                }
            }
            return(notes);
        }
        public CffUserActivation ApproveUser(Guid mKey, Guid uKey)
        {
            ArgumentChecker.ThrowIfGuidEmpty(mKey, "mKey");
            ArgumentChecker.ThrowIfGuidEmpty(uKey, "uKey");
            CffUserActivation record = null;

            using (SqlConnection connection = CreateConnection())
            {
                using (SqlDataReader dataReader = SqlHelper.ExecuteReader(connection, CommandType.StoredProcedure, "ApproveUserAccess", CreateAccessActionParameter(mKey, uKey)))
                {
                    CleverReader cleverReader = new CleverReader(dataReader);
                    while (cleverReader.Read())
                    {
                        int nStatus = cleverReader.ToInteger("Status");
                        if (nStatus > 0)
                        { //valid - UKey must pickup from customer-id
                            record = new CffUserActivation(cleverReader.ToString("Name"), "", "", cleverReader.ToString("USERMAIL"), nStatus);
                        }
                        else
                        { //invalid
                            record = new CffUserActivation("", "", "", "", nStatus);
                        }
                    }
                }
            }
            return(record);
        }
        public CffUserActivation ActivateUser(Guid uid, String pKey)
        {
            ArgumentChecker.ThrowIfNull(pKey, "pKey");
            ArgumentChecker.ThrowIfGuidEmpty(uid, "uid");
            CffUserActivation record = null;

            using (SqlConnection connection = CreateConnection())
            {
                using (SqlDataReader dataReader = SqlHelper.ExecuteReader(connection, CommandType.StoredProcedure, "ActivateNewUser", CreateActivationParameter(uid, pKey)))
                {
                    CleverReader cleverReader = new CleverReader(dataReader);
                    while (cleverReader.Read())
                    {
                        int nStatus = cleverReader.ToInteger("Status");
                        if (nStatus == 1)
                        { //valid - UKey must pickup from customer-id
                            record = new CffUserActivation(cleverReader.ToString("Name"), cleverReader.ToString("MngtEmail"), cleverReader.ToGuid("UKey").ToString(), cleverReader.ToString("USERMAIL"), nStatus);
                        }
                        else
                        { //invalid
                            record = new CffUserActivation("", "", "", "", nStatus);
                        }
                    }
                }
            }
            return(record);
        }
        public IRetentionNote LoadRetentionNotesFor(int retentionScheduleId)
        {
            IRetentionNote retentionNote;

            using (SqlConnection connection = CreateConnection())
            {
                using (SqlDataReader dataReader = SqlHelper.ExecuteReader(connection,
                                                                          CommandType.StoredProcedure,
                                                                          "RetnNotes_LoadNote",
                                                                          CreateRetnNotes_LoadNoteParameters
                                                                              (retentionScheduleId)))
                {
                    CleverReader cleverReader = new CleverReader(dataReader);
                    if (cleverReader.Read())
                    {
                        string parsedNotes = CustomerNotesParser.Parse(cleverReader.ToString("notes"));
                        retentionNote = new RetentionNote(parsedNotes);
                    }
                    else
                    {
                        retentionNote = new NullRetentionNote();
                    }
                }
            }
            return(retentionNote);
        }
 public InvoiceBatch Build(CleverReader reader)
 {
     return(new InvoiceBatch(reader.FromBigInteger("BatchNumber"),
                             reader.ToDate("BatchDate"),
                             reader.ToDecimal("FacInv"),
                             reader.ToDecimal("NFInv"),
                             reader.ToDecimal("Admin"),
                             reader.ToDecimal("FactorFee"),
                             reader.ToDecimal("Retention"),
                             reader.ToDecimal("Repurchase"),
                             reader.ToDecimal("Credit"),
                             reader.ToDecimal("Post"),
                             reader.ToNullableDate("Released"),
                             reader.ToString("txtStatus"), // Status?
                             reader.ToString("CreatedBy"),
                             reader.ToDate("Modified"),
                             reader.ToString("ModifiedBy"),
                             reader.ToString("Header"),
                             reader.ToDecimal("TotalInv"),
                             reader.ToString("ClientName"),
                             reader.FromBigInteger("ClientID"),
                             reader.ToInteger("FacilityType"),
                             reader.ToDecimal("NonCompliantFee"),
                             reader.ToDecimal("RetnPercent")
                             ));
 }
        public ClientAndCustomerContacts GetCustomerClientContact(int customerId)
        {
            if (customerId == int.MinValue || customerId == 0)
            {
                return(null);
            }
            ClientAndCustomerContacts clientAndCustomerContacts = null;

            using (SqlConnection connection = CreateConnection())
            {
                using (SqlDataReader dataReader = SqlHelper.ExecuteReader(connection,
                                                                          CommandType.StoredProcedure,
                                                                          "GetCustomerAndClientContact",
                                                                          CreateCustomerIdParameter(customerId, true)))
                {
                    CleverReader cleverReader = new CleverReader(dataReader);
                    if (!cleverReader.IsNull && cleverReader.Read())
                    {
                        ClientContact clientContact = new ClientContactBuilder(cleverReader).Build();

                        cleverReader.NextResult();
                        cleverReader.Read();

                        CustomerContact customerContact = new CustomerContactBuilder(cleverReader).Build();
                        clientAndCustomerContacts = new ClientAndCustomerContacts(clientContact, customerContact);
                    }
                }
            }
            return(clientAndCustomerContacts);
        }
        public List <UserSpecialAccounts> GetSpecialAccountAccessByID(int userId)
        {
            // continue tomorrow - request to db all clients for this user
            ArgumentChecker.ThrowIfNull(userId, "userId");
            List <UserSpecialAccounts> userSpecialAccounts = new List <UserSpecialAccounts>();

            using (SqlConnection connection = CreateConnection())
            {
                using (SqlDataReader dataReader = SqlHelper.ExecuteReader(connection, CommandType.StoredProcedure, "GetSpecialAccountAccessByUserId", CreateUserIdParameter(userId)))
                {
                    CleverReader cleverReader = new CleverReader(dataReader);
                    while (cleverReader.Read())
                    {
                        Guid   uid       = cleverReader.ToGuid("UserID");
                        string name      = cleverReader.ToString("Name");
                        int    isClient  = cleverReader.ToInteger("IsClient");
                        bool   bisClient = isClient != 0 ? true : false;
                        Int64  id        = cleverReader.FromBigInteger("ID");
                        bool   bisLocked = cleverReader.ToBoolean("IsLockedOut");
                        if (!bisLocked)
                        { //add on dropdownlist if not locked out
                            userSpecialAccounts.Add(new UserSpecialAccounts(uid, name, bisClient, id, bisLocked));
                        }
                    }
                }
            }
            return(userSpecialAccounts);
        }
        private IList <CustomerNote> ExecuteLoadCustomerNotes(SqlParameter[] sqlParameters)
        {
            IList <CustomerNote> customerNotes = new List <CustomerNote>();

            using (SqlConnection connection = CreateConnection())
            {
                using (SqlDataReader dataReader = SqlHelper.ExecuteReader(connection,
                                                                          CommandType.StoredProcedure,
                                                                          "NotesCurrent_GetCustomerNotes",
                                                                          sqlParameters))
                {
                    CleverReader cleverReader = new CleverReader(dataReader);
                    while (!cleverReader.IsNull && cleverReader.Read())
                    {
                        string parsedNotes = CustomerNotesParser.Parse(cleverReader.ToString("notes"));

                        CustomerNote customerNote = new CustomerNote(cleverReader.FromBigInteger("NotesID"),
                                                                     cleverReader.ToDate("Created"),
                                                                     ActivityType.Parse(cleverReader.ToInteger("ActivityTypeId")),
                                                                     NoteType.Parse(cleverReader.ToInteger("NoteTypeId")),
                                                                     parsedNotes,
                                                                     cleverReader.ToInteger("CreatedBy"),
                                                                     cleverReader.ToString("EmployeeName"),
                                                                     cleverReader.ToInteger("ModifiedBy"),
                                                                     cleverReader.ToString("ModifiedByEmployeeName"),
                                                                     cleverReader.ToDate("Modified")
                                                                     );
                        customerNotes.Add(customerNote);
                    }
                }
            }
            return(customerNotes);
        }
        public IList <PermanentCustomerNote> LoadPermanentCustomerNote(int customerId)
        {
            IList <PermanentCustomerNote> permanentNotes = new List <PermanentCustomerNote>();

            using (SqlConnection connection = CreateConnection())
            {
                using (SqlDataReader dataReader = SqlHelper.ExecuteReader(connection,
                                                                          CommandType.StoredProcedure,
                                                                          "NotesPermanent_LoadByCustomerID",
                                                                          CreateCustomerIdParameter(customerId)))
                {
                    CleverReader cleverReader = new CleverReader(dataReader);
                    while (cleverReader.Read())
                    {
                        string parsedNotes = CustomerNotesParser.Parse(cleverReader.ToString("notes"));

                        PermanentCustomerNote permanentCustomerNote =
                            new PermanentCustomerNote(cleverReader.FromBigInteger("NotesID"),
                                                      cleverReader.ToDate("Created"),
                                                      parsedNotes,
                                                      cleverReader.ToInteger("CreatedBy"),
                                                      cleverReader.ToString("EmployeeName"),
                                                      cleverReader.ToInteger("ModifiedBy"),
                                                      cleverReader.ToString("ModifiedByEmployeeName"),
                                                      cleverReader.ToDate("Modified"));
                        permanentNotes.Add(permanentCustomerNote);
                    }
                }
            }

            return(permanentNotes);
        }
예제 #10
0
        public RetentionDetails LoadRetentionDetails(int retentionId)
        {
            RetentionDetails retentionDetails = null;
            ChargeCollection charges          = LoadCharges(retentionId);

            using (SqlConnection connection = CreateConnection())
            {
                using (SqlDataReader reader = SqlHelper.ExecuteReader(connection,
                                                                      "stGetRetentionDetails",
                                                                      CreateRetentionIdParameter(retentionId)))
                {
                    CleverReader cleverReader = new CleverReader(reader);
                    if (cleverReader.Read())
                    {
                        RetentionInfo               retentionInfo               = new RetentionInfoBuilder(cleverReader).Build();
                        RetentionDeductable         retentionDeductable         = new RetentionDeductableBuilder(cleverReader).Build();
                        TransactionsAfterEndOfMonth transactionsAfterEndOfMonth = new TransactionsAfterEndOfMonthBuilder(cleverReader).Build();
                        RetentionSummary            retentionSummary            = new RetentionSummaryBuilder(cleverReader).Build();
                        OverdueFee overdueFee = new OverdueFeeBuidler(cleverReader).Build();

                        retentionDetails = new RetentionDetailsBuilder(cleverReader).Build(retentionInfo,
                                                                                           retentionDeductable,
                                                                                           transactionsAfterEndOfMonth,
                                                                                           retentionSummary,
                                                                                           charges,
                                                                                           overdueFee);
                    }
                }
            }
            return(retentionDetails);
        }
예제 #11
0
        public ICffClient GetCffClientByClientId(int clientId)
        {
            ICffClient cffClient = null;

            using (SqlConnection connection = CreateConnection())
            {
                using (
                    SqlDataReader dataReader = SqlHelper.ExecuteReader(connection, CommandType.StoredProcedure,
                                                                       "Client_GetClientByCleintID",
                                                                       CreateClientIdParameter(clientId)))
                {
                    CleverReader cleverReader = new CleverReader(dataReader);
                    if (!cleverReader.IsNull && cleverReader.Read())
                    {
                        if (cleverReader.FromBigInteger("ClientID") == -1)
                        {
                            cffClient = AllClients.Create();
                        }
                        else
                        {
                            cffClient = new CffClient(cleverReader.ToString("ClientName"),
                                                      cleverReader.FromBigInteger("ClientID"),
                                                      cleverReader.FromBigInteger("ClientNum"),
                                                      cleverReader.ToSmallInteger("FacilityType"),
                                                      cleverReader.ToString("CollectionsBankAccount"),
                                                      cleverReader.ToSmallInteger("CFFDebtorAdmin"),        //MSazra [20151006]
                                                      cleverReader.ToBoolean("ClientHasLetterTemplates")    //MSazra [20151006]
                                                      );
                        }
                    }
                }
            }
            return(cffClient);
        }
        public IList <AllClientsPermanentNote> LoadCffPermanentNotes()
        {
            IList <AllClientsPermanentNote> notes = new List <AllClientsPermanentNote>();

            using (SqlConnection connection = CreateConnection())
            {
                using (SqlDataReader dataReader = SqlHelper.ExecuteReader(connection,
                                                                          CommandType.StoredProcedure,
                                                                          "NotesClientPerm_LoadAll"))
                {
                    CleverReader cleverReader = new CleverReader(dataReader);
                    while (cleverReader.Read())
                    {
                        string parsedNotes = CustomerNotesParser.Parse(cleverReader.ToString("notes"));

                        AllClientsPermanentNote note = new AllClientsPermanentNote(cleverReader.FromBigInteger("NotesID"),
                                                                                   cleverReader.FromBigInteger("ClientID"),
                                                                                   cleverReader.ToString("ClientName"),
                                                                                   cleverReader.ToDate("Created"),
                                                                                   parsedNotes,
                                                                                   cleverReader.ToInteger("CreatedBy"),
                                                                                   cleverReader.ToString("EmployeeName"),
                                                                                   cleverReader.ToInteger("ModifiedBy"),
                                                                                   cleverReader.ToString(
                                                                                       "ModifiedByEmployeeName"),
                                                                                   cleverReader.ToDate("Modified"));
                        notes.Add(note);
                    }
                }
            }

            return(notes);
        }
        public IList <TransactionSearchResult> SearchTransactions(DateRange dateRange, string invoiceNumber, TransactionSearchType transactionType, SearchScope searchScope, CffCustomer customer, ICffClient client, string batchFrom, string batchTo)
        {
            if (invoiceNumber.Length < 3)
            {
                throw new ArgumentException("You need more than 3 invoice number to search ");
            }
            SqlParameter[] queryBuilder = CreateSqlBuilder(dateRange, invoiceNumber,
                                                           transactionType, searchScope, customer, client, batchFrom, batchTo);
            IList <TransactionSearchResult> transactionSearchResults = new List <TransactionSearchResult>();

            using (SqlConnection connection = CreateConnection())
            {
                try
                {
                    using (SqlDataReader dataReader = SqlHelper.ExecuteReader(connection,
                                                                              CommandType.StoredProcedure,
                                                                              "stGetCustomersSearchAll",
                                                                              queryBuilder))
                    {
                        CleverReader cleverReader = new CleverReader(dataReader);
                        while (!cleverReader.IsNull && cleverReader.Read())
                        {
                            var transactionSearchResult =
                                new TransactionSearchResult(cleverReader.ToDate("Transdate"),
                                                            cleverReader.ToDate("factorDate"),
                                                            cleverReader.ToString("TransRef"),
                                                            cleverReader.ToDecimal("TransAmount"),
                                                            cleverReader.ToDecimal("TransBalance"),
                                                            cleverReader.FromBigInteger("BatchID"),
                                                            cleverReader.FromBigInteger("CustNum"),
                                                            cleverReader.FromBigInteger("CustomerID"),
                                                            cleverReader.ToString("Customer"),
                                                            cleverReader.FromBigInteger("ClientID"),
                                                            cleverReader.ToString("ClientName"),
                                                            cleverReader.ToString("Title"),
                                                            cleverReader.ToDecimal("Balance"),
                                                            cleverReader.ToString("BatchFrom"),
                                                            cleverReader.ToString("BatchTo"));
                            transactionSearchResults.Add(transactionSearchResult);
                        }
                    }
                }
                catch (SqlException exception)
                {
                    if (exception.Message.Contains("Timeout expired"))
                    {
                        throw new CffTimeoutException(exception.Message, exception);
                    }
                    throw;
                }
            }
            Console.WriteLine(transactionSearchResults.Count);
            return(RecordLimiter.ReturnMaximumRecords(transactionSearchResults));
        }
 public CleverReader executeSPReader(List <object> stpParameters, stpType storedProcType)
 {
     using (SqlConnection connection = new SqlConnection(_connectionString))
     {
         using (SqlDataReader dataReader = SqlHelper.ExecuteReader(connection,
                                                                   System.Data.CommandType.StoredProcedure,
                                                                   storedProcName(storedProcType),
                                                                   GenerateClientParameters(stpParameters, storedProcType)))
         {
             CleverReader reader = new CleverReader(dataReader);
             return(reader);
         }
     }
 }
        public IList <CustomerContact> LoadMatchedAllClientsCustomerContact(string textToMatch)
        {
            IList <CustomerContact> contacts;

            using (SqlConnection connection = CreateConnection())
            {
                using (SqlDataReader dataReader = SqlHelper.ExecuteReader(connection,
                                                                          CommandType.StoredProcedure,
                                                                          "dbo.CustomerContactsView_GetMatchedCustomerContacts", GenerateTextToSearchParameters(textToMatch)))
                {
                    CleverReader cleverReader = new CleverReader(dataReader);
                    contacts = new CustomerContactBuilder(cleverReader).BuildAll();
                }
            }
            return(RecordLimiter.ReturnMaximumRecords(contacts));
        }
        private IList <CustomerContact> GetAllCustomersAndTheirContacts()
        {
            IList <CustomerContact> contacts;

            using (SqlConnection connection = CreateConnection())
            {
                using (SqlDataReader dataReader = SqlHelper.ExecuteReader(connection,
                                                                          CommandType.StoredProcedure,
                                                                          "dbo.CustomerContacts_GetAllContacts"))
                {
                    CleverReader cleverReader = new CleverReader(dataReader);
                    contacts = new CustomerContactBuilder(cleverReader).BuildAll();
                }
            }
            return(contacts);
        }
        public ManagementDetails LoadManagementDetails()
        {
            ManagementDetails managementDetails = null;

            using (SqlConnection connection = CreateConnection())
            {
                using (SqlDataReader reader = SqlHelper.ExecuteReader(connection,
                                                                      CommandType.StoredProcedure,
                                                                      "ManagementDetails_Load"))
                {
                    CleverReader cleverReader = new CleverReader(reader);
                    managementDetails = new ManagementDetailsBuilder(cleverReader).Build();
                }
            }

            return(managementDetails);
        }
        public String GetDashboardContent()
        {
            String content = "";

            using (SqlConnection connection = CreateConnection())
            {
                using (SqlDataReader dataReader = SqlHelper.ExecuteReader(connection, CommandType.StoredProcedure, "GetCFFContent", CreateContentIdparameter(1)))
                {
                    CleverReader cleverReader = new CleverReader(dataReader);
                    while (cleverReader.Read())
                    {
                        content = cleverReader.ToString("MsgContent");
                    }
                }
            }
            return(content);
        }
        // dbb [20160727]
        private IList <ClientContact> GetAClientsContacts(int clientId, string sAction)
        {
            IList <ClientContact> contacts;

            using (SqlConnection connection = CreateConnection())
            {
                using (SqlDataReader dataReader = SqlHelper.ExecuteReader(connection,
                                                                          CommandType.StoredProcedure,
                                                                          "dbo.stInsUpdateClientContacts",
                                                                          GenerateClientForValidationParameters(clientId, sAction)))
                {
                    CleverReader cleverReader = new CleverReader(dataReader);
                    contacts = new ClientContactBuilder(cleverReader).BuildAll();
                } //
            }
            return(contacts);
        }
        private IList <CustomerContact> GetACustomersContacts(int customerId)
        {
            IList <CustomerContact> contacts;

            using (SqlConnection connection = CreateConnection())
            {
                using (SqlDataReader dataReader = SqlHelper.ExecuteReader(connection,
                                                                          CommandType.StoredProcedure,
                                                                          "dbo.CustomerContacts_GetContacts",
                                                                          GenerateCustomerParameters(customerId)))
                {
                    CleverReader cleverReader = new CleverReader(dataReader);
                    contacts = new CustomerContactBuilder(cleverReader).BuildAll();
                }
            }
            return(contacts);
        }
        public IList <PermanentCustomerNote> LoadPermanentCustomerNoteOnRange(int customerId, DateRange dateRange)
        {
            SqlParameter customerIdParameter = new SqlParameter("@CustomerId", SqlDbType.BigInt);

            customerIdParameter.Value = customerId;

            SqlParameter dateFromParameter = new SqlParameter("@DateFrom", SqlDbType.DateTime);

            dateFromParameter.Value = Convert.ToDateTime(dateRange.StartDate.ToShortDateString());

            SqlParameter dateToParameter = new SqlParameter("@DateTo", SqlDbType.DateTime);

            dateToParameter.Value = Convert.ToDateTime(dateRange.EndDate.ToShortDateString());

            SqlParameter[] paramObjects = new SqlParameter[] { customerIdParameter, dateFromParameter, dateToParameter };

            IList <PermanentCustomerNote> permanentNotes = new List <PermanentCustomerNote>();

            using (SqlConnection connection = CreateConnection())
            {
                using (SqlDataReader dataReader = SqlHelper.ExecuteReader(connection,
                                                                          CommandType.StoredProcedure,
                                                                          "NotesPermanent_LoadCustomerInRange",
                                                                          paramObjects
                                                                          ))
                {
                    CleverReader cleverReader = new CleverReader(dataReader);
                    while (cleverReader.Read())
                    {
                        string parsedNotes = CustomerNotesParser.Parse(cleverReader.ToString("notes"));

                        PermanentCustomerNote permanentCustomerNote =
                            new PermanentCustomerNote(cleverReader.FromBigInteger("NotesID"),
                                                      cleverReader.ToDate("Created"),
                                                      parsedNotes,
                                                      cleverReader.ToInteger("CreatedBy"),
                                                      cleverReader.ToString("EmployeeName"),
                                                      cleverReader.ToInteger("ModifiedBy"),
                                                      cleverReader.ToString("ModifiedByEmployeeName"),
                                                      cleverReader.ToDate("Modified"));
                        permanentNotes.Add(permanentCustomerNote);
                    }
                }
            }
            return(permanentNotes);
        }
        public CffMgtDetails LoadCffMgtDetails()
        {
            CffMgtDetails cffMgtDetails = null;

            using (SqlConnection connection = CreateConnection())
            {
                using (SqlDataReader reader = SqlHelper.ExecuteReader(connection,
                                                                      CommandType.StoredProcedure,
                                                                      "ManagementDetails_Load"))
                {
                    CleverReader cleverReader = new CleverReader(reader);
                    cleverReader.Read();        //Msarza  - added
                    cffMgtDetails = new CffMgtDetailsBuilder(cleverReader).Build();
                }
            }

            return(cffMgtDetails);
        }
        public string GetPasskey(long clientId)
        {
            string key = string.Empty;

            ArgumentChecker.ThrowIfNull(clientId, "clientId");
            using (SqlConnection connection = CreateConnection())
            {
                using (SqlDataReader dataReader = SqlHelper.ExecuteReader(connection, CommandType.StoredProcedure, "GetPassKey", CreateClientIdParameter(clientId)))
                {
                    CleverReader cleverReader = new CleverReader(dataReader);
                    while (cleverReader.Read())
                    {
                        key = cleverReader.ToString("PASSKEY");
                    }
                }
            }
            return(key);
        }
        public Int32 VerifyIfSpecialAccountByID(int userId)
        {
            Int32 nReturn = 1;

            ArgumentChecker.ThrowIfNull(userId, "userId");
            using (SqlConnection connection = CreateConnection())
            {
                using (SqlDataReader dataReader = SqlHelper.ExecuteReader(connection, CommandType.StoredProcedure, "VerifyIfSpecialAccountByID", CreateUserIdParameter(userId)))
                {
                    CleverReader cleverReader = new CleverReader(dataReader);
                    while (cleverReader.Read())
                    {
                        nReturn = cleverReader.ToInteger("RESULT");
                    }
                }
            }
            return(nReturn);
        }
 public bool CheckClientBelongToUser(int clientId, Guid userId)
 {
     using (SqlConnection connection = CreateConnection())
     {
         using (SqlDataReader dataReader = SqlHelper.ExecuteReader(connection,
                                                                   CommandType.StoredProcedure,
                                                                   "CheckClientBelongToUser",
                                                                   CreateClientIdAndUserUIDParameters(clientId, userId)))
         {
             CleverReader cleverReader = new CleverReader(dataReader);
             if (!cleverReader.IsNull && cleverReader.Read())
             {
                 return(cleverReader.ToBoolean("Result"));
             }
         }
     }
     return(false);
 }
        public String GetRoleByPassKey(String userPassKey)
        {
            ArgumentChecker.ThrowIfNull(userPassKey, "userPassKey");
            String sRole = "Staff";

            using (SqlConnection connection = CreateConnection())
            {
                using (SqlDataReader dataReader = SqlHelper.ExecuteReader(connection, CommandType.StoredProcedure, "GetRoleByPassKey", CreateUserPassKeyParameter(userPassKey)))
                {
                    CleverReader cleverReader = new CleverReader(dataReader);
                    while (cleverReader.Read())
                    {
                        sRole = cleverReader.ToString("ROLE");
                    }
                }
            }
            return(sRole);
        }
        public string GetMatchedCustomersJSON(string matchString, long clientId, int numberOfCustomersToReturn, int criteria)
        {
            List <CffCustomer> customers = new List <CffCustomer>();

            using (SqlConnection connection = CreateConnection())
            {
                using (SqlDataReader dataReader = SqlHelper.ExecuteReader(connection,
                                                                          CommandType.StoredProcedure,
                                                                          "stGetCustomersSearch",
                                                                          ExCreateGetMatchedCustomerParameters(matchString, clientId, criteria)
                                                                          ))
                {
                    int ix = 0;

                    //System.Diagnostics.Debug.Write("Call to GetMatchedCustomersJSON by: ");
                    //System.Diagnostics.StackTrace stackTrace = new System.Diagnostics.StackTrace();
                    //System.Diagnostics.Debug.WriteLine(stackTrace.GetFrame(1).GetMethod().Name);

                    CleverReader cleverReader = new CleverReader(dataReader);
                    while (!cleverReader.IsNull && cleverReader.Read() && ix <= numberOfCustomersToReturn)
                    {
                        // MSarza: Line below  causes issues at the CleverReader class due to differing field names passed. Providing a conditional
                        //          code herein to identify and correct the field name appropriately proved to be buggy, hence, fix was instead done on the
                        //          stored procedure stGetCustomersSearch.
                        customers.Add(new CffCustomerBuilder(cleverReader).Build());
                        // MSarza: deprecated conditional code initially applied to fix issue on the preceeding line
                        //if (matchString == "%" && criteria == 0)
                        //{
                        //    //System.Diagnostics.Debug.WriteLine("Using Build2()");
                        //    customers.Add(new CffCustomerBuilder(cleverReader).Build2());
                        //}
                        //else
                        //{
                        //    //System.Diagnostics.Debug.WriteLine("Using Build()");
                        //    customers.Add(new CffCustomerBuilder(cleverReader).Build());
                        //}
                        ix++;
                    }

                    //System.Diagnostics.Debug.WriteLine("Called stGetCustomersSearch matchString: " + matchString + ", clientId: " + clientId.ToString() + ", criteria: " + criteria.ToString());
                }
            }
            return(GenerateJSONForClient(customers));
        }
예제 #28
0
        public ChargeCollection LoadBatchCharges(int batchId)
        {
            ChargeCollection charges = new ChargeCollection();

            using (SqlConnection connection = CreateConnection())
            {
                using (SqlDataReader reader = SqlHelper.ExecuteReader(connection,
                                                                      "stGetBatchCharges",
                                                                      CreateBatchIdParameter(batchId)))
                {
                    CleverReader cleverReader = new CleverReader(reader);
                    while (cleverReader.Read())
                    {
                        charges.Add(new BatchChargeBuilder(cleverReader).Build());
                    }
                }
            }
            return(charges);
        }
예제 #29
0
        public IList <InvoiceBatch> LoadInvoiceBatchesForBatchNumber(int clientId, string batchNumberToSearch)
        {
            IList <InvoiceBatch> invoiceBatches = new List <InvoiceBatch>();

            using (SqlConnection connection = CreateConnection())
            {
                using (SqlDataReader reader = SqlHelper.ExecuteReader(connection,
                                                                      "stGetMatchedBatches",
                                                                      CreateGetMatchedBatchesParameter(clientId, batchNumberToSearch)))
                {
                    CleverReader cleverReader = new CleverReader(reader);
                    while (cleverReader.Read())
                    {
                        invoiceBatches.Add(new InvoiceBatchBuilder().Build(cleverReader));
                    }
                }
            }
            return(invoiceBatches);
        }
예제 #30
0
        public IList <RetentionSchedule> LoadRetentionSchedulesForAllClients(Date date)
        {
            IList <RetentionSchedule> retentionSchedules = new List <RetentionSchedule>();

            using (SqlConnection connection = CreateConnection())
            {
                using (SqlDataReader reader = SqlHelper.ExecuteReader(connection,
                                                                      "stGetRetentionScheduleForAllClients",
                                                                      CreateRetentionScheduleForAllClientsParameter(date)))
                {
                    CleverReader cleverReader = new CleverReader(reader);
                    while (cleverReader.Read())
                    {
                        retentionSchedules.Add(new RetentionScheduleBuilder(cleverReader).Build());
                    }
                }
            }
            return(RecordLimiter.ReturnMaximumRecords(retentionSchedules));
        }