Usar un modo mas estándar para listar procedimientos
This commit is contained in:
20
ServerExplorer/UI/FrmProcedimientos.Designer.cs
generated
20
ServerExplorer/UI/FrmProcedimientos.Designer.cs
generated
@@ -30,6 +30,7 @@
|
||||
{
|
||||
this.lsvProcs = new ServerExplorer.Controls.CustomListView();
|
||||
this.colNombre = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.colSchema = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.colFecha = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.colTipo = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.txtProc = new System.Windows.Forms.TextBox();
|
||||
@@ -48,15 +49,15 @@
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.lsvProcs.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
|
||||
this.colNombre,
|
||||
this.colSchema,
|
||||
this.colFecha,
|
||||
this.colTipo});
|
||||
this.lsvProcs.Font = new System.Drawing.Font("Lucida Console", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.lsvProcs.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.lsvProcs.FullRowSelect = true;
|
||||
this.lsvProcs.GridLines = true;
|
||||
this.lsvProcs.Location = new System.Drawing.Point(0, 0);
|
||||
this.lsvProcs.Name = "lsvProcs";
|
||||
this.lsvProcs.Size = new System.Drawing.Size(261, 369);
|
||||
this.lsvProcs.Sorting = System.Windows.Forms.SortOrder.Ascending;
|
||||
this.lsvProcs.Size = new System.Drawing.Size(352, 478);
|
||||
this.lsvProcs.TabIndex = 0;
|
||||
this.lsvProcs.UseCompatibleStateImageBehavior = false;
|
||||
this.lsvProcs.View = System.Windows.Forms.View.Details;
|
||||
@@ -67,6 +68,10 @@
|
||||
this.colNombre.Text = "Nombre";
|
||||
this.colNombre.Width = 120;
|
||||
//
|
||||
// colSchema
|
||||
//
|
||||
this.colSchema.Text = "Schema";
|
||||
//
|
||||
// colFecha
|
||||
//
|
||||
this.colFecha.Text = "Fecha";
|
||||
@@ -87,7 +92,7 @@
|
||||
this.txtProc.Multiline = true;
|
||||
this.txtProc.Name = "txtProc";
|
||||
this.txtProc.ScrollBars = System.Windows.Forms.ScrollBars.Both;
|
||||
this.txtProc.Size = new System.Drawing.Size(309, 366);
|
||||
this.txtProc.Size = new System.Drawing.Size(352, 475);
|
||||
this.txtProc.TabIndex = 1;
|
||||
//
|
||||
// splitContainer1
|
||||
@@ -106,15 +111,15 @@
|
||||
// splitContainer1.Panel2
|
||||
//
|
||||
this.splitContainer1.Panel2.Controls.Add(this.txtProc);
|
||||
this.splitContainer1.Size = new System.Drawing.Size(583, 372);
|
||||
this.splitContainer1.SplitterDistance = 264;
|
||||
this.splitContainer1.Size = new System.Drawing.Size(717, 481);
|
||||
this.splitContainer1.SplitterDistance = 355;
|
||||
this.splitContainer1.TabIndex = 2;
|
||||
//
|
||||
// FrmProcedimientos
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(607, 396);
|
||||
this.ClientSize = new System.Drawing.Size(741, 505);
|
||||
this.Controls.Add(this.splitContainer1);
|
||||
this.Name = "FrmProcedimientos";
|
||||
this.Text = "frmProcedimientos";
|
||||
@@ -135,5 +140,6 @@
|
||||
private System.Windows.Forms.TextBox txtProc;
|
||||
private System.Windows.Forms.SplitContainer splitContainer1;
|
||||
private System.Windows.Forms.ColumnHeader colTipo;
|
||||
private System.Windows.Forms.ColumnHeader colSchema;
|
||||
}
|
||||
}
|
||||
@@ -36,9 +36,7 @@ namespace ServerExplorer.UI
|
||||
|
||||
// Obtener un datatable con todos los procedimientos de la base de datos.
|
||||
da = new SqlDataAdapter(
|
||||
"SELECT id,name,crdate,type FROM sysobjects " +
|
||||
"WHERE (UPPER(type) = 'P' OR UPPER(type) = 'TF' OR UPPER(type) = 'TR' OR UPPER(type) = 'V') AND category = 0 " +
|
||||
"ORDER BY name ",
|
||||
"SELECT ROUTINE_NAME Name, ROUTINE_SCHEMA [Schema], CREATED CreateDate, ROUTINE_TYPE [Type] FROM INFORMATION_SCHEMA.ROUTINES",
|
||||
cnx);
|
||||
dt = new DataTable();
|
||||
cnx.Open();
|
||||
@@ -49,33 +47,11 @@ namespace ServerExplorer.UI
|
||||
lsvProcs.Items.Clear();
|
||||
foreach (DataRow dr in dt.Rows)
|
||||
{
|
||||
ListViewItem item = lsvProcs.Items.Add((String)dr["name"]);
|
||||
item.SubItems.Add(((DateTime)dr["crdate"]).ToShortDateString());
|
||||
string type = ((string)dr["type"]).ToUpper().Trim();
|
||||
if (type == "P")
|
||||
{
|
||||
item.SubItems.Add("Proc");
|
||||
}
|
||||
else if (type == "TF")
|
||||
{
|
||||
item.SubItems.Add("Func");
|
||||
}
|
||||
else if (type == "TR")
|
||||
{
|
||||
item.SubItems.Add("Trigg");
|
||||
}
|
||||
else if (type == "V")
|
||||
{
|
||||
item.SubItems.Add("View");
|
||||
}
|
||||
else
|
||||
{
|
||||
item.SubItems.Add("Unk: \"" + (string)dr["type"] + "\"");
|
||||
}
|
||||
item.Tag = dr["id"];
|
||||
ListViewItem item = lsvProcs.Items.Add((String)dr["Name"]);
|
||||
item.SubItems.Add((string)dr["Schema"]);
|
||||
item.SubItems.Add(((DateTime)dr["CreateDate"]).ToShortDateString());
|
||||
item.SubItems.Add((string)dr["Type"]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void lsvProcs_SelectedIndexChanged(object sender, EventArgs e)
|
||||
@@ -84,13 +60,12 @@ namespace ServerExplorer.UI
|
||||
{
|
||||
DataTable dt;
|
||||
SqlDataAdapter da;
|
||||
int id = (int)lsvProcs.SelectedItems[0].Tag;
|
||||
|
||||
// Obtener un datatable con el contenido del procedimiento.
|
||||
da = new SqlDataAdapter(
|
||||
"SELECT text FROM syscomments WHERE id = @id ORDER BY colid",
|
||||
cnx);
|
||||
da.SelectCommand.Parameters.AddWithValue("@id", id);
|
||||
string Schema, Name;
|
||||
Name = lsvProcs.SelectedItems[0].SubItems[0].Text;
|
||||
Schema = lsvProcs.SelectedItems[0].SubItems[1].Text;
|
||||
da = new SqlDataAdapter("SELECT ROUTINE_DEFINITION from INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME=@Name AND ROUTINE_SCHEMA=@Schema", cnx);
|
||||
da.SelectCommand.Parameters.AddWithValue("@Name", Name);
|
||||
da.SelectCommand.Parameters.AddWithValue("@Schema", Schema);
|
||||
dt = new DataTable();
|
||||
cnx.Open();
|
||||
da.Fill(dt);
|
||||
@@ -102,7 +77,6 @@ namespace ServerExplorer.UI
|
||||
{
|
||||
txtProc.Text += ((string)dr[0]).Replace("\r", "").Replace("\n", "\r\n");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user