Example #1
0
        private void btnDeleteStudyResults_Click(object sender, EventArgs e)
        {
            var db = new quanlydiemSinhVienEntities();

            if (MessageBox.Show("Bạn có muốn xóa không ?", "Confirm", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
            {
                for (int i = 0; i < this.lstStudyResults.SelectedRows.Count; i++)
                {
                    var row  = this.lstStudyResults.SelectedRows[i];
                    var item = (ketquahoctap)row.DataBoundItem;

                    try
                    {
                        ketquahoctap KetQuaHocTap = db.ketquahoctaps.Find(item.kqht_id);
                        db.ketquahoctaps.Remove(KetQuaHocTap);
                        db.SaveChanges();
                        MessageBox.Show("Thành Công");
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("Thất Bại");
                    }
                }
            }
            this.ShowStudyResults();
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            ketquahoctap KQHT = new ketquahoctap();
            //int class_id = ((lophoc)this.cboClass.SelectedItem).lophoc_id;
            //KQHT.lophoc_id = class_id;
            int monhoc_id = ((monhoc)this.cboSubject.SelectedItem).monhoc_id;

            KQHT.monhoc_id = monhoc_id;
            KQHT.mssv      = this.txtMssv.Text;
            int diemCC = int.Parse(txtAttendance.Text);

            KQHT.chuyencan = diemCC;
            int diemGK = int.Parse(txtMidterm.Text);

            KQHT.giuaki = diemGK;
            int diemCK = int.Parse(txtFinalterm.Text);

            KQHT.cuoiki = diemCK;
            int diemTB = int.Parse(txtAverage.Text);

            KQHT.DTB = diemTB;
            try
            {
                quanlydiemSinhVienEntities db = new quanlydiemSinhVienEntities();
                db.ketquahoctaps.Add(KQHT);
                db.SaveChanges();
                MessageBox.Show("Thành Công");
                this.Close();
            }
            catch (Exception)
            {
                MessageBox.Show("Thất Bại");
            }
            this.Close();
        }
        public DataTable LaytatcadulieusinhvienbangMasvVaMamh(ketquahoctap kqht)
        {
            string        sqlLaytatcadulieusinhvienbangMasvVaMamh = "SELECT * FROM Ketquahoctap WHERE Masv='" + kqht.MASINHVIEN + "'AND Mamh='" + kqht.MAMONHOC + "'";
            SqlConnection con = dc.getConnection();

            adt = new SqlDataAdapter(sqlLaytatcadulieusinhvienbangMasvVaMamh, con);
            DataTable dt = new DataTable();

            adt.Fill(dt);
            return(dt);
        }
        public bool Xoadulieuketquasinhvien(ketquahoctap kqht)
        {
            string        sqlXoadulieuketquasinhvien = "DELETE FROM Ketquahoctap WHERE id=@ID";
            SqlConnection con = dc.getConnection();

            cm = new SqlCommand(sqlXoadulieuketquasinhvien, con);
            try
            {
                con.Open();
                cm.Parameters.Add("@ID", SqlDbType.Int).Value = kqht.ID;
                cm.ExecuteNonQuery();
                con.Close();
            }
            catch (Exception e)
            {
                return(false);
            }
            return(true);
        }
        public bool Themdulieuvaobang(ketquahoctap kqht)
        {
            string        sqlThemdulieuvaobang = "INSERT INTO Ketquahoctap (Masv,Mamh,Diem) VALUES (@MASINHVIEN,@MAMONHOC,@DIEM)";
            SqlConnection con = dc.getConnection();

            cm = new SqlCommand(sqlThemdulieuvaobang, con);
            try
            {
                con.Open();
                cm.Parameters.Add("@MASINHVIEN", SqlDbType.NVarChar).Value = kqht.MASINHVIEN;
                cm.Parameters.Add("@MAMONHOC", SqlDbType.NVarChar).Value   = kqht.MAMONHOC;
                cm.Parameters.Add("@DIEM", SqlDbType.Float).Value          = kqht.DIEM;
                cm.ExecuteNonQuery();
                con.Close();
            }
            catch (Exception e)
            {
                return(false);
            }
            return(true);
        }
        public bool Capnhatdulieubangketquahoctap(ketquahoctap kqht)
        {
            string        sqlCapnhatdulieubangketquahoctap = "UPDATE Ketquahoctap SET Masv=@MASINHVIEN , Mamh=@MAMONHOC ,Diem =@DIEM WHERE @ID=id";
            SqlConnection con = dc.getConnection();

            cm = new SqlCommand(sqlCapnhatdulieubangketquahoctap, con);
            try
            {
                con.Open();
                cm.Parameters.Add("@ID", SqlDbType.Int).Value = kqht.ID;
                cm.Parameters.Add("@MASINHVIEN", SqlDbType.NVarChar).Value = kqht.MASINHVIEN;
                cm.Parameters.Add("@MAMONHOC", SqlDbType.NVarChar).Value   = kqht.MAMONHOC;
                cm.Parameters.Add("@DIEM", SqlDbType.Float).Value          = kqht.DIEM;
                cm.ExecuteNonQuery();
                con.Close();
            }
            catch (Exception e)
            {
                return(false);
            }
            return(true);
        }
 public FormEditStudyResults(ketquahoctap KetQuaHocTap)//here
 {
     InitializeComponent();
     // TODO: Complete member initialization
     this.KetQuaHocTap = KetQuaHocTap;
 }
 public bool Capnhatdulieubangketquahoctap(ketquahoctap kqht)
 {
     return(kqht_dal.Capnhatdulieubangketquahoctap(kqht));
 }
 public DataTable LaytatcadulieusinhvienbangMasvVaMamh(ketquahoctap kqht)
 {
     return(kqht_dal.LaytatcadulieusinhvienbangMasvVaMamh(kqht));
 }
 public bool Xoadulieuketquasinhvien(ketquahoctap kqht)
 {
     return(kqht_dal.Xoadulieuketquasinhvien(kqht));
 }
 public bool Themdulieuvaobang(ketquahoctap kqht)
 {
     return(kqht_dal.Themdulieuvaobang(kqht));
 }