public object Buscarxnumeropedido(string id) { SqlConnection con = null; string cnx = db.Database.Connection.ConnectionString; string listar = ""; con = new SqlConnection(cnx); if (id == "") { listar = "select* from v_MantePlanilla where Saldo = 0"; } else { id = id.PadLeft(8, '0'); listar = "select* from v_MantePlanilla where Numero_Pedido ='" + id + "' and Saldo = 0"; } List <v_MantePlanilla> listper = new List <v_MantePlanilla>(); try { SqlCommand comando = new SqlCommand(listar, con); con.Open(); SqlDataReader reader = comando.ExecuteReader(); while (reader.Read()) { v_MantePlanilla per = new v_MantePlanilla(); per.Id_Planilla = Convert.ToInt32(reader[0].ToString()); per.Cod = reader[1].ToString(); per.DescripCorta = reader[9].ToString(); per.RazonSocial = reader[2].ToString(); per.Numero_Pedido = reader[3].ToString().PadLeft(8, '0'); per.Fecha = Convert.ToDateTime(reader[4]).ToString("dd-MM-yyyy"); per.Total = Convert.ToDecimal(reader[5].ToString()); per.Saldo = Convert.ToDecimal(reader[6].ToString()); listper.Add(per); } } catch (Exception ex) { throw ex; } finally { con.Close(); } return(listper); }
public object BuscarxZonaMercado(string zona, string mercado, string fi, string ff) { SqlConnection con = null; string cnx = db.Database.Connection.ConnectionString; con = new SqlConnection(cnx); string listar = "select* from v_MantePlanilla where Fecha between '" + fi + "'and'" + ff + "'and DescripCorta ='" + zona + "'and NombreCorto='" + mercado + "' and Saldo > 0"; List <v_MantePlanilla> listper = new List <v_MantePlanilla>(); try { SqlCommand comando = new SqlCommand(listar, con); con.Open(); SqlDataReader reader = comando.ExecuteReader(); while (reader.Read()) { v_MantePlanilla per = new v_MantePlanilla(); per.Id_Planilla = Convert.ToInt32(reader[0].ToString()); per.Cod = reader[1].ToString(); //remplaza a idcliente per.DescripCorta = reader[9].ToString(); per.RazonSocial = reader[2].ToString(); per.Numero_Pedido = reader[3].ToString().PadLeft(8, '0'); per.Fecha = Convert.ToDateTime(reader[4]).ToString("dd-MM-yyyy"); per.Total = Convert.ToDecimal(reader[5].ToString()); per.Saldo = Convert.ToDecimal(reader[6].ToString()); listper.Add(per); } } catch (Exception ex) { throw ex; } finally { con.Close(); } return(listper); }