public void MakeRequest(string staffID, DateTime start, DateTime end) { try { // Find the staff account in the db var employQuery = (from a in db.employees where a.StaffID == int.Parse(staffID) select a).Single(); employee requestor = employQuery; // Make the holiday object and add the employee holiday wantedDays = new holiday { employee = requestor, StartDate = start, EndDate = end, Status = "Pending" }; //Save changes to Database db.holidays.InsertOnSubmit(wantedDays); db.SubmitChanges(); } catch (Exception ex) { MessageBox.Show(ex.Message); throw; } }
public ActionResult DeleteConfirmed(int id) { holiday holiday = db.holiday.Find(id); db.holiday.Remove(holiday); db.SaveChanges(); return(RedirectToAction("Index")); }
protected void delete_Click(object sender, EventArgs e) { holiday h = PolaczenieSQL.find_holiday(this.l_id.Text); h.deleted(Context.User.Identity.Name); string url_text = "menager_holiday.aspx?holidayid=" + this.l_id.Text; Response.Redirect(url_text); }
public ActionResult Edit([Bind(Include = "id,dateStart,nbrDays,status,type,FK_EMPLOYEE_HOLIDAY")] holiday holiday) { if (ModelState.IsValid) { db.Entry(holiday).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.FK_EMPLOYEE_HOLIDAY = new SelectList(db.employee, "id", "State", holiday.FK_EMPLOYEE_HOLIDAY); return(View(holiday)); }
protected void ZapiszButton_Click(object sender, EventArgs e) { //Page.Validate(); if (Page.IsValid) { holiday h = new holiday(OdTextBox.Text, DoTextBox.Text, DropDownMenager.SelectedValue, "1", "1", DropDownHoliday.SelectedValue, Context.User.Identity.Name); user u = PolaczenieSQL.find_user(Context.User.Identity.Name, false, true); PolaczenieSQL.insertholiday(h, u); string url_text = "myholidays.aspx"; Response.Redirect(url_text); } }
// GET: holidays/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } holiday holiday = db.holiday.Find(id); if (holiday == null) { return(HttpNotFound()); } return(View(holiday)); }
// GET: holidays/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } holiday holiday = db.holiday.Find(id); if (holiday == null) { return(HttpNotFound()); } ViewBag.FK_EMPLOYEE_HOLIDAY = new SelectList(db.employee, "id", "State", holiday.FK_EMPLOYEE_HOLIDAY); return(View(holiday)); }
public ActionResult Delete(holiday newholiday) { //if (id == null) //{ // return new HttpStatusCodeResult(HttpStatusCode.BadRequest); //} int id = newholiday.Id; holiday holiday = db.holiday.Find(id); if (holiday == null) { return(HttpNotFound()); } db.holiday.Remove(holiday); db.SaveChanges(); return(RedirectToAction("Index", "BKCompany")); }
public ActionResult Create(holiday holiday) { if (ModelState.IsValid) { if (holiday.EndTime < holiday.StartTime) { ViewBag.Alert = "起始時間不得小於結束時間"; return(RedirectToAction("Index", "BKCompany")); } //holiday newHoliday =new holiday(); //newHoliday.StartTime = holiday.HolidayStartTime; //newHoliday.EndTime = holiday.HolidayEndTime; db.holiday.Add(holiday); db.SaveChanges(); return(RedirectToAction("Index", "BKCompany")); } ViewBag.Alert = "時間不可以為空值"; return(RedirectToAction("Index", "BKCompany")); }
public ActionResult Save(int?id, FormCollection actionValues) { var action = new DataAction(actionValues); try { var changedEvent = DHXEventsHelper.Bind <HolidayVM>(actionValues); holiday h = new holiday { holidayId = changedEvent.holidayId, startDate = changedEvent.startDate, endDate = changedEvent.endDate, name = changedEvent.name }; switch (action.Type) { case DataActionTypes.Insert: hs.Add(h); hs.Commit(); break; case DataActionTypes.Delete: hs.Delete(holiday => holiday.holidayId == changedEvent.holidayId); hs.Commit(); break; case DataActionTypes.Update: hs.Update(h); hs.Commit(); break; default: break; } action.TargetId = changedEvent.holidayId; } catch (Exception a) { action.Type = DataActionTypes.Error; } return(new AjaxSaveResponse(action)); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { if (Request.QueryString["holidayid"] != null) { string holidayid = Request.QueryString["holidayid"]; holiday new_h = PolaczenieSQL.find_holiday(holidayid); if (new_h.menager != Context.User.Identity.Name && new_h.othermenager != Context.User.Identity.Name) { Response.Redirect("menager_holidays.aspx"); } string user_name_string = PolaczenieSQL.find_user(new_h.userid).ToString(); switch (new_h.statusid) { case "1": butt_delete.Visible = false; butt_app_men.Visible = true; butt_app_hr.Visible = false; butt_rej_men.Visible = true; butt_rej_hr.Visible = false; label_status.BackColor = Color.LightYellow; break; case "2": butt_delete.Visible = false; butt_app_men.Visible = false; butt_app_hr.Visible = false; butt_rej_men.Visible = true; butt_rej_hr.Visible = false; label_status.BackColor = Color.LightYellow; break; case "3": butt_delete.Visible = false; butt_app_men.Visible = false; butt_app_hr.Visible = false; butt_rej_men.Visible = true; butt_rej_hr.Visible = false; label_status.BackColor = Color.LightGreen; break; case "4": butt_delete.Visible = false; butt_app_men.Visible = false; butt_app_hr.Visible = false; butt_rej_men.Visible = false; butt_rej_hr.Visible = false; label_status.BackColor = Color.LightPink; break; case "5": butt_delete.Visible = false; butt_app_men.Visible = false; butt_app_hr.Visible = false; butt_rej_men.Visible = false; butt_rej_hr.Visible = false; label_status.BackColor = Color.LightPink; break; case "6": butt_delete.Visible = false; butt_app_men.Visible = false; butt_app_hr.Visible = false; butt_rej_men.Visible = false; butt_rej_hr.Visible = false; label_status.BackColor = Color.DarkSeaGreen; break; case "7": butt_delete.Visible = false; butt_app_men.Visible = false; butt_app_hr.Visible = false; butt_rej_men.Visible = false; butt_rej_hr.Visible = false; label_status.BackColor = Color.LightSlateGray; break; } l_id.Text = new_h.holidayid; l_name.Text = user_name_string; l_od.Text = new_h.date_od.ToShortDateString(); l_do.Text = new_h.date_do.ToShortDateString(); l_menager.Text = PolaczenieSQL.find_user(new_h.menager).ToString(); l_ilość_dni.Text = new_h.holiday_dyas_all.ToString(); l_losc_dni_all.Text = new_h.holiday_dyas_ciag.ToString(); string[] days_of_holidays = PolaczenieSQL.find_holiday_days_byuser(new_h.userid); Labelpr.Text = days_of_holidays[0]; Labelor.Text = days_of_holidays[8]; Labelnr.Text = days_of_holidays[9]; Labeldd.Text = days_of_holidays[5]; Labelnz.Text = days_of_holidays[6]; Labelsum.Text = days_of_holidays[10]; Labelwyk.Text = days_of_holidays[3]; if (Convert.ToInt16(Labelsum.Text) > 0) { suncell.BackColor = Color.LightGreen; } if (Convert.ToInt16(Labelsum.Text) <= 0) { suncell.BackColor = Color.LightPink; } h_details.InnerHtml = "Szczegóły urlopu [id:" + holidayid + "]"; h_userdays.InnerHtml = "Dni urlopowe pracownika [" + user_name_string + "]"; PolaczenieSQL.fill_holidays_by_user(GridView1, new_h.userid, 10); PolaczenieSQL.fill_holiday_history(GridView2, holidayid); label_status.Text = "STATUS: " + new_h.status; DateTime date1 = new DateTime(new_h.date_od.Year, new_h.date_od.Month, 1); DateTime date0 = date1.AddMonths(-1); DateTime date2 = date1.AddMonths(1); PageMetods.month_calendar_by_holidayid(bigDiv, date0, date2, new_h.userid, true, new_h.holidayid); Session.Contents.RemoveAll(); GC.SuppressFinalize(this); foreach (System.Collections.DictionaryEntry entry in HttpContext.Current.Cache) { HttpContext.Current.Cache.Remove((string)entry.Key); } } else { Response.Redirect("menager_holidays.aspx"); } } }
public void MarkAsModified(holiday item) { }