protected void Page_Load(object sender, EventArgs e) { projectId = Convert.ToInt32(HttpContext.Current.Session["project_id"].ToString()); #region hit the DB using (SqlConnection aConnection = new SqlConnection(sdsDBConnection.ConnectionString)) { aConnection.Open(); SqlCommand aCommand = aConnection.CreateCommand(); SqlTransaction aTransaction; SqlDataReader aReader; // Start a local transaction. aTransaction = aConnection.BeginTransaction("SampleTransaction"); // Must assign both transaction object and connection // to Command object for a pending local transaction aCommand.Connection = aConnection; aCommand.Transaction = aTransaction; try { //get number of walls floors and roofs aCommand.CommandText = "SELECT number_walls, number_floors, number_roofs FROM sunrooms WHERE project_id = '" + projectId + "'"; aReader = aCommand.ExecuteReader(); if (aReader.HasRows) { aReader.Read(); wallCount = Convert.ToInt32(aReader[0]); floorCount = Convert.ToInt32(aReader[1]); roofCount = Convert.ToInt32(aReader[2]); } aReader.Close(); #region walls //for each wall in the project //aCommand.CommandText = "SELECT wall_type, model_type, total_length, orientation, set_back, name, first_item_index, last_item_index, start_height, end_height, soffit_length, gable_peak, obstructions, fire_protection, wall_index " // + "FROM walls WHERE project_id = '" + projectId + "'"; //SqlDataReader wallReader = aCommand.ExecuteReader(); //if (wallReader.HasRows) //{ // while (wallReader.Read()) for (int i = 0; i < wallCount; i++) { aCommand.CommandText = "SELECT wall_type, model_type, total_length, orientation, set_back, name, first_item_index, last_item_index, start_height, end_height, soffit_length, gable_peak, obstructions, fire_protection, wall_index " + "FROM walls WHERE project_id = '" + projectId + "' AND wall_index = '" + i + "'"; aReader = aCommand.ExecuteReader(); aReader.Read(); //create a new instance of a wall and set all its attributes from the db Wall aWall = new Wall(); aWall.WallType = Convert.ToString(aReader[0]); aWall.ModelType = Convert.ToString(aReader[1]); aWall.Length = Convert.ToSingle(aReader[2]); aWall.Orientation = Convert.ToString(aReader[3]); aWall.SetBack = Convert.ToSingle(aReader[4]); aWall.Name = Convert.ToString(aReader[5]); aWall.FirstItemIndex = Convert.ToInt32(aReader[6]); aWall.LastItemIndex = Convert.ToInt32(aReader[7]); aWall.StartHeight = Convert.ToSingle(aReader[8]); aWall.EndHeight = Convert.ToSingle(aReader[9]); aWall.SoffitLength = Convert.ToSingle(aReader[10]); aWall.GablePeak = Convert.ToSingle(aReader[11]); aWall.FireProtection = Convert.ToBoolean(aReader[13]); int wallIndex = Convert.ToInt32(aReader[14]); aReader.Close(); List<LinearItem> listOfLinearItems = new List<LinearItem>(); //Get linear items //aCommand.CommandText = "SELECT linear_index, linear_type, start_height, end_height, length, frame_colour, sex, fixed_location, attached_to " // + "FROM linear_items WHERE project_id = '" + projectId + "' AND last_item_index < '" + aWall.LastItemIndex + "' AND first_item_index > '" + aWall.FirstItemIndex + "'"; //aReader = aCommand.ExecuteReader(); //for each linear item/mod in the wall //if (linearItemReader.HasRows) //{ // while (linearItemReader.Read()) // { for (int j = aWall.FirstItemIndex; j < aWall.LastItemIndex; j++) { //Get linear items aCommand.CommandText = "SELECT linear_index, linear_type, start_height, end_height, length, frame_colour, sex, fixed_location, attached_to " + "FROM linear_items WHERE project_id = '" + projectId + "' AND linear_index = '" + j + "'"; aReader = aCommand.ExecuteReader(); aReader.Read(); int linearIndex = Convert.ToInt32(aReader[0]); string linearItemType = Convert.ToString(aReader[1]); float startHeight = Convert.ToSingle(aReader[2]); float endHeight = Convert.ToSingle(aReader[3]); float length = Convert.ToSingle(aReader[4]); string frameColour = Convert.ToString(aReader[5]); string sex = Convert.ToString(aReader[6]); float fixedLocation = Convert.ToSingle(aReader[7]); bool attachedTo = Convert.ToBoolean(aReader[8]); aReader.Close(); switch (linearItemType) { case "Mod": #region Mod List<ModuleItem> listOfModuleItems = new List<ModuleItem>(); Mod aMod = new Mod(); aMod.LinearIndex = linearIndex; aMod.ItemType = linearItemType; aMod.StartHeight = startHeight; aMod.EndHeight = endHeight; aMod.Length = length; aMod.FrameColour = frameColour; aMod.Sex = sex; aMod.FixedLocation = fixedLocation; aMod.AttachedTo = attachedTo; //get number of mods aCommand.CommandText = "SELECT COUNT(*) FROM module_items WHERE project_id = '" + projectId + "' " + " AND linear_index = '" + aMod.LinearIndex + "'"; aReader = aCommand.ExecuteReader(); aReader.Read(); int modCount = Convert.ToInt32(aReader[0]); //get the number of walls in the project aReader.Close(); //aCommand.CommandText = "SELECT module_index, item_type, start_height, end_height, length FROM moduleItems " // + "WHERE project_id = '" + projectId + "' AND linear_index = '" + aMod.LinearIndex + "'"; //SqlDataReader moduleItemReader = aCommand.ExecuteReader(); //for each modular item in the mod //if (moduleItemReader.HasRows) //{ // while (moduleItemReader.Read()) for (int k = 0; k < modCount; k++) { //Get module items aCommand.CommandText = "SELECT module_index, item_type, start_height, end_height, length FROM module_items " + "WHERE project_id = '" + projectId + "' AND linear_index = '" + aMod.LinearIndex + "' AND module_index = '" + k + "'"; aReader = aCommand.ExecuteReader(); aReader.Read(); int moduleIndex = Convert.ToInt32(aReader[0]); string itemType = Convert.ToString(aReader[1]); float fStartHeight = Convert.ToSingle(aReader[2]); float fEndHeight = Convert.ToSingle(aReader[3]); float fLength = Convert.ToSingle(aReader[4]); aReader.Close(); //different types of mods switch (itemType) { case "Kneewall": case "Window": #region Window //Get window aCommand.CommandText = "SELECT window_type, screen_type, start_height, end_height, length, window_colour, number_vents FROM windows " + "WHERE project_id = '" + projectId + "' AND linear_index = '" + aMod.LinearIndex + "' AND module_index = '" + moduleIndex + "'"; aReader = aCommand.ExecuteReader(); //if (windowReader.HasRows) //{ aReader.Read(); string windowStyle = Convert.ToString(aReader[0]); string screenType = Convert.ToString(aReader[1]); float windowStartHeight = Convert.ToSingle(aReader[2]); float windowEndHeight = Convert.ToSingle(aReader[3]); float windowLength = Convert.ToSingle(aReader[4]); string windowColour = Convert.ToString(aReader[5]); int numVents = Convert.ToInt32(aReader[6]); aReader.Close(); //types of windows switch (windowStyle) { case "Double Slider": //glass model 300 case "Single Slider": //glass model 400 case "Horizontal Roller XX": //glass model 300 case "Horizontal Roller": case "Horizontal 2 Track": case "H2T": case "Vertical 4 Track": case "Vertical Four Track": case "V4T": case "Vinyl": #region Vinyl Window VinylWindow aVinylWindow = new VinylWindow(); aVinylWindow.ModuleIndex = moduleIndex; aVinylWindow.ItemType = itemType; aVinylWindow.FStartHeight = fStartHeight; aVinylWindow.FEndHeight = fEndHeight; aVinylWindow.FLength = fLength; //aVinylWindow.Colour = windowColour; //replaced by FrameColour aVinylWindow.WindowStyle = windowStyle; aVinylWindow.ScreenType = screenType; aVinylWindow.LeftHeight = windowStartHeight; aVinylWindow.RightHeight = windowEndHeight; aVinylWindow.Width = windowLength; aVinylWindow.FrameColour = windowColour; // aVinylWindow.VinylTint = ""; // tint of each vent will be concatenated //numVents = (numVents == 0) ? 1 : numVents; aVinylWindow.NumVents = numVents; List<float> listOfVentHeights = new List<float>(); //Get vinyl item //aCommand.CommandText = "SELECT start_height, vinyl_tint, spreader_bar FROM vinyl_items " // + "WHERE project_id = '" + projectId + "' AND linear_index = '" + aMod.LinearIndex + "' AND module_index = '" + moduleIndex + "'"; //aReader = aCommand.ExecuteReader(); //if (vinylReader.HasRows) //{ //while (vinylReader.Read()) //for each vinyl item in the in the vinyl window for (int l = 0; l < numVents; l++) { aCommand.CommandText = "SELECT start_height, vinyl_tint, spreader_bar FROM vinyl_items " + "WHERE project_id = '" + projectId + "' AND linear_index = '" + aMod.LinearIndex + "' AND module_index = '" + moduleIndex + "' AND vent_index = '" + l + "'"; aReader = aCommand.ExecuteReader(); aReader.Read(); listOfVentHeights.Add(Convert.ToSingle(aReader[0])); aVinylWindow.VinylTint += Convert.ToString(aReader[1]); aVinylWindow.SpreaderBar = Convert.ToSingle(aReader[2]); aReader.Close(); } //vinylReader.Close(); aVinylWindow.VentHeights = listOfVentHeights; listOfModuleItems.Add(aVinylWindow); #endregion break; case "Screen": #region Screen Window Window aWindow = new Window(); aWindow.ModuleIndex = moduleIndex; aWindow.ItemType = itemType; aWindow.FStartHeight = fStartHeight; aWindow.FEndHeight = fEndHeight; aWindow.FLength = fLength; //aWindow.Colour = windowColour; //replaced by FrameColour aWindow.WindowStyle = windowStyle; aWindow.ScreenType = screenType; aWindow.LeftHeight = windowStartHeight; aWindow.RightHeight = windowEndHeight; aWindow.Width = windowLength; aWindow.FrameColour = windowColour; // //aWindow.VinylTint = ""; // tint of each vent will be concatenated //aWindow.NumVents = numVents; listOfModuleItems.Add(aWindow); #endregion break; case "Glass": case "Fixed Glass 2\"": #region Glass Window GlassWindow aGlassWindow = new GlassWindow(); aGlassWindow.ModuleIndex = moduleIndex; aGlassWindow.ItemType = itemType; aGlassWindow.FStartHeight = fStartHeight; aGlassWindow.FEndHeight = fEndHeight; aGlassWindow.FLength = fLength; //aGlassWindow.Colour = windowColour; //replaced by frameColour aGlassWindow.WindowStyle = windowStyle; aGlassWindow.ScreenType = screenType; aGlassWindow.LeftHeight = windowStartHeight; aGlassWindow.RightHeight = windowEndHeight; aGlassWindow.Width = windowLength; aGlassWindow.FrameColour = windowColour; // aGlassWindow.GlassTint = ""; // tint of each vent will be concatenated aGlassWindow.Operation = ""; // XX, XO, OX will be concatenated aGlassWindow.NumVents = numVents; //Get glass item //aCommand.CommandText = "SELECT glass_type, glass_tint, tempered, operation FROM glass_items " // + "WHERE project_id = '" + projectId + "' AND linear_index = '" + aMod.LinearIndex + "' AND module_index = '" + moduleIndex + "'"; //SqlDataReader glassReader = aCommand.ExecuteReader(); for (int l = 0; l < numVents; l++) { //if (glassReader.HasRows) //{ // while (glassReader.Read()) // { aCommand.CommandText = "SELECT glass_type, glass_tint, tempered, operation FROM glass_items " + "WHERE project_id = '" + projectId + "' AND linear_index = '" + aMod.LinearIndex + "' AND module_index = '" + moduleIndex + "' AND vent_index = '" + l + "'"; aReader = aCommand.ExecuteReader(); aReader.Read(); aGlassWindow.GlassType = Convert.ToString(aReader[0]); aGlassWindow.GlassTint += Convert.ToString(aReader[1]); aGlassWindow.Tempered = Convert.ToBoolean(aReader[2]); aGlassWindow.Operation += Convert.ToString(aReader[3]); aReader.Close(); } //glassReader.Close(); listOfModuleItems.Add(aGlassWindow); #endregion break; case "Open": #region Open Window Window openWindow = new Window(); openWindow.ModuleIndex = moduleIndex; openWindow.ItemType = itemType; openWindow.FStartHeight = fStartHeight; openWindow.FEndHeight = fEndHeight; openWindow.FLength = fLength; openWindow.WindowStyle = windowStyle; openWindow.ScreenType = screenType; openWindow.LeftHeight = windowStartHeight; openWindow.RightHeight = windowEndHeight; openWindow.Width = windowLength; openWindow.FrameColour = windowColour; listOfModuleItems.Add(openWindow); //add the modular item to the list #endregion break; case "Panel": case "Solid Wall": #region Open Window Window panel = new Window(); panel.ModuleIndex = moduleIndex; panel.ItemType = itemType; panel.FStartHeight = fStartHeight; panel.FEndHeight = fEndHeight; panel.FLength = fLength; panel.WindowStyle = windowStyle; panel.ScreenType = screenType; panel.LeftHeight = windowStartHeight; panel.RightHeight = windowEndHeight; panel.Width = windowLength; panel.FrameColour = windowColour; listOfModuleItems.Add(panel); //add the modular item to the list #endregion break; } //windowReader.Close(); #endregion break; case "Door": #region Door //Get door //aCommand.CommandText = "SELECT door_type, door_style, screen_type, height, length, door_colour, kick_plate FROM doors " // + "WHERE project_id = '" + projectId + "' AND linear_index = '" + aMod.LinearIndex + "' AND module_index = '" + moduleIndex + "'"; //SqlDataReader doorReader = aCommand.ExecuteReader(); //if (doorReader.HasRows) //{ // while (doorReader.Read()) aCommand.CommandText = "SELECT door_type, door_style, screen_type, height, length, door_colour, kick_plate FROM doors " + "WHERE project_id = '" + projectId + "' AND linear_index = '" + aMod.LinearIndex + "' AND module_index = '" + moduleIndex + "'"; aReader = aCommand.ExecuteReader(); aReader.Read(); string doorType = Convert.ToString(aReader[0]); string doorStyle = Convert.ToString(aReader[1]); string doorScreenType = Convert.ToString(aReader[2]); float doorFrameHeight = Convert.ToSingle(aReader[3]); float doorFrameLength = Convert.ToSingle(aReader[4]); string doorColour = Convert.ToString(aReader[5]); float doorKickPlate = Convert.ToSingle(aReader[6]); aReader.Close(); //get the window in this door aCommand.CommandText = "SELECT door_index, window_type, screen_type, start_height, end_height, length, window_colour, number_vents FROM windows " + "WHERE project_id = '" + projectId + "' AND linear_index = '" + aMod.LinearIndex + "' AND module_index = '" + moduleIndex + "'"; aReader = aCommand.ExecuteReader(); VinylWindow aDoorWindow = new VinylWindow(); if (aReader.HasRows) { while (aReader.Read()) { //int doorIndex = Convert.ToInt32(aReader[0]); aDoorWindow.WindowStyle = Convert.ToString(aReader[1]); aDoorWindow.ScreenType = Convert.ToString(aReader[2]); aDoorWindow.LeftHeight = Convert.ToSingle(aReader[3]); aDoorWindow.RightHeight = Convert.ToSingle(aReader[4]); aDoorWindow.Width = Convert.ToSingle(aReader[5]); aDoorWindow.FrameColour = Convert.ToString(aReader[6]); aDoorWindow.NumVents = Convert.ToInt32(aReader[7]); } } aReader.Close(); switch (aDoorWindow.WindowStyle) //door/window style { case "Full Screen": //screen break; case "Vertical Four Track": //vinyl #region V4T List<float> listOfV4TVentHeights = new List<float>(); //for each vinyl item in the in the vinyl window //for (int l = 0; l < aDoorWindow.NumVents; l++) //Get vinyl item aCommand.CommandText = "SELECT start_height, vinyl_tint, spreader_bar FROM vinyl_items " + "WHERE project_id = '" + projectId + "' AND linear_index = '" + aMod.LinearIndex + "' AND module_index = '" + moduleIndex + "'"; SqlDataReader vinylReader = aCommand.ExecuteReader(); if (vinylReader.HasRows) { while (vinylReader.Read()) { listOfV4TVentHeights.Add(Convert.ToSingle(vinylReader[0])); aDoorWindow.VinylTint += Convert.ToString(vinylReader[1]); aDoorWindow.SpreaderBar = Convert.ToSingle(vinylReader[2]); } } vinylReader.Close(); aDoorWindow.VentHeights = listOfV4TVentHeights; #endregion break; case "Full View": //glass break; case "Full View Colonial": //glass break; case "Half Lite": //glass break; case "Half Lite Venting": //glass break; case "Half Lite with Mini Blinds": //glass break; case "Full View with Mini Blinds": //glass break; case "Aluminum Storm Screen": //screen break; case "Aluminum Storm Glass": //glass break; case "Vinyl Guard": //vinyl break; } //types of doors switch (doorType) { case "Cabana": case "Cabana Door": #region Cabana Door aCommand.CommandText = "SELECT glass_tint, hinge, swing, hardware_type, screen_type FROM cabana_doors " + "WHERE project_id = '" + projectId + "' AND linear_index = '" + aMod.LinearIndex + "' AND module_index = '" + moduleIndex + "'"; SqlDataReader cabanaReader = aCommand.ExecuteReader(); if (cabanaReader.HasRows) { cabanaReader.Read(); CabanaDoor aCabanaDoor = new CabanaDoor(); aCabanaDoor.ModuleIndex = moduleIndex; aCabanaDoor.ItemType = itemType; aCabanaDoor.FStartHeight = fStartHeight; aCabanaDoor.FEndHeight = fEndHeight; aCabanaDoor.FLength = fLength; aCabanaDoor.DoorType = doorType; aCabanaDoor.DoorStyle = doorStyle; aCabanaDoor.ScreenType = doorScreenType; aCabanaDoor.Height = doorFrameHeight; aCabanaDoor.Length = doorFrameLength; aCabanaDoor.Colour = doorColour; // aCabanaDoor.Kickplate = doorKickPlate; // aCabanaDoor.GlassTint = Convert.ToString(cabanaReader[0]); aCabanaDoor.Hinge = Convert.ToString(cabanaReader[1]); aCabanaDoor.Swing = Convert.ToString(cabanaReader[2]); aCabanaDoor.HardwareType = Convert.ToString(cabanaReader[3]); aCabanaDoor.ScreenType = Convert.ToString(cabanaReader[4]); aCabanaDoor.DoorWindow = aDoorWindow; listOfModuleItems.Add(aCabanaDoor); //add the modular item to the list } cabanaReader.Close(); #endregion break; case "French": case "French Door": #region French Door aCommand.CommandText = "SELECT glass_tint, swing, operator, hardware_type, screen_type FROM french_doors " + "WHERE project_id = '" + projectId + "' AND linear_index = '" + aMod.LinearIndex + "' AND module_index = '" + moduleIndex + "'"; SqlDataReader frenchReader = aCommand.ExecuteReader(); if (frenchReader.HasRows) { frenchReader.Read(); FrenchDoor aFrenchDoor = new FrenchDoor(); aFrenchDoor.ModuleIndex = moduleIndex; aFrenchDoor.ItemType = itemType; aFrenchDoor.FStartHeight = fStartHeight; aFrenchDoor.FEndHeight = fEndHeight; aFrenchDoor.FLength = fLength; aFrenchDoor.DoorType = doorType; aFrenchDoor.DoorStyle = doorStyle; aFrenchDoor.ScreenType = doorScreenType; aFrenchDoor.Height = doorFrameHeight; aFrenchDoor.Length = doorFrameLength; aFrenchDoor.Colour = doorColour; // aFrenchDoor.Kickplate = doorKickPlate; // aFrenchDoor.GlassTint = Convert.ToString(frenchReader[0]); aFrenchDoor.Swing = Convert.ToString(frenchReader[1]); aFrenchDoor.OperatingDoor = Convert.ToString(frenchReader[2]); ///this needs to be fixed, operator in db is bool and C# is string aFrenchDoor.HardwareType = Convert.ToString(frenchReader[3]); aFrenchDoor.ScreenType = Convert.ToString(frenchReader[4]); aFrenchDoor.DoorWindow = aDoorWindow; listOfModuleItems.Add(aFrenchDoor); //add the modular item to the list } frenchReader.Close(); #endregion break; case "Patio": case "Patio Door": #region Patio Door aCommand.CommandText = "SELECT glass_tint, moving_door FROM patio_doors " + "WHERE project_id = '" + projectId + "' AND linear_index = '" + aMod.LinearIndex + "' AND module_index = '" + moduleIndex + "'"; //change k to moduleIndex. Couldn't compile other pages. SqlDataReader patioReader = aCommand.ExecuteReader(); if (patioReader.HasRows) { patioReader.Read(); PatioDoor aPatioDoor = new PatioDoor(); aPatioDoor.ModuleIndex = moduleIndex; aPatioDoor.ItemType = itemType; aPatioDoor.FStartHeight = fStartHeight; aPatioDoor.FEndHeight = fEndHeight; aPatioDoor.FLength = fLength; aPatioDoor.DoorType = doorType; aPatioDoor.DoorStyle = doorStyle; aPatioDoor.ScreenType = doorScreenType; aPatioDoor.Height = doorFrameHeight; aPatioDoor.Length = doorFrameLength; aPatioDoor.Colour = doorColour; // aPatioDoor.Kickplate = doorKickPlate; // aPatioDoor.GlassTint = Convert.ToString(patioReader[0]); aPatioDoor.MovingDoor = Convert.ToString(patioReader[1]); ///this needs to be fixed, operator in db is bool and C# is string aPatioDoor.DoorWindow = aDoorWindow; listOfModuleItems.Add(aPatioDoor); //add the modular item to the list } patioReader.Close(); #endregion break; case "Half Lite": case "Half Lite Venting": case "Half Lite With Mini Blinds": case "Full View With Mini Blinds": break; case "NoDoor": case "No Door": #region No Door Door aDoor = new Door(); aDoor.ModuleIndex = moduleIndex; aDoor.ItemType = itemType; aDoor.FStartHeight = fStartHeight; aDoor.FEndHeight = fEndHeight; aDoor.FLength = fLength; aDoor.DoorType = doorType; //aDoor.DoorStyle = doorStyle; //aDoor.ScreenType = doorScreenType; aDoor.Height = doorFrameHeight; aDoor.Length = doorFrameLength; //aDoor.Colour = doorColour; // //aDoor.Kickplate = doorKickPlate; // listOfModuleItems.Add(aDoor); //add the modular item to the list //aReader.Close(); #endregion break; } //doorReader.Close(); #endregion break; case "Box Header": // #region H BoxHeader HBoxHeader hBoxHeader = new HBoxHeader(); hBoxHeader.ModuleIndex = moduleIndex; hBoxHeader.ItemType = itemType; hBoxHeader.FStartHeight = fStartHeight; hBoxHeader.FEndHeight = fEndHeight; hBoxHeader.FLength = fLength; listOfModuleItems.Add(hBoxHeader); //add the modular item to the list #endregion break; // case "Receiver": // #region H Receiver HReceiver hReceiver = new HReceiver(); hReceiver.ModuleIndex = moduleIndex; hReceiver.ItemType = itemType; hReceiver.FStartHeight = fStartHeight; hReceiver.FEndHeight = fEndHeight; hReceiver.FLength = fLength; listOfModuleItems.Add(hReceiver); //add the modular item to the list #endregion break; case "Panel": // same as open wall window #region Solid Wall Window Window solid = new Window(); solid.ModuleIndex = moduleIndex; solid.ItemType = itemType; solid.FStartHeight = fStartHeight; solid.FEndHeight = fEndHeight; solid.FLength = fLength; listOfModuleItems.Add(solid); //add the modular item to the list #endregion break; } aMod.ModularItems = listOfModuleItems; } listOfLinearItems.Add(aMod);//add the linear item to the list //moduleItemReader.Close(); #endregion break; case "Receiver": case "Receiever": #region Receiver BoxHeader aBoxHeader = new BoxHeader(); aBoxHeader.LinearIndex = linearIndex; aBoxHeader.ItemType = linearItemType; aBoxHeader.StartHeight = startHeight; aBoxHeader.EndHeight = endHeight; aBoxHeader.Length = length; aBoxHeader.FrameColour = frameColour; aBoxHeader.Sex = sex; aBoxHeader.FixedLocation = fixedLocation; aBoxHeader.AttachedTo = attachedTo; aBoxHeader.IsReceiver = true; aBoxHeader.IsTwoPiece = false; listOfLinearItems.Add(aBoxHeader);//add the linear item to the list #endregion break; case "2 Piece Receiver": case "2PieceReceiver": #region 2 Piece Receiver aBoxHeader = new BoxHeader(); aBoxHeader.LinearIndex = linearIndex; aBoxHeader.ItemType = linearItemType; aBoxHeader.StartHeight = startHeight; aBoxHeader.EndHeight = endHeight; aBoxHeader.Length = length; aBoxHeader.FrameColour = frameColour; aBoxHeader.Sex = sex; aBoxHeader.FixedLocation = fixedLocation; aBoxHeader.AttachedTo = attachedTo; aBoxHeader.IsReceiver = true; aBoxHeader.IsTwoPiece = true; listOfLinearItems.Add(aBoxHeader);//add the linear item to the list #endregion break; case "BoxHeader": // case "Box Header": // #region Box Header aBoxHeader = new BoxHeader(); aBoxHeader.LinearIndex = linearIndex; aBoxHeader.ItemType = linearItemType; aBoxHeader.StartHeight = startHeight; aBoxHeader.EndHeight = endHeight; aBoxHeader.Length = length; aBoxHeader.FrameColour = frameColour; aBoxHeader.Sex = sex; aBoxHeader.FixedLocation = fixedLocation; aBoxHeader.AttachedTo = attachedTo; aBoxHeader.IsReceiver = false; //aBoxHeader.IsTwoPiece = false; listOfLinearItems.Add(aBoxHeader);//add the linear item to the list #endregion break; case "BoxHeaderReceiver": case "Box Header Receiver": // #region Box Header Receiver aBoxHeader = new BoxHeader(); aBoxHeader.LinearIndex = linearIndex; aBoxHeader.ItemType = linearItemType; aBoxHeader.StartHeight = startHeight; aBoxHeader.EndHeight = endHeight; aBoxHeader.Length = length; aBoxHeader.FrameColour = frameColour; aBoxHeader.Sex = sex; aBoxHeader.FixedLocation = fixedLocation; aBoxHeader.AttachedTo = attachedTo; aBoxHeader.IsReceiver = true; //aBoxHeader.IsTwoPiece = false; listOfLinearItems.Add(aBoxHeader);//add the linear item to the list #endregion break; case "Filler": #region Filler Filler aFiller = new Filler(); aFiller.LinearIndex = linearIndex; aFiller.ItemType = linearItemType; aFiller.StartHeight = startHeight; aFiller.EndHeight = endHeight; aFiller.Length = length; //aFiller.FrameColour = frameColour; aFiller.Sex = "MM"; aFiller.FixedLocation = fixedLocation; aFiller.AttachedTo = attachedTo; listOfLinearItems.Add(aFiller);//add the linear item to the list #endregion break; case "Corner Post": case "Corner": #region Corner Post Corner aCorner = new Corner(); aCorner.LinearIndex = linearIndex; aCorner.ItemType = linearItemType; aCorner.StartHeight = startHeight; aCorner.EndHeight = endHeight; aCorner.Length = length; aCorner.FrameColour = frameColour; aCorner.Sex = sex; aCorner.FixedLocation = fixedLocation; aCorner.AttachedTo = attachedTo; //aCorner.AngleIs90 = true; //hard coded, because I don't know where its coming from //aCorner.OutsideCorner = true; // hard coded because I don't know where its coming from listOfLinearItems.Add(aCorner); //add the linear item to the list #endregion break; case "ElectricalChase": case "Electrical Chase": #region ElectricalChase ElectricalChase aElectricalChase = new ElectricalChase(); aElectricalChase.LinearIndex = linearIndex; aElectricalChase.ItemType = linearItemType; aElectricalChase.StartHeight = startHeight; aElectricalChase.EndHeight = endHeight; aElectricalChase.Length = length; //aElectricalChase.FrameColour = frameColour; aElectricalChase.Sex = "MM"; aElectricalChase.FixedLocation = fixedLocation; aElectricalChase.AttachedTo = attachedTo; listOfLinearItems.Add(aElectricalChase);//add the linear item to the list #endregion break; case "HChannel": case "H Channel": #region H Channel HChannel aHChannel = new HChannel(); aHChannel.LinearIndex = linearIndex; aHChannel.ItemType = linearItemType; aHChannel.StartHeight = startHeight; aHChannel.EndHeight = endHeight; aHChannel.Length = length; aHChannel.FrameColour = frameColour; aHChannel.Sex = sex; aHChannel.FixedLocation = fixedLocation; aHChannel.AttachedTo = attachedTo; listOfLinearItems.Add(aHChannel);//add the linear item to the list #endregion break; } } aWall.LinearItems = listOfLinearItems; listOfWalls.Add(aWall); //add the wall to the list } //linearItemReader.Close(); //wallReader.Close(); #endregion #region floors if (floorCount != 0) { } #endregion #region roofs //if there is a roof in the project if (roofCount != 0) { for(int i = 0; i < roofCount; i++) { aCommand.CommandText = "SELECT roof_type, interior_skin, exterior_skin, thickness, fire_protection, thermadeck, acrylic, gutter, gutter_pro, gutter_colour, number_supports, stripe_colour, projection, width, roof_index " + "FROM roofs WHERE project_id = '" + projectId + "' roof_index = '" + i + "'"; aReader = aCommand.ExecuteReader(); aReader.Read(); //if (roofReader.HasRows) //{ // while (roofReader.Read()) // { //create a new instance of a wall and set all its attributes from the db aRoof = new Roof(); aRoof.Type = Convert.ToString(aReader[0]); aRoof.InteriorSkin = Convert.ToString(aReader[1]); aRoof.ExteriorSkin = Convert.ToString(aReader[2]); aRoof.Thickness = Convert.ToDouble(aReader[3]); aRoof.FireProtection = Convert.ToBoolean(aReader[4]); aRoof.Thermadeck = Convert.ToBoolean(aReader[5]); aRoof.Acrylic = Convert.ToBoolean(aReader[6]); aRoof.Gutters = Convert.ToBoolean(aReader[7]); aRoof.GutterPro = Convert.ToBoolean(aReader[8]); aRoof.GutterColour = Convert.ToString(aReader[9]); aRoof.NumberSupports = Convert.ToInt32(aReader[10]); aRoof.StripeColour = Convert.ToString(aReader[11]); aRoof.Projection = Convert.ToDouble(aReader[12]); //how do we deal with obstructions aRoof.Width = Convert.ToDouble(aReader[13]); int roofIndex = Convert.ToInt32(aReader[14]); aReader.Close(); List<RoofModule> listOfRoofModules = new List<RoofModule>(); aCommand.CommandText = "SELECT COUNT(*) FROM roof_modules WHERE project_id = '" + projectId + "' AND roof_index = '" + roofIndex + "'"; aReader = aCommand.ExecuteReader(); aReader.Read(); int roofModCount = Convert.ToInt32(aReader[0]); //aCommand.CommandText = "SELECT projection, width, interior_skin, exterior_skin, roof_view " //+ "FROM roof_modules WHERE project_id = '" + projectId + "' AND roof_index = '" + roofIndex + "'"; //SqlDataReader moduleReader = aCommand.ExecuteReader(); //if (moduleReader.HasRows) //{ // while (moduleReader.Read()) for(int j = 0; j < roofModCount; j++) { aCommand.CommandText = "SELECT projection, width, interior_skin, exterior_skin, roof_view " + "FROM roof_modules WHERE project_id = '" + projectId + "' AND roof_index = '" + roofIndex + "'"; aReader = aCommand.ExecuteReader(); aReader.Read(); RoofModule aModule = new RoofModule(); aModule.Projection = Convert.ToDouble(aReader[0]); aModule.Width = Convert.ToDouble(aReader[1]); aModule.InteriorSkin = Convert.ToString(aReader[2]); aModule.ExteriorSkin = Convert.ToString(aReader[3]); int roofView = Convert.ToInt32(aReader[4]); aReader.Close(); List<RoofItem> listOfRoofItems = new List<RoofItem>(); aCommand.CommandText = "SELECT COUNT(*) FROM roof_modules WHERE project_id = '" + projectId + "' AND roof_index = '" + roofIndex + "' AND roof_view = '" + roofView + "'"; aReader = aCommand.ExecuteReader(); aReader.Read(); int roofItemCount = Convert.ToInt32(aReader[0]); //aCommand.CommandText = "SELECT roof_item, projection, width, item_index " //+ "FROM roof_modules WHERE project_id = '" + projectId + "' AND roof_index = '" + roofIndex + "' AND roof_view = '" + roofView + "'"; //SqlDataReader itemReader = aCommand.ExecuteReader(); //if (itemReader.HasRows) //{ // while(itemReader.Read()) for (int k = 0; k < roofItemCount; k++) { aCommand.CommandText = "SELECT roof_item, projection, width, item_index " + "FROM roof_modules WHERE project_id = '" + projectId + "' AND roof_index = '" + roofIndex + "' AND roof_view = '" + roofView + "' AND item_index = '" + k + "'"; aReader = aCommand.ExecuteReader(); aReader.Read(); // store in an object RoofItem aRoofItem = new RoofItem(); aRoofItem.ItemType = Convert.ToString(aReader[0]); aRoofItem.Projection = Convert.ToSingle(aReader[1]); aRoofItem.Width = Convert.ToSingle(aReader[2]); int itemIndex = Convert.ToInt32(aReader[3]); aReader.Close(); ///different types of roof items switch (aRoofItem.ItemType) { case "Receiver": //no class.. what to do .. same as panel receiver? break; case "Awning Track": //no class.. what to do break; case "I-Beam": //no class.. what to do break; case "Pressure Cap I-Beam": //no class.. what to do break; case "T-Bar": //no class.. what to do break; case "Acrylic Panel": //no class.. no class ... where is colour, width, setback, projection being stored? break; case "Foam Panel": //no class ... where is colour, width, setback, projection being stored? //accordding the to db, this is the only item in which you can have fanbeams and skylight //check for skylight in this roof item //are all skylights the same? length/width etc? .. //there is no skylight object.. roof item should have a attribute for a skylight object aCommand.CommandText = "SELECT skylight_type, set_back, operator " + "FROM skylights WHERE project_id = '" + projectId + "' AND roof_index = '" + roofIndex + "' AND roof_view = '" + roofView + "' AND item_index '" + itemIndex + "'"; SqlDataReader skylightReader = aCommand.ExecuteReader(); if (skylightReader.HasRows) { while (skylightReader.Read()) { //Skylight aSkylight = new Skylight(); //create object and set attribute if required aRoofItem.SkyLight = Convert.ToSingle(skylightReader[1]); } } else { aRoofItem.SkyLight = -1; } skylightReader.Close(); //check for fanbeams in this roof item //no info in the db or in C# aCommand.CommandText = "SELECT skylight_type, set_back, operator " + "FROM fanbeams WHERE project_id = '" + projectId + "' AND roof_index = '" + roofIndex + "' AND roof_view = '" + roofView + "' AND item_index = '" + itemIndex + "'"; SqlDataReader fanbeamReader = aCommand.ExecuteReader(); if (fanbeamReader.HasRows) { while (fanbeamReader.Read()) { //Skylight aSkylight = new Skylight(); //create object and set attribute if required aRoofItem.FanBeam = Convert.ToSingle(skylightReader[1]); } } else { aRoofItem.FanBeam = -1; } fanbeamReader.Close(); break; } listOfRoofItems.Add(aRoofItem); } //itemReader.Close(); aModule.RoofItems = listOfRoofItems; listOfRoofModules.Add(aModule); } //moduleReader.Close(); aRoof.RoofModules = listOfRoofModules; } //roofReader.Close(); } #endregion aTransaction.Commit(); hidJsonObjects.Value = JsonConvert.SerializeObject(listOfWalls); } catch (Exception ex) { //lblError.Text = "Commit Exception Type: " + ex.GetType(); //lblError.Text += " Message: " + ex.Message; // Attempt to roll back the transaction. try { aTransaction.Rollback(); } catch (Exception ex2) { //This catch block will handle any errors that may have occurred //on the server that would cause the rollback to fail, such as //a closed connection. //lblError.Text = "Rollback Exception Type: " + ex2.GetType(); //lblError.Text += " Message: " + ex2.Message; } } } #endregion hidJsonObjects.Value = JsonConvert.SerializeObject(listOfWalls); PopulateDropdown(floorCount, roofCount); PopulateModOptions(); //lnkUpdateSunroom.Attributes.Add("onclick", "updateSunroom()"); //lnkSubmitSunroom.Attributes.Add("onclick", "submitSunroom()"); //lnkEditorNavMods.Attributes.Add("onclick", "$('.overlayContainer').slideToggle()"); //lnkEditorNavTools.Attributes.Add("onclick", "$('#saveButtons').fadeToggle(); $('.btnTools').slideToggle();"); lnkEditorNavSave.Attributes.Add("onclick", "updateSunroom()"); lnkEditorNavUndo.Attributes.Add("onclick", "undo()"); lnkEditorNavRedo.Attributes.Add("onclick", "redo()"); //Add list of all objects to session, for use by other pages accessed through project editor try { Session.Add("listOfWalls", listOfWalls); } catch (Exception ex) { Session["listOfWalls"] = listOfWalls; } }
//protected int project_id = Session["newProjectProjectID"]; protected void Page_Load(object sender, EventArgs e) { List<Wall> aListOfWalls = new List<Wall>(); int project_id = 10; string project_type; string installation_type; string project_name; int wallCount; int wall_index; string wall_type; string model_type; float wall_length; string orientation; float set_back; string name; int first_item_index; int last_item_index; float wall_start_height; float wall_end_height; float soffit_length; float gable_peak; int obstructions; bool fire_protection; int linear_index = 0; string linear_type; float linear_start_height; float linear_end_height; float linear_length; string frame_colour; string sex; float fixed_location; bool attached_to; int module_index; string item_type; float module_start_height; float module_end_height; float module_length; #region hardcode population //This info will all come from the database eventually //List<Wall> aListOfWalls = new List<Wall>(); float backwall = 150.0f; float frontwall = 140.0f; float slope = 0.6f; string projectName = "Joey's Super Fantastic Sunroom"; string modelType = "M200"; string roofStyle = "Studio"; bool cutPitch = true; string installType = "trailer"; string framingColour = "Driftwood"; string interiorColour = "Driftwood"; string exteriorColour = "Driftwood"; string interiorSkin = "Driftwood Aluminum Stucco"; string exteriorSkin = "Driftwood Aluminum Stucco"; Wall firstWall = new Wall(); firstWall.Length = 200; firstWall.Orientation = "WEST"; firstWall.Name = "Wall 1"; firstWall.WallType = "Proposed"; firstWall.ModelType = "M200"; firstWall.StartHeight = 150; firstWall.EndHeight = 140; firstWall.SoffitLength = 0; firstWall.GablePeak = 0; firstWall.SoffitLength = 0; Wall secondWall = new Wall(); secondWall.Length = 200; secondWall.Orientation = "SOUTH"; secondWall.Name = "Wall 2"; secondWall.WallType = "Proposed"; secondWall.ModelType = "M200"; secondWall.StartHeight = 140; secondWall.EndHeight = 140; secondWall.SoffitLength = 0; secondWall.GablePeak = 0; secondWall.SoffitLength = 0; Wall thirdWall = new Wall(); thirdWall.Length = 200; thirdWall.Orientation = "EAST"; thirdWall.Name = "Wall 3"; thirdWall.WallType = "Proposed"; thirdWall.ModelType = "M200"; thirdWall.StartHeight = 140; thirdWall.EndHeight = 150; thirdWall.SoffitLength = 0; thirdWall.GablePeak = 0; thirdWall.SoffitLength = 0; aListOfWalls.Add(firstWall); aListOfWalls.Add(secondWall); aListOfWalls.Add(thirdWall); #endregion //hardcode population #region dynamic accordion population #region Project Wide accordion.Controls.Add(new LiteralControl("<h2>Project Wide Settings</h2>")); accordion.Controls.Add(new LiteralControl("<ul>")); #region Tag Name accordion.Controls.Add(new LiteralControl("<li>")); Label tagName = new Label(); tagName.ID = "lblTagName"; tagName.Text = "Tag Name: "; accordion.Controls.Add(tagName); TextBox tagNameTextBox = new TextBox(); tagNameTextBox.ID = "txtTagName"; tagNameTextBox.Text = projectName.ToString(); tagNameTextBox.CssClass = "txtField txtInput"; tagNameTextBox.Attributes.Add("onkeydown", "return (event.keyCode!=13);"); tagNameTextBox.Attributes.Add("runat", "server"); accordion.Controls.Add(tagNameTextBox); accordion.Controls.Add(new LiteralControl("</li>")); #endregion //tag name #region Model Type accordion.Controls.Add(new LiteralControl("<li>")); Label modelLabel = new Label(); modelLabel.ID = "lblModelLabel"; modelLabel.Text = "Model Type: "; accordion.Controls.Add(modelLabel); DropDownList modelDropDown = new DropDownList(); modelDropDown.ID = "ddlModel"; for (int i = 0; i < modelNumbers.Length; i++) { modelDropDown.Items.Add(modelNumbers[i].ToString()); } modelDropDown.SelectedValue = modelType; modelDropDown.Attributes.Add("runat", "server"); accordion.Controls.Add(modelDropDown); accordion.Controls.Add(new LiteralControl("</li>")); #endregion //model type #region Roof Style accordion.Controls.Add(new LiteralControl("<li>")); Label styleLabel = new Label(); styleLabel.ID = "lblStyleLabel"; styleLabel.Text = "Roof Style: "; accordion.Controls.Add(styleLabel); DropDownList styleDropDown = new DropDownList(); styleDropDown.ID = "ddlStyle"; for (int i = 0; i < roofTypes.Length; i++) { styleDropDown.Items.Add(roofTypes[i].ToString()); } styleDropDown.SelectedValue = roofStyle; styleDropDown.Attributes.Add("runat", "server"); accordion.Controls.Add(styleDropDown); accordion.Controls.Add(new LiteralControl("</li>")); #endregion //roof style #region Cut Pitch accordion.Controls.Add(new LiteralControl("<li>")); Label firstCutPitchLabel = new Label(); firstCutPitchLabel.ID = "lblFirstCutPitch"; firstCutPitchLabel.Text = "Cut Pitch"; accordion.Controls.Add(firstCutPitchLabel); CheckBox cutPitchCheckBox = new CheckBox(); cutPitchCheckBox.ID = "chkCutPitch"; cutPitchCheckBox.Checked = cutPitch; cutPitchCheckBox.Text = " "; cutPitchCheckBox.Attributes.Add("runat", "server"); accordion.Controls.Add(cutPitchCheckBox); Label secondCutPitchLabel = new Label(); secondCutPitchLabel.ID = "lblSecondCutPitch"; secondCutPitchLabel.AssociatedControlID = "chkCutPitch"; secondCutPitchLabel.Attributes.Add("runat", "server"); accordion.Controls.Add(secondCutPitchLabel); accordion.Controls.Add(new LiteralControl("</li>")); #endregion //cut pitch #region Install Type if (installType != "standAlone") { accordion.Controls.Add(new LiteralControl("<li>")); accordion.Controls.Add(new LiteralControl("<br/>")); Label installLabel = new Label(); installLabel.ID = "lblInstall"; installLabel.Text = "Install Type"; accordion.Controls.Add(installLabel); accordion.Controls.Add(new LiteralControl("<br/>")); RadioButton installHouseRadio = new RadioButton(); installHouseRadio.ID = "radInstallHouse"; installHouseRadio.Attributes.Add("runat", "server"); installHouseRadio.GroupName = "InstallType"; installHouseRadio.Text = " "; accordion.Controls.Add(installHouseRadio); Label firstInstallLabel = new Label(); firstInstallLabel.ID = "lblFirstInstallLabel"; firstInstallLabel.AssociatedControlID = "radInstallHouse"; accordion.Controls.Add(firstInstallLabel); Label secondInstallLabel = new Label(); secondInstallLabel.ID = "lblSecondInstallLabel"; secondInstallLabel.AssociatedControlID = "radInstallHouse"; secondInstallLabel.Text = "House"; accordion.Controls.Add(secondInstallLabel); accordion.Controls.Add(new LiteralControl("<br/>")); RadioButton installTrailerRadio = new RadioButton(); installTrailerRadio.ID = "radInstallTrailer"; installTrailerRadio.Attributes.Add("runat", "server"); installTrailerRadio.GroupName = "InstallType"; installTrailerRadio.Text = " "; accordion.Controls.Add(installTrailerRadio); Label thirdInstallLabel = new Label(); thirdInstallLabel.ID = "lblThirdInstallLabel"; thirdInstallLabel.AssociatedControlID = "radInstallTrailer"; accordion.Controls.Add(thirdInstallLabel); Label fourthInstallLabel = new Label(); fourthInstallLabel.ID = "lblFourthInstallLabel"; fourthInstallLabel.AssociatedControlID = "radInstallHouse"; fourthInstallLabel.Text = "Trailer"; accordion.Controls.Add(fourthInstallLabel); accordion.Controls.Add(new LiteralControl("</li>")); accordion.Controls.Add(new LiteralControl("</ul>")); if (installType == "house") { installHouseRadio.Checked = true; } else if (installType == "trailer") { installTrailerRadio.Checked = true; } } #endregion //Install Type #region Framing Colours accordion.Controls.Add(new LiteralControl("<li>")); Label coloursTitleLabel = new Label(); coloursTitleLabel.ID = "lblWallColours"; coloursTitleLabel.Text = "Framing and Wall Colours"; accordion.Controls.Add(coloursTitleLabel); accordion.Controls.Add(new LiteralControl("<br/>")); Label framingColourLabel = new Label(); framingColourLabel.ID = "lblFramingColour"; framingColourLabel.Text = "Framing Colour: "; accordion.Controls.Add(framingColourLabel); DropDownList framingColoursDropDown = new DropDownList(); framingColoursDropDown.ID = "ddlFramingColours"; framingColoursDropDown.Attributes.Add("runat", "server"); if (modelType == "M100") { for (int i = 0; i < model100FramingColours.Length; i++) { framingColoursDropDown.Items.Add(model100FramingColours[i].ToString()); } } else if (modelType == "M200") { for (int i = 0; i < model200FramingColours.Length; i++) { framingColoursDropDown.Items.Add(model200FramingColours[i].ToString()); } } else if (modelType == "M300") { for (int i = 0; i < model300FramingColours.Length; i++) { framingColoursDropDown.Items.Add(model300FramingColours[i].ToString()); } } else { for (int i = 0; i < model400FramingColours.Length; i++) { framingColoursDropDown.Items.Add(model400FramingColours[i].ToString()); } } framingColoursDropDown.SelectedValue = framingColour; accordion.Controls.Add(framingColoursDropDown); accordion.Controls.Add(new LiteralControl("</li>")); #endregion #region Wall Colours accordion.Controls.Add(new LiteralControl("<li>")); Label wallColoursInteriorLabel = new Label(); wallColoursInteriorLabel.ID = "lblWallColoursInterior"; wallColoursInteriorLabel.Text = "Interior Colour: "; accordion.Controls.Add(wallColoursInteriorLabel); DropDownList wallColoursInteriorDropDown = new DropDownList(); wallColoursInteriorDropDown.ID = "ddlWallColoursInterior"; wallColoursInteriorDropDown.Attributes.Add("runat", "server"); for (int i = 0; i < interiorWallColours.Length; i++) { wallColoursInteriorDropDown.Items.Add(interiorWallColours[i].ToString()); } wallColoursInteriorDropDown.SelectedValue = interiorColour; accordion.Controls.Add(wallColoursInteriorDropDown); accordion.Controls.Add(new LiteralControl("<br/>")); Label wallColoursExteriorLabel = new Label(); wallColoursExteriorLabel.ID = "lblWallColoursExterior"; wallColoursExteriorLabel.Text = "Exterior Colour: "; accordion.Controls.Add(wallColoursExteriorLabel); DropDownList wallColoursExteriorDropDown = new DropDownList(); wallColoursExteriorDropDown.ID = "ddlWallColoursExterior"; wallColoursExteriorDropDown.Attributes.Add("runat", "server"); for (int i = 0; i < exteriorWallColours.Length; i++) { wallColoursExteriorDropDown.Items.Add(exteriorWallColours[i].ToString()); } wallColoursExteriorDropDown.SelectedValue = exteriorColour; accordion.Controls.Add(wallColoursExteriorDropDown); accordion.Controls.Add(new LiteralControl("</li>")); #endregion #region Wall Textures accordion.Controls.Add(new LiteralControl("<li>")); Label wallTextureTitleLabel = new Label(); wallTextureTitleLabel.ID = "lblWallTexture"; wallTextureTitleLabel.Text = "Skin Types"; accordion.Controls.Add(wallTextureTitleLabel); accordion.Controls.Add(new LiteralControl("<br/>")); Label wallTextureInteriorLabel = new Label(); wallTextureInteriorLabel.ID = "lblWallTextureInterior"; wallTextureInteriorLabel.Text = "Interior: "; accordion.Controls.Add(wallTextureInteriorLabel); DropDownList wallTextureInteriorDropDown = new DropDownList(); wallTextureInteriorDropDown.ID = "ddlWallTextureInterior"; wallTextureInteriorDropDown.Attributes.Add("runat", "server"); for (int i = 0; i < interiorWallSkinTypes.Length; i++) { wallTextureInteriorDropDown.Items.Add(interiorWallSkinTypes[i].ToString()); } wallTextureInteriorDropDown.SelectedValue = interiorSkin; accordion.Controls.Add(wallTextureInteriorDropDown); accordion.Controls.Add(new LiteralControl("<br/>")); Label wallTextureExteriorLabel = new Label(); wallTextureExteriorLabel.ID = "lblWallTextureExterior"; wallTextureExteriorLabel.Text = "Exterior: "; accordion.Controls.Add(wallTextureExteriorLabel); DropDownList wallTextureExteriorDropDown = new DropDownList(); wallTextureExteriorDropDown.ID = "ddlWallTextureExterior"; wallTextureExteriorDropDown.Attributes.Add("runat", "server"); for (int i = 0; i < exteriorWallSkinTypes.Length; i++) { wallTextureExteriorDropDown.Items.Add(exteriorWallSkinTypes[i].ToString()); } wallTextureExteriorDropDown.SelectedValue = exteriorSkin; accordion.Controls.Add(wallTextureExteriorDropDown); accordion.Controls.Add(new LiteralControl("</li>")); #endregion #endregion //Project Wide #region Wall Height Entry accordion.Controls.Add(new LiteralControl("<h2>Wall Heights</h2>")); accordion.Controls.Add(new LiteralControl("<ul>")); #region BackWall Height string[] backHeight = firstWall.StartHeight.ToString().Split('.'); accordion.Controls.Add(new LiteralControl("<li>")); Label backwallHeight = new Label(); backwallHeight.ID = "lblBackwall"; backwallHeight.Text = "Back Wall Height: "; accordion.Controls.Add(backwallHeight); TextBox backwallTextBox = new TextBox(); backwallTextBox.ID = "txtBackwall"; backwallTextBox.Text = backHeight[0]; backwallTextBox.CssClass = "txtField txtInput"; backwallTextBox.Attributes.Add("onkeydown", "return (event.keyCode!=13);"); backwallTextBox.Attributes.Add("runat", "server"); accordion.Controls.Add(backwallTextBox); DropDownList backwallFractions = new DropDownList(); backwallFractions.ID = "ddlBackwallFractions"; fractionList = GlobalFunctions.FractionOptions("." + backHeight[1]); for (int i = 0; i < fractionList.Count; i++) { backwallFractions.Items.Add(fractionList[i]); } backwallFractions.Attributes.Add("runat", "server"); accordion.Controls.Add(backwallFractions); accordion.Controls.Add(new LiteralControl("</li>")); #endregion //backwall height #region FrontWall Height string[] frontHeight = firstWall.EndHeight.ToString().Split('.'); accordion.Controls.Add(new LiteralControl("<li>")); Label frontwallHeight = new Label(); frontwallHeight.ID = "lblFrontwall"; frontwallHeight.Text = "Front Wall Height: "; accordion.Controls.Add(frontwallHeight); TextBox frontwallTextBox = new TextBox(); frontwallTextBox.ID = "txtFrontwall"; frontwallTextBox.Text = frontHeight[0]; frontwallTextBox.CssClass = "txtField txtInput"; frontwallTextBox.Attributes.Add("onkeydown", "return (event.keyCode!=13);"); frontwallTextBox.Attributes.Add("runat", "server"); accordion.Controls.Add(frontwallTextBox); DropDownList frontwallFractions = new DropDownList(); frontwallFractions.ID = "ddlFrontwallFractions"; fractionList = GlobalFunctions.FractionOptions("." + frontHeight[1]); for (int i = 0; i < fractionList.Count; i++) { frontwallFractions.Items.Add(fractionList[i]); } frontwallFractions.Attributes.Add("runat", "server"); accordion.Controls.Add(frontwallFractions); accordion.Controls.Add(new LiteralControl("</li>")); #endregion //frontwall height #region Slope //rise = parseFloat(backWallHeight) - parseFloat(frontWallHeight); //return ((rise / (roomProjection - soffitLength)) * 12).toFixed(2); //slope over 12, rounded to 2 decimal places accordion.Controls.Add(new LiteralControl("<li>")); Label slopeLabel = new Label(); slopeLabel.ID = "lblSlope"; slopeLabel.Text = "Slope: "; accordion.Controls.Add(slopeLabel); TextBox slopeTextBox = new TextBox(); slopeTextBox.ID = "txtSlope"; slopeTextBox.Text = slope.ToString(); slopeTextBox.CssClass = "txtField txtInput"; slopeTextBox.Attributes.Add("onkeydown", "return (event.keyCode!=13);"); slopeTextBox.Attributes.Add("runat", "server"); accordion.Controls.Add(slopeTextBox); Label overTwelve = new Label(); overTwelve.ID = "lblOverTwelve"; overTwelve.Text = " / 12"; accordion.Controls.Add(overTwelve); accordion.Controls.Add(new LiteralControl("</li>")); #endregion //slope accordion.Controls.Add(new LiteralControl("</ul>")); #endregion //wall height entry #region Wall Width Entry accordion.Controls.Add(new LiteralControl("<ul class=\"toggleOptions\">")); accordion.Controls.Add(new LiteralControl("<h2>Wall Widths</h2>")); for (int i = 0; i < aListOfWalls.Count; i++) { //accordion.Controls.Add(new LiteralControl("<li onclick=alert("+(i+1)+");>")); accordion.Controls.Add(new LiteralControl("<li onclick=drawWall(document.getElementById('MainContent_txtWidth" + (i + 1) + "').value,document.getElementById('MainContent_lblStartHeightDisplay" + (i + 1) + "').innerHTML,document.getElementById('MainContent_lblEndHeightDisplay" + (i + 1) + "').innerHTML," + (i + 1) + ");>")); Label accordionLabel = new Label(); accordionLabel.ID = "lblWall" + (i + 1) + "Label"; accordionLabel.Text = aListOfWalls[i].Name; accordion.Controls.Add(accordionLabel); accordion.Controls.Add(new LiteralControl("<div class=\"toggleContent\"><ul>")); #region Wall Length accordion.Controls.Add(new LiteralControl("<li>")); Label width = new Label(); width.ID = "lblWidth" + (i + 1); width.Text = "Width: "; accordion.Controls.Add(width); TextBox widthTextBox = new TextBox(); widthTextBox.ID = "txtWidth" + (i + 1); widthTextBox.Text = aListOfWalls[i].Length.ToString(); widthTextBox.CssClass = "txtField txtInput"; widthTextBox.Attributes.Add("onkeydown", "return (event.keyCode!=13);"); widthTextBox.Attributes.Add("runat", "server"); accordion.Controls.Add(widthTextBox); DropDownList widthFractions = new DropDownList(); widthFractions.ID = "ddlWall" + (i + 1) + "Fractions"; for (int j = 0; j < fractionList.Count; j++) { widthFractions.Items.Add(fractionList[j]); } widthFractions.Attributes.Add("runat", "server"); accordion.Controls.Add(widthFractions); accordion.Controls.Add(new LiteralControl("</li>")); #endregion //wall length #region Wall StartHeight accordion.Controls.Add(new LiteralControl("<li>")); Label startHeight = new Label(); startHeight.ID = "lblStartHeight" + (i + 1); startHeight.Text = "Start Height: "; accordion.Controls.Add(startHeight); Label startHeightDisplay = new Label(); startHeightDisplay.ID = "lblStartHeightDisplay" + (i + 1); startHeightDisplay.Text = aListOfWalls[i].StartHeight.ToString(); startHeightDisplay.Attributes.Add("runat", "server"); accordion.Controls.Add(startHeightDisplay); accordion.Controls.Add(new LiteralControl("</li>")); #endregion //wall start height #region Wall EndHeight accordion.Controls.Add(new LiteralControl("<li>")); Label endHeight = new Label(); endHeight.ID = "lblEndHeight" + (i + 1); endHeight.Text = "End Height: "; accordion.Controls.Add(endHeight); Label endHeightDisplay = new Label(); endHeightDisplay.ID = "lblEndHeightDisplay" + (i + 1); endHeightDisplay.Text = aListOfWalls[i].EndHeight.ToString(); endHeightDisplay.Attributes.Add("runat", "server"); accordion.Controls.Add(endHeightDisplay); accordion.Controls.Add(new LiteralControl("</li>")); #endregion //wall endheight accordion.Controls.Add(new LiteralControl("</ul></div></li>")); } accordion.Controls.Add(new LiteralControl("</ul>")); #endregion //wall width entry #endregion //dynamic accordion population }
//Wall aWall public static float PriceWall(Wall aWall) { float wallPrice = 0.0f; int sunroomModel = 100; switch(sunroomModel){ case 100: //Screen only wallPrice += PriceModel100Wall(aWall); break; case 200: //2-4 page in MSRP wallPrice += PriceModel200Wall(aWall); break; case 300: //3-4 page in MSRP wallPrice += PriceModel300Wall(aWall); break; case 400: //V4T break; } return wallPrice; }
public static float PriceModel100Wall(Wall aWall) { float wallPrice = 0.0f; int numberOfDoors = 0; float lengthOfMods = 0.0f; float lengthOfSolidWall = 0.0f; float lengthOfOpen = 0.0f; List<LinearItem> listOfMods = (List<LinearItem>)aWall.LinearItems; //Loop through linear items foreach (LinearItem aLinearItem in listOfMods) { //Linear item is a mdo if (aLinearItem.ItemType == "Mod") { //Cast linear item as a mod Mod aMod = (Mod)aLinearItem; //Mod is a door if (aMod.ModType == "Door") { Door aDoor = (Door)aMod.ModularItems[0]; //Non door add linear length to lengthOfOpen if (aDoor.DoorType == "NoDoor") { lengthOfOpen += aLinearItem.Length; } else { numberOfDoors++; lengthOfMods += aLinearItem.Length; } } //Mod is a window else if (aMod.ModType == "Window") { Kneewall aKneewall = (Kneewall)aMod.ModularItems[0]; //Kneewall Window aWindow = (Window)aMod.ModularItems[1]; if (aKneewall.FLength > 20) { //Add pricing for custom kneewall height } else { } if (aWindow.ScreenType == "No See Ums 20 x 20 Mesh") { wallPrice += PricingConstants.MODEL_100_NO_SEE_UMS_FIBERGLASS_20_X_20_MESH * aLinearItem.Length; } else if (aWindow.ScreenType == "Solar Insect Screening") { wallPrice += PricingConstants.MODEL_100_SOLAR_INSECT_SCREENING * aLinearItem.Length; } else if (aWindow.ScreenType == "Tuff Screen") { wallPrice += PricingConstants.MODEL_100_TUFF_SCREEN * aLinearItem.Length; } } else if (aMod.ModType == "Open" && aLinearItem.Length >= 8) { lengthOfOpen += aLinearItem.Length; } else { lengthOfMods += aLinearItem.Length; } } else //Check to see if everything else other than mods are included { if (aLinearItem.Length >= 8) { lengthOfSolidWall += aLinearItem.Length; lengthOfMods -= aLinearItem.Length; } } } //Set price based on number of doors in the sunroom switch (numberOfDoors) { case 1: wallPrice += PricingConstants.MODEL_100_SCREEN_OPENING_1_SCREEN_DOOR * lengthOfMods; break; case 2: wallPrice += PricingConstants.MODEL_100_SCREEN_OPENING_2_SCREEN_DOORS * lengthOfMods; break; case 3: wallPrice += PricingConstants.MODEL_100_SCREEN_OPENING_3_SCREEN_DOORS * lengthOfMods; break; } //Add solid wall pricing wallPrice += PricingConstants.MODEL_100_SOLID_WALL_PANEL * lengthOfSolidWall; //Find wall height and set appropriate pricing if ((aWall.EndHeight > 96 && aWall.EndHeight < 120) || (aWall.StartHeight > 96 && aWall.StartHeight < 120)) { wallPrice += PricingConstants.MODEL_100_NON_STANDARD_PANEL_HEIGHTS * aWall.Length; } else if (aWall.EndHeight >= 120 || aWall.StartHeight >= 120) { wallPrice += PricingConstants.MODEL_100_NON_STANDARD_PANEL_HEIGHTS_HIGHER * aWall.Length; } //Add pricing for fire protection if (aWall.FireProtection == true) { wallPrice += PricingConstants.MODEL_100_FP_SCREEN_OPENINGS_INCLUDES_1_SCREEN_DOOR * lengthOfMods; wallPrice += PricingConstants.MODEL_100_FP_SOLID_WALL_PANEL * lengthOfSolidWall; } return wallPrice; }
//Find the price for a Model 300 wall /****NEEDS REVIEWING, NOT COMPLETE****/ public static float PriceModel300Wall(Wall aWall) { float wallPrice = 0.0f; float lengthOfStandard = 0.0f; float lengthOfSolidWall = 0.0f; float lengthOfOpen = 0.0f; float lengthOfFixedVinyl = 0.0f; List<LinearItem> listOfMods = (List<LinearItem>)aWall.LinearItems; if (aWall.Orientation != "N" && aWall.Orientation != "S" && aWall.Orientation != "E" && aWall.Orientation != "W") { wallPrice = PricingConstants.MODEL_300_45_DEGREE_WALLS; } //Loop through linear items foreach (LinearItem aLinearItem in listOfMods) { //Linear item is a mod if (aLinearItem.ItemType == "Mod") { //Cast linear item as a mod Mod aMod = (Mod)aLinearItem; //Mod is a door if (aMod.ModType == "Door") { Door aDoor = (Door)aMod.ModularItems[0]; //Non door add linear length to lengthOfOpen if (aDoor.DoorType == "Vertical Four Track") { lengthOfStandard += aLinearItem.Length; } else if (aDoor.DoorType == "NoDoor") { lengthOfOpen += aLinearItem.Length; } else { lengthOfStandard += aLinearItem.Length; } } //Mod is a window else if (aMod.ModType == "Window") { Kneewall aKneewall = (Kneewall)aMod.ModularItems[0]; //Kneewall Window aWindow = (Window)aMod.ModularItems[0]; if (aKneewall.FLength > 20) { //Add pricing for custom kneewall height } else { } //Add length for fixed vinyl if (aWindow.WindowStyle.Contains("Fixed")) //Possibilities: Fixed Vinyl, Fixed Glass 2", Fixed Glass 3" { lengthOfFixedVinyl += aLinearItem.Length; } } else if (aMod.ModType == "Open" && aLinearItem.Length >= 8) { lengthOfOpen += aLinearItem.Length; } else { lengthOfStandard += aLinearItem.Length; } } else //Check to see if everything else other than mods are included { if (aLinearItem.Length >= 8) { lengthOfSolidWall += aLinearItem.Length; lengthOfStandard -= aLinearItem.Length; } } } //Add various wall pricing types to wall price based on length wallPrice += PricingConstants.MODEL_300_VINYL_HORIZONTAL_ROLLER_WINDOW * lengthOfStandard; wallPrice += PricingConstants.MODEL_300_SOLID_WALL_PANEL * lengthOfSolidWall; wallPrice += PricingConstants.MODEL_300_MANUFACTURED_OPEN_WALLS * lengthOfOpen; wallPrice += PricingConstants.MODEL_300_FIXED_WINDOWS * lengthOfFixedVinyl; //Find wall height and set appropriate pricing if ((aWall.EndHeight > 96 && aWall.EndHeight < 120) || (aWall.StartHeight > 96 && aWall.StartHeight < 120)) { wallPrice += PricingConstants.MODEL_300_NON_STANDARD_PANEL_HEIGHTS * aWall.Length; } else if (aWall.EndHeight >= 120 || aWall.StartHeight >= 120) { wallPrice += PricingConstants.MODEL_300_NON_STANDARD_PANEL_HEIGHTS_HIGHER * aWall.Length; } //Add pricing for fire protection if (aWall.FireProtection == true) { wallPrice += PricingConstants.MODEL_300_FP_HORIZONTAL_ROLLER * lengthOfStandard; wallPrice += PricingConstants.MODEL_300_FP_MANUFACTURED_OPEN_WALLS * lengthOfOpen; wallPrice += PricingConstants.MODEL_300_FP_SOLID_WALL_PANEL * lengthOfSolidWall; wallPrice += PricingConstants.MODEL_300_FP_FIXED_WINDOWS * lengthOfFixedVinyl; } return wallPrice; }
//Sunroom aSunroom public static float PriceSunroom() { Wall aWall = new Wall(); int sunroomModel = 100; float sunroomPrice = 0.0f; int numberOfWalls = 4; for (int i = 0; i < numberOfWalls; i++) { sunroomPrice += PriceWall(aWall); } switch (sunroomModel) { case 100: break; case 200: //Price entry doors for model 200 sunroomPrice += PriceModel200EntryDoors(); break; case 300: break; case 400: break; } return sunroomPrice; }
//Find the price for a Model 200 wall public static float PriceModel200Wall(Wall aWall) { float wallPrice = 0.0f; float lengthOfStandard = 0.0f; float lengthOfSolidWall = 0.0f; float lengthOfOpen = 0.0f; float lengthOfFixedVinyl = 0.0f; List<LinearItem> listOfMods = (List<LinearItem>)aWall.LinearItems; if (aWall.Orientation != "N" && aWall.Orientation != "S" && aWall.Orientation != "E" && aWall.Orientation != "W") { wallPrice = PricingConstants.MODEL_200_45_DEGREE_WALLS; } //Loop through linear items foreach (LinearItem aLinearItem in listOfMods) { if (aLinearItem.ItemType == "Electrical Chase") { wallPrice += PricingConstants.MODEL_200_VERTICAL_ELECTRICAL_CHASE; } //Linear item is a mod else if (aLinearItem.ItemType == "Mod") { /****************************************** * NEED SOMETHING FOR PRICING TRANSOMS * * NEED SOMETHING FOR MISCELLANEOUS ITEMS * * ****************************************/ //Cast linear item as a mod Mod aMod = (Mod)aLinearItem; //Mod is a door if (aMod.ModType == "Door") { Door aDoor = (Door)aMod.ModularItems[0]; //Non door add linear length to lengthOfOpen if (aDoor.DoorType == "Patio") { numberOfPatioDoors++; //Cast the window within the door to a window object Window aDoorWindow = aDoor.DoorWindow; //Must be a glass window if (aDoorWindow.WindowStyle.Contains("Glass") || aDoorWindow.WindowStyle == "Single Slider" || aDoorWindow.WindowStyle == "Horizontal Roller") { //Cast window item to vinyl window item VinylWindow aVinylDoorWindow = (VinylWindow)aDoorWindow; //If glass window tint is grey or bronze, additional pricing occurs if (aVinylDoorWindow.VinylTint.Contains("Grey") || aVinylDoorWindow.VinylTint.Contains("Bronze")){ wallPrice += PricingConstants.MODEL_200_TINTED_GLASS_IN_PATIO_DOOR; } } } else if (aDoor.DoorType == "NoDoor") { //Add length to open door length lengthOfOpen += aLinearItem.Length; } else { //Add length to standard pricing lengthOfStandard += aLinearItem.Length; } /************************************** * BLOCK TO HANDLE ENTRY DOOR PRICING * * ************************************/ if (aDoor.DoorStyle == "Vertical Four Track" && aDoor.DoorType != "French") { //Add length to standard pricing lengthOfStandard += aLinearItem.Length; numberOfV4TDoors++; } else if (aDoor.DoorStyle == "Vertical Four Track" && aDoor.DoorType == "French") { //Add length to standard pricing lengthOfStandard += aLinearItem.Length; numberOfV4TFrenchDoors++; } if (aDoor.DoorStyle == "Full View" && aDoor.DoorType != "French") { numberOfFullViewDoors++; } else if (aDoor.DoorStyle == "Full View" && aDoor.DoorType == "French") { numberOfFullViewFrenchDoors++; } if (aDoor.DoorStyle == "Full View Colonial" && aDoor.DoorType != "French") { numberOfFullViewColonialDoors++; } else if (aDoor.DoorStyle == "Full View Colonial" && aDoor.DoorType == "French") { numberOfFullViewColonialFrenchDoors++; } } //Mod is a window else if (aMod.ModType == "Window") { Kneewall aKneewall = (Kneewall)aMod.ModularItems[0]; //Kneewall Window aWindow = (Window)aMod.ModularItems[1]; if (aKneewall.FLength > 20) { //Add pricing for custom kneewall height } else { } //Add length for fixed vinyl if (aWindow.WindowStyle.Contains("Fixed")) //Possibilities: Fixed Vinyl, Fixed Glass 2", Fixed Glass 3" { lengthOfFixedVinyl += aLinearItem.Length; } if (aWindow.ScreenType == "No See Ums 20 x 20 Mesh") { wallPrice += PricingConstants.MODEL_200_NO_SEE_UMS * aLinearItem.Length; } else if (aWindow.ScreenType == "Solar Insect Screening") { wallPrice += PricingConstants.MODEL_200_SOLAR_INSECT_SCREENING * aLinearItem.Length; } else if (aWindow.ScreenType == "Tuff Screen") { wallPrice += PricingConstants.MODEL_200_TUFF_SCREEN * aLinearItem.Length; } } else if (aMod.ModType == "Open" && aLinearItem.Length >= 8) { lengthOfOpen += aLinearItem.Length; } else { lengthOfStandard += aLinearItem.Length; } } else //Check to see if everything else other than mods are included { if (aLinearItem.Length >= 8) { lengthOfSolidWall += aLinearItem.Length; lengthOfStandard -= aLinearItem.Length; } } } //Add various wall pricing types to wall price based on length wallPrice += PricingConstants.MODEL_200_VINYL_HORIZONTAL_ROLLER * lengthOfStandard; wallPrice += PricingConstants.MODEL_200_SOLID_WALL_PANEL * lengthOfSolidWall; wallPrice += PricingConstants.MODEL_200_MANUFACTURED_OPEN_WALLS * lengthOfOpen; wallPrice += PricingConstants.MODEL_200_FIXED_VINYL_WALL * lengthOfFixedVinyl; //Find wall height and set appropriate pricing if ((aWall.EndHeight > 96 && aWall.EndHeight < 120) || (aWall.StartHeight > 96 && aWall.StartHeight < 120)) { wallPrice += PricingConstants.MODEL_200_NON_STANDARD_PANEL_HEIGHTS * aWall.Length; } else if (aWall.EndHeight >= 120 || aWall.StartHeight >= 120) { wallPrice += PricingConstants.MODEL_200_NON_STANDARD_PANEL_HEIGHTS_HIGHER * aWall.Length; } //Add pricing for fire protection if (aWall.FireProtection == true) { wallPrice += PricingConstants.MODEL_200_FP_HORIZONTAL_ROLLER * lengthOfStandard; wallPrice += PricingConstants.MODEL_200_FP_MANUFACTURED_OPEN_WALLS * lengthOfOpen; wallPrice += PricingConstants.MODEL_200_FP_SOLID_WALL_PANEL * lengthOfSolidWall; wallPrice += PricingConstants.MODEL_200_FP_FIXED_VINYL_WALL * lengthOfFixedVinyl; } return wallPrice; }
public static float PriceModel100Wall(Wall aWall) { float wallPrice = 0.0f; int numberOfDoors = 0; float lengthOfMods = 0.0f; float lengthOfSolidWall = 0.0f; float lengthOfOpen = 0.0f; List <LinearItem> listOfMods = (List <LinearItem>)aWall.LinearItems; //Loop through linear items foreach (LinearItem aLinearItem in listOfMods) { //Linear item is a mdo if (aLinearItem.ItemType == "Mod") { //Cast linear item as a mod Mod aMod = (Mod)aLinearItem; //Mod is a door if (aMod.ModType == "Door") { Door aDoor = (Door)aMod.ModularItems[0]; //Non door add linear length to lengthOfOpen if (aDoor.DoorType == "NoDoor") { lengthOfOpen += aLinearItem.Length; } else { numberOfDoors++; lengthOfMods += aLinearItem.Length; } } //Mod is a window else if (aMod.ModType == "Window") { Kneewall aKneewall = (Kneewall)aMod.ModularItems[0]; //Kneewall Window aWindow = (Window)aMod.ModularItems[1]; if (aKneewall.FLength > 20) { //Add pricing for custom kneewall height } else { } if (aWindow.ScreenType == "No See Ums 20 x 20 Mesh") { wallPrice += PricingConstants.MODEL_100_NO_SEE_UMS_FIBERGLASS_20_X_20_MESH * aLinearItem.Length; } else if (aWindow.ScreenType == "Solar Insect Screening") { wallPrice += PricingConstants.MODEL_100_SOLAR_INSECT_SCREENING * aLinearItem.Length; } else if (aWindow.ScreenType == "Tuff Screen") { wallPrice += PricingConstants.MODEL_100_TUFF_SCREEN * aLinearItem.Length; } } else if (aMod.ModType == "Open" && aLinearItem.Length >= 8) { lengthOfOpen += aLinearItem.Length; } else { lengthOfMods += aLinearItem.Length; } } else //Check to see if everything else other than mods are included { if (aLinearItem.Length >= 8) { lengthOfSolidWall += aLinearItem.Length; lengthOfMods -= aLinearItem.Length; } } } //Set price based on number of doors in the sunroom switch (numberOfDoors) { case 1: wallPrice += PricingConstants.MODEL_100_SCREEN_OPENING_1_SCREEN_DOOR * lengthOfMods; break; case 2: wallPrice += PricingConstants.MODEL_100_SCREEN_OPENING_2_SCREEN_DOORS * lengthOfMods; break; case 3: wallPrice += PricingConstants.MODEL_100_SCREEN_OPENING_3_SCREEN_DOORS * lengthOfMods; break; } //Add solid wall pricing wallPrice += PricingConstants.MODEL_100_SOLID_WALL_PANEL * lengthOfSolidWall; //Find wall height and set appropriate pricing if ((aWall.EndHeight > 96 && aWall.EndHeight < 120) || (aWall.StartHeight > 96 && aWall.StartHeight < 120)) { wallPrice += PricingConstants.MODEL_100_NON_STANDARD_PANEL_HEIGHTS * aWall.Length; } else if (aWall.EndHeight >= 120 || aWall.StartHeight >= 120) { wallPrice += PricingConstants.MODEL_100_NON_STANDARD_PANEL_HEIGHTS_HIGHER * aWall.Length; } //Add pricing for fire protection if (aWall.FireProtection == true) { wallPrice += PricingConstants.MODEL_100_FP_SCREEN_OPENINGS_INCLUDES_1_SCREEN_DOOR * lengthOfMods; wallPrice += PricingConstants.MODEL_100_FP_SOLID_WALL_PANEL * lengthOfSolidWall; } return(wallPrice); }
//Find the price for a Model 300 wall /****NEEDS REVIEWING, NOT COMPLETE****/ public static float PriceModel300Wall(Wall aWall) { float wallPrice = 0.0f; float lengthOfStandard = 0.0f; float lengthOfSolidWall = 0.0f; float lengthOfOpen = 0.0f; float lengthOfFixedVinyl = 0.0f; List <LinearItem> listOfMods = (List <LinearItem>)aWall.LinearItems; if (aWall.Orientation != "N" && aWall.Orientation != "S" && aWall.Orientation != "E" && aWall.Orientation != "W") { wallPrice = PricingConstants.MODEL_300_45_DEGREE_WALLS; } //Loop through linear items foreach (LinearItem aLinearItem in listOfMods) { //Linear item is a mod if (aLinearItem.ItemType == "Mod") { //Cast linear item as a mod Mod aMod = (Mod)aLinearItem; //Mod is a door if (aMod.ModType == "Door") { Door aDoor = (Door)aMod.ModularItems[0]; //Non door add linear length to lengthOfOpen if (aDoor.DoorType == "Vertical Four Track") { lengthOfStandard += aLinearItem.Length; } else if (aDoor.DoorType == "NoDoor") { lengthOfOpen += aLinearItem.Length; } else { lengthOfStandard += aLinearItem.Length; } } //Mod is a window else if (aMod.ModType == "Window") { Kneewall aKneewall = (Kneewall)aMod.ModularItems[0]; //Kneewall Window aWindow = (Window)aMod.ModularItems[0]; if (aKneewall.FLength > 20) { //Add pricing for custom kneewall height } else { } //Add length for fixed vinyl if (aWindow.WindowStyle.Contains("Fixed")) //Possibilities: Fixed Vinyl, Fixed Glass 2", Fixed Glass 3" { lengthOfFixedVinyl += aLinearItem.Length; } } else if (aMod.ModType == "Open" && aLinearItem.Length >= 8) { lengthOfOpen += aLinearItem.Length; } else { lengthOfStandard += aLinearItem.Length; } } else //Check to see if everything else other than mods are included { if (aLinearItem.Length >= 8) { lengthOfSolidWall += aLinearItem.Length; lengthOfStandard -= aLinearItem.Length; } } } //Add various wall pricing types to wall price based on length wallPrice += PricingConstants.MODEL_300_VINYL_HORIZONTAL_ROLLER_WINDOW * lengthOfStandard; wallPrice += PricingConstants.MODEL_300_SOLID_WALL_PANEL * lengthOfSolidWall; wallPrice += PricingConstants.MODEL_300_MANUFACTURED_OPEN_WALLS * lengthOfOpen; wallPrice += PricingConstants.MODEL_300_FIXED_WINDOWS * lengthOfFixedVinyl; //Find wall height and set appropriate pricing if ((aWall.EndHeight > 96 && aWall.EndHeight < 120) || (aWall.StartHeight > 96 && aWall.StartHeight < 120)) { wallPrice += PricingConstants.MODEL_300_NON_STANDARD_PANEL_HEIGHTS * aWall.Length; } else if (aWall.EndHeight >= 120 || aWall.StartHeight >= 120) { wallPrice += PricingConstants.MODEL_300_NON_STANDARD_PANEL_HEIGHTS_HIGHER * aWall.Length; } //Add pricing for fire protection if (aWall.FireProtection == true) { wallPrice += PricingConstants.MODEL_300_FP_HORIZONTAL_ROLLER * lengthOfStandard; wallPrice += PricingConstants.MODEL_300_FP_MANUFACTURED_OPEN_WALLS * lengthOfOpen; wallPrice += PricingConstants.MODEL_300_FP_SOLID_WALL_PANEL * lengthOfSolidWall; wallPrice += PricingConstants.MODEL_300_FP_FIXED_WINDOWS * lengthOfFixedVinyl; } return(wallPrice); }
//Find the price for a Model 200 wall public static float PriceModel200Wall(Wall aWall) { float wallPrice = 0.0f; float lengthOfStandard = 0.0f; float lengthOfSolidWall = 0.0f; float lengthOfOpen = 0.0f; float lengthOfFixedVinyl = 0.0f; List <LinearItem> listOfMods = (List <LinearItem>)aWall.LinearItems; if (aWall.Orientation != "N" && aWall.Orientation != "S" && aWall.Orientation != "E" && aWall.Orientation != "W") { wallPrice = PricingConstants.MODEL_200_45_DEGREE_WALLS; } //Loop through linear items foreach (LinearItem aLinearItem in listOfMods) { if (aLinearItem.ItemType == "Electrical Chase") { wallPrice += PricingConstants.MODEL_200_VERTICAL_ELECTRICAL_CHASE; } //Linear item is a mod else if (aLinearItem.ItemType == "Mod") { /****************************************** * NEED SOMETHING FOR PRICING TRANSOMS * * NEED SOMETHING FOR MISCELLANEOUS ITEMS * * ****************************************/ //Cast linear item as a mod Mod aMod = (Mod)aLinearItem; //Mod is a door if (aMod.ModType == "Door") { Door aDoor = (Door)aMod.ModularItems[0]; //Non door add linear length to lengthOfOpen if (aDoor.DoorType == "Patio") { numberOfPatioDoors++; //Cast the window within the door to a window object Window aDoorWindow = aDoor.DoorWindow; //Must be a glass window if (aDoorWindow.WindowStyle.Contains("Glass") || aDoorWindow.WindowStyle == "Single Slider" || aDoorWindow.WindowStyle == "Horizontal Roller") { //Cast window item to vinyl window item VinylWindow aVinylDoorWindow = (VinylWindow)aDoorWindow; //If glass window tint is grey or bronze, additional pricing occurs if (aVinylDoorWindow.VinylTint.Contains("Grey") || aVinylDoorWindow.VinylTint.Contains("Bronze")) { wallPrice += PricingConstants.MODEL_200_TINTED_GLASS_IN_PATIO_DOOR; } } } else if (aDoor.DoorType == "NoDoor") { //Add length to open door length lengthOfOpen += aLinearItem.Length; } else { //Add length to standard pricing lengthOfStandard += aLinearItem.Length; } /************************************** * BLOCK TO HANDLE ENTRY DOOR PRICING * * ************************************/ if (aDoor.DoorStyle == "Vertical Four Track" && aDoor.DoorType != "French") { //Add length to standard pricing lengthOfStandard += aLinearItem.Length; numberOfV4TDoors++; } else if (aDoor.DoorStyle == "Vertical Four Track" && aDoor.DoorType == "French") { //Add length to standard pricing lengthOfStandard += aLinearItem.Length; numberOfV4TFrenchDoors++; } if (aDoor.DoorStyle == "Full View" && aDoor.DoorType != "French") { numberOfFullViewDoors++; } else if (aDoor.DoorStyle == "Full View" && aDoor.DoorType == "French") { numberOfFullViewFrenchDoors++; } if (aDoor.DoorStyle == "Full View Colonial" && aDoor.DoorType != "French") { numberOfFullViewColonialDoors++; } else if (aDoor.DoorStyle == "Full View Colonial" && aDoor.DoorType == "French") { numberOfFullViewColonialFrenchDoors++; } } //Mod is a window else if (aMod.ModType == "Window") { Kneewall aKneewall = (Kneewall)aMod.ModularItems[0]; //Kneewall Window aWindow = (Window)aMod.ModularItems[1]; if (aKneewall.FLength > 20) { //Add pricing for custom kneewall height } else { } //Add length for fixed vinyl if (aWindow.WindowStyle.Contains("Fixed")) //Possibilities: Fixed Vinyl, Fixed Glass 2", Fixed Glass 3" { lengthOfFixedVinyl += aLinearItem.Length; } if (aWindow.ScreenType == "No See Ums 20 x 20 Mesh") { wallPrice += PricingConstants.MODEL_200_NO_SEE_UMS * aLinearItem.Length; } else if (aWindow.ScreenType == "Solar Insect Screening") { wallPrice += PricingConstants.MODEL_200_SOLAR_INSECT_SCREENING * aLinearItem.Length; } else if (aWindow.ScreenType == "Tuff Screen") { wallPrice += PricingConstants.MODEL_200_TUFF_SCREEN * aLinearItem.Length; } } else if (aMod.ModType == "Open" && aLinearItem.Length >= 8) { lengthOfOpen += aLinearItem.Length; } else { lengthOfStandard += aLinearItem.Length; } } else //Check to see if everything else other than mods are included { if (aLinearItem.Length >= 8) { lengthOfSolidWall += aLinearItem.Length; lengthOfStandard -= aLinearItem.Length; } } } //Add various wall pricing types to wall price based on length wallPrice += PricingConstants.MODEL_200_VINYL_HORIZONTAL_ROLLER * lengthOfStandard; wallPrice += PricingConstants.MODEL_200_SOLID_WALL_PANEL * lengthOfSolidWall; wallPrice += PricingConstants.MODEL_200_MANUFACTURED_OPEN_WALLS * lengthOfOpen; wallPrice += PricingConstants.MODEL_200_FIXED_VINYL_WALL * lengthOfFixedVinyl; //Find wall height and set appropriate pricing if ((aWall.EndHeight > 96 && aWall.EndHeight < 120) || (aWall.StartHeight > 96 && aWall.StartHeight < 120)) { wallPrice += PricingConstants.MODEL_200_NON_STANDARD_PANEL_HEIGHTS * aWall.Length; } else if (aWall.EndHeight >= 120 || aWall.StartHeight >= 120) { wallPrice += PricingConstants.MODEL_200_NON_STANDARD_PANEL_HEIGHTS_HIGHER * aWall.Length; } //Add pricing for fire protection if (aWall.FireProtection == true) { wallPrice += PricingConstants.MODEL_200_FP_HORIZONTAL_ROLLER * lengthOfStandard; wallPrice += PricingConstants.MODEL_200_FP_MANUFACTURED_OPEN_WALLS * lengthOfOpen; wallPrice += PricingConstants.MODEL_200_FP_SOLID_WALL_PANEL * lengthOfSolidWall; wallPrice += PricingConstants.MODEL_200_FP_FIXED_VINYL_WALL * lengthOfFixedVinyl; } return(wallPrice); }
///// <summary> ///// This is an event that is used to dynamically create wall objects with the appropriate details ///// </summary> ///// <param name="sender"></param> ///// <param name="e"></param> //protected void createWallObjects(object sender, EventArgs e) //{ // //there are issues with getting values from dynamically generated hidden fields // //hard coded hidden fields work fine... // //need to dynamically determine slope, and soffit length of each wall and store it in hidden fields // float length, startHeight, endHeight, soffit;//, slope; // string orientation, name, type, model; // HiddenField wallLength, wallSoffit; // for (int i = 0; i < strWalls.Count(); i++) // { // //find and store the dynamically created hidden fields // wallLength = hiddenFieldsDiv.FindControl("hidWall" + i + "Length") as HiddenField; //wall length // wallSoffit = hiddenFieldsDiv.FindControl("hidWall" + i + "SoffitLength") as HiddenField; //wall soffit length // //length = wallLength.Value; // //startHeight = Convert.ToSingle(hidHeight.Value); // //endHeight = Convert.ToSingle(hidFrontWallHeight.Value); // //soffit = Convert.ToSingle(wallSoffit.Value); // // slope = Convert.ToSingle(hidRoofSlope.Value); // orientation = wallDetails[i, 5]; // name = "wall " + i; // type = wallDetails[i, 4]; // model = currentModel; // //string sof = wallSoffit.Value; // //create a wall object with the appropriate values in the fields and attributes of it and add it to the walls list // //walls.Add(new Wall(Convert.ToSingle(wallLength.Value), wallDetails[i, 5], "Wall" + i, wallDetails[i, 4], Convert.ToSingle(hidBackWallHeight.Value), Convert.ToSingle(hidBackWallHeight.Value), /*Convert.ToSingle(wallSoffit.Value)*/ 0F, currentModel)); // } //} protected void btnSubmit_Click(object sender, EventArgs e) { //Create objects List<Wall> listOfWalls = new List<Wall>(); int existingWallCount = 0; Session.Add("roomWidth", hidRoomWidth.Value); Session.Add("roomProjection", hidRoomProjection.Value); for (int i = 1; i <= strWalls.Length; i++) { //if blank its an existing wall, so skip it if (Request.Form["hidWall" + i + "Length"] != "") { Wall aWall = new Wall(); aWall.Length = float.Parse(Request.Form["hidWall" + i + "Length"]); aWall.Orientation = Request.Form["hidWall" + i + "Orientation"]; aWall.Name = "Wall " + (i-existingWallCount); aWall.WallType = "Proposed"; aWall.ModelType = currentModel; aWall.StartHeight = GlobalFunctions.RoundDownToNearestEighthInch(float.Parse(Request.Form["hidWall" + i + "StartHeight"])); aWall.EndHeight = GlobalFunctions.RoundDownToNearestEighthInch(float.Parse(Request.Form["hidWall" + i + "EndHeight"])); aWall.SoffitLength = float.Parse(Request.Form["hidWall" + i + "SoffitLength"]); aWall.GablePeak = 0; listOfWalls.Add(aWall); //firstItemIndex,lastItemIndex handled below //totalCornerLength,totalReceiverLength unhandled //linearItems handled below } else { existingWallCount++; } } //Loop for each wall int linearPosition = 0; //Current wall we're on int cheatCounter = 0; //If it's a gable, we need to start one element past the normal point to account for the gable post being part of the wall list int gableCompensation = 0; if (gableType != "") { gableCompensation = 1; } for (int i = 1 + gableCompensation; i <= strWalls.Length; i++) { //A list of linear items to be added to each wall List<LinearItem> linearItems = new List<LinearItem>(); bool addReceiver = true; if (wallDetails[i - 1, 4] == "P" || wallDetails[i - 1, 4] == "G") { #region Wall Creation float wallStartHeight = (float.Parse(Request.Form["hidWall" + i + "StartHeight"])); float wallEndHeight = (float.Parse(Request.Form["hidWall" + i + "EndHeight"])); float wallLeftFiller = (float.Parse(Request.Form["hidWall" + i + "LeftFiller"])); float wallRightFiller = (float.Parse(Request.Form["hidWall" + i + "RightFiller"])); float wallDoorCount = Int32.Parse(Request.Form["hidWall" + i + "DoorCount"]); bool gableCheck = false; //If this is a gable front wall of some form (gbale wall, gablefrontwall) //Then we have no need for the corners that would be added if (gableType.Contains("Gable") && wallStartHeight < wallEndHeight) { gableCheck = true; if (currentModel == "M400") { wallRightFiller -= 4.125f; } else { wallRightFiller -= 3.125f; } } //The same for the right gable wall if (gableType.Contains("Gable") && wallStartHeight > wallEndHeight) { gableCheck = true; if (currentModel == "M400") { wallLeftFiller -= 4.125f; } else { wallLeftFiller -= 3.125f; } } //if it has doors, do logic w/ doors, otherwise just directly go to window creation //CHANGEME 2,125/2 are hardcoded instead of constants if (wallDoorCount > 0) { //Left filler //The current program hasn't considered the space receievers or corner posts take up in a wall's length //So we're going to cheat it here by adding that 'space' to the fillers, and removing it later when the //Wall objects are being built, which is here. if (cheatCounter == 0) { wallLeftFiller -= 1;//CHANGEME receiver length Receiver aReceiver = new Receiver(); aReceiver.ItemType = "Receiver"; aReceiver.StartHeight = aReceiver.EndHeight = GlobalFunctions.getHeightAtPosition(wallStartHeight, wallEndHeight, 0, listOfWalls[0].Length); aReceiver.Length = 1f; aReceiver.FixedLocation = 0; linearItems.Insert(0,aReceiver); cheatCounter++; } else { //If this is a gable front wall of some form (gbale wall, gablefrontwall) //Then we have no need for the corners that would be added if (!(gableType.Contains("Gable") && wallStartHeight > wallEndHeight)) { if (currentModel == "M400") { Corner aCorner = new Corner(); aCorner.StartHeight = aCorner.EndHeight = GlobalFunctions.getHeightAtPosition(wallStartHeight, wallEndHeight, 0, listOfWalls[0].Length); aCorner.Length = 4.125f; aCorner.ItemType = "Corner"; wallLeftFiller -= aCorner.Length; linearItems.Add(aCorner); } else { Corner aCorner = new Corner(); aCorner.StartHeight = aCorner.EndHeight = GlobalFunctions.getHeightAtPosition(wallStartHeight, wallEndHeight, 0, listOfWalls[0].Length); aCorner.Length = 3.125f; aCorner.ItemType = "Corner"; wallLeftFiller -= aCorner.Length; linearItems.Add(aCorner); } cheatCounter++; } } //loop for each door for (int j = 1; j <= wallDoorCount; j++) { if (Request.Form["hidWall" + i + "Door" + j + "boxHeader"] == "Left" || Request.Form["hidWall" + i + "Door" + j + "boxHeader"] == "Both") { if (currentModel == "M400") { HChannel anHChannel = new HChannel(); anHChannel.ItemType = "HChannel"; anHChannel.Length = Constants.HCHANNEL_LENGTH; //CHANGEME if driftwood anHChannel.FixedLocation = Convert.ToSingle(Request.Form["hidWall" + i + "Door" + j + "position"]) - anHChannel.Length; anHChannel.StartHeight = GlobalFunctions.getHeightAtPosition(wallStartHeight, wallEndHeight, anHChannel.FixedLocation, listOfWalls[linearPosition].Length); anHChannel.EndHeight = GlobalFunctions.getHeightAtPosition(wallStartHeight, wallEndHeight, anHChannel.FixedLocation + anHChannel.Length, listOfWalls[linearPosition].Length); linearItems.Add(anHChannel); } else { BoxHeader aBoxHeader = new BoxHeader(); aBoxHeader.ItemType = "BoxHeader"; aBoxHeader.Length = Constants.BOXHEADER_LENGTH; aBoxHeader.FixedLocation = Convert.ToSingle(Request.Form["hidWall" + i + "Door" + j + "position"]) - aBoxHeader.Length; aBoxHeader.StartHeight = GlobalFunctions.getHeightAtPosition(wallStartHeight, wallEndHeight, aBoxHeader.FixedLocation, listOfWalls[linearPosition].Length); aBoxHeader.EndHeight = GlobalFunctions.getHeightAtPosition(wallStartHeight, wallEndHeight, aBoxHeader.FixedLocation + aBoxHeader.Length, listOfWalls[linearPosition].Length); linearItems.Add(aBoxHeader); } } Mod aMod = new Mod();// aMod.ItemType = "Mod"; aMod.ModType = Constants.MOD_TYPE_DOOR; aMod.Length = float.Parse(Request.Form["hidWall" + i + "Door" + j + "mwidth"]); aMod.FixedLocation = float.Parse(Request.Form["hidWall" + i + "Door" + j + "position"]);// +linearItems[0].Length; aMod.StartHeight = GlobalFunctions.getHeightAtPosition(wallStartHeight, wallEndHeight, aMod.FixedLocation, float.Parse(Request.Form["hidWall" + i + "Length"])); aMod.EndHeight = GlobalFunctions.getHeightAtPosition(wallStartHeight, wallEndHeight, (aMod.FixedLocation + aMod.Length), float.Parse(Request.Form["hidWall" + i + "Length"])); aMod.Sunshade = Convert.ToBoolean(Request.Form["MainContent_hidSunshade"]); aMod.SunshadeValance = (string)Request.Form["MainContent_hidValance"]; aMod.SunshadeFabric = (string)Request.Form["MainContent_hidFabric"]; aMod.SunshadeOpenness = (string)Request.Form["MainContent_hidOpenness"]; aMod.SunshadeChain = (string)Request.Form["MainContent_hidChain"]; List<ModuleItem> modularItems = new List<ModuleItem>(); string doorType = Request.Form["hidWall" + i + "Door" + j + "type"]; if (doorType == "Cabana") { //cast test? does it retain cabana info? Door aDoor = getCabanaDoorFromForm(i, j); aDoor.Punch = aDoor.FEndHeight; Window doorWindow = new Window(); doorWindow.WindowStyle = Request.Form["hidWall" + i + "Door" + j + "style"]; doorWindow.FLength = aDoor.FLength - Constants.DOOR_PADDING; //11.5 is the amount of door between edge of door and start of window (both sides totalled to 11.5) doorWindow.Width = doorWindow.FLength - 2.125f; doorWindow.FStartHeight = doorWindow.FEndHeight = aDoor.FStartHeight - aDoor.Kickplate - Constants.KICKPLATE_PADDING; //4 corresponds to the amount of framing at a bottom of a door doorWindow.LeftHeight = doorWindow.RightHeight = aDoor.FStartHeight - aDoor.Kickplate - Constants.KICKPLATE_PADDING - 2.125f; doorWindow.ItemType = "Window"; doorWindow.FrameColour = Request.Form["MainContent_hidWindowFramingColour"]; doorWindow.SpreaderBar = -1; doorWindow.ScreenType = "No Screen"; if (doorWindow.WindowStyle == "Vertical Four Track" || doorWindow.WindowStyle.Contains("Vinyl")) { doorWindow.Colour = Request.Form["hidWall" + i + "Door" + j + "vinylTint"]; doorWindow.NumVents = Convert.ToInt32(Request.Form["hidWall" + i + "Door" + j + "numberOfVents"]); } else if (!doorWindow.WindowStyle.Contains("Screen")) { doorWindow.Colour = Request.Form["hidWall" + i + "Door" + j + "glassTint"]; } else { doorWindow.ScreenType = Request.Form["hidWall" + i + "Door" + j + "screenOptions"]; } if (doorWindow.WindowStyle == "Horizontal Roller") { doorWindow.NumVents = 2; doorWindow.WindowStyle = "Horizontal Roller XO"; } //Spreaderbar logic if (doorWindow.WindowStyle == "Vertical 4 Track" && doorWindow.FLength > Constants.V4T_SPREADER_BAR_NEEDED) { doorWindow.SpreaderBar = (doorWindow.FLength / 2) - (Constants.SPREADER_BAR_SIZE / 2); //Find center of window, then place center of spreader bar at that position (by subtracting half of it) } if (doorWindow.WindowStyle.Contains("Horizontal Roller") && doorWindow.FLength > Constants.HORIZONTAL_ROLLER_SPREADER_BAR_NEEDED) { doorWindow.SpreaderBar = (doorWindow.FEndHeight / 2) - (Constants.SPREADER_BAR_SIZE / 2); } if (doorWindow.WindowStyle == "Vinyl") { if (doorWindow.FLength > Constants.TRANSOM_SPREADER_BAR_REQUIRED || doorWindow.FEndHeight > Constants.TRANSOM_SPREADER_BAR_REQUIRED || doorWindow.FStartHeight > Constants.TRANSOM_SPREADER_BAR_REQUIRED) { //If length is longer, vertical bar, else horizontal bar if (doorWindow.Width >= doorWindow.FEndHeight && doorWindow.Width >= doorWindow.FStartHeight) { doorWindow.SpreaderBar = (doorWindow.FLength / 2) - (Constants.SPREADER_BAR_SIZE / 2); } else { doorWindow.SpreaderBar = (doorWindow.FEndHeight / 2) - (Constants.SPREADER_BAR_SIZE / 2); } //If dimensions are equal? } } aDoor.DoorWindow = doorWindow; modularItems.Add(aDoor); } if (doorType == "Patio") { Door aDoor = getPatioDoorFromForm(i, j); aDoor.Punch = aDoor.FEndHeight; Window doorWindow = new Window(); doorWindow.FLength = aDoor.FLength - Constants.DOOR_PADDING; //11.5 is the amount of door between edge of door and start of window (both sides totalled to 11.5) doorWindow.Width = doorWindow.FLength - 2.125f; doorWindow.ItemType = "Window"; doorWindow.WindowStyle = Request.Form["hidWall" + i + "Door" + j + "style"]; doorWindow.FStartHeight = doorWindow.FEndHeight = aDoor.FStartHeight; //4 corresponds to the amount of framing at a bottom of a door doorWindow.LeftHeight = doorWindow.RightHeight = aDoor.FStartHeight - 2.125f; doorWindow.Colour = Request.Form["hidWall" + i + "Door" + j + "glassTint"]; doorWindow.ScreenType = Request.Form["hidWall" + i + "Door" + j + "screenOptions"]; doorWindow.FrameColour = Request.Form["MainContent_hidWindowFramingColour"]; doorWindow.SpreaderBar = -1; aDoor.DoorWindow = doorWindow; modularItems.Add(aDoor); } if (doorType == "French") { Door aDoor = getFrenchDoorFromForm(i, j); aDoor.Punch = aDoor.FEndHeight; Window doorWindow = new Window(); doorWindow.WindowStyle = Request.Form["hidWall" + i + "Door" + j + "style"]; doorWindow.FLength = aDoor.FLength - Constants.DOOR_PADDING; doorWindow.Width = doorWindow.FLength - 2.125f; doorWindow.FStartHeight = doorWindow.FEndHeight = aDoor.FStartHeight - aDoor.Kickplate - Constants.KICKPLATE_PADDING; //4 corresponds to the amount of framing at a bottom of a door; doorWindow.LeftHeight = doorWindow.RightHeight = aDoor.FStartHeight - aDoor.Kickplate - Constants.KICKPLATE_PADDING - 2.125f; //4 corresponds to the amount of framing at a bottom of a door; doorWindow.ItemType = "Window"; doorWindow.FrameColour = Request.Form["MainContent_hidWindowFramingColour"]; doorWindow.SpreaderBar = -1; if (doorWindow.WindowStyle == "Vertical 4 Track" || doorWindow.WindowStyle == "Vertical Four Track" || doorWindow.WindowStyle.Contains("Vinyl")) { doorWindow.Colour = Request.Form["hidWall" + i + "Door" + j + "vinylTint"]; if (doorWindow.WindowStyle == "Vertical 4 Track" || doorWindow.WindowStyle == "Vertical Four Track") { doorWindow.NumVents = Convert.ToInt32(Request.Form["hidWall" + i + "Door" + j + "numberOfVents"]); } } else if (!doorWindow.WindowStyle.Contains("Screen")) { doorWindow.Colour = Request.Form["hidWall" + i + "Door" + j + "glassTint"]; } else { doorWindow.Colour = ""; doorWindow.ScreenType = Request.Form["hidWall" + i + "Door" + j + "screenOptions"]; } if (doorWindow.WindowStyle == "Horizontal Roller") { doorWindow.NumVents = 2; doorWindow.WindowStyle = "Horizontal Roller XO"; } //Spreaderbar logic if (doorWindow.WindowStyle == "Vertical 4 Track" && doorWindow.FLength > Constants.V4T_SPREADER_BAR_NEEDED) { doorWindow.SpreaderBar = (doorWindow.FLength / 2) - (Constants.SPREADER_BAR_SIZE / 2); //Find center of window, then place center of spreader bar at that position (by subtracting half of it) } if (doorWindow.WindowStyle.Contains("Horizontal Roller") && doorWindow.FLength > Constants.HORIZONTAL_ROLLER_SPREADER_BAR_NEEDED) { doorWindow.SpreaderBar = (doorWindow.FEndHeight / 2) - (Constants.SPREADER_BAR_SIZE / 2); } if (doorWindow.WindowStyle == "Vinyl") { if (doorWindow.FLength > Constants.TRANSOM_SPREADER_BAR_REQUIRED || doorWindow.FEndHeight > Constants.TRANSOM_SPREADER_BAR_REQUIRED || doorWindow.FStartHeight > Constants.TRANSOM_SPREADER_BAR_REQUIRED) { //If length is longer, vertical bar, else horizontal bar if (doorWindow.Width >= doorWindow.FEndHeight && doorWindow.Width >= doorWindow.FStartHeight) { doorWindow.SpreaderBar = (doorWindow.FLength / 2) - (Constants.SPREADER_BAR_SIZE / 2); } else { doorWindow.SpreaderBar = (doorWindow.FEndHeight / 2) - (Constants.SPREADER_BAR_SIZE / 2); } //If dimensions are equal? } } aDoor.DoorWindow = doorWindow; modularItems.Add(aDoor); } if (doorType == "NoDoor") { Door aDoor = getNoDoorFromForm(i, j); aDoor.Punch = aDoor.FEndHeight; Window doorWindow = new Window(); doorWindow.WindowStyle = Request.Form["hidWall" + i + "Door" + j + "style"]; //doorWindow.FLength = aDoor.FLength - SOMEVALUE; doorWindow.Width = doorWindow.FLength - 2.125f; //doorWindow.FStartHeight = doorWindow.FStartHeight = SOMEVALUE; //doorWindow.StartHeight = doorWindow.EndHeight = SOMEVALUE; doorWindow.ItemType = "Window"; doorWindow.SpreaderBar = -1; aDoor.DoorWindow = doorWindow; modularItems.Add(aDoor); } //Extra door stuff here //now we add transom windows //The height of the wall at mod end and mod start float modStartHeight = GlobalFunctions.getHeightAtPosition(wallStartHeight, wallEndHeight, aMod.FixedLocation, float.Parse(Request.Form["hidWall" + i + "Length"]));// float modEndHeight = GlobalFunctions.getHeightAtPosition(wallStartHeight, wallEndHeight, (aMod.FixedLocation + aMod.Length), float.Parse(Request.Form["hidWall" + i + "Length"])); //The space left is the total height of the wall at the highest point of the mod minus the current built mod's space (aMod.StartHeight which equals aMod.endHeight at this point //Minus the space the door punch takes up. float sendableHeight = Math.Max(modStartHeight, modEndHeight); float[] windowInfo = GlobalFunctions.findOptimalHeightsOfWindows((sendableHeight - modularItems[0].FStartHeight - .25f), ddlTransomType.SelectedValue); if (modStartHeight == modEndHeight) { //rectangular window for (int currentWindow = 0; currentWindow < windowInfo[0]; currentWindow++) { //Set window properties Window aWindow = new Window(); aWindow.FEndHeight = aWindow.FStartHeight = windowInfo[1]; aWindow.RightHeight = aWindow.LeftHeight = windowInfo[1] - 2.125f; //Framing size aWindow.Colour = Request.Form["MainContent_hidWindowColour"]; //CHANGEME if v4t will be XXXX, can't use hidWallWindowColour need to ask elsewhere aWindow.FrameColour = Request.Form["MainContent_hidWindowFramingColour"]; aWindow.ItemType = "Window"; aWindow.FLength = aMod.Length - Constants.MOD_FRAMING_OFFSET; aWindow.Width = aWindow.FLength - Constants.WINDOW_FRAMING_OFFSET; aWindow.WindowStyle = ddlTransomType.SelectedValue; aWindow.SpreaderBar = -1; //Add remaining area to first window if (currentWindow == 0) { aWindow.FEndHeight += windowInfo[2]; aWindow.FStartHeight += windowInfo[2]; aWindow.RightHeight += windowInfo[2]; aWindow.LeftHeight += windowInfo[2]; } modularItems.Add(aWindow); } } else { //trap/triangle for (int currentWindow = 0; currentWindow < windowInfo[0]; currentWindow++) { //Set window properties Window aWindow = new Window(); aWindow.FEndHeight = aWindow.FStartHeight = windowInfo[1]; aWindow.RightHeight = aWindow.LeftHeight = windowInfo[1] - 2.125f; aWindow.Colour = Request.Form["MainContent_hidWindowColour"]; //CHANGEME if v4t will be XXXX, can't use hidWallWindowColour need to ask elsewhere aWindow.FrameColour = Request.Form["MainContent_hidWindowFramingColour"]; aWindow.ItemType = "Window"; aWindow.FLength = aMod.Length - Constants.MOD_FRAMING_OFFSET; aWindow.Width = aWindow.FLength - Constants.WINDOW_FRAMING_OFFSET; aWindow.WindowStyle = ddlTransomType.SelectedValue; aWindow.SpreaderBar = -1; //Add remaining area to first window if (currentWindow == 0) { aWindow.FEndHeight += windowInfo[2]; aWindow.FStartHeight += windowInfo[2]; aWindow.RightHeight += windowInfo[2]; aWindow.LeftHeight += windowInfo[2]; } //If last window, we need to change a height to make it sloped if (currentWindow == windowInfo[0] - 1) { //If start wall is higher, we lower end height if (wallStartHeight == Math.Max(wallStartHeight, wallEndHeight)) { aWindow.FEndHeight = aWindow.FEndHeight - (modStartHeight - modEndHeight); aWindow.RightHeight = aWindow.RightHeight - (modStartHeight - modEndHeight); } //Otherwise we lower start height else { aWindow.FStartHeight = aWindow.FStartHeight - (modEndHeight - modStartHeight); aWindow.LeftHeight = aWindow.LeftHeight - (modEndHeight - modStartHeight); } } modularItems.Add(aWindow); } } aMod.ModularItems = modularItems; linearItems.Add(aMod); if (Request.Form["hidWall" + i + "Door" + j + "boxHeader"] == "Right" || Request.Form["hidWall" + i + "Door" + j + "boxHeader"] == "Both") { if (currentModel == "M400") { HChannel anHChannel = new HChannel(); anHChannel.StartHeight = anHChannel.EndHeight = Convert.ToSingle(Request.Form["hidWall" + i + "Door" + j + "mheight"]); anHChannel.Length = 2.5f; //CHANGEME if driftwood anHChannel.ItemType = "HChannel";// anHChannel.FixedLocation = Convert.ToSingle(Request.Form["hidWall" + i + "Door" + j + "position"]) - anHChannel.Length; linearItems.Add(anHChannel); } else { BoxHeader aBoxHeader = new BoxHeader(); aBoxHeader.StartHeight = aBoxHeader.EndHeight = Convert.ToSingle(Request.Form["hidWall" + i + "Door" + j + "mheight"]); aBoxHeader.Length = Constants.BOXHEADER_LENGTH; aBoxHeader.FixedLocation = Convert.ToSingle(Request.Form["hidWall" + i + "Door" + j + "position"]) - aBoxHeader.Length; aBoxHeader.ItemType = "BoxHeader"; linearItems.Add(aBoxHeader); } } } int numberOfVents = 0; if (hidWindowType.Value == "Vertical 4 Track" || hidWindowType.Value == "Vertical Four Track") { numberOfVents = hidWindowColour.Value.Length; } if (hidWindowType.Value == "Horizontal Roller" || hidWindowType.Value == "Horizontal 2 Track") { numberOfVents = 2; } ////Now we add the windows that fill the rest of the space //string windowInfoString = Request.Form["hidWall" + i + "WindowInfo"]; //string[] windowInfoArray = windowInfoString.Split(detailsDelimiter, StringSplitOptions.RemoveEmptyEntries); //Right filler //Since we don't want to add the same corner post that is shared between walls twice, at this point we're just going to remove from filler //and from wall length, so for example, a 130 length wall will actually be 126.875 and 'go into' the next corner post //We try to check next wall. If it exists, this rightside will be a corner post. If it throws an error //this must be the last wall, so we only remove a receiver's worth from the right side. //try //{ // if (wallDetails[i - 1, 4] == "P") // { // if (currentModel == "M400") // { // wallRightFiller -= 4.125f; // } // else // { // wallRightFiller -= 3.125f; // } // } //} //catch (Exception ex) //{ // wallRightFiller -= 1f; //} //Now add the filler itself if (wallLeftFiller > 0) { Filler leftFiller = new Filler(); leftFiller.Length = wallLeftFiller; //Surround this in a try, because partial gable right walls will not have an element 0. //In that case, the fixedlocation would be the start, 0. try { leftFiller.FixedLocation = linearItems[0].Length; leftFiller.StartHeight = GlobalFunctions.getHeightAtPosition(wallStartHeight, wallEndHeight, leftFiller.FixedLocation, listOfWalls[linearPosition].Length);//position corresponds to this wall's first item's start point leftFiller.EndHeight = GlobalFunctions.getHeightAtPosition(wallStartHeight, wallEndHeight, leftFiller.FixedLocation + leftFiller.Length, listOfWalls[linearPosition].Length);//position corresponds to this wall's first item's length leftFiller.ItemType = "Filler"; linearItems.Insert(1, leftFiller); //Inserted as second element, after receiever or post } catch (Exception ex) { leftFiller.FixedLocation = 0; leftFiller.StartHeight = GlobalFunctions.getHeightAtPosition(wallStartHeight, wallEndHeight, leftFiller.FixedLocation, listOfWalls[linearPosition].Length);//position corresponds to this wall's first item's start point leftFiller.EndHeight = GlobalFunctions.getHeightAtPosition(wallStartHeight, wallEndHeight, leftFiller.FixedLocation + leftFiller.Length, listOfWalls[linearPosition].Length);//position corresponds to this wall's first item's length leftFiller.ItemType = "Filler"; linearItems.Add(leftFiller); //Inserted as first element } } if (wallRightFiller > 0) { Filler rightFiller = new Filler(); rightFiller.Length = wallRightFiller; rightFiller.FixedLocation = listOfWalls[linearPosition].Length - wallRightFiller; rightFiller.StartHeight = GlobalFunctions.getHeightAtPosition(wallStartHeight, wallEndHeight, rightFiller.FixedLocation, listOfWalls[linearPosition].Length);//position corresponds to this wall's first item's start point rightFiller.EndHeight = GlobalFunctions.getHeightAtPosition(wallStartHeight, wallEndHeight, rightFiller.FixedLocation + rightFiller.Length, listOfWalls[linearPosition].Length);//position corresponds to this wall's first item's length rightFiller.ItemType = "Filler"; linearItems.Add(rightFiller); } //if (currentModel == "M400") //{ // Corner aCorner = new Corner(); // aCorner.StartHeight = aCorner.EndHeight = GlobalFunctions.getHeightAtPosition(wallStartHeight, wallEndHeight, 0, listOfWalls[0].Length); // aCorner.Length = 4.125f; // wallRightFiller -= aCorner.Length; // linearItems.Add(aCorner); //} //else //{ // Corner aCorner = new Corner(); // aCorner.StartHeight = aCorner.EndHeight = GlobalFunctions.getHeightAtPosition(wallStartHeight, wallEndHeight, 0, listOfWalls[0].Length); // aCorner.Length = 4.125f; // wallRightFiller -= aCorner.Length; // linearItems.Add(aCorner); //} //Now that we have all the linear items, we add to each wall double iRailing = -1; if (hidRailing.Value == "Yes") { iRailing = Convert.ToDouble(hidRailingHeight.Value); } listOfWalls[linearPosition].LinearItems = linearItems; listOfWalls[linearPosition].FillSpaceWithWindows(hidWindowType.Value, hidWindowColour.Value, hidWindowFramingColour.Value, numberOfVents, Convert.ToSingle(txtKneewallHeight.Text), ddlKneewallType.SelectedValue.ToString(), ddlTransomType.SelectedValue.ToString(), bool.Parse(hidSunshade.Value), hidValance.Value, hidFabric.Value, hidOpenness.Value, hidChain.Value, hidScreenType.Value, iRailing); linearPosition++; } //This is a wall without doors else { //Left filler //The current program hasn't considered the space receievers or corner posts take up in a wall's length //So we're going to cheat it here by adding that 'space' to the fillers, and removing it later when the //Wall objects are being built, which is here. if (cheatCounter == 0) { wallLeftFiller -= 1;//CHANGEME receiver length Receiver aReceiver = new Receiver(); aReceiver.ItemType = "Receiver"; aReceiver.StartHeight = aReceiver.EndHeight = GlobalFunctions.getHeightAtPosition(wallStartHeight, wallEndHeight, 0, listOfWalls[0].Length); aReceiver.Length = 1f; aReceiver.FixedLocation = 0; linearItems.Insert(0, aReceiver); cheatCounter++; } else { //If this is a gable front wall of some form (gbale wall, gablefrontwall) //Then we have no need for the corners that would be added if (!(gableType.Contains("Gable") && wallStartHeight > wallEndHeight)) { if (currentModel == "M400") { Corner aCorner = new Corner(); aCorner.StartHeight = aCorner.EndHeight = GlobalFunctions.getHeightAtPosition(wallStartHeight, wallEndHeight, 0, listOfWalls[0].Length); aCorner.Length = 4.125f; aCorner.ItemType = "Corner"; wallLeftFiller -= aCorner.Length; linearItems.Add(aCorner); } else { Corner aCorner = new Corner(); aCorner.StartHeight = aCorner.EndHeight = GlobalFunctions.getHeightAtPosition(wallStartHeight, wallEndHeight, 0, listOfWalls[0].Length); aCorner.Length = 3.125f; aCorner.ItemType = "Corner"; wallLeftFiller -= aCorner.Length; linearItems.Add(aCorner); } cheatCounter++; } } int numberOfVents = 0; if (hidWindowType.Value == "Vertical 4 Track" || hidWindowType.Value == "Vertical Four Track") { numberOfVents = hidWindowColour.Value.Length; } if (hidWindowType.Value == "Horizontal Roller" || hidWindowType.Value == "Horizontal 2 Track") { numberOfVents = 2; } ////Now we add the windows that fill the rest of the space //string windowInfoString = Request.Form["hidWall" + i + "WindowInfo"]; //string[] windowInfoArray = windowInfoString.Split(detailsDelimiter, StringSplitOptions.RemoveEmptyEntries); //Right filler //Since we don't want to add the same corner post that is shared between walls twice, at this point we're just going to remove from filler //and from wall length, so for example, a 130 length wall will actually be 126.875 and 'go into' the next corner post //We try to check next wall. If it exists, this rightside will be a corner post. If it throws an error //this must be the last wall, so we only remove a receiver's worth from the right side. //try //{ // if (wallDetails[i - 1, 4] == "P") // { // if (currentModel == "M400") // { // wallRightFiller -= 4.125f; // } // else // { // wallRightFiller -= 3.125f; // } // } //} //catch (Exception ex) //{ // wallRightFiller -= 1f; //} //Now add the filler itself if (wallLeftFiller > 0) { Filler leftFiller = new Filler(); leftFiller.Length = wallLeftFiller; //Surround this in a try, because partial gable right walls will not have an element 0. //In that case, the fixedlocation would be the start, 0. try { leftFiller.FixedLocation = linearItems[0].Length; leftFiller.StartHeight = GlobalFunctions.getHeightAtPosition(wallStartHeight, wallEndHeight, leftFiller.FixedLocation, listOfWalls[linearPosition].Length);//position corresponds to this wall's first item's start point leftFiller.EndHeight = GlobalFunctions.getHeightAtPosition(wallStartHeight, wallEndHeight, leftFiller.FixedLocation + leftFiller.Length, listOfWalls[linearPosition].Length);//position corresponds to this wall's first item's length leftFiller.ItemType = "Filler"; linearItems.Insert(1, leftFiller); //Inserted as second element, after receiever or post } catch (Exception ex) { leftFiller.FixedLocation = 0; leftFiller.StartHeight = GlobalFunctions.getHeightAtPosition(wallStartHeight, wallEndHeight, leftFiller.FixedLocation, listOfWalls[linearPosition].Length);//position corresponds to this wall's first item's start point leftFiller.EndHeight = GlobalFunctions.getHeightAtPosition(wallStartHeight, wallEndHeight, leftFiller.FixedLocation + leftFiller.Length, listOfWalls[linearPosition].Length);//position corresponds to this wall's first item's length leftFiller.ItemType = "Filler"; linearItems.Add(leftFiller); //Inserted as first element } } if (wallRightFiller > 0) { Filler rightFiller = new Filler(); rightFiller.Length = wallRightFiller; rightFiller.FixedLocation = listOfWalls[linearPosition].Length - wallRightFiller; rightFiller.StartHeight = GlobalFunctions.getHeightAtPosition(wallStartHeight, wallEndHeight, rightFiller.FixedLocation, listOfWalls[linearPosition].Length);//position corresponds to this wall's first item's start point rightFiller.EndHeight = GlobalFunctions.getHeightAtPosition(wallStartHeight, wallEndHeight, rightFiller.FixedLocation + rightFiller.Length, listOfWalls[linearPosition].Length);//position corresponds to this wall's first item's length rightFiller.ItemType = "Filler"; linearItems.Add(rightFiller); } //if last wall, we have right side receiver if (i == strWalls.Length) { wallRightFiller -= 1;//CHANGEME receiver length Receiver aReceiver = new Receiver(); aReceiver.StartHeight = aReceiver.EndHeight = GlobalFunctions.getHeightAtPosition(wallStartHeight, wallEndHeight, listOfWalls[listOfWalls.Count - 1].Length - 1, listOfWalls[listOfWalls.Count - 1].Length); aReceiver.Length = 1f; aReceiver.FixedLocation = listOfWalls[listOfWalls.Count - 1].Length - 1; listOfWalls[listOfWalls.Count - 1].LinearItems.Add(aReceiver); cheatCounter++; } double iRailing = -1; if (hidRailing.Value == "Yes") { iRailing = Convert.ToDouble(hidRailingHeight.Value); } listOfWalls[linearPosition].LinearItems = linearItems; listOfWalls[linearPosition].FillSpaceWithWindows(hidWindowType.Value, hidWindowColour.Value, hidWindowFramingColour.Value, numberOfVents, Convert.ToSingle(txtKneewallHeight.Text), ddlKneewallType.SelectedValue.ToString(), ddlTransomType.SelectedValue.ToString(), bool.Parse(hidSunshade.Value), hidValance.Value, hidFabric.Value, hidOpenness.Value, hidChain.Value, hidScreenType.Value, iRailing);// linearPosition++; } #endregion } } ////Add Area //char[] areaStringDelimeter = { ',' }; //string areaString = Request.Form["hidWall" + i + "WindowInfo" + j]; //string[] areaInfo = areaString.Split(areaStringDelimeter, StringSplitOptions.RemoveEmptyEntries); //Mod aMod = new Mod(); //aMod.ModType = "Window"; ////Height of the mod will be the minimum height for now, CHANGEME //aMod.Height = Math.Min(float.Parse(Request.Form["hidWall" + i + "StartHeight"]), float.Parse(Request.Form["hidWall" + i + "EndHeight"])); //aMod.Length = float.Parse(areaInfo[2]); ////loop for 'number of windows' //for (int k = 0; k <= Int32.Parse(areaInfo[1]); k++) //{ // List<Object> aModItems = new List<Object>(); // Window aWindow = new Window(); //} //Add objects to session //Forward to next page //Last check, if it's a sunspace gable wall, the two gable walls are not seperate, but one entity, so we combine them if (gableType == "Sunspace Gable") { for (int i = 0; i < listOfWalls.Count; i++) { //If this is one of the walls touching the gable peak if (listOfWalls[i].StartHeight == listOfWalls[i+1].EndHeight) { //If start height is smaller, it's the first gable wall if (listOfWalls[i].StartHeight < listOfWalls[i].EndHeight) { //Add the boxheader/receiever BoxHeader aBoxHeader = new BoxHeader(); aBoxHeader.IsReceiver = true; aBoxHeader.FixedLocation = listOfWalls[i].Length; aBoxHeader.Length = Constants.BOXHEADER_LENGTH; aBoxHeader.ItemType = "BoxHeader"; aBoxHeader.StartHeight = GlobalFunctions.getHeightAtPosition(listOfWalls[i].StartHeight, listOfWalls[i].EndHeight, aBoxHeader.FixedLocation, listOfWalls[i].Length); aBoxHeader.EndHeight = GlobalFunctions.getHeightAtPosition(listOfWalls[i].StartHeight, listOfWalls[i].EndHeight, aBoxHeader.FixedLocation + aBoxHeader.Length, listOfWalls[i].Length); listOfWalls[i].LinearItems.Add(aBoxHeader); listOfWalls[i].Length += 3.25f; listOfWalls[i].GablePeak = listOfWalls[i + 1].StartHeight; //Loop through next wall adding items //Remove corner post of second wall for (int j = 0; j < listOfWalls[i+1].LinearItems.Count; j++) { //Set the fixed location to the current length of the first wall, because we 'add on' to it. listOfWalls[i + 1].LinearItems[j].FixedLocation += listOfWalls[i].Length; //Now that location is changed, add the item to the wall itself listOfWalls[i].LinearItems.Add(listOfWalls[i + 1].LinearItems[j]); //Now that the item is in the wall, the wall is longer, so increase its length listOfWalls[i].Length += listOfWalls[i + 1].LinearItems[j].Length; //Adjust endheight to endheight of second wall listOfWalls[i].EndHeight = listOfWalls[i + 1].EndHeight; } //remove second wall entirely listOfWalls.RemoveAt(i + 1); } //We found it, now break out of loop before we out of range exception break; } } } //Indexes //Loop for each wall to set its linear indexes int linearCounter=0; for (int i = 0; i < listOfWalls.Count; i++) { listOfWalls[i].FirstItemIndex = linearCounter; for (int j = 0; j < listOfWalls[i].LinearItems.Count; j++) { //First, lets set modular indexes if (listOfWalls[i].LinearItems[j].ItemType == "Mod") { //Get the mod, then loop for all its items Mod aMod = (Mod)listOfWalls[i].LinearItems[j]; for (int k = 0; k < aMod.ModularItems.Count; k++) { aMod.ModularItems[k].ModuleIndex = (k+1); } listOfWalls[i].LinearItems[j] = aMod; } //now set this item's linear index listOfWalls[i].LinearItems[j].LinearIndex = linearCounter; linearCounter++; } listOfWalls[i].LastItemIndex = linearCounter; listOfWalls[i].Name = "Wall " + (i + 1); } Receiver endReceiver = new Receiver(); endReceiver.FixedLocation = listOfWalls[listOfWalls.Count - 1].Length - 1f; endReceiver.IsTwoPiece = false; listOfWalls[listOfWalls.Count - 1].LastItemIndex++; endReceiver.ItemType = "Receiver"; endReceiver.Length = 1f; endReceiver.LinearIndex = listOfWalls[listOfWalls.Count - 1].LastItemIndex + 1; endReceiver.StartHeight = GlobalFunctions.getHeightAtPosition(listOfWalls[listOfWalls.Count - 1].StartHeight, listOfWalls[listOfWalls.Count - 1].EndHeight, listOfWalls[listOfWalls.Count - 1].Length - 1f, listOfWalls[listOfWalls.Count - 1].Length); endReceiver.EndHeight = GlobalFunctions.getHeightAtPosition(listOfWalls[listOfWalls.Count - 1].StartHeight, listOfWalls[listOfWalls.Count - 1].EndHeight, listOfWalls[listOfWalls.Count - 1].Length, listOfWalls[listOfWalls.Count - 1].Length); listOfWalls[listOfWalls.Count - 1].LinearItems.Add(endReceiver); //linear item sexes for (int i = 0; i < listOfWalls.Count; i++) { for (int j = 0; j < listOfWalls[i].LinearItems.Count; j++) { if (listOfWalls[i].LinearItems[j].ItemType == "Receiver") { //Receiver at start of wall is MF, but at end of wall is FM if (j == 0) { listOfWalls[i].LinearItems[j].Sex = "MF"; } else { listOfWalls[i].LinearItems[j].Sex = "FM"; } } //Corners are always FF to allow the walls to 'go into' them else if (listOfWalls[i].LinearItems[j].ItemType == "Corner") { listOfWalls[i].LinearItems[j].Sex = "FF"; } else if (listOfWalls[i].LinearItems[j].ItemType == "BoxHeader" || listOfWalls[i].LinearItems[j].ItemType == "HChannel") { listOfWalls[i].LinearItems[j].Sex = "FF"; } //Filler is always MM else if (listOfWalls[i].LinearItems[j].ItemType == "Filler") { listOfWalls[i].LinearItems[j].Sex = "MM"; } else if (listOfWalls[i].LinearItems[j].ItemType == "Mod") { //If previous linear item ends with male receiever, this mod must be female if (listOfWalls[i].LinearItems[j - 1].Sex.Substring(1) == "M") { listOfWalls[i].LinearItems[j].Sex = "FF"; } else { listOfWalls[i].LinearItems[j].Sex = "MM"; } try { //If a filler is after this mod, we must make the mod end in female if (listOfWalls[i].LinearItems[j + 1].ItemType == "Filler") { listOfWalls[i].LinearItems[j].Sex = listOfWalls[i].LinearItems[j].Sex.Substring(0, 1) + "F"; } //If a receiver is after this mod, we must make the mod end in male else if (listOfWalls[i].LinearItems[j + 1].ItemType == "Receiver") { listOfWalls[i].LinearItems[j].Sex = listOfWalls[i].LinearItems[j].Sex.Substring(0, 1) + "M"; } //If a boxheader is after this mod, we must make the mod end in male else if (listOfWalls[i].LinearItems[j + 1].ItemType == "BoxHeader") { listOfWalls[i].LinearItems[j].Sex = listOfWalls[i].LinearItems[j].Sex.Substring(0, 1) + "M"; } } catch (Exception ex) { //if we throw an exception, this is the very last linear item in the wall //If it is the last linear item in the wall, that means that a mod goes directly into a corner post //Adjust mod to end male to go into corner post listOfWalls[i].LinearItems[j].Sex = listOfWalls[i].LinearItems[j].Sex.Substring(0, 1) + "M"; } } } } Session.Add("listOfWalls", listOfWalls); Session.Add("sunroomProjection", hidRoomProjection.Value); Session.Add("sunroomWidth", hidRoomWidth.Value); if (Session["newProjectHasRoof"].ToString() == "Yes") { Response.Redirect("RoofWizard.aspx"); } else if (Session["newProjectPrefabFloor"].ToString() == "Yes") { Response.Redirect("WizardFloors.aspx"); } else { Response.Redirect("ProjectPreview.aspx"); } }