public void LoadTest() { StudentList students = new StudentList(); students.Load(); Assert.AreEqual(9, students.Count); }
private void StudentLogin(WSDESubVoterSelectRequest response) { if (response.SubVoterResult.Equals("login") && StudentList.Any(k => k.StudentNumber == response.SubVoterNumber)) { StudentList.First(k => k.StudentNumber == response.SubVoterNumber).IsLogin = true; } }
// GET: Student public ActionResult Index() { StudentList students = new StudentList(); students.Load(); return(View(students)); }
public void OnGet() { var student = new StudentList(); Message = "Hello, I'm here too!"; studentList = student.CreateStudentList(); }
private static void AddStudent(ref StudentList studentList) { Student newStudent = new Student("New"); Console.Write("\nEnter Student Name : "); newStudent.Name = Console.ReadLine(); do { Console.Write("\nEnter English Marks (Out Of 100) : "); while (!Int32.TryParse(Console.ReadLine(), out newStudent.Marks[0, 0])) { } } while (newStudent.EnglishMarks < 0 || newStudent.EnglishMarks > 100); do { Console.Write("\nEnter Math Marks (Out Of 100) : "); while (!Int32.TryParse(Console.ReadLine(), out newStudent.Marks[1, 0])) { } } while (newStudent.MathMarks < 0 || newStudent.MathMarks > 100); do { Console.Write("\nEnter Computer Marks (Out Of 100) : "); while (!Int32.TryParse(Console.ReadLine(), out newStudent.Marks[2, 0])) { } } while (newStudent.ComputerMarks < 0 || newStudent.ComputerMarks > 100); Console.WriteLine("****************************\n"); studentList.AddStudent(newStudent); }
private void _F_AddStudent() { var sInstance = ServiceLocator.Current.GetInstance <StudentModifyViewModel>(); sInstance.studentInfo = new StudentInfo(); sInstance.classInfo = Classes.FirstOrDefault(); if (sInstance.classInfo == null) { return; } sInstance.Title = "添加学生信息"; StudentInfoWindow studentInfoWindow = new StudentInfoWindow(); studentInfoWindow.ShowDialog(); if (studentInfoWindow.DialogResult == true) { var target = sInstance.studentInfo; target.Age = DateTime.Now.Year - target.DateOfBirth.Year; _StudentInfoDal.Insert(target); _StudentInfoDal.Save(); _RelationShipDal.Insert(new Student_Class_Relation() { StudentId = sInstance.studentInfo.ID, ClassId = sInstance.classInfo.ID }); _RelationShipDal.Save(); StudentList.Add(new StudentInfoViewModel(target)); } }
public override Task <StudentList> RetrieveAllStudents(Empty request, ServerCallContext context) { _logger.LogInformation("Retrieving all students"); StudentList list = new StudentList(); try { List <StudentModel> studentList = new List <StudentModel>(); var students = _context.Students.ToList(); foreach (var c in students) { studentList.Add(new StudentModel() { StudentId = c.StudentId, FirstName = c.FirstName, LastName = c.LastName, School = c.School, }); } list.Items.AddRange(studentList); } catch (Exception ex) { _logger.LogInformation(ex.ToString()); } return(Task.FromResult(list)); }
protected void StudentList_SelectedIndexChanged(object sender, EventArgs e) { Person person = (Person)Session["personDetail"]; int rowindex = StudentList.SelectedRow.RowIndex; string id = AssessmentQuestion.SelectedValue; string email = (String)StudentList.DataKeys[rowindex].Value; string databaseConnectUpdate = ConfigurationManager.ConnectionStrings["AssignmentEntities"].ConnectionString.ToString(); SqlConnection conUpdate = new SqlConnection(databaseConnectUpdate); conUpdate.Open(); string CompletionValue = "INCOMPLETE"; string AssignmentValue = "ASSIGNED"; string insertQuery = "insert into MCQAssessmentList" + "(Email,MCQAssessmentID,Completion,Assignment) values (@Email,@MCQAssessmentID,@Completion,@Assignment);"; SqlCommand InsertComm = new SqlCommand(insertQuery, conUpdate); InsertComm.Parameters.AddWithValue("@Email", email); InsertComm.Parameters.AddWithValue("@MCQAssessmentID", "" + id); InsertComm.Parameters.AddWithValue("@Completion", CompletionValue); InsertComm.Parameters.AddWithValue("@Assignment", AssignmentValue); try { InsertComm.ExecuteNonQuery(); conUpdate.Close(); TypeOfQuestion.SelectedValue = "MCQ"; AssessmentQuestion.SelectedValue = id; StudentList.DataBind(); ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('You Had Assigned The Assessment To The Student!');", true); } catch (System.Data.SqlClient.SqlException ex) { ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('The student has been assigned!');", true); } }
/// <summary> /// Take the data list passed in, and convert each to a new StudentDisplayViewModel item and add that to the StudentList /// </summary> /// <param name="dataList"></param> public AdminReportIndexViewModel(List <StudentModel> dataList) { foreach (var item in dataList) { StudentList.Add(new StudentDisplayViewModel(item)); } }
protected override void Delete() { if (CurrentStudent != null) { try { var student = context.Students.Where(p => p.StudentId == CurrentStudent.StudentId).SingleOrDefault(); // Помечаем объект как удаленный student.SoftDeleted = true; // Определяем, есть ли у удаляемого студента незавершенные размещения var accomodation = context.Accomodations.Where(p => p.Student.StudentId == CurrentStudent.StudentId && p.DateEnd == null).SingleOrDefault(); if (accomodation != null) { // Завершаем размещение accomodation.DateEnd = DateTime.Now; } StudentList.Remove(CurrentStudent); context.SaveChanges(); ErrorMessage = string.Empty; } catch (DbUpdateException e) { ErrorMessage = "Невозможно выполнить операцию!"; #if DEBUG ErrorMessage = e.Message; #endif } } else { ErrorMessage = "Не выбран объект для удаления."; } }
static void Main(string[] args) { do { int n = Parser.ReadInt(1, 100, "Введите число студентов: "); StudentList studentList = null; bool f = false; while (!f) { try { int probability = rnd.Next(-50, 150 + 1); studentList = new StudentList(n, probability); f = true; } catch (Exception e) { // Если Exception, то попробуем сгенерировать опять // Console.WriteLine(e.Message); // continue; } } studentList.PrintAllStudents(); Console.WriteLine(); Console.Write("Хороший студент с наименьшим средним баллом: "); studentList.PrintWorstGoodStudent(); Console.WriteLine(); studentList.PrintStudentsCourses(); Console.WriteLine("Для выхода нажмите ESC"); } while (Console.ReadKey(true).Key != ConsoleKey.Escape); Console.ReadKey(); }
protected void Page_Load(object sender, EventArgs e) { if (Session["User"] != null && Session["Account"].ToString() == "Student") { /* * check if the user session exist and Account session value is student */ string stId = Session["User"].ToString(); // get the user id from the session user Student student = new Student(stId); // declare and instantiate new student object StudentList students = new StudentList(); //declare and instantiate new studentList object students.Populate(student); // Populate the student object name.Text = student.FirstName + " " + student.LastName; // assign the first and last name to the name lable } else if (Session["User"] != null && Session["Account"].ToString() != "Student") { /* * else if the user session exist but the account session value is not student show error message */ Response.Write("Error You are not allowed to be here"); Response.End(); } else { /* * else show error message */ Response.Write("Error please log in before trying to Access this page..!"); Response.End(); } }
async Task ExecuteLoadStudentsCommand() { if (IsBusy) { return; } IsBusy = true; try { StudentList.Clear(); List <Student> students = await App.StudentDB.GetItemsAsync(); foreach (Student student in students) { StudentList.Add(student); } } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
// GET: Studentt public ActionResult Index() { StudentList strStu = new StudentList(); List <StudentManager> obj = strStu.getStudents(string.Empty); return(View()); }
public IActionResult StudentView(StudentList studentList, int id) { var students = studentList.setList(); ViewBag.AccessLevel = id; return(View(students)); }
// GET: ProgDec/Edit/5 public ActionResult Edit(int id) { ProgDecProgramsStudents pps = new ProgDecProgramsStudents(); BL.ProgDec progdec = new BL.ProgDec(); progdec.Id = id; progdec.LoadById(); pps.ProgDec = progdec; ProgramList programs = new ProgramList(); programs.Load(); pps.Programs = programs; StudentList students = new StudentList(); students.Load(); pps.Students = students; // Load all pps.Advisors = new AdvisorList(); pps.Advisors.Load(); // Deal with the existing advisors IEnumerable <int> existingAdvisorsIds = new List <int>(); // Select only the Ids existingAdvisorsIds = pps.ProgDec.Advisors.Select(a => a.Id); pps.AdvisorIds = existingAdvisorsIds; Session["advisorids"] = existingAdvisorsIds; return(View(pps)); }
public override Task <StudentList> GetAllStudents(Empty request, ServerCallContext context) { var result = new StudentList(); try { using (MYMA.Students.DAL.StudentDbContext dbContext = new MYMA.Students.DAL.StudentDbContext()) { result.Students.AddRange( dbContext.Students.ToList() .Select(y => new Student() { AdmisstionDate = Google.Protobuf.WellKnownTypes.Timestamp.FromDateTime(y.AdmisstionDate.ToUniversalTime()), DateofBirth = Google.Protobuf.WellKnownTypes.Timestamp.FromDateTime(y.DateofBirth.ToUniversalTime()), FirstName = y.FirstName, LastName = y.LastName, MiddleName = y.MiddleName, Id = y.Id, MobileNumber = y.MobileNumber, UrduName = y.UrduName })); } } catch (Exception e) { var err = e.ToString(); } return(Task.FromResult(result)); }
public void Save(string fileName) { using (StreamWriter fileStream = new StreamWriter(fileName, false, System.Text.Encoding.UTF8)) { fileStream.WriteLine("CPF"); fileStream.WriteLine(StipendBox.Text); fileStream.WriteLine(Start_Period.ToString()); fileStream.WriteLine(Finish_Period.ToString()); string subjectString = ""; SubjectsList.ForEach(subj => { subjectString += (subj.ToString() + " "); }); fileStream.WriteLine(subjectString); StudentList.ForEach(stud => { fileStream.Write(stud.IdStudent.ToString() + " - "); string assessmentString = ""; foreach (KeyValuePair <int, int> entry in stud.AssessmentsList) { assessmentString += (entry.Key.ToString() + ":" + entry.Value.ToString() + " "); } fileStream.WriteLine(assessmentString); }); } }
public StudentList ShowData(string id) { // List<StudentList> s = new List<StudentList>(); StudentList s = new StudentList(); SqlConnection con = new SqlConnection("Data Source=ALAUDDIN\\SQLEXPRESS;Initial Catalog=dbase;Integrated Security=True"); SqlCommand cmd = new SqlCommand("Select id,name,address,section,marks from StudentDetail where id=@id", con); cmd.Parameters.AddWithValue("@id", id); SqlDataReader dr; con.Open(); dr = cmd.ExecuteReader(); if (dr.Read()) { //StudentList stud = new StudentList(); s.Id = dr.GetValue(0).ToString(); s.Name = dr.GetValue(1).ToString(); s.Address = dr.GetValue(2).ToString(); s.Section = dr.GetValue(3).ToString(); s.Marks = int.Parse(dr.GetValue(4).ToString()); // s.Add(stud); } con.Close(); return(s); }
public async Task OnGetAsync() { //get list of Students StudentList = await _db.Students.AsNoTracking().ToListAsync(); ProgrammesList = await _db.Programmes.AsNoTracking().ToListAsync(); if (!String.IsNullOrEmpty(ProgrammeSearchString)) { ProgrammesFound = ProgrammesList.Where(s => s.ProgrammeName.Contains(ProgrammeSearchString)) .Select(s => s) .ToList(); } if ((ProgrammesFound != null) && (ProgrammesFound.Count() != 0)) { foreach (var programme in ProgrammesFound) { var students = StudentList.Where(s => s.ProgrammeID == programme.ProgrammeID) .Select(s => s); foreach (var student in students) { SelectedStudentList.Add(student); } } } else { SelectedStudentList = StudentList.ToList(); } }
private void inputConfigToolStripMenuItem_Click(object sender, EventArgs e) { ConfigFile temp = new ConfigFile(); openFileDialog1.Filter = "Config File(*.cfgdata)|*.cfgdata"; openFileDialog1.FilterIndex = 1; if (openFileDialog1.ShowDialog() == DialogResult.OK) { temp.LoadFromFile(openFileDialog1.FileName); List <Student> tempStudents = new List <Student>(); studentListTable.Items.Clear(); foreach (string i in temp.students) { Student newStudent = new Student(i); tempStudents.Add(newStudent); studentListTable.Items.Add(newStudent); } students = new StudentList(tempStudents); seats = new SeatList(0, Array.Empty <int>()); seatTable.RowCount = 1; seatTable.ColumnCount = 1; CleanTableWithFrontSign(); for (int k = 0; k < temp.row; k++) { AddNewRow(k + 1, temp.col[k]); } } }
/// <summary> /// Gets a list of Students /// </summary> /// <returns>List of Students</returns> public static StudentList GetItem() { StudentList myStudentList = null; using (SqlConnection myConnection = new SqlConnection(AppSettings.ConnectionString)) { SqlCommand myCommand = new SqlCommand("spSelectStudentList", myConnection); myCommand.CommandType = CommandType.StoredProcedure; myConnection.Open(); using (SqlDataReader myDataReader = myCommand.ExecuteReader()) { if (myDataReader.HasRows) { myStudentList = new StudentList(); while (myDataReader.Read()) { myStudentList.Add(FillRecord(myDataReader)); } } myDataReader.Close(); } myConnection.Close(); } return(myStudentList); }
// Add Student duymesine basildiqda bash verenler private void btnAddStudent_Click(object sender, EventArgs e) { // Add student forumundaki inputlara daxil edilenlerin yerlerine oyulmasi string firstname = txtFirstname.Text; string lastname = txtLastname.Text; string email = txtEmail.Text; // secilmish qrupun ID nomresinin groupID-ye verilmesi string groupId = ((GroupCombo)cmbGroups.SelectedItem).Value; // Group tipinden deyishen yaradiriq // ve Qrup siyahisinin ID-lerinden secilmishini deyishene veririk Group selectedGroup = GroupList.GetGroupById(groupId); if (selectedGroup == null) // eger secilmish qrup yoxdursa { MessageBox.Show("Group doesn't exist"); return; } // Studentlerin siyahisina yeni studentin elave elave edilmesi StudentList.Add(new Student { Firstname = firstname, Lastname = lastname, Email = email, Group = selectedGroup }); //txtFirstname.Text = ""; //txtLastname.Text = ""; //txtEmail.Text = ""; }
private void FillDataGridView() { dgvProgress.Rows.Clear(); StudentList studentList = new StudentList(); studentList.Fill(); foreach (var item in studentList.Value) { var row = new string[dgvProgress.ColumnCount]; row[0] = item.Surname; row[1] = item.Name; row[2] = item.Patronymic; row[dgvProgress.ColumnCount - 1] = item.StudentId.ToString(); foreach (var exam in _examList.Value) { if (exam.StudentExam == item && exam.SubjectExam == _subjectList.Value[cmbSubject.SelectedIndex]) { row[exam.Number + 2] = exam.Mark.ToString(); } } dgvProgress.Rows.Add(row); } }
// Конструктор представления модели public StudentListViewModel(StudentHostelContext context) : base(context) { GetData(); GetStudentsList(); if (StudentList != null) { CurrentStudent = null; } else if (StudentList.Count == 0) { CurrentStudent = null; } else { CurrentStudent = StudentList.First(); } // Инициализация команд AddCommand = new Command(Add, () => { return(!(IsAdding || IsEditing) && context != null); }); EditCommand = new Command(Edit, () => { return(!(IsAdding || IsEditing) && context != null); }); SaveCommand = new Command(SaveChanges, () => { return((IsAdding || IsEditing) && context != null); }); DeleteCommand = new Command(Delete, () => { return(!(IsAdding && !IsEditing) && context != null); }); CancelCommand = new Command(DiscardChanges, () => { return((IsAdding || IsEditing) && context != null); }); UpdateCommand = new Command(Update, () => { return(!(IsAdding || IsEditing) && context != null); }); FilterCommand = new Command(Filter, () => { return(IsBrowsing); }); CancelFilterCommand = new Command(CancelFilter, () => { return(IsBrowsing); }); }
private void SaveStudent() { StudentModel stu = new StudentModel(); stu = CurrentStudent; StudentList.Add(stu); }
private async void MenuItemDelete_Clicked(object sender, EventArgs e) { var menuItem = sender as MenuItem; var person = menuItem.CommandParameter as Person; if (await DisplayAlert("Uwaga", "Czy jesteś pewny, że chcesz skasować osobę: " + person.Name + " " + person.Surname, "Kasuj", "Anuluj")) { if (!String.IsNullOrEmpty(person.Photo)) { var file = await FileSystem.Current.GetFileFromPathAsync(person.Photo); if (file != null) { await file.DeleteAsync(); } } await _connection.DeleteAsync(person); PersonsList.Remove(person); StudentList.ItemsSource = PersonsList; if (!String.IsNullOrWhiteSpace(searchbar.Text)) { searchbar.Text = ""; } StudentList.EndRefresh(); } }
static void Main() { #region TASK_1 Demonstration Console.WriteLine("Таблица функции a*x^2:"); SimpleFuncTable.Table(SimpleFuncTable.PowConst, -2, 1, 2); Console.WriteLine("Таблица функции a*Sin(x):"); SimpleFuncTable.Table(SimpleFuncTable.Sinusoide, -2, 5, 2); #endregion Console.WriteLine(); #region TASK_3 Demonstration foreach (StudentList student in StudentList.Age_CourseSort(StudentList.FileReader())) { Console.WriteLine($"{student.GetLastname} {student.GetName} {student.GetUniversity} {student.GetAge} {student.GetCourse}"); } Console.WriteLine(); StudentList.StudentCoursesCounter(StudentList.FileReader()); Console.WriteLine(); List <StudentList> st = StudentList.FileReader(); StudentList.Age_CourseSort(st); Dictionary <int, int> tr = StudentList.StudentsInfo(st); foreach (int key in tr.Keys.ToList()) { Console.WriteLine($"Студентов учащихся на {key} курсе: {tr[key]} человек."); } #endregion }
private void BindGrid() { string constr = ConfigurationManager.ConnectionStrings["CS414_FasTestConnectionString"].ConnectionString; using (SqlConnection con = new SqlConnection(constr)) { HttpCookie SelectedClassID = new HttpCookie("SelectedClassID"); // Convert.ToInt32(Request.Cookies["SelectedClassID"].Value) using (SqlCommand cmd = new SqlCommand(@"SELECT DISTINCT ClassStudent.StudentID, CONCAT(FasTestUser.FirstName , ' ' , FasTestUser.LastName) AS NAME, ClassStudent.IsEnrolled FROM ClassStudent right join FasTestUser on FasTestUser.IDNumber = ClassStudent.StudentID where (FasTestUser.CredentialLevel = 3) and (ClassStudent.ClassID = " + Convert.ToInt32(Request.Cookies["SelectedClassID"].Value) + ")")) { using (SqlDataAdapter sda = new SqlDataAdapter()) { cmd.Connection = con; sda.SelectCommand = cmd; using (DataTable dt = new DataTable()) { sda.Fill(dt); StudentList.DataSource = dt; StudentList.DataBind(); } } } } }
static void StudentListTest() { //Testing student list functions Console.Write("\nTesting StudentList\n\n"); // create a list to play with StudentList sList = new StudentList(); // create some students Student frodo = new Student("Frodo", 50); Student bilbo = new Student("Bilbo", 111); Student gandalf = new Student("Gandalf", 500); Student pippen = new Student("Pippen", 30); Student sam = new Student("Samwise", 40); // load the list sList.InsertHead(frodo); sList.InsertTail(bilbo); sList.InsertHead(gandalf); sList.InsertTail(pippen); sList.InsertHead(sam); // check empty Console.Write("Checking IsEmpty, should not be empty, is: " + (sList.IsEmpty() ? "empty" : "not empty") + "\n"); // check find Console.Write("Checking find with Sam, should find: " + (sList.FindKey("Samwise") ? "found" : "not found") + "\n"); Console.Write("Checking find with Merry, should not find: " + (sList.FindKey("Merry") ? "found" : "not found") + "\n"); // check DeleteKey Console.Write("Checking DeleteKey with Pippen, should find: " + (sList.DeleteKey("Pippen") ? "found" : "not found") + "\n"); Console.Write("Checking DeleteKey with Merry, should not find: " + (sList.DeleteKey("Merry") ? "found" : "not found") + "\n"); // check DeleteHead Console.Write("Checking delete head, should show in order: Samwise Gandalf Frodo Bilbo\n"); Console.Write("Actually showed: "); while (true) { try { Student temp = sList.DeleteHead(); Console.Write(temp.Name + " "); } catch (InvalidOperationException err) { Console.Write("\nCaught error: " + err.Message + "\n"); break; } catch (Exception) { Console.Write("\nCaught something other than underflow\n"); break; } } // checkikng empty again Console.Write("Checking IsEmpty again, should now be empty, is: " + (sList.IsEmpty() ? "empty" : "not empty") + "\n"); }
/// <summary> /// Gets a list of Students /// </summary> /// <returns>List of Students</returns> public static StudentList GetItem() { StudentList myStudentList = null; using (SqlConnection myConnection = new SqlConnection(AppSettings.ConnectionString)) { SqlCommand myCommand = new SqlCommand("spSelectStudentList", myConnection); myCommand.CommandType = CommandType.StoredProcedure; myConnection.Open(); using (SqlDataReader myDataReader = myCommand.ExecuteReader()) { if (myDataReader.HasRows) { myStudentList = new StudentList(); while (myDataReader.Read()) { myStudentList.Add(FillRecord(myDataReader)); } } myDataReader.Close(); } myConnection.Close(); } return myStudentList; }
internal static StudentList GetStudentList() { if (Students == null) { Students = new StudentList(); Students.Load(); } return Students; }
public List<StudentList> GetStudentIdList() { List<StudentList> st = new List<StudentList>(); cmd = new SqlCommand("select id from StudentDetail", con); con.Open(); dr = cmd.ExecuteReader(); while (dr.Read()) { StudentList stt = new StudentList(); stt.Id = dr.GetValue(0).ToString(); st.Add(stt); } con.Close(); return st; }