public BitacoraDesarrollo detail(int id) { BitacoraDesarrollo bit = bitacora_repository.detail(id); bit.demoras = bitacora_repository.getDemorasByIdBitacora(bit.id); return(bit); }
public HttpResponseMessage detail(int id) { BitacoraDesarrollo bitacora = bitacora_service.detail(id); if (bitacora != null) { IDictionary <string, BitacoraDesarrollo> data = new Dictionary <string, BitacoraDesarrollo>(); data.Add("data", bitacora); return(Request.CreateResponse(HttpStatusCode.OK, data)); } else { IDictionary <string, string> data = new Dictionary <string, string>(); data.Add("message", "Object not found."); return(Request.CreateResponse(HttpStatusCode.BadRequest, data)); } }
public TransactionResult create(BitacoraDesarrolloVo bitacora_vo, User user_log) { if (bitacora_vo.comentarios == null) { bitacora_vo.comentarios = ""; } if (bitacora_vo.vale_acero == null) { bitacora_vo.vale_acero = ""; } if (bitacora_vo.vale_explosivos == null) { bitacora_vo.vale_explosivos = ""; } BitacoraDesarrollo obj = BitacoraDesarrolloAdapter.voToObject(bitacora_vo); obj.user = user_log; int id = bitacora_repository.create(obj); if (id > 0) { var tr = TransactionResult.CREATED; if (bitacora_vo.demoras != null) { foreach (DetalleDemoraBitacoraVo dvo in bitacora_vo.demoras) { dvo.bitacora_desarrollo_id = id; dvo.tipo_bitacora = 1; tr = bitacora_repository.createDetalleDemoraBitacora(DetalleDemoraBitacoraAdapter.voToObject(dvo)); if (tr != TransactionResult.CREATED) { return(tr); } } } return(tr); } return(TransactionResult.ERROR); //return bitacora_repository.create(obj); }
public TransactionResult autorizarRango(BitacoraDesarrollo bitacora) { SqlConnection connection = null; using (connection = new SqlConnection(ConfigurationManager.ConnectionStrings["Coz_Operaciones_DB"].ConnectionString)) { try { connection.Open(); SqlCommand command = new SqlCommand("sp_autorizarRangoBitacoraDesarrollo", connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.Add(new SqlParameter("dias_apertura_calendario", bitacora.dias_apertura_calendario)); command.Parameters.Add(new SqlParameter("id", bitacora.id)); command.ExecuteNonQuery(); return(TransactionResult.OK); } catch (SqlException ex) { if (connection != null) { connection.Close(); } if (ex.Number == 2627) { return(TransactionResult.EXISTS); } return(TransactionResult.NOT_PERMITTED); } catch (Exception ex) { Console.WriteLine(ex.Message); if (connection != null) { connection.Close(); } return(TransactionResult.ERROR); } } }
public TransactionResult update(BitacoraDesarrollo bitacora) { bitacora.status_edicion = 0; bitacora.dias_apertura_calendario = 0; SqlConnection connection = null; using (connection = new SqlConnection(ConfigurationManager.ConnectionStrings["Coz_Operaciones_DB"].ConnectionString)) { try { connection.Open(); SqlCommand command = new SqlCommand("sp_updateBitacoraDesarrollo", connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.Add(new SqlParameter("maquinaria_id", bitacora.maquinaria.id)); command.Parameters.Add(new SqlParameter("fecha_bitacora", Validations.defaultString(bitacora.fecha_bitacora.ToString()))); command.Parameters.Add(new SqlParameter("grupo", Validations.defaultString(bitacora.grupo))); command.Parameters.Add(new SqlParameter("turno", bitacora.turno)); command.Parameters.Add(new SqlParameter("compania_id", bitacora.compania.id)); command.Parameters.Add(new SqlParameter("vale_acero", Validations.defaultString(bitacora.vale_acero))); command.Parameters.Add(new SqlParameter("vale_explosivos", Validations.defaultString(bitacora.vale_explosivos))); command.Parameters.Add(new SqlParameter("subnivel_id", bitacora.subnivel.id)); command.Parameters.Add(new SqlParameter("zona", Validations.defaultString(bitacora.zona))); command.Parameters.Add(new SqlParameter("tipo_desarrollo_id", bitacora.tipo_desarrollo.id)); command.Parameters.Add(new SqlParameter("hora_primer_barreno", Validations.defaultString(bitacora.hora_primer_barreno.ToShortTimeString()))); command.Parameters.Add(new SqlParameter("hora_ultimo_barreno", Validations.defaultString(bitacora.hora_ultimo_barreno.ToShortTimeString()))); command.Parameters.Add(new SqlParameter("numero_barrenos", bitacora.numero_barrenos)); command.Parameters.Add(new SqlParameter("anclas", bitacora.anclas)); command.Parameters.Add(new SqlParameter("mallas", bitacora.mallas)); command.Parameters.Add(new SqlParameter("operador_id", bitacora.operador.id)); command.Parameters.Add(new SqlParameter("ayudante_id", bitacora.ayudante.id)); command.Parameters.Add(new SqlParameter("comentarios", Validations.defaultString(bitacora.comentarios))); command.Parameters.Add(new SqlParameter("status_edicion", bitacora.status_edicion)); command.Parameters.Add(new SqlParameter("dias_apertura_calendario", bitacora.dias_apertura_calendario)); command.Parameters.Add(new SqlParameter("user_id", bitacora.user.id)); command.Parameters.Add(new SqlParameter("id", bitacora.id)); command.ExecuteNonQuery(); return(TransactionResult.OK); } catch (SqlException ex) { if (connection != null) { connection.Close(); } if (ex.Number == 2627) { return(TransactionResult.EXISTS); } return(TransactionResult.NOT_PERMITTED); } catch (Exception ex) { Console.WriteLine(ex.Message); if (connection != null) { connection.Close(); } return(TransactionResult.ERROR); } } }
public int create(BitacoraDesarrollo bitacora) { bitacora.status_edicion = 1; bitacora.dias_apertura_calendario = 0; SqlConnection connection = null; using (connection = new SqlConnection(ConfigurationManager.ConnectionStrings["Coz_Operaciones_DB"].ConnectionString)) { try { connection.Open(); SqlCommand command = new SqlCommand("sp_createBitacoraDesarrollo", connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.Add(new SqlParameter("maquinaria_id", bitacora.maquinaria.id)); command.Parameters.Add(new SqlParameter("fecha_bitacora", Validations.defaultString(bitacora.fecha_bitacora.ToString()))); command.Parameters.Add(new SqlParameter("grupo", Validations.defaultString(bitacora.grupo))); command.Parameters.Add(new SqlParameter("turno", bitacora.turno)); command.Parameters.Add(new SqlParameter("compania_id", bitacora.compania.id)); command.Parameters.Add(new SqlParameter("vale_acero", Validations.defaultString(bitacora.vale_acero))); command.Parameters.Add(new SqlParameter("vale_explosivos", Validations.defaultString(bitacora.vale_explosivos))); command.Parameters.Add(new SqlParameter("subnivel_id", bitacora.subnivel.id)); command.Parameters.Add(new SqlParameter("zona", Validations.defaultString(bitacora.zona))); command.Parameters.Add(new SqlParameter("tipo_desarrollo_id", bitacora.tipo_desarrollo.id)); command.Parameters.Add(new SqlParameter("hora_primer_barreno", Validations.defaultString(bitacora.hora_primer_barreno.ToShortTimeString()))); command.Parameters.Add(new SqlParameter("hora_ultimo_barreno", Validations.defaultString(bitacora.hora_ultimo_barreno.ToShortTimeString()))); command.Parameters.Add(new SqlParameter("numero_barrenos", bitacora.numero_barrenos)); command.Parameters.Add(new SqlParameter("anclas", bitacora.anclas)); command.Parameters.Add(new SqlParameter("mallas", bitacora.mallas)); command.Parameters.Add(new SqlParameter("operador_id", bitacora.operador.id)); command.Parameters.Add(new SqlParameter("ayudante_id", bitacora.ayudante.id)); command.Parameters.Add(new SqlParameter("comentarios", Validations.defaultString(bitacora.comentarios))); command.Parameters.Add(new SqlParameter("status_edicion", bitacora.status_edicion)); command.Parameters.Add(new SqlParameter("dias_apertura_calendario", bitacora.dias_apertura_calendario)); command.Parameters.Add(new SqlParameter("user_id", bitacora.user.id)); SqlDataAdapter data_adapter = new SqlDataAdapter(command); DataSet data_set = new DataSet(); data_adapter.Fill(data_set); DataRow row = data_set.Tables[0].Rows[0]; return(int.Parse(row[0].ToString())); } catch (SqlException ex) { if (connection != null) { connection.Close(); } if (ex.Number == 2627) { return(0); } return(0); } catch { if (connection != null) { connection.Close(); } return(0); } } }