Ejemplo n.º 1
0
		private Destino ReaderToEntidad(FbDataReader AReader){
			Destino pResult = new Destino();
			pResult.Clave  = (int)AReader["CLAVE"];
			pResult._Destino = (string)AReader["DESTINO"];
			
			return pResult;
		}
Ejemplo n.º 2
0
        public bool ExisteDestino(Destino ADestino)
        {
            string pSentencia = "SELECT CLAVE FROM DRASDEST WHERE UPPER(TRIM(DESTINO)) = @DESTINO";
            FbConnection con = _Conexion.ObtenerConexion();

            FbCommand com = new FbCommand(pSentencia, con);
            com.Parameters.Add("@DESTINO", FbDbType.VarChar).Value = ADestino._Destino.ToUpper().Trim();

            try
            {
                con.Open();

                FbDataReader reader = com.ExecuteReader();

                if (reader.Read())
                {
                    int clave = (int)reader["CLAVE"];
                    if (clave == ADestino.Clave)
                        return false;
                    else return true;
                }
            }
            finally
            {
                if (con.State == System.Data.ConnectionState.Open)
                {
                    con.Close();
                }
            }

            return false;
        }
Ejemplo n.º 3
0
		public Destino DestinoModificar(Destino ADestino){
			string pSentencia = "UPDATE DRASDEST SET DESTINO=@DESTINO WHERE CLAVE=@CLAVEE RETURNING CLAVE";
			FbConnection con  = _Conexion.ObtenerConexion();
			
			FbCommand com = new FbCommand(pSentencia, con);
			com.Parameters.Add("@DESTINO", FbDbType.VarChar).Value = ADestino._Destino;			
			com.Parameters.Add("@CLAVEE", FbDbType.Integer).Value = ADestino.Clave;	
			FbParameter pOutParameter = new FbParameter("@CLAVE", FbDbType.Integer);
			pOutParameter.Direction = ParameterDirection.Output;
			com.Parameters.Add(pOutParameter);
			
			try
			{
				con.Open();
				com.ExecuteNonQuery();
			}
			finally
			{
				if (con.State == System.Data.ConnectionState.Open){
                    con.Close();
                }
			}
			
			return DestinoObtener((int)pOutParameter.Value);
		}
Ejemplo n.º 4
0
		public Destino DestinoInsertar(Destino ADestino){
			string pSentencia = "INSERT INTO DRASDEST (DESTINO) VALUES (@DESTINO) RETURNING CLAVE";
			FbConnection con  = _Conexion.ObtenerConexion();
			
			FbCommand com = new FbCommand(pSentencia, con);
			com.Parameters.Add("@DESTINO", FbDbType.VarChar).Value = ADestino._Destino;			
			FbParameter pOutParameter = new FbParameter("@CLAVE", FbDbType.Integer);
			pOutParameter.Direction = ParameterDirection.Output;
			com.Parameters.Add(pOutParameter);
			
			try
			{
				con.Open();
				com.ExecuteNonQuery();
			}
			finally
			{
				if (con.State == System.Data.ConnectionState.Open){
                    con.Close();
                }
			}
			
			return DestinoObtener((int)pOutParameter.Value);
		}
Ejemplo n.º 5
0
		public Destino DestinoModificar(Destino ADestino){
            if (!_DestinoPersistencia.ExisteDestino(ADestino))
                return _DestinoPersistencia.DestinoModificar(ADestino);
            else
                return null;
		}
Ejemplo n.º 6
0
		public JsonResult Modificar(Destino Destino){
			return Json(this._DestinosLogica.DestinoModificar(Destino));			
		}
Ejemplo n.º 7
0
		public JsonResult Insertar(Destino Destino){
			return Json(this._DestinosLogica.DestinoInsertar(Destino));			
		}