Actualizado para poder

parent b5edd34b
......@@ -39,11 +39,18 @@
this.label5 = new System.Windows.Forms.Label();
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.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.panel2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
this.SuspendLayout();
//
// BotonAdd
//
this.BotonAdd.Location = new System.Drawing.Point(256, 111);
this.BotonAdd.Location = new System.Drawing.Point(256, 307);
this.BotonAdd.Name = "BotonAdd";
this.BotonAdd.Size = new System.Drawing.Size(75, 23);
this.BotonAdd.TabIndex = 9;
......@@ -56,7 +63,7 @@
this.ComboboxIdioma.AllowDrop = true;
this.ComboboxIdioma.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.ComboboxIdioma.FormattingEnabled = true;
this.ComboboxIdioma.Location = new System.Drawing.Point(5, 111);
this.ComboboxIdioma.Location = new System.Drawing.Point(5, 307);
this.ComboboxIdioma.Name = "ComboboxIdioma";
this.ComboboxIdioma.Size = new System.Drawing.Size(231, 21);
this.ComboboxIdioma.TabIndex = 8;
......@@ -65,21 +72,21 @@
//
this.panel1.AutoScroll = true;
this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.panel1.Location = new System.Drawing.Point(5, 145);
this.panel1.Location = new System.Drawing.Point(5, 341);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(528, 70);
this.panel1.TabIndex = 7;
//
// txtLiteral
//
this.txtLiteral.Location = new System.Drawing.Point(123, 41);
this.txtLiteral.Location = new System.Drawing.Point(123, 49);
this.txtLiteral.Name = "txtLiteral";
this.txtLiteral.Size = new System.Drawing.Size(378, 20);
this.txtLiteral.Size = new System.Drawing.Size(410, 20);
this.txtLiteral.TabIndex = 6;
//
// BotonTraduce
//
this.BotonTraduce.Location = new System.Drawing.Point(212, 227);
this.BotonTraduce.Location = new System.Drawing.Point(212, 413);
this.BotonTraduce.Name = "BotonTraduce";
this.BotonTraduce.Size = new System.Drawing.Size(118, 37);
this.BotonTraduce.TabIndex = 5;
......@@ -89,9 +96,9 @@
//
// richTextBox1
//
this.richTextBox1.Location = new System.Drawing.Point(3, 275);
this.richTextBox1.Location = new System.Drawing.Point(3, 471);
this.richTextBox1.Name = "richTextBox1";
this.richTextBox1.Size = new System.Drawing.Size(528, 254);
this.richTextBox1.Size = new System.Drawing.Size(528, 168);
this.richTextBox1.TabIndex = 14;
this.richTextBox1.Text = "";
//
......@@ -99,20 +106,20 @@
//
this.txtNombreTabla.Location = new System.Drawing.Point(123, 10);
this.txtNombreTabla.Name = "txtNombreTabla";
this.txtNombreTabla.Size = new System.Drawing.Size(378, 20);
this.txtNombreTabla.Size = new System.Drawing.Size(410, 20);
this.txtNombreTabla.TabIndex = 16;
//
// txtLitValue
//
this.txtLitValue.Location = new System.Drawing.Point(123, 76);
this.txtLitValue.Location = new System.Drawing.Point(123, 84);
this.txtLitValue.Name = "txtLitValue";
this.txtLitValue.Size = new System.Drawing.Size(378, 20);
this.txtLitValue.Size = new System.Drawing.Size(410, 20);
this.txtLitValue.TabIndex = 17;
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(17, 48);
this.label5.Location = new System.Drawing.Point(17, 56);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(94, 13);
this.label5.TabIndex = 18;
......@@ -130,17 +137,62 @@
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(31, 79);
this.label7.Location = new System.Drawing.Point(31, 87);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(78, 13);
this.label7.TabIndex = 20;
this.label7.Text = "Valor del literal:";
//
// panel2
//
this.panel2.AutoScroll = true;
this.panel2.Controls.Add(this.dataGridView1);
this.panel2.Location = new System.Drawing.Point(5, 140);
this.panel2.Name = "panel2";
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;
this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.Column1,
this.Column2});
this.dataGridView1.Dock = System.Windows.Forms.DockStyle.Fill;
this.dataGridView1.Location = new System.Drawing.Point(0, 0);
this.dataGridView1.Name = "dataGridView1";
this.dataGridView1.Size = new System.Drawing.Size(528, 151);
this.dataGridView1.TabIndex = 1;
//
// Column1
//
this.Column1.HeaderText = "Nombre del literal";
this.Column1.Name = "Column1";
this.Column1.Width = 243;
//
// Column2
//
this.Column2.HeaderText = "Valor del literal";
this.Column2.Name = "Column2";
this.Column2.Width = 242;
//
// MainMenu
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(543, 541);
this.ClientSize = new System.Drawing.Size(537, 648);
this.Controls.Add(this.button1);
this.Controls.Add(this.panel2);
this.Controls.Add(this.label7);
this.Controls.Add(this.label6);
this.Controls.Add(this.label5);
......@@ -156,6 +208,8 @@
this.ShowIcon = false;
this.Text = "Literals";
this.Load += new System.EventHandler(this.MainMenu_Load);
this.panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
......@@ -174,5 +228,10 @@
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.DataGridView dataGridView1;
private System.Windows.Forms.DataGridViewTextBoxColumn Column1;
private System.Windows.Forms.DataGridViewTextBoxColumn Column2;
}
}
\ No newline at end of file
using DarrenLee.Translator;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
namespace Literals
......@@ -29,7 +30,11 @@ namespace Literals
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
private void MainMenu_Load(object sender, EventArgs e)
{
{
//this.dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.DisplayedCells;
//this.dataGridView1.Columns[0].FillWeight = 60;
//this.dataGridView1.Columns[1].FillWeight = 9999;
}
/// <summary>
......@@ -123,18 +128,15 @@ namespace Literals
/// Generars the SQL.
/// </summary>
/// <returns></returns>
public string GenerarSQL()
public string GenerarSQL(string literal, string literalValue)
{
string query = "";
string database = "LIT_ED1";
string litname = "UNLOCKPROCESS";
string litvalue = "Proceso Bloqueado";
try
{
foreach (Idiomas i in this.lBotones)
{
query += "UPDATE dbo." + this.txtNombreTabla.Text + " SET " + this.txtLiteral.Text + " = '" + Translator.Translate(this.txtLitValue.Text, null, CodigoIdioma(i)) + "' WHERE IDIOMA = '" + NumeroIdioma(i) + "'\n";
query += "UPDATE dbo." + this.txtNombreTabla.Text + " SET " + literal + " = '" + Translator.Translate(literalValue, null, CodigoIdioma(i)) + "' WHERE IDIOMA = '" + NumeroIdioma(i) + "'\n";
}
}
catch (Exception ex)
......@@ -150,26 +152,51 @@ namespace Literals
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
private void BotonTraduce_Click(object sender, EventArgs e)
{
if (!string.IsNullOrWhiteSpace(this.txtNombreTabla.Text))
this.richTextBox1.Text = string.Empty;
if (this.panel1.Controls.Count > 0)
{
if (!string.IsNullOrWhiteSpace(this.txtLiteral.Text))
if (this.dataGridView1.Rows.Count > 0)
{
if (!string.IsNullOrEmpty(this.txtLitValue.Text))
{
this.richTextBox1.Text = GenerarSQL();
}
else
for (int i = 0; i < this.dataGridView1.Rows.Count; i++)
{
MessageBox.Show("El valor del literal no puede estar vacío.");
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()))
{
string query = GenerarSQL(this.dataGridView1.Rows[i].Cells[0].Value.ToString(), this.dataGridView1.Rows[i].Cells[1].Value.ToString());
this.richTextBox1.Text += query + "\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("El nombre del literal no puede estar vacío o contener espacios");
else
{
MessageBox.Show("No se ha introducido ningun literal");
}
}
else
{
MessageBox.Show("El nombre de la tabla no puede estar vacío o contener espacios");
MessageBox.Show("No se ha introducido ningun idioma");
}
}
......@@ -210,7 +237,8 @@ namespace Literals
{
return "pt";
}
else {
else
{
return "es";
}
}
......@@ -223,7 +251,7 @@ namespace Literals
public string NumeroIdioma(Idiomas i)
{
string code = null;
if (i == Idiomas.Colombiano)
{
return "00009";
......@@ -236,7 +264,7 @@ namespace Literals
{
return "00004";
}
else if(i == Idiomas.Peruano)
else if (i == Idiomas.Peruano)
{
return "00025";
}
......@@ -269,6 +297,18 @@ namespace Literals
return "00001";
}
}
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
DataGridViewRow row = (DataGridViewRow)this.dataGridView1.Rows[0].Clone();
row.Cells[0].Value = this.txtLiteral.Text;
row.Cells[1].Value = this.txtLitValue.Text;
dataGridView1.Rows.Add(row);
}
}
}
......@@ -117,4 +117,16 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<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>
<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