public ActionResult Edit([Bind(Include = "MaDA,TenDA,DonGia,AnhDA,MoTa,NgayCapNhat,SoLuongTon,TrangThaiDA,DanhGiaDoAn,MaDM")] DoAn doAn, HttpPostedFileBase fileupload) { if (fileupload != null) { var fileName = Path.GetFileName(fileupload.FileName); //Luu duong dan cua file var path = Path.Combine(Server.MapPath("~/images"), fileName); if (System.IO.File.Exists(path)) { //Xoa hinh cu trong duong dan System.IO.File.Delete(path); //Luu hinh anh moi vao duong dan fileupload.SaveAs(path); } doAn.AnhDA = fileName; } db.SaveChanges(); HttpResponseMessage response = client.PutAsJsonAsync(url + @"doan/" + doAn.MaDA, doAn).Result; response.EnsureSuccessStatusCode(); return(RedirectToAction("Index")); }
private void prepareComboBox(DoAn da) { GVHD[] gvhds = gvhdBll.getAllGVHD(); HuongNghienCuu[] hncs = hcnBll.getAllHNC(); for (int i = 0; i < gvhds.Length; i ++) { if (da.ID_GVHD == gvhds[i].ID_GVHD) { cbxGVHD.SelectedIndex = i; break; } } for (int i = 0; i < hncs.Length; i++) { if (da.Ma_Huong_NC == hncs[i].Ma_Huong_NC) { cbxHNC.SelectedIndex = i; break; } } for (int i = 1; i <= 100; i++) { if(1990 + i == da.NamThucHien) { cbxNamBaoVe.SelectedIndex = i - 1; break; } } }
public async Task <DoAn> UpdateById(int id, DoAnForUpdateDto doAn) { var oldRecord = await _context.DanhSachDoAn.AsNoTracking().FirstOrDefaultAsync(x => x.MaDoAn == id); var doAnToUpdate = new DoAn { MaDoAn = id, TenDoAn = doAn.TenDoAn, MoTa = doAn.MoTa, MaHuongNghienCuu = doAn.MaHuongNghienCuu, LienKetTaiDoAn = doAn.LienKetTaiDoAn, ThoiGianBaoCao = doAn.ThoiGianBaoCao, MaHocKy = doAn.MaHocKy, DiemTongKet = doAn.DiemTongKet, NhanXetChung = doAn.NhanXetChung, DiaDiemBaoCao = doAn.DiaDiemBaoCao, ThoiGianTao = oldRecord.ThoiGianTao, ThoiGianCapNhat = DateTime.Now, }; _context.DanhSachDoAn.Update(doAnToUpdate); await _context.SaveChangesAsync(); return(doAnToUpdate); }
public IHttpActionResult PutDoAn(int id, DoAn doAn) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != doAn.MaDA) { return(BadRequest()); } db.Entry(doAn).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!DoAnExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult Create(HttpPostedFileBase Image, [Bind(Include = "Id,Image,Name,MDA,Human,Score,Humans,SinhVienId")] DoAn doAn) { string imagePath = "/Scripts/DoAn/doan.jpg"; if (Image != null && Image.ContentLength > 0) { imagePath = "/Scripts/DoAn/" + Image.FileName; string path = Path.Combine(Server.MapPath("~/Scripts/DoAn"), Image.FileName); Image.SaveAs(path); doAn.Image = imagePath; } var newdoAn = new DoAn() { Name = doAn.Name, MDA = doAn.MDA, Human = doAn.Human, Score = doAn.Score, Humans = doAn.Humans, SinhVienId = doAn.SinhVienId, Image = imagePath, }; if (ModelState.IsValid) { db.DoAns.Add(newdoAn); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.SinhVienId = new SelectList(db.SinhViens, "Id", "Name"); return(View(doAn)); }
public void remove(DoAn da) { string sqlCmd = "DELETE FROM DoAN WHERE Ma_Do_An = "; sqlCmd += "'" + da.MaDoAn.Trim() + "'"; DBHelper.DBExcuteNonQuery(sqlCmd); }
public ActionResult DeleteConfirmed(int id) { DoAn doAn = db.DoAns.Find(id); db.DoAns.Remove(doAn); db.SaveChanges(); return(RedirectToAction("Index")); }
public Item(int MaDA) { iMaDA = MaDA; DoAn doan = db.DoAns.Single(n => n.MaDA == iMaDA); sTenDA = doan.TenDA; Quantity = 1; }
public IHttpActionResult GetDoAn(int id) { DoAn doAn = db.DoAns.Find(id); if (doAn == null) { return(NotFound()); } return(Ok(doAn)); }
public ActionResult Edit([Bind(Include = "Id,Image,Name,MDA,Human,Score,Humans,SinhVienId")] DoAn doAn) { if (ModelState.IsValid) { db.Entry(doAn).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.SinhVienId = new SelectList(db.SinhViens, "Id", "Name"); return(View(doAn)); }
// GET: DoAn/Details/5 public async Task <ActionResult> Details(int?id) { DoAn doAn = null; HttpResponseMessage response = await client.GetAsync(url + @"doan/" + id); if (response.IsSuccessStatusCode) { doAn = await response.Content.ReadAsAsync <DoAn>(); } return(View(doAn)); }
private DoAn getFormData() { DoAn da = new DoAn(); da.MaDoAn = txtMaDATN.Text; da.TenSV = txtSVTH.Text; da.TenDoAn = txtTenDATN.Text; da.ID_GVHD = ((GVHD)cbxGVHD.SelectedItem).ID_GVHD; da.Ma_Huong_NC = ((HuongNghienCuu)cbxHNC.SelectedItem).Ma_Huong_NC; da.TinhTrang = true; da.NamThucHien = (int) cbxNamBaoVe.SelectedItem; return da; }
public IHttpActionResult PostDoAn(DoAn doAn) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.DoAns.Add(doAn); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = doAn.MaDA }, doAn)); }
private DoAn GetDoAnFromDataRow(DataRow row) { DoAn s = new DoAn(); s.MaDoAn = row["Ma_Do_An"].ToString(); s.TenDoAn = row["Ten_Do_An"].ToString(); s.TenSV = row["Ten_SV"].ToString(); s.NamThucHien = (int)row["Nam_Thuc_Hien"]; s.TinhTrang = (row["Tinh_Trang"] as int? == 1) ? true : false; s.Ma_Huong_NC = row["Ma_Huong_NC"].ToString(); s.ID_GVHD = row["ID_GVHD"].ToString(); return(s); }
public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } DoAn doAn = db.DoAns.Find(id); if (doAn == null) { return(HttpNotFound()); } return(View(doAn)); }
public DoAn[] findByName(string name) { string sqlCmd = "SELECT * FROM DoAN WHERE DoAN.Ten_Do_An LIKE " + "'%" + name + "%'"; DataTable d = DBHelper.DBExcuteQuery(sqlCmd); int count = d.Rows.Count; DoAn[] doAns = new DoAn[count]; for (int i = 0; i < count; i++) { doAns[i] = GetDoAnFromDataRow(d.Rows[i]); } return(doAns); }
public DoAn[] getAllDoAn() { string sqlCmd = "SELECT * FROM DoAN"; DataTable d = DBHelper.DBExcuteQuery(sqlCmd); int count = d.Rows.Count; DoAn[] doAns = new DoAn[count]; for (int i = 0; i < count; i++) { doAns[i] = GetDoAnFromDataRow(d.Rows[i]); } return(doAns); }
public IHttpActionResult DeleteDoAn(int id) { DoAn doAn = db.DoAns.Find(id); if (doAn == null) { return(NotFound()); } db.DoAns.Remove(doAn); db.SaveChanges(); return(Ok(doAn)); }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } DoAn doAn = db.DoAns.Find(id); if (doAn == null) { return(HttpNotFound()); } ViewBag.SinhVienId = new SelectList(db.SinhViens, "Id", "Name"); return(View(doAn)); }
public void setData(DoAn da) { txtMaDATN.Text = da.MaDoAn; txtSVTH.Text = da.TenSV; txtTenDATN.Text = da.TenDoAn; if (da.TinhTrang) { rbnDaBaoVe.Select(); } else { rbnChuaBaoVe.Select(); } prepareComboBox(da); }
public void save(DoAn da) { string sqlCmd = "INSERT INTO DoAN(Ma_Do_An , Ten_Do_An , Ten_SV, Nam_Thuc_Hien, Tinh_Trang , Ma_Huong_NC , ID_GVHD) " + "VALUES( @MDA,@TDA ,@TSV,@NTH,@TT,@MHNC,@ID_GVHD)"; DBHelper.OpenConnection(); SqlCommand cmd = DBHelper.GetSqlCommand(sqlCmd); cmd.Parameters.AddWithValue("@MDA", da.MaDoAn); cmd.Parameters.AddWithValue("@TDA", da.TenDoAn); cmd.Parameters.AddWithValue("@TSV", da.TenSV); cmd.Parameters.AddWithValue("@NTH", da.NamThucHien); cmd.Parameters.AddWithValue("@TT", da.TinhTrang); cmd.Parameters.AddWithValue("@MHNC", da.Ma_Huong_NC); cmd.Parameters.AddWithValue("@ID_GVHD", da.ID_GVHD); cmd.ExecuteNonQuery(); DBHelper.CloseConnection(); }
public List <DoAn> getDoAn(string trangthaidoan) { List <THONGTINDOAN> listThongtindoan; List <Domain> listQuanHuyen; List <ListDoAn> ListThongTinDoAn; ListDoAn doanMenu; List <DoAn> listDoAnQuyHoach = new List <DoAn>(); DoAn doAnQuyHoach; listQuanHuyen = this.gISRepository.getDomain("DMHuyenTPThiXa").ToList(); listQuanHuyen = listQuanHuyen.OrderBy(qh => qh.value).ToList(); for (int q = 0; q < listQuanHuyen.Count; q++) { Domain QuanHuyen = listQuanHuyen[q]; listThongtindoan = this.gISRepository.getThongTinDoAn().Where(da => da.MaQuanHuyen.Trim() == QuanHuyen.code.Trim() && da.TrangThaiDoAn == trangthaidoan).ToList(); ListThongTinDoAn = new List <dataHelper.ListDoAn>(); for (int i = 0; i < listThongtindoan.Count; i++) { THONGTINDOAN doan = listThongtindoan[i]; doanMenu = new ListDoAn(); doanMenu.MaDoAn = doan.MaDoAn; doanMenu.TenDoAn = doan.TenDoAn; ListThongTinDoAn.Add(doanMenu); } doAnQuyHoach = new DoAn(); doAnQuyHoach.MaQuanHuyen = QuanHuyen.code; doAnQuyHoach.TenQuanHuyen = QuanHuyen.value; doAnQuyHoach.ListDoAnQuyHoach = ListThongTinDoAn; listDoAnQuyHoach.Add(doAnQuyHoach); } return(listDoAnQuyHoach); }
public DoAn getDoAn(int id) { conn.Open(); string sql = "select * from doan where id=@id"; SqlCommand cmd = new SqlCommand(sql, conn); cmd.Parameters.AddWithValue("id", id); SqlDataReader reader = cmd.ExecuteReader(); DoAn doan = new DoAn(); while (reader.Read()) { doan.ID = id; doan.TenDoAn = Convert.ToString(reader["tendoan"]); doan.AuthorID = Convert.ToString(reader["authorID"]); doan.MoTa = Convert.ToString(reader["mota"]); } conn.Close(); return(doan); }
public ActionResult Create(DoAn doAn, HttpPostedFileBase fileupload) { if (fileupload == null) { ViewBag.Thongbao = "Vui lòng chọn ảnh"; return(View()); } //Them vao CSDL else { if (ModelState.IsValid) { var fileName = Path.GetFileName(fileupload.FileName); //Luu duong dan cua file var path = Path.Combine(Server.MapPath("~/images"), fileName); //Kiem tra hình anh ton tai chua? if (System.IO.File.Exists(path)) { ViewBag.Thongbao = "Hình ảnh đã tồn tại"; return(View(doAn)); } else { //Luu hinh anh vao duong dan fileupload.SaveAs(path); } doAn.AnhDA = fileName; //Luu vao CSDL db.DoAns.Add(doAn); db.SaveChanges(); ViewBag.MaDM = new SelectList(db.DanhMucDoAns.ToList().OrderBy(n => n.TenDM), "MaDM", "TenDM"); ViewBag.doan = listda; ViewBag.CountDoan = listda.Count; HttpResponseMessage response = client.PostAsJsonAsync(url + @"doan/", doAn).Result; response.EnsureSuccessStatusCode(); SetAlert("Thêm sản phẩm thành công!!!", "success"); } return(RedirectToAction("Index")); } }
public ActionResult Create(DoAn doAn, HttpPostedFileBase fileupload) { if (fileupload == null) { ViewBag.Thongbao = "Vui lòng chọn ảnh"; return(View()); } //Them vao CSDL else { if (ModelState.IsValid) { var fileName = Path.GetFileName(fileupload.FileName); //Luu duong dan cua file var path = Path.Combine(Server.MapPath("~/images"), fileName); //Kiem tra hình anh ton tai chua? if (System.IO.File.Exists(path)) { ViewBag.Thongbao = "Hình ảnh đã tồn tại"; return(View(doAn)); } else { //Luu hinh anh vao duong dan fileupload.SaveAs(path); } doAn.AnhDA = fileName; //Luu vao CSDL db.DoAns.Add(doAn); db.SaveChanges(); HttpResponseMessage response = client.PostAsJsonAsync(url + @"doan/", doAn).Result; response.EnsureSuccessStatusCode(); } TempData["SuccsessMessage"] = "Thêm mới thành công!!!"; return(RedirectToAction("Index")); } }
public void update(DoAn da) { string updateCmdString = ""; updateCmdString = " UPDATE DoAN" + " SET Ten_Do_An = @TDA , Ten_SV = @TSV, Nam_Thuc_Hien = @NTH, Tinh_Trang = @TT, Ma_Huong_NC = @MHNC, ID_GVHD = @ID_GVHD" + " WHERE Ma_Do_An = @MDA"; DBHelper.OpenConnection(); SqlCommand cmd = DBHelper.GetSqlCommand(updateCmdString); cmd.Parameters.AddWithValue("@MDA", da.MaDoAn); cmd.Parameters.AddWithValue("@TDA", da.TenDoAn); cmd.Parameters.AddWithValue("@TSV", da.TenSV); cmd.Parameters.AddWithValue("@NTH", da.NamThucHien); cmd.Parameters.AddWithValue("@TT", da.TinhTrang); cmd.Parameters.AddWithValue("@MHNC", da.Ma_Huong_NC); cmd.Parameters.AddWithValue("@ID_GVHD", da.ID_GVHD); cmd.ExecuteNonQuery(); DBHelper.CloseConnection(); }
public void save(DoAn da) { doAnDAL.save(da); }
public async Task <DoAn> Create(DoAnForCreateDto doAn) { var danhSachDoAn = await _context.DanhSachDoAn.OrderByDescending(x => x.MaDoAn).FirstOrDefaultAsync(); var maDoAn = 0; if (danhSachDoAn == null) { maDoAn = 0; } else { maDoAn = danhSachDoAn.MaDoAn + 1; } var newDoAn = new DoAn { MaDoAn = maDoAn, TenDoAn = doAn.TenDoAn, MoTa = doAn.MoTa, MaHuongNghienCuu = doAn.MaHuongNghienCuu, LienKetTaiDoAn = doAn.LienKetTaiDoAn, ThoiGianBaoCao = doAn.ThoiGianBaoCao, MaHocKy = doAn.MaHocKy, DiemTongKet = 8, NhanXetChung = doAn.NhanXetChung, DiaDiemBaoCao = doAn.DiaDiemBaoCao, ThoiGianTao = DateTime.Now, ThoiGianCapNhat = DateTime.Now, TrangThai = 1 }; await _context.DanhSachDoAn.AddAsync(newDoAn); await _context.SaveChangesAsync(); // Hướng dẫn đồ án for (int i = 0; i < doAn.HuongDanDoAn.Count; i++) { var record = new HuongDanDoAn { MaDoAn = maDoAn, MaGiangVien = doAn.HuongDanDoAn.ElementAt(i).MaGiangVien, NhanXet = doAn.HuongDanDoAn.ElementAt(i).NhanXet }; await _context.DanhSachHuongDanDoAn.AddAsync(record); await _context.SaveChangesAsync(); } // Phản biện đồ án for (int i = 0; i < doAn.PhanBienDoAn.Count; i++) { var record = new PhanBienDoAn { MaDoAn = maDoAn, MaGiangVien = doAn.PhanBienDoAn.ElementAt(i).MaGiangVien, NhanXet = doAn.PhanBienDoAn.ElementAt(i).NhanXet }; await _context.DanhSachPhanBienDoAn.AddAsync(record); await _context.SaveChangesAsync(); } // Hội đồng bảo vệ for (int i = 0; i < doAn.BaoVeDoAn.Count; i++) { var record = new ThanhVienHDBV { MaDoAn = maDoAn, MaGiangVien = doAn.BaoVeDoAn.ElementAt(i).MaGiangVien, ChucVu = doAn.BaoVeDoAn.ElementAt(i).ChucVu }; await _context.DanhSachThanhVienHDBV.AddAsync(record); await _context.SaveChangesAsync(); } // Điểm đồ án for (int i = 0; i < doAn.DiemDoAn.Count; i++) { var record = new DiemDoAn { MaDoAn = maDoAn, MaGiangVien = doAn.DiemDoAn.ElementAt(i).MaGiangVien, Diem = doAn.DiemDoAn.ElementAt(i).Diem, HeSo = doAn.DiemDoAn.ElementAt(i).HeSo }; await _context.DanhSachDiemDoAn.AddAsync(record); await _context.SaveChangesAsync(); } // Thực hiện đồ án for (int i = 0; i < doAn.ThucHienDoAn.Count; i++) { var oldRecord = _context.DanhSachSinhVien.AsNoTracking().FirstOrDefault(x => x.MaSinhVien == doAn.ThucHienDoAn.ElementAt(i)); var sinhVienToUpdate = new SinhVien { MaSinhVien = doAn.ThucHienDoAn.ElementAt(i), HoVaTen = oldRecord.HoVaTen, MaLop = oldRecord.MaLop, GioiTinh = oldRecord.GioiTinh, NgaySinh = oldRecord.NgaySinh, Email = oldRecord.Email, QueQuan = oldRecord.QueQuan, DiaChi = oldRecord.DiaChi, SoDienThoai = oldRecord.SoDienThoai, ThoiGianTao = oldRecord.ThoiGianTao, ThoiGianCapNhat = DateTime.Now, TrangThai = oldRecord.TrangThai, MaDoAn = maDoAn }; _context.DanhSachSinhVien.Update(sinhVienToUpdate); await _context.SaveChangesAsync(); } return(newDoAn); }
public void createData(DoAn da) { doAnBll.save(da); dataGridView.DataSource = doAnBll.getListDoAn(); }
public void update(DoAn da) { doAnDAL.update(da); }