public ActionResult FullReport() { using (BusManagementContext db = new BusManagementContext()) { ReportDocument rd = new ReportDocument(); rd.Load(Path.Combine(Server.MapPath("~/Report/"), "EmployeeReport.rpt")); var ReportData = (from d in db.tblDepartments join dg in db.tblDesignations on d.Id equals dg.DepartmentID join e in db.tblEmployeeDetails on d.Id equals e.DepartmentID join g in db.tblGenders on e.GenderID equals g.Id select new { e.employeeAddress, e.employeeContact, e.employeePicture, e.employeeName, e.employeeSalary, d.Department, dg.Designation, g.Gender } ).ToList(); rd.SetDataSource(ReportData); Response.Buffer = false; Response.ClearContent(); Response.ClearHeaders(); Stream stream = rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat); stream.Seek(0, SeekOrigin.Begin); return(File(stream, "application/pdf", "EmployeeReport.pdf")); } }
public ActionResult Create(tblEmployeeDetail employeeDetail, HttpPostedFileBase FileUpload) { using (BusManagementContext db = new BusManagementContext()) { try { //Save image in folder string FileName = Path.GetFileName(FileUpload.FileName); string SaveLocation = Server.MapPath("~/EmployeePicture/" + FileName); FileUpload.SaveAs(SaveLocation); //save image name in database employeeDetail.employeeImage = "~/EmployeePicture/" + FileName; // byte image Save employeeDetail.employeePicture = new byte[FileUpload.ContentLength]; ViewBag.TeacherPicture = FileUpload.InputStream.Read(employeeDetail.employeePicture, 0, FileUpload.ContentLength); db.tblEmployeeDetails.Add(employeeDetail); db.SaveChanges(); return(RedirectToAction("Index")); } catch { return(View()); } } }
public ActionResult Delete(VmDepartmentDesignation vm) { using (BusManagementContext db = new BusManagementContext()) { var DepartmentDelete = db.tblDepartments.First(d => d.Id == vm.Id); var DesignationDelete = db.tblDesignations.First(dg => dg.DepartmentID == vm.Id); db.tblDepartments.Remove(DepartmentDelete); db.tblDesignations.Remove(DesignationDelete); db.SaveChanges(); return(View(vm)); } }
// GET: VmDepartmentDesignations/Delete/5 public ActionResult Delete(int id) { using (BusManagementContext db = new BusManagementContext()) { var DepartmentDelete = db.tblDepartments.First(d => d.Id == id); var DesignationDelete = db.tblDesignations.First(dg => dg.DepartmentID == id); db.tblDepartments.Remove(DepartmentDelete); db.tblDesignations.Remove(DesignationDelete); db.SaveChanges(); return(RedirectToAction("Index")); } }
// GET: Employees/Create public ActionResult Create() { using (BusManagementContext db = new BusManagementContext()) { tblEmployeeDetail t = new tblEmployeeDetail(); ViewBag.DepartmentDropdown = db.tblDepartments.ToList(); ViewBag.DesignationsDropdown = db.tblDesignations.ToList(); ViewBag.GenderDropdown = db.tblGenders.ToList(); return(View(t)); } }
// GET: Employees/Details/5 public ActionResult Details(int?id) { using (BusManagementContext db = new BusManagementContext()) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tblEmployeeDetail emp = db.tblEmployeeDetails.Find(id); if (emp == null) { return(HttpNotFound()); } return(View(emp)); } }
public ActionResult Delete(int id) { using (BusManagementContext db = new BusManagementContext()) { try { tblEmployeeDetail emp = db.tblEmployeeDetails.Find(id); db.tblEmployeeDetails.Remove(emp); db.SaveChanges(); return(RedirectToAction("Index")); } catch { return(View()); } } }
// GET: Employees/Edit/5 public ActionResult Edit(int?id) { using (BusManagementContext db = new BusManagementContext()) { ViewBag.DepartmentDropdown = db.tblDepartments.ToList(); ViewBag.DesignationsDropdown = db.tblDesignations.ToList(); ViewBag.GenderDropdown = db.tblGenders.ToList(); if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tblEmployeeDetail emp = db.tblEmployeeDetails.Find(id); if (emp == null) { return(HttpNotFound()); } return(View(emp)); } }
public ActionResult Index() { using (BusManagementContext db = new BusManagementContext()) { List <VmDepartmentDesignation> vmList = new List <VmDepartmentDesignation>(); var DbCollection = (from d in db.tblDepartments join dg in db.tblDesignations on d.Id equals dg.DepartmentID select new { d.Department, dg.Designation } ).ToList(); foreach (var vc in DbCollection) { VmDepartmentDesignation v = new VmDepartmentDesignation(); v.Department = vc.Department; v.Designation = vc.Designation; vmList.Add(v); } return(View(vmList)); } }
public ActionResult Index() { using (BusManagementContext db = new BusManagementContext()) { //List<VmEmployee> vmList = new List<VmEmployee>(); //var ShowIndexList = (from d in db.tblDepartments // join dg in db.tblDesignations on d.Id equals dg.DepartmentID // join e in db.tblEmployeeDetails on d.Id equals e.DepartmentID // join g in db.tblGenders on e.GenderID equals g.Id // select new { e.employeeAddress, e.employeeContact, e.employeeImage, e.employeeName, e.employeeSalary, d.Department, dg.Designation, g.Gender } // ).ToList(); //foreach (var c in ShowIndexList) //{ // VmEmployee v = new VmEmployee(); // v.employeeName = c.employeeName; // v.employeeContact = c.employeeContact; // v.employeeAddress = c.employeeAddress; // v.Department = c.Department; // v.Designation = c.Designation; // v.Gender = c.Gender; // v.employeeSalary = Convert.ToDouble(c.employeeSalary); // v.employeeImage = c.employeeImage; // vmList.Add(v); //} var result = db.tblEmployeeDetails.ToList(); return(View(result)); } // db.tblEmployeeDetails.ToList() }