public string Create(Entrada 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(Entrada obj, int idEntrada) { UpdateDAC objDAC = new UpdateDAC(); if (objDAC.UpdateRecord(obj, idEntrada) == true) return "Registro almacenado con éxito."; else return "No se pudo almacenar el regitro."; }
public bool CreateRecord(Entrada obj) { SqlConnection con = new SqlConnection(Info.sqlSet()); SqlCommand cmd = new SqlCommand("SP_Entrada_Insert", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@IdFactura", obj.IdFactura); cmd.Parameters.AddWithValue("@IdArticulo", obj.IdArticulo); cmd.Parameters.AddWithValue("@Cantidad", obj.Cantidad); con.Open(); if (cmd.ExecuteNonQuery() > 0) { con.Close(); return true; } else { con.Close(); return false; } }
public Entrada readOneEntrada(int idEntrada) { Entrada entrada = new Entrada(); using (SqlConnection con = new SqlConnection(Info.sqlSet())) { SqlCommand cmd = new SqlCommand("SP_Entrada_SelectRow", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@IdEntrada", idEntrada); con.Open(); using (SqlDataReader reader = cmd.ExecuteReader()) { // Loop through each record. while (reader.Read()) { Entrada tmp = new Entrada(); tmp.IdEntrada = (reader.GetValue(0) != DBNull.Value) ? Convert.ToInt32(reader.GetValue(0)) : tmp.IdEntrada; tmp.IdFactura = (reader.GetValue(1) != DBNull.Value) ? Convert.ToInt32(reader.GetValue(1)) : tmp.IdFactura; tmp.IdArticulo = (reader.GetValue(2) != DBNull.Value) ? Convert.ToInt32(reader.GetValue(2)) : tmp.IdArticulo; tmp.Cantidad = (reader.GetValue(3) != DBNull.Value) ? Convert.ToInt32(reader.GetValue(3)) : tmp.Cantidad; entrada = tmp; } } con.Close(); } return entrada; }
public List<Entrada> readCustomEntrada(string query) { List<Entrada> entradaList = new List<Entrada>(); using (SqlConnection con = new SqlConnection(Info.sqlSet())) { SqlCommand com = new SqlCommand(query, con); con.Open(); using (SqlDataReader reader = com.ExecuteReader()) { // Loop through each record. while (reader.Read()) { Entrada tmp = new Entrada(); tmp.IdEntrada = (reader.GetValue(0) != DBNull.Value) ? Convert.ToInt32(reader.GetValue(0)) : tmp.IdEntrada; tmp.IdFactura = (reader.GetValue(1) != DBNull.Value) ? Convert.ToInt32(reader.GetValue(1)) : tmp.IdFactura; tmp.IdArticulo = (reader.GetValue(2) != DBNull.Value) ? Convert.ToInt32(reader.GetValue(2)) : tmp.IdArticulo; tmp.Cantidad = (reader.GetValue(3) != DBNull.Value) ? Convert.ToInt32(reader.GetValue(3)) : tmp.Cantidad; entradaList.Add(tmp); } } con.Close(); } return entradaList; }
public List<Entrada> readEntrada() { List<Entrada> entradaList = new List<Entrada>(); using (SqlConnection con = new SqlConnection(Info.sqlSet())) { SqlCommand cmd = new SqlCommand("SP_Entrada_SelectAll", con); cmd.CommandType = CommandType.StoredProcedure; con.Open(); using (SqlDataReader reader = cmd.ExecuteReader()) { // Loop through each record. while (reader.Read()) { Entrada tmp = new Entrada(); tmp.IdEntrada = (reader.GetValue(0) != DBNull.Value) ? Convert.ToInt32(reader.GetValue(0)) : tmp.IdEntrada; tmp.IdFactura = (reader.GetValue(1) != DBNull.Value) ? Convert.ToInt32(reader.GetValue(1)) : tmp.IdFactura; tmp.IdArticulo = (reader.GetValue(2) != DBNull.Value) ? Convert.ToInt32(reader.GetValue(2)) : tmp.IdArticulo; tmp.Cantidad = (reader.GetValue(3) != DBNull.Value) ? Convert.ToInt32(reader.GetValue(3)) : tmp.Cantidad; entradaList.Add(tmp); } } con.Close(); } return entradaList; }