public void SaveChanges(IDictionary context) { //WidthValidator.Validate(); //LengthValidator.Validate(); //HeightValidator.Validate(); if (!chbDimensions.Checked || (chbDimensions.Checked && Page.IsValid)) { ShippingMethodDto dto = (ShippingMethodDto)context[_ShippingMethodDtoString]; ShippingMethodDto.PackageRow row = null; if (dto == null) { // dto must be created in base Package edit control that holds tabs return; } // create the row if it doesn't exist; or update its modified date if it exists if (dto.Package.Count > 0) { row = dto.Package[0]; } else { row = dto.Package.NewPackageRow(); row.ApplicationId = OrderConfiguration.Instance.ApplicationId; } // fill the row with values row.Name = tbName.Text; row.Description = tbDescription.Text; if (chbDimensions.Checked) { row.Width = double.Parse(tbWidth.Text); row.Length = double.Parse(tbLength.Text); row.Height = double.Parse(tbHeight.Text); } else { row.Width = 0; row.Height = 0; row.Length = 0; } // add the row to the dto if (row.RowState == DataRowState.Detached) { dto.Package.Rows.Add(row); } } else { chbDimensions.Checked = false; } }
private void BindForm() { if (_ShippingMethodDto != null && _ShippingMethodDto.Package.Count > 0) { try { ShippingMethodDto.PackageRow packageRow = _ShippingMethodDto.Package[0]; this.tbName.Text = packageRow.Name; try { this.tbDescription.Text = packageRow.Description; } catch { this.tbDescription.Text = ""; } if (packageRow.Width > 0) { this.tbWidth.Text = packageRow.Width.ToString("F2", nfi); } else { this.tbWidth.Enabled = false; } if (packageRow.Height > 0) { this.tbHeight.Text = packageRow.Height.ToString("F2", nfi); } else { this.tbHeight.Enabled = false; } if (packageRow.Length > 0) { this.tbLength.Text = packageRow.Length.ToString("F2", nfi); } else { this.tbLength.Enabled = false; } chbDimensions.Checked = packageRow.Width > 0 && packageRow.Length > 0 && packageRow.Height > 0; } catch (Exception ex) { DisplayErrorMessage("Error during binding form: " + ex.Message); } } }
protected string GetPackageNameById(int packageId) { string name = String.Empty; ShippingMethodDto dto = GetPackages(); if (dto != null) { ShippingMethodDto.PackageRow packageRow = dto.Package.FindByPackageId(packageId); name = packageRow.Name; } return(name); }