private void LoadBlock() { if (this.BvinField.Value.Trim().Length > 0) { PolicyBlock b = MTApp.ContentServices.Policies.FindBlock(this.BvinField.Value); if (b != null) { this.NameField.Text = b.Name; this.DescriptionField.Text = b.Description; if (this.DescriptionField.SupportsTransform == true) { if (b.DescriptionPreTransform.Trim().Length > 0) { this.DescriptionField.Text = b.DescriptionPreTransform; } } this.PolicyIdField.Value = b.PolicyID; } } }
private bool Save() { bool result = false; PolicyBlock b; b = MTApp.ContentServices.Policies.FindBlock(this.BvinField.Value); if (b == null) { b = new PolicyBlock(); } b.Name = this.NameField.Text.Trim(); b.Description = this.DescriptionField.Text.Trim(); b.DescriptionPreTransform = this.DescriptionField.PreTransformText; Policy p = MTApp.ContentServices.Policies.Find(this.PolicyIdField.Value); if (this.BvinField.Value == string.Empty) { b.PolicyID = this.PolicyIdField.Value; if (p != null) { p.Blocks.Add(b); result = MTApp.ContentServices.Policies.Update(p); } } else { result = MTApp.ContentServices.Policies.UpdateBlock(b); } if (result == true) { // Update bvin field so that next save will call updated instead of create this.BvinField.Value = b.Bvin; } return(result); }
protected void GridView1_RowDataBound(object sender, System.Web.UI.WebControls.GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { PolicyBlock b = (PolicyBlock)e.Row.DataItem; if (b != null) { Label lblBlockName = (Label)e.Row.FindControl("lblBlockName"); Label lblBlockDescription = (Label)e.Row.FindControl("lblBlockDescription"); if (lblBlockName != null) { lblBlockName.Text = b.Name; } if (lblBlockDescription != null) { lblBlockDescription.Text = b.Description; } } } }