Exemplo n.º 1
0
        public DataTable Xem(Lop x)
        {
            Open();
            string     sql = "select * from Lop where MaLop=@MaLop";
            SqlCommand cmd = new SqlCommand(sql, conn);

            cmd.Parameters.AddWithValue("MaLop", x.MaLop);
            DataTable     dt = new DataTable();
            SqlDataReader dr = cmd.ExecuteReader();

            dt.Load(dr);
            return(dt);
        }
Exemplo n.º 2
0
        public void suaLop(Lop l)
        {
            string sqlUpdate = "update Lop set  tenLop = @tenLop ,nienKhoa=@nienKhoa,siSo= @siSo,maCBGV= @maCBGV where maLop =@maLop ";

            KetNoiCSDL.moKetNoi();
            SqlCommand cmd = new SqlCommand(sqlUpdate, KetNoiCSDL.connect);

            cmd.Parameters.AddWithValue("maLop", l.MaLop);
            cmd.Parameters.AddWithValue("tenLop", l.TenLop);
            cmd.Parameters.AddWithValue("nienKhoa", l.NienKhoa);
            cmd.Parameters.AddWithValue("siSo", l.SiSo);
            cmd.Parameters.AddWithValue("maCBGV", l.MaCBGV);
            cmd.ExecuteNonQuery();
            KetNoiCSDL.dongKetNoi();
        }
Exemplo n.º 3
0
        public void themLop(Lop l)
        {
            string sqlSelect = "insert into Lop values(@maLop ,@tenLop ,@nienKhoa, @siSo, @maCBGV)";

            KetNoiCSDL.moKetNoi();
            SqlCommand cmd = new SqlCommand(sqlSelect, KetNoiCSDL.connect);

            cmd.Parameters.AddWithValue("maLop", l.MaLop);
            cmd.Parameters.AddWithValue("tenLop", l.TenLop);
            cmd.Parameters.AddWithValue("nienKhoa", l.NienKhoa);
            cmd.Parameters.AddWithValue("siSo", l.SiSo);
            cmd.Parameters.AddWithValue("maCBGV", l.MaCBGV);
            cmd.ExecuteNonQuery();
            KetNoiCSDL.dongKetNoi();
        }
Exemplo n.º 4
0
        public List <Lop> layLop()
        {
            List <Lop> arr = new List <Lop>();

            KetNoiCSDL.moKetNoi();
            string        get = "select * from Lop";
            SqlCommand    cmd = new SqlCommand(get, KetNoiCSDL.connect);
            SqlDataReader dr  = cmd.ExecuteReader();

            while (dr.Read())
            {
                Lop x = new Lop(dr["maLop"] + "", dr["tenLop"] + "", dr["nienKhoa"] + "", int.Parse(dr["siSo"] + ""), dr["maCBGV"] + "");
                arr.Add(x);
            }
            KetNoiCSDL.dongKetNoi();
            return(arr);
        }
Exemplo n.º 5
0
        public int Sua(Lop x)
        {
            int n = 5;

            string[] name  = new string[n];
            object[] value = new object[n];
            name[0]  = "@MaLop";
            name[1]  = "@TenLop";
            name[2]  = "@NienKhoa";
            name[3]  = "@SiSo";
            name[4]  = "@GVCN";
            value[0] = x.MaLop;
            value[1] = x.TenLop;
            value[2] = x.NienKhoa;
            value[3] = x.SiSo;
            value[4] = x.GiaoVienChuNhiem;
            string sql = "update Lop set TenLop=@TenLop, NienKhoa=@NienKhoa, SiSo=@SiSo, GiaoVienChuNhiem=@GVCN where MaLop=@MaLop";

            return(Update(sql, name, value, n));
        }
Exemplo n.º 6
0
        public int Them(Lop x)
        {
            int n = 5;

            string[] name  = new string[n];
            object[] value = new object[n];
            name[0]  = "@MaLop";
            name[1]  = "@TenLop";
            name[2]  = "@NienKhoa";
            name[3]  = "@SiSo";
            name[4]  = "@GVCN";
            value[0] = x.MaLop;
            value[1] = x.TenLop;
            value[2] = x.NienKhoa;
            value[3] = x.SiSo;
            value[4] = x.GiaoVienChuNhiem;
            string sql = "insert into Lop values(@MaLop,@TenLop,@NienKhoa,@SiSo,@GVCN)";

            return(Update(sql, name, value, n));
        }
Exemplo n.º 7
0
        public bool Insert(Lop lop)
        {
            try
            {
                string         query       = "SELECT * FROM Lop";
                SqlDataAdapter dataAdapter = new SqlDataAdapter(query, connection);
                table = GetData();
                DataRow row = table.NewRow();
                row["tenLop"]  = lop.TenLop;
                row["DonViId"] = lop.DonViId;

                table.Rows.Add(row);

                SqlCommandBuilder sqlCommandBuilder = new SqlCommandBuilder(dataAdapter);
                dataAdapter.Update(table);

                return(true);
            }
            catch
            {
                return(false);
            }
        }
Exemplo n.º 8
0
 private void detach_Lops(Lop entity)
 {
     this.SendPropertyChanging();
     entity.GiaoVien = null;
 }
Exemplo n.º 9
0
 private void attach_Lops(Lop entity)
 {
     this.SendPropertyChanging();
     entity.GiaoVien = this;
 }
Exemplo n.º 10
0
 partial void DeleteLop(Lop instance);
Exemplo n.º 11
0
 partial void UpdateLop(Lop instance);
Exemplo n.º 12
0
 partial void InsertLop(Lop instance);