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()); } }
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(); }"; }
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(); } }