2 using System.Collections.Generic;
7 using System.ComponentModel;
16 using System.Xml.Serialization;
20 namespace sage.addons.components
27 private string nombreBaseDatos =
"";
31 public string NombreBaseDatos
33 get {
return nombreBaseDatos; }
34 set { nombreBaseDatos = value; }
40 public BindingList<dynamic> CamposNuevoMante =
new BindingList<dynamic>();
50 public List<string> NombreCamposNuevoMante =
new List<string>();
68 private DataTable CamposTabla;
71 private DataTable CamposTablaLineas;
90 public bool CrearManteTRel(
string _manteTRelName,
string _nombreTabla,
string _nombreUserControl,
string _nombreMante, out
string messageError)
92 Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();
96 Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();
99 string sourceClassName =
"ManteExt" + CultureInfo.CurrentCulture.TextInfo.ToTitleCase(_nombreMante.ToLower()).Trim() +
AddonsExecute.
NombreAddon;
100 string sourceFormName =
"FormManteExt" + CultureInfo.CurrentCulture.TextInfo.ToTitleCase(_nombreMante.ToLower()).Trim() +
AddonsExecute.
NombreAddon;
101 string sourceFileName = sourceClassName +
".cs";
102 string propertyDefName =
"ManteTRel" + _manteTRelName;
103 string mantegridName =
"mantegrid" + _manteTRelName;
105 ProjectItem prjItem = GetSourceFile(sourceFileName);
109 messageError +=
"No se ha encontrado la extensión del mantenimiento de " + _manteTRelName +
"." + Environment.NewLine;
113 string fileName = _manteTRelName +
".cs";
114 string sourceCode =
"";
115 string sourceFile =
"";
116 string propertyCode =
"";
118 StreamWriter streamWriter;
119 StringBuilder modextensionmante =
new StringBuilder();
121 ProjectItem projectItem;
124 string defstruc =
"";
125 string principalkey =
"";
126 string keysdefinition =
"";
127 string keysproperties =
"";
128 string browsertittle =
"Buscar " + _manteTRelName;
130 string sourcePropertiesCode = Resources.PropertiesUserControls;
133 Char comilles =
new Char();
137 foreach (dynamic anyobjectMante
in this.CamposNuevoMante)
143 string nombreCampo = objectManteTRel.
_Nombre.Trim();
144 string nombrePropiedad =
"_" + nombreCampo;
145 string propertyObject =
"";
146 string nombrePropiedadPrivada =
"_private" + nombreCampo;
147 string nombreCampoTRelAsignar =
"";
150 #region Definición del campoTRel 154 defstruc += tab + tab + tab +
"ewCampoTRel def" + nombrePropiedad +
" = this._AddCampoTRel(" + comilles + nombrePropiedad + comilles +
", " + comilles + comilles +
");" + Environment.NewLine;
158 defstruc += tab + tab + tab +
"ewCampoTRel def" + nombrePropiedad +
" = this._AddCampoTRel(" + comilles + nombrePropiedad + comilles +
", " + comilles + nombreCampo + comilles +
");" + Environment.NewLine;
166 defstruc += tab + tab + tab +
"def" + nombrePropiedad +
"._AnchoColumna = " + objectManteTRel.
_AnchoColumna.ToString() +
";" + Environment.NewLine;
167 defstruc += tab + tab + tab +
"def" + nombrePropiedad +
"._AutoModeSizeColumna = DataGridViewAutoSizeColumnMode." + objectManteTRel.
_AutoModeSizeColumna.ToString() +
";" + Environment.NewLine;
168 defstruc += tab + tab + tab +
"def" + nombrePropiedad +
"._Editable = " + objectManteTRel.
_Editable.ToString().ToLower() +
";" + Environment.NewLine;
169 defstruc += tab + tab + tab +
"def" + nombrePropiedad +
"._Error_Duplicados = " + comilles + objectManteTRel.
_Error_Duplicados.ToString() + comilles +
";" + Environment.NewLine;
170 defstruc += tab + tab + tab +
"def" + nombrePropiedad +
"._Error_Validar_Dato = " + comilles + objectManteTRel.
_Error_Validar_Dato.ToString() + comilles +
";" + Environment.NewLine;
171 defstruc += tab + tab + tab +
"def" + nombrePropiedad +
"._ExpandirPunto = " + objectManteTRel.
_ExpandirPunto.ToString().ToLower() +
";" + Environment.NewLine;
172 defstruc += tab + tab + tab +
"def" + nombrePropiedad +
"._FormatString = " + comilles + objectManteTRel.
_FormatString.ToString() + comilles +
";" + Environment.NewLine;
173 defstruc += tab + tab + tab +
"def" + nombrePropiedad +
"._PermiteDuplicados = " + objectManteTRel.
_PermiteDuplicados.ToString().ToLower() +
";" + Environment.NewLine;
174 defstruc += tab + tab + tab +
"def" + nombrePropiedad +
"._TipoColumna = gridColumnsTypes." + objectManteTRel.
_TipoColumna.ToString() +
";" + Environment.NewLine;
175 defstruc += tab + tab + tab +
"def" + nombrePropiedad +
"._Titulo = " + comilles + objectManteTRel.
_Titulo.ToString() + comilles +
";" + Environment.NewLine;
176 defstruc += tab + tab + tab +
"def" + nombrePropiedad +
"._Updatable = " + objectManteTRel.
_Updatable.ToString().ToLower() +
";" + Environment.NewLine;
177 defstruc += tab + tab + tab +
"def" + nombrePropiedad +
"._Validar_Asignar_Cargando = " + objectManteTRel.
_Validar_Asignar_Cargando.ToString().ToLower() +
";" + Environment.NewLine;
178 defstruc += tab + tab + tab +
"def" + nombrePropiedad +
"._Validar_Dato_BaseDatos = " + comilles + objectManteTRel.
_Validar_Dato_BaseDatos.ToString() + comilles +
";" + Environment.NewLine;
179 defstruc += tab + tab + tab +
"def" + nombrePropiedad +
"._Validar_Dato_Campos = " + comilles + objectManteTRel.
_Validar_Dato_Campos.ToString() + comilles +
";" + Environment.NewLine;
180 defstruc += tab + tab + tab +
"def" + nombrePropiedad +
"._Validar_Dato_CampoTRel_Asignar = " + comilles + nombreCampoTRelAsignar + comilles +
";" + Environment.NewLine;
181 defstruc += tab + tab + tab +
"def" + nombrePropiedad +
"._Validar_Dato_Clave = " + comilles + objectManteTRel.
_Validar_Dato_Clave.ToString() + comilles +
";" + Environment.NewLine;
182 defstruc += tab + tab + tab +
"def" + nombrePropiedad +
"._Validar_Dato_Tabla = " + comilles + objectManteTRel.
_Validar_Dato_Tabla.ToString() + comilles +
";" + Environment.NewLine;
183 defstruc += tab + tab + tab +
"def" + nombrePropiedad +
"._Visible = " + objectManteTRel.
_Visible.ToString().ToLower() +
";" + Environment.NewLine;
185 if (
char.IsNumber(objectManteTRel.
_Relleno))
187 defstruc += tab + tab + tab +
"def" + nombrePropiedad +
"._Relleno = '" + objectManteTRel.
_Relleno.ToString() +
"';" + Environment.NewLine;
193 string mascara =
new string(
'9', objectManteTRel.
Longitud);
200 defstruc += tab + tab + tab +
"def" + nombrePropiedad +
"._Mascara = new ewMascara(" + comilles + mascara + comilles +
");" + Environment.NewLine;
207 defstruc += tab + tab + tab +
"def" + nombrePropiedad +
"._Browser = new sage.ew.botones.btBrowser();" + Environment.NewLine;
208 defstruc += tab + tab + tab +
"def" + nombrePropiedad +
"._Browser._Campos = " + comilles +
"Codigo,Nombre" + comilles +
";" + Environment.NewLine;
209 defstruc += tab + tab + tab +
"def" + nombrePropiedad +
"._Browser._Campo_Predet = " + comilles +
"Nombre" + comilles +
";" + Environment.NewLine;
210 defstruc += tab + tab + tab +
"def" + nombrePropiedad +
"._Browser._Clave = " + comilles + objectManteTRel.
_Validar_Dato_Clave.ToString() + comilles +
";" + Environment.NewLine;
211 defstruc += tab + tab + tab +
"def" + nombrePropiedad +
"._Browser._DataBase = " + comilles + objectManteTRel.
_Validar_Dato_BaseDatos.ToString() + comilles +
";" + Environment.NewLine;
212 defstruc += tab + tab + tab +
"def" + nombrePropiedad +
"._Browser._Tabla = " + comilles + objectManteTRel.
_Validar_Dato_Tabla.ToString() + comilles +
";" + Environment.NewLine;
213 defstruc += tab + tab + tab +
"def" + nombrePropiedad +
"._Browser._Titulo = " + comilles + browsertittle + comilles +
";" + Environment.NewLine;
214 defstruc += tab + tab + tab +
"def" + nombrePropiedad +
"._Browser._Titulos_Campos = " + comilles +
"Código,Nombre" + comilles +
";" + Environment.NewLine;
217 defstruc += tab + tab + tab +
"def" + nombrePropiedad +
"._Mante = new sage.ew.botones.btMante();" + Environment.NewLine;
218 defstruc += tab + tab + tab +
"def" + nombrePropiedad +
"._Mante._NombreManteNet = " + comilles + objectManteTRel.
_Validar_Dato_Tabla.ToUpper() + comilles +
";" + Environment.NewLine;
221 defstruc += tab + tab + tab + Environment.NewLine;
223 #endregion Definición del campoTRel 230 keysproperties += tab + tab + tab + tab +
"/// <summary>" + Environment.NewLine;
231 keysproperties += tab + tab + tab + tab +
"/// " + nombreCampo + Environment.NewLine;
232 keysproperties += tab + tab + tab + tab +
"/// </summary>" + Environment.NewLine;
233 keysproperties += tab + tab + tab + tab +
"public ClaveTRel " + nombrePropiedad +
" { get; set; }" + Environment.NewLine;
234 keysproperties += tab + tab + tab + tab + Environment.NewLine;
236 keysdefinition += tab + tab + tab + tab + tab +
"// " + nombreCampo + Environment.NewLine;
237 keysdefinition += tab + tab + tab + tab + tab + nombrePropiedad +
" = new ClaveTRel();" + Environment.NewLine;
241 keysdefinition += tab + tab + tab + tab + tab + nombrePropiedad +
"._EsCampoLinea = true;" + Environment.NewLine;
247 principalkey = nombrePropiedad;
248 keysdefinition += tab + tab + tab + tab + tab + nombrePropiedad +
"._EsFiltro = true;" + Environment.NewLine;
252 keysdefinition += tab + tab + tab + tab + Environment.NewLine;
258 #region Definición de las propiedades 261 string tipoCampo =
"";
262 string empytValue =
"";
266 tipoCampo =
"string";
269 tipoCampo =
"string";
270 empytValue =
"= " + comilles + comilles;
273 tipoCampo =
"string";
274 empytValue =
"= " + comilles + comilles;
277 tipoCampo =
"DateTime";
278 empytValue =
"= DateTime.Now";
282 empytValue =
"= false";
285 tipoCampo =
"decimal";
293 tipoCampo =
"string";
294 empytValue =
"= " + comilles + comilles;
297 tipoCampo =
"string";
298 empytValue =
"= " + comilles + comilles;
301 tipoCampo =
"string";
302 empytValue =
"= " + comilles + comilles;
308 string propertySet = GetPropertySet(tipoCampo, comilles, objectManteTRel.
_Validar_Dato_Clave, nombrePropiedad, nombrePropiedadPrivada);
311 propertyObject = sourcePropertiesCode;
312 propertyObject = propertyObject.Replace(
"$propertyname$", nombrePropiedad);
313 propertyObject = propertyObject.Replace(
"$privatepropertyname$", nombrePropiedadPrivada);
314 propertyObject = propertyObject.Replace(
"$propertyset$", propertySet);
315 propertyObject = propertyObject.Replace(
"$fieldname$", nombreCampo.ToUpper());
316 propertyObject = propertyObject.Replace(
"$propertytype$", tipoCampo);
317 propertyObject = propertyObject.Replace(
"$converto$",
"ToString");
318 propertyObject = propertyObject.Replace(
"$emptyvalue$", empytValue);
319 propertyCode += propertyObject;
321 #endregion Definición de las propiedades 326 sourceCode = Resources.ManteTRelBase;
328 sourceCode = sourceCode.Replace(
"$classname$", _manteTRelName);
330 sourceCode = sourceCode.Replace(
"$tablename$", _nombreTabla);
331 sourceCode = sourceCode.Replace(
"$browsertittle$", browsertittle);
332 sourceCode = sourceCode.Replace(
"$structuredefinition$", defstruc);
333 sourceCode = sourceCode.Replace(
"$keysproperties$", keysproperties);
334 sourceCode = sourceCode.Replace(
"$keysdefinition$", keysdefinition);
335 sourceCode = sourceCode.Replace(
"$principalkey$", principalkey);
336 sourceCode = sourceCode.Replace(
"$propertieslindefinition$", propertyCode);
340 BackupFile(sourceFile);
341 streamWriter = File.CreateText(sourceFile);
342 streamWriter.Write(sourceCode);
343 streamWriter.Close();
347 itemWindow = projectItem.Open();
348 itemWindow.Activate();
351 CodeVariable codeVariable = GetCodeElement<CodeVariable>(propertyDefName, out messageError, prjItem, sourceClassName);
352 if (codeVariable == null)
354 modextensionmante.AppendLine(tab + tab +
"/// <summary>");
355 modextensionmante.AppendLine(tab + tab +
"/// Instancia del ManteTRel de " + _nombreTabla);
356 modextensionmante.AppendLine(tab + tab +
"/// </summary>");
357 modextensionmante.AppendLine(tab + tab +
"public Negocio.Clases." + _manteTRelName +
" " + propertyDefName +
" = null;");
358 modextensionmante.AppendLine();
360 CodeClass codeClass = GetCodeClass(sourceClassName, out messageError, prjItem);
362 EditPoint editPoint = codeClass.StartPoint.CreateEditPoint();
363 if (!editPoint.FindPattern(
"#region ManteTRels"))
365 editPoint = codeClass.StartPoint.CreateEditPoint();
368 editPoint.LineDown(2);
369 editPoint.Insert(modextensionmante.ToString());
371 modextensionmante.Clear();
372 modextensionmante.AppendLine(tab + tab + tab +
"Negocio.Clases." + _manteTRelName +
" mtrel" + _manteTRelName +
" = new Negocio.Clases." + _manteTRelName +
"();");
373 modextensionmante.AppendLine(tab + tab + tab +
"this.ManteTRel" + _manteTRelName +
" = mtrel" + _manteTRelName +
";");
374 modextensionmante.AppendLine(tab + tab + tab +
"this._Mante._AddManteTRel(mtrel" + _manteTRelName +
");");
375 modextensionmante.AppendLine();
377 CodeFunction codeFunction = GetCodeElement<CodeFunction>(sourceClassName, out messageError, prjItem, sourceClassName, 1);
379 if (codeFunction != null)
381 editPoint = codeFunction.EndPoint.CreateEditPoint();
382 editPoint.StartOfLine();
383 editPoint.Insert(modextensionmante.ToString());
388 CodeFunction functionFormManteExt = GetCodeElement<CodeFunction>(sourceFormName, out messageError, prjItem, sourceFormName);
389 if (functionFormManteExt != null)
391 EditPoint editPoint = functionFormManteExt.StartPoint.CreateEditPoint();
392 if (editPoint.FindPattern(
"extensionMante._Load()"))
394 editPoint.StartOfLine();
395 editPoint.Indent(null, 3);
396 editPoint.Insert(
"extensionMante." + propertyDefName +
"._Grid = extensionMante.usercontrolTabManteBase.Controls[" + comilles + mantegridName + comilles +
"];" + Environment.NewLine);
423 string fileName = _nombreControl +
".cs";
424 string mantegridName =
"mantegrid" + _nombreTabla;
426 Char comilles =
new Char();
430 Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();
434 ProjectItem prjItem = GetSourceFile(fileName);
439 lbOk = CrearNuevoUserControl(_nombreControl,
true, out messageError);
442 prjItem = GetSourceFile(fileName);
448 messageError =
"No se ha podido crear el control de usuario";
453 CodeFunction functionFormManteExt = GetCodeElement<CodeFunction>(
"_BloquearControles", out messageError, prjItem, _nombreControl);
454 if (functionFormManteExt != null)
457 EditPoint editPoint = functionFormManteExt.EndPoint.CreateEditPoint();
459 if (editPoint != null)
462 editPoint.Insert(
"this." + mantegridName +
"._ReadOnly = tlReadOnly;" + Environment.NewLine);
467 functionFormManteExt = null;
468 functionFormManteExt = GetCodeElement<CodeFunction>(
"InitializeComponent", out messageError, prjItem, _nombreControl);
469 if (functionFormManteExt != null)
472 EditPoint editPoint = functionFormManteExt.StartPoint.CreateEditPoint();
477 editPoint.Indent(null, 2);
478 editPoint.Insert(
"/// <summary>" + Environment.NewLine);
479 editPoint.Indent(null, 2);
480 editPoint.Insert(
"/// Objeto de Negocio asociado al usercontrol" + Environment.NewLine);
481 editPoint.Indent(null, 2);
482 editPoint.Insert(
"/// </summary>" + Environment.NewLine);
483 editPoint.Indent(null, 2);
484 editPoint.Insert(
"public ew.objetos.UserControls.Mantegrid " + mantegridName +
";" + Environment.NewLine);
486 if (editPoint.FindPattern(
"this.SuspendLayout()"))
488 editPoint.StartOfLine();
489 editPoint.Insert(
"this." + mantegridName +
" = new sage.ew.objetos.UserControls.Mantegrid();" + Environment.NewLine);
490 editPoint.Indent(null, 3);
491 editPoint.LineDown(1);
493 editPoint.Insert(
"//" + Environment.NewLine);
494 editPoint.Indent(null, 3);
495 editPoint.Insert(
"// " + mantegridName + Environment.NewLine);
496 editPoint.Indent(null, 3);
497 editPoint.Insert(
"//" + Environment.NewLine);
498 editPoint.Indent(null, 3);
499 editPoint.Insert(
"this." + mantegridName +
".Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right)));" + Environment.NewLine);
500 editPoint.Indent(null, 3);
501 editPoint.Insert(
"this." + mantegridName +
".Location = new System.Drawing.Point(0, 0);" + Environment.NewLine);
502 editPoint.Indent(null, 3);
503 editPoint.Insert(
"this." + mantegridName +
".Name = " + comilles + mantegridName + comilles +
";" + Environment.NewLine);
504 editPoint.Indent(null, 3);
505 editPoint.Insert(
"this." + mantegridName +
".Size = new System.Drawing.Size(511, 294);" + Environment.NewLine);
506 editPoint.Indent(null, 3);
507 editPoint.Insert(
"this." + mantegridName +
".TabIndex = 0;" + Environment.NewLine);
509 if (editPoint.FindPattern(
"this.ResumeLayout"))
511 editPoint.StartOfLine();
512 editPoint.Insert(
"this.Controls.Add(this." + mantegridName +
");" + Environment.NewLine);
513 editPoint.Indent(null, 3);
537 string fileName = _nombreControl +
".cs";
538 string sourceCode =
"";
539 string sourceFile =
"";
541 StreamWriter streamWriter;
542 ProjectItem projectItem;
546 Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();
548 string propertyCode =
"";
549 string fieldsLoad =
"";
551 projectItem = GetSourceFile(fileName);
553 if (projectItem != null)
555 messageError =
"Ya existe un fichero en el proyecto con el nombre indicado. (" + fileName +
")";
557 return _crearManteTRel;
560 string bindingsCode =
"";
561 string blockCode =
"";
562 string instanceObjectsCode =
"";
563 string controlsAddCode =
"";
564 string controlsDefCode =
"";
565 string controlDeclare =
"";
566 string paginasAddCode =
"";
569 int leftcontrol = 137;
570 int[] toplabel =
new int[] { 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13 };
571 int[] topcontrol =
new int[] { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 };
572 int heightcontrol = 24;
573 int widthcontrol = 100;
579 string sourceBindingsCode = Resources.ControlBinding;
580 string sourcePropertiesCode = Resources.PropertiesUserControls;
581 string sourceLabelCode = Resources.FormManteLabel;
582 string sourceTextBoxCode = Resources.FormManteTextBox;
583 string sourceCheckBoxCode = Resources.FormManteCheckBox;
584 string sourceNumericUpDownCode = Resources.FormManteNumericUpDown;
585 string sourceDateTimeCode = Resources.FormManteDateTime;
586 string sourceTxtCodLabelCode = Resources.FormManteTxtCodLabel;
587 string sourceTabPageCode = Resources.FormManteTabPage;
589 string showPageCode =
"";
590 string formDefCode =
"";
592 Char comilles =
new Char();
596 if (this.CamposNuevoMante.Count > 0)
599 if (manteProperties.
NumTabs > 1)
601 foreach (dynamic anyobjectMante
in this.CamposNuevoMante)
607 string nombrePagina = pagina.
Nombre;
609 if (nombrePagina ==
"tpGeneral")
611 controlsDefCode += tab + tab + tab +
"this.tpGeneral.Text = " + comilles + pagina.
Titulo + comilles +
";" + Environment.NewLine;
615 instanceObjectsCode += tab + tab + tab +
"this." + nombrePagina +
" = new sage.ew.objetos.ewTabPage();" + Environment.NewLine;
616 controlDeclare += tab + tab +
"private sage.ew.objetos.ewTabPage " + nombrePagina +
";" + Environment.NewLine;
618 paginasAddCode += tab + tab + tab +
"this.ewtcPaginas.Controls.Add(this." + nombrePagina +
");" + Environment.NewLine;
620 string objectDef = sourceTabPageCode;
621 objectDef = objectDef.Replace(
"$objectname$", nombrePagina);
622 objectDef = objectDef.Replace(
"$objectcaption$", pagina.
Titulo);
623 objectDef = objectDef.Replace(
"$tabindex$", tabindex.ToString());
625 controlsDefCode += objectDef;
629 paginasAddCode += tab + tab + tab +
"this.ewtcPaginas.Controls.SetChildIndex(this." + nombrePagina +
", 0);" + Environment.NewLine;
633 controlsDefCode = paginasAddCode + controlsDefCode;
639 foreach (dynamic anyobjectMante
in this.CamposNuevoMante)
645 string nombreControl = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(objectMante.
Nombre.ToLower()).Trim();
646 string nombreCampo = nombreControl;
647 string nombrePropiedad =
"_" + nombreControl;
648 string nombrePropiedadPrivada =
"_private" + nombreControl;
649 string tituloCampo = objectMante.
TituloCampo +
":";
653 string bindingObject =
"";
654 string propertyObject =
"";
655 string objectDef =
"";
658 string nomPagina =
"this";
660 if (objectMante.
Tab > 1)
668 instanceObjectsCode += tab + tab + tab +
"this.ewlabel" + nombreControl +
" = new sage.ew.objetos.ewlabel();" + Environment.NewLine;
670 controlsAddCode += tab + tab + tab + nomPagina +
".Controls.Add(this.ewlabel" + nombreControl +
");" + Environment.NewLine;
672 controlDeclare += tab + tab +
"private sage.ew.objetos.ewlabel ewlabel" + nombreControl +
";" + Environment.NewLine;
674 objectDef = sourceLabelCode;
675 objectDef = objectDef.Replace(
"$objectname$",
"ewlabel" + nombreControl);
676 objectDef = objectDef.Replace(
"$objectcaption$", tituloCampo);
677 objectDef = objectDef.Replace(
"$left$", leftlabel.ToString());
678 objectDef = objectDef.Replace(
"$top$", toplabel[objectMante.
Tab - 1].ToString());
679 objectDef = objectDef.Replace(
"$tabindex$", tabindex.ToString());
681 controlsDefCode += objectDef;
689 bindingObject = sourceBindingsCode;
690 bindingObject = bindingObject.Replace(
"$objectname$",
"ewtextbox" + nombreControl);
691 bindingObject = bindingObject.Replace(
"$propertybinding$",
"Text");
692 bindingObject = bindingObject.Replace(
"$propertyname$", nombrePropiedad);
693 bindingObject = bindingObject.Replace(
"$negocioclass$",
"extensionMante");
694 bindingsCode += bindingObject;
696 blockCode += tab + tab + tab +
"ewtextbox" + nombreControl +
".ReadOnly = tlReadOnly;" + Environment.NewLine;
698 instanceObjectsCode += tab + tab + tab +
"this.ewtextbox" + nombreControl +
" = new sage.ew.objetos.ewtextbox();" + Environment.NewLine;
700 controlsAddCode += tab + tab + tab + nomPagina +
".Controls.Add(this.ewtextbox" + nombreControl +
");" + Environment.NewLine;
702 controlDeclare += tab + tab +
"private sage.ew.objetos.ewtextbox ewtextbox" + nombreControl +
";" + Environment.NewLine;
704 objectDef = sourceTextBoxCode;
705 objectDef = objectDef.Replace(
"$objectname$",
"ewtextbox" + nombreControl);
706 objectDef = objectDef.Replace(
"$left$", leftcontrol.ToString());
707 objectDef = objectDef.Replace(
"$top$", topcontrol[objectMante.
Tab - 1].ToString());
708 objectDef = objectDef.Replace(
"$width$", widthcontrol.ToString());
709 objectDef = objectDef.Replace(
"$height$", heightcontrol.ToString());
710 objectDef = objectDef.Replace(
"$maxlength$", maxlength.ToString());
711 objectDef = objectDef.Replace(
"$tabindex$", tabindex.ToString());
713 controlsDefCode += objectDef;
717 propertyObject = sourcePropertiesCode;
718 propertyObject = propertyObject.Replace(
"$propertyname$", nombrePropiedad);
719 propertyObject = propertyObject.Replace(
"$privatepropertyname$", nombrePropiedadPrivada);
720 propertyObject = propertyObject.Replace(
"$propertyset$", nombrePropiedadPrivada +
" = value");
721 propertyObject = propertyObject.Replace(
"$fieldname$", nombreCampo.ToUpper());
722 propertyObject = propertyObject.Replace(
"$propertytype$",
"string");
723 propertyObject = propertyObject.Replace(
"$converto$",
"ToString");
724 propertyObject = propertyObject.Replace(
"$emptyvalue$",
"String.Empty");
725 propertyCode += propertyObject;
729 fieldsLoad +=
"this." + nombrePropiedad +
" = _Mante._Codigo;";
733 fieldsLoad +=
"this." + nombrePropiedad +
" = String.Empty;" + Environment.NewLine;
741 bindingObject = sourceBindingsCode;
742 bindingObject = bindingObject.Replace(
"$objectname$",
"ewcheckbox" + nombreControl);
743 bindingObject = bindingObject.Replace(
"$propertybinding$",
"Checked");
744 bindingObject = bindingObject.Replace(
"$propertyname$", nombrePropiedad);
745 bindingObject = bindingObject.Replace(
"$negocioclass$",
"extensionMante");
746 bindingsCode += bindingObject;
748 blockCode += tab + tab + tab +
"ewcheckbox" + nombreControl +
".Enabled = !tlReadOnly;" + Environment.NewLine;
750 instanceObjectsCode += tab + tab + tab +
"this.ewcheckbox" + nombreControl +
" = new sage.ew.objetos.ewcheckbox();" + Environment.NewLine;
752 controlsAddCode += tab + tab + tab + nomPagina +
".Controls.Add(this.ewcheckbox" + nombreControl +
");" + Environment.NewLine;
754 controlDeclare += tab + tab +
"private sage.ew.objetos.ewcheckbox ewcheckbox" + nombreControl +
";" + Environment.NewLine;
756 objectDef = sourceCheckBoxCode;
757 objectDef = objectDef.Replace(
"$objectname$",
"ewcheckbox" + nombreControl);
758 objectDef = objectDef.Replace(
"$left$", leftcontrol.ToString());
759 objectDef = objectDef.Replace(
"$top$", (toplabel[objectMante.
Tab - 1] + 1).ToString());
760 objectDef = objectDef.Replace(
"$width$", widthcontrol.ToString());
761 objectDef = objectDef.Replace(
"$height$", heightcontrol.ToString());
762 objectDef = objectDef.Replace(
"$maxlength$", maxlength.ToString());
763 objectDef = objectDef.Replace(
"$tabindex$", tabindex.ToString());
766 objectDef = objectDef.Replace(
"$objectcaption$",
"");
770 objectDef = objectDef.Replace(
"$objectcaption$", tituloCampo);
773 controlsDefCode += objectDef;
777 propertyObject = sourcePropertiesCode;
778 propertyObject = propertyObject.Replace(
"$propertyname$", nombrePropiedad);
779 propertyObject = propertyObject.Replace(
"$privatepropertyname$", nombrePropiedadPrivada);
780 propertyObject = propertyObject.Replace(
"$propertyset$", nombrePropiedadPrivada +
" = value");
781 propertyObject = propertyObject.Replace(
"$fieldname$", nombreCampo.ToUpper());
782 propertyObject = propertyObject.Replace(
"$converto$",
"ToBoolean");
783 propertyObject = propertyObject.Replace(
"$propertytype$",
"bool");
784 propertyObject = propertyObject.Replace(
"$emptyvalue$",
"false");
785 propertyCode += propertyObject;
787 fieldsLoad +=
"this." + nombrePropiedad +
" = false;" + Environment.NewLine;
794 bindingObject = sourceBindingsCode;
795 bindingObject = bindingObject.Replace(
"$objectname$",
"ewnumericupdown" + nombreControl);
796 bindingObject = bindingObject.Replace(
"$propertybinding$",
"Value");
797 bindingObject = bindingObject.Replace(
"$propertyname$", nombrePropiedad);
798 bindingObject = bindingObject.Replace(
"$negocioclass$",
"extensionMante");
799 bindingsCode += bindingObject;
801 blockCode += tab + tab + tab +
"ewnumericupdown" + nombreControl +
".ReadOnly = tlReadOnly;" + Environment.NewLine;
803 instanceObjectsCode += tab + tab + tab +
"this.ewnumericupdown" + nombreControl +
" = new sage.ew.objetos.ewnumericupdown();" + Environment.NewLine;
805 controlsAddCode += tab + tab + tab + nomPagina +
".Controls.Add(this.ewnumericupdown" + nombreControl +
");" + Environment.NewLine;
807 controlDeclare += tab + tab +
"private sage.ew.objetos.ewnumericupdown ewnumericupdown" + nombreControl +
";" + Environment.NewLine;
809 objectDef = sourceNumericUpDownCode;
810 objectDef = objectDef.Replace(
"$objectname$",
"ewnumericupdown" + nombreControl);
811 objectDef = objectDef.Replace(
"$left$", leftcontrol.ToString());
812 objectDef = objectDef.Replace(
"$top$", topcontrol[objectMante.
Tab - 1].ToString());
813 objectDef = objectDef.Replace(
"$width$", widthcontrol.ToString());
814 objectDef = objectDef.Replace(
"$height$", heightcontrol.ToString());
815 objectDef = objectDef.Replace(
"$maxlength$", maxlength.ToString());
816 objectDef = objectDef.Replace(
"$tabindex$", tabindex.ToString());
822 controlsDefCode += objectDef;
826 propertyObject = sourcePropertiesCode;
827 propertyObject = propertyObject.Replace(
"$propertyname$", nombrePropiedad);
828 propertyObject = propertyObject.Replace(
"$privatepropertyname$", nombrePropiedadPrivada);
829 propertyObject = propertyObject.Replace(
"$propertyset$", nombrePropiedadPrivada +
" = value");
830 propertyObject = propertyObject.Replace(
"$fieldname$", nombreCampo.ToUpper());
831 propertyObject = propertyObject.Replace(
"$propertytype$",
"decimal");
832 propertyObject = propertyObject.Replace(
"$converto$",
"ToDecimal");
833 propertyObject = propertyObject.Replace(
"$emptyvalue$",
"0");
834 propertyCode += propertyObject;
836 fieldsLoad +=
"this." + nombrePropiedad +
" = 0;" + Environment.NewLine;
843 bindingObject = sourceBindingsCode;
844 bindingObject = bindingObject.Replace(
"$objectname$",
"ewdatetime" + nombreControl);
845 bindingObject = bindingObject.Replace(
"$propertybinding$",
"Value");
846 bindingObject = bindingObject.Replace(
"$propertyname$", nombrePropiedad);
847 bindingObject = bindingObject.Replace(
"$negocioclass$",
"extensionMante");
848 bindingsCode += bindingObject;
850 blockCode += tab + tab + tab +
"ewdatetime" + nombreControl +
".Enabled = !tlReadOnly;" + Environment.NewLine;
852 instanceObjectsCode += tab + tab + tab +
"this.ewdatetime" + nombreControl +
" = new sage.ew.objetos.ewdatetime();" + Environment.NewLine;
854 controlsAddCode += tab + tab + tab + nomPagina +
".Controls.Add(this.ewdatetime" + nombreControl +
");" + Environment.NewLine;
856 controlDeclare += tab + tab +
"private sage.ew.objetos.ewdatetime ewdatetime" + nombreControl +
";" + Environment.NewLine;
858 objectDef = sourceDateTimeCode;
859 objectDef = objectDef.Replace(
"$objectname$",
"ewdatetime" + nombreControl);
860 objectDef = objectDef.Replace(
"$left$", leftcontrol.ToString());
861 objectDef = objectDef.Replace(
"$top$", topcontrol[objectMante.
Tab - 1].ToString());
862 objectDef = objectDef.Replace(
"$width$", widthcontrol.ToString());
863 objectDef = objectDef.Replace(
"$height$", heightcontrol.ToString());
864 objectDef = objectDef.Replace(
"$maxlength$", maxlength.ToString());
865 objectDef = objectDef.Replace(
"$tabindex$", tabindex.ToString());
867 controlsDefCode += objectDef;
871 propertyObject = sourcePropertiesCode;
872 propertyObject = propertyObject.Replace(
"$propertyname$", nombrePropiedad);
873 propertyObject = propertyObject.Replace(
"$privatepropertyname$", nombrePropiedadPrivada);
874 propertyObject = propertyObject.Replace(
"$propertyset$", nombrePropiedadPrivada +
" = value");
875 propertyObject = propertyObject.Replace(
"$fieldname$", nombreCampo.ToUpper());
876 propertyObject = propertyObject.Replace(
"$propertytype$",
"DateTime");
877 propertyObject = propertyObject.Replace(
"$converto$",
"ToDateTime");
878 propertyObject = propertyObject.Replace(
"$emptyvalue$",
"DateTime.Now.Date");
879 propertyCode += propertyObject;
881 fieldsLoad +=
"this." + nombrePropiedad +
" = DateTime.Now.Date;" + Environment.NewLine;
888 bindingObject = sourceBindingsCode;
889 bindingObject = bindingObject.Replace(
"$objectname$",
"txt" + nombreControl);
890 bindingObject = bindingObject.Replace(
"$propertybinding$",
"_Codigo");
891 bindingObject = bindingObject.Replace(
"$propertyname$", nombrePropiedad);
892 bindingObject = bindingObject.Replace(
"$negocioclass$",
"extensionMante");
893 bindingsCode += bindingObject;
895 string deftxtcodlabel = objectMante.
TxtCodLabel.Trim();
897 blockCode += tab + tab + tab +
"txt" + nombreControl +
"._ReadOnly = tlReadOnly;" + Environment.NewLine;
899 instanceObjectsCode += tab + tab + tab +
"this.txt" + nombreControl +
" = new " + deftxtcodlabel +
"();" + Environment.NewLine;
901 controlsAddCode += tab + tab + tab + nomPagina +
".Controls.Add(this.txt" + nombreControl +
");" + Environment.NewLine;
903 controlDeclare += tab + tab +
"private " + deftxtcodlabel +
" txt" + nombreControl +
";" + Environment.NewLine;
905 objectDef = sourceTxtCodLabelCode;
906 objectDef = objectDef.Replace(
"$objectname$",
"txt" + nombreControl);
907 objectDef = objectDef.Replace(
"$left$", leftcontrol.ToString());
908 objectDef = objectDef.Replace(
"$top$", topcontrol[objectMante.
Tab - 1].ToString());
909 objectDef = objectDef.Replace(
"$width$", 200.ToString());
910 objectDef = objectDef.Replace(
"$height$", (heightcontrol + 1).ToString());
911 objectDef = objectDef.Replace(
"$maxlength$", maxlength.ToString());
912 objectDef = objectDef.Replace(
"$tabindex$", tabindex.ToString());
914 controlsDefCode += objectDef;
918 propertyObject = sourcePropertiesCode;
919 propertyObject = propertyObject.Replace(
"$propertyname$", nombrePropiedad);
920 propertyObject = propertyObject.Replace(
"$privatepropertyname$", nombrePropiedadPrivada);
921 propertyObject = propertyObject.Replace(
"$propertyset$", nombrePropiedadPrivada +
" = value");
922 propertyObject = propertyObject.Replace(
"$fieldname$", nombreCampo.ToUpper());
923 propertyObject = propertyObject.Replace(
"$propertytype$",
"string");
924 propertyObject = propertyObject.Replace(
"$converto$",
"ToString");
925 propertyObject = propertyObject.Replace(
"$emptyvalue$",
"String.Empty");
926 propertyCode += propertyObject;
928 fieldsLoad +=
"this." + nombrePropiedad +
" = String.Empty;" + Environment.NewLine;
933 topcontrol[objectMante.
Tab - 1] += heightcontrol + 6;
934 toplabel[objectMante.
Tab - 1] += heightcontrol + 6;
940 sourceCode = Resources.TabManteBase;
942 sourceCode = sourceCode.Replace(
"$usercontrolname$", _nombreControl);
943 sourceCode = sourceCode.Replace(
"$properties$", propertyCode);
944 sourceCode = sourceCode.Replace(
"$bindings$", bindingsCode);
945 sourceCode = sourceCode.Replace(
"$bloqueos$", blockCode);
946 sourceCode = sourceCode.Replace(
"$instanceobjects$", instanceObjectsCode);
947 sourceCode = sourceCode.Replace(
"$controlsadd$", controlsAddCode);
948 sourceCode = sourceCode.Replace(
"$showpages$", showPageCode);
949 sourceCode = sourceCode.Replace(
"$controlsdef$", controlsDefCode);
950 sourceCode = sourceCode.Replace(
"$formdef$", formDefCode);
951 sourceCode = sourceCode.Replace(
"$controlsdeclares$", controlDeclare);
955 BackupFile(sourceFile);
956 streamWriter = File.CreateText(sourceFile);
957 streamWriter.Write(sourceCode);
958 streamWriter.Close();
962 itemWindow = projectItem.Open();
963 itemWindow.Activate();
977 public CodeClass
GetCodeClass(
string _className, out
string messageError, ProjectItem prjItem = null)
979 CodeClass codeClass = null;
981 Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();
992 messageError =
"No se ha encontrado la clase principal del módulo.";
997 FileCodeModel fcm = prjItem.FileCodeModel;
1000 messageError =
"No se ha encontrado código dentro de la clase principal del módulo.";
1005 CodeElements ces = fcm.CodeElements;
1008 CodeNamespace cns = null;
1009 foreach (CodeElement ce
in ces)
1011 if (ce.Kind == vsCMElement.vsCMElementNamespace)
1013 cns = ce as CodeNamespace;
1019 messageError =
"No se ha encontrado el miembro namespace dentro de la clase principal del módulo.";
1026 messageError =
"No se ha encontrado ningún miembro dentro del namespace de la clase principal del módulo.";
1031 CodeClass cls = null;
1032 foreach (CodeElement ce
in ces)
1034 if (ce.Kind == vsCMElement.vsCMElementClass)
1036 cls = ce as CodeClass;
1038 if (cls.Name == _className)
1057 public T GetCodeElement<T>(
string _functionName, out
string messageError, ProjectItem prjItem = null,
string className =
"",
int parametersNumber = -1)
1059 T codeElement =
default(T);
1061 Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();
1064 if (
string.IsNullOrWhiteSpace(className))
1070 if (prjItem == null)
1075 if (prjItem == null)
1077 messageError =
"No se ha encontrado la clase principal del módulo.";
1081 CodeClass codeClass = GetCodeClass(className, out messageError, prjItem);
1082 if (codeClass == null)
1084 messageError =
"No se ha encontrado la clase " + codeClass +
" dentro de la clase principal del módulo.";
1089 foreach (CodeElement ce
in codeClass.Members)
1091 if (ce.Name == _functionName)
1093 if (ce is CodeFunction)
1095 CodeFunction cf = (CodeFunction)ce;
1097 if (parametersNumber > -1)
1100 if (cf.Parameters.Count == parametersNumber)
1102 codeElement = (T)ce;
1109 codeElement = (T)ce;
1115 codeElement = (T)ce;
1133 public bool ModificarMante(
string _nombreModulo,
string _nombreMante,
string _nombreTabla,
string _nombreConnex, out
string _messageError)
1137 string nombreManteExt =
"ManteExt" + CultureInfo.CurrentCulture.TextInfo.ToTitleCase(_nombreMante.ToLower()).Trim() +
AddonsExecute.
NombreAddon;
1138 string nombreFormManteExt =
"Form" + nombreManteExt;
1141 Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();
1144 Dictionary<string, object> regmante = DB.SQLREGValor(
"mantes",
"pantalla", _nombreMante, _nombreConnex);
1146 if (regmante.Count == 0)
1148 _messageError =
"No se ha encontrado el mantenimiento " + _nombreMante +
" en el módulo " + _nombreModulo +
".";
1153 string nomClasse = regmante[
"clase"].ToString().Trim();
1159 #region Mètode _Extension 1161 CodeFunction codeFunction = GetCodeElement<CodeFunction>(
"_Extension", out _messageError, prjItem);
1164 if (codeFunction == null)
1168 codeFunction = codeClass.AddFunction(
"_Extension", vsCMFunction.vsCMFunctionFunction, vsCMTypeRef.vsCMTypeRefObject, -1, vsCMAccess.vsCMAccessPublic);
1169 codeFunction.AddParameter(
"_key", vsCMTypeRef.vsCMTypeRefString);
1171 EditPoint editPointC = codeFunction.StartPoint.CreateEditPoint();
1174 editPointC.Insert(
"/// <summary>" + Environment.NewLine);
1175 editPointC.Indent(null, 2);
1176 editPointC.Insert(
"/// Método para obtener la instancia de la clase de extensiones desde los documentos" + Environment.NewLine);
1177 editPointC.Indent(null, 2);
1178 editPointC.Insert(
"/// </summary>" + Environment.NewLine);
1179 editPointC.Indent(null, 2);
1180 editPointC.Insert(
"/// <param name=\"tcKey\"></param>" + Environment.NewLine);
1182 editPointC.Indent(null, 2);
1183 editPointC.CharRight(7);
1184 editPointC.Insert(
"override ");
1187 editPointC.FindPattern(
"return default(object);");
1188 editPointC.Delete(23);
1191 editPointC.Insert(
"object loInstancia = null;" + Environment.NewLine);
1192 editPointC.Insert(Environment.NewLine);
1193 editPointC.Indent(null, 3);
1194 editPointC.Insert(
"_key = _key.ToLower().Trim();" + Environment.NewLine);
1195 editPointC.Insert(Environment.NewLine);
1196 editPointC.Indent(null, 3);
1197 editPointC.Insert(
"switch (_key)" + Environment.NewLine);
1198 editPointC.Indent(null, 3);
1199 editPointC.Insert(
"{" + Environment.NewLine);
1200 editPointC.Indent(null, 4);
1201 editPointC.Insert(
"default:" + Environment.NewLine);
1202 editPointC.Indent(null, 5);
1203 editPointC.Insert(
"break;" + Environment.NewLine);
1204 editPointC.Indent(null, 3);
1205 editPointC.Insert(
"}" + Environment.NewLine);
1206 editPointC.Insert(Environment.NewLine);
1207 editPointC.Indent(null, 3);
1208 editPointC.Insert(
"return loInstancia;" + Environment.NewLine);
1214 EditPoint editPoint = codeFunction.StartPoint.CreateEditPoint();
1217 string sentence =
"case \"" + regmante[
"pantalla"].ToString().Trim().ToLower() +
"\":";
1219 if (!editPoint.FindPattern(sentence))
1226 if (editPoint.FindPattern(
"switch (_key)"))
1228 if (editPoint.FindPattern(
"default:"))
1234 lbOk = editPoint.FindPattern(
"case ");
1240 _messageError =
"No se ha podido determinar la posición de inserción de las instrucciones de código en el método _Extension del fichero SageAddons.cs";
1244 editPoint.Insert(sentence + Environment.NewLine);
1245 editPoint.Indent(null, 5);
1246 editPoint.Insert(
"loInstancia = new Negocio.Mantes." + nombreManteExt +
"(_mantePrincipal);" + Environment.NewLine);
1249 editPoint.Indent(null, 5);
1250 editPoint.Insert(
"break;" + Environment.NewLine);
1253 editPoint.StartOfLine();
1254 editPoint.Indent(null, 4);
1257 #endregion Mètode _Extension 1260 #region Mètode _BindForm 1262 codeFunction = null;
1263 codeFunction = GetCodeElement<CodeFunction>(
"_BindForm", out _messageError, prjItem);
1266 if (codeFunction == null)
1270 codeFunction = codeClass.AddFunction(
"_BindForm", vsCMFunction.vsCMFunctionFunction, vsCMTypeRef.vsCMTypeRefVoid, -1, vsCMAccess.vsCMAccessPublic);
1271 codeFunction.AddParameter(
"_nombreForm", vsCMTypeRef.vsCMTypeRefString);
1272 codeFunction.AddParameter(
"_formBase", vsCMTypeRef.vsCMTypeRefObject, -1);
1274 EditPoint editPointC = codeFunction.StartPoint.CreateEditPoint();
1277 editPointC.Insert(
"/// <summary>" + Environment.NewLine);
1278 editPointC.Indent(null, 2);
1279 editPointC.Insert(
"/// Vincula los formularios de la aplicación con los del addon" + Environment.NewLine);
1280 editPointC.Indent(null, 2);
1281 editPointC.Insert(
"/// </summary>" + Environment.NewLine);
1282 editPointC.Indent(null, 2);
1283 editPointC.Insert(
"/// <param name=\"_nombreForm\"></param>" + Environment.NewLine);
1284 editPointC.Indent(null, 2);
1285 editPointC.Insert(
"/// <param name=\"_formBase\"></param>" + Environment.NewLine);
1287 editPointC.Indent(null, 2);
1288 editPointC.CharRight(7);
1289 editPointC.Insert(
"override ");
1291 editPointC.CharRight(35);
1292 editPointC.Delete(6);
1293 editPointC.Insert(
"sage.ew.formul.FormBase");
1296 editPointC.LineDown(2);
1297 editPointC.Indent(null, 3);
1298 editPointC.Insert(
"string nombreForm = _nombreForm.ToLower().Trim();" + Environment.NewLine);
1299 editPointC.Insert(Environment.NewLine);
1300 editPointC.Indent(null, 3);
1301 editPointC.Insert(
"// Puede que el formulario sea el FormMante base. En ese caso, utilizamos el nombre de _Pantalla" + Environment.NewLine);
1302 editPointC.Indent(null, 3);
1303 editPointC.Insert(
"if (nombreForm == \"formmante\")" + Environment.NewLine);
1304 editPointC.Indent(null, 4);
1305 editPointC.Insert(
"nombreForm = _formBase._Pantalla.ToLower().Trim();" + Environment.NewLine);
1306 editPointC.Insert(Environment.NewLine);
1307 editPointC.Indent(null, 3);
1308 editPointC.Insert(
"switch (nombreForm)" + Environment.NewLine);
1309 editPointC.Indent(null, 3);
1310 editPointC.Insert(
"{" + Environment.NewLine);
1311 editPointC.Indent(null, 4);
1312 editPointC.Insert(
"default:" + Environment.NewLine);
1313 editPointC.Indent(null, 5);
1314 editPointC.Insert(
"break;" + Environment.NewLine);
1315 editPointC.Indent(null, 3);
1316 editPointC.Insert(
"}" + Environment.NewLine);
1321 editPoint = codeFunction.StartPoint.CreateEditPoint();
1324 if (regmante[
"pantalla"].ToString().Trim().ToLower() ==
"proveed")
1327 sentence =
"case \"frmproveedor\":";
1331 sentence =
"case \"" +
"frm" + regmante[
"pantalla"].ToString().Trim().ToLower() +
"\":";
1334 if (!editPoint.FindPattern(sentence))
1341 if (editPoint.FindPattern(
"switch (_nombreForm)"))
1343 if (editPoint.FindPattern(
"default:"))
1349 lbOk = editPoint.FindPattern(
"case ");
1355 _messageError =
"No se ha podido determinar la posición de inserción de las instrucciones de código en el método _BindForm del fichero SageAddons.cs";
1360 editPoint.Insert(sentence + Environment.NewLine);
1362 editPoint.Indent(null, 5);
1363 editPoint.Insert(
"case \"" + regmante[
"pantalla"].ToString().Trim().ToLower() +
"\":" + Environment.NewLine);
1366 editPoint.Indent(null, 5);
1367 editPoint.Insert(
"Negocio.Mantes." + nombreFormManteExt +
" " + nombreFormManteExt.ToLower() +
" = new Negocio.Mantes." + nombreFormManteExt +
"((sage.ew.formul.Forms.FormMante)_formBase, this);" + Environment.NewLine);
1370 editPoint.Indent(null, 5);
1371 editPoint.Insert(
"break;" + Environment.NewLine);
1374 editPoint.StartOfLine();
1375 editPoint.Indent(null, 4);
1378 #endregion Mètode _BindForm 1401 public bool ModificarManteTRel(
string _nombreManteTRel,
string _nombreTabla,
string _nombreTablaManteTRel, out
string _messageError)
1406 Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();
1413 #region Mètode _Extension 1415 CodeFunction codeFunction = GetCodeElement<CodeFunction>(
"_ExtensionManteTRel", out _messageError, prjItem);
1418 if (codeFunction == null)
1422 codeFunction = codeClass.AddFunction(
"_ExtensionManteTRel", vsCMFunction.vsCMFunctionFunction, vsCMTypeRef.vsCMTypeRefObject, -1, vsCMAccess.vsCMAccessPublic);
1423 codeFunction.AddParameter(
"_key", vsCMTypeRef.vsCMTypeRefString);
1425 EditPoint editPointC = codeFunction.StartPoint.CreateEditPoint();
1428 editPointC.Insert(
"/// <summary>" + Environment.NewLine);
1429 editPointC.Indent(null, 2);
1430 editPointC.Insert(
"/// Método para obtener las instancias de clases de extensiones de mantenimientos de tablas relacionadas (ManteTRel)" + Environment.NewLine);
1431 editPointC.Indent(null, 2);
1432 editPointC.Insert(
"/// </summary>" + Environment.NewLine);
1433 editPointC.Indent(null, 2);
1434 editPointC.Insert(
"/// <param name=\"_key\">Nombre por el que identificar el mantenimiento de relacionado</param>" + Environment.NewLine);
1435 editPointC.Indent(null, 2); editPointC.Insert(
"/// <param name=\"_manteTRelPrincipal\">Mantenimiento relacionado principal (el que se va a extender)</param>" + Environment.NewLine);
1436 editPointC.Insert(
"/// <param name=\"_ordenAddon\">Número de orden en que se cargará el addon y sus columnas</param>" + Environment.NewLine);
1437 editPointC.Indent(null, 2);
1438 editPointC.Insert(
"/// <returns></returns>" + Environment.NewLine);
1440 editPointC.Indent(null, 2);
1441 editPointC.CharRight(7);
1442 editPointC.Insert(
"override ");
1445 editPointC.FindPattern(
"return default(object);");
1446 editPointC.Delete(23);
1449 editPointC.Insert(
"object loInstancia = null;" + Environment.NewLine);
1450 editPointC.Insert(Environment.NewLine);
1451 editPointC.Indent(null, 3);
1452 editPointC.Insert(
"_key = _key.ToLower().Trim();" + Environment.NewLine);
1453 editPointC.Insert(Environment.NewLine);
1454 editPointC.Indent(null, 3);
1455 editPointC.Insert(
"switch (_key)" + Environment.NewLine);
1456 editPointC.Indent(null, 3);
1457 editPointC.Insert(
"{" + Environment.NewLine);
1458 editPointC.Indent(null, 4);
1459 editPointC.Insert(
"default:" + Environment.NewLine);
1460 editPointC.Indent(null, 5);
1461 editPointC.Insert(
"break;" + Environment.NewLine);
1462 editPointC.Indent(null, 3);
1463 editPointC.Insert(
"}" + Environment.NewLine);
1464 editPointC.Insert(Environment.NewLine);
1465 editPointC.Indent(null, 3);
1466 editPointC.Insert(
"return loInstancia;" + Environment.NewLine);
1472 EditPoint editPoint = codeFunction.StartPoint.CreateEditPoint();
1475 string sentence =
"case \"" + _nombreTablaManteTRel.ToString().Trim().ToLower() +
"\":";
1477 if (!editPoint.FindPattern(sentence))
1484 if (editPoint.FindPattern(
"switch (_key)"))
1486 if (editPoint.FindPattern(
"default:"))
1492 lbOk = editPoint.FindPattern(
"case ");
1498 _messageError =
"No se ha podido determinar la posición de inserción de las instrucciones de código en el método _Extension del fichero SageAddons.cs";
1502 editPoint.Insert(sentence + Environment.NewLine);
1503 editPoint.Indent(null, 5);
1504 editPoint.Insert(
"loInstancia = new Negocio.Clases." + _nombreTabla +
"(_manteTRelPrincipal, _ordenAddon);" + Environment.NewLine);
1507 editPoint.Indent(null, 5);
1508 editPoint.Insert(
"break;" + Environment.NewLine);
1511 editPoint.StartOfLine();
1512 editPoint.Indent(null, 4);
1515 #endregion Mètode _Extension 1544 Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();
1553 string tcUrlAnt = GetUrlAyuda(out _messageError);
1556 if (!
string.IsNullOrWhiteSpace(tcUrlAnt))
1560 EditPoint editPointIni = codeFunction.StartPoint.CreateEditPoint();
1561 EditPoint editPointFin = codeFunction.StartPoint.CreateEditPoint();
1562 editPointIni.StartOfDocument();
1563 editPointFin.EndOfDocument();
1565 editPointIni.ReplacePattern(editPointFin, $
"\"{tcUrlAnt}\"", $
"\"{tcUrl}\"");
1567 catch (Exception loEx)
1569 string lcMsg = loEx.Message;
1575 EditPoint editPoint = codeFunction.StartPoint.CreateEditPoint();
1577 string sentence =
"}";
1578 if (editPoint.FindPattern(sentence))
1580 editPoint.Indent(null, 1);
1581 editPoint.Insert($
"_UrlAyudaAddon = \"{tcUrl}\";" + Environment.NewLine);
1582 editPoint.StartOfLine();
1583 editPoint.Indent(null, 2);
1607 string tcUrl =
string.Empty;
1610 Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();
1618 EditPoint editPoint = codeFunction.StartPoint.CreateEditPoint();
1620 string sentence =
"_UrlAyudaAddon";
1621 if (editPoint.FindPattern(sentence))
1623 string tcText = editPoint.GetText(editPoint.LineLength).Trim();
1624 int lnPosIni = tcText.IndexOf(
"\"");
1625 int lnPosFin = tcText.LastIndexOf(
"\"");
1626 if (lnPosIni > 0 && lnPosFin > 0 && lnPosIni < lnPosFin)
1628 tcUrl = tcText.Substring(lnPosIni + 1, lnPosFin - lnPosIni - 1);
1646 public bool CrearExtensionMante(
string _nombreModulo,
string _nombreMante,
string _nombreTabla,
string _nombreUserControl,
bool _sinTabla, out
string _messageError)
1651 Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();
1653 string nombreManteExt =
"ManteExt" + CultureInfo.CurrentCulture.TextInfo.ToTitleCase(_nombreMante.ToLower()).Trim() +
AddonsExecute.
NombreAddon;
1654 string nombreFormManteExt =
"Form" + nombreManteExt;
1655 string nombreUserControl = _nombreUserControl;
1656 string fieldkey =
"";
1657 string propertykey =
"";
1658 string sqlfields =
"";
1659 string sqlvaules =
"";
1660 string sqlfieldsvalues =
"";
1661 string sqlSelect =
"";
1662 string sqlInsert =
"";
1663 string sqlUpdate =
"";
1664 string sqlDelete =
"";
1666 string comastr =
"";
1667 string comillacoma =
"";
1668 string propertyObject =
"";
1669 string fieldsClear =
"";
1670 string fieldsLoad =
"";
1671 string propertyCode =
"";
1672 string nombreDataTable = _nombreTabla +
"result";
1677 Char comilles =
new Char();
1680 if (nombreUserControl.Substring(0, 3).ToLower() ==
"usr")
1682 nombreUserControl = nombreUserControl.Substring(3);
1685 if (GetSourceFile(nombreManteExt +
".cs") != null)
1687 _messageError =
"El fichero " + nombreManteExt +
".cs" +
" ya existe en el proyecto.";
1691 string sourcePropertiesCode = Resources.PropertiesUserControls;
1694 foreach (dynamic anyobjectMante
in this.CamposNuevoMante)
1700 string nombreControl = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(objectMante.
Nombre.ToLower()).Trim();
1701 string nombreCampo = nombreControl;
1702 string nombrePropiedad =
"_" + nombreControl;
1703 string nombrePropiedadPrivada =
"_private" + nombreControl;
1708 fieldkey = nombreCampo;
1709 propertykey = nombrePropiedad;
1713 sqlfields += coma + nombreCampo;
1714 sqlvaules += comastr +
"DB.SQLString(this." + nombrePropiedad +
")";
1715 sqlfieldsvalues += comillacoma + nombreCampo +
" = " + comilles +
" + DB.SQLString(this." + nombrePropiedad +
") + ";
1718 comastr =
" + " + comilles +
", " + comilles +
" + ";
1719 comillacoma = comilles +
", ";
1724 propertyObject = sourcePropertiesCode;
1725 propertyObject = propertyObject.Replace(
"$propertyname$", nombrePropiedad);
1726 propertyObject = propertyObject.Replace(
"$privatepropertyname$", nombrePropiedadPrivada);
1727 propertyObject = propertyObject.Replace(
"$propertyset$", nombrePropiedadPrivada +
" = value");
1728 propertyObject = propertyObject.Replace(
"$fieldname$", nombreCampo.ToUpper());
1729 propertyObject = propertyObject.Replace(
"$propertytype$",
"string");
1730 propertyObject = propertyObject.Replace(
"$converto$",
"ToString");
1731 propertyObject = propertyObject.Replace(
"$emptyvalue$",
" = String.Empty");
1732 propertyCode += propertyObject;
1736 fieldsClear += tab + tab + tab + tab +
"this." + nombrePropiedad +
" = _Mante._Codigo;" + Environment.NewLine;
1740 fieldsClear += tab + tab + tab + tab +
"this." + nombrePropiedad +
" = String.Empty;" + Environment.NewLine;
1743 fieldsLoad += tab + tab + tab + tab +
"this." + nombrePropiedad +
" = Convert.ToString(" + nombreDataTable +
".Rows[0][" + comilles + nombreCampo + comilles +
"]);" + Environment.NewLine;
1748 propertyObject = sourcePropertiesCode;
1749 propertyObject = propertyObject.Replace(
"$propertyname$", nombrePropiedad);
1750 propertyObject = propertyObject.Replace(
"$privatepropertyname$", nombrePropiedadPrivada);
1751 propertyObject = propertyObject.Replace(
"$propertyset$", nombrePropiedadPrivada +
" = value");
1752 propertyObject = propertyObject.Replace(
"$fieldname$", nombreCampo.ToUpper());
1753 propertyObject = propertyObject.Replace(
"$converto$",
"ToBoolean");
1754 propertyObject = propertyObject.Replace(
"$propertytype$",
"bool");
1755 propertyObject = propertyObject.Replace(
"$emptyvalue$",
" = false");
1756 propertyCode += propertyObject;
1758 fieldsClear += tab + tab + tab + tab +
"this." + nombrePropiedad +
" = false;" + Environment.NewLine;
1760 fieldsLoad += tab + tab + tab + tab +
"this." + nombrePropiedad +
" = Convert.ToBoolean(" + nombreDataTable +
".Rows[0][" + comilles + nombreCampo + comilles +
"]);" + Environment.NewLine;
1765 propertyObject = sourcePropertiesCode;
1766 propertyObject = propertyObject.Replace(
"$propertyname$", nombrePropiedad);
1767 propertyObject = propertyObject.Replace(
"$privatepropertyname$", nombrePropiedadPrivada);
1768 propertyObject = propertyObject.Replace(
"$propertyset$", nombrePropiedadPrivada +
" = value");
1769 propertyObject = propertyObject.Replace(
"$fieldname$", nombreCampo.ToUpper());
1770 propertyObject = propertyObject.Replace(
"$propertytype$",
"decimal");
1771 propertyObject = propertyObject.Replace(
"$converto$",
"ToDecimal");
1772 propertyObject = propertyObject.Replace(
"$emptyvalue$",
" = 0");
1773 propertyCode += propertyObject;
1775 fieldsClear += tab + tab + tab + tab +
"this." + nombrePropiedad +
" = 0;" + Environment.NewLine;
1777 fieldsLoad += tab + tab + tab + tab +
"this." + nombrePropiedad +
" = Convert.ToDecimal(" + nombreDataTable +
".Rows[0][" + comilles + nombreCampo + comilles +
"]);" + Environment.NewLine;
1782 propertyObject = sourcePropertiesCode;
1783 propertyObject = propertyObject.Replace(
"$propertyname$", nombrePropiedad);
1784 propertyObject = propertyObject.Replace(
"$privatepropertyname$", nombrePropiedadPrivada);
1785 propertyObject = propertyObject.Replace(
"$propertyset$", nombrePropiedadPrivada +
" = value");
1786 propertyObject = propertyObject.Replace(
"$fieldname$", nombreCampo.ToUpper());
1787 propertyObject = propertyObject.Replace(
"$propertytype$",
"DateTime");
1788 propertyObject = propertyObject.Replace(
"$converto$",
"ToDateTime");
1789 propertyObject = propertyObject.Replace(
"$emptyvalue$",
" = DateTime.Now.Date");
1790 propertyCode += propertyObject;
1792 fieldsClear += tab + tab + tab + tab +
"this." + nombrePropiedad +
" = DateTime.Now.Date;" + Environment.NewLine;
1794 fieldsLoad += tab + tab + tab + tab +
"this." + nombrePropiedad +
" = Convert.ToDateTime(" + nombreDataTable +
".Rows[0][" + comilles + nombreCampo + comilles +
"]);" + Environment.NewLine;
1799 propertyObject = sourcePropertiesCode;
1800 propertyObject = propertyObject.Replace(
"$propertyname$", nombrePropiedad);
1801 propertyObject = propertyObject.Replace(
"$privatepropertyname$", nombrePropiedadPrivada);
1802 propertyObject = propertyObject.Replace(
"$propertyset$", nombrePropiedadPrivada +
" = value");
1803 propertyObject = propertyObject.Replace(
"$fieldname$", nombreCampo.ToUpper());
1804 propertyObject = propertyObject.Replace(
"$propertytype$",
"string");
1805 propertyObject = propertyObject.Replace(
"$converto$",
"ToString");
1806 propertyObject = propertyObject.Replace(
"$emptyvalue$",
" = String.Empty");
1807 propertyCode += propertyObject;
1809 fieldsClear += tab + tab + tab + tab +
"this." + nombrePropiedad +
" = String.Empty;" + Environment.NewLine;
1811 fieldsLoad += tab + tab + tab + tab +
"this." + nombrePropiedad +
" = Convert.ToString(" + nombreDataTable +
".Rows[0][" + comilles + nombreCampo + comilles +
"]);" + Environment.NewLine;
1819 sqlSelect += comilles +
"Select " + sqlfields +
" " + comilles +
" + " + Environment.NewLine;
1820 sqlSelect += tab + tab + tab + tab + comilles +
"From " + comilles +
" + DB.SQLDatabase(this._DataBase, this._Tabla) + " + comilles +
" " + comilles +
" + " + Environment.NewLine;
1821 sqlSelect += tab + tab + tab + tab + comilles +
"Where " + comilles +
" + this._Clave + " + comilles +
" = " + comilles +
" + DB.SQLString(this." + propertykey +
");" + Environment.NewLine;
1824 sqlInsert += comilles +
"Insert Into " + comilles +
" + DB.SQLDatabase(this._DataBase, this._Tabla) + " + comilles +
" " + comilles +
" + " + Environment.NewLine;
1825 sqlInsert += tab + tab + tab + tab + tab + comilles +
"(" + sqlfields +
") " + comilles +
" + " + Environment.NewLine;
1826 sqlInsert += tab + tab + tab + tab + tab + comilles +
"Values (" + comilles +
" + " + sqlvaules +
" + " + comilles +
")" + comilles +
";" + Environment.NewLine;
1829 sqlUpdate += comilles +
"Update " + comilles +
" + DB.SQLDatabase(this._DataBase, this._Tabla) + " + comilles +
" " + comilles +
" + " + Environment.NewLine;
1830 sqlUpdate += tab + tab + tab + tab + tab + comilles +
"Set " + sqlfieldsvalues +
" " + comilles +
" " + comilles +
" + " + Environment.NewLine;
1831 sqlUpdate += tab + tab + tab + tab + tab + comilles +
"Where " + comilles +
" + this._Clave + " + comilles +
" = " + comilles +
" + DB.SQLString(this." + propertykey +
");" + Environment.NewLine;
1834 sqlDelete += comilles +
"Delete From " + comilles +
" + DB.SQLDatabase(this._DataBase, this._Tabla) + " + comilles +
" " + comilles +
" + " + Environment.NewLine;
1835 sqlDelete += tab + tab + tab + tab + tab + comilles +
"Where " + comilles +
" + this._Clave + " + comilles +
" = " + comilles +
" + DB.SQLString(this." + propertykey +
");" + Environment.NewLine;
1839 sqlSelect = comilles +
"" + comilles +
";";
1840 sqlInsert = comilles +
"" + comilles +
";";
1841 sqlUpdate = comilles +
"" + comilles +
";";
1842 sqlDelete = comilles +
"" + comilles +
";";
1845 nombreDataBase =
"";
1848 #region Crear el fichero de la extensión del mantenimiento 1850 string sourceCode =
"";
1851 sourceCode = Resources.ManteExtBase;
1853 sourceCode = sourceCode.Replace(
"$manteextname$", nombreManteExt);
1854 sourceCode = sourceCode.Replace(
"$databasename$", nombreDataBase);
1855 sourceCode = sourceCode.Replace(
"$tablename$", _nombreTabla);
1856 sourceCode = sourceCode.Replace(
"$datatablename$", nombreDataTable);
1857 sourceCode = sourceCode.Replace(
"$fieldkey$", fieldkey);
1858 sourceCode = sourceCode.Replace(
"$formmanteextname$", nombreFormManteExt);
1859 sourceCode = sourceCode.Replace(
"$usercontrolname$", nombreUserControl);
1860 sourceCode = sourceCode.Replace(
"$properties$", propertyCode);
1861 sourceCode = sourceCode.Replace(
"$fieldsclear$", fieldsClear);
1862 sourceCode = sourceCode.Replace(
"$fieldsload$", fieldsLoad);
1863 sourceCode = sourceCode.Replace(
"$sqlselect$", sqlSelect);
1864 sourceCode = sourceCode.Replace(
"$sqlinsert$", sqlInsert);
1865 sourceCode = sourceCode.Replace(
"$sqlupdate$", sqlUpdate);
1866 sourceCode = sourceCode.Replace(
"$sqldelete$", sqlDelete);
1870 BackupFile(sourceFile);
1871 StreamWriter streamWriter = File.CreateText(sourceFile);
1872 streamWriter.Write(sourceCode);
1873 streamWriter.Close();
1879 Window itemWindow = projectItem.Open();
1880 itemWindow.Activate();
1882 #endregion Crear el fichero de la extensión del mantenimiento 1903 public bool CrearNuevoMantenimiento(
string nombreMante,
string nombreTabla,
string tituloForm,
string textoMenu,
bool addCeros, out
string messageError)
1907 string nombreEWMante =
"";
1908 string nombreFormMante =
"";
1909 string nombretxtCodLabel =
"txt" + nombreMante;
1910 string nombretxtfiltrodesdehasta =
"txt" + nombreMante +
"DesdeHasta";
1911 string caracterrelleno =
" ";
1912 string tituloMante =
"Mantenimiento de " + tituloForm;
1915 StreamWriter streamWriter;
1916 ProjectItem projectItem;
1920 Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();
1925 caracterrelleno =
"0";
1931 nombreEWMante = nombreMante.Trim() +
".cs";
1932 if (SourceFileExist(nombreEWMante))
1934 messageError =
"Ya existe un fichero en el proyecto con el nombre indicado. (" + nombreEWMante +
")" + Environment.NewLine;
1939 nombreFormMante =
"frm" + nombreMante.Trim();
1940 if (SourceFileExist(nombreFormMante +
".cs"))
1942 messageError =
"Ya existe un fichero en el proyecto con el nombre indicado. (" + nombreFormMante +
")" + Environment.NewLine;
1948 if (!SourceFileExist(
"Mantes"))
1953 string bindingsCode =
"";
1954 string blockCode =
"";
1955 string propertyCode =
"";
1956 string instanceObjectsCode =
"";
1957 string controlsAddCode =
"";
1958 string controlsDefCode =
"";
1959 string controlDeclare =
"";
1960 string paginasAddCode =
"";
1963 int leftcontrol = 137;
1964 int[] toplabel =
new int[] { 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13 };
1965 int[] topcontrol =
new int[] { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 };
1966 int heightcontrol = 24;
1967 int widthcontrol = 100;
1973 string sourceBindingsCode = Resources.ControlBinding;
1974 string sourcePropertiesCode = Resources.PropertiesMantes;
1975 string sourceLabelCode = Resources.FormManteLabel;
1976 string sourceTextBoxCode = Resources.FormManteTextBox;
1977 string sourceCheckBoxCode = Resources.FormManteCheckBox;
1978 string sourceNumericUpDownCode = Resources.FormManteNumericUpDown;
1979 string sourceDateTimeCode = Resources.FormManteDateTime;
1980 string sourceTxtCodLabelCode = Resources.FormManteTxtCodLabel;
1981 string sourceTabPageCode = Resources.FormManteTabPage;
1983 string showPageCode =
"";
1984 string formDefCode = Resources.FormManteForm;
1985 if (this.CamposNuevoMante.Count > 4)
1988 formDefCode = Resources.FormManteFormExt;
1990 formDefCode = formDefCode.Replace(
"$mantename$", nombreMante);
1991 formDefCode = formDefCode.Replace(
"$formname$", nombreFormMante);
1992 formDefCode = formDefCode.Replace(
"$mantetittle$", tituloMante);
1993 formDefCode = formDefCode.Replace(
"$caracterrelleno$", caracterrelleno);
1996 if (this.CamposNuevoMante.Count > 0)
1999 if (manteProperties.
NumTabs > 1)
2001 foreach (dynamic anyobjectMante
in this.CamposNuevoMante)
2007 string nombrePagina = pagina.
Nombre;
2009 if (nombrePagina ==
"tpGeneral")
2011 Char comilles =
new Char();
2013 controlsDefCode += ts + ts + ts +
"this.tpGeneral.Text = " + comilles + pagina.
Titulo + comilles +
";" + Environment.NewLine;
2017 instanceObjectsCode += ts + ts + ts +
"this." + nombrePagina +
" = new sage.ew.objetos.ewTabPage();" + Environment.NewLine;
2018 controlDeclare += ts + ts +
"private sage.ew.objetos.ewTabPage " + nombrePagina +
";" + Environment.NewLine;
2020 paginasAddCode += ts + ts + ts +
"this.ewtcPaginas.Controls.Add(this." + nombrePagina +
");" + Environment.NewLine;
2022 string objectDef = sourceTabPageCode;
2023 objectDef = objectDef.Replace(
"$objectname$", nombrePagina);
2024 objectDef = objectDef.Replace(
"$objectcaption$", pagina.
Titulo);
2025 objectDef = objectDef.Replace(
"$tabindex$", tabindex.ToString());
2027 controlsDefCode += objectDef;
2031 paginasAddCode += ts + ts + ts +
"this.ewtcPaginas.Controls.SetChildIndex(this." + nombrePagina +
", 0);" + Environment.NewLine;
2035 controlsDefCode = paginasAddCode + controlsDefCode;
2040 foreach (dynamic anyobjectMante
in this.CamposNuevoMante)
2046 string nombreCampo = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(objectMante.
Nombre.ToLower()).Trim();
2047 string nombrePropiedad =
"_" + nombreCampo;
2048 string tituloCampo = objectMante.
TituloCampo +
":";
2050 string bindingObject =
"";
2051 string propertyObject =
"";
2052 string objectDef =
"";
2054 string nomPagina =
"this.tpGeneral";
2055 if (objectMante.
Tab > 1)
2057 nomPagina =
"this.tpPagina" + objectMante.
Tab.ToString();
2063 instanceObjectsCode += ts + ts + ts +
"this.ewlabel" + nombreCampo +
" = new sage.ew.objetos.ewlabel();" + Environment.NewLine;
2065 controlsAddCode += ts + ts + ts + nomPagina +
".Controls.Add(this.ewlabel" + nombreCampo +
");" + Environment.NewLine;
2067 controlDeclare += ts + ts +
"private sage.ew.objetos.ewlabel ewlabel" + nombreCampo +
";" + Environment.NewLine;
2069 objectDef = sourceLabelCode;
2070 objectDef = objectDef.Replace(
"$objectname$",
"ewlabel" + nombreCampo);
2071 objectDef = objectDef.Replace(
"$objectcaption$", tituloCampo);
2072 objectDef = objectDef.Replace(
"$left$", leftlabel.ToString());
2073 objectDef = objectDef.Replace(
"$top$", toplabel[objectMante.
Tab - 1].ToString());
2074 objectDef = objectDef.Replace(
"$tabindex$", tabindex.ToString());
2076 controlsDefCode += objectDef;
2084 bindingObject = sourceBindingsCode;
2085 bindingObject = bindingObject.Replace(
"$objectname$",
"ewtextbox" + nombreCampo);
2086 bindingObject = bindingObject.Replace(
"$propertybinding$",
"Text");
2087 bindingObject = bindingObject.Replace(
"$propertyname$", nombrePropiedad);
2088 bindingObject = bindingObject.Replace(
"$negocioclass$",
"_ewMante");
2089 bindingsCode += bindingObject;
2091 blockCode += ts + ts + ts +
"ewtextbox" + nombreCampo +
".ReadOnly = bloquearControles;" + Environment.NewLine;
2093 instanceObjectsCode += ts + ts + ts +
"this.ewtextbox" + nombreCampo +
" = new sage.ew.objetos.ewtextbox();" + Environment.NewLine;
2095 controlsAddCode += ts + ts + ts + nomPagina +
".Controls.Add(this.ewtextbox" + nombreCampo +
");" + Environment.NewLine;
2097 controlDeclare += ts + ts +
"private sage.ew.objetos.ewtextbox ewtextbox" + nombreCampo +
";" + Environment.NewLine;
2099 objectDef = sourceTextBoxCode;
2100 objectDef = objectDef.Replace(
"$objectname$",
"ewtextbox" + nombreCampo);
2101 objectDef = objectDef.Replace(
"$left$", leftcontrol.ToString());
2102 objectDef = objectDef.Replace(
"$top$", topcontrol[objectMante.
Tab - 1].ToString());
2103 objectDef = objectDef.Replace(
"$width$", widthcontrol.ToString());
2104 objectDef = objectDef.Replace(
"$height$", heightcontrol.ToString());
2105 objectDef = objectDef.Replace(
"$maxlength$", maxlength.ToString());
2106 objectDef = objectDef.Replace(
"$tabindex$", tabindex.ToString());
2108 controlsDefCode += objectDef;
2112 propertyObject = sourcePropertiesCode;
2113 propertyObject = propertyObject.Replace(
"$propertyname$", nombrePropiedad);
2114 propertyObject = propertyObject.Replace(
"$fieldname$", nombreCampo.ToUpper());
2115 propertyObject = propertyObject.Replace(
"$propertytype$",
"string");
2116 propertyObject = propertyObject.Replace(
"$converto$",
"ToString");
2117 propertyObject = propertyObject.Replace(
"$emptyvalue$",
"String.Empty");
2118 propertyCode += propertyObject;
2125 bindingObject = sourceBindingsCode;
2126 bindingObject = bindingObject.Replace(
"$objectname$",
"ewcheckbox" + nombreCampo);
2127 bindingObject = bindingObject.Replace(
"$propertybinding$",
"Checked");
2128 bindingObject = bindingObject.Replace(
"$propertyname$", nombrePropiedad);
2129 bindingObject = bindingObject.Replace(
"$negocioclass$",
"_ewMante");
2130 bindingsCode += bindingObject;
2132 blockCode += ts + ts + ts +
"ewcheckbox" + nombreCampo +
".Enabled = !bloquearControles;" + Environment.NewLine;
2134 instanceObjectsCode += ts + ts + ts +
"this.ewcheckbox" + nombreCampo +
" = new sage.ew.objetos.ewcheckbox();" + Environment.NewLine;
2136 controlsAddCode += ts + ts + ts + nomPagina +
".Controls.Add(this.ewcheckbox" + nombreCampo +
");" + Environment.NewLine;
2138 controlDeclare += ts + ts +
"private sage.ew.objetos.ewcheckbox ewcheckbox" + nombreCampo +
";" + Environment.NewLine;
2140 objectDef = sourceCheckBoxCode;
2141 objectDef = objectDef.Replace(
"$objectname$",
"ewcheckbox" + nombreCampo);
2142 objectDef = objectDef.Replace(
"$left$", leftcontrol.ToString());
2143 objectDef = objectDef.Replace(
"$top$", (toplabel[objectMante.
Tab - 1] + 1).ToString());
2144 objectDef = objectDef.Replace(
"$width$", widthcontrol.ToString());
2145 objectDef = objectDef.Replace(
"$height$", heightcontrol.ToString());
2146 objectDef = objectDef.Replace(
"$maxlength$", maxlength.ToString());
2147 objectDef = objectDef.Replace(
"$tabindex$", tabindex.ToString());
2150 objectDef = objectDef.Replace(
"$objectcaption$",
"");
2154 objectDef = objectDef.Replace(
"$objectcaption$", tituloCampo);
2157 controlsDefCode += objectDef;
2161 propertyObject = sourcePropertiesCode;
2162 propertyObject = propertyObject.Replace(
"$propertyname$", nombrePropiedad);
2163 propertyObject = propertyObject.Replace(
"$fieldname$", nombreCampo.ToUpper());
2164 propertyObject = propertyObject.Replace(
"$converto$",
"ToBoolean");
2165 propertyObject = propertyObject.Replace(
"$propertytype$",
"bool");
2166 propertyObject = propertyObject.Replace(
"$emptyvalue$",
"false");
2167 propertyCode += propertyObject;
2174 bindingObject = sourceBindingsCode;
2175 bindingObject = bindingObject.Replace(
"$objectname$",
"ewnumericupdown" + nombreCampo);
2176 bindingObject = bindingObject.Replace(
"$propertybinding$",
"Value");
2177 bindingObject = bindingObject.Replace(
"$propertyname$", nombrePropiedad);
2178 bindingObject = bindingObject.Replace(
"$negocioclass$",
"_ewMante");
2179 bindingsCode += bindingObject;
2181 blockCode += ts + ts + ts +
"ewnumericupdown" + nombreCampo +
".ReadOnly = bloquearControles;" + Environment.NewLine;
2183 instanceObjectsCode += ts + ts + ts +
"this.ewnumericupdown" + nombreCampo +
" = new sage.ew.objetos.ewnumericupdown();" + Environment.NewLine;
2185 controlsAddCode += ts + ts + ts + nomPagina +
".Controls.Add(this.ewnumericupdown" + nombreCampo +
");" + Environment.NewLine;
2187 controlDeclare += ts + ts +
"private sage.ew.objetos.ewnumericupdown ewnumericupdown" + nombreCampo +
";" + Environment.NewLine;
2189 objectDef = sourceNumericUpDownCode;
2190 objectDef = objectDef.Replace(
"$objectname$",
"ewnumericupdown" + nombreCampo);
2191 objectDef = objectDef.Replace(
"$left$", leftcontrol.ToString());
2192 objectDef = objectDef.Replace(
"$top$", topcontrol[objectMante.
Tab - 1].ToString());
2193 objectDef = objectDef.Replace(
"$width$", widthcontrol.ToString());
2194 objectDef = objectDef.Replace(
"$height$", heightcontrol.ToString());
2195 objectDef = objectDef.Replace(
"$maxlength$", maxlength.ToString());
2196 objectDef = objectDef.Replace(
"$tabindex$", tabindex.ToString());
2202 controlsDefCode += objectDef;
2206 propertyObject = sourcePropertiesCode;
2207 propertyObject = propertyObject.Replace(
"$propertyname$", nombrePropiedad);
2208 propertyObject = propertyObject.Replace(
"$fieldname$", nombreCampo.ToUpper());
2209 propertyObject = propertyObject.Replace(
"$propertytype$",
"decimal");
2210 propertyObject = propertyObject.Replace(
"$converto$",
"ToDecimal");
2211 propertyObject = propertyObject.Replace(
"$emptyvalue$",
"0");
2212 propertyCode += propertyObject;
2219 bindingObject = sourceBindingsCode;
2220 bindingObject = bindingObject.Replace(
"$objectname$",
"ewdatetime" + nombreCampo);
2221 bindingObject = bindingObject.Replace(
"$propertybinding$",
"Value");
2222 bindingObject = bindingObject.Replace(
"$propertyname$", nombrePropiedad);
2223 bindingObject = bindingObject.Replace(
"$negocioclass$",
"_ewMante");
2224 bindingsCode += bindingObject;
2226 blockCode += ts + ts + ts +
"ewdatetime" + nombreCampo +
".Enabled = !bloquearControles;" + Environment.NewLine;
2228 instanceObjectsCode += ts + ts + ts +
"this.ewdatetime" + nombreCampo +
" = new sage.ew.objetos.ewdatetime();" + Environment.NewLine;
2230 controlsAddCode += ts + ts + ts + nomPagina +
".Controls.Add(this.ewdatetime" + nombreCampo +
");" + Environment.NewLine;
2232 controlDeclare += ts + ts +
"private sage.ew.objetos.ewdatetime ewdatetime" + nombreCampo +
";" + Environment.NewLine;
2234 objectDef = sourceDateTimeCode;
2235 objectDef = objectDef.Replace(
"$objectname$",
"ewdatetime" + nombreCampo);
2236 objectDef = objectDef.Replace(
"$left$", leftcontrol.ToString());
2237 objectDef = objectDef.Replace(
"$top$", topcontrol[objectMante.
Tab - 1].ToString());
2238 objectDef = objectDef.Replace(
"$width$", widthcontrol.ToString());
2239 objectDef = objectDef.Replace(
"$height$", heightcontrol.ToString());
2240 objectDef = objectDef.Replace(
"$maxlength$", maxlength.ToString());
2241 objectDef = objectDef.Replace(
"$tabindex$", tabindex.ToString());
2243 controlsDefCode += objectDef;
2247 propertyObject = sourcePropertiesCode;
2248 propertyObject = propertyObject.Replace(
"$propertyname$", nombrePropiedad);
2249 propertyObject = propertyObject.Replace(
"$fieldname$", nombreCampo.ToUpper());
2250 propertyObject = propertyObject.Replace(
"$propertytype$",
"DateTime");
2251 propertyObject = propertyObject.Replace(
"$converto$",
"ToDateTime");
2252 propertyObject = propertyObject.Replace(
"$emptyvalue$",
"DateTime.Now.Date");
2253 propertyCode += propertyObject;
2260 bindingObject = sourceBindingsCode;
2261 bindingObject = bindingObject.Replace(
"$objectname$",
"txt" + nombreCampo);
2262 bindingObject = bindingObject.Replace(
"$propertybinding$",
"_Codigo");
2263 bindingObject = bindingObject.Replace(
"$propertyname$", nombrePropiedad);
2264 bindingObject = bindingObject.Replace(
"$negocioclass$",
"_ewMante");
2265 bindingsCode += bindingObject;
2269 blockCode += ts + ts + ts +
"txt" + nombreCampo +
"._ReadOnly = bloquearControles;" + Environment.NewLine;
2271 instanceObjectsCode += ts + ts + ts +
"this.txt" + nombreCampo +
" = new " + objectMante.
TxtCodLabel +
"();" + Environment.NewLine;
2273 controlsAddCode += ts + ts + ts + nomPagina +
".Controls.Add(this.txt" + nombreCampo +
");" + Environment.NewLine;
2275 controlDeclare += ts + ts +
"private " + objectMante.
TxtCodLabel +
" txt" + nombreCampo +
";" + Environment.NewLine;
2277 objectDef = sourceTxtCodLabelCode;
2278 objectDef = objectDef.Replace(
"$objectname$",
"txt" + nombreCampo);
2279 objectDef = objectDef.Replace(
"$left$", leftcontrol.ToString());
2280 objectDef = objectDef.Replace(
"$top$", topcontrol[objectMante.
Tab - 1].ToString());
2281 objectDef = objectDef.Replace(
"$width$", widthcontrol.ToString());
2282 objectDef = objectDef.Replace(
"$height$", (heightcontrol + 1).ToString());
2283 objectDef = objectDef.Replace(
"$maxlength$", maxlength.ToString());
2284 objectDef = objectDef.Replace(
"$tabindex$", tabindex.ToString());
2286 controlsDefCode += objectDef;
2290 propertyObject = sourcePropertiesCode;
2291 propertyObject = propertyObject.Replace(
"$propertyname$", nombrePropiedad);
2292 propertyObject = propertyObject.Replace(
"$fieldname$", nombreCampo.ToUpper());
2293 propertyObject = propertyObject.Replace(
"$propertytype$",
"string");
2294 propertyObject = propertyObject.Replace(
"$converto$",
"ToString");
2295 propertyObject = propertyObject.Replace(
"$emptyvalue$",
"String.Empty");
2296 propertyCode += propertyObject;
2301 topcontrol[objectMante.
Tab - 1] += heightcontrol + 6;
2302 toplabel[objectMante.
Tab - 1] += heightcontrol + 6;
2308 string sourceCode =
"";
2309 string sourceFile =
"";
2313 sourceCode = Resources.ewMante;
2315 sourceCode = sourceCode.Replace(
"$mantename$", nombreMante);
2317 sourceCode = sourceCode.Replace(
"$tablename$", nombreTabla);
2318 sourceCode = sourceCode.Replace(
"$mantetittle$", tituloMante);
2319 sourceCode = sourceCode.Replace(
"$formname$", nombreFormMante);
2320 sourceCode = sourceCode.Replace(
"$caracterrelleno$", caracterrelleno);
2321 sourceCode = sourceCode.Replace(
"$properties$", propertyCode);
2325 BackupFile(sourceFile);
2326 streamWriter = File.CreateText(sourceFile);
2327 streamWriter.Write(sourceCode);
2328 streamWriter.Close();
2332 itemWindow = projectItem.Open();
2333 itemWindow.Activate();
2338 sourceCode = Resources.FormMante;
2340 sourceCode = sourceCode.Replace(
"$mantename$", nombreMante);
2342 sourceCode = sourceCode.Replace(
"$tablename$", nombreTabla);
2343 sourceCode = sourceCode.Replace(
"$mantetittle$", tituloMante);
2344 sourceCode = sourceCode.Replace(
"$formname$", nombreFormMante);
2345 sourceCode = sourceCode.Replace(
"$caracterrelleno$", caracterrelleno);
2346 sourceCode = sourceCode.Replace(
"$bindings$", bindingsCode);
2347 sourceCode = sourceCode.Replace(
"$bloqueos$", blockCode);
2351 BackupFile(sourceFile);
2352 streamWriter = File.CreateText(sourceFile);
2353 streamWriter.Write(sourceCode);
2354 streamWriter.Close();
2360 itemWindow = projectItem.Open();
2361 itemWindow.Activate();
2366 sourceCode = Resources.FormMante_Designer;
2368 sourceCode = sourceCode.Replace(
"$mantename$", nombreMante);
2370 sourceCode = sourceCode.Replace(
"$tablename$", nombreTabla);
2371 sourceCode = sourceCode.Replace(
"$mantetittle$", tituloMante);
2372 sourceCode = sourceCode.Replace(
"$formname$", nombreFormMante);
2373 sourceCode = sourceCode.Replace(
"$caracterrelleno$", caracterrelleno);
2374 sourceCode = sourceCode.Replace(
"$instanceobjects$", instanceObjectsCode);
2375 sourceCode = sourceCode.Replace(
"$controlsadd$", controlsAddCode);
2376 sourceCode = sourceCode.Replace(
"$showpages$", showPageCode);
2377 sourceCode = sourceCode.Replace(
"$controlsdef$", controlsDefCode);
2378 sourceCode = sourceCode.Replace(
"$formdef$", formDefCode);
2379 sourceCode = sourceCode.Replace(
"$controlsdeclares$", controlDeclare);
2383 BackupFile(sourceFile);
2384 streamWriter = File.CreateText(sourceFile);
2387 streamWriter.Write(sourceCode);
2388 streamWriter.Close();
2395 sourceCode = Resources.txtCodLabel;
2397 sourceCode = sourceCode.Replace(
"$mantename$", nombreMante);
2398 sourceCode = sourceCode.Replace(
"$nombretxtcodlabel$", nombretxtCodLabel);
2399 sourceCode = sourceCode.Replace(
"$titulolistado$", tituloForm.ToLower());
2401 sourceCode = sourceCode.Replace(
"$tablename$", nombreTabla);
2402 sourceCode = sourceCode.Replace(
"$mantetittle$", tituloMante);
2403 sourceCode = sourceCode.Replace(
"$formname$", nombreFormMante);
2404 sourceCode = sourceCode.Replace(
"$caracterrelleno$", caracterrelleno);
2405 sourceCode = sourceCode.Replace(
"$txtcodlabellenght$", txtcodlabellenght);
2409 BackupFile(sourceFile);
2410 streamWriter = File.CreateText(sourceFile);
2413 streamWriter.Write(sourceCode);
2414 streamWriter.Close();
2421 sourceCode = Resources.txtFiltroDesdeHasta;
2423 sourceCode = sourceCode.Replace(
"$mantename$", nombreMante);
2424 sourceCode = sourceCode.Replace(
"$nombretxtcodlabel$", nombretxtCodLabel);
2425 sourceCode = sourceCode.Replace(
"$nombretxtfiltrodesdehasta$", nombretxtfiltrodesdehasta);
2426 sourceCode = sourceCode.Replace(
"$titulolistado$", tituloForm.ToLower());
2428 sourceCode = sourceCode.Replace(
"$tablename$", nombreTabla);
2429 sourceCode = sourceCode.Replace(
"$mantetittle$", tituloMante);
2430 sourceCode = sourceCode.Replace(
"$formname$", nombreFormMante);
2431 sourceCode = sourceCode.Replace(
"$caracterrelleno$", caracterrelleno);
2432 sourceCode = sourceCode.Replace(
"$txtcodlabellenght$", txtcodlabellenght);
2435 sourceFile = Path.Combine(
AddonsExecute.
RutaProject,
"Visual\\UserControls\\") + nombretxtfiltrodesdehasta +
".cs";
2436 BackupFile(sourceFile);
2437 streamWriter = File.CreateText(sourceFile);
2440 streamWriter.Write(sourceCode);
2441 streamWriter.Close();
2488 Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();
2491 if (projectItems == null)
2496 foreach (ProjectItem prjItem
in projectItems )
2498 if (prjItem.Name == fileName)
2504 if (prjItem.ProjectItems.Count > 0)
2506 exist = SourceFileExist(fileName, prjItem.ProjectItems);
2527 Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();
2532 if (prjItem.Name == fileName)
2549 string sourcefiletebak = sourcefile +
".bak";
2551 if (File.Exists(sourcefile))
2553 File.Copy(sourcefile, sourcefiletebak,
true);
2564 List<string> sourceFiles =
new List<string>();
2565 Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();
2569 ProjectItem projectItem = GetSourcePath(_path);
2571 if (projectItem != null)
2573 foreach (ProjectItem prjItem
in projectItem.ProjectItems)
2575 sourceFiles.Add(Path.GetFileNameWithoutExtension(prjItem.Name));
2588 public ProjectItem
GetSourcePath(
string _path, ProjectItems projectItems = null)
2590 ProjectItem projectItem = null;
2591 Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();
2594 if (projectItems == null)
2599 foreach (ProjectItem prjItem
in projectItems)
2601 if (prjItem.FileNames[1].ToLower() == _path.ToLower() || Path.GetFileName(prjItem.FileNames[1]).ToLower() == _path.ToLower())
2603 projectItem = prjItem;
2608 if (prjItem.ProjectItems.Count > 0)
2610 projectItem = GetSourcePath(_path, prjItem.ProjectItems);
2612 if (projectItem != null)
2629 public ProjectItem
GetSourceFile(
string sourceName, ProjectItems prjItems = null)
2631 ProjectItem sourceFile = null;
2632 Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();
2635 if (prjItems == null)
2640 foreach (ProjectItem prjItem
in prjItems)
2642 if (Path.GetFileName(prjItem.FileNames[1]).ToLower() == sourceName.ToLower())
2644 sourceFile = prjItem;
2649 if (prjItem.ProjectItems.Count > 0)
2651 sourceFile = GetSourceFile(sourceName, prjItem.ProjectItems);
2652 if (sourceFile != null)
2666 CamposNuevoMante.Clear();
2667 NombreCamposNuevoMante.Clear();
2670 manteProperties.
Nombre = nombreDoc;
2671 manteProperties.
Titulo = tituloForm;
2672 CamposNuevoMante.Add(manteProperties);
2673 NombreCamposNuevoMante.Add(nombreDoc);
2676 ListaCampos = CamposTabla.DefaultView.ToTable();
2678 if(ListaCamposLineas!=null)
2679 ListaCamposLineas.Clear();
2689 ListaCamposLineas = CamposTablaLineas.DefaultView.ToTable();
2695 public void NuevoMantenimiento(
string nombreMante,
string nombreTabla,
string tituloForm,
string textoMenu)
2697 CamposNuevoMante.Clear();
2698 NombreCamposNuevoMante.Clear();
2701 manteProperties.
Nombre = nombreMante;
2702 manteProperties.
Titulo = tituloForm;
2704 CamposNuevoMante.Add(manteProperties);
2705 NombreCamposNuevoMante.Add(nombreMante);
2708 ListaCampos = CamposTabla.DefaultView.ToTable();
2721 tpNovaPagina.
Nombre = _nombrePagina;
2722 tpNovaPagina.
Titulo = _tituloPagina;
2723 CamposNuevoMante.Add(tpNovaPagina);
2724 NombreCamposNuevoMante.Add(_nombrePagina);
2726 return tpNovaPagina;
2737 newCampo.
Nombre = nombreCampo;
2739 CamposNuevoMante.Add(newCampo);
2740 NombreCamposNuevoMante.Add(nombreCampo);
2743 DataRow[] deleteRow = ListaCampos.Select(
"column_name = '" + nombreCampo +
"'");
2744 if (deleteRow.Count() > 0)
2746 ListaCampos.Rows.Remove(deleteRow[0]);
2760 newCampo.
Nombre = nombreCampo;
2764 CamposNuevoMante.Add(newCampo);
2765 NombreCamposNuevoMante.Add(nombreCampo);
2768 DataRow[] deleteRow = ListaCampos.Select(
"column_name = '" + nombreCampo +
"'");
2769 if (deleteRow.Count() > 0)
2771 ListaCampos.Rows.Remove(deleteRow[0]);
2785 newCampo.
_Nombre = nombreCampo;
2786 newCampo.
_Titulo = nombreCampo;
2789 CamposNuevoMante.Add(newCampo);
2790 NombreCamposNuevoMante.Add(nombreCampo);
2795 DataRow[] deleteRow = ListaCampos.Select(
"column_name = '" + nombreCampo +
"'");
2796 if (deleteRow.Count() > 0)
2798 ListaCampos.Rows.Remove(deleteRow[0]);
2803 DataRow[] deleteRow = ListaCamposLineas.Select(
"column_name = '" + nombreCampo +
"'");
2804 if (deleteRow.Count() > 0)
2806 ListaCamposLineas.Rows.Remove(deleteRow[0]);
2823 if (nombreCampo ==
"codigo" || nombreCampo ==
"nombre")
2826 foreach (dynamic objectProperties
in CamposNuevoMante)
2830 if (objectProperties.Nombre == nombreCampo)
2832 RemoveCampoMante(objectProperties);
2840 if (objectProperties._Nombre == nombreCampo)
2842 RemoveCampoMante(objectProperties);
2850 if (nombreCampo !=
"tpGeneral")
2852 if (objectProperties.Nombre == nombreCampo)
2855 CamposNuevoMante.Remove(objectProperties);
2856 NombreCamposNuevoMante.Remove(nombreCampo);
2876 string nombreCampo = campoObject.
Nombre;
2879 CamposNuevoMante.Remove(campoObject);
2880 NombreCamposNuevoMante.Remove(nombreCampo);
2883 DataRow[] campoTabla = CamposTabla.Select(
"column_name = '" + nombreCampo +
"'");
2884 if (campoTabla.Count() > 0)
2886 DataRow listaRow = ListaCampos.NewRow();
2887 for (
int i = 0; i < ListaCampos.Columns.Count - 1; i++)
2889 string columnName = ListaCampos.Columns[i].ColumnName;
2890 listaRow[columnName] = campoTabla[0][columnName];
2893 ListaCampos.Rows.Add(listaRow);
2907 string nombreCampo = campoObject.
_Nombre;
2910 CamposNuevoMante.Remove(campoObject);
2911 NombreCamposNuevoMante.Remove(nombreCampo);
2914 DataRow[] campoTabla = CamposTabla.Select(
"column_name = '" + nombreCampo +
"'");
2915 if (campoTabla.Count() > 0)
2917 DataRow listaRow = ListaCampos.NewRow();
2918 for (
int i = 0; i < ListaCampos.Columns.Count - 1; i++)
2920 string columnName = ListaCampos.Columns[i].ColumnName;
2921 listaRow[columnName] = campoTabla[0][columnName];
2924 ListaCampos.Rows.Add(listaRow);
2937 dynamic objectProperties = null;
2939 foreach (dynamic objectP
in CamposNuevoMante)
2943 if (objectP._Nombre == nombreObjeto)
2945 objectProperties = objectP;
2950 if (objectP.Nombre == nombreObjeto)
2952 objectProperties = objectP;
2957 return objectProperties;
2974 File.Delete(libreria);
2976 libreria = Path.ChangeExtension(libreria,
"pdb");
2977 File.Delete(libreria);
2990 public bool CrearMainProject(
string _rutaTerm,
string userName,
string password, out
string _messageError)
2994 Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();
3000 string currentDir = Directory.GetCurrentDirectory();
3002 Directory.SetCurrentDirectory(rutaSolution);
3003 rutaSolution = Directory.GetCurrentDirectory();
3005 Directory.SetCurrentDirectory(currentDir);
3008 string fileZip = Path.Combine(rutaSolution,
"main.zip");
3009 File.WriteAllBytes(fileZip, Resources.main);
3010 SageZip loZip =
new SageZip();
3012 loZip.FileName = fileZip;
3013 loZip.Extract(rutaSolution, 1,
"",
"");
3015 File.Delete(fileZip);
3018 string projectpath = Path.Combine(rutaSolution,
@"main\main.csproj");
3025 ConfigurationManager configManager = mainProject.ConfigurationManager;
3026 Configuration activeConfiguration = configManager.ActiveConfiguration;
3030 ProjectItem prjItem = mainProject.ProjectItems.Item(
"Program.cs");
3031 CodeFunction codeFunction = GetCodeElement<CodeFunction>(
"Main", out _messageError, prjItem,
"Program");
3033 EditPoint editPointCopy;
3034 editPointCopy = codeFunction.StartPoint.CreateEditPoint();
3035 editPointCopy.FindPattern(
"// copiar la libreria del add-on");
3036 editPointCopy.LineDown();
3037 editPointCopy.Insert(
"FUNCTIONS._CopiarLibreriasAddons(@\"" +
AddonsExecute.
RutaEuroserv +
"\", @\"" + _rutaTerm +
"\");");
3039 EditPoint editPoint;
3040 editPoint = codeFunction.StartPoint.CreateEditPoint();
3041 editPoint.FindPattern(
"// conexión a Sage 50");
3042 editPoint.LineDown();
3043 editPoint.Insert(
"main_s50.Connect(@\"" + _rutaTerm +
"\", \"" + userName +
"\", \"" + password +
"\");");
3051 catch (Exception ex)
3053 _messageError = Environment.NewLine + Environment.NewLine + ex.Message;
3068 StringReader textReader =
default(StringReader);
3069 string blocstring =
string.Empty;
3074 blocpos = dumptext.IndexOf(blocname);
3077 blocpos += blocname.Length + 3;
3079 finblocpos = dumptext.IndexOf(
"/" + blocname, blocpos);
3080 if (finblocpos > -1)
3082 finblocpos = finblocpos - blocpos - 2;
3084 blocstring = dumptext.Substring(blocpos, finblocpos);
3086 textReader =
new StringReader(blocstring);
3103 public string GetPropertySet(
string tcTipoCampo,
char comilles,
string tcValidarDato,
string tcNombrePropiedad,
string tcNombrePropiedadPrivada)
3105 string propertySet =
"";
3108 if (!
string.IsNullOrWhiteSpace(tcValidarDato))
3110 if (tcTipoCampo ==
"string")
3112 propertySet +=
"if (" + tcNombrePropiedadPrivada +
".Trim() != value.Trim())" + Environment.NewLine;
3113 propertySet += tab + tab + tab + tab +
"{" + Environment.NewLine;
3114 propertySet += Environment.NewLine;
3115 propertySet += tab + tab + tab + tab + tab +
"if (loParent != null)" + Environment.NewLine;
3116 propertySet += tab + tab + tab + tab + tab +
"{" + Environment.NewLine;
3117 propertySet += tab + tab + tab + tab + tab + tab +
"object loNewValor;" + Environment.NewLine;
3118 propertySet += tab + tab + tab + tab + tab + tab +
"if (loParent.CamposTRel_Validar_Valor(" + comilles + tcNombrePropiedad + comilles +
", value, this, out loNewValor))" + Environment.NewLine;
3119 propertySet += tab + tab + tab + tab + tab + tab +
"{" + Environment.NewLine;
3120 propertySet += tab + tab + tab + tab + tab + tab + tab +
"value = " + tcNombrePropiedadPrivada +
";" + Environment.NewLine;
3121 propertySet += tab + tab + tab + tab + tab + tab +
"}" + Environment.NewLine;
3122 propertySet += tab + tab + tab + tab + tab + tab +
"else if (loNewValor != null)" + Environment.NewLine;
3123 propertySet += tab + tab + tab + tab + tab + tab +
"{" + Environment.NewLine;
3124 propertySet += tab + tab + tab + tab + tab + tab + tab +
"value = Convert.ToString(loNewValor);" + Environment.NewLine;
3125 propertySet += tab + tab + tab + tab + tab + tab +
"}" + Environment.NewLine;
3126 propertySet += tab + tab + tab + tab + tab +
"}" + Environment.NewLine;
3127 propertySet += tab + tab + tab + tab +
"}" + Environment.NewLine;
3128 propertySet += Environment.NewLine;
3129 propertySet += tab + tab + tab + tab +
"if (" + tcNombrePropiedadPrivada +
".Trim() != value.Trim())" + Environment.NewLine;
3130 propertySet += tab + tab + tab + tab +
"{" + Environment.NewLine;
3131 propertySet += tab + tab + tab + tab + tab + tcNombrePropiedadPrivada +
" = value;" + Environment.NewLine;
3132 propertySet += tab + tab + tab + tab + tab +
"loParent._Exportar_Null();" + Environment.NewLine;
3133 propertySet += tab + tab + tab + tab +
"}" + Environment.NewLine;
3137 propertySet +=
"if (" + tcNombrePropiedadPrivada +
" != value)" + Environment.NewLine;
3138 propertySet += tab + tab + tab + tab +
"{" + Environment.NewLine;
3139 propertySet += Environment.NewLine;
3140 propertySet += tab + tab + tab + tab + tab +
"if (loParent != null)" + Environment.NewLine;
3141 propertySet += tab + tab + tab + tab + tab +
"{" + Environment.NewLine;
3142 propertySet += tab + tab + tab + tab + tab + tab +
"if (loParent.CamposTRel_Validar_Valor(" + comilles + tcNombrePropiedad + comilles +
", value, this))" + Environment.NewLine;
3143 propertySet += tab + tab + tab + tab + tab + tab +
"{" + Environment.NewLine;
3144 propertySet += tab + tab + tab + tab + tab + tab + tab +
"value = " + tcNombrePropiedadPrivada +
";" + Environment.NewLine;
3145 propertySet += tab + tab + tab + tab + tab + tab +
"}" + Environment.NewLine;
3146 propertySet += tab + tab + tab + tab + tab +
"}" + Environment.NewLine;
3147 propertySet += tab + tab + tab + tab +
"}" + Environment.NewLine;
3148 propertySet += Environment.NewLine;
3149 propertySet += tab + tab + tab + tab +
"if (" + tcNombrePropiedadPrivada +
" != value)" + Environment.NewLine;
3150 propertySet += tab + tab + tab + tab +
"{" + Environment.NewLine;
3151 propertySet += tab + tab + tab + tab + tab + tcNombrePropiedadPrivada +
" = value;" + Environment.NewLine;
3152 propertySet += tab + tab + tab + tab + tab +
"loParent._Exportar_Null();" + Environment.NewLine;
3153 propertySet += tab + tab + tab + tab +
"}" + Environment.NewLine;
3158 propertySet = tcNombrePropiedadPrivada +
" = value";
3176 Dictionary<string, bool> loDic =
new Dictionary<string, bool>();
3177 List<Tuple<string, bool>> loRes =
new List<Tuple<string, bool>>();
3179 if (!tcPathLibreria.EndsWith(
".dll")) tcPathLibreria = $
"{tcPathLibreria}.dll";
3181 string lcPathTempBase = Path.Combine(Path.GetTempPath(),
"Sage50Sdk");
3182 string lcPathCopia = CopiarLibreria(tcPathLibreria, lcPathTempBase);
3183 lcPathCopia =
string.IsNullOrWhiteSpace(lcPathCopia) ? tcPathLibreria : lcPathCopia;
3185 if (File.Exists(tcPathLibreria) && LibreriaReferencias(tcPathLibreria, lcPathCopia, ref loDic))
3187 loDic.ToList().Where(f => f.Key.StartsWith(
"sage.ew.") || f.Key.StartsWith(
"Sage.ES.S50.")).ToList().ForEach(f => loRes.Add(
new Tuple<string, bool>(f.Key, f.Value)));
3190 EliminarCarpetasLibrerias(tcPathLibreria, lcPathTempBase);
3201 private string CopiarLibreria(
string tcPathLibreria,
string tcPathTempBase)
3203 CrearCarpeta(tcPathTempBase);
3204 EliminarCarpetasLibrerias(tcPathLibreria, tcPathTempBase);
3206 string lcPathTemp = Path.Combine(tcPathTempBase, Path.GetFileNameWithoutExtension(tcPathLibreria) +
"_" + DateTime.Now.ToString(
"yyyyMMddhhmmss"));
3207 CrearCarpeta(lcPathTemp);
3209 string lcFile = Path.Combine(lcPathTemp, Path.GetFileName(tcPathLibreria));
3210 CopiarFichero(tcPathLibreria, lcFile);
3211 string lcFilePdb = Path.Combine(lcPathTemp, Path.GetFileNameWithoutExtension(tcPathLibreria) +
".pdb");
3212 CopiarFichero(Path.Combine(Path.GetDirectoryName(tcPathLibreria), Path.GetFileNameWithoutExtension(tcPathLibreria)) +
".pdb", lcFilePdb);
3222 private bool CrearCarpeta(
string tcFolder)
3226 Directory.CreateDirectory(tcFolder);
3240 private bool EliminarCarpeta(
string tcFolder)
3244 Directory.Delete(tcFolder,
true);
3261 private bool CopiarFichero(
string tcOrigen,
string tcDestino,
bool tlOverWrite =
true)
3265 File.Copy(tcOrigen, tcDestino, tlOverWrite);
3280 private void EliminarCarpetasLibrerias(
string tcPathLibreria,
string lcPathTempBase)
3284 string lcFile = Path.GetFileNameWithoutExtension(tcPathLibreria);
3285 string[] folders =
System.IO.Directory.GetDirectories(lcPathTempBase, lcFile+
"*",
System.IO.SearchOption.AllDirectories);
3286 foreach (
string lcFolder
in folders)
3287 EliminarCarpeta(lcFolder);
3302 private static bool LibreriaReferencias(
string tcPathLibreria,
string tcPathCopia, ref Dictionary<string, bool> toRes)
3304 Assembly assembly = null;
3305 List<AssemblyName> loList;
3307 string lcFile = !
string.IsNullOrWhiteSpace(tcPathCopia) ? tcPathCopia : tcPathLibreria;
3311 if (File.Exists(lcFile))
3313 assembly = _CreateAssemblyDomain(lcFile,
AssemblyType.AnotherDomain);
3314 if (assembly == null) assembly = _CreateAssemblyDomain(lcFile,
AssemblyType.ReflectionOnlyLoadFrom);
3315 if (assembly == null) assembly = _CreateAssemblyDomain(lcFile,
AssemblyType.FromFile);
3316 if (assembly == null) assembly = _CreateAssemblyDomain(lcFile,
AssemblyType.SameDomain);
3318 if (assembly is Assembly)
3322 loList = assembly.GetReferencedAssemblies().ToList();
3325 foreach (AssemblyName loAssemblyName
in loList)
3327 if (!toRes.ContainsKey(loAssemblyName.FullName))
3329 toRes.Add(loAssemblyName.FullName, loAssemblyName.GetPublicKeyToken()?.Length > 0);
3331 LibreriaReferencias(loAssemblyName.CodeBase,
"", ref toRes);
3338 catch (Exception loEx)
3340 DB.Registrar_Error(loEx);
3355 AppDomain appNewDomain = null;
3356 Assembly addonAssembly = null;
3360 switch (toAssemblyType)
3363 appNewDomain = AppDomain.CreateDomain(tcPath);
3364 addonAssembly = appNewDomain.Load(File.ReadAllBytes(tcPath));
3367 addonAssembly = Assembly.LoadFile(tcPath);
3370 addonAssembly = Assembly.ReflectionOnlyLoadFrom(tcPath);
3373 addonAssembly = Assembly.LoadFrom(tcPath);
3379 addonAssembly = null;
3382 return addonAssembly;
bool ModificarMante(string _nombreModulo, string _nombreMante, string _nombreTabla, string _nombreConnex, out string _messageError)
Modifica el módulo para que cargue el control de usuario al mantenimento indicado ...
bool CrearNuevoMantenimiento(string nombreMante, string nombreTabla, string tituloForm, string textoMenu, bool addCeros, out string messageError)
Crear nuevo mantenimiento
bool EsFiltro
Indica si el campo relacionado actuarà de filtro de la tabla
bool SourceFileExist(string fileName, ProjectItems projectItems=null)
Comprueba si el fichero especifiado existe en el proyecto
int Longitud
Máscara para columnas numéricas
string Nombre
Nombre del formulario
string Titulo
Título de la página
bool _PermiteDuplicados
Indica si se permiten valores duplicados comparando el campo con todos los registros cargados ...
new bool EsClave
Campo de la tabla relacionado
new string _Validar_Dato_CampoTRel_Asignar
Destino del valor recuperado en la consulta de validación
bool ModificarManteTRel(string _nombreManteTRel, string _nombreTabla, string _nombreTablaManteTRel, out string _messageError)
Modifica el módulo para que cargue la extensión al mantenimento relacionado indicado ...
bool CrearMainProject(string _rutaTerm, string userName, string password, out string _messageError)
Crear el proyecto de inicio para depuración
static Assembly _CreateAssemblyDomain(string tcPath, AssemblyType toAssemblyType)
Cargar libreria
new string _Validar_Dato_Tabla
Tabla donde se validará si el dato existe
dynamic GetObjectProperties(string nombreObjeto)
Devuelve el objeto relacionado con el nombre
new string _Validar_Dato_BaseDatos
Base de datos donde se validará si el dato existe
static string DllAddon
Nombre de la base de datos del addon
bool _ExpandirPunto
Introduce 0 en la posición del . hasta la longitud del campo
List< string > GetSourceFilesFromPath(string _path)
Devuelve una lista con los archivos de código de la ruta relativa del proyecto especificada ...
string Nombre
Nombre del campo
bool CrearManteTRel(string _manteTRelName, string _nombreTabla, string _nombreUserControl, string _nombreMante, out string messageError)
Crea un mantenimiento de tablas relacionadas
static string RutaEuroserv
Ruta del servidor de Sage50c
void NuevoMantenimiento(string nombreMante, string nombreTabla, string tituloForm, string textoMenu)
Prepara para
FuncsSourceCode()
Inicializa una nueva instancia de la clase
new bool EsFiltro
Campo de la tabla relacionado
string TxtCodLabel
txtCodLabel en caso de haber seleccionado el tipo TxtCodLabel
void BackupFile(string sourcefile)
Hace una copia backup del fichero que se le indica
bool ModificarUrlAyuda(string tcUrl, out string _messageError)
Modificar en el sageaddons la propiedad urlayuda
Clase para las acciones en la base de datos
List< Tuple< string, bool > > _LibreriaReferencias(string tcPathLibreria)
Libreria de referencias
bool CrearNuevoUserControlManteTRel(string _nombreControl, string _nombreTabla, out string messageError)
Crea un nuevo control de usuario
Propiedades de los campos código y nombre para el deseño de los mantenimientos
CodigoNombreManteProperties AddCampoCodigoNombreMante(string nombreCampo)
Añade el campo código y nombre al mantenimiento
ProjectItem GetSourcePath(string _path, ProjectItems projectItems=null)
Busca el item en el proyecto y lo devuelve
decimal _AnchoColumna
Permite indicar el ancho en carácteres estándar 'A' que va a tener al columna en el grid...
int NumTabs
Número de pestañas
static int GetLenCampo(string nombreDB, string nombreTabla, string nombreCampo)
Devuelve la longitud del campo
FuncsDataBase FuncsDataBase
Funciones para las bases de datos
bool RemoveCampoMante(ObjectsManteProperties campoObject)
Quita el campo del mantenimiento
bool CrearNuevoUserControl(string _nombreControl, bool _crearManteTRel, out string messageError)
Crea un nuevo control de usuario
Int32 NumericUpDownMinimum
Incremento
static string RutaProject
Ruta al proyecto
bool CrearExtensionMante(string _nombreModulo, string _nombreMante, string _nombreTabla, string _nombreUserControl, bool _sinTabla, out string _messageError)
Crear la clase extensión del mantenimiento
static Solution2 Solution
Instancia de la solución
PaginaManteProperties AddPagina(string _nombrePagina, string _tituloPagina)
Crear el objeto página para la nueva página
string Nombre
Nombre del formulario
string Titulo
Título del formulario
DataTable ListaCamposLineas
Lista de campos detalle
bool DeleteProject()
Borra la parte de código del proyecto
void CargarCamposLineas(string nombreTabla)
Cargar los campos para las líneas de los documentos
DataTable ListaCampos
Lista de campos
string GetPropertySet(string tcTipoCampo, char comilles, string tcValidarDato, string tcNombrePropiedad, string tcNombrePropiedadPrivada)
Método para obtener propertyset
StringReader GetBlocString(string dumptext, string blocname)
Devuelve el contenido del bloque
bool _Editable
Indica si el campo será editable
CodeClass GetCodeClass(string _className, out string messageError, ProjectItem prjItem=null)
Devuelve la clase indicada en el módulo especificado
Clase para la definición de las páginas del mantenimiento
AssemblyType
Enumerado para el tipo de carga de librerias
string TextoMenu
Texto para el menú
static Project PRJAddon
Instancia del proyecto que se modifica
ObjectsManteProperties AddCampoMante(string nombreCampo)
Añade el campo al mantenimiento
Int32 NumericUpDownMaximum
Incremento
Clase para mostrar las propiedades de ewCampoTRel
Propiedades para el deseño de los mantenimientos
Funciones y métodos para crear los componentes
static string NombreAddon
Nombre del addon
Int32 NumericUpDownDecimals
Posiciones decimales
bool _Visible
Indica si el campo serà visible cuando se enlaza a un grid
bool _Updatable
Indica si el campo se recupera y guarda en la tabla
gridColumnsTypes _TipoColumna
Tipo de columna para grid o tipo de control enlazado
bool RemoveCampoMante(string nombreCampo)
Quita el campo del mantenimiento
string Nombre
Nombre del campo
void NuevoDocumento(string nombreDoc, string nombreTabla, string tituloForm)
Prepara para
bool SourceFolderExist(string fileName)
Comprueba si el fichero especifiado existe en el proyecto
Propiedades de objetos para el deseño de los mantenimientos
dynamic ClassMod
Clase que se está utilizando
string _FormatString
Máscara para columnas de tipo TextoFormateado
string Nombre
Nombre del objeto
ProjectItem GetSourceFile(string sourceName, ProjectItems prjItems=null)
Busca en todo el proyecto el fichero con el nombre especificado
ewCampoTRelAddons AddCampoManteTRel(string nombreCampo, bool lineas=false)
Añade el campo al mantenimiento
new string _Validar_Dato_Clave
Clave por la cual se buscará el valor a la tabla de validación
string Titulo
Título del formulario
ObjectsManteTypes
Tipos de objetos para enlazar con los campos de los mantenimientos
Funciones para la creación de los ficheros de código
int NumeroDecimales
Máscara para columnas numéricas
Propiedades para el deseño de los mantenimientos
new string _Validar_Dato_Campos
Campos que se recuperarán en la consulta de validación
string _Error_Duplicados
Mensaje de error que se mostrará al insertar un valor duplicado
string GetUrlAyuda(out string _messageError)
Obtener la Url de ayuda
static string NombreClase
Nombre de la clase principal del addon
new bool EsCampoLinea
Campo de la tabla relacionado
new string _Nombre
Nombre del campo
bool MostrarTitulo
Muestra u oculta el título del campo
string TituloCampo
Título del campo
Int32 NumericUpDownIncrement
Incremento
DataGridViewAutoSizeColumnMode _AutoModeSizeColumna
Permite indicar que la columna autoajuste su tamaño
string _Titulo
Título para mostrar en el label asociado o en el encabezado de columna
char _Relleno
Introduce tantos carácteres al inicio del campo hasta la longitud del campo
bool RemoveCampoMante(ewCampoTRelAddons campoObject)
Quita el campo del mantenimiento
bool Visible
Hacer visible o invisible
bool _Validar_Asignar_Cargando
Indica si se buscará el dato en la tabla correspondiente mientras se ejecuta el _Load() ...
ObjectsManteTypes ObjectType
Tipo de control
string _Error_Validar_Dato
Mensaje de error que se mostrará al insertar un dato no válido
new bool CampoAgregado
Campo de la tabla relacionado
DataTable GetSchemaTable(string nombreTabla)
Rellena la vista con los campos de la tabla