Ejemplo n.º 1
0
        public Teller SelectTellerOfUser(int userId)
        {
            var          teller = new Teller();
            const string q      = @"SELECT id
                                    , name
                                    , [desc]
                                    , account_id
                                    , deleted
                                    , branch_id
                                    , user_id
                                    , currency_id
                                    , amount_min
                                    , amount_max
                                    , deposit_amount_min
                                    , deposit_amount_max
                                    , withdrawal_amount_min
                                    , withdrawal_amount_max
                                    FROM dbo.Tellers
                                    WHERE user_id = @user_id AND deleted = 0";

            using (SqlConnection conn = GetConnection())
                using (OpenCbsCommand c = new OpenCbsCommand(q, conn))
                {
                    c.AddParam("@user_id", userId);
                    using (OpenCbsReader r = c.ExecuteReader())
                    {
                        if (r.Empty)
                        {
                            return(teller);
                        }

                        while (r.Read())
                        {
                            teller.Id          = r.GetInt("id");
                            teller.Name        = r.GetString("name");
                            teller.Description = r.GetString("desc");
                            teller.Deleted     = r.GetBool("deleted");
                            teller.Account     = accountManager.Select(r.GetInt("account_id"));
                            teller.Branch      = branchManager.Select(r.GetInt("branch_id"));
                            int uId = r.GetInt("user_id");
                            teller.User = uId == 0 ? new User {
                                Id = 0
                            } : userManager.SelectUser(uId, false);
                            teller.Currency            = currencyManager.SelectCurrencyById(r.GetInt("currency_id"));
                            teller.MinAmountTeller     = r.GetMoney("amount_min");
                            teller.MaxAmountTeller     = r.GetMoney("amount_max");
                            teller.MinAmountDeposit    = r.GetMoney("deposit_amount_min");
                            teller.MaxAmountDeposit    = r.GetMoney("deposit_amount_max");
                            teller.MinAmountWithdrawal = r.GetMoney("withdrawal_amount_min");
                            teller.MaxAmountWithdrawal = r.GetMoney("withdrawal_amount_max");
                        }
                    }
                }
            return(teller);
        }
Ejemplo n.º 2
0
        public List <PaymentMethod> GetPaymentMethodOfBranch()
        {
            string q = @"SELECT [lbpm].[payment_method_id], 
                                [lbpm].[id], 
                                [pm].[name], 
                                [pm].[description], 
                                [pm].[pending], 
                                [lbpm].[branch_id], 
                                [lbpm].[date], 
                                [lbpm].[account_id] 
                         FROM PaymentMethods pm
                         INNER JOIN LinkBranchesPaymentMethods lbpm ON lbpm.payment_method_id = pm.id
                         WHERE [lbpm].[deleted] = 0";

            List <PaymentMethod> paymentMethods = new List <PaymentMethod>();

            using (SqlConnection conn = GetConnection())
                using (OpenCbsCommand c = new OpenCbsCommand(q, conn))
                {
                    //c.AddParam("@id", branchId);
                    using (OpenCbsReader r = c.ExecuteReader())
                    {
                        if (r.Empty)
                        {
                            return(paymentMethods);
                        }
                        while (r.Read())
                        {
                            PaymentMethod paymentMethod = new PaymentMethod
                            {
                                Id          = r.GetInt("payment_method_id"),
                                Name        = r.GetString("name"),
                                Description = r.GetString("description"),
                                IsPending   = r.GetBool("pending"),
                                LinkId      = r.GetInt("id"),
                                Branch      = _branchManager.Select(r.GetInt("branch_id")),
                                Date        = r.GetDateTime("date"),
                                Account     = _accountManager.Select(r.GetInt("account_id"))
                            };
                            paymentMethods.Add(paymentMethod);
                        }
                    }
                }
            return(paymentMethods);
        }