コード例 #1
0
        public ActionResult CustomerUserGridView1PartialUpdate(ProjectAnalysis.Models.T_CustomerUser item)
        {
            var model = db.T_CustomerUser;

            if (ModelState.IsValid)
            {
                try
                {
                    var modelItem = model.FirstOrDefault(it => it.CustomerUserID == item.CustomerUserID);
                    if (modelItem != null)
                    {
                        this.UpdateModel(modelItem);
                        db.SaveChanges();
                    }
                }
                catch (Exception e)
                {
                    ViewData["EditError"] = e.Message;
                }
            }
            else
            {
                ViewData["EditError"] = "Please, correct all errors.";
            }
            return(PartialView("_CustomerUserGridView1Partial", model.ToList()));
        }
コード例 #2
0
        public ActionResult CustomerUserGridView1PartialAddNew(ProjectAnalysis.Models.T_CustomerUser item)
        {
            var model = db.T_CustomerUser;

            if (ModelState.IsValid)
            {
                try
                {
                    ObjectParameter output = new ObjectParameter("CurrentSequenceStr", typeof(string));
                    db.p_sys_GenSequence("T_CustomerUser_CustomerUserID", output);
                    var result = output.Value;
                    item.CustomerUserID = long.Parse(result.ToString());
                    item.CustomerUserBH = result.ToString();
                    model.Add(item);
                    db.SaveChanges();
                }
                catch (Exception e)
                {
                    ViewData["EditError"] = e.Message;
                }
            }
            else
            {
                ViewData["EditError"] = "Please, correct all errors.";
            }
            return(PartialView("_CustomerUserGridView1Partial", model.ToList()));
        }