Ahora se pueden generar scripts completos

parent 0063dbe4
......@@ -40,8 +40,9 @@
this.label6 = new System.Windows.Forms.Label();
this.label7 = new System.Windows.Forms.Label();
this.panel2 = new System.Windows.Forms.Panel();
this.button1 = new System.Windows.Forms.Button();
this.dataGridView1 = new System.Windows.Forms.DataGridView();
this.button1 = new System.Windows.Forms.Button();
this.btnFullSql = new System.Windows.Forms.Button();
this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.panel2.SuspendLayout();
......@@ -86,11 +87,11 @@
//
// BotonTraduce
//
this.BotonTraduce.Location = new System.Drawing.Point(212, 413);
this.BotonTraduce.Location = new System.Drawing.Point(110, 427);
this.BotonTraduce.Name = "BotonTraduce";
this.BotonTraduce.Size = new System.Drawing.Size(118, 37);
this.BotonTraduce.Size = new System.Drawing.Size(132, 23);
this.BotonTraduce.TabIndex = 5;
this.BotonTraduce.Text = "Generar";
this.BotonTraduce.Text = "Generar update";
this.BotonTraduce.UseVisualStyleBackColor = true;
this.BotonTraduce.Click += new System.EventHandler(this.BotonTraduce_Click);
//
......@@ -152,16 +153,6 @@
this.panel2.Size = new System.Drawing.Size(528, 151);
this.panel2.TabIndex = 21;
//
// button1
//
this.button1.Location = new System.Drawing.Point(212, 111);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(118, 23);
this.button1.TabIndex = 22;
this.button1.Text = "Añadir literal";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// dataGridView1
//
this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
......@@ -174,6 +165,26 @@
this.dataGridView1.Size = new System.Drawing.Size(528, 151);
this.dataGridView1.TabIndex = 1;
//
// button1
//
this.button1.Location = new System.Drawing.Point(212, 111);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(118, 23);
this.button1.TabIndex = 22;
this.button1.Text = "Añadir literal";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// btnFullSql
//
this.btnFullSql.Location = new System.Drawing.Point(248, 427);
this.btnFullSql.Name = "btnFullSql";
this.btnFullSql.Size = new System.Drawing.Size(132, 23);
this.btnFullSql.TabIndex = 23;
this.btnFullSql.Text = "Generar SQL Completo";
this.btnFullSql.UseVisualStyleBackColor = true;
this.btnFullSql.Click += new System.EventHandler(this.btnFullSql_Click);
//
// Column1
//
this.Column1.HeaderText = "Nombre del literal";
......@@ -191,6 +202,7 @@
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(537, 648);
this.Controls.Add(this.btnFullSql);
this.Controls.Add(this.button1);
this.Controls.Add(this.panel2);
this.Controls.Add(this.label7);
......@@ -231,6 +243,7 @@
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.DataGridView dataGridView1;
private System.Windows.Forms.Button btnFullSql;
private System.Windows.Forms.DataGridViewTextBoxColumn Column1;
private System.Windows.Forms.DataGridViewTextBoxColumn Column2;
}
......
......@@ -310,5 +310,88 @@ namespace Literals
row.Cells[1].Value = this.txtLitValue.Text;
dataGridView1.Rows.Add(row);
}
private void btnFullSql_Click(object sender, EventArgs e)
{
string values = "";
string tablevalue = this.txtNombreTabla.Text;
string itemvalue = this.txtNombreTabla.Text.Replace("LIT_","");
string updatequery = "";
if (this.dataGridView1.Rows.Count > 0)
{
values += "" +
"IF(SELECT COUNT(*) FROM sysobjects WHERE NAME LIKE '" + this.txtNombreTabla.Text + "') > 0" +
" DROP TABLE dbo.LIT_ED1" +
" CREATE TABLE dbo.LIT_ED1(" +
" [IDIOMA] [varchar](5) NOT NULL";
for (int i = 0; i < this.dataGridView1.Rows.Count; i++)
{
if (this.dataGridView1.Rows[i].Cells[0].Value != null)
{
if (this.dataGridView1.Rows[i].Cells[1].Value != null)
{
if (!string.IsNullOrWhiteSpace(this.dataGridView1.Rows[i].Cells[0].Value.ToString()))
{
values += "," + "\n" + " [" + this.dataGridView1.Rows[i].Cells[0].Value.ToString() + "] VARCHAR(100)";
updatequery += GenerarSQL(this.dataGridView1.Rows[i].Cells[0].Value.ToString(), this.dataGridView1.Rows[i].Cells[1].Value.ToString());
updatequery += "\n" + "---------------------------------------------------------------\n";
this.dataGridView1.Rows[i].DefaultCellStyle.BackColor = Color.Green;
}
else
{
this.dataGridView1.Rows[i].DefaultCellStyle.BackColor = Color.Red;
MessageBox.Show("No se permiten espacios en blanco en el nombre del literal. Fila: " + i + "");
}
}
else
{
this.dataGridView1.Rows[i].DefaultCellStyle.BackColor = Color.Red;
}
}
else
{
this.dataGridView1.Rows[i].DefaultCellStyle.BackColor = Color.Red;
}
}
}
else
{
MessageBox.Show("No se ha introducido ningun literal");
}
if (!string.IsNullOrEmpty(values))
{
values += "\n" +
")\n" +
"GO \n" +
"IF(SELECT TABLA_LITERALES FROM OBJETOS WHERE ITEM = '"+itemvalue+"') IS NULL OR CHARINDEX('"+tablevalue+"', (SELECT TABLA_LITERALES FROM OBJETOS WHERE ITEM = '"+itemvalue+"')) <= 0 \n" +
" BEGIN \n" +
" update objetos set tabla_literales = '" + tablevalue + "' where item = '" + itemvalue + "' \n" +
" END \n" +
"ALTER TABLE dbo." + tablevalue + " ADD CONSTRAINT \n" +
" PK_" + tablevalue + " PRIMARY KEY CLUSTERED( \n" +
" [IDIOMA] \n" +
" )WITH(PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON[PRIMARY] \n" +
"GO \n" +
" ALTER TABLE dbo." + tablevalue + " WITH CHECK ADD CONSTRAINT \n" +
" FK_LIT_ED1_IDIOMAS FOREIGN KEY(IDIOMA)REFERENCES dbo.Idiomas(CODIGO) \n" +
"GO";
}
foreach (Idiomas i in this.lBotones)
{
values += "\n INSERT INTO dbo."+tablevalue+" (IDIOMA) VALUES ('"+NumeroIdioma(i)+"') ";
}
values += "\n\n GO \n";
values += updatequery ;
this.richTextBox1.Text = values;
}
}
}
......@@ -123,10 +123,4 @@
<metadata name="Column2.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column1.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column2.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment