//protected void AjaxFileUpload1_imageupload(object sender, AjaxFileUploadEventArgs e) //{ // string filename = e.FileName; // string strDestPath = Server.MapPath("~/Images/Events/"); // AjaxFileUpload1.SaveAs(@strDestPath + filename); //} protected void buttonSave_Click(object sender, EventArgs e) { try { string name = txtEventName.Text; string date = txtEventDate.Text; string time = txtEventTime.Text; string venue = VenueIDDd.SelectedValue; //string status = txtEventStatus.Text; string category = SelectEventCategory.SelectedValue; string description = txtDescription.Text; //string images = "/httpdocs/Images/Events/" + ddlImage.SelectedValue; // string sstatus = "Available"; Event ticket = new Event(name, date, time, venue, "Available", category, description, "TEST"); int eid = Connection.AddEvents(ticket); tempTable = (DataTable)Session["SeatLeveltable"]; // Create the eventid column DataColumn nce; nce = new DataColumn(); nce.DataType = System.Type.GetType("System.Int32"); nce.ColumnName = "EventId"; nce.DefaultValue = eid; tempTable.Columns.Add(nce); // Add the above into gridview EventGrid.DataSource = tempTable; EventGrid.DataBind(); // Add SeatSection and eventid from gridview to SeatCategory table foreach (GridViewRow e1 in EventGrid.Rows) { string section = e1.Cells[0].Text; int eventid = Int32.Parse(e1.Cells[3].Text); //SeatCategory slv = new SeatCategory(eventid, section, sstatus); int scatID = Connection.AddSeatCat(eventid, section); Connection.AddSeat(Int32.Parse(e1.Cells[1].Text), e1.Cells[2].Text, scatID); } lbOutPut.Text = "Upload successful!"; ClearTextFields(); } catch (Exception) { lbOutPut.Text = "Upload failed!"; } }
protected void price_Click(object sender, EventArgs e) { try { int ssection = Int32.Parse(SeatDropDown.SelectedValue); int seatprice = Int32.Parse(txtPrice.Text); int svenueid = Int32.Parse(VenueIDDd.SelectedValue); int seattotal = Connection.GetFromVenueInfo(ssection, svenueid); DataColumn Col; DataRow Ro; if (Session["SeatLeveltable"] != null) { tempTable = (DataTable)Session["SeatLeveltable"]; } else { // Create a new DataTable tempTable = new DataTable(); // Create a new column in gridview Col = new DataColumn(); Col.DataType = System.Type.GetType("System.Int32"); Col.ColumnName = ("SeatSection"); tempTable.Columns.Add(Col); // Create a new column in gridview Col = new DataColumn(); Col.DataType = System.Type.GetType("System.Int32"); Col.ColumnName = ("TotalSeat"); tempTable.Columns.Add(Col); // Create a 3rd column in gridview Col = new DataColumn(); Col.DataType = System.Type.GetType("System.Double"); Col.ColumnName = ("Price"); tempTable.Columns.Add(Col); } //Create new DataRow objects and add to DataTable Ro = tempTable.NewRow(); Ro["SeatSection"] = ssection; Ro["TotalSeat"] = seattotal; Ro["Price"] = seatprice; tempTable.Rows.Add(Ro); EventGrid.DataSource = tempTable; EventGrid.DataBind(); Session["SeatLeveltable"] = tempTable; lbPrice.Text = "Upload successful!"; //ClearSeatSection(); } catch (Exception) { lbPrice.Text = "Upload failed!"; } }
protected void price_Click(object sender, EventArgs e) { double n; if (!double.TryParse(txtPrice.Text, out n) || double.Parse(txtPrice.Text) <= 0 || !Regex.IsMatch(txtPrice.Text, @"^\$?([0-9]{1,3},([0-9]{3},)*[0-9]{3}|[0-9]+)(.[0-9][0-9])?$")) { lbPrice.Text = "Invalid Price!!"; lbPrice.ForeColor = Color.Red; } else { try { int ssection = Int32.Parse(SeatDropDown.SelectedValue); int seatprice = Int32.Parse(txtPrice.Text); int svenueid = Int32.Parse(VenueIDDd.SelectedValue); int seattotal = Connection.GetFromVenueInfo(ssection, svenueid); DataColumn Col; DataRow Ro; if (Session["SeatLeveltable"] != null) { tempTable = (DataTable)Session["SeatLeveltable"]; } else { // Create a new DataTable tempTable = new DataTable(); // Create a new column in gridview Col = new DataColumn(); Col.DataType = System.Type.GetType("System.Int32"); Col.ColumnName = ("SeatSection"); tempTable.Columns.Add(Col); // Create a new column in gridview Col = new DataColumn(); Col.DataType = System.Type.GetType("System.Int32"); Col.ColumnName = ("TotalSeat"); tempTable.Columns.Add(Col); // Create a 3rd column in gridview Col = new DataColumn(); Col.DataType = System.Type.GetType("System.Double"); Col.ColumnName = ("Price"); tempTable.Columns.Add(Col); } int section = Int32.Parse(SeatDropDown.SelectedValue); if (tempTable.AsEnumerable().Any(row => section == row.Field <int>("SeatSection"))) { //lbSeatOutput.Text = "This Section already exits."; //lbSeatOutput.ForeColor = Color.Red; EventGrid.Visible = true; this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Can not have multiple price for the same section.')", true); EventGrid.Visible = true; lbPrice.Text = ""; } else { //Create new DataRow objects and add to DataTable Ro = tempTable.NewRow(); Ro["SeatSection"] = ssection; Ro["TotalSeat"] = seattotal; Ro["Price"] = seatprice; tempTable.Rows.Add(Ro); EventGrid.DataSource = tempTable; EventGrid.DataBind(); Session["SeatLeveltable"] = tempTable; lbPrice.Text = "Upload successful!"; lbPrice.ForeColor = Color.Blue; //ClearSeatSection(); EventGrid.Visible = true; } } catch (Exception) { lbPrice.Text = "Upload failed!"; } } }
protected void buttonSave_Click(object sender, EventArgs e) { if (Session["SeatLeveltable"] == null) { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Price is missing from the Seat Level. Please enter the price and try it again.')", true); } else { tempTable = (DataTable)Session["SeatLeveltable"]; DateTime d; string filename; try { // string sstatus = "Available"; filename = Path.GetFileName(FileUpload1.FileName); FileUpload1.SaveAs(Server.MapPath("~/Images/Events/") + filename); } catch (Exception) { lbOutPut.Text = "Please upload the Image!"; lbOutPut.ForeColor = Color.Red; lbPrice.Text = ""; return; } if (!(DateTime.TryParseExact(txtEventDate.Text, "MM/dd/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out d) || DateTime.TryParseExact(txtEventDate.Text, "M/d/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out d))) { } else if (!(Regex.IsMatch(txtEventTime.Text, @"^(?:0?[0-9]|1[0-9]|2[0-3]):[0-5][0-9]$") || Regex.IsMatch(txtEventTime.Text, @"^(?:0?[0-9]|1[0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]$"))) { } else if (tempTable.Rows.Count == 0) { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Price is missing from the Seat Level. Please enter the price and try it again.')", true); } else if (!isImage(filename)) { lbOutPut.Text = "Invalid Image"; lbOutPut.ForeColor = Color.Red; lbPrice.Text = ""; } else if (DateTime.Parse(txtEventDate.Text) <= DateTime.Now) { lbOutPut.Text = "Event date must be after the current date"; lbOutPut.ForeColor = Color.Red; lbPrice.Text = ""; } else { try { string name = txtEventName.Text; string date = txtEventDate.Text; string time = txtEventTime.Text; string venue = VenueIDDd.SelectedValue; //string status = txtEventStatus.Text; string category = SelectEventCategory.SelectedValue; string description = txtDescription.Text; Event ticket = new Event(name, date, time, venue, "Available", category, description, "../Images/Events/" + filename); int eid = Connection.AddEvents(ticket); tempTable = (DataTable)Session["SeatLeveltable"]; // Create the eventid column DataColumn nce; nce = new DataColumn(); nce.DataType = System.Type.GetType("System.Int32"); nce.ColumnName = "EventId"; nce.DefaultValue = eid; tempTable.Columns.Add(nce); // Add the above into gridview EventGrid.DataSource = tempTable; EventGrid.DataBind(); // Add SeatSection and eventid from gridview to SeatCategory table foreach (DataRow e1 in tempTable.Rows) { int section = e1.Field <int>(0); int eventid = e1.Field <int>(3); //SeatCategory slv = new SeatCategory(eventid, section, sstatus); int scatID = Connection.AddSeatCat(eventid, section); Connection.AddSeat(e1.Field <int>(1), e1.Field <double>(2), scatID); } lbOutPut.Text = "Upload successful!"; lbOutPut.ForeColor = Color.Blue; ClearTextFields(); GridView1.DataBind(); Session["SeatLeveltable"] = null; EventGrid.Visible = false; lbPrice.Text = ""; } catch (Exception exc) { lbOutPut.Text = "Upload failed!"; lbOutPut.ForeColor = Color.Red; } } } }