示例#1
0
        private void btnXoa_Click_1(object sender, EventArgs e)
        {
            if (currentIDDeAn == -1)
            {
                MessageBox.Show("Vui long chon Sinh vien");
                return;
            }
            DeAn da = new DeAn();

            da.IDDeAn   = currentIDDeAn;
            da.TenDeAn  = txtTenDeAn.Text.Trim();
            da.NoiDung  = rtbNoiDung.Text.Trim();
            da.LoaiDeAn = cbLoaiDeAn.SelectedItem.ToString();
            Nhom nhom = cbNhom.SelectedItem as Nhom;

            da.IDNhom = nhom.IDNhom;
            GiaoVien gv = cbGiaoVien.SelectedItem as GiaoVien;

            da.IDGiaoVien = gv.IDGiaoVien;
            da.status     = 0;
            if (DeAnController.CapNhatDeAn(da) == false)
            {
                MessageBox.Show("Khong xoa De an duoc");
                return;
            }
            currentIDDeAn = -1;
            showDSDeAn();
        }
示例#2
0
 private void dgvDeAn_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     if (dgvDeAn.CurrentRow.Index >= 0)
     {
         int  IDDA = Int32.Parse(dgvDeAn.CurrentRow.Cells[0].Value.ToString());
         DeAn da   = DeAnController.GetDeAn(IDDA);
         currentIDDeAn            = da.IDDeAn;
         txtTenDeAn.Text          = da.TenDeAn.Trim();
         cbLoaiDeAn.SelectedIndex = cbLoaiDeAn.FindStringExact(da.LoaiDeAn.Trim());
         rtbNoiDung.Text          = da.NoiDung.Trim();
         foreach (Nhom nhom in cbNhom.Items)
         {
             if (nhom.IDNhom == da.IDNhom)
             {
                 cbNhom.SelectedIndex = cbNhom.Items.IndexOf(nhom);
             }
         }
         foreach (GiaoVien gv in cbGiaoVien.Items)
         {
             if (gv.IDGiaoVien == da.IDGiaoVien)
             {
                 cbGiaoVien.SelectedIndex = cbGiaoVien.Items.IndexOf(gv);
                 return;
             }
         }
     }
 }
示例#3
0
 private void btnTienDo_Click(object sender, EventArgs e)
 {
     if (dgvDeAn.CurrentRow.Index >= 0)
     {
         int       IDDA = Int32.Parse(dgvDeAn.CurrentRow.Cells[0].Value.ToString());
         DeAn      da   = DeAnController.GetDeAn(IDDA);
         frmTienDo ftd  = new frmTienDo((int)da.IDNhom, IDDA);
         ftd.Show();
     }
 }
示例#4
0
        private void btnThem_Click_1(object sender, EventArgs e)
        {
            errorDeAn.Clear();
            if (txtTenDeAn.Text.Trim().Length <= 0)
            {
                errorDeAn.SetError(txtTenDeAn, "Thêm tên đề án");
                return;
            }
            if (rtbNoiDung.Text.Trim().Length <= 5)
            {
                errorDeAn.SetError(rtbNoiDung, "Thêm nội dung đề án");
                return;
            }
            if (cbLoaiDeAn.SelectedItem == null)
            {
                errorDeAn.SetError(cbLoaiDeAn, "Chọn loại đề án");
                return;
            }
            if (cbNhom.SelectedItem as Nhom == null)
            {
                errorDeAn.SetError(cbNhom, "Chọn nhóm");
                return;
            }
            if (cbGiaoVien.SelectedItem as GiaoVien == null)
            {
                errorDeAn.SetError(cbGiaoVien, "Chọn Giáo viên");
                return;
            }

            GiaoVien giaovien = cbGiaoVien.SelectedItem as GiaoVien;
            Nhom     nhom     = cbNhom.SelectedItem as Nhom;
            DeAn     da       = new DeAn();

            da.TenDeAn    = txtTenDeAn.Text.Trim();
            da.LoaiDeAn   = cbLoaiDeAn.SelectedItem.ToString();
            da.NoiDung    = rtbNoiDung.Text.Trim();
            da.IDNhom     = nhom.IDNhom;
            da.IDGiaoVien = giaovien.IDGiaoVien;
            da.status     = 1;
            if (DeAnController.ThemDeAn(da) == false)
            {
                MessageBox.Show("Khong them duoc");
                return;
            }
            showDSDeAn();
            this.txtTenDeAn.Clear();
            this.cbLoaiDeAn.Text = "";
            this.rtbNoiDung.Clear();
            this.cbNhom.Text     = "";
            this.cbGiaoVien.Text = "";
        }
