Exemple #1
0
        public void agregar(TerminalDestino nuevo)
        {
            SqlConnection conexion = new SqlConnection();
            SqlCommand    comando  = new SqlCommand();



            try
            {
                conexion.ConnectionString = "data source=localhost\\sqlexpress; initial catalog=TP_Final; integrated security=sspi";
                comando.CommandType       = System.Data.CommandType.Text;
                comando.CommandText       = "insert into TerminalesDestino (CodTerminal, NomTerminal, Estado) Values (@CodTerminal, @NomTerminal, @Estado)";
                comando.Parameters.Clear();
                comando.Parameters.AddWithValue("@CodTerminal", nuevo.CodTerminal.ToString());
                comando.Parameters.AddWithValue("@NomTerminal", nuevo.NombreTerminal.ToString());
                comando.Parameters.AddWithValue("@Estado", nuevo.Estado.ToString());

                comando.Connection = conexion;

                conexion.Open();
                comando.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                throw ex;
            }

            finally
            {
                conexion.Close();
            }
        }
Exemple #2
0
        public void btnGuardar_Click(object sender, EventArgs e)
        {
            TerminalDestinoNegocio negocio = new TerminalDestinoNegocio();

            try
            {
                if (terminalDestino == null)
                {
                    terminalDestino = new TerminalDestino();
                }

                terminalDestino.CodTerminal    = txtCodTerminal.Text.Trim();
                terminalDestino.NombreTerminal = txtNomTermianl.Text.Trim();
                //chofer.Estado = txtEstado.Text.Trim();
                terminalDestino.Estado = "A";

                if (terminalDestino.IdTerminal == 0)
                {
                    negocio.agregar(terminalDestino);
                }


                Response.Redirect("TerminalesDestino.aspx");


                //else
                //    negocio.modificar(articulo);

                //Dispose();
            }
            catch (Exception EX)
            {
                throw EX;
            }
        }
Exemple #3
0
        protected void btnActualizar_Click(object sender, EventArgs e)
        {
            TerminalDestinoNegocio negocio = new TerminalDestinoNegocio();

            try
            {
                terminalDestino = new TerminalDestino();

                terminalDestino.IdTerminal     = int.Parse(txtID.Text.Trim());
                terminalDestino.CodTerminal    = txtCodTerminal.Text.Trim();
                terminalDestino.NombreTerminal = txtNomTerminal.Text.Trim();
                terminalDestino.Estado         = "A";

                //if (chofer.IdChofer == 0)
                negocio.modificarTerminal(terminalDestino);


                Response.Redirect("TerminalesDestino.aspx");


                //else
                //    negocio.modificar(articulo);

                //Dispose();
            }
            catch (Exception EX)
            {
                throw EX;
            }
        }
Exemple #4
0
        public void modificarTerminal(TerminalDestino terminal)
        {
            AccesoDatos datos   = new AccesoDatos();
            SqlCommand  comando = new SqlCommand();

            try
            {
                //datos.setearQuery("Update POKEMONS set Nombre=@Nombre Where Id=@Id");
                datos.setearSP("SP_ModificarTerminalDestino");
                datos.AgregarParametro("@Id", terminal.IdTerminal.ToString());
                datos.AgregarParametro("@CodTerminal", terminal.CodTerminal.ToString());
                datos.AgregarParametro("@NomTerminal", terminal.NombreTerminal);
                datos.AgregarParametro("@Estado", terminal.Estado);
                datos.ejecutarAccion();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #5
0
        public List <TerminalDestino> listar2()
        {
            lista = new List <TerminalDestino>();

            TerminalDestino aux;

            AccesoDatos datos = new AccesoDatos();

            try
            {
                datos.SetearQery("Select ID, CodTerminal, NomTerminal, Estado from TerminalesDestino where Estado = 'A'");

                datos.ejecutarLector();

                while (datos.lector.Read())
                {
                    aux = new TerminalDestino();

                    //aux.Nombre = (string)lector["nombre"]; OTRA FORMA DE ASIGNACION

                    aux.IdTerminal = datos.lector.GetInt32(0);


                    if (!Convert.IsDBNull(datos.lector["CodTerminal"]))
                    {
                        aux.CodTerminal = datos.lector.GetString(1);
                    }

                    if (!Convert.IsDBNull(datos.lector["NomTerminal"]))
                    {
                        aux.NombreTerminal = datos.lector.GetString(2);
                    }


                    if (!Convert.IsDBNull(datos.lector["Estado"]))
                    {
                        aux.Estado = datos.lector.GetString(3);
                    }

                    //if (!Convert.IsDBNull(datos.lector["FechaNac"]))
                    //    aux.FechaNacimiento = datos.lector.GetSqlDateTime(3);

                    //if (!Convert.IsDBNull(datos.lector["Estado"]))
                    //    aux.Estado = datos.lector.GetSqlBoolean(3);

                    lista.Add(aux);
                }

                return(lista);
            }


            catch (Exception ex)
            {
                throw ex;
            }

            finally
            {
                datos.cerrarConexion();
            }
        }