Ejemplo n.º 1
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            Modelo.EmpresaColaboradora_BD clsEmpresaColaboradorabd = new Modelo.EmpresaColaboradora_BD();
            Controlador.EmpresaColaboradora clsEmpresaColaboradora = new Controlador.EmpresaColaboradora();

            if (txtRUC.Text.Length == 11)
            {
                if (clsEmpresaColaboradorabd.VerificarSiExisteRUC(txtRUC.Text) == true)
                {
                    //si existe actualizo datos de personal

                    clsEmpresaColaboradora.email = txtEmail.Text.Trim();
                    clsEmpresaColaboradora.gerente = txtGerente.Text.Trim();
                    clsEmpresaColaboradora.idEmpresaColaboradora = txtRUC.Text.Trim();
                    clsEmpresaColaboradora.nombreEmpresa = txtRazonSocial.Text.Trim();
                    clsEmpresaColaboradora.telefono = txtTelefono.Text.Trim();

                    int resultado = Modelo.EmpresaColaboradora_BD.ActualizarDatosdEmpresa(clsEmpresaColaboradora);
                    if (resultado > 0)
                    {
                        MessageBox.Show("La actualizacion se realizo con Exito!!", "Guardado", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        limpiarControles();
                    }
                    else
                    {
                        MessageBox.Show("No se pudo actualizar los datos de la empresa", "Fallo!!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }

                }
                else
                {
                    // si no existe inserto el personal nuevo

                    clsEmpresaColaboradora.email = txtEmail.Text.Trim();
                    clsEmpresaColaboradora.gerente = txtGerente.Text.Trim();
                    clsEmpresaColaboradora.idEmpresaColaboradora = txtRUC.Text.Trim();
                    clsEmpresaColaboradora.nombreEmpresa = txtRazonSocial.Text.Trim();
                    clsEmpresaColaboradora.telefono = txtTelefono.Text.Trim();

                    int resultado = Modelo.EmpresaColaboradora_BD.AgregarEmpresa(clsEmpresaColaboradora);
                    if (resultado > 0)
                    {
                        MessageBox.Show("Los datos de la empresa nueva se guardaron con Exito!!", "Guardado", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        limpiarControles();
                    }
                    else
                    {
                        MessageBox.Show("No se pudo guardar los datos de la empresa", "Fallo!!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }

                }
            }
            else
            {

                MessageBox.Show("Debe ingresar el RUC  de la empresa", "Fallo!!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
        public Controlador.EmpresaColaboradora BuscarXRUC(Controlador.EmpresaColaboradora clsEmpresaColaboradora)
        {
            Controlador.EmpresaColaboradora clsEmpresaColaboradorax = new Controlador.EmpresaColaboradora();
            SqlConnection cnx = Conexion.Conexion.ObtenerConexion();
            cnx.Open();
            SqlCommand comando = new SqlCommand(String.Format(
               "SELECT NombreEmpresa, Gerente, Telefono, Email, idEmpresaColaboradora FROM empresacolaboradora WHERE idEmpresaColaboradora='{0}'", clsEmpresaColaboradora.idEmpresaColaboradora), cnx);
            SqlDataReader reader = comando.ExecuteReader();

            while (reader.Read())
            {
                clsEmpresaColaboradorax.email = Convert.ToString(reader["Email"]);
                clsEmpresaColaboradorax.gerente = Convert.ToString(reader["Gerente"]);
                clsEmpresaColaboradorax.idEmpresaColaboradora = Convert.ToString(reader["idEmpresaColaboradora"]);
                clsEmpresaColaboradorax.nombreEmpresa = Convert.ToString(reader["NombreEmpresa"]);
                clsEmpresaColaboradorax.telefono = Convert.ToString(reader["Telefono"]);

            }
            cnx.Close();
            return clsEmpresaColaboradorax;
        }
Ejemplo n.º 3
0
        private void txtRUC_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == Convert.ToChar(Keys.Enter))
            {

                Modelo.EmpresaColaboradora_BD clsEmpresaColaboradorabd = new Modelo.EmpresaColaboradora_BD();

                if (clsEmpresaColaboradorabd.VerificarSiExisteRUC(this.txtRUC.Text))
                {
                    //si existe el RUC muestro en lbl la empresa
                    Controlador.EmpresaColaboradora clsEmpresaColaboradora = new Controlador.EmpresaColaboradora();
                    //  Modelo.PersonalBD clspersonalbdx = new Modelo.PersonalBD();

                    clsEmpresaColaboradora.idEmpresaColaboradora = txtRUC.Text;

                    clsEmpresaColaboradora = clsEmpresaColaboradorabd.BuscarXRUC(clsEmpresaColaboradora);

                    this.lblRUC.Text = clsEmpresaColaboradora.nombreEmpresa;

                }
                else
                {

                    MessageBox.Show(" El numero de RUC no existe en la base de datos.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }

            }
        }
Ejemplo n.º 4
0
        private void txtRUC_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == Convert.ToChar(Keys.Enter))
            {

                Modelo.EmpresaColaboradora_BD clsEmpresaColaboradorabd = new Modelo.EmpresaColaboradora_BD();

                if (clsEmpresaColaboradorabd.VerificarSiExisteRUC(txtRUC.Text))
                {
                    //si existe el personal  recupero los datos de l personal a mis controles
                    Controlador.EmpresaColaboradora clsEmpresaColaboradora = new Controlador.EmpresaColaboradora();
                    //  Modelo.PersonalBD clspersonalbdx = new Modelo.PersonalBD();

                    clsEmpresaColaboradora.idEmpresaColaboradora = txtRUC.Text;

                    clsEmpresaColaboradora = clsEmpresaColaboradorabd.BuscarXRUC(clsEmpresaColaboradora);

                    this.txtEmail.Text = clsEmpresaColaboradora.email;
                    this.txtGerente.Text = clsEmpresaColaboradora.gerente;
                    this.txtRazonSocial.Text = clsEmpresaColaboradora.nombreEmpresa;
                    this.txtRUC.Text = clsEmpresaColaboradora.idEmpresaColaboradora;
                    this.txtTelefono.Text = clsEmpresaColaboradora.telefono;

                }
                else
                {

                    MessageBox.Show(" La empresa no existe en la base de datos.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }

            }
        }