private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog opf
= new OpenFileDialog
(); opf.Filter = "Archivos de imagen|*.BMP;*.JPG;*.GIF;*.PNG";
opf.ShowDialog();
this.textBox9.Text = opf.FileName;
}
private void button2_Click(object sender, EventArgs e)//validar textbox vacios con CICLO antes de guardar o ACeptar
{
for (int i = 0; i < arrText.Length; ++i)
{
if (arrText[i].Text == "")
{
MessageBox.Show("Debe completar todos los campos", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
}
OleDbConnection cnn
= new OleDbConnection
(); cnn.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|db.accdb";
OleDbCommand cmda
= new OleDbCommand
();
cmda.Connection = cnn;
cmda.CommandText = "INSERT INTO ALUMNOS(CI, PrimerNombre, SegundoNombre, PrimerApellido, SegundoApellido, Edad, NumeroContacto, CorreoContacto, Foto, monto_inscripcion,estatus) VALUES(@AA, @BB, @CC, @DD, @EE, @FF, @GG, @HH, @II, 350, 1)";
cmda.Parameters.AddWithValue("@AA", this.textBox1.Text);
cmda.Parameters.AddWithValue("@BB", this.textBox2.Text);
cmda.Parameters.AddWithValue("@CC", this.textBox3.Text);
cmda.Parameters.AddWithValue("@DD", this.textBox4.Text);
cmda.Parameters.AddWithValue("@EE", this.textBox5.Text);
cmda.Parameters.AddWithValue("@FF", this.textBox6.Text);
cmda.Parameters.AddWithValue("@GG", this.textBox8.Text);
cmda.Parameters.AddWithValue("@HH", this.textBox7.Text);
//cmda.Parameters.AddWithValue("@JJ", this.textBox10.Text); //ultimo textbox incluido de Direccion
Byte[] arr = GlamConfig.getArrImg(arrText[arrText.Length - 1].Text.Trim().Length > 0 ? arrText[arrText.Length - 1].Text : Application.StartupPath + @"iconsno.gif");
OleDbParameter pa
= new OleDbParameter
(); pa.Value = arr;
pa.OleDbType = OleDbType.VarBinary;
pa.Size = arr.Length;
pa.ParameterName = "@II";
cmda.Parameters.Add(pa);
cnn.Open();
[b] int resultado = cmda.ExecuteNonQuery();[/b][u][u][i][color=#FF0000][/color][/i][/u][/u]
cnn.Close();
if (resultado > 0)
MessageBox.Show("Alumna Registrada");
else
MessageBox.Show("Alumna no registrada. Ocurrio un Error");
cmda.Parameters.Clear();
}