コード例 #1
0
        private void btnXoa_Click_1(object sender, EventArgs e)
        {
            if (currentIDTienDo == -1)
            {
                MessageBox.Show("Vui long chon Tien do");
                return;
            }
            TienDo td = new TienDo();

            td.IDTienDo       = currentIDTienDo;
            td.NoiDung        = rtbNoiDungTienDo.Text.Trim();
            td.TaiLieuBaoCao  = txtTaiLieu.Text.Trim();
            td.ThoiGianBaoCao = dtpNgayBaoCao.Value;
            td.HoanThanh      = Int32.Parse(txtHoanThanh.Text.Trim());
            td.NhanXet        = rtbNhanXet.Text.Trim();
            td.IDDeAn         = currentIDDeAn;
            td.IDNhom         = currentIDNhom;
            td.status         = 0;
            SinhVien sv = cbSinhVien.SelectedItem as SinhVien;

            td.IDSinhVien = sv.IDSinhVien;
            if (TienDoController.CapNhatTienDo(td) == false)
            {
                MessageBox.Show("Khong xoa duoc Tien do");
                return;
            }
            showTienDo();
            currentIDTienDo = -1;
        }
コード例 #2
0
 public static bool CapNhatTienDo(TienDo tiendo)
 {
     try
     {
         using (var _context = new DBQuanLyDeAnEntities())
         {
             var td = (from t in _context.TienDoes
                       where t.IDTienDo == tiendo.IDTienDo
                       select t)
                      .SingleOrDefault();
             td.NoiDung        = tiendo.NoiDung;
             td.TaiLieuBaoCao  = tiendo.TaiLieuBaoCao;
             td.ThoiGianBaoCao = tiendo.ThoiGianBaoCao;
             td.HoanThanh      = tiendo.HoanThanh;
             td.NhanXet        = tiendo.NhanXet;
             td.IDSinhVien     = tiendo.IDSinhVien;
             td.status         = tiendo.status;
             _context.SaveChanges();
             return(true);
         }
     }
     catch
     {
         return(false);
     }
 }
コード例 #3
0
 public static bool UpdateTienDo(TienDo td)
 {
     using (var _context = new ManagementTopicStudentEntities())
     {
         _context.TienDoes.AddOrUpdate(td);
         _context.SaveChanges();
         return(true);
     }
 }
コード例 #4
0
 public static bool DeleteTienDo(TienDo td)
 {
     using (var _context = new ManagementTopicStudentEntities())
     {
         var db = (from u in _context.TienDoes
                   where u.MaTienDo == td.MaTienDo
                   select u).SingleOrDefault();
         _context.TienDoes.Remove(db);
         _context.SaveChanges();
         return(true);
     }
 }
コード例 #5
0
        private void btnThem_Click_1(object sender, EventArgs e)
        {
            errorTienDo.Clear();
            if (txtTaiLieu.Text.Trim().Length <= 0)
            {
                errorTienDo.SetError(txtTaiLieu, "Thêm tài liệu báo cáo");
                return;
            }

            if (rtbNhanXet.Text.Trim().Length <= 0)
            {
                errorTienDo.SetError(rtbNhanXet, "Thêm tài nội dung tiến độ");
                return;
            }
            if (cbSinhVien.SelectedItem as SinhVien == null)
            {
                errorTienDo.SetError(cbSinhVien, "Thêm sinh viên thực hiện");
                return;
            }
            if (Int32.Parse(txtHoanThanh.Text.Trim()) > 100 && Int32.Parse(txtHoanThanh.Text.Trim()) < 0)
            {
                errorTienDo.SetError(txtHoanThanh, "Hoàn thành có giá trị từ 0 đến 100%");
                return;
            }
            if (DateTime.Now > dtpNgayBaoCao.Value)
            {
                errorTienDo.SetError(dtpNgayBaoCao, "Chọn ngày báo cáo phù hợp");
                return;
            }
            TienDo td = new TienDo();

            td.NoiDung        = rtbNoiDungTienDo.Text.Trim();
            td.TaiLieuBaoCao  = txtTaiLieu.Text.Trim();
            td.ThoiGianBaoCao = dtpNgayBaoCao.Value;
            td.HoanThanh      = Int32.Parse(txtHoanThanh.Text.Trim());
            td.NhanXet        = rtbNhanXet.Text.Trim();
            td.IDDeAn         = currentIDDeAn;
            td.IDNhom         = currentIDNhom;
            td.status         = 1;
            SinhVien sv = cbSinhVien.SelectedItem as SinhVien;

            td.IDSinhVien = sv.IDSinhVien;
            if (TienDoController.ThemTienDo(td) == false)
            {
                MessageBox.Show("Khong them Tien Do duoc");
                return;
            }
            showTienDo();
            currentIDTienDo = -1;
        }
