protected void Page_Load(object sender, EventArgs e) { if (Session["buying"] != null) { Session["ShoppingCart"] = null; } DateTime date; if (Session["date"] == null) { date = DateTime.Now; Session["date"] = date; } else date = Convert.ToDateTime(Session["date"]); LbHeader.Text = "Entertainments in " + date.ToString("MMMM"); WsBallet.Service1 wsBallet = new WsBallet.Service1(); WsOpera.Service1 wsOpera = new WsOpera.Service1(); WsSmallTheatre.Service1 wsTheatre = new WsSmallTheatre.Service1(); DataRow singleEvent; DataTable DtSchedule = new DataTable(); DtSchedule.Columns.Add("Org"); DtSchedule.Columns.Add("Title"); DtSchedule.Columns.Add("Date", System.Type.GetType("System.DateTime")); DtSchedule.Columns.Add("Runtime", System.Type.GetType("System.Int32")); DtSchedule.Columns.Add("OpenSeats", System.Type.GetType("System.Int32")); var scheduleBallet = wsBallet.GetScheduleForAMonth(date); if (scheduleBallet != null) { for (int i = 0; i < scheduleBallet.Length / 4; i++) { int y = i * 4; singleEvent = DtSchedule.NewRow(); singleEvent[0] = "Ballet"; singleEvent[1] = scheduleBallet[y]; singleEvent[2] = Convert.ToDateTime(scheduleBallet[y + 1]); singleEvent[3] = Convert.ToInt32(scheduleBallet[y + 2]); singleEvent[4] = Convert.ToInt32(scheduleBallet[y + 3]); DtSchedule.Rows.Add(singleEvent); } } var scheduleOpera = wsOpera.GetScheduleForAMonth(date); if (scheduleOpera != null) { for (int i = 0; i < scheduleOpera.Length / 4; i++) { int y = i * 4; singleEvent = DtSchedule.NewRow(); singleEvent[0] = "Opera"; singleEvent[1] = scheduleOpera[y]; singleEvent[2] = Convert.ToDateTime(scheduleOpera[y + 1]); singleEvent[3] = Convert.ToInt32(scheduleOpera[y + 2]); singleEvent[4] = Convert.ToInt32(scheduleOpera[y + 3]); DtSchedule.Rows.Add(singleEvent); } } var scheduleTheatre = wsTheatre.GetScheduleForAMonth(date); if (scheduleTheatre != null) { for (int i = 0; i < scheduleTheatre.Length / 4; i++) { int y = i * 4; singleEvent = DtSchedule.NewRow(); singleEvent[0] = "Theatre"; singleEvent[1] = scheduleTheatre[y]; singleEvent[2] = Convert.ToDateTime(scheduleTheatre[y + 1]); singleEvent[3] = Convert.ToInt32(scheduleTheatre[y + 2]); singleEvent[4] = Convert.ToInt32(scheduleTheatre[y + 3]); DtSchedule.Rows.Add(singleEvent); } } DataTable EarliestEvents = Get3EarliestEvents(DtSchedule); GvEntertainments.DataSource = EarliestEvents; GvEntertainments.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { if (Session["buying"] != null) { Session["ShoppingCart"] = null; } DateTime date; if (Session["date"] == null) { date = DateTime.Now; Session["date"] = date; } else { if (Session["stage"] != null) { if (Session["stage"].Equals("Theatre")) date = Convert.ToDateTime(Session["date"]); else { date = DateTime.Now; Session["date"] = date; } } else { date = DateTime.Now; Session["date"] = date; } } LbHeader.Text = "Repertorire for the theatre in " + date.ToString("MMMM"); WsSmallTheatre.Service1 wsTheatre = new WsSmallTheatre.Service1(); DataRow singleEvent; DataTable DtSchedule = new DataTable(); DtSchedule.Columns.Add("Title"); DtSchedule.Columns.Add("Date", System.Type.GetType("System.DateTime")); DtSchedule.Columns.Add("Runtime", System.Type.GetType("System.Int32")); DtSchedule.Columns.Add("OpenSeats", System.Type.GetType("System.Int32")); var scheduleBallet = wsTheatre.GetScheduleForAMonth(date); if (scheduleBallet != null) { for (int i = 0; i < scheduleBallet.Length / 4; i++) { int y = i * 4; singleEvent = DtSchedule.NewRow(); singleEvent[0] = scheduleBallet[y]; singleEvent[1] = Convert.ToDateTime(scheduleBallet[y + 1]); singleEvent[2] = Convert.ToInt32(scheduleBallet[y + 2]); singleEvent[3] = Convert.ToInt32(scheduleBallet[y + 3]); DtSchedule.Rows.Add(singleEvent); } } GvEntTheatre.DataSource = DtSchedule; GvEntTheatre.DataBind(); }
private void updateDataBase(int rowNumber) { string connectionString = ConfigurationManager.ConnectionStrings["DbOrdersConnectionString"].ToString(); MapDbOrdersDataContext dataContext = new MapDbOrdersDataContext(connectionString); int invoiceID = dataContext.Invoices.Where(x => x.Code == (string)Session["code"]).Select(y => y.InvoiceID).First(); //var record = dataContext.InvoiceLines.Where(x => x.InvoiceID == invoiceID && // x.DateOfEvent == Convert.ToDateTime(GvOrders.Rows[rowNumber].Cells[0]) && // x.Row == Convert.ToInt32(GvOrders.Rows[rowNumber].Cells[2]) && // x.Number == Convert.ToInt32(GvOrders.Rows[rowNumber].Cells[3]) && // x.Title == GvOrders.Rows[rowNumber].Cells[1].ToString()).First(); if (Convert.ToDateTime(orders.Rows[rowNumber][0]).AddDays(10) < DateTime.Now) { var record = dataContext.InvoiceLines.Where(x => x.InvoiceID == invoiceID && x.DateOfEvent == Convert.ToDateTime(orders.Rows[rowNumber][0]) && x.Row == Convert.ToInt32(orders.Rows[rowNumber][2]) && x.Number == Convert.ToInt32(orders.Rows[rowNumber][3]) && x.Title == orders.Rows[rowNumber][1].ToString()).First(); switch (record.Organizer) { case "Ballet": WsBallet.Service1 wsBallet = new WsBallet.Service1(); string result = wsBallet.CancelReservation(Convert.ToDateTime(orders.Rows[rowNumber][0]), orders.Rows[rowNumber][1].ToString(), Convert.ToInt32(orders.Rows[rowNumber][2]), Convert.ToInt32(orders.Rows[rowNumber][3])); // Maybe some information occured any problems...? break; case "Opera": WsOpera.Service1 wsOpera = new WsOpera.Service1(); string result2 = wsOpera.CancelReservation(Convert.ToDateTime(orders.Rows[rowNumber][0]), orders.Rows[rowNumber][1].ToString(), Convert.ToInt32(orders.Rows[rowNumber][2]), Convert.ToInt32(orders.Rows[rowNumber][3])); // Maybe some information occured any problems...? // Mark certain seat as available. break; case "Theatre": WsSmallTheatre.Service1 wsTheatre = new WsSmallTheatre.Service1(); string result3 = wsTheatre.CancelReservation(Convert.ToDateTime(orders.Rows[rowNumber][0]), orders.Rows[rowNumber][1].ToString(), Convert.ToInt32(orders.Rows[rowNumber][2]), Convert.ToInt32(orders.Rows[rowNumber][3])); // Maybe some information occured any problems...? break; } dataContext.InvoiceLines.DeleteOnSubmit(record); dataContext.SubmitChanges(); Response.Redirect("CancelOrder.aspx"); } else { LbInfo.Text = "This reservation cannot be canceled."; LbInfo.Visible = true; } }