Exemplo n.º 1
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();
 }
Exemplo n.º 2
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();
 }
Exemplo n.º 3
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();
        }
Exemplo n.º 4
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();
 }
Exemplo n.º 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 ^_^");
            }
        }
Exemplo n.º 6
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();
 }
Exemplo n.º 7
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 !! ");
            }
        }
Exemplo n.º 8
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 ^_^");
            }
        }
Exemplo n.º 9
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 ^_^");
     }
 }
Exemplo n.º 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();
 }
Exemplo n.º 11
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();
        }
Exemplo n.º 12
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();
        }
Exemplo n.º 13
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();
        }
Exemplo n.º 14
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();
        }
Exemplo n.º 15
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();
        }
Exemplo n.º 16
0
 public void getStdData()
 {
     ExamDB.Open();
     try
     {
         SqlCommand std = new SqlCommand("getAllStd", ExamDB);
         std.CommandType = CommandType.StoredProcedure;
         DataTable dt = new DataTable();
         dt.Load(std.ExecuteReader());
         dataGridView1.DataSource = dt;
     }
     catch
     {
         MessageBox.Show("^_^ Please Enter Data Load ^_^");
     }
     ExamDB.Close();
 }
Exemplo n.º 17
0
 private void GetCrsTopic()
 {
     ExamDB.Open();
     try
     {
         SqlCommand std = new SqlCommand("getCrsTopic", ExamDB);
         std.CommandType = CommandType.StoredProcedure;
         DataTable dt = new DataTable();
         dt.Load(std.ExecuteReader());
         dataGridView2.DataSource = dt;
     }
     catch
     {
         MessageBox.Show("^_^ Please Enter Valid Data ^_^");
     }
     ExamDB.Close();
 }
Exemplo n.º 18
0
 private void GetallStdCourse()
 {
     ExamDB.Open();
     try
     {
         SqlCommand std = new SqlCommand("getAllStdinCrs", ExamDB);
         std.CommandType = CommandType.StoredProcedure;
         DataTable dTable = new DataTable();
         std.Parameters.AddWithValue("@name", SqlDbType.VarChar).Value = std_crs.Text.Trim().ToString();
         dTable.Load(std.ExecuteReader());
         dataGridView3.DataSource = dTable;
     }
     catch
     {
         MessageBox.Show("^_^ Please Enter Valid Data ^_^");
     }
     ExamDB.Close();
 }
Exemplo n.º 19
0
 private void NewStudentPage()
 {
     try
     {
         ExamDB.Open();
         SqlCommand std = new SqlCommand("getdept", ExamDB);
         std.CommandType = CommandType.StoredProcedure;
         SqlDataReader Std = std.ExecuteReader();
         while (Std.Read())
         {
             dic.Add(int.Parse(Std["Manger Code"].ToString()), Std["Department Name"].ToString());
             dept.Items.Add(Std["Department Name"]).ToString();
         }
         Std.Close();
         ExamDB.Close();
         ExamDB.Open();
         SqlCommand crs = new SqlCommand("getAllcours", ExamDB);
         std.CommandType = CommandType.StoredProcedure;
         SqlDataReader Crs = crs.ExecuteReader();
         while (Crs.Read())
         {
             dic1.Add(int.Parse(Crs["Course Code"].ToString()), Crs["Course Name"].ToString());
         }
         Crs.Close();
         ExamDB.Close();
         int x = 10;
         foreach (var item in dic1)
         {
             x += 30;
             CheckBox cb = new CheckBox();
             cb.AutoSize        = true;
             cb.Location        = new Point(800, 160 + x);
             cb.Text            = item.Value;
             cb.Name            = item.Key.ToString();
             cb.CheckedChanged += CourseName;
             tabPage2.Controls.Add(cb);
         }
     }
     catch
     {
         MessageBox.Show("^_^ Please Enter Valid Data ^_^");
     }
 }
