public static void seed(ExamDB db)
        {
            IList <Degree> Degrees = new List <Degree>()
            {
                new Degree()
                {
                    id          = 1,
                    Title       = "Under graduate",
                    Description = "Under graduate"
                },
                new Degree()
                {
                    id          = 2,
                    Title       = "Graduate",
                    Description = "Graduate"
                },
                new Degree()
                {
                    id          = 3,
                    Title       = "Post graduate",
                    Description = "Post graduate"
                },
            };

            foreach (var item in Degrees)
            {
                db.Degrees.Add(item);
            }

            db.SaveChanges();
        }
        public static void seed(ExamDB context)
        {
            context.Student.AddOrUpdate(
                new Student()
            {
                id             = 1,
                Semester       = 1,
                Session        = 2016,
                RegistrationNO = "94384711",
                Designation    = 5,
                Gender         = "Male",
                Picture        = "",
                Status         = 1,
                Department     = 1,
                Comment        = "",
            },
                new Student()
            {
                id             = 2,
                Semester       = 1,
                Session        = 2016,
                RegistrationNo = "94344711",
                Designation    = 5,
                Gender         = "Male",
                Picture        = "",
                Status         = 1,
                Department     = 1,
                Comment        = "",
                created_at     = DateTime.Now,
                edited_at      = DateTime.Now
            }
                );

            context.SaveChanges();
        }
Exemple #3
0
        private void name_dept_SelectedIndexChanged(object sender, EventArgs e)
        {
            IDINS.Items.Clear();
            ExamDB.Open();
            try
            {
                SqlCommand ins = new SqlCommand("getInstructorID", ExamDB);
                ins.CommandType = CommandType.StoredProcedure;
                foreach (var item in deptDic)
                {
                    if (name_dept.SelectedItem.ToString() == item.Value)
                    {
                        insID = item.Key;
                        break;
                    }
                }
                ins.Parameters.AddWithValue("@id", SqlDbType.Int).Value = insID;
                SqlDataReader INS = ins.ExecuteReader();
                while (INS.Read())
                {
                    IDINS.Items.Add(INS["Ins_id"]).ToString();
                }
                INS.Close();

                DOB.Text = name.Text = sal.Text = ads.Text = string.Empty;
            }
            catch
            {
                MessageBox.Show("This Department has No Instructors");
            }
            ExamDB.Close();
        }
Exemple #4
0
        //add TF Question
        private void addTFQuestion_Click(object sender, EventArgs e)
        {
            ExamDB.Open();
            try
            {
                if (queBox.Text == null || queBox.Text == "" ||
                    queBox.Text.Length < 5 || degree.Text == null ||
                    degree.Text == "" || anserBox.Text == "" ||
                    anserBox.Text == null
                    )
                {
                    MessageBox.Show("^_^ your question is very short ^_^");
                    queBox.Text = degree.Text = anserBox.Text = String.Empty;
                }
                else
                {
                    SqlCommand cmd = new SqlCommand("addNewTFQuestion", ExamDB);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@question", SqlDbType.NVarChar).Value = queBox.Text.ToString().Trim();
                    cmd.Parameters.AddWithValue("@grade", SqlDbType.Int).Value         = degree.Text.Trim().ToString();
                    cmd.Parameters.AddWithValue("@ansid", SqlDbType.Int).Value         = anserBox.Text.ToString().Trim();
                    cmd.Parameters.AddWithValue("@crs_id", SqlDbType.Int).Value        = TFId;
                    cmd.ExecuteNonQuery();
                    MessageBox.Show("^_^ You Added New Question ^_^");

                    queBox.Text = degree.Text = anserBox.Text = String.Empty;
                }
            }
            catch
            {
                MessageBox.Show("^_^ Please Enter Valid Data ^_^");
                queBox.Text = degree.Text = anserBox.Text = String.Empty;
            }
            ExamDB.Close();
        }
