예제 #1
0
        private void btnAgregar_Click(object sender, EventArgs e)
        {
            this.Close();
            FormAgregarE abrir = new FormAgregarE();

            abrir.Show();
        }
예제 #2
0
        void Ingreso()
        {
            if (tbId.Text.Length > 0 && tbContacto.Text.Length > 0 && tbFono.Text.Length > 0 && tbNombre.Text.Length > 0)
            {
                if (tbId.Text.Length < 16 && tbContacto.Text.Length < 26 && tbFono.Text.Length < 26 && tbNombre.Text.Length < 26)
                {
                    try
                    {
                        SqlCommand comando = new SqlCommand("Insert into tblEmpresa (idEmpresa, Nombre, Contacto, Fono) values(@id, @name, @con, @fono)", miconexion);
                        comando.Parameters.AddWithValue("id", tbId.Text);
                        comando.Parameters.AddWithValue("name", tbNombre.Text);
                        comando.Parameters.AddWithValue("con", tbContacto.Text);
                        comando.Parameters.AddWithValue("fono", tbFono.Text);
                        miconexion.Open();
                        comando.ExecuteNonQuery();
                        miconexion.Close();
                        this.Hide();
                        MessageBox.Show("Ingresado satifactoriamente");
                        this.Close();
                    }

                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message,
                            "Error",
                            MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    finally
                    {
                        // Por si se produce un error,
                        // comprobar si la conexión está abierta
                        if (miconexion.State == ConnectionState.Open)
                        {
                            miconexion.Close();
                        }
                    }

                }

                else
                {
                    MessageBox.Show("Por Favor rellene los campos con la cantidad \npermitida descrita en el manual",
                                    "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);

                }
            }

            else
            {
                MessageBox.Show("Por Favor rellene los campos para ingresar",
                                      "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                if (tbId.Text == "")
                {
                    errorProvider1.SetError(tbId, "Debe rellenar el campo"); ;
                }
                else
                {
                    errorProvider1.SetError(tbId, "El valor valido");
                }

            }

            this.Close();
            FormAgregarE abrir = new FormAgregarE();
            abrir.Show();
        }
예제 #3
0
        void Ingreso()
        {
            if (tbId.Text.Length > 0 && tbContacto.Text.Length > 0 && tbFono.Text.Length > 0 && tbNombre.Text.Length > 0)
            {
                if (tbId.Text.Length < 16 && tbContacto.Text.Length < 26 && tbFono.Text.Length < 26 && tbNombre.Text.Length < 26)
                {
                    try
                    {
                        SqlCommand comando = new SqlCommand("Insert into tblEmpresa (idEmpresa, Nombre, Contacto, Fono) values(@id, @name, @con, @fono)", miconexion);
                        comando.Parameters.AddWithValue("id", tbId.Text);
                        comando.Parameters.AddWithValue("name", tbNombre.Text);
                        comando.Parameters.AddWithValue("con", tbContacto.Text);
                        comando.Parameters.AddWithValue("fono", tbFono.Text);
                        miconexion.Open();
                        comando.ExecuteNonQuery();
                        miconexion.Close();
                        this.Hide();
                        MessageBox.Show("Ingresado satifactoriamente");
                        this.Close();
                    }

                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message,
                                        "Error",
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    finally
                    {
                        // Por si se produce un error,
                        // comprobar si la conexión está abierta
                        if (miconexion.State == ConnectionState.Open)
                        {
                            miconexion.Close();
                        }
                    }
                }

                else
                {
                    MessageBox.Show("Por Favor rellene los campos con la cantidad \npermitida descrita en el manual",
                                    "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }

            else
            {
                MessageBox.Show("Por Favor rellene los campos para ingresar",
                                "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                if (tbId.Text == "")
                {
                    errorProvider1.SetError(tbId, "Debe rellenar el campo");;
                }
                else
                {
                    errorProvider1.SetError(tbId, "El valor valido");
                }
            }

            this.Close();
            FormAgregarE abrir = new FormAgregarE();

            abrir.Show();
        }
예제 #4
0
 private void btnAgregar_Click(object sender, EventArgs e)
 {
     this.Close();
     FormAgregarE abrir = new FormAgregarE();
     abrir.ShowDialog();
 }
예제 #5
0
        void Ingreso()
        {
            if (tbContacto.Text.Length > 0 && tbFono.Text.Length > 0 && tbNombre.Text.Length > 0)
            {
                if (tbContacto.Text.Length < 26 && tbFono.Text.Length < 26 && tbNombre.Text.Length < 26)
                {
                    try
                    {
                        int b = num(0);
                        miconexion.Open();
                        SqlCommand    consulta = new SqlCommand(" select * from tblEmpresa where idEmpresa = '" + b.ToString() + "'", miconexion);
                        SqlDataReader ejecuta  = consulta.ExecuteReader();
                        while (ejecuta.Read() == true)
                        {
                            b = num(0);
                        }

                        miconexion.Close();

                        SqlCommand comando = new SqlCommand("Insert into tblEmpresa (idEmpresa, Nombre, Contacto, Fono) values(@id, @name, @con, @fono)", miconexion);
                        comando.Parameters.AddWithValue("id", b);
                        comando.Parameters.AddWithValue("name", tbNombre.Text);
                        comando.Parameters.AddWithValue("con", tbContacto.Text);
                        comando.Parameters.AddWithValue("fono", tbFono.Text);
                        miconexion.Open();
                        comando.ExecuteNonQuery();
                        miconexion.Close();
                        //this.Hide();
                        MessageBox.Show("Ingresado satifactoriamente");
                        this.Close();
                    }

                    catch (SqlException ex)
                    {
                        MessageBox.Show(ex.Message,
                                        "Error",
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    finally
                    {
                        // Por si se produce un error,
                        // comprobar si la conexión está abierta
                        if (miconexion.State == ConnectionState.Open)
                        {
                            miconexion.Close();
                        }
                    }
                }

                else
                {
                    MessageBox.Show("Por Favor rellene los campos con la cantidad \npermitida descrita en el manual",
                                    "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }

            else
            {
                MessageBox.Show("Por Favor rellene los campos para ingresar",
                                "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            this.Close();
            FormAgregarE abrir = new FormAgregarE();

            abrir.Show();
        }
예제 #6
0
        void Ingreso()
        {
            if (tbContacto.Text.Length > 0 && tbFono.Text.Length > 0 && tbNombre.Text.Length > 0)
            {
                if (tbContacto.Text.Length < 26 && tbFono.Text.Length < 26 && tbNombre.Text.Length < 26)
                {
                    try
                    {
                        int b = num(0);
                        miconexion.Open();
                        SqlCommand consulta = new SqlCommand(" select * from tblEmpresa where idEmpresa = '" + b.ToString() + "'", miconexion);
                        SqlDataReader ejecuta = consulta.ExecuteReader();
                        while (ejecuta.Read() == true)
                        {
                            b = num(0);
                        }

                        miconexion.Close();

                        SqlCommand comando = new SqlCommand("Insert into tblEmpresa (idEmpresa, Nombre, Contacto, Fono) values(@id, @name, @con, @fono)", miconexion);
                        comando.Parameters.AddWithValue("id", b);
                        comando.Parameters.AddWithValue("name", tbNombre.Text);
                        comando.Parameters.AddWithValue("con", tbContacto.Text);
                        comando.Parameters.AddWithValue("fono", tbFono.Text);
                        miconexion.Open();
                        comando.ExecuteNonQuery();
                        miconexion.Close();
                        //this.Hide();
                        MessageBox.Show("Ingresado satifactoriamente");
                        this.Close();
                    }

                    catch (SqlException ex)
                    {
                        MessageBox.Show(ex.Message,
                            "Error",
                            MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    finally
                    {
                        // Por si se produce un error,
                        // comprobar si la conexión está abierta
                        if (miconexion.State == ConnectionState.Open)
                        {
                            miconexion.Close();
                        }
                    }

                }

                else
                {
                    MessageBox.Show("Por Favor rellene los campos con la cantidad \npermitida descrita en el manual",
                                    "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);

                }
            }

            else
            {
                MessageBox.Show("Por Favor rellene los campos para ingresar",
                                      "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }

            this.Close();
            FormAgregarE abrir = new FormAgregarE();
            abrir.Show();
        }