Exemplo n.º 20
0
        private void GetNewStdDataOnLoad()
        {
            deptDic.Clear();
            ExamDB.Open();
            SqlCommand std = new SqlCommand("getdept", ExamDB);

            std.CommandType = CommandType.StoredProcedure;
            SqlDataReader Std = std.ExecuteReader();

            while (Std.Read())
            {
                deptDic.Add(int.Parse(Std["Manger Code"].ToString()), Std["Department Name"].ToString());
                deptName.Items.Add(Std["Department Name"]).ToString();
                name_dept.Items.Add(Std["Department Name"]).ToString();
            }
            Std.Close();
            ExamDB.Close();
            ExamDB.Open();
            SqlCommand crs = new SqlCommand("getAllcours", ExamDB);

            std.CommandType = CommandType.StoredProcedure;
            SqlDataReader Crs = crs.ExecuteReader();

            while (Crs.Read())
            {
                coursDic.Add(int.Parse(Crs["Course Code"].ToString()), Crs["Course Name"].ToString());
            }
            Crs.Close();
            ExamDB.Close();
            int x = 10;

            foreach (var item in coursDic)
            {
                x += 30;
                CheckBox cb = new CheckBox();
                cb.AutoSize        = true;
                cb.Location        = new Point(800, 100 + x);
                cb.Text            = item.Value;
                cb.Name            = item.Key.ToString();
                cb.CheckedChanged += CourseName;
                tabPage2.Controls.Add(cb);
            }
        }
Exemplo n.º 21
0
 private void btnnew_Click(object sender, EventArgs e)
 {
     ExamDB.Open();
     try
     {
         if (stdName.Text == null ||
             stdName.Text == "" ||
             stdName.Text.Length <= 3 ||
             lastname.Text.Length <= 3 ||
             lastname.Text == null ||
             lastname.Text == "" ||
             DeptName.Text == null ||
             DeptName.Text == ""
             )
         {
             MessageBox.Show(" ^_^ please Enter a Correct Data & the name must be more or equal 3 ^_^");
         }
         else
         {
             SqlCommand edit = new SqlCommand("updateStudent", ExamDB);
             edit.CommandType = CommandType.StoredProcedure;
             edit.Parameters.AddWithValue("@id", SqlDbType.Int).Value         = stdID.SelectedItem;
             edit.Parameters.AddWithValue("@fname", SqlDbType.NVarChar).Value = stdName.Text;
             edit.Parameters.AddWithValue("@lname", SqlDbType.NVarChar).Value = lastname.Text;
             edit.Parameters.AddWithValue("@bod", SqlDbType.DateTime).Value   = dob.Value.Date.ToString().Split(' ')[0];
             edit.Parameters.AddWithValue("@add", SqlDbType.NVarChar).Value   = address.Text;
             edit.Parameters.AddWithValue("@dept", SqlDbType.Int).Value       = deptId;
             edit.ExecuteNonQuery();
             MessageBox.Show("^_^ You Updated New Student ^_^");
             ExamDB.Close();
             dob.Text = address.Text = DeptName.Text = stdName.Text = lastname.Text = string.Empty;
         }
     }
     catch
     {
         MessageBox.Show("^_^ Please Enter Valid Data ^_^");
         dob.Text = address.Text = DeptName.Text = stdName.Text = lastname.Text = string.Empty;
     }
     ExamDB.Close();
     getStdData();
     getStdName();
 }
Exemplo n.º 22
0
 //add new course
 private void save_Click(object sender, EventArgs e)
 {
     ExamDB.Open();
     try
     {
         if (crsName.Text == "" ||
             crsName.Text == null ||
             crsName.Text.Length < 2 ||
             dur.Text == null ||
             dur.Text == ""
             )
         {
             MessageBox.Show("^_^ Please Enter Valid Data ^_^");
         }
         else
         {
             SqlCommand cmd = new SqlCommand("addCourse", ExamDB);
             cmd.CommandType = CommandType.StoredProcedure;
             cmd.Parameters.AddWithValue("@crsname", SqlDbType.NVarChar).Value = crsName.Text.ToString().Trim();
             cmd.Parameters.AddWithValue("@dur", SqlDbType.Int).Value          = dur.Text.ToString().Trim();
             cmd.Parameters.AddWithValue("@insId", SqlDbType.Int).Value        = insId;
             int x = cmd.ExecuteNonQuery();
             if (x == -1)
             {
                 MessageBox.Show("^_^ course is  existed ^_^");
             }
             else
             {
                 MessageBox.Show("^_^ You Added New Course ^_^");
             }
             crsName.Text = dur.Text = String.Empty;
         }
     }
     catch
     {
         MessageBox.Show("^_^ Please Enter Valid Data ^_^");
     }
     ExamDB.Close();
     GetAllCourses();
     GetQue();
 }
