예제 #1
0
        public CambiosTuberiaResponse usp_NewCambiosTuberia(CambiosTuberia registro)
        {
            CambiosTuberiaResponse Result = new CambiosTuberiaResponse();

            try
            {
                using (SqlConnection cnn = new SqlConnection(ConfigurationManager.ConnectionStrings["CNPC_Ductos"].ConnectionString))
                {
                    SqlCommand cmd = new SqlCommand("usp_NewCambiosTuberia", cnn);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@NumeroOleoducto", registro.NumeroOleoducto);
                    cmd.Parameters.AddWithValue("@CodigoDelTubo01", registro.CodigoDelTubo01);
                    cmd.Parameters.AddWithValue("@CodigoDelTuboReemplazado", registro.CodigoDelTuboReemplazado);
                    cmd.Parameters.AddWithValue("@TuberiaId", registro.TuberiaId);
                    cmd.Parameters.AddWithValue("@Motivo", registro.Motivo);
                    cmd.Parameters.AddWithValue("@OrdenServicio", registro.OrdenServicio);
                    cmd.Parameters.AddWithValue("@FechaOrdenServicio", registro.FechaOrdenServicio == null ? DateTime.Now : registro.FechaOrdenServicio);
                    cmd.Parameters.AddWithValue("@RowState", registro.RowState);
                    cmd.Parameters.AddWithValue("@LastUpdate", registro.LastUpdate);

                    cnn.Open();
                    cmd.ExecuteNonQuery();
                    cnn.Close();
                    Result.Item      = registro;
                    Result.Resultado = true;
                }
            }
            catch (Exception ex)
            {
                Result.Resultado    = false;
                Result.MensajeError = "Capa DAL: " + ex.Message;
            }

            return(Result);
        }
예제 #2
0
        public HttpResponseMessage Post([FromBody] CambiosTuberia registro)
        {
            var msg = new HttpResponseMessage(HttpStatusCode.NotAcceptable);
            CambiosTuberiaRequest  RegistroRequest = new CambiosTuberiaRequest();
            CambiosTuberiaResponse resultado       = null;
            var proxy = new ServicioClient();

            if (ModelState.IsValid)
            {
                try
                {
                    RegistroRequest.Item      = registro;
                    RegistroRequest.Operacion = Model.Operacion.Agregar;
                    resultado = proxy.CambiosTuberiaEjecutarOperacion(RegistroRequest);
                    if (resultado.Item == null)
                    {
                        resultado.Resultado    = false;
                        resultado.MensajeError = "Error en el registro de datos";
                        throw (new Exception(resultado.MensajeError));
                    }
                }
                catch (Exception ex)
                {
                    resultado.MensajeError = ex.Message;
                }
            }
            else
            {
                resultado.MensajeError = "Error en el ingreso de Datos";
            }
            msg = new HttpResponseMessage(HttpStatusCode.Created);
            msg.Headers.Location = new Uri(Request.RequestUri + resultado.Item.Id.ToString());
            return(msg);
        }
