Esempio n. 1
0
        public ActionResult GmoCapexes_Update([DataSourceRequest] DataSourceRequest request, GmoCapex gmoCapex, string userID)
        {
            int _userID   = userID.ToInt();
            var _userInfo = db.peAppUsers.Where(u => u.ID.Equals(_userID)).Select(u => new { u.Dept, u.LoginName }).FirstOrDefault();

            if (ModelState.IsValid)
            {
                var entity = new GmoCapex
                {
                    Id             = gmoCapex.Id,
                    AnnualBudgetId = gmoCapex.AnnualBudgetId,
                    DeptName       = gmoCapex.DeptName,
                    PrjLeader      = gmoCapex.PrjLeader,
                    PrjName        = gmoCapex.PrjName,
                    YusuanMoney    = gmoCapex.YusuanMoney,
                    BudgetQuarter  = gmoCapex.BudgetQuarter,
                    Status         = gmoCapex.Status,
                    JinduMiaoshu   = gmoCapex.JinduMiaoshu,
                    CapexId        = gmoCapex.CapexId,
                    ShenqingMoney  = gmoCapex.ShenqingMoney,
                    HuiguJieguo    = gmoCapex.HuiguJieguo,
                    Inputer        = gmoCapex.Inputer,
                    //InputDatetime = gmoCapex.InputDatetime,
                    Modifier       = _userInfo.LoginName ?? "",
                    ModifyDatetime = DateTime.Now
                };

                db.GmoCapexes.Attach(entity);
                db.Entry(entity).State = EntityState.Modified;
                db.SaveChanges();
            }

            return(Json(new[] { gmoCapex }.ToDataSourceResult(request, ModelState)));
        }
Esempio n. 2
0
        public ActionResult GmoCapexes_Destroy([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")] IEnumerable <GmoCapex> gmoCapexs)
        {
            var entities = new List <GmoCapex>();

            if (ModelState.IsValid)
            {
                foreach (var gmoCapex in gmoCapexs)
                {
                    var entity = new GmoCapex
                    {
                        Id             = gmoCapex.Id,
                        AnnualBudgetId = gmoCapex.AnnualBudgetId,
                        DeptName       = gmoCapex.DeptName,
                        PrjLeader      = gmoCapex.PrjLeader,
                        PrjName        = gmoCapex.PrjName,
                        YusuanMoney    = gmoCapex.YusuanMoney,
                        BudgetQuarter  = gmoCapex.BudgetQuarter,
                        Status         = gmoCapex.Status,
                        JinduMiaoshu   = gmoCapex.JinduMiaoshu,
                        CapexId        = gmoCapex.CapexId,
                        ShenqingMoney  = gmoCapex.ShenqingMoney,
                        HuiguJieguo    = gmoCapex.HuiguJieguo,
                        Inputer        = gmoCapex.Inputer,
                        InputDatetime  = gmoCapex.InputDatetime,
                        Modifier       = gmoCapex.Modifier,
                        ModifyDatetime = gmoCapex.ModifyDatetime
                    };
                    entities.Add(entity);
                    db.GmoCapexes.Attach(entity);
                    db.GmoCapexes.Remove(entity);
                    //db.Entry(entity).State = EntityState.Modified;
                }
                //var entity = new GmoCapex
                //{
                //    Id = gmoCapex.Id,
                //    AnnualBudgetId = gmoCapex.AnnualBudgetId,
                //    DeptName = gmoCapex.DeptName,
                //    PrjLeader = gmoCapex.PrjLeader,
                //    PrjName = gmoCapex.PrjName,
                //    YusuanMoney = gmoCapex.YusuanMoney,
                //    BudgetQuarter = gmoCapex.BudgetQuarter,
                //    Status = gmoCapex.Status,
                //    JinduMiaoshu = gmoCapex.JinduMiaoshu,
                //    CapexId = gmoCapex.CapexId,
                //    ShenqingMoney = gmoCapex.ShenqingMoney,
                //    HuiguJieguo = gmoCapex.HuiguJieguo,
                //    Inputer = gmoCapex.Inputer,
                //    InputDatetime = gmoCapex.InputDatetime,
                //    Modifier = gmoCapex.Modifier,
                //    ModifyDatetime = gmoCapex.ModifyDatetime
                //};


                db.SaveChanges();
            }

            return(Json(entities.ToDataSourceResult(request, ModelState)));
        }
Esempio n. 3
0
        public ActionResult GmoCapexes_Create([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")] IEnumerable <GmoCapex> gmoCapexs, string userID)
        {
            int _userID    = userID.ToInt();
            var _userInfo  = db.peAppUsers.Where(u => u.ID.Equals(_userID)).Select(u => new { u.Dept, u.LoginName }).FirstOrDefault();
            var gmoCapexes = gmoCapexs as IList <GmoCapex> ?? gmoCapexs.ToList();

            if (ModelState.IsValid)
            {
                foreach (var gmoCapex in gmoCapexes)
                {
                    var entity = new GmoCapex
                    {
                        AnnualBudgetId = gmoCapex.AnnualBudgetId,
                        DeptName       = gmoCapex.DeptName,
                        PrjLeader      = gmoCapex.PrjLeader,
                        PrjName        = gmoCapex.PrjName,
                        YusuanMoney    = gmoCapex.YusuanMoney,
                        BudgetQuarter  = gmoCapex.BudgetQuarter,
                        Status         = gmoCapex.Status,
                        JinduMiaoshu   = gmoCapex.JinduMiaoshu,
                        CapexId        = gmoCapex.CapexId,
                        ShenqingMoney  = gmoCapex.ShenqingMoney,
                        HuiguJieguo    = gmoCapex.HuiguJieguo,
                        Inputer        = _userInfo.LoginName ?? "",
                        //InputDatetime = gmoCapex.InputDatetime,
                        Modifier       = "",
                        ModifyDatetime = gmoCapex.ModifyDatetime
                    };

                    db.GmoCapexes.Add(entity);
                    gmoCapex.Id = entity.Id;
                }
                db.SaveChanges();
            }

            return(Json(gmoCapexes.ToDataSourceResult(request, ModelState)));
        }