Esempio n. 1
0
        public void Inicializar(IPAddress ip, int puerto)
        {
            this.Ip     = ip;
            this.Puerto = puerto;

            Log.d("[ServidorSocket] Inicializar por Ip: {1} Puerto: {0}", Puerto.ToString(), Ip.ToString());
        }
        private void CargarComboPuertoDestino()
        {
            SqlDataReader reader = PuertoFunc.ObtenerPuerto();

            DataGridViewComboBoxColumn comboTipo = (DataGridViewComboBoxColumn)dgv_tramos.Columns["colPuertoDestino"];

            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    Puerto puerto = new Puerto();
                    puerto.id     = Convert.ToInt32(reader.GetDecimal(0));
                    puerto.nombre = reader.GetString(1);
                    //puerto.estado = reader.GetBoolean(2);
                    ComboboxItem item = new ComboboxItem();
                    item.Text  = puerto.nombre;
                    item.Value = puerto;
                    comboTipo.Items.Add(puerto.nombre);
                }
                int currentRow = dgv_tramos.Rows.Count - 1;
                DataGridViewComboBoxCell celltipo = (DataGridViewComboBoxCell)(dgv_tramos.Rows[currentRow].Cells[1]);
                celltipo.Value = comboTipo.Items[0];
            }
            reader.Close();
        }
Esempio n. 3
0
        public static void Add(Puerto puerto)
        {
            if (ValidarExistenciaPuerto(puerto.Nombre))
            {
                throw new Exception("El puerto ya existe");
            }

            try
            {
                var        conn    = Repository.GetConnection();
                SqlCommand comando = new SqlCommand(@"INSERT INTO TIRANDO_QUERIES.Puerto(puer_nombre, puer_activo) values(@nombre, @activo)", conn);

                puerto.Nombre = puerto.Nombre.Trim().ToUpper();
                comando.Parameters.AddWithValue("@nombre", puerto.Nombre);
                puerto.Activo = true;
                comando.Parameters.Add("@activo", SqlDbType.Bit);
                comando.Parameters["@activo"].Value = puerto.Activo;
                comando.ExecuteNonQuery();

                comando.Dispose();
                conn.Close();
                conn.Dispose();
            }
            catch (Exception ex)
            {
                throw new Exception("Ocurrió un error al intentar crear el puerto", ex);
            }
        }
Esempio n. 4
0
        private ObservableCollection <Puerto> SelectAllByAyuda(String CONS_TabVia, String CONS_CodVia, String TIPO_TabPais, String TIPO_CodPais, String PUER_CodEstandar, String PUER_Nombre)
        {
            try
            {
                ObservableCollection <Puerto> items = new ObservableCollection <Puerto>();
                Puerto item = new Puerto();
                DataAccessEnterpriseSQL.DAAsignarProcedure("TCOM_SP_CONSULTAR_PuertoAyuda");
                DataAccessEnterpriseSQL.DAAgregarParametro("@pchrCONS_TabVia", CONS_TabVia, SqlDbType.Char, 3, ParameterDirection.Input);
                DataAccessEnterpriseSQL.DAAgregarParametro("@pchrCONS_CodVia", CONS_CodVia, SqlDbType.Char, 3, ParameterDirection.Input);
                DataAccessEnterpriseSQL.DAAgregarParametro("@pchrPUER_CodEstandar", PUER_CodEstandar, SqlDbType.Char, 7, ParameterDirection.Input);
                DataAccessEnterpriseSQL.DAAgregarParametro("@pvchPUER_Nombre", PUER_Nombre, SqlDbType.VarChar, 100, ParameterDirection.Input);

                using (IDataReader reader = DataAccessEnterpriseSQL.DAExecuteReader())
                {
                    while (reader.Read())
                    {
                        item = new Puerto();
                        Loader.LoadEntity(reader, item);
                        item.Instance = InstanceEntity.Unchanged;
                        items.Add(item);
                    }
                }
                return(items);
            }
            catch (Exception ex)
            { throw ex; }
        }
Esempio n. 5
0
 private Puerto SelectOneByCodEstandar(String CONS_TabVia, String CONS_CodVia, String PUER_CodEstandar)
 {
     try
     {
         Puerto item = new Puerto();
         DataAccessEnterpriseSQL.DAAsignarProcedure("TCOM_SP_CONSULTAR_PuertoCodEstandar");
         DataAccessEnterpriseSQL.DAAgregarParametro("@pchrCONS_TabVia", CONS_TabVia, SqlDbType.Char, 3, ParameterDirection.Input);
         DataAccessEnterpriseSQL.DAAgregarParametro("@pchrCONS_CodVia", CONS_CodVia, SqlDbType.Char, 3, ParameterDirection.Input);
         DataAccessEnterpriseSQL.DAAgregarParametro("@pchrPUER_CodEstandar", PUER_CodEstandar, SqlDbType.Char, 7, ParameterDirection.Input);
         using (IDataReader reader = DataAccessEnterpriseSQL.DAExecuteReader())
         {
             if (reader.Read())
             {
                 Loader.LoadEntity(reader, item);
                 item.Instance = InstanceEntity.Unchanged;
             }
             else
             {
                 throw new Exception("No se encontro el registro.");
             }
         }
         return(item);
     }
     catch (Exception ex)
     { throw ex; }
 }
        private void button1_Click(object sender, EventArgs e)
        {
            Puerto puerto1 = new Puerto(pp_id, this.txt_nombre.Text);

            puerto.UpdatePuerto(puerto1);
            MessageBox.Show("El nombre se modifico con exito", "Mensaje", MessageBoxButtons.OK);
        }
Esempio n. 7
0
        public static Puerto GetByID(int id)
        {
            var            conn    = Repository.GetConnection();
            string         comando = string.Format(@"SELECT * FROM TIRANDO_QUERIES.Puerto WHERE puer_codigo = {0}", id);
            DataTable      dataTable;
            SqlDataAdapter dataAdapter;

            try
            {
                dataAdapter = new SqlDataAdapter(comando, conn);
                dataTable   = new DataTable();

                dataAdapter.Fill(dataTable);

                DataRow registroPuerto = dataTable.Rows[0];

                var idPuerto = int.Parse(registroPuerto["puer_codigo"].ToString());

                var puerto = new Puerto
                {
                    Cod_Puerto = idPuerto,
                    Activo     = bool.Parse(registroPuerto["puer_activo"].ToString()),
                    Nombre     = registroPuerto["puer_nombre"].ToString()
                };

                conn.Close();
                conn.Dispose();

                return(puerto);
            }
            catch (Exception ex)
            {
                throw new Exception("Ocurrió un error al intentar obtener el puerto", ex);
            }
        }
Esempio n. 8
0
        private bool Delete(ref Puerto item)
        {
            try
            {
                if (item.Instance == Infrastructure.Aspect.BusinessEntity.InstanceEntity.Deleted)
                {
                    DataAccessEnterpriseSQL.DAAsignarProcedure("TCOM_SP_ELIMINAR_Puerto");
                    DataAccessEnterpriseSQL.DAAgregarParametro("@pintPUER_Codigo", item.PUER_Codigo, SqlDbType.Int, 4, ParameterDirection.Input);

                    if (DataAccessEnterpriseSQL.DAExecuteNonQuery() > 0)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    return(true);
                }
            }
            catch (Exception ex)
            { throw ex; }
        }
Esempio n. 9
0
        public static ResultadoTransaccion ObtienePuertoPorCodigo(String codigo)
        {
            var    res    = new ResultadoTransaccion();
            Puerto puerto = null;
            //Abrir Conexion
            var conn = BaseDatos.Conexion();

            try {
                var command = new SqlCommand("SP_L_Puertos_por_codigo", conn);
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.AddWithValue("@codigo", codigo);
                var reader = command.ExecuteReader();
                while (reader.Read())
                {
                    puerto = GetFromDataReader(reader);
                }

                res.Accion            = Entidades.Enums.Enums.AccionTransaccion.Consultar;
                res.ObjetoTransaccion = puerto;
                res.Descripcion       = "Se creo la cotizacion Exitosamente";
            } catch (Exception ex) {
                Log.EscribirLog(ex.Message);

                res.Descripcion  = ex.Message;
                res.ArchivoError = NombreClase;
                res.MetodoError  = MethodBase.GetCurrentMethod().Name;
            } finally {
                conn.Close();
            }
            return(res);
        }
Esempio n. 10
0
        public static Puerto ObtenerPuertoDesdeUnReader(SqlDataReader reader)
        {
            Puerto puerto = new Puerto();

            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    if (!reader.IsDBNull(0))
                    {
                        puerto.id = Convert.ToInt32(reader.GetDecimal(0));
                    }
                    if (!reader.IsDBNull(1))
                    {
                        puerto.nombre = reader.GetString(1);
                    }
                    if (!reader.IsDBNull(2))
                    {
                        puerto.estado = reader.GetBoolean(2);
                    }
                }
            }
            reader.Close();
            return(puerto);
        }
