public List<Pagos> readPagos() { List<Pagos> pagosList = new List<Pagos>(); using (SqlConnection con = new SqlConnection(Info.sqlSet())) { SqlCommand cmd = new SqlCommand("SP_Pagos_SelectAll", con); cmd.CommandType = CommandType.StoredProcedure; con.Open(); using (SqlDataReader reader = cmd.ExecuteReader()) { // Loop through each record. while (reader.Read()) { Pagos tmp = new Pagos(); tmp.IdPago = (reader.GetValue(0) != DBNull.Value) ? Convert.ToInt32(reader.GetValue(0)) : tmp.IdPago; tmp.IdEmpleado = (reader.GetValue(1) != DBNull.Value) ? Convert.ToInt32(reader.GetValue(1)) : tmp.IdEmpleado; tmp.Monto = (reader.GetValue(2) != DBNull.Value) ? Convert.ToSingle(reader.GetValue(2)) : tmp.Monto; tmp.Fecha = (reader.GetValue(3) != DBNull.Value) ? Convert.ToDateTime(reader.GetValue(3)) : tmp.Fecha; pagosList.Add(tmp); } } con.Close(); } return pagosList; }
public Pagos readOnePagos(int idPagos) { Pagos pagos = new Pagos(); using (SqlConnection con = new SqlConnection(Info.sqlSet())) { SqlCommand cmd = new SqlCommand("SP_Pagos_SelectRow", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@IdPagos", idPagos); con.Open(); using (SqlDataReader reader = cmd.ExecuteReader()) { // Loop through each record. while (reader.Read()) { Pagos tmp = new Pagos(); tmp.IdPago = (reader.GetValue(0) != DBNull.Value) ? Convert.ToInt32(reader.GetValue(0)) : tmp.IdPago; tmp.IdEmpleado = (reader.GetValue(1) != DBNull.Value) ? Convert.ToInt32(reader.GetValue(1)) : tmp.IdEmpleado; tmp.Monto = (reader.GetValue(2) != DBNull.Value) ? Convert.ToSingle(reader.GetValue(2)) : tmp.Monto; tmp.Fecha = (reader.GetValue(3) != DBNull.Value) ? Convert.ToDateTime(reader.GetValue(3)) : tmp.Fecha; pagos = tmp; } } con.Close(); } return pagos; }
public string Create(Pagos obj) { CreateDAC objDAC = new CreateDAC(); if (objDAC.CreateRecord(obj) == true) return "Registro almacenado con éxito."; else return "No se pudo almacenar el regitro."; }
public SinglePagos(Pagos reg) { InitializeComponent(); pagos = reg; this.DataContext = pagos; btnActualizar.Visibility = Visibility.Visible; btnGuardar.Visibility = Visibility.Collapsed; }
public string Update(Pagos obj, int idPagos) { UpdateDAC objDAC = new UpdateDAC(); if (objDAC.UpdateRecord(obj, idPagos) == true) return "Registro almacenado con éxito."; else return "No se pudo almacenar el regitro."; }
public bool CreateRecord(Pagos obj) { SqlConnection con = new SqlConnection(Info.sqlSet()); SqlCommand cmd = new SqlCommand("SP_Pagos_Insert", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@IdEmpleado", obj.IdEmpleado); cmd.Parameters.AddWithValue("@Monto", obj.Monto); cmd.Parameters.AddWithValue("@Fecha", obj.Fecha); con.Open(); if (cmd.ExecuteNonQuery() > 0) { con.Close(); return true; } else { con.Close(); return false; } }