Пример #1
0
        public bool VerificarExisteArea(CE_Area objce_area)
        {
            //la funcion me permite recuperar los datos
            try
            {

                OracleConnection cnx = Conexion.ObtenerConexionOracle();
                OracleCommand cmd = new OracleCommand(String.Format("select * from area where nombrearea ='{0}'", objce_area.nombrearea), cnx);
                cnx.Open();
                OracleDataReader reader;

                reader = cmd.ExecuteReader();

                Boolean existearea = reader.HasRows;

                cnx.Close();

                return existearea;

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #2
0
        public int NuevaArea(CE_Area objce_area)
        {
            //el metodo m
            try
            {
                int filasafectadas = 0;

                OracleConnection cnx = Conexion.ObtenerConexionOracle();
                OracleCommand cmd = new OracleCommand();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Connection = cnx;
                cmd.CommandText = "sp_Nueva_Area";
                //asignar paramentros al procedimiento almacenado
                cmd.Parameters.AddWithValue("nombreareaX", objce_area.nombrearea);

                //abrir la conexion
                cnx.Open();
                //ejecutar el procedimiento almacenado
                filasafectadas = cmd.ExecuteNonQuery();
                //Cerrar conexion
                cnx.Close();
                return filasafectadas;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #3
0
        private void btnAgregar_Click(object sender, EventArgs e)
        {
            CE_Area objce_area = new CE_Area();
            CN_Area objcn_area = new CN_Area();

            objce_area.nombrearea = txtArea.Text;

            if (objcn_area.VerificarExisteArea(objce_area) == true)
            {

                MessageBox.Show("El area ya existe", "Fallo!!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

            }
            else
            {

                int filasafectadas = objcn_area.NuevaArea(objce_area);

                if (filasafectadas > 0)
                {
                    MessageBox.Show("La actualizacion se realizo con Exito!!", "Guardado", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("No se pudo actualizar", "Fallo!!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }

                this.dgvArea.DataSource = objcn_area.Listar_Areas();

            }
        }
Пример #4
0
        public int NuevaArea(CE_Area objce_area)
        {
            int filasafectadas = 0;
            CD_Area objcd_area = new CD_Area();

            filasafectadas = objcd_area.NuevaArea(objce_area);

            return filasafectadas;
        }
Пример #5
0
        public bool VerificarExisteArea(CE_Area objce_area)
        {
            CD_Area objcd_area = new CD_Area();

            return  objcd_area.VerificarExisteArea(objce_area);
        }