Exemple #5
0
        private void enrollbtn_Click(object sender, EventArgs e)
        {
            int Find = 0;

            try
            {
                ExamDB.Open();
                foreach (var item in crsesIds)
                {
                    SqlCommand find = new SqlCommand("addStudentCourse", ExamDB);
                    find.CommandType = CommandType.StoredProcedure;
                    find.Parameters.AddWithValue("@st_id", SqlDbType.Int).Value  = stid;
                    find.Parameters.AddWithValue("@crs_id", SqlDbType.Int).Value = item.Key;
                    Find += find.ExecuteNonQuery();
                }



                if (Find < 1)
                {
                    MessageBox.Show("^_^ Courses not added ^_^");
                }
                else
                {
                    enrolledCrs.Items.Clear();
                    MessageBox.Show("^_^ Courses is added ^_^");
                }
                ExamDB.Close();
            }
            catch
            {
                MessageBox.Show("^_^ Please Enter Valid Data ^_^");
            }
        }
Exemple #6
0
        private void nameStd_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                avCrs.Items.Clear();
                crsdic.Clear();
                ExamDB.Open();
                SqlCommand std = new SqlCommand("getAvailableCrs", ExamDB);
                std.CommandType = CommandType.StoredProcedure;
                foreach (var item in stdnameDic)
                {
                    if (nameStd.SelectedItem.ToString() == item.Value)
                    {
                        stid = item.Key;
                        break;
                    }
                }
                std.Parameters.AddWithValue("@id", SqlDbType.Int).Value = stid;
                SqlDataReader Std = std.ExecuteReader();
                while (Std.Read())
                {
                    crsdic.Add(int.Parse(Std["Crs_id"].ToString()), Std["Crs_name"].ToString());
                    avCrs.Items.Add(Std["Crs_name"]).ToString();
                }

                Std.Close();
                ExamDB.Close();
            }
            catch
            {
                MessageBox.Show("^_^ This Student is enrolled to all courses ^_^");
            }
        }
        /* METHOD -> DataBinds the Exam Combo Box */
        private void SetCbExams()
        {
            exams = ExamDB.GetExamByAdmin(adminID);

            if (exams.Count > 0) //Admin has exams, display and enable the exam name combo box
            {
                exams.Insert(0, new Exam {
                    ExamName = "Select Exam", ExamID = -1
                });                                                                 //instantiates placeholder object at index 0

                ctrl_cb_examName.DataSource    = exams;
                ctrl_cb_examName.DisplayMember = "ExamName";
                ctrl_cb_examName.ValueMember   = "ExamID";
                ctrl_cb_examName.Enabled       = true;
                ctrl_tb_duration.Text          = "";
            }
            else //Admin has no exams, disable Exam combo box
            {
                ctrl_cb_examName.DataSource = null;
                ctrl_cb_examName.Text       = "No Exams Created";
                ctrl_cb_examName.Enabled    = false;
                ctrl_btn_updateExam.Enabled = false;
                ctrl_btn_delete.Enabled     = false;
                ctrl_tb_duration.Text       = "";
            }
        }
Exemple #8
0
        public static void seed(ExamDB context)
        {
            IList <Session_Courses> Session_Courses = new List <Session_Courses>()
            {
                new Session_Courses()
                {
                    id         = 1,
                    Course     = 1,
                    Department = 1,
                    Faculty    = 2,
                    Semester   = 1,
                    Session    = 2016,
                    created_at = DateTime.Now,
                    edited_at  = DateTime.Now
                },
                new Session_Courses()
                {
                    id         = 2,
                    Course     = 2,
                    Department = 1,
                    Faculty    = 2,
                    Semester   = 2,
                    Session    = 2016,
                    created_at = DateTime.Now,
                    edited_at  = DateTime.Now
                },
            };

            foreach (var item in Session_Courses)
            {
                context.Session_Courses.Add(item);
            }

            context.SaveChanges();
        }
Exemple #9
0
        private void delete_Click(object sender, EventArgs e)
        {
            ExamDB.Open();
            try
            {
                SqlCommand cmd = new SqlCommand("deleteDeparment", ExamDB);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@id", SqlDbType.VarChar).Value = deptID;
                int affRows = cmd.ExecuteNonQuery();
                if (affRows > 0)
                {
                    MessageBox.Show("^_^ You Deleted The Department ^_^");
                    ExamDB.Close();
                    dataGridView2.DataSource = null;
                    dataGridView2.Refresh();

                    GetInsDept();
                }
                else
                {
                    MessageBox.Show("^_^ select department at first ^_^");
                    ExamDB.Close();
                }
            }

            catch (Exception)
            {
                MessageBox.Show("Can't Delete Departement With Students !! ");
            }
        }
Exemple #10
0
 private void GetQue()
 {
     TFDic.Clear();
     MCDic.Clear();
     stdCrsDic.Clear();
     topicCrs.Clear();
     ExamDB.Open();
     try
     {
         SqlCommand crs = new SqlCommand("getAllcours", ExamDB);
         crs.CommandType = CommandType.StoredProcedure;
         SqlDataReader Crs = crs.ExecuteReader();
         while (Crs.Read())
         {
             TFDic.Add(int.Parse(Crs["Course Code"].ToString()), Crs["Course Name"].ToString());
             namrCRS.Items.Add(Crs["Course Name"].ToString());
             MCDic.Add(int.Parse(Crs["Course Code"].ToString()), Crs["Course Name"].ToString());
             CRS.Items.Add(Crs["Course Name"].ToString());
             topicCrs.Add(int.Parse(Crs["Course Code"].ToString()), Crs["Course Name"].ToString());
             crs_Name.Items.Add(Crs["Course Name"]).ToString();
             stdCrsDic.Add(int.Parse(Crs["Course Code"].ToString()), Crs["Course Name"].ToString());
             std_crs.Items.Add(Crs["Course Name"]).ToString();
         }
         Crs.Close();
     }
     catch
     {
         MessageBox.Show("^_^ Please Enter Valid Data ^_^");
     }
     ExamDB.Close();
 }
Exemple #11
0
 //only show data of department's instructor
 private void stdName_SelectedIndexChanged(object sender, EventArgs e)
 {
     foreach (var item in mngDic)
     {
         if (stdName.SelectedItem.ToString() == item.Value)
         {
             deptID = item.Key;
             break;
         }
     }
     ExamDB.Open();
     try
     {
         SqlCommand std = new SqlCommand("getcourInInstr", ExamDB);
         std.CommandType = CommandType.StoredProcedure;
         DataTable dTable = new DataTable();
         std.Parameters.AddWithValue("@id", SqlDbType.VarChar).Value = deptID;
         dTable.Load(std.ExecuteReader());
         dataGridView2.DataSource = dTable;
         std.Parameters.Clear();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
         // MessageBox.Show("^_^ Please Enter Valid Data ^_^");
     }
     ExamDB.Close();
 }
Exemple #12
0
 private void nameDept_SelectedIndexChanged(object sender, EventArgs e)
 {
     foreach (var item in manger)
     {
         if (nameDept.SelectedItem.ToString() == item.Value)
         {
             depID = item.Key;
             break;
         }
     }
     ExamDB.Open();
     try
     {
         SqlCommand std = new SqlCommand("getStudentByDept", ExamDB);
         std.CommandType = CommandType.StoredProcedure;
         DataTable dTable = new DataTable();
         std.Parameters.AddWithValue("@deptId", SqlDbType.VarChar).Value = depID;
         dTable.Load(std.ExecuteReader());
         dataGridView3.DataSource = dTable;
     }
     catch (Exception)
     {
         MessageBox.Show("^_^ Please Enter Valid Data ^_^");
     }
     ExamDB.Close();
     GetDeptData();
 }
Exemple #13
0
        public static void seed(ExamDB context)
        {
            IList <DayTiming> DayTiming = new List <DayTiming>()
            {
                new DayTiming()
                {
                    id         = 1,
                    Timing     = "Morning",
                    created_at = DateTime.Now,
                    edited_at  = DateTime.Now
                },
                new DayTiming()
                {
                    id         = 2,
                    Timing     = "Evening",
                    created_at = DateTime.Now,
                    edited_at  = DateTime.Now
                },
            };

            foreach (var item in DayTiming)
            {
                context.DayTiming.AddOrUpdate(item);
            }

            context.SaveChanges();
        }
Exemple #14
0
        //new department
        private void save_Click(object sender, EventArgs e)
        {
            ExamDB.Open();
            try
            {
                if (deptName.Text == null || deptName.Text == "" || deptName.Text.Length < 2)
                {
                    MessageBox.Show("^_^ The Data you Enterd is too Short ^_^");
                }
                else
                {
                    SqlCommand cmd = new SqlCommand("addDepartment", ExamDB);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@dname", SqlDbType.NVarChar).Value = deptName.Text.ToString().Trim();
                    cmd.Parameters.AddWithValue("@mgr_id", SqlDbType.Int).Value     = mngID;
                    cmd.ExecuteNonQuery();
                    MessageBox.Show("^_^ You Added New Department ^_^");

                    deptName.Text = deptMng.Text = String.Empty;
                }
            }
            catch
            {
                MessageBox.Show("^_^ Please Enter Valid Data ^_^");
            }
            ExamDB.Close();
            GetDeptData();
            GetDeptName();
            GetInsDept();
        }
Exemple #15
0
 private void stdID_SelectedIndexChanged(object sender, EventArgs e)
 {
     dob.Text = address.Text = DeptName.Text = stdName.Text = lastname.Text = string.Empty;
     try
     {
         ExamDB.Open();
         SqlCommand find = new SqlCommand("getStudent", ExamDB);
         find.CommandType = CommandType.StoredProcedure;
         find.Parameters.AddWithValue("@id", SqlDbType.Int).Value = stdID.SelectedItem;
         SqlDataReader Find = find.ExecuteReader();
         while (Find.Read())
         {
             stdName.Text  = Find["fname"].ToString();
             lastname.Text = Find["lname"].ToString();
             address.Text  = Find["Address"].ToString();
             dob.Text      = Find["BirthDate"].ToString();
         }
         Find.Close();
         ExamDB.Close();
     }
     catch
     {
         MessageBox.Show("^_^ Please Enter Valid Data ^_^");
     }
 }
        public static void seed(ExamDB db)
        {
            IList <DayTime> DayTime = new List <DayTime>()
            {
                /*
                 * new DayTime()
                 * {
                 *  id = 1,
                 *  Title = "Morning",
                 *  Description = "Morning",
                 * },
                 * new DayTime()
                 * {
                 *  id = 2,
                 *  Title = "Evening",
                 *  Description = "Evening",
                 * },
                 */
            };

            foreach (var item in DayTime)
            {
                db.DayTime.AddOrUpdate(item);
            }

            db.SaveChanges();
        }
Exemple #17
0
        //add new topic
        private void addTopic_Click(object sender, EventArgs e)
        {
            ExamDB.Open();
            try
            {
                if (topName.Text == null || topName.Text == "" || topName.Text.Length < 3)
                {
                    MessageBox.Show("^_^ Please Enter more than 3 char ^_^");
                }
                SqlCommand cmd = new SqlCommand("addNewTopicInCourse", ExamDB);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@crs_id", SqlDbType.NVarChar).Value = topId;
                cmd.Parameters.AddWithValue("@t_name", SqlDbType.Int).Value      = topName.Text;
                cmd.ExecuteNonQuery();
                MessageBox.Show("^_^ You Added New Tpoic ^_^");

                topName.Text = String.Empty;
            }
            catch
            {
                MessageBox.Show("^_^ Please Enter Valid Data ^_^");
            }
            ExamDB.Close();
            GetCrsTopic();
        }
