private Models.ZoneMap CreateZoneMap(int?copyFromZoneMapID = null) { //Create a new zone map and assign entered values var zoneType = (eZoneType)int.Parse(cboZoneType.SelectedValue); var zoneMap = new Models.ZoneMap { ZoneType = zoneType, Description = txtZoneMapDescription.Text, IsEnabled = true, }; using (var uow = DIContainer.CreateUnitOfWork()) { var repo = DIContainer.CreateRepository <Repositories.IZoneMapRepository>(uow); repo.Add(zoneMap); //Save changes to database uow.SaveChanges(); if (copyFromZoneMapID.HasValue) { repo.ZoneMapCopyZones(copyFromZoneMapID.Value, zoneMap.ZoneMapID); } } //and return the new zone map with its assigned ZoneMapID return(zoneMap); }
private void LoadZones(Models.ZoneMap zoneMap) { //Reset the hidden field that holds the selected cellIds hidZoneChanges.Value = string.Empty; HtmlTableRow tr = null; HtmlTableCell td = null; //For each ZoneMap Zone foreach (var zone in zoneMap.Zones.OrderBy(z => z.Description)) { tr = new HtmlTableRow(); tr.Attributes.Add("class", "GridRow_Orchestrator"); grdZones.Rows.Add(tr); //Add a cell for the Zone td = new HtmlTableCell(); tr.Cells.Add(td); //Create a new input box and add it to the cell //Set the cells id so that it indicates to Zone and Pallets TextBox input = new TextBox(); td.Controls.Add(input); input.ID = string.Format("cell:{0}", zone.ZoneID); input.Text = zone.Description; //Each input box will call a function when its value is changed so that //the cell colour can be changed and the id of th input recorded in the hidden field input.Attributes.Add("onchange", "Zone_onchange(this);"); } int newZones = 10; for (int i = 0; i < newZones; i++) { tr = new HtmlTableRow(); tr.Attributes.Add("class", "GridRow_Orchestrator"); grdZones.Rows.Add(tr); //Add a cell for the Zone td = new HtmlTableCell(); tr.Cells.Add(td); //Create a new input box and add it to the cell //Set the cells id so that it indicates to Zone and Pallets TextBox input = new TextBox(); td.Controls.Add(input); input.ID = string.Format("new:{0}", i); //Each input box will call a function when its value is chnaged so that //the cell colour can be changed and the id of th input recorded in the hidden field input.Attributes.Add("onchange", "Zone_onchange(this);"); } }