Esempio n. 11
0
        public static ResultadoTransaccion EliminaPuerto(Puerto puerto)
        {
            var res = new ResultadoTransaccion();
            //Abrir Conexion
            var conn = BaseDatos.Conexion();

            try {
                var command = new SqlCommand("SP_E_PUERTOS", conn);
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.AddWithValue("@codigo", puerto.Codigo);
                var foo = command.ExecuteNonQuery();

                res.ObjetoTransaccion = puerto;
                res.Descripcion       = "Se Elimino el Puerto Exitosamente";
            } catch (Exception ex) {
                Log.EscribirLog(ex.Message);

                res.Descripcion  = ex.Message;
                res.ArchivoError = NombreClase;
                res.MetodoError  = MethodBase.GetCurrentMethod().Name;
            } finally {
                conn.Close();
            }
            return(res);
        }
Esempio n. 12
0
        public ActionResult Puerto(int?RowID_Lista)
        {
            if (RowID_Lista == null || RowID_Lista == 0)
            {
                ViewBag.Ciudad       = db.Ciudad.ToList();
                ViewBag.Departamento = db.Departamento.ToList();
                ViewBag.Pais         = db.Pais.ToList();
            }
            else
            {
                Puerto p = db.Puerto.Where(a => a.RowID == RowID_Lista).FirstOrDefault();
                ViewBag.Pais         = db.Pais.ToList();
                ViewBag.Departamento = db.Departamento.Where(f => f.PaisID == p.Ciudad.Departamento.PaisID);
                ViewBag.Ciudad       = db.Ciudad.Where(f => f.DepartamentoID == p.Ciudad.DepartamentoID);
            }


            if (RowID_Lista != null)
            {
                return(View(db.Puerto.Where(le => le.RowID == RowID_Lista).FirstOrDefault()));
            }
            else
            {
                return(View(new Puerto()));
            }
        }
Esempio n. 13
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] Puerto puerto)
        {
            if (id != puerto.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(puerto);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PuertoExists(puerto.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(puerto));
        }
Esempio n. 14
0
        public Boolean Save(ref Puerto Item)
        {
            try
            {
                Boolean m_isCorrect = true;
                Infrastructure.Aspect.DataAccess.DataAccessEnterpriseSQL.DABeginTransaction();
                switch (Item.Instance)
                {
                case Infrastructure.Aspect.BusinessEntity.InstanceEntity.Added:
                    m_isCorrect = Insert(ref Item); break;

                case Infrastructure.Aspect.BusinessEntity.InstanceEntity.Modified:
                    m_isCorrect = Update(ref Item); break;

                case Infrastructure.Aspect.BusinessEntity.InstanceEntity.Deleted:
                    m_isCorrect = Delete(ref Item); break;
                }
                if (m_isCorrect)
                {
                    Infrastructure.Aspect.DataAccess.DataAccessEnterpriseSQL.DACommitTransaction();
                }
                else
                {
                    Infrastructure.Aspect.DataAccess.DataAccessEnterpriseSQL.DARollbackTransaction();
                }
                return(m_isCorrect);
            }
            catch (Exception)
            { Infrastructure.Aspect.DataAccess.DataAccessEnterpriseSQL.DARollbackTransaction(); throw; }
        }
Esempio n. 15
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            if (validar())
            {
                return;
            }
            var puerto = BindViewToDomain();
            ResultadoTransaccion resultado = null;

            try {
                if (_puerto == null)
                {
                    resultado = ClsPuertos.CreaPuerto(puerto);
                }
                else
                {
                    resultado = ClsPuertos.ActualizaPuerto(puerto);
                }
                MessageBox.Show(resultado.Descripcion, "Mantenedor de Puertos", MessageBoxButtons.OK, MessageBoxIcon.Information);

                _puerto = null;

                LimpiarDatos();
                if (gridPuertos.DataSource != null)
                {
                    ListarPuertos();
                }
            } catch (Exception ex) {
                Console.Write(ex.InnerException);
            }
        }
Esempio n. 16
0
        public BLPuerto(IUnityContainer container)
        {
            this.ContainerService = container;
            Loader = new BusinessEntityLoader <Puerto>();
            Puerto item = new Puerto();

            Loader.EntityType = item.GetType();
        }
Esempio n. 17
0
        public void createPort(Puerto port)
        {
            Dictionary <String, Object> dic = new Dictionary <String, Object>();

            dic.Add("@Nombre", port.getPuerto());

            db.executeProcedureWithParameters("dbo.sp_crear_puerto", dic);
        }
Esempio n. 18
0
        private static Puerto GetFromDataReader(SqlDataReader reader)
        {
            var p = new Puerto();

            p.Codigo = reader["puerto"].ToString();
            p.Nombre = reader["nombre"].ToString();
            p.Pais   = reader["pais"].ToString();
            return(p);
        }
Esempio n. 19
0
 internal void SetDestino()
 {
     if (this.puertoSeleccionado != null)
     {
         unTramo.destino = this.puertoSeleccionado;
         unaComprarPasajeVista.setPuertoDestino(this.puertoSeleccionado);
         this.puertoSeleccionado = null;
     }
 }
Esempio n. 20
0
        private Puerto BindViewToDomain()
        {
            var puerto = new Puerto();

            puerto.Codigo = txtCodigo.Text;
            puerto.Nombre = txtNombre.Text;
            puerto.Pais   = txtPais.Text;
            return(puerto);
        }
Esempio n. 21
0
 public void setDestino()
 {
     if (puertoSeleccionado != null)
     {
         tramo.destino = puertoSeleccionado;
         vista.setDestino(tramo.destino.nombre);
         puertoSeleccionado = null;
     }
 }
Esempio n. 22
0
 internal void setPasaPor()
 {
     if (puertoSeleccionado != null)
     {
         this.pasaPor = puertoSeleccionado;
         vista.setPasaPor(this.pasaPor.nombre);
         puertoSeleccionado = null;
     }
 }
Esempio n. 23
0
 internal void SetOrigen()
 {
     if (this.puertoSeleccionado != null)
     {
         unTramo.origen = this.puertoSeleccionado;
         unaComprarPasajeVista.SetPuertoOrigen(this.puertoSeleccionado);
         this.puertoSeleccionado = null;
     }
 }
Esempio n. 24
0
 internal void setDestino()
 {
     if (puertoSeleccionado != null)
     {
         this.destino = puertoSeleccionado;
         vista.setDestino(this.destino.nombre);
         puertoSeleccionado = null;
     }
 }
Esempio n. 25
0
 public void setOrigen()
 {
     if (puertoSeleccionado != null)
     {
         this.origen = puertoSeleccionado;
         vista.setOrigen(this.origen.nombre);
         puertoSeleccionado = null;
     }
 }
Esempio n. 26
0
        private void search_Click(object sender, EventArgs e)
        {
            DateTime d        = this.dtInicio.Value;
            Puerto   pOrigen  = this.comboPuertoOri.SelectedItem as Puerto;
            Puerto   pDestino = this.comboPuertoDest.SelectedItem as Puerto;

            this.dgvViajes.DataSource = dao.getAllTrips(pOrigen.idPuerto, pDestino.idPuerto, d);
            dgvViajes.Visible         = true;
            this.seleccion.Visible    = true;
        }
Esempio n. 27
0
        public int verifyPortExisted(Puerto port)
        {
            DataTable dt = db.select_query("Select PUERTOS.idPuerto from dbo.Puerto PUERTOS where PUERTOS.Nombre = '" + port.getPuerto() + "';");

            if (dt.Rows.Count != 0)
            {
                return(1);
            }
            return(0);
        }
Esempio n. 28
0
        public async Task <IActionResult> Create([Bind("Id,Name")] Puerto puerto)
        {
            if (ModelState.IsValid)
            {
                _context.Add(puerto);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(puerto));
        }
Esempio n. 29
0
        private void toolStripButton2_Click_1(object sender, EventArgs e)
        {
            _puerto       = null;
            ActiveControl = txtCodigo;
            LimpiarDatos();
            gridView1.ClearSelection();
            var seleccionados = gridView1.GetSelectedRows();

            foreach (var i in seleccionados)
            {
                gridView1.UnselectRow(i);
            }
        }
 public Boolean SavePuerto(ref Puerto Item)
 {
     try
     {
         if (Item.Instance != Infrastructure.Aspect.BusinessEntity.InstanceEntity.Unchanged)
         {
             return(BL_Puerto.Save(ref Item));
         }
         return(true);
     }
     catch (Exception)
     { throw; }
 }