Exemple #18
0
 private void IDINS_SelectedIndexChanged(object sender, EventArgs e)
 {
     DOB.Text = name.Text = sal.Text = ads.Text = string.Empty;
     ExamDB.Open();
     try
     {
         SqlCommand find = new SqlCommand("getInstructor", ExamDB);
         find.CommandType = CommandType.StoredProcedure;
         find.Parameters.AddWithValue("@id", SqlDbType.Int).Value = IDINS.SelectedItem;
         SqlDataReader Find = find.ExecuteReader();
         while (Find.Read())
         {
             name.Text = Find["Name"].ToString();
             sal.Text  = Find["Salary"].ToString();
             ads.Text  = Find["Address"].ToString();
             DOB.Text  = Find["BirthDate"].ToString();
         }
         Find.Close();
     }
     catch
     {
         MessageBox.Show("^_^ Please Enter Valid Data ^_^");
     }
     ExamDB.Close();
 }
Exemple #19
0
 public Properties()
 {
     created_by = new ExamDB().User.Find(1); // System
     isDeleted  = false;
     created_at = DateTime.Now;
     edited_at  = DateTime.Now;
 }
Exemple #20
0
 private void insName_SelectedIndexChanged(object sender, EventArgs e)
 {
     foreach (var item in InsDic)
     {
         if (insName.SelectedItem.ToString() == item.Value)
         {
             insId = item.Key;
             break;
         }
     }
     ExamDB.Open();
     try
     {
         SqlCommand std = new SqlCommand("getInstructorWithCourseAndNoStudent", ExamDB);
         std.CommandType = CommandType.StoredProcedure;
         DataTable dTable = new DataTable();
         std.Parameters.AddWithValue("@InsId", SqlDbType.VarChar).Value = insId;
         dTable.Load(std.ExecuteReader());
         dataGridView2.DataSource = dTable;
     }
     catch
     {
         MessageBox.Show("^_^ Please Enter Valid Data ^_^");
     }
     ExamDB.Close();
 }
        public static void seed(ExamDB db)
        {
            IList <Degree> Degrees = new List <Degree>()
            {
                /*
                 * new Degree()
                 * {
                 *  id = 1,
                 *  Title = "Under graduate",
                 *  Description = "Under graduate"
                 * },
                 * new Degree()
                 * {
                 *  id = 2,
                 *  Title = "Graduate",
                 *  Description = "Graduate"
                 * },
                 * new Degree()
                 * {
                 *  id = 3,
                 *  Title = "Post graduate",
                 *  Description = "Post graduate"
                 * },
                 */
            };

            foreach (var item in Degrees)
            {
                db.Degree.Add(item);
            }

            db.SaveChanges();
        }
        public static void seed(ExamDB context)
        {
            IList <Degrees> Degrees = new List <Degrees>()
            {
                new Degrees()
                {
                    id         = 1,
                    Title      = "Under graduate",
                    created_at = DateTime.Now,
                    edited_at  = DateTime.Now
                },
                new Degrees()
                {
                    id         = 2,
                    Title      = "Graduate",
                    created_at = DateTime.Now,
                    edited_at  = DateTime.Now
                },
                new Degrees()
                {
                    id         = 3,
                    Title      = "Post graduate",
                    created_at = DateTime.Now,
                    edited_at  = DateTime.Now
                },
            };

            foreach (var item in Degrees)
            {
                context.Degrees.Add(item);
            }

            context.SaveChanges();
        }
        public static void seed(ExamDB db)
        {
            IList <DayTiming> DayTiming = new List <DayTiming>()
            {
                new DayTiming()
                {
                    id          = 1,
                    Title       = "Morning",
                    Description = "Morning",
                },
                new DayTiming()
                {
                    id          = 2,
                    Title       = "Evening",
                    Description = "Evening",
                },
            };

            foreach (var item in DayTiming)
            {
                db.DayTiming.AddOrUpdate(item);
            }

            db.SaveChanges();
        }
