コード例 #1
0
        public ActionResult InsertStore(string CardNber, string Name, string CredentialsNumber, string XEffective, string YEffective)//新增信息
        {
            string strStore = "falied";

            try
            {
                //实例化对象
                Models.B_EffectiveList myStore = new Models.B_EffectiveList();
                //给表对象属性赋值
                myStore.CardNber          = CardNber.Trim();
                myStore.Name              = Name.Trim();
                myStore.CredentialsNumber = CredentialsNumber.Trim();
                myStore.XEffective        = XEffective.Trim();
                myStore.YEffective        = YEffective.Trim();
                //把表对象实体模型中
                MyModels.B_EffectiveList.Add(myStore);
                //将对象实体插入到数据库中
                MyModels.SaveChanges();
                strStore = "ok";
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            return(Json(strStore, JsonRequestBehavior.AllowGet));
        }
コード例 #2
0
        public ActionResult DeleteEffective(int EffectiveId) //删除
        {
            string strMsg = "fail";                          //定义返回

            //查询数据
            Models.B_EffectiveList dbMemberAge = (from tbMemberAge in MyModels.B_EffectiveList
                                                  where tbMemberAge.EffectiveID == EffectiveId
                                                  select tbMemberAge).Single();
            MyModels.B_EffectiveList.Remove(dbMemberAge);//删除
            if (MyModels.SaveChanges() > 0)
            {
                strMsg = "success";
            }
            return(Json(strMsg, JsonRequestBehavior.AllowGet));
        }