示例#5
0
        public void showDSDeAn()
        {
            BindingSource source = new BindingSource();

            if (this.admin == 1)
            {
                dsDeAn = DeAnController.GetListDeAn();
            }
            else
            {
                dsDeAn = DeAnController.GetDeAnGV(this.currentGiaoVien);
            }
            source.DataSource       = dsDeAn;
            this.dgvDeAn.DataSource = source;
            //dgvDeAn.Refresh();
        }
        private void btnDangKy_Click(object sender, EventArgs e)
        {
            SetErrorProvider();
            if (txtIDNhom.Text != "" && txtTenDeAn.Text != "" && txtGVHD.Text != "" && txtMoTa.Text != "" &&
                dtpDateStart.Value > DateTime.Now && dtpDateEnd.Value > dtpDateStart.Value)
            {
                string IDnhom = txtIDNhom.Text.Trim();
                #region Tên nhóm hoặc giảng viên không tồn tại
                using (var _context = new DBLapTrinhWin())
                {
                    var nhom = from u in _context.NhomSinhViens
                               where u.IDNhom == IDnhom
                               select u;
                    if (nhom.Count() == 0)
                    {
                        MessageBox.Show("Nhóm không tồn tại!");
                        this.ActiveControl = txtIDNhom;
                        return;
                    }

                    string gvhd = txtGVHD.Text.Trim();
                    var    gv   = from u in _context.GiangViens
                                  where u.MSGV == gvhd
                                  select u;
                    if (gv.Count() == 0)
                    {
                        MessageBox.Show("Giảng viên không tồn tại");
                        this.ActiveControl = txtGVHD;
                        return;
                    }
                }
                #endregion

                #region Xử lý lưu các thuộc tính vào database
                List <string> cacthuoctinh = new List <string>();
                cacthuoctinh = DeAnController.TachIDNhom(IDnhom);
                string type = "";

                if (cacthuoctinh[0] == "DAMH")
                {
                    type = "1";
                }
                else if (cacthuoctinh[0] == "TLCN")
                {
                    type = "2";
                }
                else if (cacthuoctinh[0] == "DATN")
                {
                    type = "3";
                }

                DeAn DeAnDangKy = new DeAn();
                DeAnDangKy.IDDeAn   = IDnhom;
                DeAnDangKy.TenDeAn  = txtTenDeAn.Text.Trim();
                DeAnDangKy.Type     = type;
                DeAnDangKy.IDNhomSV = IDnhom;
                DeAnDangKy.GVHD     = txtGVHD.Text.Trim();
                DeAnDangKy.MoTa     = txtMoTa.Text;
                if (type == "1")
                {
                    DeAnDangKy.MonHoc = cacthuoctinh[1];
                }
                else
                {
                    DeAnDangKy.ChuyenNganh = cacthuoctinh[1];
                }
                using (var _context = new DBLapTrinhWin())
                {
                    _context.DeAns.Add(DeAnDangKy);
                    _context.SaveChanges();
                }
                txtIDDeAn.Text = IDnhom;
                TienDo tienDo = new TienDo();
                tienDo.IDDeAn = DeAnDangKy.IDDeAn;
                using (var _context = new DBLapTrinhWin())
                {
                    _context.TienDoes.Add(tienDo);
                    _context.SaveChanges();
                }
                MessageBox.Show("Thêm đề án thành công!");

                AddDeAnThanhCongEventArgs arg = new AddDeAnThanhCongEventArgs();
                OnAddDeAnThanhCong(arg);
                this.Close();
                #endregion
            }
        }