Exemplo n.º 1
0
        private void button3_Click(object sender, EventArgs e)
        {
            int sex;

            SqlConnection con = new SqlConnection();

            con.ConnectionString = KetNoi.str;
            con.Open();
            SqlCommand cmd = new SqlCommand();

            cmd.Connection = con;
            string TenLop;

            TenLop          = cbxTenLop.SelectedItem.ToString();
            cmd.CommandText = "select* from Lop where TenLop ='" + TenLop + "'";
            SqlDataReader rd;

            rd = cmd.ExecuteReader();
            DataTable td = new DataTable();

            td.Load(rd);
            string MaLop = td.Rows[0][0].ToString();

            if (radioButton7.Checked == true)
            {
                sex = 0;
            }
            else
            {
                sex = 1;
            }

            cmd.CommandText = "INSERT INTO SinhVien VALUES('" + txtmaSV.Text + "','" + txtTenSV.Text + "'," + sex + ",'" + mskNgaySinh.Text + "','" + txtNoiS.Text + "','" + txtTT.Text + "','" + txtKH.Text + "','" + txtLL.Text + "','" + MaLop + "','" + hinhanh + "')";
            cmd.ExecuteNonQuery();
            con.Close();
            string strmasv;
            string strtensv;

            strtensv = txtTenSV.Text;
            strmasv  = txtmaSV.Text;
            frmthemkqSV frm = new frmthemkqSV(strmasv, strtensv);

            frm.Show();
        }
Exemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            SqlConnection con = new SqlConnection();

            con.ConnectionString = KetNoi.str;
            con.Open();
            SqlCommand cmd = new SqlCommand();

            cmd.Connection = con;
            string TenMonHoc;

            TenMonHoc       = cbxmonhoc.SelectedItem.ToString();
            cmd.CommandText = "select* from MonHoc where TenMonHoc ='" + TenMonHoc + "'";

            SqlDataReader rd;

            rd = cmd.ExecuteReader();
            DataTable td = new DataTable();

            td.Load(rd);
            string MaMonHoc = td.Rows[0][0].ToString();
            int    LanThi;

            LanThi = Convert.ToInt16(txtLanThi.Text);
            double DiemThi;

            DiemThi = Convert.ToDouble(txtDiemThi.Text);
            double TongKet;

            TongKet         = Convert.ToDouble(txtTongKet.Text);
            cmd.CommandText = "INSERT INTO KetQua VALUES('" + MaMonHoc + "','" + masv + "'," + LanThi + "," + DiemThi + "," + TongKet + ")";
            cmd.ExecuteNonQuery();
            con.Close();
            MessageBox.Show("Thêm Dữ Liệu Thành Công!");
            Close();
            frmthemkqSV frm = new frmthemkqSV(masv, tensv);

            frm.Show();
        }