private void AlertaHoraxHora() { LineaHoraLogica lin = new LineaHoraLogica(); lin.Linea = Globals._gsLineHr; if (!LineaHoraLogica.AlertaCapturaHora(lin)) { FormCollection fc = Application.OpenForms; try { bool bForm = false; foreach (Form frm in fc) { if (frm.Name == "wfLineAlert") { bForm = true; } } if (!bForm) { wfLineAlert wfAlerta = new wfLineAlert(); wfAlerta.ShowDialog(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } }
private void Inicio() { //load data try { _lsProceso = "PRO020"; dgwLine.DataSource = null; CargarColumnas(); //1. find last folio from date //1.1 Load data from folio //1.2 Cursor on next hour row lblFecha.Text = DateTime.Today.ToShortDateString(); if (!string.IsNullOrEmpty(Globals._gsStation)) { LineaRampeoLogica lineR = new LineaRampeoLogica(); lineR.Estacion = Globals._gsStation; DataTable dtLR = LineaRampeoLogica.ConsultarEstacion(lineR); if (dtLR.Rows.Count > 0) { Globals._gsCompany = dtLR.Rows[0]["company"].ToString(); Globals._gsLineHr = dtLR.Rows[0]["linehr"].ToString(); } } lblLine.Text = Globals._gsLineHr; tssLine.Text = Globals._gsLineHr; LineaHoraLogica line = new LineaHoraLogica(); line.Linea = Globals._gsLineHr; DataTable data = LineaHoraLogica.ConsultarActual(line); if (data.Rows.Count > 0) { _llFolio = long.Parse(data.Rows[0]["folio"].ToString()); _ldMeta = decimal.Parse(data.Rows[0]["meta"].ToString()); _ldActualAc = decimal.Parse(data.Rows[0]["cant_total"].ToString()); _ldDefectosAc = decimal.Parse(data.Rows[0]["defectos"].ToString()); lblMeta.Text = _ldMeta.ToString(); lblActual.Text = _ldActualAc.ToString(); lblDefectos.Text = _ldDefectosAc.ToString(); //horario LineaHoraDetLogica lined = new LineaHoraDetLogica(); lined.Folio = _llFolio; DataTable dtH = LineaHoraDetLogica.VistaHorario(lined); dgwLine.DataSource = dtH; if (_ldActualAc > 0 && _ldActualAc < _ldMeta) { pnlActual.BackColor = Color.Red; lblActual.ForeColor = Color.White; } else { pnlActual.BackColor = Color.Green; lblActual.ForeColor = Color.DarkBlue; } } else { LineaConfigLogica con = new LineaConfigLogica(); con.Linea = Globals._gsLineHr; //2. Load line data //2.1 Load line setup DataTable confL = LineaConfigLogica.ConsultarConfLinea(con); if (confL.Rows.Count > 0) { con.Clave = confL.Rows[0]["clave"].ToString(); lblMeta.Text = confL.Rows[0]["meta"].ToString(); lblActual.Text = string.Empty; lblDefectos.Text = string.Empty; DataTable dataC = LineaConfigLogica.VistaHorarioLinea(con); dgwLine.DataSource = dataC; CargarColumnas(); } } if (dgwLine.Rows.Count > 0) { foreach (DataGridViewRow row in dgwLine.Rows) { string sOrden = row.Cells[7].Value.ToString(); if (!string.IsNullOrEmpty(sOrden) && !string.IsNullOrWhiteSpace(sOrden)) { int iWO = 0; if (!int.TryParse(sOrden, out iWO)) { iWO = 0; } if (iWO > 0) { lblOrden.Text = sOrden; } } string sActual = row.Cells[4].Value.ToString(); if (string.IsNullOrEmpty(sActual) || string.IsNullOrWhiteSpace(sActual) || sActual == "0") { dgwLine.CurrentCell = dgwLine[4, row.Index]; dgwLine.Focus(); break; } } } else { MessageBox.Show("La linea no se encuentra configurada en los parámetros del sistema.", Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); Close(); return; } if (!string.IsNullOrEmpty(_lsOrden)) { lblOrden.Text = _lsOrden; CargaWO(); } } catch (Exception ex) { MessageBox.Show("Error " + ex.ToString(), Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
private void btnSave_Click(object sender, EventArgs e) { try { if (!Valida()) { return; } if (!ValidaHoraCaptura()) { return; } LineaHoraLogica line = new LineaHoraLogica(); if (_llFolio > 0) { line.Folio = _llFolio; } else { line.Folio = AccesoDatos.Consec(_lsProceso); } line.Linea = lblLine.Text.ToString(); line.Fecha = DateTime.Parse(lblFecha.Text.ToString()); line.Turno = "1";//AccesoDatos.Turno(); line.Meta = int.Parse(lblMeta.Text.ToString()); line.Real = int.Parse(lblActual.Text.ToString()); int iDef = 0; if (!int.TryParse(lblDefectos.Text, out iDef)) { iDef = 0; } line.Defectos = iDef; line.Usuario = Globals._gsStation; if (LineaHoraLogica.GuardarSP(line) > 0) { LineaHoraDetLogica det = new LineaHoraDetLogica(); det.Folio = line.Folio; foreach (DataGridViewRow row in dgwLine.Rows) { int iCons = 0; if (!string.IsNullOrEmpty(row.Cells[0].Value.ToString())) { iCons = int.Parse(row.Cells[0].Value.ToString()); } string sHora = row.Cells[1].Value.ToString(); int iMeta = int.Parse(row.Cells[2].Value.ToString()); int iMetaAc = int.Parse(row.Cells[3].Value.ToString()); int iActual = int.Parse(row.Cells[4].Value.ToString()); int iActualAc = int.Parse(row.Cells[5].Value.ToString()); string sCumple = row.Cells[9].Value.ToString(); int iDefectos = 0; if (!int.TryParse(row.Cells[6].Value.ToString(), out iDefectos)) { iDefectos = 0; } string sOrden = row.Cells[7].Value.ToString(); string sNota = row.Cells[8].Value.ToString(); det.Consec = iCons; det.Hora = sHora; det.Meta = iMeta; det.MetaAc = iMetaAc; det.Actual = iActual; det.ActualAc = iActualAc; det.Defectos = iDefectos; det.Orden = sOrden; det.Nota = sNota; det.Cumple = sCumple; LineaHoraDetLogica.GuardarSP(det); } MessageBox.Show("Hora por Hora se ha registrado exitosamente", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); Close(); } } catch (Exception ex) { MessageBox.Show("Error " + ex.ToString(), Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }