private void ToolStripMenuItemDangKy_Click(object sender, EventArgs e) { PhieuDangKy ds = new PhieuDangKy(); ds.maphong = this.mahphong; ds.ShowDialog(); }
public bool Create(PhieuDangKy entity) { var phieuThu = db.PhieuDangKy.Add(entity); db.SaveChanges(); return(phieuThu != null); }
private void btndangky_Click(object sender, EventArgs e) { try { PhieuDangKy PDK = new PhieuDangKy(); PDK.MaPhieuDK = tbxmapdk.Text.Trim(); PDK.MaDeTai = tbxmadt.Text.Trim(); PDK.NgayDK = dtpngaydkdt.Value; PDK.MSSV = tbxmssv.Text.Trim(); PhieuDangKyBLL PDKBLL = new PhieuDangKyBLL(); string _MaPhieuDK = tbxmapdk.Text.Trim(); if (!(PDKBLL.CheckID(_MaPhieuDK))) { PDKBLL.Insert(PDK); LoadData(); } else { MessageBox.Show("Mã lớp " + _MaPhieuDK.ToString() + "đã tồn tại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception ex) { MessageBox.Show("Thêm bị lỗi: " + ex.Message.ToString(), "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
public ActionResult DeleteConfirmed(int id) { PhieuDangKy phieuDangKy = db.PhieuDangKies.Find(id); db.PhieuDangKies.Remove(phieuDangKy); db.SaveChanges(); return(RedirectToAction("Index")); }
public int Update(PhieuDangKy obj) { int result = 0; string strQuery = "update PHIEUDANGKI set NgayDK='" + obj.NgayDK + "',FK_MaDeTai='" + obj.MaDeTai + "' where MaPhieuDK='" + obj.MaPhieuDK + "'"; DataConfig config = new DataConfig(); result = config.excuteNoneQuery(strQuery); return(result); //tra ve so ghi nhan thuc hien }
//ham tim kiem //public DataTable TimKiem(string chuoi) //{ // DataTable result = new DataTable(); // DataConfig config = new DataConfig();//tao ket noi // string strQuery = "select * from PHIEUDANGKI where MaPhieuDK like'%" + chuoi + "%'"; // tim kiem theo ma // result = config.GetData(strQuery);// form load len thi thuc hien load data // return result; //} //them csdl public int Insert(PhieuDangKy obj) { int result = 0; string strQuery = "insert into PHIEUDANGKI (MaPhieuDK,NgayDK,FK_MaDeTai,FK_MSSV) values ('" + obj.MaPhieuDK + "','" + obj.NgayDK + "','" + obj.MaDeTai + "','" + obj.MSSV + "')"; DataConfig config = new DataConfig(); result = config.excuteNoneQuery(strQuery); return(result); //tra ve so ghi nhan thuc hien }
public ActionResult Edit([Bind(Include = "PhieuDangKyId,DaiLyId,NgayDangKy,SLDangKy")] PhieuDangKy phieuDangKy) { if (ModelState.IsValid) { db.Entry(phieuDangKy).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.DaiLyId = new SelectList(db.DaiLies, "DaiLyId", "TenDaiLy", phieuDangKy.DaiLyId); return(View(phieuDangKy)); }
public IActionResult Getcv(string id) { try { PhieuDangKy model = _db.PhieuDangKy.Find(id); return(Ok(model)); } catch (Exception) { return(BadRequest()); } }
// GET: Admin/PhieuDangKies/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } PhieuDangKy phieuDangKy = db.PhieuDangKies.Find(id); if (phieuDangKy == null) { return(HttpNotFound()); } return(View(phieuDangKy)); }
public IActionResult Post3(string id) { try { PhieuDangKy del = _db.PhieuDangKy.FirstOrDefault(x => x.MaPhieuDangKy == id); del.TrangThai = false; _db.SaveChanges(); return(Ok("Xoa thanh cong")); } catch { return(BadRequest()); } }
// GET: Admin/PhieuDangKies/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } PhieuDangKy phieuDangKy = db.PhieuDangKies.Find(id); if (phieuDangKy == null) { return(HttpNotFound()); } ViewBag.DaiLyId = new SelectList(db.DaiLies, "DaiLyId", "TenDaiLy", phieuDangKy.DaiLyId); return(View(phieuDangKy)); }
public void EditPhieuDangKy(PhieuDangKy p) { openConnection(); string query = "update PHIEUDANGKY set MaKH = @MaKH, MaNV = @MaNV, NgayLap = @NgayLap, NgayDi = @NgayDi, MaPhong = @MaPhong, TraTruoc = @TraTruoc, DonVi = @DonVi where MaPhieuDangKy = @MaPhieuDangKy"; SqlCommand cmd = new SqlCommand(query, Conn); cmd.Parameters.AddWithValue("@MaPhieuDangKy", p.MaPhieuDangKy); cmd.Parameters.AddWithValue("@MaKH", p.MaKH); cmd.Parameters.AddWithValue("@MaNV", p.MaNV); cmd.Parameters.AddWithValue("@NgayLap", p.NgayLap); cmd.Parameters.AddWithValue("@NgayDi", p.NgayDi); cmd.Parameters.AddWithValue("@MaPhong", p.MaPhong); cmd.Parameters.AddWithValue("@TraTruoc", p.TraTruoc); cmd.Parameters.AddWithValue("@DonVi", p.DonVi); cmd.ExecuteNonQuery(); }
public void insertPhieuDangKy(PhieuDangKy p) { openConnection(); string query = "insert into PHIEUDANGKY(MaPhieuDangKy, MaKH, MaNV, NgayLap, NgayDi, MaPhong, TraTruoc, DonVi) values (@MaPhieuDangKy, @MaKH, @MaNV, @NgayLap, @NgayDi, @MaPhong, @TraTruoc, @DonVi)"; SqlCommand cmd = new SqlCommand(query, Conn); cmd.Parameters.AddWithValue("@MaPhieuDangKy", p.MaPhieuDangKy); cmd.Parameters.AddWithValue("@MaKH", p.MaKH); cmd.Parameters.AddWithValue("@MaNV", p.MaNV); cmd.Parameters.AddWithValue("@NgayLap", p.NgayLap); cmd.Parameters.AddWithValue("@NgayDi", p.NgayDi); cmd.Parameters.AddWithValue("@MaPhong", p.MaPhong); cmd.Parameters.AddWithValue("@TraTruoc", p.TraTruoc); cmd.Parameters.AddWithValue("@DonVi", p.DonVi); cmd.ExecuteNonQuery(); }
public IActionResult Post2([FromBody] PhieuDangKy cb, string id) { try { PhieuDangKy edit = _db.PhieuDangKy.FirstOrDefault(x => x.MaPhieuDangKy == id); edit.MaCBNV = cb.MaCBNV; edit.MaHocKy = cb.MaHocKy; edit.NgayDangKy = cb.NgayDangKy; edit.NguoiDangKy = cb.NguoiDangKy; _db.SaveChanges(); return(Ok("Them thanh cong")); } catch { return(BadRequest()); } }
public bool Update(PhieuDangKy entity) { try { var model = GetSingle(entity.MaPhieuDangKy); model.MaDaiLy = entity.MaDaiLy; model.NgayDangKy = entity.NgayDangKy; model.TongSoLuongDangKy = entity.TongSoLuongDangKy; db.SaveChanges(); } catch (Exception ex) { return(false); } return(true); }
public ActionResult DangKyLichTrinhTour(FormCollection tour) { if (Session[KHACHHANG] != null) { Khach khach = (Khach)Session["KhachHang"]; PhieuDangKy phieu = new PhieuDangKy(); phieu.MaKhach = khach.MaKhach; if (tour["LichTrinh"] == null) { ViewData["LichTrinh"] = "Bạn chưa chọn lịch trình"; } else { phieu.MaLichtrinh = int.Parse(tour["LichTrinh"]); } phieu.Ngaylap = DateTime.Now; phieu.TinhTrang = null; if (bool.Parse(tour["LoaiThamGia"])) { string[] tens = tour.GetValues("Ten"); string[] sdts = tour.GetValues("SDT"); for (int i = 0; i < tens.Length; i++) { if (!string.IsNullOrEmpty(tens[i]) || !string.IsNullOrEmpty(sdts[i])) { KhachThamGia khachThamGia = new KhachThamGia(); khachThamGia.Ten = tens[i]; khachThamGia.SDT = sdts[i]; phieu.KhachThamGias.Add(khachThamGia); } } } db.PhieuDangKies.InsertOnSubmit(phieu); db.SubmitChanges(); return(Redirect("/")); } return(RedirectToRoute(routeName: "DangNhap")); }
private void btncapnhat_Click(object sender, EventArgs e) { try { PhieuDangKy PDK = new PhieuDangKy(); PDK.MaPhieuDK = tbxmapdk.Text.Trim(); PDK.MaDeTai = tbxmadt.Text.Trim(); PDK.NgayDK = dtpngaydkdt.Value; PDK.MSSV = tbxmssv.Text.Trim(); PhieuDangKyBLL PDKBLL = new PhieuDangKyBLL(); string _MaPhieuDK = tbxmapdk.Text.Trim(); PDKBLL.Update(PDK); LoadData(); } catch (Exception ex) { MessageBox.Show("Sửa bị lỗi: " + ex.Message.ToString(), "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
public IActionResult Post([FromBody] PhieuDangKy cb) { cb.TrangThai = true; try { PhieuDangKy tour = new PhieuDangKy() { MaCBNV = cb.MaCBNV, NgayDangKy = cb.NgayDangKy, NguoiDangKy = cb.NguoiDangKy, MaPhieuDangKy = cb.MaPhieuDangKy, MaHocKy = cb.MaCBNV, TrangThai = cb.TrangThai }; _db.PhieuDangKy.Add(tour); _db.SaveChanges(); return(Ok("Them thanh cong")); } catch (Exception) { return(BadRequest()); } }
public ActionResult Create(List <PhieuDangKyVM> listPDKVM, int daiLyId, System.DateTime ngayDangKy) { if (ModelState.IsValid) { foreach (var item in listPDKVM) { if (item.SLDangKy != 0) { PhieuDangKy phieuDangKy = new PhieuDangKy(); phieuDangKy.LoaiVeSoId = db.LoaiVeSoes.Where(m => m.TenTinh == item.TenTinh).Select(m => m.LoaiVeSoId).FirstOrDefault(); phieuDangKy.DaiLyId = daiLyId; phieuDangKy.NgayDangKy = ngayDangKy; phieuDangKy.SLDangKy = item.SLDangKy; db.PhieuDangKies.Add(phieuDangKy); db.SaveChanges(); } } return(RedirectToAction("Index")); } return(View()); }