コード例 #6
0
 public static bool AddTienDo(TienDo td)
 {
     try
     {
         using (var _context = new ManagementTopicStudentEntities())
         {
             _context.TienDoes.Add(td);
             _context.SaveChanges();
             return(true);
         }
     }
     catch
     {
         return(false);
     }
 }
コード例 #7
0
 public static bool ThemTienDo(TienDo td)
 {
     try
     {
         using (var _context = new DBQuanLyDeAnEntities())
         {
             _context.TienDoes.Add(td);
             _context.SaveChanges();
             return(true);
         }
     }
     catch
     {
         return(false);
     }
 }
コード例 #8
0
        private void btnXoa_Click(object sender, EventArgs e)
        {
            if (this.dataGridView1.SelectedRows.Count <= 0)
            {
                MessageBox.Show("Hãy chọn dòng cần xóa!");
                return;
            }

            TienDo td = TienDoController.getTienDo(this.dataGridView1.SelectedRows[0].Cells[0].Value.ToString());

            TienDoController.DeleteTienDo(td);
            //Hiển thị
            BindingSource source = new BindingSource();

            source.DataSource             = TienDoController.getListTienDo();
            this.dataGridView1.DataSource = source;
        }
コード例 #9
0
        private void dgvTienDo_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (dgvTienDo.CurrentCell.ColumnIndex != 0)
            {
                return;
            }
            currentIDTienDo = Int32.Parse(dgvTienDo.CurrentRow.Cells[0].Value.ToString());
            TienDo td = TienDoController.GetTienDo(currentIDTienDo);

            txtTaiLieu.Text       = td.TaiLieuBaoCao.Trim();
            rtbNoiDungTienDo.Text = td.NoiDung.Trim();
            txtHoanThanh.Text     = td.HoanThanh.ToString();
            rtbNhanXet.Text       = td.NhanXet.Trim();
            dtpNgayBaoCao.Value   = DateTime.Parse(td.ThoiGianBaoCao.ToString());
            foreach (SinhVien sv in cbSinhVien.Items)
            {
                if (sv.IDSinhVien == td.IDSinhVien)
                {
                    cbSinhVien.SelectedItem = cbSinhVien.Items.IndexOf(sv);
                    return;
                }
            }
        }
