public Incidente readOneIncidente(int idIncidente) { Incidente incidente = new Incidente(); using (SqlConnection con = new SqlConnection(Info.sqlSet())) { SqlCommand cmd = new SqlCommand("SP_Incidente_SelectRow", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@IdIncidente", idIncidente); con.Open(); using (SqlDataReader reader = cmd.ExecuteReader()) { // Loop through each record. while (reader.Read()) { Incidente tmp = new Incidente(); tmp.IdFalta = (reader.GetValue(0) != DBNull.Value) ? Convert.ToInt32(reader.GetValue(0)) : tmp.IdFalta; tmp.IdEmpleado = (reader.GetValue(1) != DBNull.Value) ? Convert.ToInt32(reader.GetValue(1)) : tmp.IdEmpleado; tmp.Tipo = (reader.GetValue(2) != DBNull.Value) ? Convert.ToString(reader.GetValue(2)) : tmp.Tipo; tmp.Fecha = (reader.GetValue(3) != DBNull.Value) ? Convert.ToDateTime(reader.GetValue(3)) : tmp.Fecha; incidente = tmp; } } con.Close(); } return incidente; }
public string Create(Incidente obj) { CreateDAC objDAC = new CreateDAC(); if (objDAC.CreateRecord(obj) == true) return "Registro almacenado con éxito."; else return "No se pudo almacenar el regitro."; }
public SingleIncidente(Incidente reg) { InitializeComponent(); incidente = reg; this.DataContext = incidente; btnActualizar.Visibility = Visibility.Visible; btnGuardar.Visibility = Visibility.Collapsed; }
public string Update(Incidente obj, int idIncidente) { UpdateDAC objDAC = new UpdateDAC(); if (objDAC.UpdateRecord(obj, idIncidente) == true) return "Registro almacenado con éxito."; else return "No se pudo almacenar el regitro."; }
public bool CreateRecord(Incidente obj) { SqlConnection con = new SqlConnection(Info.sqlSet()); SqlCommand cmd = new SqlCommand("SP_Incidente_Insert", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@IdEmpleado", obj.IdEmpleado); cmd.Parameters.AddWithValue("@Tipo", obj.Tipo); cmd.Parameters.AddWithValue("@Fecha", obj.Fecha); con.Open(); if (cmd.ExecuteNonQuery() > 0) { con.Close(); return true; } else { con.Close(); return false; } }
public List<Incidente> readIncidente() { List<Incidente> incidenteList = new List<Incidente>(); using (SqlConnection con = new SqlConnection(Info.sqlSet())) { SqlCommand cmd = new SqlCommand("SP_Incidente_SelectAll", con); cmd.CommandType = CommandType.StoredProcedure; con.Open(); using (SqlDataReader reader = cmd.ExecuteReader()) { // Loop through each record. while (reader.Read()) { Incidente tmp = new Incidente(); tmp.IdFalta = (reader.GetValue(0) != DBNull.Value) ? Convert.ToInt32(reader.GetValue(0)) : tmp.IdFalta; tmp.IdEmpleado = (reader.GetValue(1) != DBNull.Value) ? Convert.ToInt32(reader.GetValue(1)) : tmp.IdEmpleado; tmp.Tipo = (reader.GetValue(2) != DBNull.Value) ? Convert.ToString(reader.GetValue(2)) : tmp.Tipo; tmp.Fecha = (reader.GetValue(3) != DBNull.Value) ? Convert.ToDateTime(reader.GetValue(3)) : tmp.Fecha; incidenteList.Add(tmp); } } con.Close(); } return incidenteList; }