//------------------------------------------------------------------------------------------------ //Sub Fund Tab //------------------------------------------------------------------------------------------------ public ActionResult GetSubFundDTable() { SubFundModel model = new SubFundModel(); List <SubFundList> getSubFundList = new List <SubFundList>(); var SQLQuery = "SELECT [SubFundID], [SubFundTitle], [Tbl_FMFund_Fund].[FundTitle] FROM [BOSS].[dbo].[Tbl_FMFund_SubFund],[dbo].[Tbl_FMFund_Fund] where [dbo].[Tbl_FMFund_SubFund].FundID =[dbo].[Tbl_FMFund_Fund].FundID"; using (SqlConnection Connection = new SqlConnection(GlobalFunction.ReturnConnectionString())) { Connection.Open(); using (SqlCommand command = new SqlCommand("[dbo].[SP_Fund]", Connection)) { command.CommandType = CommandType.StoredProcedure; command.Parameters.Add(new SqlParameter("@SQLStatement", SQLQuery)); SqlDataReader dr = command.ExecuteReader(); while (dr.Read()) { getSubFundList.Add(new SubFundList() { SubFundID = GlobalFunction.ReturnEmptyInt(dr[0]), FundTitle = GlobalFunction.ReturnEmptyString(dr[2]), SubFundTitle = GlobalFunction.ReturnEmptyString(dr[1]) }); } } Connection.Close(); } model.getSubFundList = getSubFundList.ToList(); return(PartialView("SubFundTab/_TableSubFund", model.getSubFundList)); }
public ActionResult GetSubFundForm(int ActionID, int SubFundID) { SubFundModel model = new SubFundModel(); if (ActionID == 2) { var sfund = (from a in BOSSDB.Tbl_FMFund_SubFund where a.SubFundID == SubFundID select a).FirstOrDefault(); model.SubFundList.SubFundTitle = sfund.SubFundTitle; model.SubFundList.FundID = Convert.ToInt32(sfund.FundID); model.SubFundList.SubFundID = sfund.SubFundID; } model.ActionID = ActionID; return(PartialView("SubFundTab/_SubFundForm", model)); }
//SubFund Tab public ActionResult GetSubFundTab() { SubFundModel model = new SubFundModel(); return(PartialView("SubFundTab/IndexSubFundTab", model)); }
public ActionResult SaveSubFund(SubFundModel model) { var isExist = ""; if (ModelState.IsValid) { var subfundTitle = model.SubFundList.SubFundTitle; subfundTitle = new CultureInfo("en-US").TextInfo.ToTitleCase(subfundTitle); Tbl_FMFund_SubFund checksubFund = (from a in BOSSDB.Tbl_FMFund_SubFund where (a.SubFundTitle == model.SubFundList.SubFundTitle) select a).FirstOrDefault(); if (model.ActionID == 1) { if (checksubFund == null) { Tbl_FMFund_SubFund sfund = new Tbl_FMFund_SubFund(); sfund.SubFundTitle = subfundTitle; sfund.FundID = model.SubFundList.FundID; BOSSDB.Tbl_FMFund_SubFund.Add(sfund); BOSSDB.SaveChanges(); isExist = "false"; } else if (checksubFund != null) { isExist = "true"; } } else if (model.ActionID == 2) { Tbl_FMFund_SubFund subfund = (from a in BOSSDB.Tbl_FMFund_SubFund where a.SubFundID == model.SubFundList.SubFundID select a).FirstOrDefault(); List <Tbl_FMFund_SubFund> subfundTitlelist = (from e in BOSSDB.Tbl_FMFund_SubFund where e.SubFundTitle == subfundTitle select e).ToList(); if (checksubFund != null) { if (subfund.SubFundTitle == subfundTitle && subfund.SubFundID == model.SubFundList.SubFundID && subfund.FundID == model.SubFundList.FundID) { subfund.SubFundTitle = subfundTitle; subfund.FundID = GlobalFunction.ReturnEmptyInt(model.SubFundList.FundID); BOSSDB.Entry(subfund); BOSSDB.SaveChanges(); isExist = "justUpdate"; } else { if (subfund.SubFundTitle != subfundTitle && subfundTitlelist.Count >= 1) { isExist = "true"; } else { subfund.SubFundTitle = subfundTitle; subfund.FundID = GlobalFunction.ReturnEmptyInt(model.SubFundList.FundID); BOSSDB.Entry(subfund); BOSSDB.SaveChanges(); isExist = "justUpdate"; } } } else if (checksubFund == null) { subfund.SubFundTitle = subfundTitle; subfund.FundID = model.SubFundList.FundID; BOSSDB.Entry(subfund); BOSSDB.SaveChanges(); isExist = "justUpdate"; } } } return(new JsonResult() { JsonRequestBehavior = JsonRequestBehavior.AllowGet, Data = new { isExist = isExist } }); }