示例#1
0
        public DataTable getDatatableStatistic(string year)
        {
            DataTable dt = new DataTable();

            initDataTableStatistic(dt);
            foreach (HocSinh student in dbContext.HocSinhs.ToList())
            {
                try
                {
                    BangDiem score   = learningOutComes(getListScoreByStudent(student.maHS, year));
                    HanhKiem conduct = getConductStudent(student.maHS, year);
                    DataRow  row     = dt.NewRow();
                    row["Học sinh"]    = student.hoTenHS;
                    row["Lớp"]         = dbContext.Lops.Single(m => m.maLop == student.maLop).tenLop;
                    row["Năm học"]     = year;
                    row["TB học kỳ 1"] = ConverScore(score.tbHocKy1.ToString());
                    row["HK học kì 1"] = conduct.hocKy1;
                    row["TB học kỳ 2"] = ConverScore(score.tbHocKy2.ToString());
                    row["HK Học kỳ 2"] = conduct.hocKy2;
                    row["TB cả năm"]   = ConverScore(score.tbNamHoc.ToString());
                    row["HK cả năm"]   = conduct.caNam;
                    dt.Rows.Add(row);
                }
                catch (Exception e)
                {
                }
            }

            return(dt);
        }
 public bool Sua(HanhKiem hk)
 {
     try
     {
         string query = @" UPDATE dbo.HanhKiem set Ten = N'" + hk.Ten + "' where mahk = '" + hk.MaHK + "'";
         OpenConection();
         ExecuteQueries(query);
         CloseConnection();
         return(true);
     }
     catch (Exception ex)
     {
         SetEx(ex);
         return(false);
     }
 }
 public bool Them(HanhKiem hk)
 {
     try
     {
         string query = @"INSERT INTO dbo.HanhKiem ( MaHK, Ten ) VALUES  ( '" + hk.MaHK + "',  N'" + hk.Ten + "')";
         OpenConection();
         ExecuteQueries(query);
         CloseConnection();
         return(true);
     }
     catch (Exception ex)
     {
         SetEx(ex);
         return(false);
     }
 }
示例#4
0
 private void btOk_Click(object sender, EventArgs e)
 {
     if (type == "Them")
     {
         if (txtMaHK.Text != "" && txtTen.Text != "")
         {
             HanhKiem hk = new HanhKiem(txtMaHK.Text.Trim().ToString(), txtTen.Text.Trim().ToString());
             if (dal_hk.Them(hk) == true)
             {
                 FormatData();
                 ShowData();
                 EnableMethod(true);
                 MessageBox.Show("Thêm thành công");
             }
             else
             {
                 Exception ex = dal_hk.GetEx();
                 MessageBox.Show(ex.Message);
             }
         }
         else
         {
             MessageBox.Show("Bạn cần nhập đủ thông tin phòng ban");
         }
     }
     else if (type == "Sua")
     {
         if (txtTen.Text != "")
         {
             HanhKiem hk = new HanhKiem(txtMaHK.Text.Trim().ToString(), txtTen.Text.Trim().ToString());
             if (dal_hk.Sua(hk) == true)
             {
                 FormatData();
                 ShowData();
                 MessageBox.Show("Sửa thành công");
                 EnableMethod(true);
             }
             else
             {
                 Exception ex = dal_hk.GetEx();
                 MessageBox.Show(ex.Message);
             }
         }
         else
         {
             MessageBox.Show("Bạn cần nhập đủ thông tin phòng ban");
         }
     }
     else if (type == "Xoa")
     {
         if (txtMaHK.Text != "" && txtTen.Text != "")
         {
             DialogResult dr = MessageBox.Show("Bạn có muốn xóa khồng?", "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
             if (dr == DialogResult.OK)
             {
                 dal_hk.Xoa(txtMaHK.Text);
                 EnableMethod(true);
                 ShowData();
             }
             else
             {
                 EnabledData(false);
                 EnableMethod(true);
             }
         }
     }
 }
示例#5
0
 public bool Sua(HanhKiem hk)
 {
     return(dal_hk.Sua(hk));
 }
示例#6
0
 public bool Them(HanhKiem hk)
 {
     return(dal_hk.Them(hk));
 }