private StudentDetail ConvertToStudentDetail(StudentDb studentDb) { DateTime?lastSignIn = null; if (studentDb.User.SignIns != null && studentDb.User.SignIns.Any()) { lastSignIn = studentDb.User.SignIns.Max(t => t.SigninTime); } var sortedSigninHistory = studentDb.User.SignIns.OrderBy(s => s.Id); StudentDetail student = new StudentDetail() { StudentId = studentDb.StudentId, SignUpSource = studentDb.SignUpSource, Notes = studentDb.Notes, Avatar = studentDb.Avatar, School = studentDb.School, Mobile = studentDb.Mobile, City = studentDb.City, Address = studentDb.Address, Title = studentDb.Title, CurrentSigninIp = sortedSigninHistory.Count() > 0 ? sortedSigninHistory.TakeLast(1).FirstOrDefault().SigninIp : string.Empty, LastSigninIp = sortedSigninHistory.Count() > 1 ? sortedSigninHistory.TakeLast(2).FirstOrDefault().SigninIp : string.Empty, NumberOfLogins = studentDb.User.SignIns.Count, }; return(student); }
public async Task <ActionResult <StudentDetail> > PostPaymentDetail(StudentDetail paymentDetail) { _context.StudentDetails.Add(paymentDetail); await _context.SaveChangesAsync(); return(CreatedAtAction("GetPaymentDetail", new { id = paymentDetail.StudentID }, paymentDetail)); }
public string EditStudentDetails(StudentDetail detail) { using (var dbContext = new StudentEntities()) { using (DbContextTransaction transaction = dbContext.Database.BeginTransaction()) { try { var studentDetails = dbContext.StudentDetails.Where(x => x.StudentDetials_ID == detail.StudentDetials_ID).FirstOrDefault(); var student = dbContext.Students.Where(x => x.Student_ID == studentDetails.Student_ID).FirstOrDefault(); var subject = dbContext.Subjects.Where(x => x.SubjectID == studentDetails.Subject_ID).FirstOrDefault(); if (studentDetails != null) { studentDetails.Marks = detail.Marks; studentDetails.Class = detail.Class; student.First_Name = detail.First_Name; student.Last_Name = detail.Last_Name; subject.Subject_Name = detail.Subject_Name; dbContext.Entry(studentDetails).State = EntityState.Modified; dbContext.Entry(student).State = EntityState.Modified; dbContext.Entry(subject).State = EntityState.Modified; dbContext.SaveChanges(); transaction.Commit(); } } catch (Exception ex) { transaction.Rollback(); return(ex.Message); } } } return("success"); }
public bool StudentLogin(StudentDetail objStudentDetail, out int isStudentId) { using (StudentPortalEntities db = new StudentPortalEntities()) { try { var student = (from x in db.StudentDetails where x.Email == objStudentDetail.Email select x).FirstOrDefault(); if (student != null) { if (student.Password == objStudentDetail.Password) { isStudentId = student.Id; return(true); } } isStudentId = 0; return(false); } catch (Exception ex) { isStudentId = 0; return(false); } } }
private void btnSave_Click(object sender, EventArgs e) { if (!LoggedInUser.IsAdmin) { Base.ShowError("Access Denied", "You do not have the required permission"); return; } var item = new StudentDetail() { Id = _id, DepartmentId = (comboDept.SelectedValue.ToString()), Lastname = txtSurname.Text.ToTitleCase(), Firstname = txtFirstname.Text.ToTitleCase(), Othername = txtOthername.Text.ToTitleCase(), Email = txtEmail.Text.ToLower(), MatricNo = txtMatricNo.Text.ToUpper(), PhoneNo = txtPhoneNo.Text, }; var validate = ValidateForm(); if (validate == string.Empty) { AddOrUpdate(item); } else { Base.ShowInfo("Validation Failed", validate); } }
public StudentDetail findStudentByNum(string num) { //查询对应学生信息 var info = from p in db.TrueStudents join b in db.Classrooms on p.Classroomid equals b.Id where p.Num.Equals(num) select new { stu = p, classname = b.Name }; if (info.ToList().Count > 0) { StudentDetail sd = new StudentDetail(); sd.Stu = info.First().stu; sd.Classroomname = info.First().classname; return(sd); } else { return(null); } }
// Hiển thị kết quả đánh giá theo cả lớp học phần public ActionResult ShowResultSurvey(int?id) { if (id == null) { return(RedirectToAction("NotFoundWebsite", "Home", new { area = "SignIn" })); } // Lấy số lượng sinh viên đã đánh giá học phần ViewBag.hasSurvey = SubjectBusinessModel.GetSumStudentDoneSurvey(id); // Lấy ra thông tin chi tiết của sinh viên đầu tiên trong học phần đó StudentDetail student_Detail = StudentDetailBusinessModel.GetFirstStudentDetailBySubject(id); if (student_Detail == null) { return(RedirectToAction("NotFoundWebsite", "Home", new { area = "SignIn" })); } if (ViewBag.hasSurvey == 0) { return(View(student_Detail)); } // Lấy tổng số sinh viên của học phần đó ViewBag.SumStudent = SubjectBusinessModel.GetSumStudentBySubject(id); // Lấy ra điểm trung bình theo cả lớp của các tiêu chí ViewBag.ListPointAver = SubjectBusinessModel.GetListAverage(id); // Lấy ra danh sách các tiêu chí đánh giá ViewBag.NameSurvey = ContentSurveyBusinessModel.GetListContentSurvey(); // Lấy ra tổng số tiêu chí đánh giá ViewBag.CountSurvey = ContentSurveyBusinessModel.GetSumContentSurvey(); return(View(student_Detail)); }
public IActionResult Create(StudentDetail studentDetail) { try { var checkRecordExists = schoolDBContext.StudentDetails.Where( sdetails => sdetails.StudentName == studentDetail.StudentName && sdetails.StudentRollNumber == studentDetail.StudentRollNumber && sdetails.DateOfBirth == studentDetail.DateOfBirth).FirstOrDefault(); if (checkRecordExists != null) { if (checkRecordExists.StudentID > 0) { return(BadRequest()); } } schoolDBContext.StudentDetails.Add(studentDetail); var saveResult = schoolDBContext.SaveChanges(); if (saveResult < 1) { return(BadRequest()); } return(Ok()); } catch (Exception ex) { return(BadRequest()); } }
static void Main(string[] args) { ListOfStudentDetail students = new ListOfStudentDetail(); List <Students> everyStudent = StudentDetail.GetAllStudent(); Console.WriteLine("Current Students List: "); try { foreach (var v in StudentDetail.deserialized) { Console.Write("Name: {0} {1} {2}", v.firstName, v.middleName, v.lastName); Console.Write(" , "); Console.Write("ID: " + v.id + "\n"); Console.WriteLine("======="); } } catch (Exception) { throw; } students.SetupData(); Console.ReadLine(); }
public ActionResult AddStudent(StudentDetail student) { if (ModelState.IsValid) { var msg = string.Format("Please enter a value between 01/01/1996 and 31/12/2000"); DateTime dob = Convert.ToDateTime(student.DateofBirth); DateTime startdate = DateTime.ParseExact("01/01/1996", "dd/MM/yyyy", null); DateTime enddate = DateTime.ParseExact("31/12/2000", "dd/MM/yyyy", null); if ((dob.CompareTo(startdate) >= 0) && (dob.CompareTo(enddate) <= 1)) { db.StudentDetails.Add(student); Fee fees = new Fee() { StudentId = student.StudentId, Amount = student.feesAmount, Balance = student.feesAmount, Branch = student.Branch, Year = student.year, Paid = "NotPaid" }; db.Fees.Add(fees); db.SaveChanges(); return(Content("<html><head><script>alert('Successfully Registered'); window.location.href = '/Student/AddStudent'</script></head></html>")); } else { ModelState.AddModelError("DateofBirth", msg); } } return(View()); }
public int AddDetail(StudentDetail emp) { db.StudentDetail.Add(emp); db.SaveChanges(); return(emp.StudentId); }
private StudentDetail _populateValues(StudentDetail entity, StudentModel model) { if (null == entity) { entity = new StudentDetail(); entity.StudentId = model.StudentId; entity.EmailId = model.EmailId; entity.SchoolBranchId = model.SchoolBranchId; } entity.Address1 = model.Address1; entity.Address2 = model.Address2; entity.City = model.City; entity.Country = model.Country; entity.State = model.State; entity.ClassId = model.ClassId; entity.DateOfBirthh = model.DateOfBirthh; entity.Gender = model.Gender; entity.ParentMobileNo = model.ParentMobileNo; entity.ParentName = model.ParentName; entity.PrimaryTagId = model.PrimaryTagId; entity.SecondaryTagId = model.SecondaryTagId; entity.SectionId = model.SectionId; entity.StudentName = model.StudentName; entity.ZipCode = model.ZipCode; return(entity); }
public async Task <IActionResult> Edit(int id, [Bind("ID,Name,Phone_Number,Birth_Date")] StudentDetail studentDetail) { if (id != studentDetail.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(studentDetail); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StudentDetailExists(studentDetail.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(studentDetail)); }
public ActionResult Edit([Bind(Include = "Studentid,Name,FatherName,Mobile,Email,Gender,DOB,Image,Address,Qualification,CourseType,RollNo,JoiningDate,UserName,Password,date,Status")] StudentDetail studentDetail, HttpPostedFileBase file, Helper Help) { if (ModelState.IsValid) { studentDetail.date = System.DateTime.Now; studentDetail.Image = file != null?Help.uploadfile(file) : img; #region delete file string fullPath = Request.MapPath("~/UploadedFiles/" + img); if (img == studentDetail.Image) { } else { if (System.IO.File.Exists(fullPath)) { System.IO.File.Delete(fullPath); } } #endregion db.Entry(studentDetail).State = EntityState.Modified; db.SaveChanges(); TempData["Success"] = "Updated Successfully"; return(RedirectToAction("Index")); } return(View(studentDetail)); }
public ActionResult Login(StudentDetail model, string returnUrl) { dbcontext db = new dbcontext(); var dataItem = db.StudentDetails.Where(x => x.UserName == model.UserName && x.Password == model.Password).ToList(); if (dataItem != null) { //FormsAuthentication.SetAuthCookie(dataItem.Usename, false); if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/") && !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\")) { return(Redirect(returnUrl)); } else { TempData["Success"] = "Login Successfully"; Session["student"] = dataItem.FirstOrDefault().Studentid; return(RedirectToAction("StudentProfile", "Home")); } } else { ModelState.AddModelError("", "Invalid user/pass"); return(View()); } }
public ActionResult SurveySubject(FormCollection form) { // Lấy tổng số tiêu chí đánh giá ViewBag.Count = db.ContentSurveys.ToList().Count(); // Lấy các tiêu chí đánh giá ViewBag.ContentSurvey = db.ContentSurveys.Select(x => x.Text).ToList(); // Lấy id từ form int k = int.Parse(form["id"]); int stDetailID = int.Parse(form["studentDetailID"]); StudentDetail student_Detail = db.StudentDetails.First(x => x.SubjectID == k); // Kiểm tra đã đánh giá đủ các tiêu chí chưa if (form.Count < db.ContentSurveys.ToList().Count() + 3) { ViewBag.Message2 = "Bạn cần đánh giá đủ các tiêu chí"; return(View(student_Detail)); } int i = 0; foreach (var item in db.ContentSurveys) { // Khởi tạo Survey và gán giá trị cho các thuộc tính Survey survey = new Survey(); survey.StudentDetailID = stDetailID; survey.ContentSurveyID = item.ContentSurveyID; survey.Point = int.Parse(form[i++]); db.Surveys.Add(survey); } // Lấy thông tin chi tiết sinh viên - môn học StudentDetail stDetail = db.StudentDetails.FirstOrDefault(x => x.StudentDetailID == stDetailID); stDetail.NoteSurvey = form["note"].ToString(); db.SaveChanges(); return(RedirectToAction("ShowListSubject")); }
// POST: odata/StudentDetails public IHttpActionResult Post(StudentDetail studentDetail) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.StudentDetails.Add(studentDetail); try { db.SaveChanges(); } catch (DbUpdateException) { if (StudentDetailExists(studentDetail.id)) { return(Conflict()); } else { throw; } } return(Created(studentDetail)); }
public async Task <IHttpActionResult> PostStudentDetail(StudentDetail studentDetail) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.StudentDetails.Add(studentDetail); try { await db.SaveChangesAsync(); } catch (DbUpdateException) { if (StudentDetailExists(studentDetail.Id)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = studentDetail.Id }, studentDetail)); }
public async Task <ActionResult <StudentDetail> > PostStudentDetail(StudentDetail studentDetail) { _context.StudentDetails.Add(studentDetail); await _context.SaveChangesAsync(); return(CreatedAtAction("GetStudentDetail", new { id = studentDetail.SId }, studentDetail)); }
protected void Button1_Click(object sender, EventArgs e) { /*SqlConnection con = (SqlConnection)Application["connection"]; * SqlCommand cmd = (SqlCommand)Application["command"]; * string sql = "select * from Academic "; * cmd.CommandText = sql; * con.Open(); * SqlDataReader dr = cmd.ExecuteReader(); * // Dictionary<float, int> rank = new Dictionary<float, int>; * while(dr.Read()) * { * * }*/ admissionEntities ae = new admissionEntities(); var aca = from c in ae.Academics orderby(c.hsc_marks * 0.6 + c.competitive_exam_marks * 0.4) descending, c.ssc_marks descending select c; int rank = 0; foreach (var x in aca) { rank++; string stdid = x.std_id; StudentDetail s = ae.StudentDetails.Where(s1 => s1.std_id == stdid).FirstOrDefault <StudentDetail>(); s.rank = rank; } ae.SaveChanges(); /*Label1.Visible = true; * Label1.Text = "Rank Successfully Generated";*/ Button1.Enabled = false; Button1.Text = "Rank Successfully Generated"; }
public async Task <IActionResult> PutStudentDetail(int id, StudentDetail studentDetail) { if (id != studentDetail.SId) { return(BadRequest()); } _context.Entry(studentDetail).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StudentDetailExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
// Hiển thị kết quả đánh giá học phần của môn học đó public ActionResult ShowResultSurvey(int?id) { if (id == null) { return(RedirectToAction("NotFoundWebsite", "Home", new { area = "SignIn" })); } // Lấy ra danh sách id của sinh viên - học phần List <int> lis = db.Subjects.FirstOrDefault(x => x.SubjectID == id).StudentDetail.Select(x => x.StudentDetailID).ToList(); // Lấy ra một đối tượng sinh viên - học phần StudentDetail student_Detail = db.StudentDetails.First(x => x.SubjectID == id); // Lấy ra tổng số đánh giá học phần ViewBag.hasSurvey = db.Surveys.Where(x => lis.Any(k => k == x.StudentDetailID)).ToList().Count(); // Lấy ra tổng số sinh viên của một học phần ViewBag.SumStudent = db.Subjects.FirstOrDefault(x => x.SubjectID == id).StudentDetail.ToList().Count(); // Kiểm tra xem đã có sinh viên nào đánh giá chưa if (ViewBag.hasSurvey == 0) { return(View(student_Detail)); } // Lấy ra danh sách điểm trung bình theo cả lớp của các tiêu chí đánh giá ViewBag.ListPointAver = db.Surveys .Where(x => lis.Any(k => k == x.StudentDetailID)) .GroupBy(x => x.ContentSurveyID) .Select(x => x.Average(y => y.Point)).ToList(); // Lấy ra các tiêu chí đánh giá ViewBag.NameSurvey = db.ContentSurveys.Select(x => x.Text).ToList(); // Lấy ra tổng số tiêu chí đánh giá ViewBag.CountSurvey = db.ContentSurveys.ToList().Count(); return(View(student_Detail)); }
private void writeToDB(StudentDetail student) { TargetDB db = new TargetDB("Yuwa", "anly4s85vg.database.windows.net", "Yuwa", "Welcome_1234"); var queryString = string.Format("INSERT INTO StudentDetails(FirstName, LastName, Gender) VALUES ('{0}','{1}','{2}')", student.FirstName, student.LastName, student.Gender); db.ExecuteNonQuery(queryString); }
public string UpdateStudent(StudentDetail student) { using (var context = new BASContext()) { var oldStudent = context.Students.SingleOrDefault(a => a.Id == student.Id && !a.IsDeleted); if (oldStudent == null) { return("Student not found"); } if (context.Students.Any(a => a.MatricNo == student.MatricNo || a.Email == student.Email && !a.IsDeleted && a.Id != student.Id)) { return("Student with this Matric number or Email address exists"); } oldStudent.Email = student.Email; oldStudent.Firstname = student.Firstname; oldStudent.Lastname = student.Lastname; oldStudent.Othername = student.Othername; oldStudent.MatricNo = student.MatricNo; oldStudent.PhoneNo = student.PhoneNo; oldStudent.DepartmentId = student.DepartmentId; if (context.SaveChanges() > 0) { return("Student details updated successfully"); } return("Student details could not be updated"); } }
private bool GetFingerPrints(Bitmap bmp) { try { var fingers = _bioRepo.GetFingers(); foreach (var item in fingers) { FingerBmp = BytesToBitmap((byte[])item.FingerTemplate); StudentId = item.StudentId; DigitaPersonaClass obj = new DigitaPersonaClass(); if (obj.NonUnique(ref FingerBmp, ref bmp)) { studentDetail = _studentRepo.GetStudent(StudentId); return(true); } } return(false); } catch (Exception) { throw; } }
public async Task <IHttpActionResult> PutStudentDetail(int id, StudentDetail studentDetail) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != studentDetail.Id) { return(BadRequest()); } db.Entry(studentDetail).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StudentDetailExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IActionResult Put(int id, [FromBody] StudentDetail emp) { if (ModelState.IsValid) { try { var result = db.UpdateDetail(id, emp); if (result != 1) { return(NotFound()); } return(Ok(result)); } catch (Exception ex) { if (ex.GetType().FullName == "Microsoft.EntityFrameworkCore.DbUpdateConcurrencyException") { return(NotFound()); } return(BadRequest()); } } return(BadRequest()); }
public ActionResult Index(StudentViewModel objStudentViewModel) { StudentMaster objStudentMaster = new StudentMaster() { Name = objStudentViewModel.StudentName, ClassName = objStudentViewModel.ClassName, ExamId = objStudentViewModel.ExamId, RollNumber = objStudentViewModel.RollNumber }; objStudentDBEntities.StudentMasters.Add(objStudentMaster); objStudentDBEntities.SaveChanges(); foreach (var item in objStudentViewModel.ListOfStudentMarks) { StudentDetail objStudentDetail = new StudentDetail() { MarksObtained = item.ObtainedMarks, Percentage = Convert.ToInt32(item.Percentage), ///to check conversion StudentId = objStudentMaster.StudentId, TotalMarks = item.TotalMarks, SubjectId = item.SubjectId }; objStudentDBEntities.StudentDetails.Add(objStudentDetail); objStudentDBEntities.SaveChanges(); } return(Json(new { message = "Data successfully added", status = true }, JsonRequestBehavior.AllowGet)); }
public ActionResult DeleteConfirmed(string id) { StudentDetail studentDetail = db.StudentDetails.Find(id); db.StudentDetails.Remove(studentDetail); db.SaveChanges(); return(RedirectToAction("Index")); }
static void Main(string[] args) { StudentDetail s = new StudentDetail(); ScoreReport c = new ScoreReport(); Console.WriteLine("Student subject: " + c.subject); Console.WriteLine("Student mark: " + c.mark); }
public List<StudentDetail> GetStudentList() { List<StudentDetail> objStudent = new List<StudentDetail>(); ///*Create instance of entity model*/ //NorthwindEntities objentity = new NorthwindEntities(); ///*Getting data from database for user validation*/ //var _objuserdetail = (from data in objentity.Students // select data); //foreach (var item in _objuserdetail) //{ // objStudent.Add(new StudentDetail { Id = item.Id, Name = item.Name, Section = item.Section, Class = item.Class, Address = item.Address }); //} //return objStudent; SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["Connect"].ConnectionString); SqlCommand cmd = null; SqlDataReader dr; try { if (con.State.ToString() == "Open") { con.Close(); } con.Open(); cmd = new SqlCommand("SELECT [ID] FROM [Automation].[dbo].[tbl_UserMaster]", con); cmd.CommandType = CommandType.Text; dr = cmd.ExecuteReader(); //int j = 0; StudentDetail Stu = new StudentDetail(); //List<int> Li; //foreach (var item in dr) //{ // objStudent.Add(new StudentDetail { Id = Convert.ToInt16( item.ToString()) }); //} while (dr.Read()) { //string asdf = dr.GetString(0); objStudent.Add(new StudentDetail { Id = dr.GetInt32(0) }); //Stu.Id = Convert.ToInt16(dr.GetValue(j).ToString()); //Li.Add(Convert.ToInt16(dr.GetValue(j).ToString())); //j += 1; } //_objuserloginmodel.Studentmodel.Add(); } catch (Exception ex) { } return objStudent; }