Beispiel #1
0
        //Xóa môn học
        public void MonHoc_Del(string ID)
        {
            MonHoc monHoc = db.MonHocs.FirstOrDefault(x => x.ID == ID);

            if (monHoc != null)
            {
                monHoc.IsDeleted = true;
                //db.MonHocs.DeleteOnSubmit(monHoc);
                db.SubmitChanges();
            }
        }
Beispiel #2
0
        public void xoaMonHoc(MonHoc mh)
        {
            string sqlUpdate = "delete from MonHoc where maMon=@maMon";

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

            cmd.Parameters.AddWithValue("maMon", mh.MaMon);
            cmd.ExecuteNonQuery();
            KetNoiCSDL.dongKetNoi();
        }
Beispiel #3
0
        public int Xoa(MonHoc x)
        {
            int n = 1;

            string[] name  = new string[n];
            object[] value = new object[n];
            name[0]  = "@MaMon";
            value[0] = x.MaMon;
            string sql = "delete MonHoc where MaMon=@MaMon";

            return(Update(sql, name, value, n));
        }
Beispiel #4
0
        public DataTable Xem(MonHoc x)
        {
            Open();
            string     sql = "select * from MonHoc where MaMon=@MaMon";
            SqlCommand cmd = new SqlCommand(sql, conn);

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

            dt.Load(dr);
            return(dt);
        }
Beispiel #5
0
        public void suaMonHoc(MonHoc mh)
        {
            string sqlUpdate = "update MonHoc set  tenMon =@tenMon , soTiet =@soTiet where maMon =@maMon ";

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

            cmd.Parameters.AddWithValue("maMon", mh.MaMon);
            cmd.Parameters.AddWithValue("tenMon", mh.TenMon);
            cmd.Parameters.AddWithValue("soTiet", mh.SoTiet);
            cmd.ExecuteNonQuery();
            KetNoiCSDL.dongKetNoi();
        }
Beispiel #6
0
        public void themMonHoc(MonHoc mh)
        {
            string sqlSelect = "insert into MonHoc values(@maMon ,@tenMon ,@soTiet)";

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

            cmd.Parameters.AddWithValue("maMon", mh.MaMon);
            cmd.Parameters.AddWithValue("tenMon", mh.TenMon);
            cmd.Parameters.AddWithValue("soTiet", mh.SoTiet);
            cmd.ExecuteNonQuery();
            KetNoiCSDL.dongKetNoi();
        }
Beispiel #7
0
        //Thêm môn học
        public void MonHoc_Add(int Khoi, string maMon, string tenMon)
        {
            string ID     = System.Guid.NewGuid().ToString();
            MonHoc monHoc = new MonHoc();

            monHoc.ID         = ID;
            monHoc.Khoi       = Khoi;
            monHoc.MaMonHoc   = maMon;
            monHoc.TenMonHoc  = tenMon;
            monHoc.SoCauHoi   = 0;
            monHoc.CreateDate = DateTime.Now.Date;
            monHoc.InUsed     = false;
            monHoc.IsDeleted  = false;
            db.MonHocs.InsertOnSubmit(monHoc);
            db.SubmitChanges();
        }
 public bool Sua(MonHoc mh)
 {
     try
     {
         string query = @" UPDATE dbo.MonHoc set Ten = N'" + mh.Ten + "', heso = '" + mh.HeSo + "' where mamh = '" + mh.MaMH + "'";
         OpenConection();
         ExecuteQueries(query);
         CloseConnection();
         return(true);
     }
     catch (Exception ex)
     {
         SetEx(ex);
         return(false);
     }
 }
Beispiel #9
0
        public int Sua(MonHoc x)
        {
            int n = 3;

            string[] name  = new string[n];
            object[] value = new object[n];
            name[0]  = "@MaMon";
            name[1]  = "@TenMon";
            name[2]  = "@SoTiet";
            value[0] = x.MaMon;
            value[1] = x.TenMon;
            value[2] = x.SoTiet;
            string sql = "update MonHoc set TenMon=@TenMon, SoTiet=@SoTiet where MaMon=@MaMon";

            return(Update(sql, name, value, n));
        }
Beispiel #10
0
        public int Them(MonHoc x)
        {
            int n = 3;

            string[] name  = new string[n];
            object[] value = new object[n];
            name[0]  = "@MaMon";
            name[1]  = "@TenMon";
            name[2]  = "@SoTiet";
            value[0] = x.MaMon;
            value[1] = x.TenMon;
            value[2] = x.SoTiet;
            string sql = "insert into MonHoc values(@MaMon,@TenMon,@SoTiet)";

            return(Update(sql, name, value, n));
        }
 public bool Them(MonHoc mh)
 {
     try
     {
         string query = @"INSERT INTO dbo.MonHoc
     VALUES  ( '" + mh.MaMH + "',N'" + mh.Ten + "', '" + mh.HeSo + "')";
         OpenConection();
         ExecuteQueries(query);
         CloseConnection();
         return(true);
     }
     catch (Exception ex)
     {
         SetEx(ex);
         return(false);
     }
 }
Beispiel #12
0
        //Duyệt môn học
        public void MonHoc_Change(string ID)
        {
            MonHoc monHoc = db.MonHocs.FirstOrDefault(x => x.ID == ID);

            if (monHoc != null)
            {
                if (monHoc.InUsed == false)
                {
                    monHoc.InUsed = true;
                }
                else
                {
                    monHoc.InUsed = false;
                }
                db.SubmitChanges();
            }
        }
Beispiel #13
0
        public List <MonHoc> layMonHoc()
        {
            List <MonHoc> arr = new List <MonHoc>();

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

            while (dr.Read())
            {
                MonHoc x = new MonHoc(dr["maMon"] + "", dr["tenMon"] + "", float.Parse(dr["soTiet"] + ""));
                arr.Add(x);
            }
            KetNoiCSDL.dongKetNoi();
            return(arr);
        }
Beispiel #14
0
        public List <MonHoc> layMonHocTheoDieuKien(string maMon)
        {
            List <MonHoc> arr = new List <MonHoc>();

            KetNoiCSDL.moKetNoi();
            string     get = "select * from MonHoc where maMon = @maMon";
            SqlCommand cmd = new SqlCommand(get, KetNoiCSDL.connect);

            cmd.Parameters.AddWithValue("maMon", maMon);
            SqlDataReader dr = cmd.ExecuteReader();

            while (dr.Read())
            {
                MonHoc x = new MonHoc(dr["maMon"] + "", dr["tenMon"] + "", float.Parse(dr["soTiet"] + ""));
                arr.Add(x);
            }
            KetNoiCSDL.dongKetNoi();
            return(arr);
        }
 partial void DeleteMonHoc(MonHoc instance);
 partial void UpdateMonHoc(MonHoc instance);
 partial void InsertMonHoc(MonHoc instance);
 partial void InsertMonHoc(MonHoc instance);
 partial void DeleteMonHoc(MonHoc instance);
 partial void UpdateMonHoc(MonHoc instance);