private void frm_SelectStudent_Load(object sender, EventArgs e)
        {
            ob = new class_Application();
            s = "select user_id,user_name from user_access";
            ds = ob.fill_data_set(s);


            DataGridViewCheckBoxColumn chk = new DataGridViewCheckBoxColumn();
            dataGridView1.Columns.Add("user_id", "USER ID");
            dataGridView1.Columns.Add("user_name", "USER NAME");
            dataGridView1.Columns.Add(chk);
            dataGridView1.Columns[2].HeaderText = "SELECT";
            dataGridView1.Columns[2].Name = "select";
            dataGridView1.RowHeadersVisible = false;
            dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
            dataGridView1.Columns[0].SortMode = DataGridViewColumnSortMode.Programmatic;
            dataGridView1.Columns[1].SortMode = DataGridViewColumnSortMode.Programmatic;
            dataGridView1.Columns[2].SortMode = DataGridViewColumnSortMode.Programmatic;



            dataGridView1.Rows.Add(ds.Tables[0].Rows.Count);
            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {   dataGridView1.Rows[i].Cells["user_id"].Value = ds.Tables[0].Rows[i]["user_id"];
                dataGridView1.Rows[i].Cells["user_name"].Value = ds.Tables[0].Rows[i]["user_name"];
            }


        }
        //---form load event-------->
        private void frm_select_exam_Load(object sender, EventArgs e)
        {
            ob = new class_Application();
            s = null;
            
            
             s="SELECT Test_Master.Exam_code, Test_Master.Test_code, Exam_Master.Exam_Name, Test_Master.Test_Name,"+
              " Test_Master.Test_Duration FROM (Exam_Master INNER JOIN Test_Master ON"+
              " Exam_Master.Exam_Code = Test_Master.Exam_code) INNER JOIN Questions_Master "+
              "ON (Exam_Master.Exam_Code = Questions_Master.Exam_code) AND (Test_Master.Test_code = Questions_Master.Test_code)"+
              " AND (Test_Master.Exam_code = Questions_Master.Exam_code);";
             ds = ob.fill_data_set(s);

             var query = from p in ds.Tables[0].AsEnumerable()
                         group p by new
                         {
                             ExamCode=p.Field<string>(0),
                             TestCode=p.Field<string>(1),
                             ExamNmae=p.Field<string>(2),
                             TestName=p.Field<string>(3),
                             Duration=p.Field<int>(4)
                         } into grp
                         select new
                         {
                             ExamCode = grp.Key.ExamCode,
                             TestCode = grp.Key.TestCode,
                             ExamNmae = grp.Key.ExamNmae,
                             TestName = grp.Key.TestName,
                             Duration = grp.Key.Duration 
                         };


          
             DataTable dt_table = new DataTable();
             dt_table.Columns.Add("ExamCode", typeof(string));
             dt_table.Columns.Add("TestCode", typeof(string));
             dt_table.Columns.Add("ExamName", typeof(string));
             dt_table.Columns.Add("TestName", typeof(string));
             dt_table.Columns.Add("Duration", typeof(int));
             DataRow combo_row;

             foreach (var grp in query)
             {   combo_row = dt_table.NewRow();
                 combo_row["ExamCode"] = grp.ExamCode;
                 combo_row["TestCode"] = grp.TestCode;
                 combo_row["ExamName"] = grp.ExamNmae;
                 combo_row["TestName"] = grp.TestName;
                 combo_row["Duration"] = grp.Duration;
                 dt_table.Rows.Add(combo_row);
            }

          
            comboBox1.DataSource = dt_table;
            comboBox1.DisplayMember = "ExamName";
            
         }
Ejemplo n.º 3
0
        //---button click event for successful login--->
        private void button1_Click(object sender, EventArgs e)
        {
            string s;
            s = null;
            DataSet ds = new DataSet();
            ob = new class_Application();
            s = "SELECT User_Access.User_ID,user_name,user_role FROM User_Access where user_name='"+ textBox1.Text.ToUpper() +"' and user_password='******' and is_active=1;";
            ds = ob.fill_data_set(s);

         


  


            //---elaborate login code will go in here----->
            if (ds.Tables[0].Rows.Count>0 && Convert.ToString(ds.Tables[0].Rows[0][2]).Equals("ADMIN"))
            {   class_Application.user_id = Convert.ToString(ds.Tables[0].Rows[0][0]);
                class_Application.user_name = Convert.ToString(ds.Tables[0].Rows[0][1]);
                class_Application.parent_form.enable_admin_menu();
                this.Close();
            }

               

            else if (ds.Tables[0].Rows.Count > 0 && Convert.ToString(ds.Tables[0].Rows[0][2]).Equals("USER"))
            {
                class_Application.user_id = Convert.ToString(ds.Tables[0].Rows[0][0]);
                class_Application.user_name = Convert.ToString(ds.Tables[0].Rows[0][1]);
                class_Application.parent_form.enable_user_menu();
                this.Close();
            }


            else
            {
                MessageBox.Show("Please check your login id or password");
            }
        }