public ActionResult btnInsert()//保存 { Models.S_MemberInfoList Delst = new Models.S_MemberInfoList(); Delst.XingMing = Request.Form["XingMing"]; Delst.CredentialsType = Request.Form["CredentialsType"]; Delst.CredentialsNumber = Request.Form["CredentialsNumber"]; Delst.PostalAddress = Request.Form["PostalAddress"]; Delst.Location = Request.Form["Location"]; Delst.Postalcode = Request.Form["Postalcode"]; Delst.dianziyoujian = Request.Form["dianziyoujian"]; Delst.Profession = Request.Form["Profession"]; Delst.OfficePhone = Request.Form["OfficePhone"]; Delst.PrivateTelephone = Request.Form["PrivateTelephone"]; Delst.CellphoneNumber = Request.Form["CellphoneNumber"]; Delst.TimeToMall = Request.Form["TimeToMall"]; Delst.MemberEd = Request.Form["MemberEd"]; Delst.MemberFamilyIncome = Request.Form["MemberFamilyIncome"]; Delst.Vehicle = Request.Form["Vehicle"]; Delst.FamilyMember = Request.Form["FamilyMember"]; Delst.CardNumberChange = Request.Form["CardNumberChange"]; Delst.CommentsOnAForm = Request.Form["CommentsOnAForm"]; if (Delst.XingMing != null && Delst.CredentialsType != null && Delst.CredentialsNumber != null && Delst.PostalAddress != null && Delst.Location != null && Delst.Postalcode != null && Delst.dianziyoujian != null && Delst.Profession != null && Delst.OfficePhone != null && Delst.PrivateTelephone != null && Delst.CellphoneNumber != null && Delst.TimeToMall != null && Delst.MemberEd != null && Delst.MemberFamilyIncome != null && Delst.Vehicle != null && Delst.FamilyMember != null && Delst.CardNumberChange != null && Delst.CommentsOnAForm != null) { MyModels.S_MemberInfoList.Add(Delst); MyModels.SaveChanges(); return(Json("success", JsonRequestBehavior.AllowGet)); } else { return(Json("fail", JsonRequestBehavior.AllowGet)); } }
public ActionResult DeleteMember(int MemberId) //删除信息 { string strMsg = "fail"; //定义返回 //查询数据 Models.S_MemberInfoList dbMember = (from tbMember in MyModels.S_MemberInfoList where tbMember.MemberID == MemberId select tbMember).Single(); MyModels.S_MemberInfoList.Remove(dbMember);//删除 if (MyModels.SaveChanges() > 0) { strMsg = "success"; } return(Json(strMsg, JsonRequestBehavior.AllowGet)); }