public string getEvents() { EventOnAir ev = new EventOnAir(); List<EventOnAir> eventsList = new List<EventOnAir>(); DataTable dt = ev.readTable(); for (int i = 0; i < dt.Rows.Count; i++) { EventOnAir evTemp = new EventOnAir(); evTemp.Point = new Point(double.Parse(dt.Rows[i]["Lat"].ToString()), double.Parse(dt.Rows[i]["Lng"].ToString())); evTemp.Address = dt.Rows[i]["Address"].ToString(); evTemp.MaxAge = int.Parse(dt.Rows[i]["MaxAge"].ToString()); evTemp.MinAge = int.Parse(dt.Rows[i]["MinAge"].ToString()); evTemp.NumOfParti = int.Parse(dt.Rows[i]["NumOfParticipants"].ToString()); evTemp.ImageUrl= dt.Rows[i]["ImageUrl"].ToString(); evTemp.AdminID = int.Parse(dt.Rows[0]["AdminId"].ToString()); evTemp.IsPrivate1 = bool.Parse(dt.Rows[0]["Private"].ToString()); evTemp.DateTime = DateTime.Parse(dt.Rows[i]["Time"].ToString()); evTemp.DateTimeStr = (dt.Rows[i]["Time"].ToString()); evTemp.Description = dt.Rows[i]["Description"].ToString(); evTemp.Comments = dt.Rows[i]["Comments"].ToString(); evTemp.EventNum = dt.Rows[i]["EventNumber"].ToString(); //add the event to the list eventsList.Add(evTemp); } JavaScriptSerializer js = new JavaScriptSerializer(); string jsonString = js.Serialize(eventsList); return jsonString; }
public string getEvents() { EventOnAir ev = new EventOnAir(); List <EventOnAir> eventsList = new List <EventOnAir>(); DataTable dt = ev.readTable(); for (int i = 0; i < dt.Rows.Count; i++) { EventOnAir evTemp = new EventOnAir(); evTemp.Point = new Point(double.Parse(dt.Rows[i]["Lat"].ToString()), double.Parse(dt.Rows[i]["Lng"].ToString())); evTemp.Address = dt.Rows[i]["Address"].ToString(); evTemp.MaxAge = int.Parse(dt.Rows[i]["MaxAge"].ToString()); evTemp.MinAge = int.Parse(dt.Rows[i]["MinAge"].ToString()); evTemp.NumOfParti = int.Parse(dt.Rows[i]["NumOfParticipants"].ToString()); evTemp.ImageUrl = dt.Rows[i]["ImageUrl"].ToString(); evTemp.AdminID = int.Parse(dt.Rows[0]["AdminId"].ToString()); evTemp.IsPrivate1 = bool.Parse(dt.Rows[0]["Private"].ToString()); evTemp.DateTime = DateTime.Parse(dt.Rows[i]["Time"].ToString()); evTemp.DateTimeStr = (dt.Rows[i]["Time"].ToString()); evTemp.Description = dt.Rows[i]["Description"].ToString(); evTemp.Comments = dt.Rows[i]["Comments"].ToString(); evTemp.EventNum = dt.Rows[i]["EventNumber"].ToString(); //add the event to the list eventsList.Add(evTemp); } JavaScriptSerializer js = new JavaScriptSerializer(); string jsonString = js.Serialize(eventsList); return(jsonString); }
protected void Page_Load(object sender, EventArgs e) { string ageRange; EventOnAir Ev = new EventOnAir(); MapPlaceHolder.Visible = false; dt = Ev.readTable(); GridView1.DataSource = dt; GridView1.DataBind(); //load the user age if (Session["UserDeatail"] != null) { DataTable dtUser = (DataTable)HttpContext.Current.Session["UserDeatail"]; ageTXT.Text = dtUser.Rows[0]["Age"].ToString(); } for (int i = 0; i < dt.Rows.Count; i++) { //edit the age range ageRange = dt.Rows[i]["MinAge"].ToString(); ageRange += "-" + dt.Rows[i]["MaxAge"].ToString(); GridView1.Rows[i].Cells[6].Text = ageRange; // adding the join btn Button JoinBtn = new Button(); JoinBtn.Text = " Join Now"; JoinBtn.CssClass = "myButton"; JoinBtn.Click += new EventHandler(JoinBtn_Click); JoinBtn.ID = dt.Rows[i]["EventNumber"].ToString(); GridView1.Rows[i].Cells[7].Controls.Add(JoinBtn); //hide if private CheckBox cb = (CheckBox)GridView1.Rows[i].Cells[10].Controls[0]; if (cb.Checked) { GridView1.Rows[i].Visible = false; } //hide EventNumber & Comments & private& lat lng for (int r = 8; r < 14; r++) { GridView1.Rows[i].Cells[r].Visible = false; GridView1.HeaderRow.Cells[r].Visible = false; } } GridView1.HeaderRow.Cells[0].Text = ""; GridView1.HeaderRow.Cells[2].Text = "Max Partic."; GridView1.HeaderRow.Cells[6].Text = "Age Range"; GridView1.HeaderRow.Cells[7].Text = ""; //adding the image for (int i = 0; i < dt.Rows.Count; i++) { Image imsel = new Image(); imsel.ImageUrl = dt.Rows[i]["imageUrl"].ToString(); GridView1.Rows[i].Cells[0].Controls.Add(imsel); } }
//insert new event protected void confirmBTN_Click(object sender, EventArgs e) { string[] latlagArr = new string[2]; string timedate; EventOnAir ev = new EventOnAir(); if (LatLOngHIde.Value != "") { //take lat lng string latlong = LatLOngHIde.Value; latlagArr = latlong.Split(','); latlagArr[0] = latlagArr[0].Remove(0, 1); latlagArr[1] = latlagArr[1].Remove(latlagArr[1].Length - 1, 1); string address = CityHIde.Value; //insert to the Event class ev.Point = new Point(double.Parse(latlagArr[0]), double.Parse(latlagArr[1])); ev.Address = address; } try { DataTable dt = (DataTable)HttpContext.Current.Session["UserDeatail"]; ev.AdminID = int.Parse(dt.Rows[0]["UserId"].ToString()); ev.Catedory = int.Parse(categoryDDL.SelectedValue); ev.NumOfParti = int.Parse(NOP.Text); timedate = FixDate(dateTB.Text) +" " + timeTB.Text; ev.DateTime = DateTime.Parse(timedate); ev.MinAge = double.Parse(MinAgeTxt.Text); ev.MaxAge = double.Parse(MaxAgeTxt.Text); ev.Frequency = int.Parse(FrequRBL.SelectedValue); ev.IsPrivate1 = bool.Parse(EventTypeRBL.SelectedValue); ev.Comments = commentsTB.Text; } catch (Exception ex) { ShowPopup(ex.Message); } //if admin wants to up date if (confirmBTN.Text == "Edit Event") { updateEvent(ev); } else { insertEvent(ev); } }
protected void Page_Load(object sender, EventArgs e) { MapPlaceHolder.Visible = false; string ageRange; EventOnAir Ev = new EventOnAir(); dt = Ev.readTable(); GridView1.DataSource = dt; //GridView1 desing GridView1.AllowPaging = true; dt.Columns[6].ColumnName = "Age Range"; GridView1.DataBind(); for (int i = 0; i < dt.Rows.Count; i++) { //edit the age range ageRange = dt.Rows[i]["Age Range"].ToString(); ageRange += "-" + dt.Rows[i]["MaxAge"].ToString(); GridView1.Rows[i].Cells[6].Text = ageRange; // adding the join btn Button JoinBtn = new Button(); JoinBtn.Text = " Join Now"; JoinBtn.Click += new EventHandler(JoinBtn_Click); JoinBtn.ID = dt.Rows[i]["EventNumber"].ToString(); GridView1.Rows[i].Cells[7].Controls.Add(JoinBtn); //hide if private CheckBox cb = (CheckBox)GridView1.Rows[i].Cells[10].Controls[0]; if (cb.Checked) { GridView1.Rows[i].Visible = false; } //hide EventNumber & Comments & private GridView1.Rows[i].Cells[8].Visible = false; GridView1.Rows[i].Cells[9].Visible = false; GridView1.Rows[i].Cells[10].Visible = false; } GridView1.HeaderRow.Cells[7].Text = ""; GridView1.HeaderRow.Cells[8].Visible = false; GridView1.HeaderRow.Cells[9].Visible = false; GridView1.HeaderRow.Cells[10].Visible = false; //adding the image for (int i = 0; i < dt.Rows.Count; i++) { Image imsel = new Image(); imsel.ImageUrl = dt.Rows[i]["imageUrl"].ToString(); GridView1.Rows[i].Cells[1].Controls.Add(imsel); } }
public void LoadUserTable() { DBservices db = new DBservices(); usetT = db.GetAllUsers(); userGride.DataSource = usetT; userGride.DataBind(); AddImage(); AddCheckBox(); //load events EventOnAir ev = new EventOnAir(); dt = ev.readTable(); }
protected void Page_Load(object sender, EventArgs e) { MapPlaceHolder.Visible = false; string ageRange; EventOnAir Ev = new EventOnAir(); dt = Ev.readTable(); GridView1.DataSource = dt; //GridView1 desing GridView1.AllowPaging = true; dt.Columns[6].ColumnName = "Age Range"; GridView1.DataBind(); for (int i = 0; i < dt.Rows.Count; i++) { //edit the age range ageRange = dt.Rows[i]["Age Range"].ToString(); ageRange += "-" + dt.Rows[i]["MaxAge"].ToString(); GridView1.Rows[i].Cells[6].Text = ageRange; // adding the join btn Button JoinBtn = new Button(); JoinBtn.Text = " Join Now"; JoinBtn.Click += new EventHandler(JoinBtn_Click); JoinBtn.ID = dt.Rows[i]["EventNumber"].ToString(); GridView1.Rows[i].Cells[7].Controls.Add(JoinBtn); //hide if private CheckBox cb = (CheckBox)GridView1.Rows[i].Cells[10].Controls[0]; if (cb.Checked) { GridView1.Rows[i].Visible = false; } //hide EventNumber & Comments & private GridView1.Rows[i].Cells[8].Visible = false; GridView1.Rows[i].Cells[9].Visible = false; GridView1.Rows[i].Cells[10].Visible = false; } GridView1.HeaderRow.Cells[7].Text = ""; GridView1.HeaderRow.Cells[8].Visible = false; GridView1.HeaderRow.Cells[9].Visible = false; GridView1.HeaderRow.Cells[10].Visible = false; //adding the image for (int i = 0; i < dt.Rows.Count; i++) { Image imsel = new Image(); imsel.ImageUrl = dt.Rows[i]["imageUrl"].ToString(); GridView1.Rows[i].Cells[1].Controls.Add(imsel); } }
protected void confirmBTN_Click(object sender, EventArgs e) { string[] latlagArr = new string[2]; string timedate; EventOnAir ev = new EventOnAir(); //take lat lng string latlong = LatLOngHIde.Value; latlagArr = latlong.Split(','); latlagArr[0] = latlagArr[0].Remove(0, 1); latlagArr[1] = latlagArr[1].Remove(latlagArr[1].Length - 1, 1); string address = CityHIde.Value; //insert to the Event class ev.Point = new Point(double.Parse(latlagArr[0]), double.Parse(latlagArr[1])); ev.Address = address; DataTable dt = (DataTable)HttpContext.Current.Session["UserDeatail"]; ev.AdminID = int.Parse(dt.Rows[0]["UserId"].ToString()); ev.Catedory = int.Parse(categoryDDL.SelectedValue); ev.NumOfParti = int.Parse(NOP.Text); timedate = dateTB.Text + " " + timeTB.Text; ev.DateTime = DateTime.Parse(timedate); ev.MinAge = double.Parse(MinAgeTxt.Text); ev.MaxAge = double.Parse(MaxAgeTxt.Text); ev.Frequency = int.Parse(FrequRBL.SelectedValue); ev.IsPrivate1 = bool.Parse(EventTypeRBL.SelectedValue); ev.Comments = commentsTB.Text; int numEfect = ev.insert(); if (numEfect == 0) { MessageBox.Show("the Event wasnt added ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop); } else { MessageBox.Show("the Event was added Successfully", "Successfully", MessageBoxButtons.OK, MessageBoxIcon.Information); Response.Redirect("Home.aspx");//×œ×©× ×•×ª לMYEVNTS } }
protected void confirmBTN_Click(object sender, EventArgs e) { string[] latlagArr = new string[2]; string timedate; EventOnAir ev = new EventOnAir(); //take lat lng string latlong = LatLOngHIde.Value; latlagArr = latlong.Split(','); latlagArr[0] = latlagArr[0].Remove(0, 1); latlagArr[1] = latlagArr[1].Remove(latlagArr[1].Length - 1, 1); string address = CityHIde.Value; //insert to the Event class ev.Point = new Point(double.Parse(latlagArr[0]), double.Parse(latlagArr[1])); ev.Address = address; DataTable dt = (DataTable)HttpContext.Current.Session["UserDeatail"]; ev.AdminID = int.Parse(dt.Rows[0]["UserId"].ToString()); ev.Catedory = int.Parse(categoryDDL.SelectedValue); ev.NumOfParti = int.Parse(NOP.Text); timedate = dateTB.Text + " " + timeTB.Text; ev.DateTime = DateTime.Parse(timedate); ev.MinAge = double.Parse(MinAgeTxt.Text); ev.MaxAge = double.Parse(MaxAgeTxt.Text); ev.Frequency = int.Parse(FrequRBL.SelectedValue); ev.IsPrivate1 = bool.Parse(EventTypeRBL.SelectedValue); ev.Comments = commentsTB.Text; int numEfect = ev.insert(); if (numEfect == 0) { MessageBox.Show("the Event wasnt added ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop); } else { MessageBox.Show("the Event was added Successfully", "Successfully", MessageBoxButtons.OK, MessageBoxIcon.Information); Response.Redirect("Home.aspx");//×œ×©× ×•×ª לMYEVNTS } }
//insert event to DB public int insert(EventOnAir p) { SqlConnection con; SqlCommand cmd; try { con = connect(conectionStr); } catch (Exception ex) { throw (ex); } String cStr = BuildInsertCommand(p); // helper method to build the insert string cmd = CreateCommand(cStr, con); // create the command try { int numEffected = cmd.ExecuteNonQuery(); // execute the command return(numEffected); } catch (Exception ex) { return(0); // write to log throw (ex); } finally { if (con != null) { // close the db connection con.Close(); } } }
//build insert command for event private String BuildInsertCommand(EventOnAir p) { String command; int isprivate = 0; string dateStr = " "; StringBuilder sb = new StringBuilder(); if (p.IsPrivate1) { isprivate = 1; } dateStr += p.DateTime.Month.ToString() + "/" + p.DateTime.Day.ToString() + "/" + p.DateTime.Year.ToString() + " " + p.DateTime.Hour.ToString() + ":" + p.DateTime.Minute.ToString() + "0:00"; sb.AppendFormat("Values({0}, {1} ,{2}, {3},'{4}',{5},{6},'{7}',{8},'{9}','{10}','{11}')", p.NumOfParti, p.Catedory, p.Frequency, isprivate, dateStr, p.MinAge, p.MaxAge, p.Comments, p.AdminID, p.Address, p.Point.Lat, p.Point.Lng); String prefix = "INSERT INTO EventsOnAir " + "( NumOfParticipants, CategoryId, FrequencyId, [Private],[Time],MinAge,MaxAge,Comments,AdminId,Address,Lat,Lng)"; command = prefix + sb.ToString(); return(command); }
protected void Page_Load(object sender, EventArgs e) { //load the event detail if (Session["EventNumber"] == null) { return; } eventNum = (Session["EventNUmber"]).ToString(); if (Session["gridTable"] == null) { return; } DataTable dt = (DataTable)HttpContext.Current.Session["gridTable"]; // load the event detail to show #region for (int i = 0; i < dt.Rows.Count; i++) { if (dt.Rows[i]["EventNumber"].ToString() == eventNum) { latHF.Value = dt.Rows[i]["Lat"].ToString(); lngHF.Value = dt.Rows[i]["Lng"].ToString(); ANS_MaxPlayerLbl.Text = dt.Rows[i]["NumOfParticipants"].ToString(); iconImg.ImageUrl = dt.Rows[i]["ImageUrl"].ToString(); ANS_datatimelbl.Text = dt.Rows[i]["Time"].ToString(); ANS_locationLbl.Text = dt.Rows[i]["Address"].ToString(); ANS_commentLbl.Text = dt.Rows[i]["Comments"].ToString(); ANS_Frequency.Text = dt.Rows[i]["Frequncy"].ToString(); ANS_AgeLbl.Text = dt.Rows[i]["MinAge"].ToString() + "-" + dt.Rows[i]["MaxAge"].ToString(); EventNameLbl.Text = dt.Rows[i]["Description"].ToString(); User u = new User(); u.UserId = int.Parse(dt.Rows[i]["AdminId"].ToString()); DataTable dtName = u.CheckUserName(); ANS_AdminLbl.Text = dtName.Rows[0]["Fname"].ToString() + " " + dtName.Rows[0]["Lname"].ToString(); bool ansTemp = (bool)dt.Rows[0]["Private"]; string temp = "Public"; if (ansTemp) { temp = "Private"; } ANS_EventTypelbl.Text = temp; } } #endregion //loag the users that register to this event #region EventOnAir EV = new EventOnAir(); DataTable dtUser = EV.ReadUserInEvent(eventNum); //adding the num coulm DataColumn dc = new DataColumn("num"); dc.DataType = typeof(int); dtUser.Columns.Add(dc); dc.SetOrdinal(0); for (int i = 0; i < int.Parse(ANS_MaxPlayerLbl.Text); i++) { DataRow NewRow = dtUser.NewRow(); dtUser.Rows.Add(NewRow); } playerTableGrv.DataSource = dtUser; playerTableGrv.DataBind(); playerTableGrv.HeaderRow.Cells[0].Text = ""; //add the num of row like the num of players for (int i = 0; i < playerTableGrv.Rows.Count; i++) { playerTableGrv.Rows[i].Cells[0].Text = (i + 1).ToString(); } }
protected void Page_Load(object sender, EventArgs e) { //load the event detail if (Session["EventNumber"] == null) return; eventNum = (Session["EventNUmber"]).ToString(); if (Session["gridTable"] == null) return; DataTable dt = (DataTable)HttpContext.Current.Session["gridTable"]; // load the event detail to show #region for (int i = 0; i < dt.Rows.Count; i++) { if (dt.Rows[i]["EventNumber"].ToString() == eventNum) { latHF.Value = dt.Rows[i]["Lat"].ToString(); lngHF.Value = dt.Rows[i]["Lng"].ToString(); ANS_MaxPlayerLbl.Text = dt.Rows[i]["NumOfParticipants"].ToString(); iconImg.ImageUrl = dt.Rows[i]["ImageUrl"].ToString(); ANS_datatimelbl.Text = dt.Rows[i]["Time"].ToString(); ANS_locationLbl.Text = dt.Rows[i]["Address"].ToString(); ANS_commentLbl.Text = dt.Rows[i]["Comments"].ToString(); ANS_Frequency.Text = dt.Rows[i]["Frequncy"].ToString(); ANS_AgeLbl.Text = dt.Rows[i]["MinAge"].ToString() + "-" + dt.Rows[i]["MaxAge"].ToString(); EventNameLbl.Text = dt.Rows[i]["Description"].ToString(); User u = new User(); u.UserId = int.Parse(dt.Rows[i]["AdminId"].ToString()); DataTable dtName = u.CheckUserName(); ANS_AdminLbl.Text = dtName.Rows[0]["Fname"].ToString() + " " + dtName.Rows[0]["Lname"].ToString(); bool ansTemp = (bool)dt.Rows[0]["Private"]; string temp = "Public"; if (ansTemp) temp = "Private"; ANS_EventTypelbl.Text = temp; } } #endregion //loag the users that register to this event #region EventOnAir EV = new EventOnAir(); DataTable dtUser = EV.ReadUserInEvent(eventNum); //adding the num coulm DataColumn dc = new DataColumn("num"); dc.DataType = typeof(int); dtUser.Columns.Add(dc); dc.SetOrdinal(0); for (int i = 0; i < int.Parse(ANS_MaxPlayerLbl.Text); i++) { DataRow NewRow = dtUser.NewRow(); dtUser.Rows.Add(NewRow); } playerTableGrv.DataSource = dtUser; playerTableGrv.DataBind(); playerTableGrv.HeaderRow.Cells[0].Text = ""; //add the num of row like the num of players for (int i = 0; i < playerTableGrv.Rows.Count; i++) { playerTableGrv.Rows[i].Cells[0].Text = (i + 1).ToString(); } }
public string ReadMyEvent(string UserEmail) { List<EventOnAir> MyeventsList = new List<EventOnAir>(); DBservices dbs = new DBservices(); User U = new User(); U.Email = UserEmail; DataTable dtUserEvents = dbs.ReadMyEvent(U); for (int i = 0; i < dtUserEvents.Rows.Count; i++) { EventOnAir evTemp = new EventOnAir(); evTemp.Point = new Point(double.Parse(dtUserEvents.Rows[i]["Lat"].ToString()), double.Parse(dtUserEvents.Rows[i]["Lng"].ToString())); evTemp.Address = dtUserEvents.Rows[i]["Address"].ToString(); evTemp.MaxAge = int.Parse(dtUserEvents.Rows[i]["MaxAge"].ToString()); evTemp.MinAge = int.Parse(dtUserEvents.Rows[i]["MinAge"].ToString()); evTemp.NumOfParti = int.Parse(dtUserEvents.Rows[i]["NumOfParticipants"].ToString()); evTemp.ImageUrl = dtUserEvents.Rows[i]["ImageUrl"].ToString(); evTemp.AdminID = int.Parse(dtUserEvents.Rows[0]["AdminId"].ToString()); evTemp.IsPrivate1 = bool.Parse(dtUserEvents.Rows[0]["Private"].ToString()); evTemp.DateTime = DateTime.Parse(dtUserEvents.Rows[i]["Time"].ToString()); evTemp.DateTimeStr = (dtUserEvents.Rows[i]["Time"].ToString()); evTemp.Description = dtUserEvents.Rows[i]["Description"].ToString(); evTemp.Comments = dtUserEvents.Rows[i]["Comments"].ToString(); evTemp.EventNum = dtUserEvents.Rows[i]["EventNumber"].ToString(); //add the event to the list MyeventsList.Add(evTemp); } JavaScriptSerializer js = new JavaScriptSerializer(); string jsonString = js.Serialize(MyeventsList); return jsonString; }
public string setPOI(double lat, double lng, int nop, int category, string type, int frequecy, int minAge, int maxAge, string address, string time, string comments, int adminId) { //string strtemp; string[] dateArr = new string[2]; string[] dateArrT = new string[3]; EventOnAir ev = new EventOnAir(); ev.Point = new Point(lat, lng); ev.Address = address; ev.MaxAge = maxAge; ev.MinAge = minAge; ev.NumOfParti = nop; ev.Catedory = category; ev.IsPrivate1 = bool.Parse(type.ToString()); //dateArr = time.Split(' '); //dateArrT = dateArr[0].Split('-'); //strtemp = dateArrT[2] + "/" + dateArrT[0] + "/" + dateArrT[1]; //string dateandtime = strtemp + " " + dateArr[1]; ev.DateTime = DateTime.Parse("07/28/2014 20:00"); ev.Comments = comments; ev.Frequency = frequecy; ev.AdminID = adminId; JavaScriptSerializer js = new JavaScriptSerializer(); string jsonString = js.Serialize("ok"); try { ev.insert(); jsonString = time + "-----" + "dateandtime"; //jsonString = ev.insert().ToString(); } catch (Exception ex) { jsonString = js.Serialize("error in setPOI --- " + ex.Message); } return jsonString; }
//GetRating get the sum of rating public int GetRating(EventOnAir e) { SqlConnection con; con = connect(conectionStr); DataSet tblGetAdminName = new DataSet(); SqlDataAdapter adpt1; SqlCommand MySPCommand = new SqlCommand("GetRating", con); MySPCommand.CommandType = CommandType.StoredProcedure; SqlParameter parEventN = new SqlParameter("@EventNum", SqlDbType.Int); parEventN.Value = e.EventNum; parEventN.Direction = ParameterDirection.Input; MySPCommand.Parameters.Add(parEventN); adpt1 = new SqlDataAdapter(MySPCommand); adpt1.Fill(tblGetAdminName, "T2"); con.Close(); DataTable TTemp = tblGetAdminName.Tables["T2"]; return int.Parse(TTemp.Rows[0][0].ToString()); }
public string getOneMyEvent(string eventNum, string UserEmail) { List<EventOnAir> eventsList = new List<EventOnAir>(); DBservices dbs = new DBservices(); User U = new User(); U.Email = UserEmail; DataTable dtUserEvents = dbs.ReadMyEvent(U); for (int i = 0; i < dtUserEvents.Rows.Count; i++) { if (dtUserEvents.Rows[i]["EventNumber"].ToString() == eventNum) { EventOnAir evTemp = new EventOnAir(); evTemp.Point = new Point(double.Parse(dtUserEvents.Rows[i]["Lat"].ToString()), double.Parse(dtUserEvents.Rows[i]["Lng"].ToString())); evTemp.Address = dtUserEvents.Rows[i]["Address"].ToString(); evTemp.MaxAge = int.Parse(dtUserEvents.Rows[i]["MaxAge"].ToString()); evTemp.MinAge = int.Parse(dtUserEvents.Rows[i]["MinAge"].ToString()); evTemp.NumOfParti = int.Parse(dtUserEvents.Rows[i]["NumOfParticipants"].ToString()); evTemp.ImageUrl = dtUserEvents.Rows[i]["ImageUrl"].ToString(); evTemp.AdminID = int.Parse(dtUserEvents.Rows[i]["AdminId"].ToString()); evTemp.IsPrivate1 = bool.Parse(dtUserEvents.Rows[i]["Private"].ToString()); evTemp.DateTime = DateTime.Parse(dtUserEvents.Rows[i]["Time"].ToString()); evTemp.DateTimeStr = (dtUserEvents.Rows[i]["Time"].ToString()); evTemp.Description = dtUserEvents.Rows[i]["Description"].ToString(); evTemp.FrequencyStr = dtUserEvents.Rows[i]["Frequency"].ToString(); evTemp.Comments = dtUserEvents.Rows[i]["Comments"].ToString(); evTemp.EventNum = dtUserEvents.Rows[i]["EventNumber"].ToString(); evTemp.NumOfRegis = dtUserEvents.Rows[i]["NumOfRegister"].ToString(); User u = new User(); u.UserId = int.Parse(dtUserEvents.Rows[i]["AdminId"].ToString()); DataTable dtName = u.CheckUserName(); if (dtName.Rows.Count == 1) { evTemp.AdminFullName = dtName.Rows[0]["Fname"].ToString() + " " + dtName.Rows[0]["Lname"].ToString(); } else { evTemp.AdminFullName = ""; } DataTable dtUS = evTemp.ReadUserInEvent(eventNum); for (int r = 0; r < dtUS.Rows.Count; r++) { User utemp = new User(); utemp.UserName = dtUS.Rows[r]["UserName"].ToString(); utemp.UserId = int.Parse(dtUS.Rows[r]["UserId"].ToString()); utemp.Fname = dtUS.Rows[r]["Fname"].ToString(); utemp.Lname = dtUS.Rows[r]["Lname"].ToString(); utemp.Age = int.Parse(dtUS.Rows[r]["Age"].ToString()); utemp.Rating = int.Parse(dtUS.Rows[r]["Rating"].ToString()); utemp.City = dtUS.Rows[r]["City"].ToString(); utemp.ImageUrl = dtUS.Rows[r]["Picture"].ToString(); evTemp.PlayerUserList.Add(utemp); } eventsList.Add(evTemp); //add the event to the list } } JavaScriptSerializer js = new JavaScriptSerializer(); string jsonString = js.Serialize(eventsList); return jsonString; }
//insert event protected void insertEvent(EventOnAir ev) { string message; int numEfect = ev.insert(); if (numEfect == 0) { message = "The Event wasnt added!"; ShowPopup(message); } else { message = "The Event was added Successfully!"; ShowPopup(message); Response.Redirect("MyEvents.aspx"); } }
//updateEvent protected void updateEvent(EventOnAir ev) { string message; ev.EventNum = eventnum; int numEfect = ev.update(); if (numEfect == 0) { message = "The Event wasnt Update!"; ShowPopup(message); } else { message = "The Event was Update Successfully!"; ShowPopup(message); Response.Redirect("MyEvents.aspx"); } }
// update event public int update(EventOnAir p) { SqlConnection con; SqlCommand cmd; try { con = connect(conectionStr); } catch (Exception) { return 0; } String cStr = BuildupdateCommand(p); // helper method to build the insert string cmd = CreateCommand(cStr, con); // create the command try { int numEffected = cmd.ExecuteNonQuery(); // execute the command return numEffected; } catch (Exception ex) { return 0; // write to log MessageBox.Show("the Event wasnt added" + ex, "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop); } finally { if (con != null) { // close the db connection con.Close(); } } }
//build insert update for event private String BuildupdateCommand(EventOnAir p) { int isprivate = 0; string dateStr = ""; if (p.IsPrivate1) isprivate = 1; dateStr += p.DateTime.Month.ToString() + "/" + p.DateTime.Day.ToString() + "/" + p.DateTime.Year.ToString() + " " + p.DateTime.Hour.ToString() + ":" + p.DateTime.Minute.ToString() + "0:00"; String command; StringBuilder sb = new StringBuilder(); String com = "UPDATE EventsOnAir SET NumOfParticipants=" + p.NumOfParti + ",CategoryId=" + p.Catedory + ",FrequencyId=" + p.Frequency + ", Private=" + isprivate + ", Time='" + dateStr + "',MinAge=" + p.MinAge + ",MaxAge=" + p.MaxAge + ",Comments='" + p.Comments + "',AdminId=" + p.AdminID + ",Address='" + p.Address + "',Lat=" + p.Point.Lat + ",Lng=" + p.Point.Lng + "WHERE EventNumber=" + p.EventNum; command = com; return command; }
//insert event to DB public int insert(EventOnAir p) { SqlConnection con; SqlCommand cmd; try { con = connect(conectionStr); } catch (Exception ex) { throw (ex); } String cStr = BuildInsertCommand(p); // helper method to build the insert string cmd = CreateCommand(cStr, con); // create the command try { int numEffected = cmd.ExecuteNonQuery(); // execute the command return numEffected; } catch (Exception ex) { return 0; // write to log throw (ex); } finally { if (con != null) { // close the db connection con.Close(); } } }
//build insert command for event private String BuildInsertCommand(EventOnAir p) { String command; int isprivate = 0; string dateStr = " "; StringBuilder sb = new StringBuilder(); if (p.IsPrivate1) isprivate = 1; dateStr += p.DateTime.Month.ToString() + "/" + p.DateTime.Day.ToString() + "/" + p.DateTime.Year.ToString() + " " + p.DateTime.Hour.ToString() + ":" + p.DateTime.Minute.ToString() + "0:00"; sb.AppendFormat("Values({0}, {1} ,{2}, {3},'{4}',{5},{6},'{7}',{8},'{9}','{10}','{11}')", p.NumOfParti, p.Catedory, p.Frequency, isprivate, dateStr, p.MinAge, p.MaxAge, p.Comments, p.AdminID, p.Address, p.Point.Lat, p.Point.Lng); String prefix = "INSERT INTO EventsOnAir " + "( NumOfParticipants, CategoryId, FrequencyId, [Private],[Time],MinAge,MaxAge,Comments,AdminId,Address,Lat,Lng)"; command = prefix + sb.ToString(); return command; }
protected void Page_Load(object sender, EventArgs e) { string ageRange; EventOnAir Ev = new EventOnAir(); MapPlaceHolder.Visible = false; dt = Ev.readTable(); GridView1.DataSource = dt; GridView1.DataBind(); //load the user age if (Session["UserDeatail"] != null) { DataTable dtUser = (DataTable)HttpContext.Current.Session["UserDeatail"]; ageTXT.Text = dtUser.Rows[0]["Age"].ToString(); } for (int i = 0; i < dt.Rows.Count; i++) { //edit the age range ageRange = dt.Rows[i]["MinAge"].ToString(); ageRange += "-" + dt.Rows[i]["MaxAge"].ToString(); GridView1.Rows[i].Cells[6].Text = ageRange; // adding the join btn Button JoinBtn = new Button(); JoinBtn.Text = " Join Now"; JoinBtn.CssClass = "myButton"; JoinBtn.Click += new EventHandler(JoinBtn_Click); JoinBtn.ID = dt.Rows[i]["EventNumber"].ToString(); GridView1.Rows[i].Cells[7].Controls.Add(JoinBtn); //hide if private CheckBox cb = (CheckBox)GridView1.Rows[i].Cells[10].Controls[0]; if (cb.Checked) { GridView1.Rows[i].Visible = false; } //hide EventNumber & Comments & private& lat lng for (int r = 8; r < 14; r++) { GridView1.Rows[i].Cells[r].Visible = false; GridView1.HeaderRow.Cells[r].Visible = false; } } GridView1.HeaderRow.Cells[0].Text = ""; GridView1.HeaderRow.Cells[2].Text = "Max Partic."; GridView1.HeaderRow.Cells[6].Text = "Age Range"; GridView1.HeaderRow.Cells[7].Text = ""; //adding the image for (int i = 0; i < dt.Rows.Count; i++) { Image imsel = new Image(); imsel.ImageUrl = dt.Rows[i]["imageUrl"].ToString(); GridView1.Rows[i].Cells[0].Controls.Add(imsel); } }