예제 #1
0
    public void InitializeControls()
    {
        List <MutualFund>  listFunds = new List <MutualFund>();
        IList <MutualFund> Funds     = new List <MutualFund>();

        if (isFillterSellingAgent)
        {
            foreach (PersonOrgRelation employer in this.User.Person.FindCurrentEmployments(iSabayaContext))
            {
                //if (employer.Organization == iSabayaContext.SystemOwnerOrg)
                //{
                Funds = ComplicatedListFunds(employer.Organization);
                break;
                //}
                //else
                //{
                //Funds = FundSellingAgent.ListFunds(iSabayaContext, employer.Organization);
                //}
            }
        }
        else
        {
            Funds = ComplicatedListFunds();
        }

        if (transactionTypeCode != "")
        {
            if (Funds.Count > 0)
            {
                foreach (MutualFund item in Funds)
                {
                    if (item.GetTransactionType(InvestmentTransactionType.FindByCode(iSabayaContext, transactionTypeCode).Code, DateTime.Now) != null)
                    {
                        listFunds.Add(item);
                    }
                }
            }
        }
        else
        {
            if (Funds.Count > 0)
            {
                listFunds = new List <MutualFund>(Funds);
            }
        }
        if (listFunds.Count > 0)
        {
            listFunds.Sort((x, y) => string.Compare(x.Code, y.Code));
            Session[this.ClientID + "FundLists"] = Session[this.ClientID + "tempLists"] = listFunds;
        }
        refreshControl();
    }
        /*ใช้ในหน้าสรุปซื้อขาย เรียกจาก ObjectDatasource*/
        public static IList <VOTransactionSelect_GridTransaction> List(
            imSabayaContext context,
            int fundId,
            int accountId,
            DateTime date,
            int transactionTypeId,
            int sellingAgentId,
            int orgUnitId
            )
        {
            ICriteria crit = context.PersistencySession.CreateCriteria(typeof(MFTransaction));

            crit.Add(Expression.Eq("Fund", (Fund)MutualFund.Find(context, fundId)))
            //.Add(Expression.Eq("RollbackStatus", (byte)0))
            .CreateAlias("CurrentState", "currentState")
            .CreateAlias("CurrentState.State", "state")
            .Add(Expression.Eq("state.Code", "Released"));

            if (accountId != 0)
            {
                crit.Add(Expression.Eq("Portfolio", MFAccount.Find(context, accountId)));
            }

            if (transactionTypeId != 0)
            {
                crit.Add(Expression.Eq("Type", InvestmentTransactionType.Find(context, transactionTypeId)));
            }
            if (date != DateTime.MinValue)
            {
                DateTime minOfToday = date.Date;
                DateTime maxOfToday = date.Date.AddDays(1).Date.AddMilliseconds(-1);
                crit.Add(Expression.Between("TransactionTS", minOfToday, maxOfToday));
            }
            if (sellingAgentId != 0)
            {
                crit.Add(Expression.Eq("SellingAgent", Organization.Find(context, sellingAgentId)));
            }
            IList <MFTransaction> list = crit.List <MFTransaction>();

            IList <VOTransactionSelect_GridTransaction> vos = new List <VOTransactionSelect_GridTransaction>();

            foreach (MFTransaction tran in list)
            {
                vos.Add(new VOTransactionSelect_GridTransaction(context, tran));
            }
            return(vos);
        }
    private DataTable TransactionTypeLists()
    {
        iSystem   mySystem;
        DataTable ds = null;

        if (CommonConstants.Systems.TryGetValue(int.Parse(System.Configuration.ConfigurationManager.AppSettings["ApplicationID"]), out mySystem))
        {
            IList <InvestmentTransactionType> transtype = InvestmentTransactionType.ListPrincipalTypes(iSabayaContext, mySystem.ApplicationID);
            ds = new DataTable();
            ds.Columns.Add(new DataColumn("title", System.Type.GetType("System.String")));
            ds.Columns.Add(new DataColumn("value", System.Type.GetType("System.Int32")));
            ds.Rows.Add("ทุกประเภท");
            foreach (InvestmentTransactionType item in transtype)
            {
                ds.Rows.Add(item.Title.ToString(), item.TransactionTypeID);
            }

            Session[this.ClientID + "trantypes"] = ds;
        }
        return(ds);
    }
예제 #4
0
    public void InitialControl()
    {
        ISession session = iSabayaContext.PersistencySession;
        IList <ProvidentFund> listFunds = null;

        //        if (isMasterFund)
        //        {
        //            // do notthing
        //        }
        //        else if (isNotMasterFund)
        //        {
        //            String sqlquery = @"select * from fund
        //                                where IsMasterFund = 0 and FundDiscriminator = 2";
        //            ISQLQuery query = session.CreateSQLQuery(sqlquery).AddEntity(typeof(ProvidentFund)); ;
        //            listFunds = query.List<ProvidentFund>();
        //        }
        //        else
        //        {
        //            //listFunds = ProvidentFund.List(iSabayaContext);
        //        }
        listFunds = ProvidentFund.ListSingleFunds(iSabayaContext);
        List <ProvidentFund> listFundFilters = new List <ProvidentFund>();

        if (!transactionTypeCode.Equals(""))
        {
            TreeListNode channel = TreeListNode.FindByCode(iSabayaContext, "WEB");
            InvestmentTransactionType tranType = InvestmentTransactionType.FindByCode(iSabayaContext, TransactionTypeCode);
            if (listFunds != null)
            {
                foreach (ProvidentFund fund in listFunds)
                {
                    //bool isHave = InstrumentTransactionType.IsHave(session, fund, channel, tranType);
                    ICriteria crit = iSabayaContext.PersistencySession.CreateCriteria(typeof(InstrumentTransactionType));
                    crit.Add(Expression.Eq("Fund", fund));
                    bool isHave = crit.List <InstrumentTransactionType>().Count > 0;
                    if (isHave)
                    {
                        listFundFilters.Add(fund);
                    }
                }
            }
        }
        else
        {
            if (listFunds != null)
            {
                foreach (ProvidentFund fund in listFunds)
                {
                    listFundFilters.Add(fund);
                }
            }
        }

        dic.Clear();

        if (includeAllFundItem)
        {
            dic.Add(0, "-All Funds-");
        }
        if (listFunds != null)
        {
            foreach (ProvidentFund fund in listFundFilters)
            {
                //dic.Add(fund.FundID, "[" + fund.Code + "]" + fund.ShortTitle.ToString());
                dic.Add(fund.FundID, fund.Code);
            }
            ViewState["listFunds"] = dic;
        }
        refreshControl();
    }