예제 #3
0
        public CambiosTuberiaResponse FilterByMotivoCambiosTuberia(int TuberiaId, string Nombre, int page, int records)
        {
            CambiosTuberiaResponse ductos = new CambiosTuberiaResponse();

            ductos.List = new List <CambiosTuberia>();
            using (SqlConnection cnn = new SqlConnection(ConfigurationManager.ConnectionStrings["CNPC_Ductos"].ConnectionString))
            {
                SqlCommand cmd = new SqlCommand("uspGetListCambiosTuberia", cnn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@NumeroOleoducto", SqlDbType.VarChar).Value = Nombre;
                cmd.Parameters.Add("@TuberiaId", SqlDbType.Int).Value           = TuberiaId;
                cmd.Parameters.Add("@Motivo", SqlDbType.VarChar).Value          = Nombre;
                cmd.Parameters.Add("@Records", SqlDbType.Int).Value             = records;
                cmd.Parameters.Add("@Page", SqlDbType.Int).Value          = page;
                cmd.Parameters.Add("@TotalPage", SqlDbType.Int).Direction = ParameterDirection.Output;
                cnn.Open();

                cmd.ExecuteNonQuery();
                ductos.TotalPages = Int32.Parse(cmd.Parameters["@TotalPage"].Value.ToString());

                SqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    CambiosTuberia d = new CambiosTuberia();
                    d.Id = reader.SafeGetInt32("Id", 0);
                    d.NumeroOleoducto = reader.SafeGetString("NumeroOleoducto", "");
                    d.TuberiaId       = reader.SafeGetInt32("TuberiaId", 0);
                    d.Motivo          = reader.SafeGetString("Motivo", "");
                    d.OrdenServicio   = reader.SafeGetString("OrdenServicio", "");
                    d.RowState        = reader.SafeGetString("RowState", "");
                    d.LastUpdate      = reader.SafeGetDateTime("LastUpdate", new DateTime(1950, 01, 01));
                    ductos.List.Add(d);
                }
                ductos.Page    = page;
                ductos.Records = records;

                cnn.Close();
            }
            using (SqlConnection cnn = new SqlConnection(ConfigurationManager.ConnectionStrings["CNPC_Ductos"].ConnectionString))
            {
                SqlCommand cmd = new SqlCommand("uspGetCountCambiosTuberia", cnn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@TuberiaId", SqlDbType.Int).Value  = TuberiaId;
                cmd.Parameters.Add("@Nombre", SqlDbType.VarChar).Value = Nombre;
                cmd.Parameters.Add("@Records", SqlDbType.Int).Value    = records;

                cnn.Open();
                SqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    ductos.TotalPages   = reader.SafeGetInt32("TotalPage", 0);
                    ductos.TotalRecords = reader.SafeGetInt32("TotalRecords", 0);
                }
                cnn.Close();
            }
            return(ductos);
        }
예제 #4
0
        public CambiosTuberiaResponse GetListCambiosTuberia(string NumeroOleoducto, int TuberiaID, int page, int records)
        {
            CambiosTuberiaResponse Result = null;

            using (var r = new Repository <CambiosTuberia>())
            {
                Result = r.usp_GetListCambiosTuberia(NumeroOleoducto, TuberiaID, records, page);
            }
            return(Result);
        }
예제 #5
0
        public CambiosTuberiaResponse FilterByName(int TuberiaID, string Nombre, int page, int records)
        {
            CambiosTuberiaResponse Result = null;

            using (var r = new Repository <CambiosTuberia>())
            {
                Result = r.FilterByMotivoCambiosTuberia(TuberiaID, Nombre, page, records);
            }
            return(Result);
        }
예제 #6
0
        public CambiosTuberiaResponse Create(CambiosTuberia registro)
        {
            CambiosTuberiaResponse Result = null;

            using (var r = new Repository <CambiosTuberia>())
            {
                CambiosTuberia d = r.Retrieve(p => p.Id == registro.Id);
                if (d == null)
                {
                    Result = r.usp_NewCambiosTuberia(registro);
                }
                else
                {
                    throw (new Exception("Error al guardar el Cambios Tuberia"));
                }
            }
            return(Result);
        }
예제 #7
0
        public CambiosTuberiaResponse usp_GetListCambiosTuberia(string NumeroOleoducto, int TuberiaID, int records, int page)
        {
            CambiosTuberiaResponse registros = new CambiosTuberiaResponse();

            registros.List = new List <CambiosTuberia>();
            try
            {
                using (SqlConnection cnn = new SqlConnection(ConfigurationManager.ConnectionStrings["CNPC_Ductos"].ConnectionString))
                {
                    SqlCommand cmd = new SqlCommand("usp_GetListTipoSoporte", cnn);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cnn.Open();

                    cmd.ExecuteNonQuery();
                    registros.TotalPages = Int32.Parse(cmd.Parameters["@TotalPage"].Value.ToString());

                    SqlDataReader reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        CambiosTuberia d = new CambiosTuberia();
                        d.Id = reader.SafeGetInt32("Id", 0);
                        d.NumeroOleoducto    = reader.SafeGetString("NumeroOleoducto", "");
                        d.CodigoDelTubo01    = reader.SafeGetString("CodigoDelTubo01", "");
                        d.Motivo             = reader.SafeGetString("Motivo", "");
                        d.OrdenServicio      = reader.SafeGetString("OrdenServicio", "");
                        d.FechaOrdenServicio = reader.SafeGetDateTime("FechaOrdenservicio", new DateTime(1950, 01, 01));
                        registros.List.Add(d);
                    }
                    registros.Page    = page;
                    registros.Records = records;

                    cnn.Close();
                }
            }
            catch (Exception ex)
            {
                registros.Resultado    = false;
                registros.MensajeError = "Capa DAL: " + ex.Message;
            }

            return(registros);
        }