private void SaveButton_Click(object sender, EventArgs e) { if (Page.IsValid) { try { bool notifyChange = false; if (IsDriving.Checked) { JourneySubscription.NumLifts = Convert.ToInt32(NumLifts.Text); JourneySubscription.SetJourneyStartTime(JourneyStartTime.Text); JourneySubscription.LiftSubscriptionJourneyStationId = null; notifyChange = BLL.HasSubscriptionLiftsSet(JourneySubscription); } else { if (BLL.HasSubscriptionLiftsSet(JourneySubscription)) { RegisterStartupScriptIfNeeded("JourneySaveFailed", string.Format(pbHelpers.JavaScriptAlertString, "Diese Route kann nicht gelöscht werden,\\nda schon Personen definiert sind,\\nwelche mitfahren.")); return; } JourneySubscription.NumLifts = null; foreach (JourneyStation journeyStation in JourneySubscription.journeyStations) { journeyStation.SortOrder = -1; } } BLL.EditSubscription(JourneySubscription, false); if (notifyChange) { //notify all lifts about the change BLL.NofityJourneyChange(JourneySubscription); } #if (DEBUG) System.Threading.Thread.Sleep(2500); #endif RegisterStartupScriptIfNeeded("JourneySaveSuccess", string.Format(pbHelpers.JavaScriptString, "alert('Routendefinition erfolgreich gespeichert.');fClose();")); } catch (EventSiteException ex) { RegisterStartupScriptIfNeeded("SaveJourneyExc", ex.JavaScriptAlertString); JourneySubscription = BLL.GetSubscription(JourneySubscription.SubscriptionId); EventSiteBL.SetJourneyStations(JourneySubscription); } } }
private void LiftChoice_SelectedIndexChanged(object sender, System.EventArgs e) { try { Subscription subscr = Subscription.GetSubscriptionById(SubscriptionsWithLifts, Convert.ToInt32(LiftChoice.SelectedValue)); EventSiteBL.SetJourneyStations(subscr); JourneyStartTime.InnerText = ((JourneyStation)subscr.JourneyStations[0]).StationTime; JourneyStationChoice.DataSource = subscr.JourneyStations; JourneyStationChoice.DataTextField = "Station"; JourneyStationChoice.DataValueField = "JourneyStationId"; JourneyStationChoice.DataBind(); JourneyStationChoice.Items.Insert(0, new ListItem("", "")); } catch {} }
private void Page_Load(object sender, EventArgs e) { //reponse.exires to avoid caching in modal dialog Response.Expires = -1; //Response.Cache.SetNoStore(); if (!BLL.Mandator.IsLiftManagementEnabled) { throw new EventSiteException("Dieses Feature ist auf diesem Mandanten ausgeschaltet!", -1); } if (!IsPostBack) { string sid = Request.QueryString["sid"]; if (sid == null || sid == string.Empty) { throw new EventSiteException("QueryString Parameter 'sid' not found!", 900); } JourneySubscription = BLL.GetSubscription(Convert.ToInt32(sid)); EventSiteBL.SetJourneyStations(JourneySubscription); pageTitle.InnerText = string.Format("Route von {0} definieren", JourneySubscription.Contact.Name); IsDriving.Checked = JourneySubscription.SubscriptionLiftState == LiftState.drives || JourneySubscription.SubscriptionLiftState == LiftState.full; if (IsDriving.Checked) { NumLifts.Text = JourneySubscription.NumLifts.ToString(); if (JourneySubscription.JourneyStations.Count > 0) { JourneyStartTime.Text = ((JourneyStation)JourneySubscription.JourneyStations[0]).StationTime; } } ContactsPastJourneys = BLL.GetPastJourneys(JourneySubscription.Contact); FillPastJourneys(); } if (JourneySubscription.SubscriptionLiftState == LiftState.lift) { RegisterStartupScriptIfNeeded("LiftShouldNotDrive", string.Format(pbHelpers.JavaScriptString, string.Format("alert('Da {0} schon bei jemandem mitfährt, kann nicht\\nnoch eine Route definiert werden. Bei Bedarf muss\\ndie Mitfahrt zuerst entfernt werden.');fClose();", JourneySubscription.Contact.Name))); } }
private void Page_Load(object sender, EventArgs e) { //reponse.exires to avoid caching in modal dialog Response.Expires = -1; //Response.Cache.SetNoStore(); if (!BLL.Mandator.IsLiftManagementEnabled) { throw new EventSiteException("Dieses Feature ist auf diesem Mandanten ausgeschaltet!", -1); } if (!IsPostBack) { string sid = Request.QueryString["sid"]; if (sid == null || sid == string.Empty) { throw new EventSiteException("QueryString Parameter 'sid' not found!", 900); } JourneySubscription = BLL.GetSubscription(Convert.ToInt32(sid)); EventSiteBL.SetJourneyStations(JourneySubscription); pageTitle.InnerText = string.Format("Mitfahrt von {0} definieren", JourneySubscription.Contact.Name); try { FillFormFields(); } catch (EventSiteException ex) { RegisterStartupScriptIfNeeded("FillFormFieldsError", ex.JavaScriptAlertString); } } if (BLL.HasSubscriptionLiftsSet(JourneySubscription)) { RegisterStartupScriptIfNeeded("LiftShouldNotDrive", string.Format(pbHelpers.JavaScriptString, string.Format("alert('Da mit {0} schon Personen mitfahren, kann keine\\nMitfahrt definiert werden.');fClose();", JourneySubscription.Contact.Name))); } }
private void SaveButton_Click(object sender, EventArgs e) { if (Page.IsValid) { Subscription oldSubscription = (JourneySubscription.LiftSubscriptionJourneyStationId.IsNull ? null : GetSubscriptionByJourneyStationId(JourneySubscription.LiftSubscriptionJourneyStationId)); Subscription newSubscription = (TakesLift.Checked ? GetSubscriptionByJourneyStationId(Convert.ToInt32(JourneyStationChoice.SelectedValue)) : null); SaveCase scase = SaveCase.saves_new_lift; if (TakesLift.Checked) { if (JourneySubscription.LiftSubscriptionJourneyStationId.IsNull) { //saves new lift scase = SaveCase.saves_new_lift; } else { if (JourneySubscription.LiftSubscriptionJourneyStationId == Convert.ToInt32(JourneyStationChoice.SelectedValue)) { //saves but no change scase = SaveCase.saves_lift_but_no_change; } else { if (oldSubscription == newSubscription) { //saves a change same subscription scase = SaveCase.saves_lift_change_same_subscription; } else { //saves a change other subscription scase = SaveCase.saves_lift_change_other_subscription; } } } JourneySubscription.NumLifts = null; foreach (JourneyStation journeyStation in JourneySubscription.journeyStations) { journeyStation.SortOrder = -1; } JourneySubscription.LiftSubscriptionJourneyStationId = Convert.ToInt32(JourneyStationChoice.SelectedValue); } else { if (JourneySubscription.LiftSubscriptionJourneyStationId.IsNull) { //saves but no change scase = SaveCase.saves_nolift_but_no_change; } else { //saves remove lift scase = SaveCase.saves_remove_lift; } JourneySubscription.LiftSubscriptionJourneyStationId = null; } try { BLL.EditSubscription(JourneySubscription, false); } catch (EventSiteException ex) { RegisterStartupScriptIfNeeded("SaveLiftExc", ex.JavaScriptAlertString); JourneySubscription = BLL.GetSubscription(JourneySubscription.SubscriptionId); EventSiteBL.SetJourneyStations(JourneySubscription); return; } string action = ""; string definition = ""; string successMessage = "Der Fahrer wurde darüber informiert."; switch (scase) { case SaveCase.saves_new_lift: action = "eine neue Mitfahrt definiert:"; definition = string.Format("{0} fährt ab {1} mit. Bemerkung: {2}", JourneySubscription.Contact.Name, JourneyStationChoice.SelectedItem.Text, Comment.Text); BLL.NotifyLiftSave(action, definition, JourneySubscription.Event, newSubscription.Contact, JourneySubscription.Contact); break; case SaveCase.saves_lift_change_same_subscription: action = "eine Mitfahrt geändert. Neu:"; definition = string.Format("{0} fährt ab {1} mit. Bemerkung: {2}", JourneySubscription.Contact.Name, JourneyStationChoice.SelectedItem.Text, Comment.Text); BLL.NotifyLiftSave(action, definition, JourneySubscription.Event, newSubscription.Contact, JourneySubscription.Contact); break; case SaveCase.saves_lift_change_other_subscription: action = "eine Mitfahrt entfernt:"; definition = string.Format("{0} fährt nicht mit.", JourneySubscription.Contact.Name); BLL.NotifyLiftSave(action, definition, JourneySubscription.Event, oldSubscription.Contact, JourneySubscription.Contact); action = "eine neue Mitfahrt definiert:"; definition = string.Format("{0} fährt ab {1} mit. Bemerkung: {2}", JourneySubscription.Contact.Name, JourneyStationChoice.SelectedItem.Text, Comment.Text); BLL.NotifyLiftSave(action, definition, JourneySubscription.Event, newSubscription.Contact, JourneySubscription.Contact); break; case SaveCase.saves_remove_lift: action = "eine Mitfahrt entfernt:"; definition = string.Format("{0} fährt nicht mit.", JourneySubscription.Contact.Name); BLL.NotifyLiftSave(action, definition, JourneySubscription.Event, oldSubscription.Contact, JourneySubscription.Contact); break; case SaveCase.saves_nolift_but_no_change: case SaveCase.saves_lift_but_no_change: //no notification needed successMessage = "Der Fahrer wurde nicht informiert, da keine Änderung gemacht wurde."; break; } RegisterStartupScriptIfNeeded("JourneySaveSuccess", string.Format(pbHelpers.JavaScriptString, "alert('Mitfahr-Einstellung wurde erfolgreich gespeichert.\\n\\n" + successMessage + "');fClose();")); #if (DEBUG) System.Threading.Thread.Sleep(2500); #endif } }