コード例 #10
0
        private void btnThemmoi_Click(object sender, EventArgs e)
        {
            int dem = 0;

            if (this.txtTenTienDo.Text.Trim().Length <= 0)
            {
                this.errorProvider1.SetError(this.txtTenTienDo, "Phai nhap ten tien do");
                dem++;
            }
            else
            {
                this.errorProvider1.SetError(this.txtTenTienDo, null);
            }
            if (this.cboDeTai.Text.Trim().Length <= 0)
            {
                this.errorProvider2.SetError(this.cboDeTai, "Phai chon de tai");
                dem++;
            }
            else
            {
                this.errorProvider2.SetError(this.cboDeTai, null);
            }
            if (this.cboNhom.Text.Trim().Length <= 0)
            {
                this.errorProvider3.SetError(this.cboNhom, "Phai chon nhom");
                dem++;
            }
            else
            {
                this.errorProvider3.SetError(this.cboNhom, null);
            }
            if (this.txtTrangThai.Text.Trim().Length <= 0)
            {
                this.errorProvider4.SetError(this.txtTrangThai, "Phai nhap trang thai cua de tai");
                dem++;
            }
            else
            {
                this.errorProvider4.SetError(this.txtTrangThai, null);
            }
            if (dem != 0)
            {
                return;
            }
            TienDo td = new TienDo();

            td.MaTienDo   = this.txtTenTienDo.Text.Trim();
            td.MaDT       = this.cboDeTai.Text.Trim();
            td.MaNhom     = this.cboNhom.Text.Trim();
            td.TaiLieu    = this.txtTaiLieu.Text.Trim();
            td.TrangThai  = this.txtTrangThai.Text.Trim();
            td.ThoiGianKT = this.dataTimeKT.Value;
            td.NhanXet    = this.txtNhanXet.Text.Trim();
            if (TienDoController.AddTienDo(td) == false)
            {
                MessageBox.Show("Mã đề tài bị trùng");
                return;
            }
            //TienDoController.AddTienDo(td);
            BindingSource source = new BindingSource();

            source.DataSource             = TienDoController.getListTienDo();
            this.dataGridView1.DataSource = source;
        }
コード例 #11
0
        private void btnSua_Click(object sender, EventArgs e)
        {
            int dem = 0;

            if (this.txtTenTienDo.Text.Trim().Length <= 0)
            {
                this.errorProvider1.SetError(this.txtTenTienDo, "Phai nhap ten tien do");
                dem++;
            }
            else
            {
                this.errorProvider1.SetError(this.txtTenTienDo, null);
            }
            if (this.cboDeTai.Text.Trim().Length <= 0)
            {
                this.errorProvider2.SetError(this.cboDeTai, "Phai chon de tai");
                dem++;
            }
            else
            {
                this.errorProvider2.SetError(this.cboDeTai, null);
            }
            if (this.cboNhom.Text.Trim().Length <= 0)
            {
                this.errorProvider3.SetError(this.cboNhom, "Phai chon nhom");
                dem++;
            }
            else
            {
                this.errorProvider3.SetError(this.cboNhom, null);
            }
            if (this.txtTrangThai.Text.Trim().Length <= 0)
            {
                this.errorProvider4.SetError(this.txtTrangThai, "Phai nhap trang thai cua de tai");
                dem++;
            }
            else
            {
                this.errorProvider4.SetError(this.txtTrangThai, null);
            }
            if (dem != 0)
            {
                return;
            }
            if (flag == true)
            {
                try
                {
                    this.dataGridView1.SelectedCells[0].Value = this.txtTenTienDo.Text.Trim();
                    this.dataGridView1.SelectedCells[5].Value = this.cboDeTai.Text.Trim();
                    this.dataGridView1.SelectedCells[6].Value = this.cboNhom.Text.Trim();
                    this.dataGridView1.SelectedCells[2].Value = this.txtTaiLieu.Text.Trim();
                    this.dataGridView1.SelectedCells[1].Value = this.txtTrangThai.Text.Trim();
                    this.dataGridView1.SelectedCells[3].Value = this.dataTimeKT.Value;
                    this.dataGridView1.SelectedCells[4].Value = this.txtNhanXet.Text.Trim();
                }
                catch
                {
                    MessageBox.Show("Hãy nhấn vào ô trống đầu tiên của mỗi dòng để chọn dòng cần cập nhật!");
                    return;
                }
            }
            flag = false;
            TienDo td = new TienDo();

            td.MaTienDo   = this.txtTenTienDo.Text.Trim();
            td.MaDT       = this.cboDeTai.Text.Trim();
            td.MaNhom     = this.cboNhom.Text.Trim();
            td.TaiLieu    = this.txtTaiLieu.Text.Trim();
            td.TrangThai  = this.txtTrangThai.Text.Trim();
            td.ThoiGianKT = this.dataTimeKT.Value;
            td.NhanXet    = this.txtNhanXet.Text.Trim();
            TienDoController.UpdateTienDo(td);
            BindingSource source = new BindingSource();

            source.DataSource             = TienDoController.getListTienDo();
            this.dataGridView1.DataSource = source;
        }
