Ejemplo n.º 1
0
        private bool CreateMarks()
        {
            int affectedRows = 0;

            using (AcademyEntities1 db = new AcademyEntities1())
            {
                int        studentID = (db.Students.Where(c => c.Name == cbMarkStudentID.SelectedItem.ToString()).FirstOrDefault()).İd;
                int        taskID    = (db.Tasks.Where(m => m.Name == cbMarkTaskID.SelectedItem.ToString()).FirstOrDefault()).İd;
                Task_Marks mark      = new Task_Marks
                {
                    StudentİD = studentID,
                    TaskİD    = taskID,
                    Mark      = Convert.ToInt32(MarkTxt.Text),
                    Status    = true
                };

                db.Task_Marks.Add(mark);

                affectedRows = db.SaveChanges();
            }
            if (affectedRows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 2
0
        private void DgvMarkCreate_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            int markID = (int)dgvMarkCreate.Rows[e.RowIndex].Cells[0].Value;

            using (AcademyEntities1 db = new AcademyEntities1())
            {
                MarksCRUD = db.Task_Marks.Where(s => s.İd == markID).FirstOrDefault();
                if (MarksCRUD != null)
                {
                    cbMarkStudentID.SelectedItem = MarksCRUD.Student.Name;
                    cbMarkTaskID.SelectedItem    = MarksCRUD.Task.Name;
                    MarkTxt.Text = Convert.ToString(MarksCRUD.Mark);
                }
            }
            MarkCreateBtn.Enabled = false;
            MarkDeleteBtn.Enabled = true;
            MarkUpdateBtn.Enabled = true;
        }
Ejemplo n.º 3
0
        private bool DeleteMark()
        {
            int affectedRows = 0;

            using (AcademyEntities1 db = new AcademyEntities1())
            {
                Task_Marks newMark = db.Task_Marks.Where(s => s.İd == MarksCRUD.İd).FirstOrDefault();
                newMark.Status = false;
                affectedRows   = db.SaveChanges();
            }
            if (affectedRows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 4
0
        private bool UpdateMark()
        {
            int affectedRows = 0;

            using (AcademyEntities1 db = new AcademyEntities1())
            {
                int studentID = (db.Students.Where(g => g.Name == cbMarkStudentID.SelectedItem.ToString()).FirstOrDefault()).İd;
                int taskID    = (db.Tasks.Where(g => g.Name == cbMarkTaskID.SelectedItem.ToString()).FirstOrDefault()).İd;

                Task_Marks newMark = db.Task_Marks.Where(s => s.İd == MarksCRUD.İd).FirstOrDefault();
                newMark.StudentİD = studentID;
                newMark.TaskİD    = taskID;
                newMark.Mark      = Convert.ToInt32(MarkTxt.Text);
                affectedRows      = db.SaveChanges();
            }
            if (affectedRows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }