예제 #1
0
        /// <summary>
        /// cập nhật môn học
        /// </summary>
        /// <param name="mamh"></param>
        /// <param name="tenmh"></param>
        /// <param name="sochi"></param>
        public void update(string masv, string mamh, double diem, int lanthu, string ghichu, string hocki)
        {
            try
            {
                dbConnect.Open();
                Diemsv obj = (from Diemsv o in dbConnect.db
                              where (o.Mamh == mamh) && (o.Masv == masv)
                              select o).FirstOrDefault();
                if (obj != null)
                {
                    obj.Diem   = diem;
                    obj.Lanthu = lanthu;
                    obj.Ghichu = ghichu;
                    obj.Hocki  = hocki;
                    dbConnect.db.Store(obj);
                }

                dbConnect.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                dbConnect.Close();
            }
        }
예제 #2
0
        /// <summary>
        /// thêm môn học
        /// </summary>
        /// <param name="mamh"></param>
        /// <param name="tenmh"></param>
        /// <param name="sochi"></param>
        public void add(string masv, string mamh, double diem, int lanthu, string ghichu, string hocki)
        {
            Diemsv obj = new Diemsv();

            obj.Masv   = masv;
            obj.Mamh   = mamh;
            obj.Diem   = diem;
            obj.Lanthu = lanthu;
            obj.Ghichu = ghichu;
            obj.Hocki  = hocki;

            try
            {
                dbConnect.Open();
                dbConnect.db.Store(obj);
                dbConnect.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                dbConnect.Close();
            }
        }
예제 #3
0
        /// <summary>
        /// thêm môn học
        /// </summary>
        /// <param name="mamh"></param>
        /// <param name="tenmh"></param>
        /// <param name="sochi"></param>
        public void add(string masv, string mamh, double diem, int lanthu, string ghichu, string hocki)
        {
            Diemsv obj = new Diemsv();
            obj.Masv = masv;
            obj.Mamh = mamh;
            obj.Diem = diem;
            obj.Lanthu = lanthu;
            obj.Ghichu = ghichu;
            obj.Hocki = hocki;

            try
            {
                dbConnect.Open();
                dbConnect.db.Store(obj);
                dbConnect.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                dbConnect.Close();
            }
        }
예제 #4
0
        /// <summary>
        /// Kiểm tra mã môn học có trong csdl chưa
        /// </summary>
        /// <param name="mamh"></param>
        /// <returns></returns>
        public bool isExist(string mamh, string mssv)
        {
            Diemsv obj = this.getById(mamh, mssv);

            if (obj == null)
            {
                return(false);
            }
            return(true);
        }
예제 #5
0
        /// <summary>
        /// lấy môn học theo mã
        /// </summary>
        /// <param name="ma"></param>
        /// <returns></returns>
        public Diemsv getById(string ma, string mssv)
        {
            Diemsv obj = null;

            try
            {
                dbConnect.Open();
                obj = (from Diemsv o in dbConnect.db
                       where (o.Mamh == ma) && (o.Masv == mssv)
                       select o).FirstOrDefault();
                dbConnect.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                dbConnect.Close();
            }

            return(obj);
        }
예제 #6
0
        /// <summary>
        /// xóa môn học
        /// </summary>
        /// <param name="ma"></param>
        public void delete(string mamh, string mssv)
        {
            try
            {
                dbConnect.Open();
                Diemsv obj = (from Diemsv o in dbConnect.db
                              where (o.Mamh == mamh) && (o.Masv == mssv)
                              select o).FirstOrDefault();
                if (obj != null)
                {
                    dbConnect.db.Delete(obj);
                }

                dbConnect.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                dbConnect.Close();
            }
        }