예제 #1
0
        public ActionResult Sudent_Register(Tbl_Student svw, HttpPostedFileBase imgfile)
        {
            Tbl_Student s = new Tbl_Student();

            //try
            //{
            s.S_UserName  = svw.S_UserName;
            s.S_Password  = svw.S_Password;
            s.S_FirstName = svw.S_FirstName;
            s.S_LastName  = svw.S_LastName;
            s.S_EmailID   = svw.S_EmailID;
            s.S_ContactNo = svw.S_ContactNo;
            s.S_Birthdate = svw.S_Birthdate;
            s.S_Age       = svw.S_Age;
            s.S_img       = uploadimage(imgfile);
            db.Tbl_Student.Add(s);
            db.SaveChanges();
            return(RedirectToAction("slogin"));

            //  }
            //catch (Exception)
            //{
            //    ViewBag.msg = "Data could not insert";
            //}

            //  return View();
        }
예제 #2
0
        public IHttpActionResult Get(string id)
        {
            var item = context.Tbl_Student.Where(p => p.StudentID == id).FirstOrDefault();

            if (item == null)
            {
                return(StatusCode(HttpStatusCode.NoContent));
            }
            else
            {
                Tbl_Student cat = new Tbl_Student();
                cat.SerialID         = item.SerialID;
                cat.StudentID        = item.StudentID;
                cat.FirstName        = item.FirstName;
                cat.LastName         = item.LastName;
                cat.BirthDate        = item.BirthDate;
                cat.DepartmentID     = item.DepartmentID;
                cat.FatherName       = item.FatherName;
                cat.MotherName       = item.MotherName;
                cat.PresentAddress   = item.PresentAddress;
                cat.PermanentAddress = item.PermanentAddress;
                cat.Phone            = item.Phone;
                cat.Email            = item.Email;
                cat.Sex                 = item.Sex;
                cat.Nationality         = item.Nationality;
                cat.Religion            = item.Religion;
                cat.MaritalStatus       = item.MaritalStatus;
                cat.BloodGroup          = item.BloodGroup;
                cat.AdmissionDate       = item.AdmissionDate;
                cat.GraduationDate      = item.GraduationDate;
                cat.PerSemesterRecordID = item.PerSemesterRecordID;
                cat.DocumentsGiven      = item.DocumentsGiven;
                cat.Password            = item.Password;
                cat.Picture             = item.Picture;
                cat.Type                = item.Type;

                cat.links.Add(new Links()
                {
                    HRef = "http://localhost:57254/api/Students", Method = "GET", Rel = "Self"
                });
                cat.links.Add(new Links()
                {
                    HRef = "http://localhost:57254/api/Students/" + cat.StudentID, Method = "GET", Rel = "Specific Resource"
                });
                cat.links.Add(new Links()
                {
                    HRef = "http://localhost:57254/api/Students/" + cat.StudentID, Method = "PUT", Rel = "Resource Edit"
                });
                cat.links.Add(new Links()
                {
                    HRef = "http://localhost:57254/api/Students/" + cat.StudentID, Method = "DELETE", Rel = "Resource Delete"
                });
                cat.links.Add(new Links()
                {
                    HRef = "http://localhost:57254/api/Students", Method = "POST", Rel = "Resource Create"
                });
                return(Ok(cat));
            }
        }
