Пример #1
0
        private void btn_show_Click(object sender, EventArgs e)
        {
            try
            {
                BLL_SV bll_sv = new BLL_SV();

                dataGridView1.DataSource = bll_sv.Show();
            }catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #2
0
        private void btn_delete_Click(object sender, EventArgs e)
        {
            try {
                BLL_SV bll_sv = new BLL_SV();

                int index = dataGridView1.CurrentCell.RowIndex;

                string id = dataGridView1.Rows[index].Cells["MSSV"].Value.ToString();

                bll_sv.Delete(id);

                dataGridView1.DataSource = bll_sv.Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #3
0
        private void btn_Add_Click(object sender, EventArgs e)
        {
            try
            {
                BLL_SV bll_sv = new BLL_SV();

                SinhVien sv = new SinhVien()
                {
                    MSSV    = txt_MSSV.Text,
                    Name    = txt_SV.Text,
                    ID_Khoa = txt_ID_Khoa.Text,
                };

                bll_sv.Add(sv);

                dataGridView1.DataSource = bll_sv.Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #4
0
        private void btn_dtgrv_sql_Click(object sender, EventArgs e)
        {
            try
            {
                BLL_SV bll_sv = new BLL_SV();

                for (int i = 0; i < dataGridView1.RowCount - 1; i++)
                {
                    SinhVien sv = new SinhVien()
                    {
                        MSSV    = dataGridView1.Rows[i].Cells[0].Value.ToString(),
                        Name    = dataGridView1.Rows[i].Cells[1].Value.ToString(),
                        ID_Khoa = dataGridView1.Rows[i].Cells[2].Value.ToString(),
                    };

                    bll_sv.Add(sv);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #5
0
        private void btn_Update_Click(object sender, EventArgs e)
        {
            try
            {
                BLL_SV bll_sv = new BLL_SV();

                SinhVien sv = new SinhVien()
                {
                    Name    = txt_SV.Text,
                    ID_Khoa = txt_ID_Khoa.Text,
                };

                int index = dataGridView1.CurrentCell.RowIndex;

                string id = dataGridView1.Rows[index].Cells["MSSV"].Value.ToString();

                bll_sv.Update(id, sv);

                dataGridView1.DataSource = bll_sv.Show();
            }catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }