Пример #1
0
        //Hàm xóa
        public void XoaDuLieu(EC_BuoiHoc_HocSinh ec)
        {
            SqlCommand cmd = new SqlCommand();

            cmd.CommandText = "dbo.[BuoiHoc_HocSinh_Delete]";
            cmd.CommandType = CommandType.StoredProcedure;

            try
            {
                con.MoKetNoi();
                // Use connection object of base class
                cmd.Connection = con.connect;

                cmd.Parameters.AddWithValue("@Ma_HocSinh", ec.Ma_HocSinh);
                cmd.Parameters.AddWithValue("@Ma_BuoiHoc", ec.Ma_BuoiHoc);

                cmd.ExecuteNonQuery();
                return;
            }
            catch (Exception e)
            {
                throw new Exception("Lỗi khi xóa buổi học của học sinh");
            }
            finally
            {
                con.DongKetNoi();
                cmd.Dispose();
            }
        }
Пример #2
0
        /// <summary>
        /// Populate business object from data reader
        /// </summary>
        /// <param name="businessObject">business object</param>
        /// <param name="dataReader">data reader</param>
        internal void PopulateBusinessObjectFromReader(EC_BuoiHoc_HocSinh businessObject, IDataReader dataReader)
        {
            businessObject.Ma_BuoiHoc = dataReader.GetString(dataReader.GetOrdinal(EC_BuoiHoc_HocSinh.BuoiHoc_HocSinh_Fields.Ma_BuoiHoc.ToString()));

            if (!dataReader.IsDBNull(dataReader.GetOrdinal(EC_BuoiHoc_HocSinh.BuoiHoc_HocSinh_Fields.Ma_HocSinh.ToString())))
            {
                businessObject.Ma_HocSinh = dataReader.GetString(dataReader.GetOrdinal(EC_BuoiHoc_HocSinh.BuoiHoc_HocSinh_Fields.Ma_HocSinh.ToString()));
            }

            if (!dataReader.IsDBNull(dataReader.GetOrdinal(EC_BuoiHoc_HocSinh.BuoiHoc_HocSinh_Fields.DiemDanh.ToString())))
            {
                businessObject.DiemDanh = dataReader.GetBoolean(dataReader.GetOrdinal(EC_BuoiHoc_HocSinh.BuoiHoc_HocSinh_Fields.DiemDanh.ToString()));
            }

            if (!dataReader.IsDBNull(dataReader.GetOrdinal(EC_BuoiHoc_HocSinh.BuoiHoc_HocSinh_Fields.DanhGia.ToString())))
            {
                businessObject.DanhGia = dataReader.GetString(dataReader.GetOrdinal(EC_BuoiHoc_HocSinh.BuoiHoc_HocSinh_Fields.DanhGia.ToString()));
            }

            if (!dataReader.IsDBNull(dataReader.GetOrdinal(EC_BuoiHoc_HocSinh.BuoiHoc_HocSinh_Fields.DongTien.ToString())))
            {
                businessObject.DongTien = dataReader.GetBoolean(dataReader.GetOrdinal(EC_BuoiHoc_HocSinh.BuoiHoc_HocSinh_Fields.DongTien.ToString()));
            }

            if (!dataReader.IsDBNull(dataReader.GetOrdinal(EC_BuoiHoc_HocSinh.BuoiHoc_HocSinh_Fields.SoTien_Buoi.ToString())))
            {
                businessObject.SoTien_Buoi = dataReader.GetInt32(dataReader.GetOrdinal(EC_BuoiHoc_HocSinh.BuoiHoc_HocSinh_Fields.SoTien_Buoi.ToString()));
            }
        }
Пример #3
0
        /// <summary>
        /// Populate business objects from the data reader
        /// </summary>
        /// <param name="dataReader">data reader</param>
        /// <returns>list of SinhVien</returns>
        internal List <EC_BuoiHoc_HocSinh> PopulateObjectsFromReader(IDataReader dataReader)
        {
            List <EC_BuoiHoc_HocSinh> list = new List <EC_BuoiHoc_HocSinh>();

            while (dataReader.Read())
            {
                EC_BuoiHoc_HocSinh businessObject = new EC_BuoiHoc_HocSinh();
                PopulateBusinessObjectFromReader(businessObject, dataReader);
                list.Add(businessObject);
            }
            return(list);
        }
Пример #4
0
        private void btDiemDanh_Click(object sender, EventArgs e)
        {
            EC_LichHoc BuoiHoc    = listBuoiHoc[Stt];
            string     Ma_BuoiHoc = BuoiHoc.Ma_BuoiHoc;

            int SoDiHoc = 0;

            foreach (DataGridViewRow row in dgLopHoc.Rows)
            {
                if (Convert.ToBoolean(row.Cells["DiemDanhh"].Value) == true)
                {
                    SoDiHoc++;
                }
            }
            int TongSoTien_Buoi = BuoiHoc.TongHocPhi_Buoi;
            int SoTien_Buoi;

            if (SoDiHoc == 0)
            {
                SoTien_Buoi = 0;
                return;
            }
            else
            {
                SoTien_Buoi = TongSoTien_Buoi / SoDiHoc;
            }
            foreach (DataGridViewRow row in dgLopHoc.Rows)
            {
                string Ten_HocSinh = row.Cells["Ten_HocSinh"].Value.ToString();
                string SDT         = row.Cells["SDT"].Value.ToString();
                string Ma_HocSinh  = "";
                foreach (EC_HocSinh hs in DanhSachLop)
                {
                    if (hs.Ten_HocSinh == Ten_HocSinh && hs.SDT == SDT)
                    {
                        Ma_HocSinh = hs.Ma_HocSinh;
                    }
                }
                EC_BuoiHoc_HocSinh bhhs = new EC_BuoiHoc_HocSinh();
                bhhs.Ma_HocSinh  = Ma_HocSinh;
                bhhs.Ma_BuoiHoc  = Ma_BuoiHoc;
                bhhs.DiemDanh    = Convert.ToBoolean(row.Cells["DiemDanhh"].Value);
                bhhs.DongTien    = false;
                bhhs.SoTien_Buoi = SoTien_Buoi;
                bhhs.DanhGia     = "";
                new BUS_BuoiHoc_HocSinh().SuaDuLieu(bhhs);
            }

            new BUS_LichHoc().SuaTrangThai(Ma_BuoiHoc, true);

            LoadForm();
        }
Пример #5
0
        public EC_BuoiHoc_HocSinh Select_ByPrimaryKey(string Ma_BuoiHoc, string Ma_HocSinh)
        {
            SqlCommand sqlCommand = new SqlCommand();

            sqlCommand.CommandText = "dbo.[BuoiHoc_HocSinh_Select_By_Ma]";
            sqlCommand.CommandType = CommandType.StoredProcedure;

            try
            {
                sqlCommand.Parameters.AddWithValue("@Ma_BuoiHoc", Ma_BuoiHoc);
                sqlCommand.Parameters.AddWithValue("@Ma_HocSinh", Ma_HocSinh);

                con.MoKetNoi();
                // Use connection object of base class
                sqlCommand.Connection = con.connect;

                IDataReader dataReader = sqlCommand.ExecuteReader();

                if (dataReader.Read())
                {
                    EC_BuoiHoc_HocSinh businessObject = new EC_BuoiHoc_HocSinh();

                    PopulateBusinessObjectFromReader(businessObject, dataReader);

                    return(businessObject);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Lỗi khi lấy tất cả buổi học.", ex);
            }
            finally
            {
                con.DongKetNoi();
                sqlCommand.Dispose();
            }
        }
Пример #6
0
 public void XoaDuLieu(EC_BuoiHoc_HocSinh ec)
 {
     sql.XoaDuLieu(ec);
 }
Пример #7
0
 public void SuaDuLieu(EC_BuoiHoc_HocSinh ec)
 {
     sql.SuaDuLieu(ec);
 }
Пример #8
0
 public void ThemDuLieu(EC_BuoiHoc_HocSinh ec)
 {
     sql.ThemDuLieu(ec);
 }