private void cmbNamHoc_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         if (isFirstLoadSuccess)
         {
             maNamHoc = (cmbNamHoc.SelectedItem as NamHocDTO).MaNamHoc;
             ChiTietMonBUS.CapNhatNamHoc(maChiTietMon, maNamHoc);
         }
     }
     catch (System.Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
示例#2
0
        private void btnCapNhatChiTietMon_Click(object sender, EventArgs e)
        {
            try
            {
                DialogResult result = MessageBox.Show("Bạn có chắc muốn cập nhật chi tiết môn học cho lớp này không?",
                                                      "Question",
                                                      MessageBoxButtons.YesNo,
                                                      MessageBoxIcon.Question,
                                                      MessageBoxDefaultButton.Button1);
                if (result == DialogResult.Yes)
                {
                    foreach (DataGridViewRow row in dtgvChiTietMon.Rows)
                    {
                        ChiTietMonDTO chiTietMonDTO = new ChiTietMonDTO();

                        chiTietMonDTO.MaChiTietMon = Int32.Parse(row.Cells["MaChiTietMon"].Value.ToString());
                        chiTietMonDTO.ThoiGianHoc  = row.Cells["ThoiGianHoc"].Value.ToString();
                        chiTietMonDTO.GioHoc       = row.Cells["GioHoc"].Value.ToString();
                        chiTietMonDTO.GiangDuong   = row.Cells["GiangDuong"].Value.ToString();
                        //chiTietMonDTO.GiangVien = row.Cells["GiangVien"].Value.ToString();
                        chiTietMonDTO.NgayThiLan1       = row.Cells["NgayThiLan1"].Value.ToString();
                        chiTietMonDTO.GioThiLan1        = row.Cells["GioThiLan1"].Value.ToString();
                        chiTietMonDTO.GiangDuongThiLan1 = row.Cells["GiangDuongThiLan1"].Value.ToString();
                        chiTietMonDTO.CanBoCoiThiLan1   = row.Cells["CanBoCoiThiLan1"].Value.ToString();
                        chiTietMonDTO.SoBaiThiLan1      = Int32.Parse(row.Cells["SoBaiThiLan1"].Value.ToString());
                        chiTietMonDTO.NgayThiLan2       = row.Cells["NgayThiLan2"].Value.ToString();
                        chiTietMonDTO.GioThiLan2        = row.Cells["GioThiLan2"].Value.ToString();
                        chiTietMonDTO.GiangDuongThiLan2 = row.Cells["GiangDuongThiLan2"].Value.ToString();
                        chiTietMonDTO.CanBoCoiThiLan2   = row.Cells["CanBoCoiThiLan2"].Value.ToString();
                        chiTietMonDTO.SoBaiThiLan2      = Int32.Parse(row.Cells["SoBaiThiLan2"].Value.ToString());
                        chiTietMonDTO.GhiChu            = row.Cells["GhiChu"].Value.ToString();

                        ChiTietMonBUS.UpdateRecord(chiTietMonDTO);
                    }

                    MessageBox.Show("Cập nhật chi tiết môn thành công");
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
示例#3
0
        public void LayDanhSachChiTietMon()
        {
            try
            {
                dtChiTietMon = ChiTietMonBUS.GetTable(lopDTO.MaLop);
                foreach (DataRow dr in dtChiTietMon.Rows)
                {
                    DataTable dtGiangVienMon = GiangVienBUS.LayDanhSachGiangVienCuaMon(Int32.Parse(dr["MaChiTietMon"].ToString()));
                    if (dtChiTietMon.Rows.Count > 0)
                    {
                        string giangVien = "";

                        foreach (DataRow drGiangVienMon in dtGiangVienMon.Rows)
                        {
                            if (giangVien == "")
                            {
                                giangVien += drGiangVienMon["TenGiangVien"].ToString();
                            }
                            else
                            {
                                giangVien = giangVien + Environment.NewLine + drGiangVienMon["TenGiangVien"].ToString();
                            }
                        }
                        dr["GiangVien"] = giangVien;
                    }

                    DataTable dtCanBoCoiThiLan1 = GiangVienBUS.LayDanhSachCanBoCoiThiLan1CuaMon(Int32.Parse(dr["MaChiTietMon"].ToString()));
                    if (dtCanBoCoiThiLan1.Rows.Count > 0)
                    {
                        string canBoCoiThiLan1 = "";

                        foreach (DataRow drCanBoCoiThiLan1 in dtCanBoCoiThiLan1.Rows)
                        {
                            if (canBoCoiThiLan1 == "")
                            {
                                canBoCoiThiLan1 += drCanBoCoiThiLan1["TenGiangVien"].ToString();
                            }
                            else
                            {
                                canBoCoiThiLan1 = canBoCoiThiLan1 + Environment.NewLine + drCanBoCoiThiLan1["TenGiangVien"].ToString();
                            }
                        }
                        dr["CanBoCoiThiLan1"] = canBoCoiThiLan1;
                    }

                    DataTable dtCanBoCoiThiLan2 = GiangVienBUS.LayDanhSachCanBoCoiThiLan2CuaMon(Int32.Parse(dr["MaChiTietMon"].ToString()));
                    if (dtCanBoCoiThiLan2.Rows.Count > 0)
                    {
                        string canBoCoiThiLan2 = "";

                        foreach (DataRow drCanBoCoiThiLan2 in dtCanBoCoiThiLan2.Rows)
                        {
                            if (canBoCoiThiLan2 == "")
                            {
                                canBoCoiThiLan2 += drCanBoCoiThiLan2["TenGiangVien"].ToString();
                            }
                            else
                            {
                                canBoCoiThiLan2 = canBoCoiThiLan2 + Environment.NewLine + drCanBoCoiThiLan2["TenGiangVien"].ToString();
                            }
                        }
                        dr["CanBoCoiThiLan2"] = canBoCoiThiLan2;
                    }
                }

                dtgvChiTietMon.DataSource = dtChiTietMon;

                //DataGridViewComboBoxColumn namHocCol = new DataGridViewComboBoxColumn();
                //namHocCol.Name = "CmbNamHoc";
                //namHocCol.HeaderText = "Năm Học";
                //namHocCol.ValueType = typeof(int);
                //dtgvChiTietMon.Columns.Insert(dtgvChiTietMon.Columns["TenMon"].Index + 1, namHocCol);

                //IList listNamHoc = NamHocBUS.GetList();

                //foreach (DataGridViewRow row in this.dtgvChiTietMon.Rows)
                //{
                //    ((DataGridViewComboBoxCell)row.Cells["CmbNamHoc"]).DataSource = listNamHoc;
                //    row.Cells["CmbNamHoc"].Value = row.Cells["TenNamHoc"].Value;
                //}

                dtgvChiTietMon.Columns["TenMon"].HeaderText            = "Môn";
                dtgvChiTietMon.Columns["TenNamHoc"].HeaderText         = "Năm Học";
                dtgvChiTietMon.Columns["ThoiGianHoc"].HeaderText       = "Thời Gian Học";
                dtgvChiTietMon.Columns["GioHoc"].HeaderText            = "Giờ Học";
                dtgvChiTietMon.Columns["GiangDuong"].HeaderText        = "Giảng Đường";
                dtgvChiTietMon.Columns["GiangVien"].HeaderText         = "Giảng Viên";
                dtgvChiTietMon.Columns["NgayThiLan1"].HeaderText       = "Ngày Thi Lần 1";
                dtgvChiTietMon.Columns["GioThiLan1"].HeaderText        = "Giờ Thi Lần 1";
                dtgvChiTietMon.Columns["GiangDuongThiLan1"].HeaderText = "Giảng Đường Thi Lần 1";
                dtgvChiTietMon.Columns["CanBoCoiThiLan1"].HeaderText   = "Cán Bộ Coi Thi Lần 1";
                dtgvChiTietMon.Columns["SoBaiThiLan1"].HeaderText      = "Số Bài Thi Lần 1";
                dtgvChiTietMon.Columns["NgayThiLan2"].HeaderText       = "Ngày Thi Lần 2";
                dtgvChiTietMon.Columns["GioThiLan2"].HeaderText        = "Giờ Thi Lần 2";
                dtgvChiTietMon.Columns["GiangDuongThiLan2"].HeaderText = "Giảng Đường Thi Lần 2";
                dtgvChiTietMon.Columns["CanBoCoiThiLan2"].HeaderText   = "Cán Bộ Coi Thi Lần 2";
                dtgvChiTietMon.Columns["SoBaiThiLan2"].HeaderText      = "Số Bài Thi Lần 2";
                dtgvChiTietMon.Columns["GhiChu"].HeaderText            = "Ghi Chú";

                dtgvChiTietMon.Columns["TenMon"].DefaultCellStyle.WrapMode            = DataGridViewTriState.True;
                dtgvChiTietMon.Columns["ThoiGianHoc"].DefaultCellStyle.WrapMode       = DataGridViewTriState.True;
                dtgvChiTietMon.Columns["GioHoc"].DefaultCellStyle.WrapMode            = DataGridViewTriState.True;
                dtgvChiTietMon.Columns["GiangDuong"].DefaultCellStyle.WrapMode        = DataGridViewTriState.True;
                dtgvChiTietMon.Columns["GiangVien"].DefaultCellStyle.WrapMode         = DataGridViewTriState.True;
                dtgvChiTietMon.Columns["NgayThiLan1"].DefaultCellStyle.WrapMode       = DataGridViewTriState.True;
                dtgvChiTietMon.Columns["GioThiLan1"].DefaultCellStyle.WrapMode        = DataGridViewTriState.True;
                dtgvChiTietMon.Columns["GiangDuongThiLan1"].DefaultCellStyle.WrapMode = DataGridViewTriState.True;
                dtgvChiTietMon.Columns["CanBoCoiThiLan1"].DefaultCellStyle.WrapMode   = DataGridViewTriState.True;
                dtgvChiTietMon.Columns["SoBaiThiLan1"].DefaultCellStyle.WrapMode      = DataGridViewTriState.True;
                dtgvChiTietMon.Columns["NgayThiLan2"].DefaultCellStyle.WrapMode       = DataGridViewTriState.True;
                dtgvChiTietMon.Columns["GioThiLan2"].DefaultCellStyle.WrapMode        = DataGridViewTriState.True;
                dtgvChiTietMon.Columns["GiangDuongThiLan2"].DefaultCellStyle.WrapMode = DataGridViewTriState.True;
                dtgvChiTietMon.Columns["CanBoCoiThiLan2"].DefaultCellStyle.WrapMode   = DataGridViewTriState.True;
                dtgvChiTietMon.Columns["SoBaiThiLan2"].DefaultCellStyle.WrapMode      = DataGridViewTriState.True;
                dtgvChiTietMon.Columns["GhiChu"].DefaultCellStyle.WrapMode            = DataGridViewTriState.True;

                dtgvChiTietMon.Columns["MaChiTietMon"].Visible = false;
                dtgvChiTietMon.Columns["MaMon"].Visible        = false;
                dtgvChiTietMon.Columns["MaNamHoc"].Visible     = false;

                dtgvChiTietMon.Columns["TenMon"].ReadOnly          = true;
                dtgvChiTietMon.Columns["TenNamHoc"].ReadOnly       = true;
                dtgvChiTietMon.Columns["GiangVien"].ReadOnly       = true;
                dtgvChiTietMon.Columns["CanBoCoiThiLan1"].ReadOnly = true;
                dtgvChiTietMon.Columns["CanBoCoiThiLan2"].ReadOnly = true;
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
示例#4
0
        private void btnThemLop_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtTenLop.Text == "")
                {
                    MessageBox.Show("Phải nhập tên lớp");
                    return;
                }
                if (countSelectedRow() == 0)
                {
                    MessageBox.Show("Phải chọn ít nhất 1 môn học");
                    return;
                }

                DialogResult result = MessageBox.Show("Bạn có chắc muốn thêm lớp này không?",
                                                      "Question",
                                                      MessageBoxButtons.YesNo,
                                                      MessageBoxIcon.Question,
                                                      MessageBoxDefaultButton.Button1);
                if (result == DialogResult.Yes)
                {
                    lopDTO.TenLop = txtTenLop.Text;

                    if (txtSoLuongSinhVien.Text == "")
                    {
                        lopDTO.SoLuongSinhVien = 0;
                    }
                    else
                    {
                        lopDTO.SoLuongSinhVien = Int32.Parse(txtSoLuongSinhVien.Text);
                    }

                    if (txtSoLuongTrongNganSach.Text == "")
                    {
                        lopDTO.SoLuongTrongNganSach = 0;
                    }
                    else
                    {
                        lopDTO.SoLuongTrongNganSach = Int32.Parse(txtSoLuongTrongNganSach.Text);
                    }

                    if (txtSoLuongNgoaiNganSach.Text == "")
                    {
                        lopDTO.SoLuongNgoaiNganSach = 0;
                    }
                    else
                    {
                        lopDTO.SoLuongNgoaiNganSach = Int32.Parse(txtSoLuongNgoaiNganSach.Text);
                    }

                    //lopDTO.MaNamHoc = (cmbNamHoc.SelectedItem as NamHocDTO).MaNamHoc;
                    LopBUS.Insert(lopDTO);

                    foreach (DataGridViewRow row in dtgvDSMon.Rows)
                    {
                        if (row.Cells[0].Value != null)
                        {
                            LopMonDTO lopMonDTO = new LopMonDTO();
                            lopMonDTO.MaLop = lopDTO.MaLop;
                            lopMonDTO.MaMon = Int32.Parse(row.Cells["MaMon"].Value.ToString());
                            LopMonBUS.Insert(lopMonDTO);

                            ChiTietMonDTO chiTietMonDTO = new ChiTietMonDTO();
                            chiTietMonDTO.MaLopMon = lopMonDTO.MaLopMon;
                            ChiTietMonBUS.Insert(chiTietMonDTO);
                        }
                    }

                    MessageBox.Show("Thêm lớp thành công");

                    LayDanhSachChiTietMon();

                    btnCapNhatChiTietMon.Visible = true;
                    dtgvChiTietMon.Visible       = true;
                    btnThemLop.Enabled           = false;
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }