protected override void WriteSaveEventCode() { Writer.PushIdentationLevel(); Writer.IncreaseIdentation(); Writer.IncreaseIdentation(); Writer.IncreaseIdentation(); for (int i = 0; i < ValidationColumns.Count; i++) { ColumnValidation cv = ValidationColumns[i]; string colName = GetCanonicalIdentifier(cv.Name); if (cv.DataType == "timestamp") { Writer.WriteLine("if( (( DataRowView ){0}BindingSource.Current )[ \"{1}\" ] is DBNull )", CanonicalTableName, colName); Writer.WriteLine("{"); Writer.WriteLine("((DataRowView){0}BindingSource.Current)[\"{1}\"] = DateTime.Now;", CanonicalTableName, colName); Writer.WriteLine("}"); } } Writer.WriteLine("{0}BindingSource.EndEdit();", CanonicalTableName); Writer.WriteLine("{0}BindingSource.EndEdit();", CanonicalDetailTableName); Writer.WriteLine("ad.Update(this.newDataSet.{0});", CanonicalTableName); Writer.WriteLine("ad{0}.Update(this.newDataSet.{0});", CanonicalDetailTableName); Writer.PopIdentationLevel(); }
protected override void WriteSaveEventCode() { Writer.PushIdentationLevel(); Writer.IncreaseIdentation(); Writer.IncreaseIdentation(); Writer.IncreaseIdentation(); for (int i = 0; i < ValidationColumns.Count; i++) { ColumnValidation cv = ValidationColumns[i]; string colName = GetCanonicalIdentifier(cv.Name); if (cv.DataType == "timestamp") { Writer.WriteLine("If TypeOf( CType({0}BindingSource.Current, DataRowView )( \"{1}\" ) ) Is DBNull Then ", CanonicalTableName, colName); Writer.WriteLine(" CType({0}BindingSource.Current, DataRowView )(\"{1}\") = DateTime.Now", CanonicalTableName, colName); Writer.WriteLine("End If"); } } Writer.WriteLine("{0}BindingSource.EndEdit()", CanonicalTableName); Writer.WriteLine("{0}BindingSource.EndEdit()", CanonicalDetailTableName); Writer.WriteLine("ad.Update(Me.newDataSet.{0})", CanonicalTableName); Writer.WriteLine("ad{0}.Update(Me.newDataSet.{0})", CanonicalDetailTableName); Writer.PopIdentationLevel(); }
protected override void WriteFormLoadCode() { Writer.PushIdentationLevel(); Writer.IncreaseIdentation(); Writer.IncreaseIdentation(); Writer.IncreaseIdentation(); Writer.WriteLine("ctx = New Model1Entities()"); if (DataAccessTech == DataAccessTechnology.EntityFramework5) { Writer.WriteLine("Dim _entities As ObjectResult(Of {0}) = ctx.{0}.Execute(MergeOption.AppendOnly)", CanonicalTableName); } else if (DataAccessTech == DataAccessTechnology.EntityFramework6) { Writer.WriteLine("ctx.{0}.Load()", CanonicalTableName); Writer.WriteLine("Dim _entities As BindingList(Of {0}) = ctx.{0}.Local.ToBindingList()", CanonicalTableName); Writer.WriteLine("AddHandler {0}BindingSource.CurrentChanged, AddressOf {0}BindingSource_CurrentChanged", CanonicalTableName); } Writer.WriteLine("{0}BindingSource.DataSource = _entities", CanonicalTableName); for (int i = 0; i < ValidationColumns.Count; i++) { ColumnValidation cv = ValidationColumns[i]; string colName = cv.Name; string idColumnCanonical = GetCanonicalIdentifier(colName); if (cv.HasLookup) { string canonicalReferencedTableName = GetCanonicalIdentifier(cv.FkInfo.ReferencedTableName); Writer.WriteLine("Me.{0}_comboBox.DataSource = ctx.{1}.ToList()", idColumnCanonical, canonicalReferencedTableName); Writer.WriteLine("Me.{0}_comboBox.DisplayMember = \"{1}\"", idColumnCanonical, cv.EfLookupColumnMapping); Writer.WriteLine("Me.{0}_comboBox.ValueMember = \"{1}\"", idColumnCanonical, cv.FkInfo.ReferencedColumnName); Writer.WriteLine("Me.{0}_comboBox.DataBindings.Add(New System.Windows.Forms.Binding(\"SelectedValue\", Me.{1}BindingSource, \"{2}\", True))", idColumnCanonical, CanonicalTableName, cv.EfColumnMapping); } else if (cv.IsDateType()) { Writer.WriteLine("Me.{0}_dateTimePicker.DataBindings.Add(New System.Windows.Forms.Binding(\"Text\", Me.{2}BindingSource, \"{1}\", True ))", idColumnCanonical, cv.EfColumnMapping, CanonicalTableName); } else if (cv.IsBooleanType()) { Writer.WriteLine("Me.{0}CheckBox.DataBindings.Add(New System.Windows.Forms.Binding(\"Checked\", Me.{2}BindingSource, \"{1}\", True))", idColumnCanonical, cv.EfColumnMapping, CanonicalTableName); } else { Writer.WriteLine("Me.{0}TextBox.DataBindings.Add(New System.Windows.Forms.Binding(\"Text\", Me.{2}BindingSource, \"{1}\", True ))", idColumnCanonical, cv.EfColumnMapping, CanonicalTableName); } } Writer.WriteLine("{0}BindingSource.DataSource = {1}BindingSource", CanonicalDetailTableName, CanonicalTableName); Writer.WriteLine("{0}BindingSource.DataMember = \"{0}\"", CanonicalDetailTableName); WriteDataGridColumnInitialization(); Writer.WriteLine("dataGridView1.DataSource = {0}BindingSource", CanonicalDetailTableName); Writer.PopIdentationLevel(); }
internal override string GetDataSourceForCombo(ColumnValidation cv) { string colName = cv.Name; string idColumnCanonical = GetCanonicalIdentifier(colName); string canonicalReferencedTableName = GetCanonicalIdentifier(cv.FkInfo.ReferencedTableName); return(string.Format("ctx.{1}.ToList()", idColumnCanonical, canonicalReferencedTableName)); }
void grdColumns_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { if (e.Control is DataGridViewComboBoxEditingControl) { DataGridViewComboBoxEditingControl cb = e.Control as DataGridViewComboBoxEditingControl; ColumnValidation cv = _colValsByName[(string)grdColumns.CurrentRow.Cells[0].Value]; cb.DataSource = cv.ReferenceableColumns; } }
internal override string GetDataSourceForCombo(ColumnValidation cv) { string colName = cv.Name; string idColumnCanonical = GetCanonicalIdentifier(colName); string canonicalReferencedTableName = GetCanonicalIdentifier(cv.FkInfo.ReferencedTableName); Writer.WriteLine("if( ad2 != null ) ad2.Dispose();"); Writer.WriteLine("ad2 = new MySql.Data.MySqlClient.MySqlDataAdapter(\"select * from `{0}`\", strConn2);", cv.FkInfo.ReferencedTableName); Writer.WriteLine("ad2.Fill(this.newDataSet.{0});", canonicalReferencedTableName); return(string.Format("this.newDataSet.{0}", canonicalReferencedTableName)); }
protected override void WriteFormLoadCode() { Writer.PushIdentationLevel(); Writer.IncreaseIdentation(); Writer.IncreaseIdentation(); Writer.IncreaseIdentation(); Writer.WriteLine("ctx = new Model1Entities();"); if (DataAccessTech == DataAccessTechnology.EntityFramework5) { Writer.WriteLine("ObjectResult<{0}> _entities = ctx.{0}.Execute(MergeOption.AppendOnly);", CanonicalTableName); } else if (DataAccessTech == DataAccessTechnology.EntityFramework6) { Writer.WriteLine("ctx.{0}.Load();", CanonicalTableName); Writer.WriteLine("BindingList<{0}> _entities = ctx.{0}.Local.ToBindingList();", CanonicalTableName); } Writer.WriteLine("{0}BindingSource.DataSource = _entities;", CanonicalTableName); for (int i = 0; i < ValidationColumns.Count; i++) { ColumnValidation cv = ValidationColumns[i]; string colName = cv.Name; string idColumnCanonical = GetCanonicalIdentifier(colName); if (cv.HasLookup) { string canonicalReferencedTableName = GetCanonicalIdentifier(cv.FkInfo.ReferencedTableName); Writer.WriteLine("this.{0}_comboBox.DataSource = ctx.{1}.ToList();", idColumnCanonical, canonicalReferencedTableName); Writer.WriteLine("this.{0}_comboBox.DisplayMember = \"{1}\";", idColumnCanonical, cv.EfLookupColumnMapping); Writer.WriteLine("this.{0}_comboBox.ValueMember = \"{1}\";", idColumnCanonical, cv.FkInfo.ReferencedColumnName); Writer.WriteLine("this.{0}_comboBox.DataBindings.Add(new System.Windows.Forms.Binding(\"SelectedValue\", this.{1}BindingSource, \"{2}\", true));", idColumnCanonical, CanonicalTableName, cv.EfColumnMapping); } else if (cv.IsDateType()) { Writer.WriteLine("this.{0}_dateTimePicker.DataBindings.Add(new System.Windows.Forms.Binding(\"Text\", this.{2}BindingSource, \"{1}\", true ));", idColumnCanonical, cv.EfColumnMapping, CanonicalTableName); } else if (cv.IsBooleanType()) { Writer.WriteLine("this.{0}CheckBox.DataBindings.Add(new System.Windows.Forms.Binding(\"Checked\", this.{2}BindingSource, \"{1}\", true));", idColumnCanonical, cv.EfColumnMapping, CanonicalTableName); } else { Writer.WriteLine("this.{0}TextBox.DataBindings.Add(new System.Windows.Forms.Binding(\"Text\", this.{2}BindingSource, \"{1}\", true ));", idColumnCanonical, cv.EfColumnMapping, CanonicalTableName); } } Writer.PopIdentationLevel(); }
internal override string GetDataSourceForCombo(ColumnValidation cv) { string colName = cv.Name; string idColumnCanonical = GetCanonicalIdentifier(colName); string canonicalReferencedTableName = GetCanonicalIdentifier(cv.FkInfo.ReferencedTableName); Writer.WriteLine("If Not ( ad2 Is Nothing ) Then"); Writer.WriteLine("ad2.Dispose()"); Writer.WriteLine("End If"); Writer.WriteLine("ad2 = New MySql.Data.MySqlClient.MySqlDataAdapter(\"select * from `{0}`\", strConn2)", cv.FkInfo.ReferencedTableName); Writer.WriteLine("ad2.Fill(Me.newDataSet.{0})", canonicalReferencedTableName); return(string.Format("Me.newDataSet.{0}", canonicalReferencedTableName)); }
protected override void WriteDesignerControlDeclCode() { Writer.PushIdentationLevel(); Writer.IncreaseIdentation(); Writer.IncreaseIdentation(); Writer.WriteLine("Friend WithEvents newDataSet As NewDataSet "); Writer.WriteLine("Friend WithEvents {0}BindingSource As System.Windows.Forms.BindingSource", CanonicalTableName); for (int i = 0; i < ValidationColumns.Count; i++) { ColumnValidation cv = ValidationColumns[i]; string idColumnCanonical = GetCanonicalIdentifier(cv.Name); if (cv.HasLookup) { Writer.WriteLine("Friend WithEvents {0}_comboBox As System.Windows.Forms.ComboBox", idColumnCanonical); } else if (cv.IsDateType()) { Writer.WriteLine("Friend WithEvents {0}_dateTimePicker As System.Windows.Forms.DateTimePicker", idColumnCanonical); } else if (cv.IsBooleanType()) { Writer.WriteLine("Friend WithEvents {0}CheckBox As System.Windows.Forms.CheckBox", idColumnCanonical); } else { Writer.WriteLine("Friend WithEvents {0}TextBox As System.Windows.Forms.TextBox", idColumnCanonical); } Writer.WriteLine("Friend WithEvents {0}Label As System.Windows.Forms.Label", idColumnCanonical); } Writer.WriteLine("Friend WithEvents {0}BindingSource As System.Windows.Forms.BindingSource", CanonicalDetailTableName); Writer.WriteLine("Friend WithEvents dataGridView1 As System.Windows.Forms.DataGridView"); Writer.WriteLine("Friend WithEvents panel2 As System.Windows.Forms.Panel"); Writer.WriteLine("Friend WithEvents panel3 As System.Windows.Forms.Panel"); Writer.WriteLine("Friend WithEvents panel4 As System.Windows.Forms.Panel"); Writer.WriteLine("Friend WithEvents panel5 As System.Windows.Forms.Panel"); Writer.WriteLine("Friend WithEvents lblDetails As System.Windows.Forms.Label"); Writer.PopIdentationLevel(); }
protected override void WriteDesignerControlDeclCode() { Writer.PushIdentationLevel(); Writer.IncreaseIdentation(); Writer.IncreaseIdentation(); Writer.WriteLine("private NewDataSet newDataSet;"); Writer.WriteLine("private System.Windows.Forms.BindingSource {0}BindingSource;", CanonicalTableName); for (int i = 0; i < ValidationColumns.Count; i++) { ColumnValidation cv = ValidationColumns[i]; string idColumnCanonical = GetCanonicalIdentifier(cv.Name); if (cv.HasLookup) { Writer.WriteLine("private System.Windows.Forms.ComboBox {0}_comboBox;", idColumnCanonical); } else if (cv.IsDateType()) { Writer.WriteLine("private System.Windows.Forms.DateTimePicker {0}_dateTimePicker;", idColumnCanonical); } else if (cv.IsBooleanType()) { Writer.WriteLine("private System.Windows.Forms.CheckBox {0}CheckBox;", idColumnCanonical); } else { Writer.WriteLine("private System.Windows.Forms.TextBox {0}TextBox;", idColumnCanonical); } Writer.WriteLine("private System.Windows.Forms.Label {0}Label;", idColumnCanonical); } Writer.WriteLine("private System.Windows.Forms.BindingSource {0}BindingSource;", CanonicalDetailTableName); Writer.WriteLine("private System.Windows.Forms.DataGridView dataGridView1;"); Writer.WriteLine("private System.Windows.Forms.Panel panel2;"); Writer.WriteLine("private System.Windows.Forms.Label lblDetails;"); Writer.WriteLine("private System.Windows.Forms.Panel panel3;"); Writer.WriteLine("private System.Windows.Forms.Panel panel4;"); Writer.WriteLine("private System.Windows.Forms.Panel panel5;"); Writer.PopIdentationLevel(); }
protected override void WriteFormLoadCode() { Writer.PushIdentationLevel(); Writer.IncreaseIdentation(); Writer.IncreaseIdentation(); Writer.IncreaseIdentation(); Writer.WriteLine("Dim strConn As String = \"{0};\"", ConnectionString); Writer.WriteLine("ad = New MySqlDataAdapter(\"select * from `{0}`\", strConn)", TableName); Writer.WriteLine("Dim builder As MySqlCommandBuilder = New MySqlCommandBuilder(ad)"); Writer.WriteLine("ad.Fill(Me.newDataSet.{0})", CanonicalTableName); Writer.WriteLine("ad.DeleteCommand = builder.GetDeleteCommand()"); Writer.WriteLine("ad.UpdateCommand = builder.GetUpdateCommand()"); Writer.WriteLine("ad.InsertCommand = builder.GetInsertCommand()"); Writer.WriteLine("Dim ad3 As MySqlDataAdapter"); for (int i = 0; i < ValidationColumns.Count; i++) { ColumnValidation cv = ValidationColumns[i]; if (cv.HasLookup) { string colName = cv.Name; string idColumnCanonical = GetCanonicalIdentifier(colName); string canonicalReferencedTable = GetCanonicalIdentifier(cv.FkInfo.ReferencedTableName); Writer.WriteLine("ad3 = New MySqlDataAdapter(\"select * from `{0}`\", strConn)", cv.FkInfo.ReferencedTableName); Writer.WriteLine("ad3.Fill(Me.newDataSet.{0})", canonicalReferencedTable); Writer.WriteLine("Me.{0}_comboBox.DataSource = Me.newDataSet.{1}", idColumnCanonical, canonicalReferencedTable); Writer.WriteLine("Me.{0}_comboBox.DisplayMember = \"{1}\"", idColumnCanonical, cv.EfLookupColumnMapping); Writer.WriteLine("Me.{0}_comboBox.ValueMember = \"{1}\"", idColumnCanonical, cv.FkInfo.ReferencedColumnName); Writer.WriteLine("Me.{0}_comboBox.DataBindings.Add(New System.Windows.Forms.Binding(\"SelectedValue\", Me.{1}BindingSource, \"{2}\", True))", idColumnCanonical, CanonicalTableName, cv.EfColumnMapping); Writer.WriteLine("ad3.Dispose()"); } } Writer.PopIdentationLevel(); }
protected override void WriteValidationCode() { bool validationsEnabled = ValidationsEnabled; List <ColumnValidation> validationColumns = ValidationColumns; Writer.PushIdentationLevel(); Writer.IncreaseIdentation(); Writer.IncreaseIdentation(); if (validationsEnabled) { for (int i = 0; i < validationColumns.Count; i++) { ColumnValidation cv = validationColumns[i]; if (cv.IsDateType() || cv.IsReadOnly() || cv.IsBooleanType()) { continue; } string idColumnCanonical = GetCanonicalIdentifier(cv.Column.ColumnName); if (cv.HasLookup && cv.Required) { Writer.WriteLine("private void {0}_comboBox_Validating(object sender, CancelEventArgs e)", idColumnCanonical); Writer.WriteLine("{"); Writer.WriteLine("int i = {0}_comboBox.SelectedIndex;", idColumnCanonical); Writer.WriteLine("e.Cancel = false;"); Writer.WriteLine("if( i == -1 )"); Writer.WriteLine("{"); Writer.WriteLine("e.Cancel = true; "); Writer.WriteLine("errorProvider1.SetError({0}_comboBox, \"Must select a {0}\");", idColumnCanonical); Writer.WriteLine("}"); Writer.WriteLine("if( !e.Cancel )"); Writer.WriteLine("{"); Writer.WriteLine("errorProvider1.SetError({0}_comboBox, \"\");", idColumnCanonical); Writer.WriteLine("}"); Writer.WriteLine("}"); continue; } Writer.WriteLine("private void {0}TextBox_Validating(object sender, CancelEventArgs e)", idColumnCanonical); Writer.WriteLine("{"); Writer.WriteLine("e.Cancel = false;"); if (cv.Required) { Writer.WriteLine("if( string.IsNullOrEmpty( {0}TextBox.Text ) )", idColumnCanonical); Writer.WriteLine("{"); Writer.WriteLine("e.Cancel = true;"); Writer.WriteLine("errorProvider1.SetError( {0}TextBox, \"The field {1} is required\" ); ", idColumnCanonical, cv.Name); Writer.WriteLine("}"); } if (cv.IsNumericType()) { string numericType = ""; if (cv.IsIntegerType()) { numericType = "int"; } else if (cv.IsFloatingPointType()) { numericType = "double"; } Writer.WriteLine("{0} v;", numericType); Writer.WriteLine("string s = {0}TextBox.Text;", idColumnCanonical); if (!string.IsNullOrEmpty(numericType)) { Writer.WriteLine("if( !{0}.TryParse( s, out v ) )", numericType); Writer.WriteLine("{"); } else { // just assume is good Writer.WriteLine("if( true )"); Writer.WriteLine("{"); } Writer.WriteLine("e.Cancel = true;"); Writer.WriteLine("errorProvider1.SetError( {0}TextBox, \"The field {1} must be {2}.\" );", idColumnCanonical, cv.Name, numericType); Writer.WriteLine("}"); if (cv.MinValue != null) { Writer.WriteLine("else if( {0} > v )", cv.MinValue); Writer.WriteLine("{"); Writer.WriteLine("e.Cancel = true;"); Writer.WriteLine("errorProvider1.SetError( {0}TextBox, \"The field {1} must be greater or equal than {2}.\" );", idColumnCanonical, cv.Name, cv.MinValue); Writer.WriteLine("}"); } if (cv.MaxValue != null) { Writer.WriteLine("else if( {0} < v )", cv.MaxValue); Writer.WriteLine("{"); Writer.WriteLine("e.Cancel = true;"); Writer.WriteLine("errorProvider1.SetError( {0}TextBox, \"The field {1} must be lesser or equal than {2}\" );", idColumnCanonical, cv.Name, cv.MaxValue); Writer.WriteLine("} "); } } Writer.WriteLine("if( !e.Cancel ) {{ errorProvider1.SetError( {0}TextBox, \"\" ); }} ", idColumnCanonical); Writer.WriteLine("}"); Writer.WriteLine(); } } Writer.PopIdentationLevel(); }
internal abstract string GetDataSourceForCombo(ColumnValidation cv);
internal override string GetDataSourceForCombo(ColumnValidation cv) { throw new NotImplementedException(); }
protected void WriteValidationCodeDetailsGrid() { bool validationsEnabled = ValidationsEnabled; if (!validationsEnabled) { return; } List <ColumnValidation> validationColumns = GetValidationColumns(); Writer.PushIdentationLevel(); Writer.IncreaseIdentation(); Writer.IncreaseIdentation(); Writer.WriteLine("Private Sub dataGridView1_CellValidating(sender As Object, e As DataGridViewCellValidatingEventArgs)"); Writer.WriteLine(""); Writer.WriteLine("Dim s As String"); Writer.WriteLine("Dim row As DataGridViewRow= dataGridView1.Rows(e.RowIndex)"); Writer.WriteLine("Dim value As Object = e.FormattedValue"); Writer.WriteLine("e.Cancel = False"); Writer.WriteLine("row.ErrorText = \"\""); Writer.WriteLine("If row.IsNewRow Then"); Writer.WriteLine("Return"); Writer.WriteLine("End If"); for (int i = 0; i < validationColumns.Count; i++) { ColumnValidation cv = validationColumns[i]; if (cv.IsBooleanType() || cv.HasLookup) { continue; } string idColumnCanonical = GetCanonicalIdentifier(cv.Column.ColumnName); Writer.WriteLine("If e.ColumnIndex = {0} Then", i); Writer.WriteLine(""); string numericType = ""; if (cv.IsNumericType()) { if (cv.IsIntegerType()) { numericType = "Integer"; } if (cv.IsFloatingPointType()) { numericType = "Double"; } Writer.WriteLine("Dim v as {0}", numericType); } if (cv.Required) { Writer.WriteLine("If (TypeOf value is DBNull) OrElse String.IsNullOrEmpty( value.ToString() ) Then "); Writer.WriteLine("e.Cancel = True"); Writer.WriteLine("row.ErrorText = \"The field {0} is required\"", cv.Name); Writer.WriteLine("Return"); Writer.WriteLine("End If"); } if (cv.IsNumericType()) { Writer.WriteLine("s = value.ToString()"); if (!string.IsNullOrEmpty(numericType)) { Writer.WriteLine("If Not {0}.TryParse( s, v ) Then", numericType); } else { // just assume is good Writer.WriteLine("If True Then"); } Writer.WriteLine("e.Cancel = True"); Writer.WriteLine("row.ErrorText = \"The field {0} must be {1}.\"", cv.Name, numericType); Writer.WriteLine("Return"); if (cv.MinValue != null) { Writer.WriteLine("ElseIf {0} > v Then", cv.MinValue); Writer.WriteLine("e.Cancel = True"); Writer.WriteLine("row.ErrorText = \"The field {0} must be greater or equal than {1}.\"", cv.Name, cv.MinValue); Writer.WriteLine("Return"); } if (cv.MaxValue != null) { Writer.WriteLine("ElseIf {0} < v Then", cv.MaxValue); Writer.WriteLine("e.Cancel = True"); Writer.WriteLine("row.ErrorText = \"The field {0} must be lesser or equal than {1}\"", cv.Name, cv.MaxValue); Writer.WriteLine("Return"); } Writer.WriteLine("End If"); } Writer.WriteLine("End If"); } Writer.WriteLine("End Sub"); // DataError Writer.WriteLine("Private Sub dataGridView1_DataError(ByVal sender As Object, ByVal e As DataGridViewDataErrorEventArgs)"); Writer.WriteLine("dataGridView1.Rows(e.RowIndex).ErrorText = e.Exception.Message"); Writer.WriteLine("e.Cancel = true"); Writer.WriteLine("End Sub"); Writer.PopIdentationLevel(); }
protected override void WriteControlInitialization(bool addBindings) { Label l = new Label(); Size szText = TextRenderer.MeasureText(GetMaxWidthString(Columns), l.Font); Point initLoc = new Point(szText.Width + 10 + 50, 50); Point xy = new Point(initLoc.X, initLoc.Y); bool passedHalve = false; int tabIdx = 1; bool validationsEnabled = ValidationsEnabled; int i = 0; Writer.PushIdentationLevel(); Writer.IncreaseIdentation(); Writer.IncreaseIdentation(); Writer.IncreaseIdentation(); for (int j = 0; j < ValidationColumns.Count; j++) { ColumnValidation cv = ValidationColumns[j]; string colName = cv.Name; string idColumnCanonical = GetCanonicalIdentifier(colName); // Place half the column input in one column and the other in the second column. if (!passedHalve && ++i > (Columns.Count / 2)) { passedHalve = true; xy.X += 200 + 20 + szText.Width; xy.Y = initLoc.Y; } Writer.WriteLine("//"); Writer.WriteLine("// {0}Label", idColumnCanonical); Writer.WriteLine("//"); Writer.WriteLine("this.{0}Label = new System.Windows.Forms.Label();", idColumnCanonical); Writer.WriteLine("this.{0}Label.AutoSize = true;", idColumnCanonical); Size szLabel = TextRenderer.MeasureText(colName, l.Font); Writer.WriteLine("this.{0}Label.Location = new System.Drawing.Point( {1}, {2} );", idColumnCanonical, xy.X - 10 - szLabel.Width, xy.Y); Writer.WriteLine("this.{0}Label.Name = \"{0}Label\";", idColumnCanonical); Writer.WriteLine("this.{0}Label.Size = new System.Drawing.Size( {1}, {2} );", idColumnCanonical, szLabel.Width, szLabel.Height); Writer.WriteLine("this.{0}Label.TabIndex = {1};", idColumnCanonical, tabIdx++); Writer.WriteLine("this.{0}Label.Text = \"{1}\";", idColumnCanonical, colName); Writer.WriteLine("this.Panel1.Controls.Add( this.{0}Label );", idColumnCanonical); if (cv.HasLookup) { Writer.WriteLine("this.{0}_comboBox = new System.Windows.Forms.ComboBox();", idColumnCanonical); Writer.WriteLine("this.{0}_comboBox.Location = new System.Drawing.Point( {1}, {2} );", idColumnCanonical, xy.X, xy.Y); //Writer.WriteLine("this.{0}_comboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;", idColumnCanonical); Writer.WriteLine("this.{0}_comboBox.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Append;", idColumnCanonical); Writer.WriteLine("this.{0}_comboBox.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems;", idColumnCanonical); Writer.WriteLine("this.{0}_comboBox.FormattingEnabled = true;", idColumnCanonical); Writer.WriteLine("this.{0}_comboBox.Name = \"{0}_comboBox\";", idColumnCanonical); Writer.WriteLine("this.{0}_comboBox.Size = new System.Drawing.Size(206, 21);", idColumnCanonical); Writer.WriteLine("this.{0}_comboBox.TabIndex = {1};", idColumnCanonical, tabIdx++); if (validationsEnabled) { Writer.WriteLine("this.{0}_comboBox.Validating += new System.ComponentModel.CancelEventHandler( this.{0}_comboBox_Validating );", idColumnCanonical); } if (addBindings) { // nothing } Writer.WriteLine("this.Panel1.Controls.Add( this.{0}_comboBox );", idColumnCanonical); } else if (cv.IsDateType()) { Writer.WriteLine("//"); Writer.WriteLine("// {0}_dateTimePicker", idColumnCanonical); Writer.WriteLine("//"); Writer.WriteLine("this.{0}_dateTimePicker = new System.Windows.Forms.DateTimePicker();", idColumnCanonical); if (cv.IsDateTimeType()) { Writer.WriteLine("this.{0}_dateTimePicker.CustomFormat = \"dd/MM/yyyy, hh:mm\"; ", idColumnCanonical); } else { Writer.WriteLine("this.{0}_dateTimePicker.CustomFormat = \"dd/MM/yyyy\"; ", idColumnCanonical); } Writer.WriteLine("this.{0}_dateTimePicker.Format = System.Windows.Forms.DateTimePickerFormat.Custom;", idColumnCanonical); Writer.WriteLine("this.{0}_dateTimePicker.Location = new System.Drawing.Point({1}, {2});", idColumnCanonical, xy.X, xy.Y); Writer.WriteLine("this.{0}_dateTimePicker.Name = \"{0}_dateTimePicker\";", idColumnCanonical); Writer.WriteLine("this.{0}_dateTimePicker.Size = new System.Drawing.Size(200, 20);", idColumnCanonical); Writer.WriteLine("this.{0}_dateTimePicker.TabIndex = {1};", idColumnCanonical, tabIdx++); Writer.WriteLine("this.{0}_dateTimePicker.Value = new System.DateTime(2014, 5, 26, 17, 35, 11, 0);", idColumnCanonical); if (addBindings) { Writer.WriteLine("this.{0}_dateTimePicker.DataBindings.Add(new System.Windows.Forms.Binding(\"Text\", this.{2}BindingSource, \"{1}\", true ));", idColumnCanonical, cv.EfColumnMapping, CanonicalTableName); } Writer.WriteLine("this.Panel1.Controls.Add( this.{0}_dateTimePicker );", idColumnCanonical); } else if (cv.IsBooleanType()) { Writer.WriteLine("//"); Writer.WriteLine("//{0}CheckBox", idColumnCanonical); Writer.WriteLine("//"); Writer.WriteLine("this.{0}CheckBox = new System.Windows.Forms.CheckBox();", idColumnCanonical); Writer.WriteLine("this.{0}CheckBox.AutoSize = true;", idColumnCanonical); Writer.WriteLine("this.{0}CheckBox.Location = new System.Drawing.Point({1}, {2});", idColumnCanonical, xy.X, xy.Y + 3); Writer.WriteLine("this.{0}CheckBox.Name = \"{0}CheckBox\";", idColumnCanonical); Writer.WriteLine("this.{0}CheckBox.Size = new System.Drawing.Size(15, 14);", idColumnCanonical); Writer.WriteLine("this.{0}CheckBox.TabIndex = {1};", idColumnCanonical, tabIdx++); Writer.WriteLine("this.{0}CheckBox.UseVisualStyleBackColor = true;", idColumnCanonical); Writer.WriteLine("this.Panel1.Controls.Add( this.{0}CheckBox );", idColumnCanonical); if (addBindings) { Writer.WriteLine("this.{0}CheckBox.DataBindings.Add(new System.Windows.Forms.Binding(\"Checked\", this.{2}BindingSource, \"{1}\", true));", idColumnCanonical, cv.EfColumnMapping, CanonicalTableName); } } else { Writer.WriteLine("//"); Writer.WriteLine("// {0}TextBox", idColumnCanonical); Writer.WriteLine("//"); Writer.WriteLine("this.{0}TextBox = new System.Windows.Forms.TextBox();", idColumnCanonical); if (addBindings) { Writer.WriteLine("this.{0}TextBox.DataBindings.Add(new System.Windows.Forms.Binding(\"Text\", this.{2}BindingSource, \"{1}\", true ));", idColumnCanonical, cv.EfColumnMapping, CanonicalTableName); } Writer.WriteLine("this.{0}TextBox.Location = new System.Drawing.Point( {1}, {2} );", idColumnCanonical, xy.X, xy.Y); Writer.WriteLine("this.{0}TextBox.Name = \"{0}TextBox\";", idColumnCanonical); Writer.WriteLine("this.{0}TextBox.Size = new System.Drawing.Size( {1}, {2} );", idColumnCanonical, 100, 20); Writer.WriteLine("this.{0}TextBox.TabIndex = {1};", idColumnCanonical, tabIdx++); if (cv.MaxLength.HasValue) { Writer.WriteLine("this.{0}TextBox.MaxLength = {1};", idColumnCanonical, cv.MaxLength.Value); } if (cv.IsReadOnly()) { Writer.WriteLine("this.{0}TextBox.Enabled = false;", idColumnCanonical); } else if (validationsEnabled) { Writer.WriteLine("this.{0}TextBox.Validating += new System.ComponentModel.CancelEventHandler( this.{0}TextBox_Validating );", idColumnCanonical); } Writer.WriteLine("this.Panel1.Controls.Add( this.{0}TextBox);", idColumnCanonical); } xy.Y += szText.Height * 2; } Writer.PopIdentationLevel(); }
protected override void WriteFormLoadCode() { Writer.PushIdentationLevel(); Writer.IncreaseIdentation(); Writer.IncreaseIdentation(); Writer.IncreaseIdentation(); Writer.WriteLine("Dim strConn As string = \"{0};\"", ConnectionString); Writer.WriteLine("ad = new MySqlDataAdapter(\"select * from `{0}`\", strConn)", TableName); Writer.WriteLine("Dim builder As MySqlCommandBuilder = New MySqlCommandBuilder(ad)"); Writer.WriteLine("ad.Fill(Me.newDataSet.{0})", CanonicalTableName); Writer.WriteLine("ad.DeleteCommand = builder.GetDeleteCommand()"); Writer.WriteLine("ad.UpdateCommand = builder.GetUpdateCommand()"); Writer.WriteLine("ad.InsertCommand = builder.GetInsertCommand()"); Writer.WriteLine("ad{0} = New MySqlDataAdapter(\"select * from `{1}`\", strConn)", CanonicalDetailTableName, DetailTableName); Writer.WriteLine("builder = New MySqlCommandBuilder(ad{0})", CanonicalDetailTableName); Writer.WriteLine("ad{0}.Fill(Me.newDataSet.{0})", CanonicalDetailTableName); Writer.WriteLine("ad{0}.DeleteCommand = builder.GetDeleteCommand()", CanonicalDetailTableName); Writer.WriteLine("ad{0}.UpdateCommand = builder.GetUpdateCommand()", CanonicalDetailTableName); Writer.WriteLine("ad{0}.InsertCommand = builder.GetInsertCommand()", CanonicalDetailTableName); RetrieveFkColumns(); StringBuilder sbSrcCols = new StringBuilder("new DataColumn() { "); StringBuilder sbDstCols = new StringBuilder("new DataColumn() { "); for (int i = 0; i < FkColumnsSource.Count; i++) { // Both FkColumnsSource & FkColumnsDest have the item count sbSrcCols.AppendFormat(" newDataSet.{0}.Columns( \"{1}\" )", CanonicalTableName, FkColumnsSource[i]); sbDstCols.AppendFormat(" newDataSet.{0}.Columns( \"{1}\" ) ", CanonicalDetailTableName, FkColumnsDest[i]); } sbSrcCols.Append("}"); sbDstCols.Append("}"); Writer.WriteLine("newDataSet.Relations.Add( New DataRelation( \"{0}\", {1}, {2} ) )", ConstraintName, sbSrcCols.ToString(), sbDstCols.ToString()); Writer.WriteLine("Dim ad3 As MySqlDataAdapter"); for (int i = 0; i < ValidationColumns.Count; i++) { ColumnValidation cv = ValidationColumns[i]; if (cv.HasLookup) { string colName = cv.Name; string idColumnCanonical = GetCanonicalIdentifier(colName); string canonicalReferencedTable = GetCanonicalIdentifier(cv.FkInfo.ReferencedTableName); Writer.WriteLine("ad3 = New MySqlDataAdapter(\"select * from `{0}`\", strConn)", cv.FkInfo.ReferencedTableName); Writer.WriteLine("ad3.Fill(Me.newDataSet.{0})", canonicalReferencedTable); Writer.WriteLine("Me.{0}_comboBox.DataSource = Me.newDataSet.{1}", idColumnCanonical, canonicalReferencedTable); Writer.WriteLine("Me.{0}_comboBox.DisplayMember = \"{1}\"", idColumnCanonical, cv.EfLookupColumnMapping); Writer.WriteLine("Me.{0}_comboBox.ValueMember = \"{1}\"", idColumnCanonical, cv.FkInfo.ReferencedColumnName); Writer.WriteLine("Me.{0}_comboBox.DataBindings.Add(New System.Windows.Forms.Binding(\"SelectedValue\", Me.{1}BindingSource, \"{2}\", True))", idColumnCanonical, CanonicalTableName, cv.EfColumnMapping); Writer.WriteLine("ad3.Dispose()"); } } Writer.WriteLine("{0}BindingSource.DataSource = {1}BindingSource", CanonicalDetailTableName, CanonicalTableName); Writer.WriteLine("{0}BindingSource.DataMember = \"{1}\"", CanonicalDetailTableName, ConstraintName); WriteDataGridColumnInitialization(); Writer.WriteLine("dataGridView1.DataSource = {0}BindingSource", CanonicalDetailTableName); Writer.PopIdentationLevel(); }
private static IEnumerable <ModelClientValidationRule> GetClientValidationRule(this ColumnValidation validation, string columnName) { switch (validation.ValidationType) { case ValidationType.Required: return(new[] { new ModelClientValidationRequiredRule(string.Format(validation.ErrorMessage, columnName)) }); case ValidationType.Unique: return(new[] { new ModelClientValidationRequiredRule(string.Format(validation.ErrorMessage, columnName)) }); case ValidationType.StringLength: var stringLength = (StringLengthValidation)validation; return(new[] { new ModelClientValidationStringLengthRule(string.Format(validation.ErrorMessage, columnName), stringLength.Min, stringLength.Max) }); case ValidationType.Range: var rangeValidation = (RangeValidation)validation; return(new[] { new ModelClientValidationRangeRule(string.Format(validation.ErrorMessage, columnName), rangeValidation.Start, rangeValidation.End) }); case ValidationType.Regex: var regexValidation = (RegexValidation)validation; return(new[] { new ModelClientValidationRegexRule(string.Format(validation.ErrorMessage, columnName), regexValidation.Pattern) }); default: return(new ModelClientValidationRegexRule[0]); } }
protected void WriteValidationCodeDetailsGrid() { bool validationsEnabled = ValidationsEnabled; if (!validationsEnabled) { return; } List <ColumnValidation> validationColumns = GetValidationColumns(); Writer.PushIdentationLevel(); Writer.IncreaseIdentation(); Writer.IncreaseIdentation(); Writer.WriteLine("private void dataGridView1_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)"); Writer.WriteLine("{"); Writer.WriteLine("string s;"); Writer.WriteLine("DataGridViewRow row = dataGridView1.Rows[e.RowIndex];"); Writer.WriteLine("object value = e.FormattedValue;"); Writer.WriteLine("e.Cancel = false;"); Writer.WriteLine("row.ErrorText = \"\";"); Writer.WriteLine("if (row.IsNewRow) return;"); for (int i = 0; i < validationColumns.Count; i++) { ColumnValidation cv = validationColumns[i]; if (cv.IsBooleanType() || cv.HasLookup) { continue; } string idColumnCanonical = GetCanonicalIdentifier(cv.Column.ColumnName); Writer.WriteLine("if (e.ColumnIndex == {0})", i); Writer.WriteLine("{"); string numericType = ""; if (cv.IsNumericType()) { if (cv.IsIntegerType()) { numericType = "int"; } if (cv.IsFloatingPointType()) { numericType = "double"; } Writer.WriteLine("{0} v;", numericType); } if (cv.Required) { Writer.WriteLine("if( (value is DBNull) || string.IsNullOrEmpty( value.ToString() ) )"); Writer.WriteLine("{"); Writer.WriteLine("e.Cancel = true;"); Writer.WriteLine("row.ErrorText = \"The field {0} is required\";", cv.Name); Writer.WriteLine("return;"); Writer.WriteLine("}"); } if (cv.IsNumericType()) { Writer.WriteLine("s = value.ToString();"); if (!string.IsNullOrEmpty(numericType)) { Writer.WriteLine("if( !{0}.TryParse( s, out v ) )", numericType); Writer.WriteLine("{"); } else { // just assume is good Writer.WriteLine("if( true )"); Writer.WriteLine("{"); } Writer.WriteLine("e.Cancel = true;"); Writer.WriteLine("row.ErrorText = \"The field {0} must be {1}.\";", cv.Name, numericType); Writer.WriteLine("return;"); Writer.WriteLine("}"); if (cv.MinValue != null) { Writer.WriteLine("else if( {0} > v )", cv.MinValue); Writer.WriteLine("{"); Writer.WriteLine("e.Cancel = true;"); Writer.WriteLine("row.ErrorText = \"The field {0} must be greater or equal than {1}.\";", cv.Name, cv.MinValue); Writer.WriteLine("return;"); Writer.WriteLine("} "); } if (cv.MaxValue != null) { Writer.WriteLine("else if( {0} < v )", cv.MaxValue); Writer.WriteLine("{"); Writer.WriteLine("e.Cancel = true;"); Writer.WriteLine("row.ErrorText = \"The field {0} must be lesser or equal than {1}\";", cv.Name, cv.MaxValue); Writer.WriteLine("return;"); Writer.WriteLine("} "); } } Writer.WriteLine("}"); } Writer.WriteLine("}"); // DataError event Writer.WriteLine(""); Writer.WriteLine("private void dataGridView1_DataError(object sender, DataGridViewDataErrorEventArgs e)"); Writer.WriteLine("{"); Writer.WriteLine("dataGridView1.Rows[e.RowIndex].ErrorText = e.Exception.Message;"); Writer.WriteLine("e.Cancel = true;"); Writer.WriteLine("}"); Writer.PopIdentationLevel(); }
protected override void WriteDataGridColumnInitialization() { List <ColumnValidation> validationColumns = GetValidationColumns(); Writer.PushIdentationLevel(); Writer.IncreaseIdentation(); Writer.IncreaseIdentation(); Writer.IncreaseIdentation(); Writer.WriteLine("dataGridView1.AutoGenerateColumns = false;"); Writer.WriteLine("string strConn2 = \"{0};\";", ConnectionString); Writer.WriteLine("MySql.Data.MySqlClient.MySqlDataAdapter ad2 = null;"); for (int i = 0; i < validationColumns.Count; i++) { ColumnValidation cv = validationColumns[i]; string idColumnCanonical = GetCanonicalIdentifier(cv.Column.ColumnName); if (cv.IsBooleanType()) { Writer.WriteLine("System.Windows.Forms.DataGridViewCheckBoxColumn col{0} = new System.Windows.Forms.DataGridViewCheckBoxColumn();", idColumnCanonical); Writer.WriteLine("col{0}.DataPropertyName = \"{1}\";", idColumnCanonical, cv.EfColumnMapping); Writer.WriteLine("col{0}.HeaderText = \"{1}\";", idColumnCanonical, cv.Name); Writer.WriteLine("col{0}.Name = \"col{0}\";", idColumnCanonical); Writer.WriteLine("dataGridView1.Columns.Add(col{0});", idColumnCanonical); } else if (cv.HasLookup) { Writer.WriteLine("System.Windows.Forms.DataGridViewComboBoxColumn col{0} = new System.Windows.Forms.DataGridViewComboBoxColumn();", idColumnCanonical); Writer.WriteLine("col{0}.DataSource = {1};", idColumnCanonical, GetDataSourceForCombo(cv)); Writer.WriteLine("col{0}.DataPropertyName = \"{1}\";", idColumnCanonical, cv.EfColumnMapping); Writer.WriteLine("col{0}.DisplayMember = \"{1}\";", idColumnCanonical, cv.EfLookupColumnMapping); Writer.WriteLine("col{0}.ValueMember = \"{1}\";", idColumnCanonical, cv.FkInfo.ReferencedColumnName); Writer.WriteLine("col{0}.HeaderText = \"{0}\";", idColumnCanonical); Writer.WriteLine("col{0}.Name = \"col{0}\";", idColumnCanonical); Writer.WriteLine("col{0}.ToolTipText = \"Pick the column from the foreign table to use as friendly value for this lookup.\";", idColumnCanonical); Writer.WriteLine("dataGridView1.Columns.Add(col{0});", idColumnCanonical); } else if (cv.IsDateType()) { Writer.WriteLine("MyDateTimePickerColumn col{0} = new MyDateTimePickerColumn();", idColumnCanonical); Writer.WriteLine("col{0}.DataPropertyName = \"{1}\";", idColumnCanonical, cv.EfColumnMapping); Writer.WriteLine("col{0}.HeaderText = \"{1}\";", idColumnCanonical, cv.Name); Writer.WriteLine("col{0}.Name = \"col{0}\";", idColumnCanonical); Writer.WriteLine("dataGridView1.Columns.Add(col{0});", idColumnCanonical); } else { Writer.WriteLine("System.Windows.Forms.DataGridViewTextBoxColumn col{0} = new System.Windows.Forms.DataGridViewTextBoxColumn();", idColumnCanonical); Writer.WriteLine("col{0}.DataPropertyName = \"{1}\";", idColumnCanonical, cv.EfColumnMapping); Writer.WriteLine("col{0}.HeaderText = \"{1}\";", idColumnCanonical, cv.Name); Writer.WriteLine("col{0}.Name = \"col{0}\";", idColumnCanonical); if (cv.MaxLength.HasValue) { Writer.WriteLine("col{0}.MaxInputLength = {1};", idColumnCanonical, cv.MaxLength.Value); } if (cv.IsReadOnly()) { Writer.WriteLine("col{0}.ReadOnly = true;", idColumnCanonical); Writer.WriteLine("col{0}.DefaultCellStyle.BackColor = Color.LightGray;", idColumnCanonical); } Writer.WriteLine("dataGridView1.Columns.Add(col{0});", idColumnCanonical); } } Writer.PopIdentationLevel(); }
protected override void WriteValidationCode() { bool validationsEnabled = ValidationsEnabled; List <ColumnValidation> validationColumns = ValidationColumns; Writer.PushIdentationLevel(); Writer.IncreaseIdentation(); Writer.IncreaseIdentation(); if (validationsEnabled) { for (int i = 0; i < validationColumns.Count; i++) { ColumnValidation cv = validationColumns[i]; if (cv.IsDateType() || cv.IsReadOnly() || cv.IsBooleanType()) { continue; } string idColumnCanonical = GetCanonicalIdentifier(cv.Column.ColumnName); if (cv.HasLookup && cv.Required) { Writer.WriteLine("Private Sub {0}_comboBox_Validating(sender As System.Object, e As System.ComponentModel.CancelEventArgs)", idColumnCanonical); Writer.WriteLine("Dim i As Integer = {0}_comboBox.SelectedIndex", idColumnCanonical); Writer.WriteLine("e.Cancel = False"); Writer.WriteLine("If i = -1 Then"); Writer.WriteLine("e.Cancel = True"); Writer.WriteLine("errorProvider1.SetError({0}_comboBox, \"Must select a {0}\")", idColumnCanonical); Writer.WriteLine("End If"); Writer.WriteLine("If Not e.Cancel Then"); Writer.WriteLine("errorProvider1.SetError({0}_comboBox, \"\")", idColumnCanonical); Writer.WriteLine("End If"); Writer.WriteLine("End Sub"); continue; } Writer.WriteLine("Private Sub {0}TextBox_Validating(sender As Object, e As CancelEventArgs)", idColumnCanonical); Writer.WriteLine(""); Writer.WriteLine("e.Cancel = False"); if (cv.Required) { Writer.WriteLine("If String.IsNullOrEmpty( {0}TextBox.Text ) Then ", idColumnCanonical); Writer.WriteLine("e.Cancel = True"); Writer.WriteLine("errorProvider1.SetError( {0}TextBox, \"The field {1} is required\" ) ", idColumnCanonical, cv.Name); Writer.WriteLine("End If"); } if (cv.IsNumericType()) { string numericType = ""; if (cv.IsIntegerType()) { numericType = "Integer"; } else if (cv.IsFloatingPointType()) { numericType = "Double"; } Writer.WriteLine("Dim v As {0}", numericType); Writer.WriteLine("Dim s As string = {0}TextBox.Text", idColumnCanonical); if (!string.IsNullOrEmpty(numericType)) { Writer.WriteLine("If Not {0}.TryParse( s, v ) Then", numericType); } else { // just assume is good Writer.WriteLine("If True Then"); } Writer.WriteLine("e.Cancel = True"); Writer.WriteLine("errorProvider1.SetError( {0}TextBox, \"The field {1} must be {2}.\" )", idColumnCanonical, cv.Name, numericType); if (cv.MinValue != null) { Writer.WriteLine("ElseIf {0} > v Then ", cv.MinValue); Writer.WriteLine("e.Cancel = True"); Writer.WriteLine("errorProvider1.SetError( {0}TextBox, \"The field {1} must be greater or equal than {2}.\" )", idColumnCanonical, cv.Name, cv.MinValue); } if (cv.MaxValue != null) { Writer.WriteLine("ElseIf {0} < v Then ", cv.MaxValue); Writer.WriteLine("e.Cancel = True"); Writer.WriteLine("errorProvider1.SetError( {0}TextBox, \"The field {1} must be lesser or equal than {2}\" )", idColumnCanonical, cv.Name, cv.MaxValue); } Writer.WriteLine("End If"); } Writer.WriteLine("If Not e.Cancel Then"); Writer.WriteLine("errorProvider1.SetError( {0}TextBox, \"\" )", idColumnCanonical); Writer.WriteLine("End If"); Writer.WriteLine("End Sub"); Writer.WriteLine(); } } Writer.PopIdentationLevel(); }