예제 #3
0
        public IHttpActionResult Get()
        {
            var list = context.Tbl_Student.ToList();
            List <Tbl_Student> categories = new List <Tbl_Student>();

            foreach (var item in list)
            {
                Tbl_Student cat = new Tbl_Student();
                cat.SerialID         = item.SerialID;
                cat.StudentID        = item.StudentID;
                cat.FirstName        = item.FirstName;
                cat.LastName         = item.LastName;
                cat.BirthDate        = item.BirthDate;
                cat.DepartmentID     = item.DepartmentID;
                cat.FatherName       = item.FatherName;
                cat.MotherName       = item.MotherName;
                cat.PresentAddress   = item.PresentAddress;
                cat.PermanentAddress = item.PermanentAddress;
                cat.Phone            = item.Phone;
                cat.Email            = item.Email;
                cat.Sex                 = item.Sex;
                cat.Nationality         = item.Nationality;
                cat.Religion            = item.Religion;
                cat.MaritalStatus       = item.MaritalStatus;
                cat.BloodGroup          = item.BloodGroup;
                cat.AdmissionDate       = item.AdmissionDate;
                cat.GraduationDate      = item.GraduationDate;
                cat.PerSemesterRecordID = item.PerSemesterRecordID;
                cat.DocumentsGiven      = item.DocumentsGiven;
                cat.Password            = item.Password;
                cat.Picture             = item.Picture;
                cat.Type                = item.Type;

                cat.links.Add(new Links()
                {
                    HRef = "http://localhost:57254/api/Students", Method = "GET", Rel = "Self"
                });
                cat.links.Add(new Links()
                {
                    HRef = "http://localhost:57254/api/Students/" + cat.StudentID, Method = "GET", Rel = "Specific Resource"
                });
                cat.links.Add(new Links()
                {
                    HRef = "http://localhost:57254/api/Students/" + cat.StudentID, Method = "PUT", Rel = "Resource Edit"
                });
                cat.links.Add(new Links()
                {
                    HRef = "http://localhost:57254/api/Students/" + cat.StudentID, Method = "DELETE", Rel = "Resource Delete"
                });
                cat.links.Add(new Links()
                {
                    HRef = "http://localhost:57254/api/Students", Method = "POST", Rel = "Resource Create"
                });

                categories.Add(cat);
            }
            return(Ok(categories));
        }
        public ActionResult Index(Model_TakeTurn model)
        {
            int ID = Convert.ToInt32(model.Sheft);



            Tbl_TurnTimeSheet _TurnTimeSheet = db.Tbl_TurnTimeSheet.Where(a => a.TTS_ID == ID).SingleOrDefault();
            Tbl_Student       _Student       = db.Tbl_Student.Where(a => a.Student_Code == User.Identity.Name).SingleOrDefault();


            if (_Student.Student_TakeTurn)
            {
                return(RedirectToAction("index", "Portal"));
            }


            if (_TurnTimeSheet.TTS_MaxSize > _TurnTimeSheet.Tbl_TakeTurn.Count())
            {
                Tbl_TakeTurn _TakeTurn = new Tbl_TakeTurn()
                {
                    TT_Guid      = Guid.NewGuid(),
                    TT_StudentID = _Student.Student_ID,
                    TT_TTSID     = _TurnTimeSheet.TTS_ID,
                };

                db.Tbl_TakeTurn.Add(_TakeTurn);

                _Student.Student_TakeTurn = true;

                db.Entry(_Student).State = EntityState.Modified;


                if (Convert.ToBoolean(db.SaveChanges() > 0))
                {
                    TempData["TosterState"]   = "success";
                    TempData["TosterType"]    = TosterType.Maseage;
                    TempData["TosterMassage"] = "عملیات با موفقیت انجام شده";

                    return(RedirectToAction("index", "Portal"));
                }
                else
                {
                    TempData["TosterState"]   = "error";
                    TempData["TosterType"]    = TosterType.Maseage;
                    TempData["TosterMassage"] = "خطا";

                    return(RedirectToAction("Index"));
                }
            }
            else
            {
                TempData["TosterState"]   = "error";
                TempData["TosterType"]    = TosterType.Maseage;
                TempData["TosterMassage"] = "ظرفیت این تایم تکمیل شده است";

                return(RedirectToAction("Index"));
            }
        }