コード例 #12
0
        public JsonResult GetTienDo()
        {
            tongcuclamnghiepEntities tongcuclamnghiep = new tongcuclamnghiepEntities();
            List <string>            labels           = new List <string>();
            List <DonViTienDo>       DanhSachDonVi    = new List <DonViTienDo>();
            List <int> DungTienDo  = new List <int>();
            List <int> ChamTienDo  = new List <int>();
            List <int> KhongBaoCao = new List <int>();

            List <TienDo> tienDos = new List <TienDo>();

            DanhSachDonVi = tongcuclamnghiep.m_unit.Where(a => a.status == true).Select(a => new DonViTienDo()
            {
                Id = a.id, UnitName = a.unitname
            }).ToList();
            tongcuclamnghiep.m_precious.Where(a => a.enddate < DateTime.Now).ToList().ForEach(a => {
                //labels.Add(a.precious_name);
                //int intDungTienDo = a.m_unit_precious.Where(b => b.completedate < a.slowday).Count();
                //DungTienDo.Add(intDungTienDo);
                //int intChamTienDo= a.m_unit_precious.Where(b => b.completedate >= a.slowday && b.completedate<=a.completedate).Count();
                //ChamTienDo.Add(intChamTienDo);
                //int intKhongBaoCao = a.m_unit_precious.Where(b => b.completedate == null).Count();
                //intKhongBaoCao += tongcuclamnghiep.m_unit.Where(b => b.status == true).ToList().Where(b => !a.m_unit_precious.ToList().Select(c => c.unit_id).Contains(b.id)).Count();
                //KhongBaoCao.Add(intKhongBaoCao);

                TienDo tienDo            = new TienDo();
                tienDo.QuyBaoCao         = a.precious_name;
                tienDo.SoDonViDungTienDo = a.m_unit_precious.Where(b => b.completedate < a.slowday).Select(b => new DonViTienDo()
                {
                    Id = b.m_unit.id, UnitName = b.m_unit.unitname
                }).ToList();
                tienDo.SoDonViChamTienDo = a.m_unit_precious.Where(b => b.completedate >= a.slowday && b.completedate <= a.completedate).Select(b => new DonViTienDo()
                {
                    Id = b.m_unit.id, UnitName = b.m_unit.unitname
                }).ToList();
                List <DonViTienDo> SoDonViKhongBaoCao = a.m_unit_precious.Where(b => b.completedate == null).Select(b => new DonViTienDo()
                {
                    Id = b.m_unit.id, UnitName = b.m_unit.unitname
                }).ToList();
                tongcuclamnghiep.m_unit.Where(b => b.status == true).ToList().Where(b => !a.m_unit_precious.ToList().Select(c => c.unit_id).Contains(b.id)).ToList().ForEach(b => {
                    SoDonViKhongBaoCao.Add(new DonViTienDo()
                    {
                        Id = b.id, UnitName = b.unitname
                    });
                });
                tienDo.SoDonViKhongBaoCao = SoDonViKhongBaoCao;

                labels.Add(a.precious_name);
                DungTienDo.Add(tienDo.SoDonViDungTienDo.Count());
                ChamTienDo.Add(tienDo.SoDonViChamTienDo.Count());
                KhongBaoCao.Add(tienDo.SoDonViKhongBaoCao.Count());
                tienDos.Add(tienDo);
            });
            List <List <int> > series = new List <List <int> >()
            {
                DungTienDo, ChamTienDo, KhongBaoCao
            };
            int totalUnit = tongcuclamnghiep.m_unit.Where(a => a.status == true).Count();

            return(Json(new { labels = labels, series = series, totalUnit = totalUnit, tienDos = tienDos, DanhSachDonVi = DanhSachDonVi }, JsonRequestBehavior.AllowGet));
        }
コード例 #13
0
        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
            }
        }