示例#1
0
 private void XemDiem()
 {
     if (m_dgvMain.DataSource == null)
     {
         MessageBox.Show("Chọn học sinh cần xem điểm");
     }
     else
     {
         if (m_ccbPhanQuyen.Text.ToString() == "GVCN")
         {
             frmXemDiem frmXD = new frmXemDiem(m_dgvMain.SelectedRows[0]);
             frmXD.Show();
         }
         else
         {
             frmXemSuaDiem_Mon frmXDM = new frmXemSuaDiem_Mon(m_dgvMain.SelectedRows[0], false);
             frmXDM.Show();
         }
     }
 }
示例#2
0
        private void btnLuuDiem_Click(object sender, EventArgs e)
        {
            string[] colNames = { "colDiemMieng", "colDiem15Phut", "colDiem45Phut", "colDiemThi" };
            if (!KiemTraTruocKhiLuu.KiemTraDiem(dgvDiem, colNames) || STT == null)
            {
                return;
            }

            string maLop    = cmbLop.SelectedValue.ToString();
            string maNamHoc = cmbNamHoc.SelectedValue.ToString();
            string maMonHoc = cmbMonHoc.SelectedValue.ToString();
            string maHocKy  = cmbHocKy.SelectedValue.ToString();
            int    rowCount = 0;

            foreach (DataGridViewRow row in dgvDiem.Rows)
            {
                string maHocSinh = row.Cells["colMaHocSinh"].Value.ToString();
                rowCount++;

                for (int i = 0; i < colNames.Length; i++)
                {
                    if (row.Cells[colNames[i]].Value.ToString() == "")
                    {
                        row.Cells[colNames[i]].Value = 0;
                    }
                    string chuoiDiem = row.Cells[colNames[i]].Value.ToString();

                    if (string.IsNullOrWhiteSpace(chuoiDiem))
                    {
                        continue;
                    }
                    int count = 0;

                    for (int j = 0; j < chuoiDiem.Length; j++)
                    {
                        if (chuoiDiem[j] != ';' && j != chuoiDiem.Length - 1)
                        {
                            count++;
                        }
                        else
                        {
                            if (j == chuoiDiem.Length - 1)
                            {
                                j++;
                                count++;
                            }

                            string diemDaXuLy = chuoiDiem.Substring(j - count, count);
                            if (!string.IsNullOrWhiteSpace(diemDaXuLy) && QuyDinhBUS.Instance.KiemTraDiem(diemDaXuLy))
                            {
                                DiemDTO diem = new DiemDTO(maHocSinh, maMonHoc, maHocKy, maNamHoc, maLop, $"LD000{i + 1}", float.Parse(diemDaXuLy));
                                DiemBUS.Instance.ThemDiem(diem);
                            }
                            count = 0;
                        }
                    }
                }

                #region Xóa các kết quả cũ
                for (int i = 1; i < 60; i++)
                {
                    for (int j = 1; j < 20; j++)
                    {
                        int id = STT[i, j];
                        if (id > 0)
                        {
                            DiemBUS.Instance.XoaDiem(id);
                        }
                        else
                        {
                            break;
                        }
                    }
                }
                #endregion

                #region Lưu vào bảng kết quả
                if (rowCount <= dgvDiem.Rows.Count)
                {
                    KQHSMonHocBUS.Instance.LuuKetQua(maHocSinh, maLop, maNamHoc, maMonHoc, maHocKy);
                    KQHSCaNamBUS.Instance.LuuKetQua(maHocSinh, maLop, maNamHoc);
                    KQLHMonHocBUS.Instance.LuuKetQua(maLop, maNamHoc, maMonHoc, maHocKy);
                    KQLHHocKyBUS.Instance.LuuKetQua(maLop, maNamHoc, maHocKy);
                }
                #endregion
            }

            MessageBox.Show("Cập nhật thành công!", "COMPLETED", MessageBoxButtons.OK, MessageBoxIcon.Information);
            btnHienThiDanhSach_Click(sender, e);

            frmXemDiem frm = (frmXemDiem)Application.OpenForms["frmXemDiem"];
            if (frm != null)
            {
                frm.btnHienThiClicked(sender, e);
            }
        }