private void UpdateRecord() { using (new WaitCursor()) { exam oclsexam = new exam(); exam clsexam = new exam(); oclsexam.ExamId = System.Convert.ToInt32((Grid.SelectedCells[0].Column.GetCellContent(Grid.SelectedItem) as TextBlock).Text); oclsexam = examData.Select_Record(oclsexam); if (VerifyData() == true) { SetData(clsexam); Boolean bSucess = new Boolean(); bSucess = examData.Update(oclsexam, clsexam); if (bSucess == true) { GoBack_To_Grid(); } else { MessageBox.Show("Update failed.", "Error"); } } } }
static void Main(string[] args) { exam obj = data; obj.Invoke(12); Console.ReadKey(); }
// // GET: /Exam/Edit/5 public ActionResult Edit(int id) { List <SelectListItem> mystud = new List <SelectListItem>(); exam e = sc.SearchExam(id); foreach (var st in sc.showallstud()) { bool sel = false; if (st.rno == e.rno) { sel = true; } mystud.Add(new SelectListItem { Text = st.sname, Value = st.rno.ToString(), Selected = sel }); } ViewBag.city = mystud; return(View(e)); }
private void GetData() { using (new WaitCursor()) { ClearRecord(); exam clsexam = new exam(); clsexam.ExamId = System.Convert.ToInt32((Grid.SelectedCells[0].Column.GetCellContent(Grid.SelectedItem) as TextBlock).Text); clsexam = examData.Select_Record(clsexam); if ((clsexam != null)) { try { nudExamId.Text = System.Convert.ToInt32(clsexam.ExamId).ToString(); if (clsexam.ExamType is null) { tbExamType.Text = default(string); } else { tbExamType.Text = Convert.ToString(clsexam.ExamType); } } catch { } } } }
public async Task <IActionResult> Edit(int id, [Bind("id,name,subject_id,max_marks,time")] exam exam) { if (id != exam.id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(exam); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!examExists(exam.id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(exam)); }
public ActionResult Delete(int id, FormCollection collection) { exam examsToDelete = _db.exams.Find(id); _db.exams.Remove(examsToDelete); _db.SaveChanges(); return(RedirectToAction("Exams")); }
public static bool Update(exam oldexam, exam newexam) { SqlConnection connection = SchoolData.GetConnection(); string updateStatement = "UPDATE " + " [exam] " + "SET " + " [ExamType] = @NewExamType " + "WHERE " + " [ExamId] = @OldExamId " + " AND ((@OldExamType IS NULL AND [ExamType] IS NULL) OR [ExamType] = @OldExamType) " + ""; SqlCommand updateCommand = new SqlCommand(updateStatement, connection); updateCommand.CommandType = CommandType.Text; if (newexam.ExamType != null) { updateCommand.Parameters.AddWithValue("@NewExamType", newexam.ExamType); } else { updateCommand.Parameters.AddWithValue("@NewExamType", DBNull.Value); } updateCommand.Parameters.AddWithValue("@OldExamId", oldexam.ExamId); if (oldexam.ExamType != null) { updateCommand.Parameters.AddWithValue("@OldExamType", oldexam.ExamType); } else { updateCommand.Parameters.AddWithValue("@OldExamType", DBNull.Value); } try { connection.Open(); int count = updateCommand.ExecuteNonQuery(); if (count > 0) { return(true); } else { return(false); } } catch (SqlException ex) { throw ex; } finally { connection.Close(); } }
public async Task <IActionResult> Create([Bind("id,name,subject_id,max_marks,time")] exam exam) { if (ModelState.IsValid) { _context.Add(exam); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(exam)); }
public void updateexam(exam item, int index) { exam a = years[selectedyear].getsubject(selectedsubject).getexam(index); a.setduration(item.getduration()); a.setmarks(item.getmarks()); a.setname(item.getname()); a.setoverallvalue(item.getoverallvalue()); a.setstartdate(item.getstartdate()); a.settotalmarks(item.gettotalmarks()); updateexams(); }
public examedit(ref exam it, int index) { InitializeComponent(); i = index; theexam = it; textBox1.Text = theexam.getname(); numericUpDown1.Value = theexam.getoverallvalue(); textBox2.Text = theexam.getmarks().ToString(); numericUpDown2.Value = (decimal)theexam.gettotalmarks(); dateTimePicker1.Value = theexam.getstartdate(); dateTimePicker2.Value = theexam.getstartdate() + theexam.getduration(); }
public ActionResult Create([Bind(Exclude = "id")] exam examsToCreate) { if (!ModelState.IsValid) { return(View()); } _db.exams.Add(examsToCreate); _db.SaveChanges(); return(RedirectToAction("Exams")); }
public ActionResult addtodb(int examid, string ename, int scount, int year) { automatedexamsEntities1 e = new automatedexamsEntities1(); exam ex = new exam(); ex.eid = examid; ex.ename = ename; ex.subjectcount = scount; ex.year = year; e.exams.Add(ex); e.SaveChanges(); return(View()); }
private void ackbtn_Click(object sender, EventArgs e) { DataClasses1DataContext db = new DataClasses1DataContext(); exam examinfo = new exam(); examinfo.id = idbox.Text; examinfo.course_id = idbox.Text; examinfo.exam_address = addressbox.Text; examinfo.exam_time = datetime.Value.Date; db.exam.InsertOnSubmit(examinfo); try { db.SubmitChanges(); MessageBox.Show("提交成功"); } catch { MessageBox.Show("提交失败"); } }
private void App_OnStartup(object sender, StartupEventArgs e) { var screens = Screen.AllScreens; var exam = new exam(); exam.WindowStartupLocation = WindowStartupLocation.Manual; var examReference = new exam_Reference(); examReference.WindowStartupLocation = WindowStartupLocation.Manual; if (screens.Count() == 1) { var bound = screens.FirstOrDefault().Bounds; exam.Top = bound.Top; exam.Left = bound.Left; exam.Height = bound.Height; exam.Width = bound.Width / 2.0; exam.Show(); examReference.Top = bound.Top; examReference.Left = bound.Width / 2.0; examReference.Height = bound.Height; examReference.Width = bound.Width / 2.0; examReference.Show(); } else { var secondaryScreen = screens[0]; var secondaryWorkingArea = secondaryScreen.Bounds; exam.Top = secondaryWorkingArea.Top; exam.Left = secondaryWorkingArea.Left; exam.Height = secondaryWorkingArea.Height; exam.Width = secondaryWorkingArea.Width; //exam.WindowState = System.Windows.WindowState.Maximized; exam.Show(); var primaryScreen = screens[1]; var primaryWorkingArea = primaryScreen.Bounds; examReference.Top = primaryWorkingArea.Top; examReference.Left = primaryWorkingArea.Left; examReference.Height = primaryWorkingArea.Height; examReference.Width = primaryWorkingArea.Width; //examReference.WindowState = primaryScreen. examReference.Show(); } }
private void SetData(exam clsexam) { using (new WaitCursor()) { if (string.IsNullOrEmpty(tbExamType.Text)) { clsexam.ExamType = null; } else { clsexam.ExamType = tbExamType.Text; } } }
// GET: Exam/Delete/5 public ActionResult Delete(int id) { if (id == null) { return(RedirectToAction("Exams")); } exam examsToDelete = _db.exams.Find(id); if (examsToDelete == null) { return(HttpNotFound()); } return(View(examsToDelete)); }
public ActionResult Edit(int id, exam e) { try { // TODO: Add update logic here string msg = sc.UpdateExam(e); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Create(exam ee) { try { // TODO: Add insert logic here string msg = sc.InsertExam(ee); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Edit(exam examToEdit) { var originalExam = (from m in _db.exams where m.exam_id == examToEdit.exam_id select m).First(); if (!ModelState.IsValid) { return(View(originalExam)); } _db.Entry(originalExam).CurrentValues.SetValues(examToEdit); _db.SaveChanges(); return(RedirectToAction("Exams")); }
public static bool Add(exam clsexam) { SqlConnection connection = SchoolData.GetConnection(); string insertStatement = "INSERT " + " [exam] " + " ( " + " [ExamType] " + " ) " + "VALUES " + " ( " + " @ExamType " + " ) " + ""; SqlCommand insertCommand = new SqlCommand(insertStatement, connection); insertCommand.CommandType = CommandType.Text; if (clsexam.ExamType != null) { insertCommand.Parameters.AddWithValue("@ExamType", clsexam.ExamType); } else { insertCommand.Parameters.AddWithValue("@ExamType", DBNull.Value); } try { connection.Open(); int count = insertCommand.ExecuteNonQuery(); if (count > 0) { return(true); } else { return(false); } } catch (SqlException ex) { throw ex; } finally { connection.Close(); } }
public static bool Delete(exam clsexam) { SqlConnection connection = SchoolData.GetConnection(); string deleteStatement = "DELETE FROM " + " [exam] " + "WHERE " + " [ExamId] = @OldExamId " + " AND ((@OldExamType IS NULL AND [ExamType] IS NULL) OR [ExamType] = @OldExamType) " + ""; SqlCommand deleteCommand = new SqlCommand(deleteStatement, connection); deleteCommand.CommandType = CommandType.Text; deleteCommand.Parameters.AddWithValue("@OldExamId", clsexam.ExamId); if (clsexam.ExamType != null) { deleteCommand.Parameters.AddWithValue("@OldExamType", clsexam.ExamType); } else { deleteCommand.Parameters.AddWithValue("@OldExamType", DBNull.Value); } try { connection.Open(); int count = deleteCommand.ExecuteNonQuery(); if (count > 0) { return(true); } else { return(false); } } catch (SqlException ex) { throw ex; } finally { connection.Close(); } }
public static exam Select_Record(exam clsexamPara) { exam clsexam = new exam(); SqlConnection connection = SchoolData.GetConnection(); string selectStatement = "SELECT " + " [ExamId] " + " ,[ExamType] " + "FROM " + " [exam] " + "WHERE " + " [ExamId] = @ExamId " + ""; SqlCommand selectCommand = new SqlCommand(selectStatement, connection); selectCommand.CommandType = CommandType.Text; selectCommand.Parameters.AddWithValue("@ExamId", clsexamPara.ExamId); try { connection.Open(); SqlDataReader reader = selectCommand.ExecuteReader(CommandBehavior.SingleRow); if (reader.Read()) { clsexam.ExamId = System.Convert.ToInt32(reader["ExamId"]); clsexam.ExamType = reader["ExamType"] is DBNull ? null : reader["ExamType"].ToString(); } else { clsexam = null; } reader.Close(); } catch (SqlException ex) { throw ex; } finally { connection.Close(); } return(clsexam); }
private void InsertRecord() { using (new WaitCursor()) { exam clsexam = new exam(); if (VerifyData() == true) { SetData(clsexam); Boolean bSucess = new Boolean(); bSucess = examData.Add(clsexam); if (bSucess == true) { GoBack_To_Grid(); } else { MessageBox.Show("Insert failed.", "Error"); } } } }
private void DeleteRecord() { using (new WaitCursor()) { exam clsexam = new exam(); clsexam.ExamId = System.Convert.ToInt32((Grid.SelectedCells[0].Column.GetCellContent(Grid.SelectedItem) as TextBlock).Text); if (MessageBox.Show("Are you sure? Delete this record?", "Delete", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { SetData(clsexam); Boolean bSucess = new Boolean(); bSucess = examData.Delete(clsexam); if (bSucess == true) { GoBack_To_Grid(); } else { MessageBox.Show("Delete failed.", "Error"); } } } }
/// <summary> /// Add new exam on specipic level and stage /// </summary> /// <param name="obj"></param> private void addExamToDBUser(object obj) { using (amedilab_dataEntities entities = new amedilab_dataEntities()) { try { exam addThis = obj as exam; //found level by level_ID addThis.level1 = (from levels in entities.levels where levels.level1 == _eyeMusicModel.select_level select levels).SingleOrDefault(); //found stage by stage_ID addThis.stage1 = (from stages in entities.stages where stages.stage1 == _eyeMusicModel.select_stage select stages).SingleOrDefault(); entities.exams.Add((DAL.exam)obj); entities.SaveChanges(); } catch (DbEntityValidationException dbEx) { foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { Trace.TraceInformation("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage); } } } catch (Exception e) { } } }
private void button15_Click(object sender, EventArgs e) { // add exam if (selectedsubject != -1) { exam a = new exam(); years[selectedyear].getsubject(selectedsubject).addexam(a); updateexams(); } else MessageBox.Show("please select a subject"); }
public void loadexams(ref StreamReader reader) { int numofexams = int.Parse(reader.ReadLine()); for (int i = 0; i != numofexams; i++) { exam a = new exam(); a.load(ref reader); exams.Add(a); } }
public void addexam(exam item) { exams.Add(item); }
private void ExamForm_Load(object sender, EventArgs e) { ex = (exam) ((ExamForm) sender).Tag; string[] substrings = ex.text.Split('\n'); answer = ex.ranswers; if (userProgress.getExamProgress(ex.lesson) > 0) { List<ExAnswer> list = new List<ExAnswer>(); list = userProgress.getExamAnswers(ex.lesson); if (userProgress.getExamProgress(ex.lesson) > 3) { MessageBox.Show("Экзамен сдан. Ваша оценка: " + userProgress.getExamProgress(ex.lesson).ToString()); } else { MessageBox.Show("Экзамен не сдан. Количество правильных ответов: " + userProgress.getExamProgress(ex.lesson).ToString()); } int i = 0; int y = 60; foreach (string answer in substrings) { Label label = new Label(); label.Location = new Point(0, y); label.AutoSize = true; label.Text = answer; this.Controls.Add(label); y += 20; TextBox text = new TextBox(); text.Name = "ans"; text.Text = list[i].ans; text.Location = new Point(0, y); text.Size = new Size(200, 20); this.Controls.Add(text); y += 30; i++; } } else { int y = 60; foreach (string answer in substrings) { Label label = new Label(); label.Location = new Point(0, y); label.AutoSize = true; label.Text = answer; this.Controls.Add(label); y += 20; TextBox text = new TextBox(); text.Name = "ans"; text.Size = new Size(200, 20); text.Location = new Point(0, y); this.Controls.Add(text); y += 30; } } Button button = new Button(); button.Location = new Point(430, 630); button.Text = "Show results"; button.AutoSize = true; button.Click += new EventHandler(this.Btn_Click); this.Controls.Add(button); Button but = new Button(); but.AutoSize = true; but.Text = "Close"; but.Location = new Point(830, 630); but.Click += new EventHandler(this.Home_Click); this.Controls.Add(but); }
public bool AddExam(exam exam) { exam.Student = this; Marks.Add(exam); return(true); }
public void AddExam(exam exam) { db.exams.InsertOnSubmit(exam); Save(); }
// // GET: /Exam/Delete/5 public ActionResult Delete(int id) { exam e = sc.SearchExam(id); return(View(e)); }
private void CompleteBtn_OnClick(object sender, RoutedEventArgs e) { var windows = Application.Current.Windows; foreach (var item in windows) { var itemWindow = item as Window; if (itemWindow == null) { continue; } if (itemWindow.Title.Equals("exam_Compared")) { itemWindow.Close(); } } bool containExam = false; bool containexamReference = false; foreach (var item in windows) { var itemWindow = item as Window; if (itemWindow == null) { continue; } if (itemWindow.Title.Equals("exam")) { containExam = true; } if (itemWindow.Title.Equals("exam_Reference")) { containexamReference = true; } } if (containExam && containexamReference) { return; } var screens = Screen.AllScreens; var exam = new exam(); exam.WindowStartupLocation = WindowStartupLocation.Manual; var examReference = new exam_Reference(); examReference.WindowStartupLocation = WindowStartupLocation.Manual; if (screens.Count() == 1) { var bound = screens.FirstOrDefault().Bounds; exam.Top = bound.Top; exam.Left = bound.Left; exam.Height = bound.Height; exam.Width = bound.Width / 2.0; exam.Show(); examReference.Top = bound.Top; examReference.Left = bound.Width / 2.0; examReference.Height = bound.Height; examReference.Width = bound.Width / 2.0; examReference.Show(); } else { var secondaryScreen = screens[0]; var secondaryWorkingArea = secondaryScreen.Bounds; exam.Top = secondaryWorkingArea.Top; exam.Left = secondaryWorkingArea.Left; exam.Height = secondaryWorkingArea.Height; exam.Width = secondaryWorkingArea.Width; //exam.WindowState = System.Windows.WindowState.Maximized; exam.Show(); var primaryScreen = screens[1]; var primaryWorkingArea = primaryScreen.Bounds; examReference.Top = primaryWorkingArea.Top; examReference.Left = primaryWorkingArea.Left; examReference.Height = primaryWorkingArea.Height; examReference.Width = primaryWorkingArea.Width; //examReference.WindowState = primaryScreen. examReference.Show(); } }