예제 #5
0
        public ActionResult ImportStudentFromExcel(HttpPostedFileBase file)
        {
            if (file != null && file.ContentLength > 0)
            {
                try
                {
                    string path = Path.Combine(Server.MapPath("~/Images"), Path.GetFileName(file.FileName));
                    file.SaveAs(path);
                }
                catch
                {
                    TempData["TosterState"]   = "error";
                    TempData["TosterType"]    = TosterType.Maseage;
                    TempData["TosterMassage"] = "خطا";
                    return(View());
                }
            }
            else
            {
                ViewBag.Message = "You have not specified a file.";
            }

            Microsoft_Excel excel = new Microsoft_Excel(@"C:\2.xlsx");

            excel.Open(1);
            int row_count = excel.Get_RowCount();

            string[,] ex = excel.Get_Range(1, 1, row_count, 2);
            excel.Close();

            for (int i = 0; i < row_count; i++)
            {
                Tbl_Student _Student = new Tbl_Student()
                {
                    Student_Code         = ex[i, 0],
                    Student_NationalCode = ex[i, 1],
                    Student_Guid         = Guid.NewGuid()
                };

                db.Tbl_Student.Add(_Student);
            }


            if (Convert.ToBoolean(db.SaveChanges() > 0))
            {
                TempData["TosterState"]   = "success";
                TempData["TosterType"]    = TosterType.Maseage;
                TempData["TosterMassage"] = "ثبت نام با موفقیت انجام شده";
                return(View());
            }
            else
            {
                TempData["TosterState"]   = "error";
                TempData["TosterType"]    = TosterType.Maseage;
                TempData["TosterMassage"] = "خطا";
                return(View());
            }
        }
예제 #6
0
        public ActionResult Index(Model_StudentInfo model)
        {
            Tbl_Student _Student = db.Tbl_Student.Where(a => a.Student_Code == User.Identity.Name).SingleOrDefault();

            if (_Student.Student_SIID != null || _Student.Student_Info)
            {
                return(RedirectToAction("ShowForm", "PortalForms", new { ID = "c78afdf3-a647-4e54-95e8-94869576b7e5" }));
            }

            Tbl_StudentInfo _info = new Tbl_StudentInfo()
            {
                SI_Name             = model.Name,
                SI_Family           = model.Family,
                SI_Phone            = model.Phone,
                SI_Mobile           = model.Mobile,
                SI_Email            = model.Email,
                SI_BirthdayLocation = model.BirthLocation,
                SI_BeforeUniversity = model.BeforeUniversity,
                SI_Guid             = Guid.NewGuid(),
                SI_InsuranceCodeID  = Convert.ToInt32(model.Insurance),
                SI_BloodCodeID      = Convert.ToInt32(model.Blood),
                SI_GenderCodeID     = Convert.ToInt32(model.Gender),
                SI_NationalCodeID   = Convert.ToInt32(model.National),
                SI_HomeTypeCodeID   = Convert.ToInt32(model.HomeType),
                SI_MarriageCodeID   = Convert.ToInt32(model.Marriage),
                SI_BranchID         = Convert.ToInt32(model.Branch),
                SI_BirthYearCodeID  = Convert.ToInt32(model.BirthYear),
            };

            db.Tbl_StudentInfo.Add(_info);


            _Student.Tbl_StudentInfo = _info;
            _Student.Student_Info    = true;

            db.Entry(_Student).State = EntityState.Modified;

            if (Convert.ToBoolean(db.SaveChanges() > 0))
            {
                TempData["TosterState"]   = "success";
                TempData["TosterType"]    = TosterType.Maseage;
                TempData["TosterMassage"] = "عملیات با موفقیت انجام شده";

                return(RedirectToAction("ShowForm", "PortalForms", new { ID = "c78afdf3-a647-4e54-95e8-94869576b7e5" }));
            }
            else
            {
                TempData["TosterState"]   = "error";
                TempData["TosterType"]    = TosterType.Maseage;
                TempData["TosterMassage"] = "خطا";

                return(RedirectToAction("Index"));
            }
        }
예제 #7
0
        public void Tbl_Student_CompareTwoAsserts_AreEqual()
        {
            var actual = new Tbl_Student {
                S_ID = 1, S_UserName = "******", S_Password = "******", S_FirstName = "abc", S_LastName = "lmn", S_EmailID = "*****@*****.**", S_Age = 22
            };

            Assert.AreEqual(1, actual.S_ID);
            Assert.AreEqual("abc", actual.S_UserName);
            Assert.AreEqual("xyz", actual.S_Password);
            Assert.AreEqual("abc", actual.S_FirstName);
            Assert.AreEqual("lmn", actual.S_LastName);
            Assert.AreEqual("*****@*****.**", actual.S_EmailID);
            Assert.AreEqual(22, actual.S_Age);
        }