Exemplo n.º 23
0
 private void getDepartMent()
 {
     ExamDB.Open();
     try
     {
         SqlCommand std = new SqlCommand("getdept", ExamDB);
         std.CommandType = CommandType.StoredProcedure;
         SqlDataReader Std = std.ExecuteReader();
         while (Std.Read())
         {
             deptNamedic.Add(int.Parse(Std["Manger Code"].ToString()), Std["Department Name"].ToString());
             DeptName.Items.Add(Std["Department Name"]).ToString();
         }
         Std.Close();
     }
     catch
     {
         MessageBox.Show("^_^ Please Enter Valid Data ^_^");
     }
     ExamDB.Close();
 }
Exemplo n.º 24
0
        //add MC Question
        private void addMCQue_Click(object sender, EventArgs e)
        {
            ExamDB.Open();
            try
            {
                if (qubox.Text == null || qubox.Text == "" ||
                    deg.Text == null || deg.Text == "" ||
                    a.Text == null || a.Text == "" ||
                    b.Text == null || c.Text == "" ||
                    d.Text == null || b.Text == "" ||
                    b.Text == null || d.Text == "" ||
                    qubox.Text.Length < 5
                    )
                {
                    MessageBox.Show(" ^_^ please Enter Data Frist ^_^");
                }
                else
                {
                    SqlCommand cmd = new SqlCommand("addNewMcQuestion", ExamDB);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@question", SqlDbType.NVarChar).Value = qubox.Text.ToString().Trim();
                    cmd.Parameters.AddWithValue("@grade", SqlDbType.Int).Value         = deg.Text.Trim().ToString();
                    cmd.Parameters.AddWithValue("@ansid", SqlDbType.Int).Value         = answer.Text.ToString().Trim();
                    cmd.Parameters.AddWithValue("@ch1", SqlDbType.Int).Value           = a.Text.ToString().Trim();
                    cmd.Parameters.AddWithValue("@ch2", SqlDbType.Int).Value           = b.Text.ToString().Trim();
                    cmd.Parameters.AddWithValue("@ch3", SqlDbType.Int).Value           = c.Text.ToString().Trim();
                    cmd.Parameters.AddWithValue("@ch4", SqlDbType.Int).Value           = d.Text.ToString().Trim();
                    cmd.Parameters.AddWithValue("@crs_id", SqlDbType.Int).Value        = MCId;
                    cmd.ExecuteNonQuery();
                    MessageBox.Show("^_^ You Added New Question ^_^");

                    qubox.Text = crsName.Text = deg.Text = answer.Text = String.Empty;
                }
            }
            catch
            {
                MessageBox.Show("^_^ Please Enter Valid Data ^_^");
            }
            ExamDB.Close();
        }
Exemplo n.º 25
0
 private void getStdName()
 {
     stdnameDic.Clear();
     ExamDB.Open();
     try
     {
         SqlCommand std = new SqlCommand("getAllStdName ", ExamDB);
         std.CommandType = CommandType.StoredProcedure;
         SqlDataReader Std = std.ExecuteReader();
         while (Std.Read())
         {
             stdnameDic.Add(int.Parse(Std["St_id"].ToString()), Std["FullName"].ToString());
             nameStd.Items.Add(Std["FullName"]).ToString();
         }
         Std.Close();
     }
     catch
     {
         MessageBox.Show("^_^ Please Enter Valid Data ^_^");
     }
     ExamDB.Close();
 }