Exemple #24
0
        private void addNewStd()
        {
            ExamDB.Open();
            try
            {
                if (fname.Text == null ||
                    fname.Text == "" ||
                    fname.Text.Length <= 3 ||
                    lname.Text.Length <= 3 ||
                    lname.Text == null ||
                    lname.Text == "" ||
                    ads.Text == null ||
                    ads.Text == "" ||
                    bod.Text == null ||
                    bod.Text == "" ||
                    dept.Text == null ||
                    dept.Text == ""
                    )
                {
                    MessageBox.Show(" ^_^ please Correct Data & your Name must be >= 3 char ^_^");
                }
                else
                {
                    SqlCommand cmd = new SqlCommand("addStudent", ExamDB);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@fname", SqlDbType.NVarChar).Value   = fname.Text;
                    cmd.Parameters.AddWithValue("@lname", SqlDbType.NVarChar).Value   = lname.Text;
                    cmd.Parameters.AddWithValue("@address", SqlDbType.NVarChar).Value = ads.Text;
                    cmd.Parameters.AddWithValue("@bod", SqlDbType.Date).Value         = bod.Value.Date.ToString().Split(' ')[0];
                    cmd.Parameters.AddWithValue("@dept", SqlDbType.Int).Value         = deptId;
                    SqlDataReader CMD = cmd.ExecuteReader();
                    int           Std = 0;
                    while (CMD.Read())
                    {
                        Std = int.Parse(CMD["St_id"].ToString());
                    }
                    CMD.Close();
                    fname.Text = lname.Text = ads.Text = bod.Text = dept.Text = String.Empty;
                    int Crs = 0;

                    for (int i = 0; i < checkedCrs.Count; i++)
                    {
                        SqlCommand chcrs = new SqlCommand("addStudentCourse", ExamDB);
                        chcrs.CommandType = CommandType.StoredProcedure;
                        chcrs.Parameters.AddWithValue("@st_id", SqlDbType.Int).Value  = Std;
                        chcrs.Parameters.AddWithValue("@crs_id", SqlDbType.Int).Value = checkedCrs[i];
                        Crs = chcrs.ExecuteNonQuery();
                    }

                    MessageBox.Show("^_^ You Added New Student ^_^");
                }
            }
            catch
            {
                MessageBox.Show("^_^ Please Enter Valid Data ^_^");
            }
            ExamDB.Close();
            getStdName();
        }
Exemple #25
0
        private void addNewIns()
        {
            ExamDB.Open();
            try
            {
                if (ins_Name.Text == null ||
                    ins_Name.Text == "" ||
                    ins_Name.Text.Length < 3 ||
                    adress.Text == null ||
                    adress.Text == "" ||
                    bod.Text == null ||
                    bod.Text == ""
                    )
                {
                    MessageBox.Show(" ^_^ please Enter Data Frist ^_^");
                }
                else
                {
                    SqlCommand cmd = new SqlCommand("addInstructor", ExamDB);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@insName", SqlDbType.NVarChar).Value = ins_Name.Text.ToString().Trim();
                    cmd.Parameters.AddWithValue("@salary", SqlDbType.Decimal).Value   = salary.Text.ToString().Trim();
                    cmd.Parameters.AddWithValue("@hireDate", SqlDbType.Date).Value    = hireData.Value.Date.ToString().Split(' ')[0];
                    cmd.Parameters.AddWithValue("@addr", SqlDbType.NVarChar).Value    = adress.Text.ToString().Trim();
                    cmd.Parameters.AddWithValue("@BirthDate", SqlDbType.Date).Value   = bod.Value.Date.ToString().Split(' ')[0];
                    cmd.Parameters.AddWithValue("@depId", SqlDbType.Int).Value        = ins_id;
                    SqlDataReader CMD = cmd.ExecuteReader();
                    int           Std = 0;
                    while (CMD.Read())
                    {
                        Std = int.Parse(CMD["Ins_id"].ToString());
                    }
                    CMD.Close();
                    ins_Name.Text = salary.Text = hireData.Text = bod.Text = adress.Text = String.Empty;
                    int Crs = 0;

                    for (int i = 0; i < checkedCrs.Count; i++)
                    {
                        SqlCommand chcrs = new SqlCommand("addCrsIns", ExamDB);
                        chcrs.CommandType = CommandType.StoredProcedure;
                        chcrs.Parameters.AddWithValue("@insid", SqlDbType.Int).Value = Std;
                        chcrs.Parameters.AddWithValue("@crsid", SqlDbType.Int).Value = checkedCrs[i];
                        Crs = chcrs.ExecuteNonQuery();
                    }

                    MessageBox.Show("^_^ You Added New Instructor ^_^");
                }
            }
            catch
            {
                MessageBox.Show("^_^ Please Enter Valid Data ^_^");
            }
            ExamDB.Close();
        }