예제 #8
0
        public ActionResult slogin(Tbl_Student s)
        {
            Tbl_Student std = db.Tbl_Student.Where(x => x.S_UserName == s.S_UserName && x.S_Password == s.S_Password).SingleOrDefault();

            if (std == null)
            {
                ViewBag.msg = "Invalid Username or Password";
            }
            else
            {
                Session["S_ID"] = std.S_ID;
                return(RedirectToAction("StudentExam"));
            }
            return(View());
        }
예제 #9
0
        public ActionResult Login(Tbl_Student student)
        {
            var log = db.Tbl_Student.Where(n => n.SuserName == student.SuserName &&
                                           n.Spassword == student.Spassword).FirstOrDefault();

            if (log != null)
            {
                Session["id"]   = log.SID;
                Session["name"] = log.SuserName.ToString();
                return(RedirectToAction("Index"));
            }
            else
            {
                ModelState.AddModelError("", "User Name or Password is wrong");
            }
            return(View());
        }
예제 #10
0
 public ActionResult Registation(Tbl_Student student)
 {
     if (ModelState.IsValid)
     {
         if (db.Tbl_Student.Any(x => x.Stid == student.Stid || x.SuserName == student.SuserName))
         {
             ViewBag.show = " Student already exist";
             RedirectToAction("Registation", "Student");
         }
         else
         {
             db.Tbl_Student.Add(student);
             db.SaveChanges();
             ModelState.Clear();
             ViewBag.show2 = student.Sname + "  Successfully Add";
         }
     }
     return(View());
 }
예제 #11
0
        public ActionResult Create(Model_StudentCreate model)
        {
            if (ModelState.IsValid)
            {
                if (db.Tbl_Student.Where(x => x.Student_Code == model.Student_Code).Any())
                {
                    TempData["TosterState"]   = "info";
                    TempData["TosterType"]    = TosterType.Maseage;
                    TempData["TosterMassage"] = "اطلاعات دانشجوی مورد نظر قبلا در سامانه ثبت شده است.";

                    return(RedirectToAction("Index"));
                }

                Tbl_Student Student = new Tbl_Student()
                {
                    Student_Guid         = Guid.NewGuid(),
                    Student_Code         = model.Student_Code,
                    Student_NationalCode = model.Student_NationalCode
                };

                db.Tbl_Student.Add(Student);

                if (Convert.ToBoolean(db.SaveChanges() > 0))
                {
                    TempData["TosterState"]   = "success";
                    TempData["TosterType"]    = TosterType.Maseage;
                    TempData["TosterMassage"] = "ثبت شد";

                    return(RedirectToAction("Index"));
                }
                else
                {
                    TempData["TosterState"]   = "error";
                    TempData["TosterType"]    = TosterType.Maseage;
                    TempData["TosterMassage"] = "ثبت نشد";

                    return(RedirectToAction("Index"));
                }
            }

            return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
        }
예제 #12
0
        public IHttpActionResult Post([FromBody] Tbl_PreStudent pre)
        {
            var item = context.Tbl_PreStudent.Where(x => x.StudentID == pre.StudentID).FirstOrDefault();

            Tbl_Student cat = new Tbl_Student();

            cat.StudentID        = item.StudentID;
            cat.FirstName        = item.FirstName;
            cat.LastName         = item.LastName;
            cat.BirthDate        = item.BirthDate;
            cat.DepartmentID     = item.DepartmentID;
            cat.FatherName       = item.FatherName;
            cat.MotherName       = item.MotherName;
            cat.PresentAddress   = item.PresentAddress;
            cat.PermanentAddress = item.PermanentAddress;
            cat.Phone            = item.Phone;
            cat.Email            = item.Email;
            cat.Sex                 = item.Sex;
            cat.Nationality         = item.Nationality;
            cat.Religion            = item.Religion;
            cat.MaritalStatus       = item.MaritalStatus;
            cat.BloodGroup          = item.BloodGroup;
            cat.AdmissionDate       = item.AdmissionDate;
            cat.GraduationDate      = item.GraduationDate;
            cat.PerSemesterRecordID = item.PerSemesterRecordID;
            cat.DocumentsGiven      = item.DocumentsGiven;
            cat.Password            = item.Password;
            cat.Picture             = item.Picture;
            cat.Type                = item.Type;
            Tbl_Accounts1 ac = new Tbl_Accounts1();

            ac.UserID   = pre.StudentID;
            ac.Password = item.Password;
            ac.Type     = item.Type;

            context.Tbl_Student.Add(cat);
            context.Tbl_Accounts1.Add(ac);
            context.Tbl_PreStudent.Remove(item);
            context.SaveChanges();
            return(Created(Url.Link("GetStudentById", new { id = cat.StudentID }), cat));
        }
