Пример #1
0
        public List <ModifyStudent> GetAllStudent()
        {
            List <ModifyStudent> stu = new List <ModifyStudent>();

            string conn = ConfigurationManager.ConnectionStrings["dbx"].ConnectionString;

            using (SqlConnection con = new SqlConnection(conn))
            {
                using (SqlCommand cmd = new SqlCommand("sp_findData", con))
                {
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                    con.Open();

                    SqlDataReader rdr = cmd.ExecuteReader();
                    while (rdr.Read())
                    {
                        ModifyStudent student = new ModifyStudent();
                        student.ID       = int.Parse(rdr["ID"].ToString());
                        student.Name     = rdr["Name"].ToString();
                        student.Addresss = rdr["Address"].ToString();
                        student.Course   = rdr["Course"].ToString();
                        student.Image    = rdr["Image"].ToString();
                        stu.Add(student);
                    }
                }
            }
            return(stu);
        }
Пример #2
0
        public void AddStudentData(ModifyStudent Mstud, HttpPostedFileBase file)
        {
            string conn = ConfigurationManager.ConnectionStrings["dbx"].ConnectionString;

            using (SqlConnection con = new SqlConnection(conn))
            {
                using (SqlCommand cmd = new SqlCommand("sp_saveData", con))
                {
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                    con.Open();
                    cmd.Parameters.AddWithValue("@ID", Mstud.ID);
                    cmd.Parameters.AddWithValue("@Name", Mstud.Name);
                    cmd.Parameters.AddWithValue("@Address", Mstud.Addresss);
                    cmd.Parameters.AddWithValue("@Course", Mstud.Course);
                    if (file != null && file.ContentLength > 0)
                    {
                        string fileName = Path.GetFileName(file.FileName);
                        string imgPath  = Path.Combine(System.Web.HttpContext.Current.Server.MapPath("~/Images/"), fileName);
                        file.SaveAs(imgPath);
                    }
                    cmd.Parameters.AddWithValue("@Image", "~/Images/" + file.FileName);
                    cmd.ExecuteNonQuery();
                }
            }
        }
Пример #3
0
 public IActionResult ModifyStudent(ModifyStudent modifyStudent)
 {
     if (studentsDbContext.Student.Where(s => s.IndexNumber == modifyStudent.Index).Any())
     {
         var student = studentsDbContext.Student.SingleOrDefault(s => s.IndexNumber == modifyStudent.Index);
         if (student.IndexNumber != modifyStudent.IndexNumber && modifyStudent.IndexNumber != null)
         {
             student.IndexNumber = modifyStudent.IndexNumber;
             studentsDbContext.SaveChanges();
         }
         if (student.FirstName != modifyStudent.FirstName && modifyStudent.FirstName != null)
         {
             student.FirstName = modifyStudent.FirstName;
             studentsDbContext.SaveChanges();
         }
         if (student.LastName != modifyStudent.LastName && modifyStudent.LsatName != null)
         {
             student.LastName = modifyStudent.LastName;
             studentsDbContext.SaveChanges();
         }
         if (student.Birthdate != modifyStudent.Birthdate && modifyStudent.Birthdate != null)
         {
             student.Birthdate = modifyStudent.Birthdate;
             studentsDbContext.SaveChanges();
         }
         if (student.IdEnrollment != modifyStudent.IdEnrollment && modifyStudent.IdEnrollment != null)
         {
             student.IdEnrollment = modifyStudent.IdEnrollment;
             studentsDbContext.SaveChanges();
         }
         return(Ok());
     }
     return(NotFound());
 }
Пример #4
0
        public EntityStateWrapperContainer Modify(ModifyStudent.CommandModel commandModel)
        {
            EnrollmentDate = commandModel.EnrollmentDate;
            FirstMidName = commandModel.FirstMidName;
            LastName = commandModel.LastName;

            return new EntityStateWrapperContainer().ModifyEntity(this);
        }
 public ActionResult Create(ModifyStudent Mstud, HttpPostedFileBase file)
 {
     if (ModelState.IsValid)
     {
         ModifyStudentViewModel studentt = new ModifyStudentViewModel();
         studentt.AddStudentData(Mstud, file);
         return(RedirectToAction("Index"));
     }
     return(View());
 }
        public ModifyStudent.Response Handle(ModifyStudent.Request request)
        {
            var validationDetails = Validator.ValidateRequest(request);
            if (validationDetails.HasValidationIssues)
                return new ModifyStudent.Response(validationDetails);

            var commandModel = request.CommandModel;
            var container = StudentFactory.CreatePartial(commandModel.ID).Modify(commandModel);
            validationDetails = _Repository.Save(container);

            return new ModifyStudent.Response(validationDetails);
        }
Пример #7
0
        public string InsertStudentAccount(CreateStudentAccount model)
        {
            DateTime      birth   = new DateTime(model.year, model.month, model.day);
            string        md5pass = new Md5Function().MD5HashFunction(model.password);
            ModifyAccount ma      = new ModifyAccount();
            ModifyStudent ms      = new ModifyStudent();

            if (ma.Check(model.username))
            {
                return("false");
            }
            else
            {
                ma.Insert(model.username, md5pass, 3);
                ms.Insert(model.name, birth, model.gender, model.country, model.address, model.username, model.course, model.branch);
                return("true");
            }
        }