protected void comboBankCallback()
    {
        ProvidentFund fund = this.Fund;

        if (fund != null)
        {
            IList <PartyBankAccount> fbanks = fund.AssociatedBankAccounts;
            comboBank.ValueField = "ID";
            comboBank.TextField  = "AccountName";
            Session[this.ClientID + "fbanks"] = fbanks;
            comboBank.DataSource = fbanks;
            comboBank.DataBind();
        }
        else
        {
            ProvidentFund empFund = (ProvidentFund)Session["SessionFund"];
            if (empFund != null)
            {
                IList <PartyBankAccount> fbanks = empFund.AssociatedBankAccounts;
                comboBank.ValueField = "ID";
                comboBank.TextField  = "AccountName";
                Session[this.ClientID + "fbanks"] = fbanks;
                comboBank.DataSource = fbanks;
                comboBank.DataBind();
            }
        }
    }
 public ActionResult Edit(int id, FormCollection collection)
 {
     try
     {
         // TODO: Add update logic here
         var model = ProvidentFund.GetById(id);
         TryUpdateModel(model);
         model.SaveOrUpDate();
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
 public ActionResult Create(FormCollection collection)
 {
     try
     {
         // TODO: Add insert logic here
         var model = new ProvidentFund();
         TryUpdateModel(model);
         model.Insert();
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         ASPxGridView grid = (ASPxGridView)DropDownEdit.FindControl("GridView");
         grid.DataBind();
         if (Session["SessionFund"] != null)
         {
             ProvidentFund fund = ((ProvidentFund)Session["SessionFund"]);
             DropDownEdit.KeyValue = fund.FundID;
             DropDownEdit.Text     = fund.Code;
         }
         else
         {
             DropDownEdit.KeyValue = null;
             DropDownEdit.Text     = string.Empty;
         }
     }
 }
    public void InitialControl(string currentLanguage)
    {
        IList <ProvidentFund> listFunds = null;

        if (!IsFillterSellingAgent)
        {
            listFunds = ProvidentFund.List(iSabayaContext);
        }
        else
        {
            User user = (User)this.User;
        }
        //dic.Clear();

        foreach (ProvidentFund fund in listFunds)
        {
            ComboFundName.Items.Add(fund.Code, fund.FundID.ToString());
        }
    }
    protected String employerNameCallback()
    {
        Employer      emp   = this.Employer;
        ProvidentFund pFund = this.Fund;
        String        Result;

        if (emp != null)
        {
            Result = emp.Name.ToString(iSabayaContext.CurrentLanguage) + " รหัส: " + emp.EmployerNo.ToString();
        }
        else if (pFund != null)
        {
            Result = pFund.Title.ToString(iSabayaContext.CurrentLanguage);
        }
        else
        {
            Result = "ไม่พบชื่อ!";
        }
        return(Result);
    }
    public void InitializeControls()
    {
        ISession session = iSabayaContext.PersistencySession;
        IList <ProvidentFund> listFunds = null;
        string type = "";

        type = isMasterFund ? "isMasterFund" : "";
        type = isNotMasterFund ? "isNotMasterFund" : "";
        type = isNotSubFund ? "isNotSubFund" : "";
        type = masterFundID != 0 ? "isMasterFundID" : "";
        type = IsAvalibleForEmployer ? "IsAvalibleForEmployer" : "";
        type = IsAvalibleAndNotMasterFund ? "IsAvalibleAndNotMasterFund" : "";
        #region
        String    sqlquery = "";
        ISQLQuery query    = null;
        switch (type)
        {
        case "isMasterFund":
            sqlquery  = @"select * from fund
                                where IsMasterFund = 1 and FundDiscriminator = 2";
            query     = session.CreateSQLQuery(sqlquery).AddEntity(typeof(ProvidentFund));
            listFunds = query.List <ProvidentFund>();
            break;

        case "isNotMasterFund":
            sqlquery  = @"select * from fund
                                where IsMasterFund = 0 and FundDiscriminator = 2";
            query     = session.CreateSQLQuery(sqlquery).AddEntity(typeof(ProvidentFund));;
            listFunds = query.List <ProvidentFund>();
            break;

        case "isNotSubFund":
            sqlquery  = @"select * from Fund f
                                where f.IsMasterFund = 0 and f.FundDiscriminator = 2
                                Except
                                select f.* from Fund f
                                inner join FundRelation fr on f.FundID = fr.ChildFundID
                                where f.IsMasterFund = 0 and f.FundDiscriminator = 2
                                union
                                select * from Fund f
                                where f.IsMasterFund = 1 and f.FundDiscriminator = 2";
            query     = session.CreateSQLQuery(sqlquery).AddEntity(typeof(ProvidentFund));;
            listFunds = query.List <ProvidentFund>();
            break;

        case "IsAvalibleForEmployer":
            sqlquery  = @"SELECT * FROM Fund f
                                -- fund is not subfund
                                WHERE f.IsMasterFund = 0 AND f.FundDiscriminator = 2
                                Except
                                SELECT f.* FROM Fund f
                                INNER JOIN FundRelation fr on f.FundID = fr.ChildFundID
                                WHERE f.IsMasterFund = 0 AND f.FundDiscriminator = 2
                                UNION
                                SELECT * FROM Fund f
                                WHERE f.IsMasterFund = 1 AND f.FundDiscriminator = 2

                                EXCEPT

                                -- fund is used by  Employer
                                (SELECT f.*
                                FROM Employer e
                                INNER JOIN EmployerFund ef ON e.EmployerID = ef.EmployerID
                                INNER JOIN Fund f ON f.FundID = ef.FundID
                                INNER JOIN TreeListNode trn ON trn.NodeID = f.FundCategoryID
                                WHERE (trn.NodeID = 1584 OR trn.NodeID = 1443) AND f.FundDiscriminator = 2 )";
            query     = session.CreateSQLQuery(sqlquery).AddEntity(typeof(ProvidentFund));;
            listFunds = query.List <ProvidentFund>();
            break;

        case "IsAvalibleAndNotMasterFund":
            sqlquery  = @"SELECT * FROM Fund f
                                -- fund is not Sub fund and not Master Fund
                                WHERE f.IsMasterFund = 0 AND f.FundDiscriminator = 2        
                                Except
                                SELECT f.* FROM Fund f
                                INNER JOIN FundRelation fr on f.FundID = fr.ChildFundID
                                WHERE f.IsMasterFund = 0 AND f.FundDiscriminator = 2

                                EXCEPT

                                -- fund is used by  Employer
                                (SELECT f.*
                                FROM Employer e
                                INNER JOIN EmployerFund ef ON e.EmployerID = ef.EmployerID
                                INNER JOIN Fund f ON f.FundID = ef.FundID
                                INNER JOIN TreeListNode trn ON trn.NodeID = f.FundCategoryID
                                WHERE f.FundDiscriminator = 2 )";
            query     = session.CreateSQLQuery(sqlquery).AddEntity(typeof(ProvidentFund));;
            listFunds = query.List <ProvidentFund>();
            break;

        case "isMasterFundID":
            ProvidentFund MasterFund = iSabayaContext.PersistencySession.Get <ProvidentFund>(masterFundID);
            listFunds = new List <ProvidentFund>();
            foreach (FundRelation item in MasterFund.ChildrenFundRelations)
            {
                listFunds.Add((ProvidentFund)item.ChildFund);
            }
            break;

        default:
            listFunds = ProvidentFund.List(iSabayaContext);
            break;
        }
        #endregion


        #region
        //        if (isMasterFund)
        //        {
        //            String sqlquery = @"select * from fund
        //                                where IsMasterFund = 1 and FundDiscriminator = 2";
        //            ISQLQuery query = session.CreateSQLQuery(sqlquery).AddEntity(typeof(ProvidentFund)); ;
        //            listFunds = query.List<ProvidentFund>();
        //        }
        //        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 if (isNotSubFund)
        //        {
        //            String sqlquery = @"select * from Fund f
        //                                where f.IsMasterFund = 0 and f.FundDiscriminator = 2
        //                                Except
        //                                select f.* from Fund f
        //                                inner join FundRelation fr on f.FundID = fr.ChildFundID
        //                                where f.IsMasterFund = 0 and f.FundDiscriminator = 2
        //                                union
        //                                select * from Fund f
        //                                where f.IsMasterFund = 1 and f.FundDiscriminator = 2";
        //            ISQLQuery query = session.CreateSQLQuery(sqlquery).AddEntity(typeof(ProvidentFund)); ;
        //            listFunds = query.List<ProvidentFund>();
        //        }
        //        else if (masterFundID != 0)
        //        {
        //            ProvidentFund MasterFund = iSabayaContext.PersistencySession.Get<ProvidentFund>(masterFundID);
        //            listFunds = new List<ProvidentFund>();
        //            foreach (FundRelation item in MasterFund.ChildrenFundRelations)
        //            {
        //                listFunds.Add((ProvidentFund)item.ChildFund);
        //            }
        //        }
        //        else
        //        {
        //            listFunds = ProvidentFund.List(iSabayaContext);
        //        }
        #endregion
        #region
        //List<ProvidentFund> listFundFilters = new List<ProvidentFund>();
        //if (!transactionTypeCode.Equals(""))
        //{
        //    TreeListNode channel = TreeListNode.FindByCode(iSabayaContext, "WEB");
        //    TransactionType tranType = TransactionType.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);
        //        }
        //    }
        //}
        #endregion
        dic.Clear();

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

        //cboFundCode.SelectedIndex = 0;
        cboFundCode.ClientInstanceName = cboFundCode.ClientID;
        lblFundName.ClientInstanceName = lblFundName.ClientID;
        cbLoadFund.ClientInstanceName  = cbLoadFund.ClientID;

        /*Combo change*/
        cboFundCode.ClientSideEvents.SelectedIndexChanged = @"function(s, e)
                {
                    if(" + isShowFundName.ToString().ToLower() + @")"
                                                            + cbLoadFund.ClientInstanceName + @".SendCallback('');"
                                                            + AdditionClientScriptEvents.AfterSelectedChanged + @"
                }";

        /*Callback complete*/
        cbLoadFund.ClientSideEvents.CallbackComplete =
            @"function(s, e) {"
            + lblFundName.ClientInstanceName + @".SetValue(e.result);
                if(typeof(" + GridOutput + @") != 'undefined')
                    setTimeout('" + GridOutput + @".PerformCallback()', 5000);
                if(typeof(oncompleteLoadMFFund) != 'undefined')
                    oncompleteLoadMFFund();
           }";
    }
Example #8
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();
    }
    public void ChangeEmployerTradeDate(int EmployerID)
    {
        if (EmployerID == 0)
        {
            return;
        }
        Employer employer = Employer.Find(this.iSabayaContext, EmployerID);

        if (employer != null)
        {
            Session["SessionEmployer"] = employer;
            IList <ProvidentFund> IsNotMasterFundLists = new List <ProvidentFund>();
            foreach (ProvidentFund item in employer.GetFundsOn(DateTime.Today))
            {
                if (item.IsMasterFund != true)
                {
                    IsNotMasterFundLists.Add(item);
                }
            }

            ProvidentFund EmpMasterFund = employer.GetMainFundOn(DateTime.Today);
            IList <InstrumentTransactionType> fundTransactionCalendars = new List <InstrumentTransactionType>();
            if (EmpMasterFund != null)
            {
                fundTransactionCalendars = EmpMasterFund.InstrumentTransactionTypes;
            }
            if (fundTransactionCalendars.Count <= 0)
            {
                foreach (ProvidentFund item in IsNotMasterFundLists)
                {
                    if (item.InstrumentTransactionTypes.Count > 0)
                    {
                        fundTransactionCalendars = item.InstrumentTransactionTypes;
                    }
                }
            }

            DateTime tradeDate = TimeInterval.MinDate;
            DateTime effectiveDate;
            DateTime settlementDate;
            //TimeSchedule schedule = fundTransactionCalendars[0].TradeCalendar;
            for (int i = 0; i < fundTransactionCalendars.Count; i++)
            {
                if (fundTransactionCalendars[i].InvestmentTransactionType.Code == PFConstants.PFTTCodeContFileImport)
                {
                    Session["SessionScheduleId"] = fundTransactionCalendars[i].TradeCalendar;
                    fundTransactionCalendars[i].FindTransactionDates(iSabayaContext, DateTime.Now,
                                                                     out tradeDate, out effectiveDate, out settlementDate);
                    break;
                }
            }

            if (tradeDate == TimeInterval.MinDate)
            {
                Session["SessionTradeDate"]  = null;
                Session["SessionScheduleId"] = null;
            }
            else
            {
                Session["SessionTradeDate"] = tradeDate;
            }
        }
        else
        {
            Session["SessionEmployer"]   = null;
            Session["SessionScheduleId"] = null;
            Session["SessionTradeDate"]  = null;
        }
    }
 // GET: ProvidentFund/Edit/5
 public ActionResult Edit(int id)
 {
     return(View(ProvidentFund.GetById(id)));
 }
 // GET: ProvidentFund
 public ActionResult Index()
 {
     return(View(ProvidentFund.GetAll()));
 }
    protected void Page_Load(object sender, EventArgs e)
    {
        cboEmployer.SetValidation(ValidateGroup);
        if (!hideBank)
        {
            comboBank.SetValidation(ValidateGroup);
        }
        if (!hideBank)
        {
            cboFundCode.SetValidation(ValidateGroup);
        }
        tableContent.SetCssHtmlTable_V(comboBank.CssPostfix);
        comboBank.ClientInstanceName         = this.ClientID + comboBank.ClientID;
        cboFundCode.ClientInstanceName       = this.ClientID + cboFundCode.ClientID;
        cboEmployer.ClientInstanceName       = this.ClientID + cboEmployer.ClientID;
        cbFundAndBankName.ClientInstanceName = this.ClientID + cbFundAndBankName.ClientID;
        cbEmployerName.ClientInstanceName    = this.ClientID + cboEmployer.ClientID;

        cboFundCode.ClientSideEvents.SelectedIndexChanged =
            @"function(s,e) {
					"                     + cbEmployerName.ClientInstanceName + @".PerformCallback();
                    " + comboBank.ClientInstanceName + @".PerformCallback();
                }";

        comboBank.ClientSideEvents.SelectedIndexChanged =
            @"function(s,e) {
                    " + cbFundAndBankName.ClientInstanceName + @".PerformCallback();
                }";

        comboBank.ClientSideEvents.EndCallback =
            @"function(s,e) {
                    " + cbFundAndBankName.ClientInstanceName + @".PerformCallback();
                }";

        cboEmployer.ClientSideEvents.SelectedIndexChanged =
            @"function(s,e) {
                    " + cbEmployerName.ClientInstanceName + @".PerformCallback();
                    if(typeof(" + comboBank.ClientInstanceName + @") != 'undefined')
                        " + comboBank.ClientInstanceName + @".PerformCallback();
                    if(typeof(employeeControl_cbChangeEmployer) != 'undefined'){
						employeeControl_cbChangeEmployer.SendCallback(s.GetValue());
					}
                }";

        cbFundAndBankName.ClientSideEvents.CallbackComplete =
            @"function(s,e ){
                var obj = eval('('+e.result+')');
                " + lblFundName.ClientInstanceName + @".SetValue(obj.fundname);
                " + lblBankName.ClientInstanceName + @".SetValue(obj.bank);
            }";

        cbEmployerName.ClientSideEvents.CallbackComplete =
            @"function(s,e ){
                " + lblEmployerName.ClientInstanceName + @".SetValue(e.result);
				}"                ;

        if (IsRequestPage)
        {
            trFund.Visible = !hideFund;
            trBank.Visible = !hideBank;
            //trFundAndBankLabel.Visible = trBank.Visible;
            if (hideFund)
            {
                lblFund.Visible     = false;
                cboFundCode.Visible = false;
                cboEmployer.Visible = true;
            }
            else
            {
                IList <ProvidentFund> funds = ProvidentFund.List(iSabayaContext);
                Session[this.ClientID + "funds"] = funds;
                cboFundCode.ValueField           = "FundID";
                cboFundCode.TextField            = "Code";
                cboFundCode.DataSource           = funds;
                cboFundCode.DataBind();
            }
            if (hideBank)
            {
                lblBank.Visible     = false;
                comboBank.Visible   = false;
                lblFundName.Visible = false;
                lblBankName.Visible = false;
            }
        }
        else
        {
            if (Session[this.ClientID + "fbanks"] != null)
            {
                IList <PartyBankAccount> fbanks = (IList <PartyBankAccount>)Session[this.ClientID + "fbanks"];
                comboBank.DataSource = fbanks;
                comboBank.ValueField = "ID";
                comboBank.TextField  = "AccountName";
                comboBank.DataBind();
            }
        }
        if (!Page.IsCallback)
        {
            comboBankCallback();
            employerNameCallback();
            fundAndBankNameCallBack();
        }
    }
    public void Refresh()
    {
        //Postback Form
        //ISession session = Config.Session;
        ISession session = iSabayaContext.PersistencySession;
        Employer emp     = (Employer)Session["SessionEmployer"];

        if (emp != null)
        {
            ISQLQuery query = session.CreateSQLQuery(
                @"
                            SELECT    Fund.*
                            from  dbo.EmployerFund INNER JOIN
                            dbo.Employer ON dbo.EmployerFund.EmployerID = dbo.Employer.EmployerID
                            inner join Fund on EmployerFund.FundID=Fund.FundID
                            where

                            Employer.EmployerID=" + emp.EmployerID).AddEntity(typeof(ProvidentFund));

            //Employer.EffectiveFrom >=GETDATE() and Employer.EffectiveTo<=GETDATE()
            IList <ProvidentFund> funds = query.List <ProvidentFund>();
            Session[this.ClientID + "funds"] = funds;

            cboFundCode.ValueField = "FundID";
            cboFundCode.TextField  = "Code";
            cboFundCode.DataSource = funds;
            cboFundCode.DataBind();
        }
        else
        {
            //if (Session["SessionFundCheck"] != null)
            //{
            //    int a = (int)Session["SessionFundCheck"];
            //    if (a != null)
            //    {
            //        if (a == 1)
            //        {
            //            IList<MutualFund> funds = MutualFund.List(iSabayaContext);
            //            Session[this.ClientID + "funds"] = funds;

            //            cboFundCode.ValueField = "FundID";
            //            cboFundCode.TextField = "Code";
            //            cboFundCode.DataSource = funds;
            //            cboFundCode.DataBind();
            //        }
            //        else
            //        {
            //            IList<ProvidentFund> funds = ProvidentFund.List(iSabayaContext);
            //            Session[this.ClientID + "funds"] = funds;

            //            cboFundCode.ValueField = "FundID";
            //            cboFundCode.TextField = "Code";
            //            cboFundCode.DataSource = funds;
            //            cboFundCode.DataBind();
            //        }
            //    }
            //}
            ProvidentFund fund = (ProvidentFund)Session["SessionFund"];
            if (fund != null)
            {
                ISQLQuery query = session.CreateSQLQuery(
                    @"
								select em.*
								from EmployerFund emF
								inner join Employer em on emF.EmployerID= em.EmployerID
								where emF.FundID="                                 + fund.FundID + @"
								AND (emF.EffectiveFrom <= GETDATE())
								AND (emF.EffectiveTo >= GETDATE())"                                ).AddEntity(typeof(Employer));

                IList <Employer> employers = query.List <Employer>();
                Session[this.ClientID + "funds"] = fund;

                cboEmployer.ValueField = "EmployerID";
                cboEmployer.TextField  = "EmployerNo";
                cboEmployer.DataSource = employers;
                cboEmployer.DataBind();
                if (IsPostBack && !Page.IsCallback)
                {
                    cboEmployer.SelectedIndex = -1;
                }
            }
        }
    }