private void AutoAddScheduledOrder(schedule record, CtxService service) { if (service == null) { return; } try { int defaultEMPID = service.getDefaultEMPID(); record.MS_Next_Main_Date = DateTime.Now.AddDays(record.MS_Frequency).ToShortDateString() + " " + DateTime.Now.AddDays(record.MS_Frequency).ToShortTimeString(); record.MS_Main_Comp_Date = ""; record.MS_WOCreate_Timestamp = DateTime.Now.AddDays(record.MS_Frequency).ToShortDateString() + " " + DateTime.Now.AddDays(record.MS_Frequency).ToShortTimeString(); record.MS_WOClosed_Timestamp = ""; record.EMP_ID = (record.EMP_ID != 0) ? record.EMP_ID : defaultEMPID; int result = service.Add(record); if (result == 0) { throw new Exception("Error editing scheduled maintenance record."); } else { service.clearCache(); } } finally { service.Dispose(); } }
public void Post([FromBody] schedule data) { var db = dataContext.context(); var collection = db.GetCollection <schedule>("rehearsSched"); collection.InsertOne(data); }
public ActionResult Schedule(schedule obj, HttpPostedFileBase schedulefile) { try { string PhotoPath = Server.MapPath("~/Docs/Images/"); string PhotoName = Guid.NewGuid() + Path.GetFileName(schedulefile.FileName); //3l4an lw atb3t tokins m3 asm l swra y4lha string FinalPhotoPath = Path.Combine(PhotoPath, PhotoName); schedulefile.SaveAs(FinalPhotoPath); if (ModelState.IsValid) { obj.schedulefile = PhotoName; db.schedule.Add(obj); db.SaveChanges(); ModelState.Clear(); return(RedirectToAction("Grades")); } return(View(obj)); } catch (Exception ex) { ViewBag.ScheduleType = new SelectList(db.scheduletype, "id", "TypeOfSchedule"); return(View(obj)); } }
public async Task <IActionResult> Edit(int id, [Bind("Id,ClassName,Location,Date,Time")] schedule schedule) { if (id != schedule.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(schedule); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!scheduleExists(schedule.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(schedule)); }
public ActionResult Edit(int id, schedule sc) { try { using (inventorymgtEntities db = new inventorymgtEntities()) { db.Entry(sc).State = EntityState.Modified; if (sc.Image == null) { var scheduleContext = db.Entry(sc); scheduleContext.State = EntityState.Modified; var clientValues = scheduleContext.CurrentValues.Clone().ToObject(); scheduleContext.Reload(); scheduleContext.CurrentValues.SetValues(clientValues); var currentValues = scheduleContext.Entity; var databaseValues = (schedule)scheduleContext.OriginalValues.ToObject(); scheduleContext.Entity.Image = databaseValues.Image; } db.SaveChanges(); } // TODO: Add update logic here return(RedirectToAction("Index")); } catch { return(View()); } }
private void validateScheduleInputs(schedule record) { if (record == null) { throw new Exception("Object to add cannot be null"); } if (record.MFB_Id == 0) { throw new Exception("FlagBoard must be selected."); } if (record.MM_Id == 0) { throw new Exception("Machine must be selected."); } if (record.EMP_ID == 0) { throw new Exception("Employee must be selected."); } if (record.MT_Id == 0) { throw new Exception("Maintenance type must be selected."); } if (record.MS_Maint_Code == 0) { throw new Exception("Maintenance Code must be selected."); } }
public ActionResult DeleteConfirmed(int id) { schedule schedule = db.schedules.Find(id); db.schedules.Remove(schedule); db.SaveChanges(); return RedirectToAction("Index"); }
public IActionResult Delete([FromBody] schedule ec) { string myurl = url + "api/v1/configuration/lpm/schedule?id=" + ec.id.ToString(); string result = DeleteUrl(myurl); JObject jo = (JObject)JsonConvert.DeserializeObject(result); switch (Convert.ToInt32(jo["code"])) { case 200: Json("Success"); break; case 400: break; case 410: break; case 411: break; default: break; } return(Json("Success")); }
// GET: schedules/Create public ActionResult Create() { schedule model = new schedule(); model.Date = DateTime.Today; model.Hour = DateTime.Now.TimeOfDay; return(View(model)); }
public ActionResult DeleteSchedule(int id) { schedule sch = db.schedules.Single(x => x.schedule_id == id); db.schedules.Remove(sch); db.SaveChanges(); return(RedirectToAction("InfoOfTutor", "Tutor", new { id = Session["UserID"] })); }
/// <summary> /// Saves the schedule to the isolated storage /// </summary> /// <param name="schedule">schedule</param> public void SaveSchedule(schedule schedule) { using (IsolatedStorageFileStream stream = this.myStorage.OpenFile(ScheduleFileName, FileMode.Create)) { XmlSerializer serializer = new XmlSerializer(typeof(schedule)); serializer.Serialize(stream, schedule); } }
public async Task <ActionResult> DeleteConfirmed(int id) { schedule schedule = await db.schedules.FindAsync(id); db.schedules.Remove(schedule); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
/// <summary> /// Gets the schedule from the isolated storage /// </summary> /// <returns>schedule</returns> public schedule GetSchedule() { using (IsolatedStorageFileStream stream = this.myStorage.OpenFile(ScheduleFileName, FileMode.Open)) { XmlSerializer serializer = new XmlSerializer(typeof(schedule)); schedule tempschedule = (schedule)serializer.Deserialize(stream); return(tempschedule); } }
public ActionResult CreateSchedule(schedule schedule) { schedule.status = 2; schedule.dateCreate = DateTime.Now; schedule.tutor_id = int.Parse(Session["UserID"].ToString()); db.schedules.Add(schedule); db.SaveChanges(); return(RedirectToAction("InfoOfTutor", "Tutor", new { id = Session["UserID"] })); }
/// <summary> /// Method which deserializes the download XML schedule /// </summary> /// <param name="rawXML"></param> /// <returns></returns> private schedule DeserializeToSchedule(string rawXML) { XmlSerializer serializer = new XmlSerializer(typeof(schedule)); XDocument document = XDocument.Parse(rawXML); schedule tempschedule = (schedule)serializer.Deserialize(document.CreateReader()); tempschedule.Clean(); return(tempschedule); }
public ActionResult Edit([Bind(Include = "Train_number,Source_Code,Destination_code,schdep,scharr,Distance,Day,Priority")] schedule schedule) { if (ModelState.IsValid) { db.Entry(schedule).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(schedule)); }
public ActionResult Edit([Bind(Include = "Id,time,date,depart,arrive")] schedule schedule) { if (ModelState.IsValid) { db.Entry(schedule).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } return View(schedule); }
public ActionResult Create([Bind(Include = "sn,doc_id,dep_id,hos_id,starttime,endtime,s_display")] schedule schedule) { if (ModelState.IsValid) { db.schedule.Add(schedule); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(schedule)); }
// GET: Schedule/Details/5 public ActionResult Details(int id) { schedule sc = new schedule(); using (inventorymgtEntities db = new inventorymgtEntities()) { sc = db.schedules.Where(m => m.ID == id).FirstOrDefault(); } return(View(sc)); }
public ActionResult Edit([Bind(Include = "scheduleID,hours,fname,lname")] schedule schedule) { if (ModelState.IsValid) { db.Entry(schedule).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(schedule)); }
public ActionResult Create([Bind(Include = "ID,ClientName,Date,Hour")] schedule schedule) { if (ModelState.IsValid) { db.schedules.Add(schedule); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(schedule)); }
public async Task <IActionResult> Create([Bind("Id,ClassName,Location,Date,Time")] schedule schedule) { if (ModelState.IsValid) { _context.Add(schedule); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(schedule)); }
public ActionResult MobileEditor(ICollection <InputObject> pageInputs, string method, string CID, string MSID, string MMID) { int MS_Id = 0, MM_Id = 0; int MFBID = 1; Int32.TryParse(MSID, out MS_Id); Int32.TryParse(MMID, out MM_Id); try { if (CID.Length < 6) { throw new Exception("Location variable in wrong format"); } Helpers.objectMapper <schedule> mapper = new Helpers.objectMapper <schedule>(); schedule record = mapper.mapCollection(pageInputs); MFBID = record.MFB_Id; record.MS_Id = MS_Id; if (record == null) { throw new Exception("ERROR: could not map page inputs. Contact helper desk to log bug."); } switch (method.ToUpper()) { case "SUBMIT": Save(CID, record); break; case "DELETE": delete(CID, record); break; default: throw new Exception("ERROR: NO METHOD RECIEVED"); } } catch (Exception ex) { Models.MobileEditorModel model = getEditorModelObject(CID, MS_Id, MFBID, MM_Id); model.CID = CID; model.MS_Id = MS_Id; model.MM_Id = MM_Id; if (model.inputs.Count > 0) { model.inputs[0].errorFlag = true; model.inputs[0].errorMessage = ex.Message; } model.inputs = mapScheduleValues(model.inputs, model.MS_Id, model.CID); return(View(model)); } return(RedirectToAction("Index", "Home", new { CID = CID })); }
public ActionResult Create([Bind(Include = "scheduleID,hours,fname,lname")] schedule schedule) { if (ModelState.IsValid) { db.schedules.Add(schedule); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(schedule)); }
public ActionResult Edit([Bind(Include = "sn,doc_id,dep_id,hos_id,starttime,endtime,s_display")] schedule schedule) { var newschedule = db.schedule.Where(m => m.sn == schedule.sn).FirstOrDefault(); newschedule.starttime = schedule.starttime.ToLocalTime().ToUniversalTime(); newschedule.endtime = schedule.endtime.ToLocalTime().ToUniversalTime(); newschedule.s_display = schedule.s_display; db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Create([Bind(Include = "Train_number,Source_Code,Destination_code,schdep,scharr,Distance,Day,Priority")] schedule schedule) { if (ModelState.IsValid) { db.schedules.Add(schedule); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(schedule)); }
public ActionResult Create([Bind(Include = "Id,time,date,depart,arrive")] schedule schedule) { if (ModelState.IsValid) { db.schedules.Add(schedule); db.SaveChanges(); return RedirectToAction("Index"); } return View(schedule); }
public async Task <ActionResult> Edit([Bind(Include = "s_id,source,destination,date,cost,bus_id,description")] schedule schedule) { if (ModelState.IsValid) { db.Entry(schedule).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.bus_id = new SelectList(db.buses, "bus_id", "bus_name", schedule.bus_id); return(View(schedule)); }
public ActionResult Edit([Bind(Include = "id,id_subject,id_teacher,cabinet,time")] schedule schedule) { if (ModelState.IsValid) { db.Entry(schedule).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.id_subject = new SelectList(db.subject, "id", "name", schedule.id_subject); ViewBag.id_teacher = new SelectList(db.teacher, "id", "fio", schedule.id_teacher); return(View(schedule)); }
private void Button_Click(object sender, RoutedEventArgs e) { using (var DB = new Scheduler.DB.SchedulerEntities()) { var sch = new schedule(); sch.ID = 1; sch.ScheduleText = "Test"; DB.schedules.Add(sch); DB.SaveChanges(); } }