public Decimal calculaRacks(string codigo, int tipoRack, Decimal pedido)//PASARLE EL CODIGO, TIPO DE RACK Y LA CANTIDAD { Decimal cantidad = 0; Decimal res = 0; cMetodos cm = new cMetodos(); string[] parametros = cm.getParametros("Solutia"); SqlConnection conn = new SqlConnection("Data Source=" + parametros[1] + "; Initial Catalog=" + parametros[4] + "; Persist Security Info=True; User ID=" + parametros[2] + "; Password="******""); //primero se obtiene la cantidad de producto por ventana try { conn.Open(); string select = "Select PxT from catArt where Clave = '" + codigo + "'";//FT estaba PxT SqlCommand cmd = new SqlCommand(select, conn); SqlDataReader reader = cmd.ExecuteReader(); if (reader.Read()) { cantidad = Decimal.Parse(reader.GetString(0)); conn.Close(); } } catch (Exception e) { conn.Close(); string error = e.Message; //using (StreamWriter writer = new StreamWriter("C:\\Users\\Desarrollo1\\Desktop\\debug.txt", true)){writer.WriteLine("Error: "+ error+"| Hora: "+DateTime.Now+"");} } if (cantidad == 0) { return(res); } else { /* Se busca numero de tabla por rack*/ conn.Open(); String sSqlStr = ""; int nTablas = 0; sSqlStr = "Select RutaNivel from RProduccion where idRack = " + tipoRack; // SE busca el numero por tabla de producción segun el tipo de maquina-Rack (Basser1,2,3 o Compactas) SqlCommand cmd = new SqlCommand(sSqlStr, conn); SqlDataReader reader = cmd.ExecuteReader(); if (reader.Read()) { nTablas = Convert.ToInt16(reader.GetString(0)); conn.Close(); } // Se calcula: // Cantidad = pedido / (Piezas por tabla X nTablas) // cantidad = pedido / (nTablas * cantidad); //cantidad = Decimal.Ceiling(cantidad);//redondear res = Convert.ToInt32(cantidad); } return(res); }
static void Main(string[] args) { cMetodos tarea = new cMetodos(); tarea.Oracion(); Console.WriteLine("Cuantos numeros desea Ordenar -> \r"); int cantidad = int.Parse(Console.ReadLine()); int suma = tarea.CargaValores(cantidad); int iteraciones = tarea.SumaCantidad(suma); tarea.Ordena(iteraciones, cantidad); Console.ReadKey(); }
private void menuItem2_Click(object sender, EventArgs e) { string msj = ""; /*foreach (cMetodos.Producto producto in listaEPCS) { * if (!producto.tarimaParcial) { * todasParciales = false; * break; * } * }*/ //if (txtUbicacion.Text.Length > 0 || todasParciales == true) { //string nuevaUbicacion = txtUbicacion.Text; if (listaEPCS.Count > 0) { Cursor.Current = Cursors.WaitCursor; int cantidad = 0; cMetodos ws = new cMetodos(); foreach (cMetodos.Producto prod in listaEPCS) { cantidad += prod.cantidad; } // Enviar email a encargado de Producción en Napresa string planta = ordenProduccion.Substring(0, 2); cMetodos metodos = new cMetodos(); string[] emails = metodos.emailsProcesoStock(planta); int cont = 0; if (emails != null) { for (int i = 0; i < emails.Length; i++) { if (enviarMail(emails[i], cantidad.ToString()) != null) { cont++; } } if (cont == 0) { MessageBox.Show("Error en el WebService al enviar emails. Intentelo de nuevo más tarde."); Cursor.Current = Cursors.Default; this.Dispose(); return; } } else { if (enviarMail(cMetodos.EMAIL_TO_DEFAULT, cantidad.ToString()) == null) { MessageBox.Show("Error en el WebService al enviar emails. Intentelo de nuevo más tarde."); Cursor.Current = Cursors.Default; this.Dispose(); return; } cont++; } // Modificar datos en BD foreach (cMetodos.Producto prod in listaEPCS) { ws.sendToStock(descripcionProd, ordenProduccion, prod.cantidad, prod.cantidadTotal); ws.escuadrasToStock(prod.epc, "A01", prod.tarimaParcial, prod.cantidad, descripcionProd); /*if (prod.tarimaParcial) { * ws.crearEscuadraVirtual(descripcionProd, prod.cantidad); * }*/ } ws = null; msj = "Se han enviado " + cont + " correos de notificación a los encargados correspondientes de la planta."; this.Dispose(); } else { msj = "Debes hacer el proceso de selección de tarimas antes de poder reubicar."; cbProdBusq.Focus(); } /*} else { * msj = "Ingresa la nueva ubicación."; * txtUbicacion.Focus(); * }*/ Cursor.Current = Cursors.Default; MessageBox.Show(msj); }