Ejemplo n.º 1
0
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex >= 0)
            {
                DataGridViewRow row = this.dataGridView1.Rows[e.RowIndex];

                if (selectedItem == 0)
                {
                    studentId          = Convert.ToInt32(row.Cells["id"].Value.ToString());
                    TB_studentNo.Text  = row.Cells["studentNo"].Value.ToString();
                    TB_name.Text       = row.Cells["name"].Value.ToString();
                    TB_lastName.Text   = row.Cells["lastName"].Value.ToString();
                    TB_birthPlace.Text = row.Cells["birthPlace"].Value.ToString();
                    TB_birthYear.Text  = row.Cells["birthYear"].Value.ToString();
                }
                else if (selectedItem == 1)
                {
                    TB_lessonsStudentNo.Text = row.Cells["studentNo"].Value.ToString();
                    if (row.Cells["bm100"].Value.ToString() == "1")
                    {
                        CLB_studentLessons.SetItemChecked(0, true);
                    }
                    if (row.Cells["bm200"].Value.ToString() == "1")
                    {
                        CLB_studentLessons.SetItemChecked(1, true);
                    }
                    if (row.Cells["bm300"].Value.ToString() == "1")
                    {
                        CLB_studentLessons.SetItemChecked(2, true);
                    }
                }
                else if (selectedItem == 2)
                {
                    updateResultGroup.Controls.Clear();
                    int i = 4;
                    TB_resultsStudentNo.Text = row.Cells["studentNo"].Value.ToString();
                    while (i < 7)
                    {
                        if (row.Cells[i].Value.ToString() != "0")
                        {
                            row.HeaderCell.Value = "BM" + (i * 100 - 300).ToString();
                            Control[] objs    = new Control[2];
                            Label     side    = new Label();
                            TextBox   results = new TextBox();
                            objs[0]          = side;
                            objs[1]          = results;
                            side.Text        = row.HeaderCell.Value.ToString();
                            side.Location    = new Point(6, 63 + loc);
                            results.Location = new Point(112, 60 + loc);
                            results.Name     = "TB_" + row.HeaderCell.Value.ToString();
                            updateResultGroup.Controls.AddRange(objs);
                            loc += 30;
                        }
                        i++;
                    }
                    loc = 0;
                }
            }
        }
Ejemplo n.º 2
0
        private void getInfo(int b)
        {
            string studentNo = "";

            if (b != 0)
            {
                for (int i = 0; i < table.Rows.Count; i++)
                {
                    if (table.Rows[i][1].ToString() == TB_studentNo.Text)
                    {
                        studentNo          = table.Rows[i][1].ToString();
                        TB_name.Text       = table.Rows[i][2].ToString();
                        TB_lastName.Text   = table.Rows[i][3].ToString();
                        TB_birthYear.Text  = table.Rows[i][4].ToString();
                        TB_birthPlace.Text = table.Rows[i][5].ToString();
                        num = i;
                        break;
                    }
                }
            }
            else
            {
                if (num < table.Rows.Count && num >= 0)
                {
                    studentNo          = table.Rows[num][1].ToString();
                    TB_name.Text       = table.Rows[num][2].ToString();
                    TB_lastName.Text   = table.Rows[num][3].ToString();
                    TB_birthYear.Text  = table.Rows[num][4].ToString();
                    TB_birthPlace.Text = table.Rows[num][5].ToString();
                }
            }
            // Ders Kayıtlarını Al
            string     query = "SELECT * FROM lessons WHERE studentNo = '" + studentNo + "'";
            SqlCommand cmd   = new SqlCommand(query, conn);

            conn.Open();
            SqlDataReader read = cmd.ExecuteReader();

            while (read.Read())
            {
                if (read[2].ToString() == "1")
                {
                    CLB_studentLessons.SetItemChecked(0, true);
                }
                if (read[3].ToString() == "1")
                {
                    CLB_studentLessons.SetItemChecked(1, true);
                }
                if (read[4].ToString() == "1")
                {
                    CLB_studentLessons.SetItemChecked(2, true);
                }
            }
            read.Close();
            // Ders Kayıtlarını Al
            query           = "SELECT * FROM examsResults WHERE studentNo = '" + studentNo + "'";
            cmd.CommandText = query;
            read            = cmd.ExecuteReader();
            while (read.Read())
            {
                TB_bm100.Text = read[2].ToString();
                TB_bm200.Text = read[3].ToString();
                TB_bm300.Text = read[4].ToString();
            }

            conn.Close();
        }