Exemplo n.º 26
0
 private void GetCourseIns()
 {
     InsDic.Clear();
     ExamDB.Open();
     try
     {
         SqlCommand std = new SqlCommand("getDeptIns", ExamDB);
         std.CommandType = CommandType.StoredProcedure;
         SqlDataReader Std = std.ExecuteReader();
         while (Std.Read())
         {
             InsDic.Add(int.Parse(Std["Ins_id"].ToString()), Std["Name"].ToString());
             insCrs.Items.Add(Std["Name"]).ToString();
         }
         Std.Close();
     }
     catch
     {
         MessageBox.Show("^_^ Please Enter Valid Data ^_^");
     }
     ExamDB.Close();
 }
Exemplo n.º 27
0
 //get load of instructor dept data in combo box
 private void GetInsDept()
 {
     stdName.Items.Clear();
     mngDic.Clear();
     ExamDB.Open();
     try
     {
         SqlCommand std = new SqlCommand("getdept", ExamDB);
         std.CommandType = CommandType.StoredProcedure;
         SqlDataReader Std = std.ExecuteReader();
         while (Std.Read())
         {
             mngDic.Add(int.Parse(Std["Manger Code"].ToString()), Std["Department Name"].ToString());
             stdName.Items.Add(Std["Department Name"]).ToString();
         }
         Std.Close();
     }
     catch
     {
         MessageBox.Show("^_^ please enter valid data ^_^");
     }
     ExamDB.Close();
 }
Exemplo n.º 28
0
        private void DeptName_SelectedIndexChanged(object sender, EventArgs e)
        {
            stdID.Items.Clear();
            ExamDB.Open();
            try
            {
                SqlCommand std = new SqlCommand("getstdID", ExamDB);

                std.CommandType = CommandType.StoredProcedure;
                foreach (var item in deptNamedic)
                {
                    if (DeptName.SelectedItem.ToString() == item.Value)
                    {
                        deptId = item.Key;
                        break;
                    }
                }
                std.Parameters.AddWithValue("@id", SqlDbType.Int).Value = deptId;

                SqlDataReader Std = std.ExecuteReader();
                while (Std.Read())
                {
                    stdID.Items.Add(Std["St_id"]).ToString();
                }
                Std.Close();

                dob.Text = address.Text = DeptName.Text = stdName.Text = lastname.Text = string.Empty;
            }
            catch
            {
                MessageBox.Show("^_^ This Department Has No Student ^_^");
                dob.Text = address.Text = DeptName.Text = stdName.Text = lastname.Text = string.Empty;
            }

            ExamDB.Close();
            getStdName();
        }
Exemplo n.º 29
0
        private void Update_Click(object sender, EventArgs e)
        {
            ExamDB.Open();
            try
            {
                if (name.Text == null || name.Text == "" ||
                    name.Text.Length < 3 ||
                    sal.Text == null || sal.Text == "" ||
                    ads.Text == null || ads.Text == ""
                    )
                {
                    MessageBox.Show(" ^_^ please Enter Data Frist^_^");
                }
                else
                {
                    SqlCommand edit = new SqlCommand("updateInstructor", ExamDB);
                    edit.CommandType = CommandType.StoredProcedure;
                    edit.Parameters.AddWithValue("@id", SqlDbType.Int).Value         = IDINS.SelectedItem;
                    edit.Parameters.AddWithValue("@name", SqlDbType.NVarChar).Value  = name.Text;
                    edit.Parameters.AddWithValue("@salary", SqlDbType.Decimal).Value = sal.Text;
                    edit.Parameters.AddWithValue("@addr", SqlDbType.VarChar).Value   = ads.Text;
                    edit.Parameters.AddWithValue("@BirthDate", SqlDbType.Date).Value = DOB.Value.Date.ToString().Split(' ')[0];;
                    edit.Parameters.AddWithValue("@depId", SqlDbType.Int).Value      = insID;
                    edit.ExecuteNonQuery();
                    MessageBox.Show("^_^ You Updated The Instructor ^_^");

                    name.Text = sal.Text = ads.Text = string.Empty;
                }
            }
            catch
            {
                MessageBox.Show("^_^ Please Enter Valid Data ^_^");
                name.Text = sal.Text = ads.Text = string.Empty;
            }
            ExamDB.Close();
        }