public Equipment_Data(int hardware, string model, string warranty, string warBegin, string warEnd, int state, int person) { tblWarranty tblw = new tblWarranty { warranty_name = warranty, warranty_start = warBegin, warranty_end = warEnd }; db.tblWarranties.InsertOnSubmit(tblw); db.SubmitChanges(); tblEquipment tble = new tblEquipment { hardware_code = hardware, equipment_model = model, warranty_code = tblw.warranty_code, state_code = state, equipment_freez = false }; db.tblEquipments.InsertOnSubmit(tble); db.SubmitChanges(); tblReport tblr = new tblReport { Equimpment_code = tble.equipment_code, Person_code = person, Data = DateTime.Now.ToShortDateString() }; db.tblReports.InsertOnSubmit(tblr); db.SubmitChanges(); }
/// <summary> /// Deletes user, users records and identification card depending if the uderID already exists /// </summary> /// <param name="reportID">the user that is being deleted</param> /// <returns>list of users</returns> public void DeleteReport(int reportID) { try { using (ReportDBEntities context = new ReportDBEntities()) { bool isReport = IsReportID(reportID); if (isReport == true) { // find the user and identification card before removing them tblReport reportToDelete = (from r in context.tblReports where r.ReportID == reportID select r).First(); context.tblReports.Remove(reportToDelete); context.SaveChanges(); } else { MessageBox.Show("Cannot delete the report"); } } } catch (Exception ex) { Debug.WriteLine("Exception" + ex.Message.ToString()); } }
public tblReport AddReport(vwReport report) { try { using (WorkingHoursDBEntities context = new WorkingHoursDBEntities()) { tblReport newReport = new tblReport(); newReport.EmployeeID = report.EmployeeID; newReport.DateOfReport = DateTime.Today; newReport.Position = report.Position; newReport.Project = report.Project; context.tblReports.Add(newReport); context.SaveChanges(); report.ReportID = newReport.ReportID; return(newReport); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("Exception" + ex.Message.ToString()); return(null); } }
public ActionResult DeleteConfirmed(int id) { tblReport tblReport = db.tblReports.Find(id); db.tblReports.Remove(tblReport); db.SaveChanges(); return(RedirectToAction("Index")); }
public AddReport(tblReport reportEdit) { InitializeComponent(); this.DataContext = new AddReportViewmodel(this, reportEdit); this.Language = XmlLanguage.GetLanguage("sr-SR"); txtWorkHours.Focus(); }
public AddReportViewmodel(AddReport addReport) { report = new tblReport(); DateTime date = DateTime.Now; report.CurrentDate = date; this.addReport = addReport; }
public ActionResult Edit([Bind(Include = "ReportId,SectorId,ReportTitle,ReportDate,ReportFilePath")] tblReport tblReport) { if (ModelState.IsValid) { db.Entry(tblReport).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.SectorId = new SelectList(db.tblSectors, "SectorId", "SectorName", tblReport.SectorId); return(View(tblReport)); }
public ActionResult Edit([Bind(Include = "Report_ID,Report_Contents,Report_DateSend,Report_User,Report_Blog,Report_Post")] tblReport tblReport) { if (ModelState.IsValid) { db.Entry(tblReport).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Report_Blog = new SelectList(db.tblBlogs, "BLog_ID", "Blog_Title", tblReport.Report_Blog); ViewBag.Report_Post = new SelectList(db.tblPosts, "Post_ID", "Post_Title", tblReport.Report_Post); return(View(tblReport)); }
// GET: Reports/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tblReport tblReport = db.tblReports.Find(id); if (tblReport == null) { return(HttpNotFound()); } return(View(tblReport)); }
public JsonResult SaveReport(tblReport model) { var service = new CreateServices(); var res = service.SaveReport(model); if (res) { return(Json(new { success = true })); } else { return(Json(new { success = false })); } }
public ActionResult Report(int?id, string Report_Contents) { tblUser user = db.tblUsers.Find(int.Parse(Request.Cookies["member_id"].Value.ToString())); tblReport addItem = new tblReport() { Report_Contents = Report_Contents, Report_DateSend = DateTime.Now, Report_Post = id, Report_User = user.User_ID }; db.tblReports.Add(addItem); db.SaveChanges(); return(RedirectToAction("Details", new { id })); }
// GET: Reports/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tblReport tblReport = db.tblReports.Find(id); if (tblReport == null) { return(HttpNotFound()); } ViewBag.SectorId = new SelectList(db.tblSectors, "SectorId", "SectorName", tblReport.SectorId); return(View(tblReport)); }
public JsonResult UpdateReport(tblReport model) { var service = new UpdateServices(); var res = (bool)service.SaveChangesReport(model); if (res) { return(Json(new { success = true })); } else { return(Json(new { success = false })); } }
/// <summary> /// Creates or edits a report /// </summary> /// <param name="report">the report that is being added</param> /// <returns>a new or edited report</returns> public vwUserReport AddReport(vwUserReport report) { InputCalculator iv = new InputCalculator(); try { using (ReportDBEntities context = new ReportDBEntities()) { if (report.ReportID == 0) { tblReport newReport = new tblReport { Project = report.Project, ReportDate = report.ReportDate, ReportHours = report.ReportHours, UserID = Service.LoggedInUser[0].UserID }; context.tblReports.Add(newReport); context.SaveChanges(); report.ReportID = newReport.ReportID; return(report); } else { tblReport reportToEdit = (from ss in context.tblReports where ss.ReportID == report.ReportID select ss).First(); reportToEdit.Project = report.Project; reportToEdit.ReportDate = report.ReportDate; reportToEdit.ReportHours = report.ReportHours; reportToEdit.UserID = report.UserID; reportToEdit.ReportID = report.ReportID; tblReport reportEdit = (from ss in context.tblReports where ss.ReportID == report.ReportID select ss).First(); context.SaveChanges(); return(report); } } } catch (Exception ex) { Debug.WriteLine("Exception" + ex.Message.ToString()); return(null); } }
// GET: Admin/tblReportsAdmin/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tblReport tblReport = db.tblReports.Find(id); if (tblReport == null) { return(HttpNotFound()); } ViewBag.Report_Blog = new SelectList(db.tblBlogs, "BLog_ID", "Blog_Title", tblReport.Report_Blog); ViewBag.Report_Post = new SelectList(db.tblPosts, "Post_ID", "Post_Title", tblReport.Report_Post); return(View(tblReport)); }
public tblReport Get(int id) { tblReport data = null; try { using (var dbContext = new PMSEntities()) { data = dbContext.tblReports.Where(x => x.Id == id).ToList().FirstOrDefault(); } } catch (Exception ex) { } return(data); }
public void DeleteReport(int reportID) { try { using (ManagerAppEntities context = new ManagerAppEntities()) { tblReport reportToDelete = (from r in context.tblReports where r.ReportID == reportID select r).First(); context.tblReports.Remove(reportToDelete); context.SaveChanges(); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("Exception: " + ex.Message.ToString()); } }
public int Insert(tblReport data) { try { using (var dbContext = new PMSEntities()) { data.ReportId = Guid.NewGuid(); dbContext.tblReports.Add(data); dbContext.SaveChanges(); } return(1); } catch (Exception ex) { return(0); } }
public int Update(tblReport data) { try { using (var dbContext = new PMSEntities()) { dbContext.tblReports.Attach(data); dbContext.Entry(data).State = EntityState.Modified; dbContext.SaveChanges(); } return(1); } catch (Exception ex) { return(0); } }
// GET: PMS/Reports public ActionResult ReportsData(int?id) { List <FilterEntity> listFilters = _filterService.GetFilters(); ViewBag.Filters = listFilters; tblReport data = null; if (id == null) { data = new tblReport(); } else { data = _reportsService.Get(id.Value); } return(View(data)); }
public bool SaveReport(tblReport model) { using (var dbContextTransaction = _db.Database.BeginTransaction()) { try { _db.Reports.Add(model); _db.SaveChanges(); dbContextTransaction.Commit(); return(true); } catch (Exception) { dbContextTransaction.Rollback(); return(false); } } }
public void AddReport(tblReport report) { report.ReportDate = DateTime.ParseExact(DateTime.Now.ToString("yyyy-MM-dd"), "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture); using (StreamReader sr = new StreamReader("../../ID.txt")) { string line; while ((line = sr.ReadLine()) != null) { report.EmployeeID = Convert.ToInt32(line); } } using (EmployeeEntities context = new EmployeeEntities()) { tblEmployee employee = (from x in context.tblEmployees where x.EmployeeID == report.EmployeeID select x).First(); report.FullName = employee.EmployeeName + " " + employee.EmployeeLastName; context.tblReports.Add(report); context.SaveChanges(); } }
public tblReport AddReport(tblReport report) { try { using (ManagerAppEntities context = new ManagerAppEntities()) { if (report.ReportID == 0) { tblReport newProducts = new tblReport { CurrentDate = report.CurrentDate, ProjectName = report.ProjectName, WorkHour = report.WorkHour, Employee = report.Employee, Position = report.Position }; context.tblReports.Add(newProducts); context.SaveChanges(); report.ReportID = newProducts.ReportID; return(report); } else { tblReport reportToEdit = (from ss in context.tblReports where ss.ReportID == report.ReportID select ss).First(); reportToEdit.CurrentDate = report.CurrentDate; reportToEdit.ProjectName = report.ProjectName; reportToEdit.WorkHour = report.WorkHour; reportToEdit.Employee = report.Employee; reportToEdit.Position = report.Position; reportToEdit.ReportID = report.ReportID; context.SaveChanges(); return(report); } } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("Exception: " + ex.Message.ToString()); return(null); } }
public void DeleteReport(int id) { try { using (WorkingHoursDBEntities context = new WorkingHoursDBEntities()) { tblReport reportToDelete = (from u in context.tblReports where u.ReportID == id select u).First(); context.tblReports.Remove(reportToDelete); context.SaveChanges(); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("Exception" + ex.Message.ToString()); } }
public bool SaveChangesReport(tblReport model) { using (var dbContextTransaction = _db.Database.BeginTransaction()) { try { tblReport item = _db.Reports.Where(x => x.id == model.id).FirstOrDefault(); item.name = model.name; item.code = model.code; item.description = model.description; _db.SaveChanges(); dbContextTransaction.Commit(); return(true); } catch (Exception) { dbContextTransaction.Rollback(); return(false); } } }
/// <summary> /// Deletes user, users records and identification card depending if the uderID already exists /// </summary> /// <param name="userID">the user that is being deleted</param> /// <returns>list of users</returns> public void DeleteWorker(int userID) { InputCalculator iv = new InputCalculator(); List <tblReport> AllReports = GetAllReports(); try { using (ReportDBEntities context = new ReportDBEntities()) { bool isUser = IsUserID(userID); // Delete are evidences from the user for (int i = 0; i < AllReports.Count; i++) { if (AllReports[i].UserID == userID) { tblReport report = (from r in context.tblReports where r.UserID == userID select r).First(); context.tblReports.Remove(report); context.SaveChanges(); } } if (isUser == true) { // find the user and identification card before removing them tblUser userToDelete = (from r in context.tblUsers where r.UserID == userID select r).First(); context.tblUsers.Remove(userToDelete); context.SaveChanges(); } else { MessageBox.Show("Cannot delete the user"); } } } catch (Exception ex) { Debug.WriteLine("Exception" + ex.Message.ToString()); } }
public tblReport EditReport(vwReport report) { try { using (WorkingHoursDBEntities context = new WorkingHoursDBEntities()) { tblReport reportToEdit = (from u in context.tblReports where u.ReportID == report.ReportID select u).First(); reportToEdit.Position = report.Position; reportToEdit.Project = report.Project; reportToEdit.NumberOfHours = report.NumberOfHours; context.SaveChanges(); return(reportToEdit); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("Exception" + ex.Message.ToString()); return(null); } }
public EmployeeViewModel(View.Employee open, int id) { emp = open; newReport = new tblReport(); newReport.employeeId = id; }
public JsonResult SaveReport() { int result = 0; tblReport data = JsonConvert.DeserializeObject <tblReport>(Request["data"]); if (Request.Files.Count > 0) { HttpFileCollectionBase files = Request.Files; HttpPostedFileBase file = files[0]; string folderPath = ConfigurationManager.AppSettings["ReportsPath"]; string fileName = ""; if (!Directory.Exists(folderPath)) { Directory.CreateDirectory(folderPath); } if (data.IsFileAttached) { fileName = Request.Files[0].FileName; if (!string.IsNullOrEmpty(data.FilePath) && data.IsFileAttached) { System.IO.File.Delete(data.FilePath); } if (!System.IO.File.Exists(folderPath + fileName)) { Request.Files[0].SaveAs(folderPath + fileName); data.FilePath = folderPath + fileName; data.FileName = fileName; } else { fileName = "1_" + Request.Files[0].FileName; if (!System.IO.File.Exists(folderPath + fileName)) { fileName = DateTime.Now.ToString("ddMMyyyHHmmsss") + "_1_" + Request.Files[0].FileName; } Request.Files[0].SaveAs(folderPath + fileName); data.FilePath = folderPath + fileName; data.FileName = fileName; } } if (data.IsOtherFileAttached) { int index = 1; if (!data.IsOtherFileAttached) { index = 0; } fileName = Request.Files[index].FileName; if (!string.IsNullOrEmpty(data.OtherFilePath) && data.IsOtherFileAttached) { System.IO.File.Delete(data.OtherFilePath); } if (!System.IO.File.Exists(folderPath + fileName)) { Request.Files[index].SaveAs(folderPath + fileName); data.OtherFilePath = folderPath + fileName; data.OtherFileName = fileName; } else { fileName = "1_" + Request.Files[index].FileName; if (!System.IO.File.Exists(folderPath + fileName)) { fileName = DateTime.Now.ToString("ddMMyyyHHmmsss") + "_1_" + Request.Files[index].FileName; } Request.Files[index].SaveAs(folderPath + fileName); data.OtherFilePath = folderPath + fileName; data.OtherFileName = fileName; } } } if (data.Id == 0) { result = _reportsService.Insert(data); } else { result = _reportsService.Update(data); } return(Json(result, JsonRequestBehavior.AllowGet)); }
public EmployeeViewModel(Employee employeeOpen) { report = new tblReport(); employee = employeeOpen; }