protected List<Space> CreateSpaceList() { try { //Creating the vehicle List<Space> spaceList = new List<Space>(); SpaceType spaceType = new SpaceType(); SpaceData spaceData = new SpaceData(); DataTable dataTableAmountOfSpace = new DataTable(); int parkingId; string parkingName; int campusId; int spaceTypeId; string spaceTypeName; bool status = true; int amount = 1; try { amount = Convert.ToInt32(textboxAmount.Value); } catch (FormatException) { buttonStyle.buttonStyleRed(buttonErrors, "You can't enter numbers in amount field."); return null; } if (hiddenCampusValue.Value.Equals(string.Empty)) campusId = Convert.ToInt32(selectCampus.Items[0].Value); else campusId = Convert.ToInt32(hiddenCampusValue.Value); if (hiddenPakingValue.Value.Equals(string.Empty)) { parkingId = Convert.ToInt32(selectParking.Items[0].Value); parkingName = selectParking.Items[0].Text; } else { parkingId = Convert.ToInt32(hiddenPakingValue.Value); parkingName = selectParking.Items.FindByValue(hiddenPakingValue.Value).Text; } if (hiddenSpaceTypeValue.Value.Equals(string.Empty)) { dataTableAmountOfSpace = spaceData.DataTableParkingTypeSpace(parkingId, Convert.ToInt32(selectSpaceType.Items[0].Value)); spaceTypeId = Convert.ToInt32(selectSpaceType.Items[0].Value); spaceTypeName = selectSpaceType.Items[0].Text; } else { dataTableAmountOfSpace = spaceData.DataTableParkingTypeSpace(parkingId, Convert.ToInt32(hiddenSpaceTypeValue.Value)); spaceTypeId = Convert.ToInt32(hiddenSpaceTypeValue.Value); spaceTypeName = selectSpaceType.Items.FindByValue(hiddenSpaceTypeValue.Value).Text; } if (hiddenStatusValue.Value.Equals(string.Empty)) { buttonStyle.buttonStyleRed(buttonErrors, "Please, input the status of the lapse."); return null; } else { if (hiddenStatusValue.Value.Equals("true")) status = true; else if (hiddenStatusValue.Value.Equals("false")) status = false; } spaceType.Id = spaceTypeId; spaceType.Name = spaceTypeName; if (amount == 0) { buttonStyle.buttonStyleRed(buttonErrors, "The amount can't be zero."); return null; } else if (amount < 0) { buttonStyle.buttonStyleRed(buttonErrors, "The amount can't be less than zero."); return null; } for (int i = dataTableAmountOfSpace.Rows.Count + 1; i < dataTableAmountOfSpace.Rows.Count + 1 + amount; i++) { Space space = new Space(); space.Name = spaceTypeName + "-" + i; space.ParkingId = parkingId; space.ParkingName = parkingName; space.ParkingCampusId = campusId; space.SpaceType = spaceType; space.Status = status; spaceList.Add(space); } return spaceList; } catch (FormatException) { return null; } }
protected void FillTable() { SpaceData spaceData = new SpaceData(); DataTable dt = new DataTable(); int campusId = 0; int parkingId = 0; //Populating a DataTable from database. try { if (hiddenCampusToViewValue.Value.Equals(string.Empty)) { campusId = Convert.ToInt32(selectCampusToView.Items[0].Value); } else { campusId = Convert.ToInt32(hiddenCampusToViewValue.Value); } buttonStyle.buttonStyleBlue(buttonInfoSpaceTable, "Please, after any operation select one space!"); } catch (Exception) { buttonStyle.buttonStyleRed(buttonInfoSpaceTable, "No campus or parking available to view."); } try { if (hiddenParkingToViewValue.Value.Equals(string.Empty)) { parkingId = Convert.ToInt32(selectParkingToView.Items[0].Value); } else { parkingId = Convert.ToInt32(hiddenParkingToViewValue.Value); } buttonStyle.buttonStyleBlue(buttonInfoSpaceTable, "Please, after any operation select one space!"); } catch (Exception) { buttonStyle.buttonStyleRed(buttonInfoSpaceTable, "No parking available to view."); } dt = spaceData.DataTableParkingSpace(campusId, parkingId); //Building an HTML string. StringBuilder html = new StringBuilder(); //Building the Header row. html.Append("<tbody>"); html.Append("<tr>"); foreach (DataColumn column in dt.Columns) { html.Append("<th>"); html.Append(column.ColumnName); html.Append("</th>"); } html.Append("</tr>"); //Building the Data rows. foreach (DataRow row in dt.Rows) { html.Append("<tr class='desmarcado'>"); foreach (DataColumn column in dt.Columns) { html.Append("<td onclick='getValue(this.parentNode)' style='cursor:pointer'>"); html.Append(row[column.ColumnName]); html.Append("</td>"); } html.Append("<td>"); html.Append("<button onclick='setValues(this.parentNode.parentNode)' type='button'>Edit</button>"); html.Append("</td>"); html.Append("<td>"); html.Append("<button onclick='deleteRole()' type='button'>Delete</button>"); html.Append("</td>"); html.Append("</tr>"); } html.Append("</tbody>"); //Append the HTML string to Placeholder. placeHolderTableSpace.Controls.Clear(); placeHolderTableSpace.Controls.Add(new Literal { Text = html.ToString() }); }
protected void FillTable() { SpaceData spaceData = new SpaceData(); DataTable dt = new DataTable(); int campusId = 0; int parkingId = 0; //Populating a DataTable from database. try { if (hiddenCampusToViewValue.Value.Equals(string.Empty)) campusId = Convert.ToInt32(selectCampusToView.Items[0].Value); else campusId = Convert.ToInt32(hiddenCampusToViewValue.Value); buttonStyle.buttonStyleBlue(buttonInfoSpaceTable, "Please, after any operation select one space!"); } catch (Exception) { buttonStyle.buttonStyleRed(buttonInfoSpaceTable, "No campus or parking available to view."); } try { if (hiddenParkingToViewValue.Value.Equals(string.Empty)) parkingId = Convert.ToInt32(selectParkingToView.Items[0].Value); else parkingId = Convert.ToInt32(hiddenParkingToViewValue.Value); buttonStyle.buttonStyleBlue(buttonInfoSpaceTable, "Please, after any operation select one space!"); } catch (Exception) { buttonStyle.buttonStyleRed(buttonInfoSpaceTable, "No parking available to view."); } dt = spaceData.DataTableParkingSpace(campusId, parkingId); //Building an HTML string. StringBuilder html = new StringBuilder(); //Building the Header row. html.Append("<tbody>"); html.Append("<tr>"); foreach (DataColumn column in dt.Columns) { html.Append("<th>"); html.Append(column.ColumnName); html.Append("</th>"); } html.Append("</tr>"); //Building the Data rows. foreach (DataRow row in dt.Rows) { html.Append("<tr class='desmarcado'>"); foreach (DataColumn column in dt.Columns) { html.Append("<td onclick='getValue(this.parentNode)' style='cursor:pointer'>"); html.Append(row[column.ColumnName]); html.Append("</td>"); } html.Append("<td>"); html.Append("<button onclick='setValues(this.parentNode.parentNode)' type='button'>Edit</button>"); html.Append("</td>"); html.Append("<td>"); html.Append("<button onclick='deleteRole()' type='button'>Delete</button>"); html.Append("</td>"); html.Append("</tr>"); } html.Append("</tbody>"); //Append the HTML string to Placeholder. placeHolderTableSpace.Controls.Clear(); placeHolderTableSpace.Controls.Add(new Literal { Text = html.ToString() }); }
protected List <Space> CreateSpaceList() { try { //Creating the vehicle List <Space> spaceList = new List <Space>(); SpaceType spaceType = new SpaceType(); SpaceData spaceData = new SpaceData(); DataTable dataTableAmountOfSpace = new DataTable(); int parkingId; string parkingName; int campusId; int spaceTypeId; string spaceTypeName; bool status = true; int amount = 1; try { amount = Convert.ToInt32(textboxAmount.Value); } catch (FormatException) { buttonStyle.buttonStyleRed(buttonErrors, "You can't enter numbers in amount field."); return(null); } if (hiddenCampusValue.Value.Equals(string.Empty)) { campusId = Convert.ToInt32(selectCampus.Items[0].Value); } else { campusId = Convert.ToInt32(hiddenCampusValue.Value); } if (hiddenPakingValue.Value.Equals(string.Empty)) { parkingId = Convert.ToInt32(selectParking.Items[0].Value); parkingName = selectParking.Items[0].Text; } else { parkingId = Convert.ToInt32(hiddenPakingValue.Value); parkingName = selectParking.Items.FindByValue(hiddenPakingValue.Value).Text; } if (hiddenSpaceTypeValue.Value.Equals(string.Empty)) { dataTableAmountOfSpace = spaceData.DataTableParkingTypeSpace(parkingId, Convert.ToInt32(selectSpaceType.Items[0].Value)); spaceTypeId = Convert.ToInt32(selectSpaceType.Items[0].Value); spaceTypeName = selectSpaceType.Items[0].Text; } else { dataTableAmountOfSpace = spaceData.DataTableParkingTypeSpace(parkingId, Convert.ToInt32(hiddenSpaceTypeValue.Value)); spaceTypeId = Convert.ToInt32(hiddenSpaceTypeValue.Value); spaceTypeName = selectSpaceType.Items.FindByValue(hiddenSpaceTypeValue.Value).Text; } if (hiddenStatusValue.Value.Equals(string.Empty)) { buttonStyle.buttonStyleRed(buttonErrors, "Please, input the status of the lapse."); return(null); } else { if (hiddenStatusValue.Value.Equals("true")) { status = true; } else if (hiddenStatusValue.Value.Equals("false")) { status = false; } } spaceType.Id = spaceTypeId; spaceType.Name = spaceTypeName; if (amount == 0) { buttonStyle.buttonStyleRed(buttonErrors, "The amount can't be zero."); return(null); } else if (amount < 0) { buttonStyle.buttonStyleRed(buttonErrors, "The amount can't be less than zero."); return(null); } for (int i = dataTableAmountOfSpace.Rows.Count + 1; i < dataTableAmountOfSpace.Rows.Count + 1 + amount; i++) { Space space = new Space(); space.Name = spaceTypeName + "-" + i; space.ParkingId = parkingId; space.ParkingName = parkingName; space.ParkingCampusId = campusId; space.SpaceType = spaceType; space.Status = status; spaceList.Add(space); } return(spaceList); } catch (FormatException) { return(null); } }