コード例 #1
0
        public ActionResult CreateFundSource(FundSourceModel objFundSourceModel)
        {
            var resultDto = new ResultDto();

            if (ModelState.IsValid)
            {
                var fundSourceDto = Mapper.Map <FundSourceModel, FundSourceDto>(objFundSourceModel);
                fundSourceDto.UserId = UserInfo.UserID;
                if (fundSourceDto.FundSourceID == 0)
                {
                    resultDto = _fundSourceService.Insert(fundSourceDto);
                }
                else
                {
                    resultDto = _fundSourceService.Update(fundSourceDto);
                }
                if (resultDto.ObjectId > 0)
                {
                    fundSourceDto        = _fundSourceService.GetByID(resultDto.ObjectId);
                    objFundSourceModel   = Mapper.Map <FundSourceDto, FundSourceModel>(fundSourceDto);
                    resultDto.ObjectCode = fundSourceDto.FundSourceCode;
                }
            }
            ViewBag.Result = resultDto;
            return(View(objFundSourceModel));
        }
コード例 #2
0
        //=============================================================================================================================
        //Fund Source Tab
        //=============================================================================================================================
        public ActionResult GetFundSourceDTable()
        {
            FundSourceModel model = new FundSourceModel();

            List <FundSourceList> getFundSourceList = new List <FundSourceList>();

            var SQLQuery = "SELECT [FundSourceID],[FundSourceTitle],[AppropSourceTypeTitle] FROM [BOSS].[dbo].[Tbl_FMApprop_FundSource], [dbo].[FMApprop_AppropriationSourceType] where [dbo].[Tbl_FMApprop_FundSource].AppropSourceTypeID = [dbo].[FMApprop_AppropriationSourceType].AppropSourceTypeID";

            using (SqlConnection Connection = new SqlConnection(GlobalFunction.ReturnConnectionString()))
            {
                Connection.Open();
                using (SqlCommand command = new SqlCommand("[dbo].[SP_AppropriationSource]", Connection))
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.Add(new SqlParameter("@SQLStatement", SQLQuery));
                    SqlDataReader dr = command.ExecuteReader();
                    while (dr.Read())
                    {
                        getFundSourceList.Add(new FundSourceList()
                        {
                            FundSourceID          = GlobalFunction.ReturnEmptyInt(dr[0]),
                            FundSourceTitle       = GlobalFunction.ReturnEmptyString(dr[1]),
                            AppropSourceTypeTitle = GlobalFunction.ReturnEmptyString(dr[2])
                        });
                    }
                }
                Connection.Close();
            }
            model.getFundSourceList = getFundSourceList.ToList();
            return(PartialView("FundSource/_TableFundSource", model.getFundSourceList));
        }
コード例 #3
0
        public ActionResult GetFundSourceForm(int ActionID, int PrimaryID)
        {
            FundSourceModel model = new FundSourceModel();

            if (ActionID == 2)
            {
                var fundsource = (from a in BOSSDB.Tbl_FMApprop_FundSource where a.FundSourceID == PrimaryID select a).FirstOrDefault();

                model.AppropSourceTypeID             = Convert.ToInt32(fundsource.AppropSourceTypeID);
                model.FundSourceList.FundSourceTitle = fundsource.FundSourceTitle;
                model.FundSourceList.FundSourceID    = fundsource.FundSourceID;
            }
            model.ActionID = ActionID;
            return(PartialView("FundSource/_FundSourceForm", model));
        }
コード例 #4
0
        public ActionResult CreateFundSource(string Id)
        {
            int fundSourceId  = DecryptQueryString(Id);
            var fundSourceDto = new FundSourceDto();

            var objFundsourceModel = new FundSourceModel();

            if (fundSourceId > 0)
            {
                fundSourceDto = _fundSourceService.GetByID(fundSourceId);

                objFundsourceModel = Mapper.Map <FundSourceDto, FundSourceModel>(fundSourceDto);
            }
            ViewBag.Result = new ResultDto();

            return(View(objFundsourceModel));
        }
コード例 #5
0
        //=============================================================================================================================
        //Calling Tabs
        //=============================================================================================================================
        public ActionResult GetFundSourceTab()
        {
            FundSourceModel model = new FundSourceModel();

            return(PartialView("FundSource/FundSourceIndex", model));
        }
コード例 #6
0
        public ActionResult SaveFundSource(FundSourceModel model)
        {
            var isExist = "";

            if (ModelState.IsValid)
            {
                var fundsourceTitle = model.FundSourceList.FundSourceTitle;
                fundsourceTitle = Regex.Replace(fundsourceTitle, @"\s\s+", "");
                fundsourceTitle = Regex.Replace(fundsourceTitle, @"^\s+", "");
                fundsourceTitle = Regex.Replace(fundsourceTitle, @"\s+$", "");
                fundsourceTitle = new CultureInfo("en-US").TextInfo.ToTitleCase(fundsourceTitle);
                Tbl_FMApprop_FundSource checkFundsource = (from a in BOSSDB.Tbl_FMApprop_FundSource where (a.FundSourceTitle == fundsourceTitle) select a).FirstOrDefault();

                if (model.ActionID == 1)
                {
                    if (checkFundsource == null)
                    {
                        Tbl_FMApprop_FundSource fundsource = new Tbl_FMApprop_FundSource();
                        fundsource.FundSourceTitle    = fundsourceTitle;
                        fundsource.AppropSourceTypeID = model.AppropSourceTypeID;
                        BOSSDB.Tbl_FMApprop_FundSource.Add(fundsource);
                        BOSSDB.SaveChanges();
                        isExist = "false";
                    }
                    else if (checkFundsource != null)
                    {
                        isExist = "true";
                    }
                }
                else if (model.ActionID == 2)
                {
                    Tbl_FMApprop_FundSource        fundS           = (from a in BOSSDB.Tbl_FMApprop_FundSource where a.FundSourceID == model.FundSourceList.FundSourceID select a).FirstOrDefault();
                    List <Tbl_FMApprop_FundSource> fundsourcetitle = (from e in BOSSDB.Tbl_FMApprop_FundSource where e.FundSourceTitle == fundsourceTitle select e).ToList();
                    if (checkFundsource != null)
                    {
                        if (fundS.FundSourceTitle != fundsourceTitle && fundsourcetitle.Count >= 1)
                        {
                            isExist = "true";
                        }
                        else
                        {
                            fundS.FundSourceTitle    = fundsourceTitle;
                            fundS.AppropSourceTypeID = model.AppropSourceTypeID;
                            BOSSDB.Entry(fundS);
                            BOSSDB.SaveChanges();
                            isExist = "justUpdate";
                        }
                    }
                    else if (checkFundsource == null)
                    {
                        fundS.FundSourceTitle    = fundsourceTitle;
                        fundS.AppropSourceTypeID = model.AppropSourceTypeID;
                        BOSSDB.Entry(fundS);
                        BOSSDB.SaveChanges();
                        isExist = "justUpdate";
                    }
                }
            }
            return(new JsonResult()
            {
                JsonRequestBehavior = JsonRequestBehavior.AllowGet,
                Data = new { isExist = isExist }
            });
        }