private Destino ReaderToEntidad(FbDataReader AReader){
			Destino pResult = new Destino();
			pResult.Clave  = (int)AReader["CLAVE"];
			pResult._Destino = (string)AReader["DESTINO"];
			
			return pResult;
		}
        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;
        }
		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);
		}
		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);
		}
Exemple #5
0
		public Destino DestinoModificar(Destino ADestino){
            if (!_DestinoPersistencia.ExisteDestino(ADestino))
                return _DestinoPersistencia.DestinoModificar(ADestino);
            else
                return null;
		}
		public JsonResult Modificar(Destino Destino){
			return Json(this._DestinosLogica.DestinoModificar(Destino));			
		}
		public JsonResult Insertar(Destino Destino){
			return Json(this._DestinosLogica.DestinoInsertar(Destino));			
		}