Пример #1
0
        public ActionResult DeleteInfo(Models.StudentInfo obj)
        {
            //var sr = new System.IO.StreamReader(Request.InputStream);
            //var jss = new JavaScriptSerializer();
            //var obj = jss.Deserialize<Models.StudentInfo>(sr.ReadToEnd());///前台传来的数据
            var studentInfos = db.StudentInfo.Where(p => p.StudentId == obj.StudentId).FirstOrDefault();

            db.StudentInfo.Remove(studentInfos);
            db.SaveChanges();
            var rst = Json(new { success = true, message = 1 }, JsonRequestBehavior.AllowGet);

            return(rst);
        }
Пример #2
0
        public string GetInfo(Models.StudentInfo obj)
        {
            //var sr = new System.IO.StreamReader(Request.InputStream);
            var jss = new JavaScriptSerializer();

            //var obj = jss.Deserialize<Models.StudentInfo>(sr.ReadToEnd());///前台传来的数据

            Models.StudentInfo studentInfos = db.StudentInfo.Where(p => p.StudentId == obj.StudentId).FirstOrDefault();
            StringBuilder      sb           = new StringBuilder();
            String             json         = jss.Serialize(studentInfos).ToString();

            return(json);
        }
Пример #3
0
 public IHttpActionResult updatestudent(Models.StudentInfo data)
 {
     using (StudentDbContext entities = new StudentDbContext())
     {
         Models.StudentInfo studentID = entities.studentInfos.Where(i => i.ID == data.ID).FirstOrDefault();
         if (studentID != null)
         {
             studentID.Name        = data.Name;
             studentID.DateOfBirth = data.DateOfBirth;
             studentID.Address     = data.Address;
             studentID.Class       = data.Class;
         }
         entities.SaveChanges();
     }
     return(Ok("Cap nhat thanh cong"));
 }
        public ActionResult Create(Models.StudentInfo collection)
        {
            string message = "";

            if (ModelState.IsValid)
            {
                string   Name   = collection.Name;
                string   Email  = collection.Email;
                string   Mobile = collection.Mobile;
                string   Course = collection.Course;
                int      age    = collection.age;
                DateTime DOB    = Convert.ToDateTime(collection.DOB);


                //  DataSet dt = con.GetRecordWithDataset("DECLARE @ScheduleDateTime DATETIME=getdate();Declare @ExpiryDateTime Datetime = getdate() + 91; exec glivebooks.dbo.[crm_insert_feed_lists] @Website_ID='9',@LoginID='" + ssn + "',@ListingID='" + ListingID + "',@FeedChannelID='" + feedchannelid + "',@ListingCategoryID='" + ListingCategoryID + "',@ListingTitle='" + ListingTitle + "',@ListingHeadline='',@ListingDescription='" + ListingDescription + "',@ScheduleDateTime=@ScheduleDateTime,@Expires=1,@ExpiryDateTime=@ExpiryDateTime,@FeedVisibilityID=3,@ActionButtonID=20,@ListingTopicsIDList='',@VisibilityExceptFriendList='',@VisibilitySpecificFriendList='',@CustomFriendListID='',@ResponseContactFeedChannelID='" + ResponseContactFeedChannelID + "',@FeedID='" + FeedId + "' ");
                DataSet dt = BussinessLogicController.GetSetRecord("exec sp_registration @id='', @Name='" + Name + "',@Email='" + Email + "',@Mobile='" + Mobile + "',@Course='" + Course + "',@age='" + age + "',@DOB='" + DOB + "',@action='insert'");
                if (dt.Tables.Count > 0)
                {
                    if (dt.Tables[0].Rows.Count > 0)
                    {
                        message         = dt.Tables[0].Rows[0]["message"].ToString();
                        ViewBag.Message = message;
                    }
                }
                // TODO: Add insert logic here
            }

            if (message == "")
            {
                return(View());
            }

            if (message == "you have successfully registered")
            {
                ModelState.Clear();
            }


            // return Json("",message, JsonRequestBehavior.AllowGet);
            return(View());
        }
Пример #5
0
        public ActionResult StudentInfo()
        {
            var sr  = new System.IO.StreamReader(Request.InputStream);
            var jss = new JavaScriptSerializer();
            var obj = jss.Deserialize <Models.StudentInfo>(sr.ReadToEnd());///前台传来的数据

            if (obj != null)
            {
                Models.StudentInfo student = new Models.StudentInfo();
                student.Name      = obj.Name;
                student.StudentId = obj.StudentId;
                student.Class     = obj.Class;
                student.DormId    = obj.DormId;

                db.StudentInfo.Add(student);
                db.SaveChanges();
            }
            var rst = Json(new { success = true, message = 1 }, JsonRequestBehavior.AllowGet);

            return(rst);
        }
Пример #6
0
        public ActionResult StudentAdd(Models.StudentInfo obj)
        {
            //var sr = new System.IO.StreamReader(Request.InputStream);
            //var jss = new JavaScriptSerializer();
            //var obj = jss.Deserialize<Models.StudentInfo>(sr.ReadToEnd());///前台传来的数据

            var rst = Json(new { success = true, message = 1 }, JsonRequestBehavior.AllowGet);

            try
            {
                var student = db.StudentInfo.Where(p => p.StudentId == obj.StudentId).FirstOrDefault();
                Models.StudentInfo studentInfo = new Models.StudentInfo();
                if (obj != null && student != null && obj.StudentId == student.StudentId)
                {
                    student.Name      = obj.Name;
                    student.StudentId = obj.StudentId;
                    student.Class     = obj.Class;
                    student.DormId    = obj.DormId;
                }
                else
                {
                    studentInfo.Name      = obj.Name;
                    studentInfo.StudentId = obj.StudentId;
                    studentInfo.Class     = obj.Class;
                    studentInfo.DormId    = obj.DormId;
                    db.StudentInfo.Add(studentInfo);
                }
                db.SaveChanges();
            }
            catch (Exception)
            {
                rst = Json(new { success = true, message = 0 }, JsonRequestBehavior.AllowGet);
            }

            return(rst);
        }
Пример #7
0
        public IHttpActionResult addNewStudent([FromBody] Models.StudentInfo data)
        {
            var now       = DateTime.Now;
            var zeroDate  = DateTime.MinValue.AddHours(now.Hour).AddMinutes(now.Minute).AddSeconds(now.Second).AddMilliseconds(now.Millisecond);
            int studentId = (int)(zeroDate.Ticks / 10000);



            using (StudentDbContext entities = new StudentDbContext())
            {
                Models.StudentInfo studentinfo = new Models.StudentInfo()
                {
                    ID          = studentId,
                    Name        = data.Name,
                    DateOfBirth = data.DateOfBirth,
                    Address     = data.Address,
                    Class       = data.Class,
                    ImagePath   = data.ImagePath
                };
                entities.studentInfos.Add(studentinfo);
                entities.SaveChanges();
            };
            return(Ok("Them thanh cong"));
        }