private IQueryable GetTableActivity() { try { using (StudentDBDataContext con = new StudentDBDataContext(conn_str)) { var templ = con.GetTable <ActivityTemplate>(); var dataTemp = from act in templ where act.IdUser == currUser.Id select new { Názov = act.ActivityName, Maximum = act.MaxPoints, act.Id }; ActivityGridView.DataSource = dataTemp; ActivityGridView.RowHeadersVisible = false; ActivityGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; ActivityGridView.Columns["Id"].Visible = false; ActivityGridView.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells; var studs = con.GetTable <Student>(); var kruzok = from stud in studs where stud.ID_stud_skupina == this.studentSkup.Id select(string) stud.ID_Kruzok; kruzok.ToList <string>(); groupCmbo.Items.Add("Všetky"); foreach (var kruz in kruzok.Distinct()) { groupCmbo.Items.Add(kruz); } return(dataTemp); } } catch (Exception ex) { Logger newLog = new Logger(); newLog.LogError(ex); MessageBox.Show(ex.ToString()); return(null); } }
private void odstrániťToolStripMenuItem_Click(object sender, EventArgs e) { try { var result = MessageBox.Show("Naozaj chcete odstrániť aktivitu ?", "Odstrániť aktivitu", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { using (var con = new StudentDBDataContext(conn_str)) { var stud = con.GetTable <Student>().Where(x => x.ID_stud_skupina == studentSkupina.Id && x.Id == (int)Student_Grid.CurrentRow.Cells[0].Value).FirstOrDefault(); var act = con.GetTable <Activity>().Where(x => x.IdStudent == stud.Id && x.Id == (int)Activity_Grid.CurrentRow.Cells[3].Value).FirstOrDefault(); var tasks = con.GetTable <Task>().Where(x => x.IdStudent == (int)Student_Grid.CurrentRow.Cells[0].Value && x.IdActivity == act.Id); con.Tasks.DeleteAllOnSubmit(tasks); con.SubmitChanges(); con.Activities.DeleteOnSubmit(act); con.SubmitChanges(); } } Activity_Grid.DataSource = null; GetActivities(); } catch (Exception ex) { Logger newLog = new Logger(); newLog.LogError(ex); } }
private void GetTableTasks() { try { using (StudentDBDataContext con = new StudentDBDataContext(conn_str)) { if (ActivityGridView.SelectedRows.Count > 0) { var selectedActivity = (int)ActivityGridView.CurrentRow.Cells["Id"].Value; var acts = con.GetTable <ActivityTemplate>().Where(x => x.IdUser == currUser.Id && x.Id == selectedActivity).FirstOrDefault(); var tasks = con.GetTable <TaskTemplate>().Where(x => x.IdActivityTemplate == acts.Id).Select(x => new { x.ActivityTemplate, x.Id, x.IdActivityTemplate, Maximum = x.MaxPts, Názov = x.TaskName }); TaskGrid.DataSource = tasks; TaskGrid.Columns["IdActivityTemplate"].Visible = false; TaskGrid.Columns["Id"].Visible = false; TaskGrid.Columns["ActivityTemplate"].Visible = false; } } } catch (Exception ex) { Logger newLog = new Logger(); newLog.LogError(ex); MessageBox.Show(ex.ToString()); return; } }
/// <summary> /// Delete email template /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void materialFlatButton3_Click(object sender, EventArgs e) { try { using (StudentDBDataContext con = new StudentDBDataContext(conn_str)) { DialogResult response = MessageBox.Show("Naozaj chcete odstrániť šablónu ?", "Upozornenie", MessageBoxButtons.YesNo); if (response == DialogResult.Yes) { con.Attachments.DeleteAllOnSubmit(con.GetTable <Attachment>().Where(x => x.IdEmailTemplate == (int)TempGridView.CurrentRow.Cells[2].Value)); con.EmailTemplates.DeleteOnSubmit(con.GetTable <EmailTemplate>(). Where(x => x.IdUser == currentUser.Id && x.Id == (int)TempGridView.CurrentRow.Cells[2].Value).FirstOrDefault()); con.SubmitChanges(); } else { return; } } GetEmailTemps(currentUser); } catch (Exception ex) { Logger newLog = new Logger(); newLog.LogError(ex); MessageBox.Show(ex.ToString()); return; } }
//Nacitanie uloh aktivity do datagridview private void GetTableTasks() { try { using (StudentDBDataContext con = new StudentDBDataContext(conn_str)) { if (ActivityGridView.Rows.Count > 0) { var selectedActivity = (int)ActivityGridView.CurrentRow.Cells["Id"].Value; var acts = con.GetTable <ActivityTemplate>().Where(x => x.IdUser == currUser.Id && x.Id == selectedActivity).FirstOrDefault(); var tasks = con.GetTable <TaskTemplate>().Where(x => x.IdActivityTemplate == acts.Id); TaskGrid.DataSource = tasks; TaskGrid.Columns["TaskName"].HeaderText = "Názov úlohy"; TaskGrid.Columns["MaxPts"].HeaderText = "Maximum"; TaskGrid.Columns["TaskName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; TaskGrid.Columns["IdActivityTemplate"].Visible = false; TaskGrid.Columns["Id"].Visible = false; TaskGrid.Columns["ActivityTemplate"].Visible = false; TaskGrid.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells; } } } catch (Exception ex) { Logger newLog = new Logger(); newLog.LogError(ex); MessageBox.Show(ex.ToString()); return; } }
// public User LoggedUser { get; set; } // Prihlásenie používateľa a validácia ním zadaných údajov private User Login() { var userDict = new Dictionary <string, int?>(); if (string.IsNullOrEmpty(NameBox.Text) || string.IsNullOrWhiteSpace(NameBox.Text) || string.IsNullOrEmpty(FirstPssBox.Text) || string.IsNullOrWhiteSpace(FirstPssBox.Text)) { MessageBox.Show("Meno ani heslo nemôžu byť prázdne"); return(null); } else { using (StudentDBDataContext con = new StudentDBDataContext(conn_str)) { IQueryable <User> user = con.GetTable <User>().Where(x => x.Meno == NameBox.Text); // SQL nie je CaseSensitive tak musíme iným spôsobom validovať správnosť údajov foreach (var us in user) { userDict.Add(us.Meno, us.Id); } var userId = userDict.Where(x => x.Key.Equals(NameBox.Text, StringComparison.CurrentCulture)).Select(x => x.Value).FirstOrDefault(); if (userId == null) { MessageBox.Show("Nesprávne meno alebo heslo"); FirstPssBox.Text = string.Empty; return(null); } else { User currUser = con.GetTable <User>().SingleOrDefault(x => x.Id == userId.Value); var pss = SHA512(FirstPssBox.Text); //Porovnávanie hashu z databázy s hashom od používateľa if (currUser.Heslo.Length == pss.Length) { for (int i = 0; i < currUser.Heslo.Length; i++) { if (currUser.Heslo[i] != pss[i]) { MessageBox.Show("Nesprávne heslo"); FirstPssBox.Text = string.Empty; return(null); } } } else { MessageBox.Show("Nesprávne heslo"); FirstPssBox.Text = string.Empty; return(null); } // Ak sa program dostal až sem, tak používateľ zadal správne prihlasovacie údaje return(currUser); } } } }
// Pri prvom zapnuti okna sa vytvori finalne hodnotenie pre kazdeho studenta // Aby bol mozny export finalneho hodnotenia private void CreateFinalGradeOnStart() { try { using (StudentDBDataContext con = new StudentDBDataContext(conn_str)) { var allStudents = con.GetTable <Student>().Where(x => x.ID_stud_skupina == group.Id); var allFinalGrades = con.GetTable <FinalGrade>().Where(x => x.IdSkupina == group.Id); bool isAdded = false; if (allStudents.Count() <= 0 || allStudents == null) { return; } foreach (var student in allStudents) { var exists = allFinalGrades.Where(x => x.IdSkupina == group.Id && x.IdStudent == student.Id); if (exists.Count() > 0) { continue; } FinalGrade finalGrade = new FinalGrade() { IdSkupina = group.Id, IdStudent = student.Id, ActivityLectPoints = 0, ActivitySemPoints = 0, GotPoints = 0, Grade = "Fx", MaxPts = 0, MissedLectures = 0, MissedSeminars = 0, }; con.FinalGrades.InsertOnSubmit(finalGrade); isAdded = true; } if (isAdded) { con.SubmitChanges(); } else { return; } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); Logger newLog = new Logger(); newLog.LogError(ex); } }
/// <summary> /// Vytvorenie aktivity, body za aktivitu /// </summary> private void PointsForActivity(int?id) { try { using (StudentDBDataContext con = new StudentDBDataContext(conn_str)) { var actTempl = con.GetTable <ActivityTemplate>().Where(x => x.Id == id).FirstOrDefault(); Activity activity = new Activity() { ActivityName = actTempl.ActivityName, IdFirstRem = null, IdSecRem = null, MaxPoints = actTempl.MaxPoints, Deadline = DateTime.Now, EmailSendingActive = false, IdSkupina = studentSkupina.Id, IdUser = currentUser.Id, Hodnotene = true, SendFirst = false, SendSecond = false, IdStudent = (int)Student_Grid.CurrentRow.Cells[0].Value, Hodnotenie = actTempl.MaxPoints, Comment = string.Empty, SendMe = false, }; con.Activities.InsertOnSubmit(activity); con.SubmitChanges(); var tasks = con.GetTable <TaskTemplate>().Where(x => x.IdActivityTemplate == actTempl.Id); foreach (var tsk in tasks) { Task task = new Task() { IdActivity = activity.Id, TaskName = tsk.TaskName, Points = tsk.MaxPts, IdStudent = activity.IdStudent, Hodnotenie = tsk.MaxPts, Comment = string.Empty, }; con.Tasks.InsertOnSubmit(task); } con.SubmitChanges(); } GetActivities(); } catch (ArgumentNullException ex) { Logger logger = new Logger(); logger.LogError(ex); } }
public Email_Client(User activeUser, StudentSkupina skup) { InitializeComponent(); MaterialSkin.MaterialSkinManager skinManager = MaterialSkin.MaterialSkinManager.Instance; skinManager.EnforceBackcolorOnAllComponents = false; skinManager.AddFormToManage(this); skinManager.Theme = MaterialSkin.MaterialSkinManager.Themes.LIGHT; skinManager.ColorScheme = new MaterialSkin.ColorScheme(MaterialSkin.Primary.BlueGrey500, MaterialSkin.Primary.BlueGrey500, MaterialSkin.Primary.BlueGrey500, MaterialSkin.Accent.Blue400, MaterialSkin.TextShade.WHITE); currentUser = activeUser; group = skup; try { using (StudentDBDataContext con = new StudentDBDataContext(conn_str)) { var user = con.GetTable <User>().Where(x => x.Id == currentUser.Id).FirstOrDefault(); var actTempLec = con.GetTable <ActivityTemplate>().Where(x => x.Id == user.PointsForActLec).FirstOrDefault(); var actTempSem = con.GetTable <ActivityTemplate>().Where(x => x.Id == user.PointsForActSem).FirstOrDefault(); ABox.Text = user.AGrade.ToString(); BBox.Text = user.BGrade.ToString(); CBox.Text = user.CGrade.ToString(); DBox.Text = user.DGrade.ToString(); EBox.Text = user.EGrade.ToString(); textBox1.Text = user.ApiKey; textBox2.Text = user.Email; materialMultiLineTextBox1.Text = user.Signature; LoadComboBoxes(activeUser); if (actTempSem != null && comboBox1.Items.Count > 0) { comboBox1.SelectedItem = actTempSem.ActivityName; } if (actTempLec != null && comboBox1.Items.Count > 0) { comboBox2.SelectedItem = actTempLec.ActivityName; } } } catch (Exception ex) { Logger logger = new Logger(); logger.LogError(ex); } }
private void CreateBtn_Click(object sender, EventArgs e) { try { if (!string.IsNullOrEmpty(GroupNameBox.Text) && GroupNameBox.Text.Length > 3) { using (StudentDBDataContext con = new StudentDBDataContext(conn_str)) { var existingGroups = con.GetTable <StudentSkupina>().Where(x => x.Nazov == GroupNameBox.Text && x.Id_User == currentUser.Id); if (existingGroups.Count() > 0) { MessageBox.Show("Skupina s týmto názvom už existuje, prosím zvoľte iný názov skupiny", "Upozornenie", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } var newGroup = new StudentSkupina() { Id_User = currentUser.Id, Nazov = GroupNameBox.Text, Forma = (string)FormCombo.SelectedItem }; con.StudentSkupinas.InsertOnSubmit(newGroup); con.SubmitChanges(); } } else { MessageBox.Show("Názov skupiny musí obsahovať viac ako 3 znaky"); return; } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void GetEmailTemps(User user) { try { using (StudentDBDataContext con = new StudentDBDataContext(conn_str)) { var allTemps = con.GetTable <EmailTemplate>(); var userTemps = from temp in allTemps where temp.IdUser == currentUser.Id select new { temp.EmailTemplateName, temp.EmailContent, temp.Id, temp.EmailSubject }; TempGridView.DataSource = userTemps; TempGridView.Columns["EmailContent"].Visible = false; TempGridView.Columns["Id"].Visible = false; TempGridView.Columns["EmailSubject"].Visible = false; TempGridView.Columns["EmailTemplateName"].HeaderText = "Názov emailovej šablóny"; TempGridView.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells; TempGridView.MultiSelect = false; TempGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; TempGridView.RowHeadersVisible = false; TempGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; } } catch (Exception ex) { Logger newLog = new Logger(); newLog.LogError(ex); MessageBox.Show(ex.ToString()); } }
// Change user to get from login public string SetEnvironmentVar(User currentUser) { try { StudentDBDataContext con = new StudentDBDataContext(conn_str); var users = con.GetTable <User>(); var apikey = from user in users where user.Id == currentUser.Id select(string) user.ApiKey; if (apikey.Count() <= 0) { System.Windows.Forms.MessageBox.Show("Je nutné pridať ApiKey v nastaveniach používateľa"); return(null); } var key = apikey.FirstOrDefault(); if (Environment.GetEnvironmentVariable("SENDGRID_API_KEY") == null || Environment.GetEnvironmentVariable("SENDGRID_API_KEY") != key) { Environment.SetEnvironmentVariable("SENDGRID_API_KEY", key); } return(key); } catch (InvalidDataException) { System.Windows.Forms.MessageBox.Show("Nie je nastavený kľúč"); return(null); } }
private bool Validation() { try { if (!BoxValidation()) { return(false); } using (StudentDBDataContext con = new StudentDBDataContext(conn_str)) { var exists = con.GetTable <User>().Where(x => x.Email == EmailBox.Text || x.Meno == NameBox.Text).Count(); if (exists > 0) { MessageBox.Show("Používateľ s týmto menom alebo emailom už existuje"); return(false); } else { return(true); } } } catch (Exception ex) { Logger logger = new Logger(); logger.LogError(ex); MessageBox.Show("Počas registrácie nastala chyba", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } }
protected List <Student> GetStudents() { StudentDBDataContext con = new StudentDBDataContext(conn_str); var students = con.GetTable <Student>().Where(x => x.ID_stud_skupina == currentGroup.Id).ToList(); return(students); }
private void GradeActivityForm_FormClosing(object sender, FormClosingEventArgs e) { try { using (StudentDBDataContext con = new StudentDBDataContext(conn_str)) { if (con.GetTable <Activity>().Where(x => x.Id == currActivity.Id && x.IdStudent == currStud.Id).FirstOrDefault().Hodnotene == false) { DialogResult dialogResult = MessageBox.Show("Aktivita nebola ohodnotená, chcete naozaj skončiť ?", "Skončiť bez hodnotenia? ", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { e.Cancel = false; } else { e.Cancel = true; } } else { e.Cancel = false; } } } catch (Exception ex) { Logger newLog = new Logger(); newLog.LogError(ex); MessageBox.Show(ex.ToString()); } }
public FinalGradeForm(User user, StudentSkupina skup) { MaterialSkin.MaterialSkinManager skinManager = MaterialSkin.MaterialSkinManager.Instance; skinManager.EnforceBackcolorOnAllComponents = false; skinManager.AddFormToManage(this); skinManager.Theme = MaterialSkin.MaterialSkinManager.Themes.LIGHT; skinManager.ColorScheme = new MaterialSkin.ColorScheme(MaterialSkin.Primary.BlueGrey500, MaterialSkin.Primary.BlueGrey500, MaterialSkin.Primary.BlueGrey500, MaterialSkin.Accent.Blue400, MaterialSkin.TextShade.WHITE); InitializeComponent(); currentUser = user; group = skup; try { using (StudentDBDataContext con = new StudentDBDataContext(conn_str)) { if (con.GetTable <Student>().Where(x => x.ID_stud_skupina == skup.Id).Count() > 0) { CreateFinalGradeOnStart(); LoadGrid(skup); } } } catch (Exception ex) { MessageBox.Show("Uistite sa, že existujú študenti"); Logger logger = new Logger(); logger.LogError(ex); } }
//Nacitavanie studentov do datagridu private void LoadGrid(StudentSkupina skupina) { try { using (StudentDBDataContext con = new StudentDBDataContext(conn_str)) { var students = con.GetTable <Student>().Where(x => x.ID_stud_skupina == skupina.Id).Select(y => new { y.Id, y.Meno, y.Priezvisko, y.ISIC }); if (students.Count() > 0) { StudentGrid.DataSource = students; StudentGrid.Columns["Id"].Visible = false; StudentGrid.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells; } else { this.Close(); } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); Logger newLog = new Logger(); newLog.LogError(ex); } }
protected List <Activity> GetActivities() { StudentDBDataContext con = new StudentDBDataContext(conn_str); var activity = con.GetTable <Activity>().Where(x => x.IdSkupina == currentGroup.Id).ToList(); return(activity); }
protected List <TotalAttendance> GetTotalAttendances() { StudentDBDataContext con = new StudentDBDataContext(conn_str); var totalAttendance = con.GetTable <TotalAttendance>().Where(x => x.Student.ID_stud_skupina == currentGroup.Id).ToList(); return(totalAttendance); }
protected List <FinalGrade> GetFinalGrades() { StudentDBDataContext con = new StudentDBDataContext(conn_str); var finalGrades = con.GetTable <FinalGrade>().Where(x => x.IdSkupina == currentGroup.Id).ToList(); return(finalGrades); }
private void MaterialTabCOntrol_SelectedIndexChanged(object sender, EventArgs e) { if (this.MaterialTabCOntrol.SelectedTab.Name == currActivity.ActivityName) { var labl = (Label)MaterialTabCOntrol.SelectedTab.Controls.Find("StudentPtsLabel", false).FirstOrDefault(); using (StudentDBDataContext con = new StudentDBDataContext(conn_str)) { var act = con.GetTable <Task>().Where(x => x.IdActivity == currActivity.Id && x.IdStudent == currStud.Id); double?gradeTotal = 0; foreach (var tsk in act) { gradeTotal += tsk.Hodnotenie; } if (MaterialTabCOntrol.SelectedIndex == 0) { MaterialTabCOntrol.SelectedTab.Controls.Find("StudentPtsLabel", false).FirstOrDefault().Text = "Získané: " + gradeTotal.ToString(); } } } else { return; } }
protected List <AttendanceStud> GetAttendances() { StudentDBDataContext con = new StudentDBDataContext(conn_str); var attendance = con.GetTable <AttendanceStud>().Where(x => x.IDSkupina == currentGroup.Id).ToList(); return(attendance); }
private IQueryable GetTableTemp() { try { using (StudentDBDataContext con = new StudentDBDataContext(conn_str)) { var templ = con.GetTable <ActivityTemplate>(); var dataTemp = from act in templ where act.IdUser == currUser.Id select new { Názov = act.ActivityName, Maximum = act.MaxPoints, act.Id }; AllActTempGrid.DataSource = dataTemp; AllActTempGrid.RowHeadersVisible = false; AllActTempGrid.AllowUserToAddRows = false; AllActTempGrid.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; AllActTempGrid.AllowUserToDeleteRows = false; AllActTempGrid.AllowUserToResizeColumns = false; AllActTempGrid.ReadOnly = true; AllActTempGrid.Columns["Id"].Visible = false; AllActTempGrid.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells; return(dataTemp); } } catch (Exception ex) { Logger logger = new Logger(); logger.LogError(ex); return(null); } }
private Nullable <int> GetEmailTemps(ComboBox x) { try { StudentDBDataContext con = new StudentDBDataContext(conn_str); if (!string.IsNullOrEmpty(x.Text)) { var temps = con.GetTable <EmailTemplate>().Where(y => y.IdUser == currUser.Id); var emailTmp = from email in temps where email.EmailTemplateName == x.Text select email.Id; return(emailTmp.FirstOrDefault()); } else { return(null); } } catch (Exception ex) { Logger newLog = new Logger(); newLog.LogError(ex); MessageBox.Show(ex.ToString()); return(null); } }
private void LoadComboBoxes(User user) { try { using (StudentDBDataContext con = new StudentDBDataContext(conn_str)) { var activities = con.GetTable <ActivityTemplate>().Where(x => x.IdUser == currentUser.Id); if (activities.Count() > 0) { foreach (var activity in activities) { comboBox1.Items.Add(activity.ActivityName); comboBox2.Items.Add(activity.ActivityName); activityId.Add(activity.ActivityName, activity.Id); } } } } catch (Exception ex) { Logger logger = new Logger(); logger.LogError(ex); } }
private void AddManualAttendanceBtn_Click(object sender, EventArgs e) { try { if ((string)comboBox3.SelectedValue != string.Empty) { using (var con = new StudentDBDataContext(conn_str)) { var student = studentsManual.TryGetValue(comboBox3.Text, out int value); var std = con.GetTable <Student>().Where(x => x.Id == value).FirstOrDefault(); if (std == null) { MessageBox.Show("Nie je vybraný žiaden študent"); return; } var insert = new AttendanceStud { IDSkupina = this.StudentSkup.Id, Type = CheckType(), Date = GetDate(), IDStudent = value, IdGroup = std.ID_Kruzok, Comment = string.Empty }; var attend = con.GetTable <AttendanceStud>(); var AttList = from AttendanceStud in attend where insert.IDSkupina == AttendanceStud.IDSkupina && AttendanceStud.Date == insert.Date && AttendanceStud.Type == insert.Type && AttendanceStud.IDStudent == insert.IDStudent select new { AttendanceStud.Type, AttendanceStud.Date }; if (AttList.Count() == 0) { con.AttendanceStuds.InsertOnSubmit(insert); con.SubmitChanges(ConflictMode.FailOnFirstConflict); } Filter(); ResetLabels(); } } } catch (Exception ex) { Logger newLog = new Logger(); newLog.LogError(ex); MessageBox.Show("Nastala chyba, viac informácii nájdete v logoch.", "Chyba", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// Odstranit ak nebude potrebne /// </summary> private void GetAttendance() { try { using (StudentDBDataContext con = new StudentDBDataContext(conn_str)) { var attendance = con.GetTable <AttendanceStud>(); var students = con.GetTable <Student>(); con.Connection.Open(); var AttList = from att in attendance from stud in students where att.IDSkupina == StudentSkup.Id where stud.Id == att.IDStudent select new { stud.Meno, stud.Priezvisko, att.Date, att.Status, att.Type, att.IdAttendance, stud.ID_Kruzok, stud.Id }; attGrid.DataSource = AttList.Where(t => t.Type == CheckType()).OrderByDescending(x => x.Date.Day); if ((string)comboBox1.Text == "Všetky") { AttList.Where(t => t.Type == CheckType()); } else { attGrid.DataSource = AttList.Where(t => t.Type == CheckType() && t.ID_Kruzok == comboBox1.Text).OrderByDescending(x => x.Date.Day); } attGrid.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; attGrid.Columns["IdAttendance"].Visible = false; attGrid.Columns["Id"].Visible = false; attGrid.Columns["Date"].HeaderText = "Dátum"; attGrid.Columns["Date"].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; attGrid.Columns["Type"].HeaderText = "Typ"; attGrid.Columns["ID_Kruzok"].HeaderText = "Krúžok"; attGrid.MultiSelect = true; attGrid.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells; } } catch (Exception ex) { Logger newLog = new Logger(); newLog.LogError(ex); MessageBox.Show("Nastala chyba, viac informácii nájdete v logoch.", "Chyba", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public EmailSendingForm(User user, StudentSkupina skupina) { InitializeComponent(); MaterialSkin.MaterialSkinManager skinManager = MaterialSkin.MaterialSkinManager.Instance; skinManager.EnforceBackcolorOnAllComponents = false; skinManager.AddFormToManage(this); skinManager.Theme = MaterialSkin.MaterialSkinManager.Themes.LIGHT; skinManager.ColorScheme = new MaterialSkin.ColorScheme(MaterialSkin.Primary.BlueGrey500, MaterialSkin.Primary.BlueGrey500, MaterialSkin.Primary.BlueGrey500, MaterialSkin.Accent.Blue400, MaterialSkin.TextShade.WHITE); currentUser = user; currentGroup = skupina; StudentDBDataContext con = new StudentDBDataContext(conn_str); var students = con.GetTable <Student>(); var groups = con.GetTable <StudentSkupina>().Where(x => x.Id == skupina.Id); var skup = from student in students where student.ID_stud_skupina == currentGroup.Id select new { student.Meno, student.Email, student.Priezvisko, student.Email_UCM }; var columnWidth = new int[] { 100, 120 }; autocompleteMenu1.MaximumSize = new System.Drawing.Size(250, 200); foreach (var student in skup) { autocompleteMenu1.AddItem(new MulticolumnAutocompleteItem(new[] { RWS(student.Meno) + " " + RWS(student.Priezvisko), RWS(student.Email) }, RWS(student.Email)) { ColumnWidth = columnWidth }); autocompleteMenu1.AddItem(new MulticolumnAutocompleteItem(new[] { "", RWS(student.Email_UCM) }, RWS(student.Email_UCM)) { ColumnWidth = columnWidth }); } var kruzok = from stud in students where stud.ID_stud_skupina == skupina.Id select(string) stud.ID_Kruzok; kruzok.ToList <string>(); foreach (var kruz in kruzok.Distinct()) { GroupComboEmail.Items.Add(kruz); } autocompleteMenu1.Enabled = true; autocompleteMenu1.AllowsTabKey = true; }
private void GradeActivityBtnClick(object sender, EventArgs e) { try { if (this.MaterialTabCOntrol.SelectedTab.Name == currActivity.ActivityName) { var labl = (Label)MaterialTabCOntrol.SelectedTab.Controls.Find("StudentPtsLabel", false).FirstOrDefault(); var commentBox = (RichTextBox)MaterialTabCOntrol.SelectedTab.Controls.Find("comment", false).FirstOrDefault(); using (StudentDBDataContext con = new StudentDBDataContext(conn_str)) { var act = con.GetTable <Task>().Where(x => x.IdActivity == currActivity.Id && x.IdStudent == currStud.Id); double gradeTotal = 0; foreach (var tsk in act) { gradeTotal += tsk.Hodnotenie; } var insert = con.Activities.Where(x => x.IdSkupina == currGroup.Id && x.Id == currActivity.Id && x.IdStudent == currStud.Id).FirstOrDefault(); if (gradeTotal <= insert.MaxPoints) { ///ERROR 280 Line insert.Hodnotene = true; insert.Hodnotenie = gradeTotal; if (!string.IsNullOrEmpty(commentBox.Text)) { insert.Comment = commentBox.Text; } else { insert.Comment = string.Empty; } insert.EmailSendingActive = false; insert.SendFirst = false; insert.SendSecond = false; insert.SendMe = false; } con.SubmitChanges(); MessageBox.Show("Aktivita ohodnotená"); } } else { return; } } catch (Exception ex) { Logger newLog = new Logger(); newLog.LogError(ex); MessageBox.Show(ex.ToString()); } }
private IQueryable GetTableActivity() { try { using (StudentDBDataContext con = new StudentDBDataContext(conn_str)) { var templ = con.GetTable <ActivityTemplate>(); var dataTemp = from act in templ where act.IdUser == currUser.Id select new { Názov = act.ActivityName, Bodov = act.MaxPoints, act.Id }; ActivityGridView.DataSource = dataTemp; ActivityGridView.RowHeadersVisible = false; ActivityGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; ActivityGridView.Columns["Id"].Visible = false; ActivityGridView.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells; dateTimePicker2.Format = DateTimePickerFormat.Custom; dateTimePicker2.CustomFormat = "HH:mm"; dateTimePicker2.ShowUpDown = true; var studs = con.GetTable <Student>().Where(x => x.ID_stud_skupina == skupina.Id); foreach (var student in studs.Distinct()) { studentCombo.Items.Add(student.Meno + " " + student.Priezvisko); studentsId.Add(student.Meno + " " + student.Priezvisko, student.Id); } return(dataTemp); } } catch (Exception ex) { Logger newLog = new Logger(); newLog.LogError(ex); MessageBox.Show(ex.ToString()); return(null); } }