예제 #13
0
        public ActionResult ConfirmStudent(int id, Tbl_Student tbl, Tbl_PreStudent tbl1, Tbl_Accounts1 tbl2)
        {
            Tbl_PreStudent k = _unitOfWork.GetRepositoryInstance <Tbl_PreStudent>().GetAllRecordsIQueryable().Where(x => x.ConfrimID == id).FirstOrDefault();

            tbl.StudentID        = k.StudentID;
            tbl.FatherName       = k.FatherName;
            tbl.FirstName        = k.FirstName;
            tbl.LastName         = k.LastName;
            tbl.MotherName       = k.MotherName;
            tbl.GraduationDate   = k.GraduationDate;
            tbl.MaritalStatus    = k.MaritalStatus;
            tbl.Nationality      = k.Nationality;
            tbl.Password         = k.Password;
            tbl.PresentAddress   = k.PresentAddress;
            tbl.PermanentAddress = k.PermanentAddress;
            tbl.Phone            = k.Phone;
            tbl.Picture          = k.Picture;
            tbl.Religion         = k.Religion;
            tbl.Sex                 = k.Sex;
            tbl.Email               = k.Email;
            tbl.DocumentsGiven      = k.DocumentsGiven;
            tbl.DepartmentID        = k.DepartmentID;
            tbl.BloodGroup          = k.BloodGroup;
            tbl.BirthDate           = k.BirthDate;
            tbl.Type                = k.Type;
            tbl.AdmissionDate       = k.AdmissionDate;
            tbl.PerSemesterRecordID = k.PerSemesterRecordID;
            _unitOfWork.GetRepositoryInstance <Tbl_Student>().Add(tbl);
            _unitOfWork.GetRepositoryInstance <Tbl_PreStudent>().Remove(k);
            tbl2.Status   = "Active";
            tbl2.Password = tbl.Password;
            tbl2.Type     = tbl.Type;
            tbl2.UserID   = tbl.StudentID;
            _unitOfWork.GetRepositoryInstance <Tbl_Accounts1>().Add(tbl2);


            return(RedirectToAction("StudentRegistrationConfirm"));
        }
예제 #14
0
        public IHttpActionResult Put([FromUri] string id, [FromBody] Tbl_Student item)
        {
            var cat = context.Tbl_Student.Where(p => p.StudentID == id).FirstOrDefault();

            if (cat == null)
            {
                return(StatusCode(HttpStatusCode.NoContent));
            }
            else
            {
                cat.SerialID         = item.SerialID;
                cat.StudentID        = item.StudentID;
                cat.FirstName        = item.FirstName;
                cat.LastName         = item.LastName;
                cat.BirthDate        = item.BirthDate;
                cat.DepartmentID     = item.DepartmentID;
                cat.FatherName       = item.FatherName;
                cat.MotherName       = item.MotherName;
                cat.PresentAddress   = item.PresentAddress;
                cat.PermanentAddress = item.PermanentAddress;
                cat.Phone            = item.Phone;
                cat.Email            = item.Email;
                cat.Sex                 = item.Sex;
                cat.Nationality         = item.Nationality;
                cat.Religion            = item.Religion;
                cat.MaritalStatus       = item.MaritalStatus;
                cat.BloodGroup          = item.BloodGroup;
                cat.AdmissionDate       = item.AdmissionDate;
                cat.GraduationDate      = item.GraduationDate;
                cat.PerSemesterRecordID = item.PerSemesterRecordID;
                cat.DocumentsGiven      = item.DocumentsGiven;
                cat.Password            = item.Password;
                cat.Picture             = item.Picture;
                cat.Type                = item.Type;
                return(Ok(item));
            }
        }