public string Create(Salida obj) { CreateDAC objDAC = new CreateDAC(); if (objDAC.CreateRecord(obj) == true) return "Registro almacenado con éxito."; else return "No se pudo almacenar el regitro."; }
public string Update(Salida obj, int idSalida) { UpdateDAC objDAC = new UpdateDAC(); if (objDAC.UpdateRecord(obj, idSalida) == true) return "Registro almacenado con éxito."; else return "No se pudo almacenar el regitro."; }
public Salidas(Salida reg) { InitializeComponent(); salida = reg; this.DataContext = salida; btnActualizar.Visibility = Visibility.Visible; btnGuardar.Visibility = Visibility.Collapsed; }
public bool CreateRecord(Salida obj) { SqlConnection con = new SqlConnection(Info.sqlSet()); SqlCommand cmd = new SqlCommand("SP_Salida_Insert", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@IdEmpleado", obj.IdEmpleado); cmd.Parameters.AddWithValue("@Nota", obj.Nota); cmd.Parameters.AddWithValue("@Fecha", obj.Fecha); con.Open(); if (cmd.ExecuteNonQuery() > 0) { con.Close(); return true; } else { con.Close(); return false; } }
public Salida readOneSalida(int idSalida) { Salida salida = new Salida(); using (SqlConnection con = new SqlConnection(Info.sqlSet())) { SqlCommand cmd = new SqlCommand("SP_Salida_SelectRow", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@IdSalida", idSalida); con.Open(); using (SqlDataReader reader = cmd.ExecuteReader()) { // Loop through each record. while (reader.Read()) { Salida tmp = new Salida(); tmp.IdSalida = (reader.GetValue(0) != DBNull.Value) ? Convert.ToInt32(reader.GetValue(0)) : tmp.IdSalida; tmp.IdEmpleado = (reader.GetValue(1) != DBNull.Value) ? Convert.ToInt32(reader.GetValue(1)) : tmp.IdEmpleado; tmp.Nota = (reader.GetValue(2) != DBNull.Value) ? Convert.ToString(reader.GetValue(2)) : tmp.Nota; tmp.Fecha = (reader.GetValue(3) != DBNull.Value) ? Convert.ToDateTime(reader.GetValue(3)) : tmp.Fecha; salida = tmp; } } con.Close(); } return salida; }
public List<Salida> readSalida() { List<Salida> salidaList = new List<Salida>(); using (SqlConnection con = new SqlConnection(Info.sqlSet())) { SqlCommand cmd = new SqlCommand("SELECT IdSalida, IdEmpleado, Nota, Fecha, (SELECT Nombre+ ' ' + ApellidoPaterno + ' ' + ApellidoMaterno FROM Empleado Where IdEmpleado = Salida.IdEmpleado) AS Nombre FROM Salida ", con); //cmd.CommandType = CommandType.StoredProcedure; con.Open(); using (SqlDataReader reader = cmd.ExecuteReader()) { // Loop through each record. while (reader.Read()) { Salida tmp = new Salida(); tmp.IdSalida = (reader.GetValue(0) != DBNull.Value) ? Convert.ToInt32(reader.GetValue(0)) : tmp.IdSalida; tmp.IdEmpleado = (reader.GetValue(1) != DBNull.Value) ? Convert.ToInt32(reader.GetValue(1)) : tmp.IdEmpleado; tmp.Nota = (reader.GetValue(2) != DBNull.Value) ? Convert.ToString(reader.GetValue(2)) : tmp.Nota; tmp.Fecha = (reader.GetValue(3) != DBNull.Value) ? Convert.ToDateTime(reader.GetValue(3)) : tmp.Fecha; tmp.Nombre = (reader.GetValue(4) != DBNull.Value) ? Convert.ToString(reader.GetValue(4)) : tmp.Nombre; salidaList.Add(tmp); } } con.Close(); } return salidaList; }