private void cbbClave_SelectedIndexChanged(object sender, EventArgs e) { if (cbbClave.SelectedIndex == -1) { return; } dgwHrs.DataSource = null; dgwLineas.DataSource = null; string sCve = cbbClave.SelectedValue.ToString(); LineaConfigLogica con = new LineaConfigLogica(); con.Clave = sCve; DataTable data = LineaConfigLogica.ConsultarClave(con); if (data.Rows.Count > 0) { txtDescrip.Text = data.Rows[0]["descrip"].ToString(); lblMeta.Text = data.Rows[0]["meta"].ToString(); cbbMetaum.SelectedValue = data.Rows[0]["meta_um"].ToString(); cbbTurno.SelectedValue = data.Rows[0]["turno"].ToString(); DataTable dtH = LineaConfigLogica.ConsultarVistaHorario(con); dgwHrs.DataSource = dtH; DataTable dtL = LineaConfigLogica.VistaClaveLine(con); dgwLineas.DataSource = dtL; CargarColumnasHr(); } }
// hora por hora private void cbbClave_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Escape) { Close(); } if (e.KeyCode != Keys.Enter) { return; } try { if (!string.IsNullOrEmpty(cbbClave.Text) && !string.IsNullOrWhiteSpace(cbbClave.Text)) { string sCodigo = cbbClave.Text.ToUpper().ToString(); LineaConfigLogica con = new LineaConfigLogica(); con.Clave = sCodigo; DataTable datos = LineaConfigLogica.ConsultarClave(con); if (datos.Rows.Count != 0) { txtDescrip.Text = datos.Rows[0]["descrip"].ToString(); lblMeta.Text = datos.Rows[0]["meta"].ToString(); cbbMetaum.SelectedValue = datos.Rows[0]["meta_um"].ToString(); cbbTurno.SelectedValue = datos.Rows[0]["turno"].ToString(); DataTable dtH = LineaConfigLogica.ConsultarVistaHorario(con); dgwHrs.DataSource = dtH; DataTable dtL = LineaConfigLogica.VistaClaveLine(con); dgwLineas.DataSource = dtL; CargarColumnasHr(); } else { // nuevo codigo InicioHr(); cbbClave.Text = sCodigo; } } } catch (Exception ex) { MessageBox.Show("Favor de notificar al Administrador." + Environment.NewLine + ex.ToString(), Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } }
private void cbbTurno_SelectedIndexChanged(object sender, EventArgs e) { if (cbbTurno.SelectedIndex == -1 || cbbClave.SelectedIndex != -1) { return; } string sTurno = cbbTurno.SelectedValue.ToString(); LineaConfigLogica con = new LineaConfigLogica(); con.Turno = sTurno; DataTable dt = LineaConfigLogica.VistaTurnoHr(con); dgwHrs.DataSource = dt; dgwHrs.CurrentCell = dgwHrs[2, 0]; dgwHrs.Focus(); CargarColumnasHr(); }
private void Inicio() { //load data try { _lsUsuario = System.Security.Principal.WindowsIdentity.GetCurrent().Name; _lsUsuario = _lsUsuario.Substring(_lsUsuario.IndexOf("\\") + 1).ToUpper(); cbxLang.SelectedIndex = 0; txtJornada.Clear(); txtHrDisp.Clear(); txtHori.Clear(); txtSegDisp.Clear(); txtCajas.Clear(); txtKitCaja.Clear(); txtKits.Clear(); txtTack.Clear(); txtTack80.Clear(); txtAssyTime.Clear(); txtMaxComp.Clear(); txtMesas.Clear(); txtMesaWrap.Clear(); txtMesaSub.Clear(); txtOperNA.Clear(); txtSurtidor.Clear(); txtInspSella.Clear(); txtSellador.Clear(); txtInspec.Clear(); txtVertical.Clear(); txtSobre.Clear(); txtHori.Clear(); txtNA.Clear(); txtTape.Clear(); txtDetroit.Clear(); txtMaxHC.Clear(); txtMinHC.Clear(); txtOutAdd.Clear(); chbBoxHr.Checked = false; chbCycleTimer.Checked = false; chbActive.Checked = false; ConfigLogica con = new ConfigLogica(); con.CN = Globals._gsCompany; DataTable data = ConfigLogica.Consultar(con); if (data.Rows.Count > 0) { if (!string.IsNullOrEmpty(data.Rows[0][1].ToString())) { txtJornada.Text = data.Rows[0][1].ToString(); } if (!string.IsNullOrEmpty(data.Rows[0][2].ToString())) { txtHrDisp.Text = data.Rows[0][2].ToString(); } if (!string.IsNullOrEmpty(data.Rows[0][3].ToString())) { txtSegDisp.Text = data.Rows[0][3].ToString(); } if (!string.IsNullOrEmpty(data.Rows[0][4].ToString())) { txtCajas.Text = data.Rows[0][4].ToString(); } if (!string.IsNullOrEmpty(data.Rows[0][5].ToString())) { txtKitCaja.Text = data.Rows[0][5].ToString(); } if (!string.IsNullOrEmpty(data.Rows[0][6].ToString())) { txtKits.Text = data.Rows[0][6].ToString(); } if (!string.IsNullOrEmpty(data.Rows[0][7].ToString())) { txtTack.Text = data.Rows[0][7].ToString(); } if (!string.IsNullOrEmpty(data.Rows[0][8].ToString())) { txtTack80.Text = data.Rows[0][8].ToString(); } if (!string.IsNullOrEmpty(data.Rows[0][9].ToString())) { txtAssyTime.Text = data.Rows[0][9].ToString(); } if (!string.IsNullOrEmpty(data.Rows[0][10].ToString())) { txtMaxComp.Text = data.Rows[0][10].ToString(); } if (!string.IsNullOrEmpty(data.Rows[0][11].ToString())) { txtMesas.Text = data.Rows[0][11].ToString(); } if (!string.IsNullOrEmpty(data.Rows[0][12].ToString())) { txtMesaWrap.Text = data.Rows[0][12].ToString(); } if (!string.IsNullOrEmpty(data.Rows[0][13].ToString())) { txtMesaSub.Text = data.Rows[0][13].ToString(); } if (!string.IsNullOrEmpty(data.Rows[0][14].ToString())) { txtOperNA.Text = data.Rows[0][14].ToString(); } if (!string.IsNullOrEmpty(data.Rows[0][15].ToString())) { txtSurtidor.Text = data.Rows[0][15].ToString(); } if (!string.IsNullOrEmpty(data.Rows[0][16].ToString())) { txtInspSella.Text = data.Rows[0][16].ToString(); } if (!string.IsNullOrEmpty(data.Rows[0][17].ToString())) { txtSellador.Text = data.Rows[0][17].ToString(); } if (!string.IsNullOrEmpty(data.Rows[0][18].ToString())) { txtInspec.Text = data.Rows[0][18].ToString(); } if (!string.IsNullOrEmpty(data.Rows[0][21].ToString())) { txtHori.Text = data.Rows[0][21].ToString(); } if (!string.IsNullOrEmpty(data.Rows[0][22].ToString())) { txtVertical.Text = data.Rows[0][22].ToString(); } if (!string.IsNullOrEmpty(data.Rows[0][23].ToString())) { txtSobre.Text = data.Rows[0][23].ToString(); } if (!string.IsNullOrEmpty(data.Rows[0][25].ToString())) { txtTape.Text = data.Rows[0][25].ToString(); } if (!string.IsNullOrEmpty(data.Rows[0][24].ToString())) { txtNA.Text = data.Rows[0][24].ToString(); } if (!string.IsNullOrEmpty(data.Rows[0]["detroit"].ToString())) { txtDetroit.Text = data.Rows[0]["detroit"].ToString(); } cbxLang.SelectedValue = data.Rows[0]["lenguage"].ToString(); txtMaxHC.Text = data.Rows[0]["max_hc"].ToString(); txtMinHC.Text = data.Rows[0]["min_hc"].ToString(); txtOutAdd.Text = data.Rows[0]["out_addtime"].ToString(); if (data.Rows[0]["ind_boxhr"].ToString() == "1") { chbBoxHr.Checked = true; } if (data.Rows[0]["cycle_timer"].ToString() == "1") { chbCycleTimer.Checked = true; } if (data.Rows[0]["active"].ToString() == "1") { chbActive.Checked = true; } } LineaRampeoLogica lin = new LineaRampeoLogica(); lin.CN = Globals._gsCompany; dgwLine.DataSource = LineaRampeoLogica.Vista(lin); CargarColumnas(); _gs.ControlGridText(this.Name, dgwLine); Globals gs = new Globals(); gs.ControlText(this.Name, tabPage1); gs.ControlText(this.Name, tabPage2); gs.ControlText(this.Name, tabPage3); cbbClave.DataSource = LineaConfigLogica.Consultar(); cbbClave.ValueMember = "clave"; cbbClave.DisplayMember = "clave"; cbbClave.SelectedIndex = -1; Dictionary <string, string> List = new Dictionary <string, string>(); List.Add("CJ", "Cajas"); List.Add("KT", "Kits"); cbbMetaum.DataSource = new BindingSource(List, null); cbbMetaum.DisplayMember = "Value"; cbbMetaum.ValueMember = "Key"; cbbMetaum.SelectedIndex = 0; cbbTurno.DataSource = LineaConfigLogica.ConsultarTurnos(); cbbTurno.DisplayMember = "turno"; cbbTurno.ValueMember = "turno"; cbbTurno.SelectedValue = 0; dgwHrs.DataSource = null; dgwLineas.DataSource = null; txtJornada.Focus(); } catch (Exception ex) { MessageBox.Show("Error " + ex.ToString(), Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
private void btnSaveHr_Click(object sender, EventArgs e) { if (!Valida()) { return; } if (!ValidaAcceso()) { MessageBox.Show("No tiene permiso para modificar esta configuración", Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } try { LineaConfigLogica con = new LineaConfigLogica(); string sCve = cbbClave.Text.ToString(); con.Clave = sCve; con.Descrip = txtDescrip.Text.ToString(); con.Meta = int.Parse(lblMeta.Text.ToString()); con.MetaUm = cbbMetaum.SelectedValue.ToString(); con.Turno = cbbTurno.SelectedValue.ToString(); if (LineaConfigLogica.GuardarSP(con) > 0) { foreach (DataGridViewRow row in dgwHrs.Rows) { if (row.Index == dgwHrs.Rows.Count - 1) { continue; } if (string.IsNullOrEmpty(row.Cells[1].Value.ToString())) { continue; } LineaConfigHrLogica conh = new LineaConfigHrLogica(); conh.Clave = con.Clave; conh.Consec = int.Parse(row.Cells[0].Value.ToString()); conh.Horario = row.Cells[1].Value.ToString(); conh.Meta = int.Parse(row.Cells[2].Value.ToString()); conh.MetaAc = int.Parse(row.Cells[3].Value.ToString()); LineaConfigHrLogica.GuardarSP(conh); } if (dgwLineas.RowCount > 1) { foreach (DataGridViewRow row in dgwLineas.Rows) { if (row.Index == dgwLineas.Rows.Count - 1) { continue; } int iLine = 0; if (!int.TryParse(row.Cells[1].Value.ToString(), out iLine)) { continue; } LineaConfigLnLogica conL = new LineaConfigLnLogica(); conL.Clave = con.Clave; int iCons = 0; if (!int.TryParse(row.Cells[0].Value.ToString(), out iCons)) { iCons = 0; } conL.Consec = iCons; conL.Linea = row.Cells[1].Value.ToString(); LineaConfigLnLogica.GuardarSP(conL); } } } Close(); } catch (Exception ex) { MessageBox.Show(ex.ToString(), Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } }
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); } }