コード例 #1
0
 public bool obtenerRegistro(string pedido, DateTime d1, DateTime d2)
 {
     bool found = false;
     OleDbCommand comm = new OleDbCommand();
     ListaRegistros = new List<estRegistro>();
     estRegistro r;
     comm.Connection = connAccess;
     comm.CommandText = "SELECT tRegistrosPedidosPulsar.* , tUsuarios.nombre, tUsuarios.apellido "
                         + "FROM tRegistrosPedidosPulsar "
                         + "LEFT JOIN tUsuarios ON tUsuarios.id = tRegistrosPedidosPulsar.idUsuario "
                         + "WHERE (tRegistrosPedidosPulsar.PedidoPulsar='" + pedido + "' AND (tRegistrosPedidosPulsar.Fecha >= @D1 AND tRegistrosPedidosPulsar.Fecha <= @D2 ))"
                         + "ORDER BY tRegistrosPedidosPulsar.id ASC";
     comm.Parameters.AddWithValue("@D1", d1.Date);
     comm.Parameters.AddWithValue("@D2", d2.Date);
     string tempPallets = "";
     try
     {
         connAccess.Open();
         OleDbDataReader reader = comm.ExecuteReader();
         while (reader.Read())
         {
             r = new estRegistro();
             r.pallets = new List<string>();
             r.id = int.Parse(reader["id"].ToString());
             tempPallets = reader["PalletsTerminados"].ToString();
             foreach (string s in tempPallets.Split('|'))
                 r.pallets.Add(s);
             r.fechaReg = DateTime.Parse(reader["Fecha"].ToString());
             r.pedidoPulsar = reader["PedidoPulsar"].ToString();
             r.pedidoPMM = reader["PedidoPMM"].ToString();
             r.ordenCompra = reader["OrdenCompra"].ToString();
             r.usuario = reader["nombre"].ToString()+ " " + reader["apellido"].ToString();
             r.loteDespacho = reader["LoteDespacho"].ToString();
             r.lotes = reader["LotesProduccion"].ToString();
             r.pesosBrutos = reader["PesosBrutos"].ToString();
             r.pesosNetos = reader["PesosNetos"].ToString();
             r.taras = reader["Taras"].ToString();
             r.embarquePallet  = reader["EmbarquePallet"].ToString();
             r.cancelado = Convert.ToBoolean(reader["cancelado"].ToString());
             if (this.analizarSiCompleto(ref r))
                 r.estado = "COMPLETO";
             else
                 r.estado = "INCOMPLETO";
             this.ListaRegistros.Add(r);
             found = true;
         }
         connAccess.Close();
         reader.Dispose();
         return found;
     }
     catch (Exception ex)
     {
         if (connAccess.State == System.Data.ConnectionState.Open)
             connAccess.Close();
         MessageBox.Show(ex.Message);
         return false;
     }
 }
コード例 #2
0
ファイル: Registro.cs プロジェクト: GeMaths/etiquetasPMM
        public bool obtenerRegistro(string c, DateTime d1, DateTime d2)
        {
            if (c.Contains('\''))
                c = c.Replace("\'","''");
            bool found = false;
            OleDbCommand comm = new OleDbCommand();
            ListaRegistros = new List<estRegistro>();
            estRegistro r;
            comm.Connection = connAccess;
            comm.CommandText = "SELECT tRegistrosCajas.* , tUsuarios.nombre, tUsuarios.apellido "
                                + "FROM tRegistrosCajas "
                                + "LEFT JOIN tUsuarios ON tUsuarios.id = tRegistrosCajas.idUsuario "
                                + "WHERE (tRegistrosCajas.cliente='" + c + "' AND tRegistrosCajas.fechaEdicion BETWEEN @D1 AND @D2 ) ";
            comm.Parameters.AddWithValue("@D1", d1.Date);
            comm.Parameters.AddWithValue("@D2", d2.Date);
            try
            {
                connAccess.Open();
                OleDbDataReader reader = comm.ExecuteReader();
                while (reader.Read())
                {
                    r = new estRegistro();

                    r.id = int.Parse(reader["id"].ToString());
                    r.clave = reader["clave"].ToString();
                    r.fechaReg = DateTime.Parse(reader["fechaEdicion"].ToString());
                    if (string.IsNullOrEmpty(reader["fechaEntrega"].ToString()))
                        r.fechaEntrega = DateTime.Now;
                    else
                        r.fechaEntrega = DateTime.Parse(reader["fechaEntrega"].ToString());
                    r.pedidoPMM = reader["pedidoPMM"].ToString();
                    r.ordenCompra = reader["ordenCompra"].ToString();
                    r.usuario = reader["nombre"].ToString()+ " " + reader["apellido"].ToString();
                    r.material = reader["material"].ToString();
                    r.calibre = reader["calibre"].ToString();
                    r.color = reader["color"].ToString();
                    r.corte = reader["corte"].ToString();
                    r.cliente = reader["cliente"].ToString();
                    r.cantCajas = int.Parse(reader["NoCajas"].ToString());
                    r.loteDespacho = reader["loteDespacho"].ToString();
                    r.lotes = reader["lotes"].ToString();
                    r.pesosBrutos = reader["pesosBrutos"].ToString();
                    r.pesosNetos = reader["pesosNetos"].ToString();
                    r.unidades = reader["unidades"].ToString();
                    r.taras = reader["taras"].ToString();
                    r.editadoPor = reader["editadoPor"].ToString();
                    r.unidadesCorte = reader["UnidadesCorte"].ToString();
                    r.cancelado = Convert.ToBoolean(reader["cancelado"].ToString());
                    r.pedidoCompleto = Convert.ToBoolean(reader["PEDIDO_COMPLETO"].ToString());
                    this.ListaRegistros.Add(r);
                    found = true;
                }
                connAccess.Close();
                reader.Dispose();
                return found;
            }
            catch (Exception ex)
            {
                if (connAccess.State == System.Data.ConnectionState.Open)
                    connAccess.Close();
                MessageBox.Show(ex.Message);
                return false;
            }
        }
コード例 #3
0
 public bool analizarSiCompleto(ref estRegistro r)
 {
     OleDbCommand comm = new OleDbCommand();
     comm.Connection = connAccess;
     comm.CommandText = "SELECT cantidadPallets FROM tInfoPedidosPulsar WHERE pedidoPulsar='"+r.pedidoPulsar+"'";
     int cantidadDebidaParaTotal = 0;
     try
     {
         OleDbDataReader reader = comm.ExecuteReader();
         while (reader.Read())
         {
             cantidadDebidaParaTotal = int.Parse(reader["cantidadPallets"].ToString());
         }
     }
     catch (Exception ex)
     {
         if (connAccess.State == System.Data.ConnectionState.Open)
             connAccess.Close();
         MessageBox.Show(ex.Message);
         return false;
     }
     if (r.pallets.Count == cantidadDebidaParaTotal)
         return true;
     else
         return false;
 }