private void Edit_Events(object sender, MouseButtonEventArgs e) { try { DataGrid dg = sender as DataGrid; EventsDataGrid p = (EventsDataGrid)dg.SelectedItems[0]; // OR: Patient p = (Patient)dg.SelectedItem; UpdateEvent up = new UpdateEvent(p, StaffRole); if (p.EventStartDateTime.Hour >= 12) { up.AMPM_Start.SelectedIndex = 1; } else { up.AMPM_Start.SelectedIndex = 0; } if (p.EventEndDateTime.Hour >= 12) { up.AMPM_End.SelectedIndex = 1; } else { up.AMPM_End.SelectedIndex = 0; } up.DateRecieved.SelectedDate = p.EventStartDateTime; up.ShowDialog(); } catch (Exception error) { } Refresh_Events(sender, e); }
protected void Page_Load(object sender, EventArgs e) { ErrorMessageLabel.Visible = false; // Get the query string values. NameValueCollection coll = Request.QueryString; int farmId = Convert.ToInt32(coll.Get("farmId")); DateTime startDate = Convert.ToDateTime(coll.Get("start_date")); if (!IsPostBack) { // Get the logged in account information. RegistrationService.LoginInfo loginInfo = (RegistrationService.LoginInfo)Session["loginInfo"]; // Set the required query string varables into hidden fields. FarmIdHiddenField.Value = farmId.ToString(); StartDateHiddenField.Value = startDate.ToString("MM/dd/yyyy"); try { // Get the farm details and display. FarmService.FarmService farmService = serviceLoader.GetFarm(); FarmService.FarmInfo farm = farmService.GetFarmDetail(farmId); FarmNameLabel.Text = farm.FarmName; PlotCountLabel.Text = farm.PlotCount.ToString(); ContactCountLabel.Text = farm.ContactCount.ToString(); int planId = farm.MailingPlan.MailingPlanId; PlanIdHiddenField.Value = planId.ToString(); MailingPlanLabel.Text = farm.MailingPlan.Title; CreatedOnLabel.Text = farm.CreateDate.ToString("MM/dd/yyyy"); // Get the scheduled events and display. ScheduleService.ScheduleService scheduleService = serviceLoader.GetSchedule(); IList <ScheduleService.ScheduleEventInfo> events = scheduleService.GetPlanEvents(planId, startDate); EventsDataGrid.DataSource = events; EventsDataGrid.DataBind(); } catch (Exception ex) { ErrorMessageLabel.Text = "Unable to process the request. Please contact your administrator."; ErrorMessageLabel.Visible = true; log.Error("Unknown Error", ex); } } }
public UpdateEvent(EventsDataGrid p, string staffDBRole) { StaffDBRole = staffDBRole; EventID = p.EventID; EventName = p.EventName; EventDescription = p.EventDescription; BeginMinute = p.EventStartDateTime.Minute.ToString(); EndMinute = p.EventEndDateTime.Minute.ToString(); if (BeginMinute.Length == 1) { BeginMinute = "0" + BeginMinute; } if (EndMinute.Length == 1) { EndMinute = "0" + EndMinute; } if (p.EventStartDateTime.Hour > 12) { BeginHour = (p.EventStartDateTime.Hour - 12).ToString(); } else if (p.EventStartDateTime.Hour == 0) { BeginHour = "12"; } else { BeginHour = p.EventStartDateTime.Hour.ToString(); } if (p.EventEndDateTime.Hour > 12) { EndHour = (p.EventEndDateTime.Hour - 12).ToString(); } else if (p.EventEndDateTime.Hour == 0) { EndHour = "12"; } else { EndHour = p.EventEndDateTime.Hour.ToString(); } InitializeComponent(); text_EventName.Focus(); }