Exemple #26
0
        private void ctrl_btn_ok_Click(object sender, EventArgs e)
        {
            if (IsValidData()) //need to add validation
            {
                if (isAdd)     //user clicks *ADD* button| true is just a placeholder
                {
                    Exam newExam = new Exam();
                    newExam.Administrator = Exam.Administrator;
                    this.PutExamData(newExam);

                    try
                    {
                        Exam.ExamID       = ExamDB.AddExam(newExam); //AddExam from ExamDb
                        this.DialogResult = DialogResult.OK;
                        MessageBox.Show("Add Successful!");
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, ex.GetType().ToString());
                    }
                }
                else //user clicks *UPDATE* button
                {
                    Exam newExam = new Exam();
                    newExam.ExamID = Exam.ExamID;

                    this.PutExamData(newExam);
                    try
                    {
                        //Return error if update failed
                        if (!ExamDB.UpdateExam(Exam, newExam))
                        {
                            MessageBox.Show("Another user has updated or " +
                                            "deleted that exam.", "Database Error");
                            this.DialogResult = DialogResult.Retry;
                        }
                        else //Set the new exam as the form's exam and show success message
                        {
                            Exam = newExam;
                            this.DialogResult = DialogResult.OK;
                            MessageBox.Show("Update Successful!");
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, ex.GetType().ToString());
                    }

                    this.Close();
                }
            }
        }//end ok button click
        public static void seed(ExamDB context)
        {
            IList <ResultType> ResultTypes = new List <ResultType>()
            {
            };

            foreach (var item in ResultTypes)
            {
                context.ResultType.Add(item);
            }

            context.SaveChanges();
        }
Exemple #28
0
        public static void seed(ExamDB context)
        {
            IList <Faculty> Faculties = new List <Faculty>()
            {
            };

            foreach (var item in Faculties)
            {
                context.Faculty.Add(item);
            }

            context.SaveChanges();
        }
        public static void seed(ExamDB context)
        {
            IList <Designations> Designations = new List <Designations>()
            {
                new Designations()
                {
                    id         = 1,
                    Title      = "Admin",
                    created_at = DateTime.Now,
                    edited_at  = DateTime.Now
                },
                new Designations()
                {
                    id         = 2,
                    Title      = "Lecturer",
                    created_at = DateTime.Now,
                    edited_at  = DateTime.Now
                },
                new Designations()
                {
                    id         = 3,
                    Title      = "Lab_Incharge",
                    created_at = DateTime.Now,
                    edited_at  = DateTime.Now
                },
                new Designations()
                {
                    id         = 4,
                    Title      = "Worker",
                    created_at = DateTime.Now,
                    edited_at  = DateTime.Now
                },
                new Designations()
                {
                    id         = 5,
                    Title      = "Student",
                    created_at = DateTime.Now,
                    edited_at  = DateTime.Now
                },
            };

            foreach (var item in Designations)
            {
                context.Designations.Add(item);
            }

            context.SaveChanges();
        }
Exemple #30
0
        public static void seed(ExamDB db)
        {
            USER             user       = db.User.Find(1);
            IList <Activity> Activities = new List <Activity>()
            {
                // new Activity{Id=, Title = "", Description = ""},
                //new Activity{Id=1, Title = "Create User", Description = "For creating new user"},
            };

            foreach (var item in Activities)
            {
                db.Activity.Add(item);
            }

            db.SaveChanges();
        }