private void txtticket_KeyUp(object sender, KeyEventArgs e) { try { if (e.Key == Key.Enter) { if (txtticket.Text.Trim().Equals("11101")) { txtoperario.Clear(); txtticket.Clear(); txtoperario.Focus(); return; } if (comboBihorario.SelectedValue.ToString() == "0" || comboLinea.SelectedValue.ToString() == "0" || idemp == 0) { lblEstadoTicket.Content = "Debe Seleccionar Linea, Bihorario ó Asignar Operario"; txtticket.Clear(); txtticket.Focus(); return; } Limpiar(); var cadena = txtticket.Text.Trim();// txtticket.Text.Substring(txtticket.Text); var chart = cadena.Substring(0, 1); var serial = chart == "0" ? cadena.Substring(1, cadena.Length - 1) : cadena; var sql = " select s.prodno,s.serialno,o.operno,s.bundleno,o.descr,o.ctdescr,linenumber,plant,b.qty" + " from serial2 s inner join oper o on s.operno = o.operno " + " inner join prod p on s.prodno = p.prodno" + " inner join bundle b on b.prodno = p.prodno" + " where s.serialno = '" + serial + "' and b.bundleno = s.bundleno"; lblTicketLeido.Content = serial; var lista = new List <Pervasives>(); var dt = Pervasive_PSQL.GetDataTable(sql); if (dt.Rows.Count == 0) { txtticket.Text = string.Empty; txtticket.Focus(); lblEstadoTicket.Content = "El codigo no existe, Advertencia"; } else { foreach (DataRow item in dt.Rows) { var obj = new Pervasives { Prodno = item.ItemArray[0].ToString(), Serialno = item.ItemArray[1].ToString(), Operno = item.ItemArray[2].ToString(), Bundleno = Convert.ToInt16(item.ItemArray[3].ToString()), Descr = item.ItemArray[4].ToString(), Ctdescr = item.ItemArray[5].ToString(), BundleUni = Convert.ToInt32(item.ItemArray[8].ToString()) }; lista.Add(obj); } if (lista.Count > 0) { lblCorte.Content = lista[0].Prodno; lblBulto.Content = lista[0].Bundleno.ToString(); lblEstilo.Content = lista[0].Serialno; lbloperacion.Content = lista[0].Descr; lblUnidades.Content = lista[0].BundleUni; using (AuditoriaEntities contex = new AuditoriaEntities()) { var serial2 = dt.Rows[0][1].ToString().TrimEnd(); var band = contex.tbProduccionTickets.Where(x => x.serial.Equals(serial2)).FirstOrDefault(); if (band == null) { var newobjS = new tbProduccionTickets() { serial = serial2, // dt.Rows[0][1].ToString(), codigoOperacion = dt.Rows[0][5].ToString(), descOperacion = dt.Rows[0][4].ToString(), corte = dt.Rows[0][0].ToString(), nSeq = Convert.ToInt16(dt.Rows[0][3].ToString()), linea = dt.Rows[0][6].ToString(), fechaRegistro = DateTime.Now, usuario = emp, operarioId = idemp, BundleUni = Convert.ToInt32(dt.Rows[0][8].ToString()), bihorario = Convert.ToInt16(comboBihorario.SelectedValue.ToString()), lineaConfeccion = Convert.ToInt16(comboLinea.SelectedValue.ToString()) }; contex.tbProduccionTickets.Add(newobjS); contex.SaveChanges(); txtticket.Text = string.Empty; txtticket.Focus(); lblEstadoTicket.Content = "Agregado Correctamente"; // MensajeVoz("Lectura Exitosa"); } else { txtticket.Text = string.Empty; txtticket.Focus(); lblEstadoTicket.Content = "Lectura Duplicada"; // MensajeVoz("Lectura Duplicada"); } var listadb = contex.spdProduccionOperarioDiario(idemp).ToList(); lbltotal.Content = listadb.Count.ToString(); lbltotalBihorario.Content = comboBihorario.SelectedValue.ToString() == "0" ? listadb.Where(x => x.bihorario == listadb.Max(z => z.bihorario)).Count().ToString() : listadb.Where(x => x.bihorario == Convert.ToInt16(comboBihorario.SelectedValue.ToString())).Count().ToString(); gridCodigos.ItemsSource = listadb; } } else { txtticket.Text = string.Empty; txtticket.Focus(); lblEstadoTicket.Content = "El codigo no existe, Advertencia"; } } } } catch (Exception ex) { lblEstadoTicket.Content = ex.Message; txtticket.Text = string.Empty; txtticket.Focus(); // MensajeVoz(ex.Message); } }
private void txtoperario_KeyUp(object sender, KeyEventArgs e) { try { if (e.Key == Key.Enter) { limpiarOper(); var operario = txtoperario.Text.Trim().ToLower(); var sql = "select top 1 empno,estatus,module,lastname,firstname,badgeno,loc1,loc2 from employee where badgeno = '" + operario + "'"; var dt = Pervasive_PSQL.GetDataTable(sql); if (dt.Rows.Count == 0) { txtoperario.Text = string.Empty; txtoperario.Focus(); lblEstadoTicket.Content = "El operario " + operario + " no existe"; //MensajeVoz("El operario no existe!!!"); //MessageBox.Show("El operario no existe", "Advertencia"); } else { var nombre = string.Concat(dt.Rows[0][4], " ", dt.Rows[0][3]).ToUpper().TrimEnd(); lblNombre.Content = nombre;//string.Concat(dt.Rows[0][4], " ", dt.Rows[0][3]); lblCod.Content = dt.Rows[0][0].ToString(); lblModulo.Content = dt.Rows[0][6].ToString(); lblLinea.Content = dt.Rows[0][7].ToString(); txtoperario.Text = string.Empty; txtticket.Focus(); lblEstadoTicket.Content = "Lectura Exitosa!!!"; // MensajeVoz("Lectura Exitosa!"); using (AuditoriaEntities contex = new AuditoriaEntities()) { var codigobarra = dt.Rows[0][5].ToString().TrimEnd(); var obj = contex.Operario.Where(x => x.codigoBarra.ToUpper().Equals(codigobarra)).FirstOrDefault(); if (obj == null) { var objnew = new Operario { nombre = nombre, codigo = dt.Rows[0][0].ToString(), codigoBarra = dt.Rows[0][5].ToString(), activo = true }; contex.Operario.Add(objnew); contex.SaveChanges(); idemp = objnew.id_operario; } else { obj.codigoBarra = dt.Rows[0][5].ToString(); obj.codigo = dt.Rows[0][0].ToString(); idemp = obj.id_operario; } contex.SaveChanges(); var listadb = contex.spdProduccionOperarioDiario(idemp).ToList(); lbltotal.Content = listadb.Count.ToString(); lbltotalBihorario.Content = comboBihorario.SelectedValue.ToString() == "0" ? listadb.Where(x => x.bihorario == listadb.Max(z => z.bihorario)).Count().ToString() : listadb.Where(x => x.bihorario == Convert.ToInt16(comboBihorario.SelectedValue.ToString())).Count().ToString(); gridCodigos.ItemsSource = listadb; } } } } catch (Exception ex) { lblEstadoTicket.Content = ex.Message; /// MensajeVoz(ex.Message); } }