Esempio n. 1
0
        private void cbbPlanta_SelectionChangeCommitted(object sender, EventArgs e)
        {
            try
            {
                PlantaLogica plan = new PlantaLogica();
                plan.Planta = cbbPlanta.SelectedValue.ToString();
                DataTable datos = PlantaLogica.Consultar(plan);
                if (datos.Rows.Count != 0)
                {
                    txtNombre.Text = datos.Rows[0]["nombre"].ToString();

                    LineaLogica lin = new LineaLogica();
                    lin.Planta = cbbPlanta.SelectedValue.ToString();
                    DataTable Lista = LineaLogica.ListarPta(lin);
                    dgwLineas.DataSource = Lista;

                    txtNombre.Focus();
                }

                CargarLineas();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }
Esempio n. 2
0
        private void GeneraReporte(string _asUser, double _dReal)
        {
            try
            {
                string sTurno = cbbTurno.SelectedValue.ToString();
                string sHora  = cbbHora.Text.ToString();

                UsuarioLogica user = new UsuarioLogica();
                user.Usuario = _asUser;
                DataTable dtU     = UsuarioLogica.Consultar(user);
                string    sIndRam = dtU.Rows[0]["ind_ramp"].ToString();
                double    dRampeo = double.Parse(dtU.Rows[0]["rampeo"].ToString());
                string    sLinea  = dtU.Rows[0]["linea"].ToString();
                string    sPlanta = dtU.Rows[0]["planta"].ToString();

                LineaLogica line = new LineaLogica();
                line.Linea  = sLinea;
                line.Planta = sPlanta;
                DataTable dtL      = LineaLogica.Consultar(line);
                string    sMateria = dtL.Rows[0]["standar"].ToString();

                LinestdLogica lins = new LinestdLogica();
                lins.Linea = sLinea;
                lins.Turno = sTurno;
                DataTable dtStd = LinestdLogica.ConsultarTurno(lins);

                double dMeta = 0;
                for (int x = 0; x < dtStd.Rows.Count; x++)
                {
                    string sNombre = dtStd.Rows[x][3].ToString();
                    double dEstd   = 0;
                    if (!double.TryParse(dtStd.Rows[x][4].ToString(), out dEstd))
                    {
                        dEstd = 0;
                    }

                    dMeta += dEstd;

                    if (sHora == sNombre)
                    {
                        AgregaLinea(_asUser, sPlanta, sLinea, dMeta, _dReal);
                        break;
                    }
                }

                //guarda t_metadia
            }
            catch (Exception ex)
            {
                MessageBox.Show("Favor de notificar al Administrador" + Environment.NewLine + ex.ToString(), Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
        }
Esempio n. 3
0
        private void cbbLinea_KeyDown(object sender, KeyEventArgs e)
        {
            try
            {
                if (e.KeyCode == Keys.Escape)
                {
                    Close();
                }

                if (e.KeyCode != Keys.Enter)
                {
                    return;
                }

                LineaLogica line = new LineaLogica();
                line.Linea = cbbLinea.SelectedValue.ToString();
                DataTable datos = LineaLogica.ConsultarLine(line);
                if (datos.Rows.Count != 0)
                {
                    txtNombre.Text          = datos.Rows[0]["nombre"].ToString();
                    cbbPlanta.SelectedValue = datos.Rows[0]["planta"].ToString();

                    AreaLogica area = new AreaLogica();
                    area.Planta = datos.Rows[0]["planta"].ToString();
                    DataTable dtA = AreaLogica.ListarPlanta(area);
                    cbbArea.DataSource    = dtA;
                    cbbArea.ValueMember   = "area";
                    cbbArea.DisplayMember = "area";
                    cbbArea.SelectedValue = datos.Rows[0]["area"].ToString();

                    cbbMaterial.SelectedValue = datos.Rows[0]["standar"].ToString();


                    LinestdLogica lin = new LinestdLogica();
                    lin.Linea = cbbLinea.SelectedValue.ToString();
                    lin.Turno = "1";
                    DataTable Lista = LinestdLogica.Listar(lin);
                    dgwTurno1.DataSource = Lista;

                    lin.Turno = "2";
                    DataTable Lista2 = LinestdLogica.Listar(lin);
                    dgwTurno2.DataSource = Lista2;
                    txtNombre.Focus();
                }

                CargarStd();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }
Esempio n. 4
0
        private void cbbArea_SelectionChangeCommitted(object sender, EventArgs e)
        {
            try
            {
                string        sUsuario = cbbUsuario.SelectedValue.ToString();
                UsuarioLogica user     = new UsuarioLogica();
                user.Usuario = sUsuario;
                DataTable datos = UsuarioLogica.Consultar(user);
                if (datos.Rows.Count != 0)
                {
                    cbbPuesto.SelectedValue = datos.Rows[0]["puesto"].ToString();
                    if (datos.Rows[0]["puesto"].ToString() == "OP")
                    {
                        cbbTurno.SelectedValue  = datos.Rows[0]["turno"].ToString();
                        cbbPlanta.SelectedValue = datos.Rows[0]["planta"].ToString();

                        LineaLogica line = new LineaLogica();
                        line.Planta = cbbPlanta.SelectedValue.ToString();
                        DataTable dt = LineaLogica.ListarPta(line);
                        cbbLinea.DataSource    = dt;
                        cbbLinea.ValueMember   = "linea";
                        cbbLinea.DisplayMember = "linea";
                        cbbLinea.SelectedValue = datos.Rows[0]["linea"].ToString();

                        if (datos.Rows[0]["ind_ramp"].ToString() == "1")
                        {
                            chbRamp.Checked = true;
                        }
                        else
                        {
                            chbRamp.Checked = false;
                        }
                        if (!string.IsNullOrEmpty(datos.Rows[0]["rampeo"].ToString()))
                        {
                            txtRamp.Text = datos.Rows[0]["rampeo"].ToString();
                        }
                    }
                    else
                    {
                        cbbTurno.ResetText();
                        cbbPlanta.ResetText();
                        cbbLinea.ResetText();
                        chbRamp.Checked = false;
                        txtRamp.Clear();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }
Esempio n. 5
0
        private DataTable GeneraReporte(string _asUser, double _dReal, DataTable _dt)
        {
            try
            {
                UsuarioLogica user = new UsuarioLogica();
                user.Usuario = _asUser;
                DataTable dtU     = UsuarioLogica.Consultar(user);
                string    sIndRam = dtU.Rows[0]["ind_ramp"].ToString();
                double    dRampeo = double.Parse(dtU.Rows[0]["rampeo"].ToString());
                string    sLinea  = dtU.Rows[0]["linea"].ToString();
                string    sPlanta = dtU.Rows[0]["planta"].ToString();

                LineaLogica line = new LineaLogica();
                line.Linea  = sLinea;
                line.Planta = sPlanta;
                DataTable dtL      = LineaLogica.Consultar(line);
                string    sMateria = dtL.Rows[0]["standar"].ToString();

                LinestdLogica lins = new LinestdLogica();
                lins.Linea = sLinea;
                lins.Turno = _lsTurno;
                DataTable dtStd = LinestdLogica.ConsultarTurno(lins);

                double dMeta = 0;
                for (int x = 0; x < dtStd.Rows.Count; x++)
                {
                    string sNombre = dtStd.Rows[x][3].ToString();
                    double dEstd   = 0;
                    if (!double.TryParse(dtStd.Rows[x][4].ToString(), out dEstd))
                    {
                        dEstd = 0;
                    }

                    dMeta += dEstd;
                    if (_lsHrReg.Substring(0, 2) == sNombre.Substring(0, 2))
                    {
                        // GUARDAR REGISTRO <>>
                        //AgregaLinea(_asUser, sPlanta, sLinea, dMeta, _dReal);
                        _dt.Rows.Add(0, 0, _asUser, sPlanta, sLinea, dMeta, _dReal);
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Favor de notificar al Administrador" + Environment.NewLine + ex.ToString(), Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(_dt);
            }
            return(_dt);
        }
Esempio n. 6
0
 private void dgwUsuarios_CellValueChanged(object sender, DataGridViewCellEventArgs e)
 {
     if (e.ColumnIndex == 1 || e.ColumnIndex == 2)
     {
         int iIndex = e.ColumnIndex;
         _lbCambioDet = true;
     }
     if (e.ColumnIndex == 1)
     {
         string sNombre = dgwUsuarios[e.ColumnIndex, e.RowIndex].Value.ToString().ToUpper();
         if (!string.IsNullOrEmpty(sNombre) && !string.IsNullOrWhiteSpace(sNombre))
         {
             PlantaLogica pl = new PlantaLogica();
             pl.Planta = sNombre;
             if (!PlantaLogica.Verificar(pl))
             {
                 dgwUsuarios[6, e.RowIndex].Value = "0";
                 MessageBox.Show("La planta no se encuentra registrada", Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                 return;
             }
             else
             {
                 dgwUsuarios[6, e.RowIndex].Value = "1";
             }
         }
     }
     if (e.ColumnIndex == 2)
     {
         string sPlanta = dgwUsuarios[1, e.RowIndex].Value.ToString().ToUpper();
         string sNombre = dgwUsuarios[e.ColumnIndex, e.RowIndex].Value.ToString().ToUpper();
         if (!string.IsNullOrEmpty(sNombre) && !string.IsNullOrWhiteSpace(sNombre))
         {
             LineaLogica ln = new LineaLogica();
             ln.Planta = sPlanta;
             ln.Linea  = sNombre;
             if (!LineaLogica.Verificar(ln))
             {
                 dgwUsuarios[6, e.RowIndex].Value = "0";
                 MessageBox.Show("La linea no se encuentra registrada", Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                 return;
             }
             else
             {
                 dgwUsuarios[6, e.RowIndex].Value = "1";
             }
         }
     }
 }
Esempio n. 7
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            Global.gsUsuario  = Environment.UserName.ToString().ToUpper();
            Global.gsEstacion = Environment.MachineName.ToString().ToUpper();

            LineaLogica lin = new LineaLogica();

            lin.Nombre = Global.gsEstacion;

            Global.Turno();
            UsuarioLogica user = new UsuarioLogica();

            user.Usuario = Global.gsUsuario;


            //if (LineaLogica.VerificarMaq(lin))
            if (UsuarioLogica.VerificarOperador(user))
            {
                Application.Run(new wfMTpp()); //Line monitor
            }
            else
            {
                AreaLogica area = new AreaLogica();
                area.Estacion = Global.gsEstacion;
                if (AreaLogica.VerificarEstacion(area))
                {
                    Application.Run(new wfDashboard()); //Area dashboard
                }
                else
                {
                    DataTable dtConf    = ConfigLogica.Consultar();
                    string    sMonLaser = dtConf.Rows[0]["monitor_laser"].ToString();
                    //sMonLaser = "MEXI0848";
                    if (Global.gsEstacion == sMonLaser)
                    {
                        Application.Run(new wfDashboard()); //Area dashboard
                    }
                    else
                    {
                        Application.Run(new wfMainMenu());
                    }
                }
            }
        }
Esempio n. 8
0
 private void cbbPlanta_SelectionChangeCommitted(object sender, EventArgs e)
 {
     try
     {
         LineaLogica line = new LineaLogica();
         line.Planta = cbbPlanta.SelectedValue.ToString();
         DataTable dt = LineaLogica.ListarPta(line);
         cbbLinea.DataSource    = dt;
         cbbLinea.ValueMember   = "linea";
         cbbLinea.DisplayMember = "linea";
         cbbLinea.SelectedValue = -1;
     }
     catch (Exception ex)
     {
         MessageBox.Show("Favor de Notificar al Administrador" + Environment.NewLine + ex.ToString(), "Error..." + Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
 }
Esempio n. 9
0
        private void Inicio()
        {
            cbbLinea.ResetText();
            DataTable data = LineaLogica.Listar();

            cbbLinea.DataSource    = data;
            cbbLinea.ValueMember   = "linea";
            cbbLinea.DisplayMember = "linea";
            cbbLinea.SelectedIndex = -1;

            txtNombre.Clear();

            cbbPlanta.ResetText();
            DataTable dtT = PlantaLogica.Listar();

            cbbPlanta.DataSource    = dtT;
            cbbPlanta.ValueMember   = "planta";
            cbbPlanta.DisplayMember = "nombre";
            cbbPlanta.SelectedIndex = -1;

            cbbArea.ResetText();
            cbbArea.DataSource = null;

            cbbMaterial.ResetText();
            DataTable dt = MaterialLogica.Listar();

            cbbMaterial.DataSource    = dt;
            cbbMaterial.ValueMember   = "material";
            cbbMaterial.DisplayMember = "nombre";
            cbbMaterial.SelectedIndex = -1;

            dgwTurno1.DataSource = null;

            dgwTurno2.DataSource       = null;
            dgwLineasRemove.DataSource = null;

            CargarStd();

            cbbLinea.Focus();
        }
Esempio n. 10
0
        private void cbbPlanta_KeyDown(object sender, KeyEventArgs e)
        {
            try
            {
                if (e.KeyCode == Keys.Escape)
                {
                    Close();
                }

                if (e.KeyCode != Keys.Enter)
                {
                    return;
                }

                PlantaLogica plan = new PlantaLogica();
                plan.Planta = cbbPlanta.SelectedValue.ToString();
                DataTable datos = PlantaLogica.Consultar(plan);
                if (datos.Rows.Count != 0)
                {
                    txtNombre.Text = datos.Rows[0]["nombre"].ToString();

                    LineaLogica lin = new LineaLogica();
                    lin.Planta = cbbPlanta.SelectedValue.ToString();
                    DataTable Lista = LineaLogica.ListarPta(lin);
                    dgwLineas.DataSource = Lista;

                    txtNombre.Focus();
                }

                CargarLineas();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }
Esempio n. 11
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (cbbLinea.SelectedIndex == -1)
            {
                return;
            }


            DialogResult Result = MessageBox.Show("Desea borrar la Linea?", Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (Result == DialogResult.Yes)
            {
                try
                {
                    LineaLogica lin = new LineaLogica();
                    lin.Linea = cbbLinea.SelectedValue.ToString();

                    //if (LineaLogica.AntesDeEliminar(lin))
                    //{
                    //    MessageBox.Show("La Linea no se puede borrar, debido a que cuenta con movimientos en el Sistema", Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    //    return;
                    //}

                    if (LineaLogica.Eliminar(lin))
                    {
                        MessageBox.Show("La Linea ha sido borrada", Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        Inicio();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Favor de Notificar al Administrador" + Environment.NewLine + ex.ToString(), Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }
            }
        }
Esempio n. 12
0
        private bool Guardar()
        {
            try
            {
                if (!Valida())
                {
                    return(false);
                }

                PlantaLogica plan = new PlantaLogica();
                plan.Planta = cbbPlanta.Text.ToString().ToUpper();
                plan.Nombre = txtNombre.Text.ToString();
                if (PlantaLogica.Guardar(plan) == 0)
                {
                    MessageBox.Show("Error al intentar guardar la Planta", Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(false);
                }

                //BORRA ESTACIONES ELIMINADAS
                foreach (DataGridViewRow row in dgwLineasRemove.Rows)
                {
                    string sPlanta = row.Cells[0].Value.ToString();
                    string sLinea  = row.Cells[1].Value.ToString();
                    if (!string.IsNullOrEmpty(sPlanta))
                    {
                        LineaLogica line = new LineaLogica();
                        line.Planta = sPlanta;
                        line.Linea  = sLinea;
                        try
                        {
                            LineaLogica.Eliminar(line);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show("Favor de Notificar al Administrador" + Environment.NewLine + "LineaLogica.Eliminar(mode);" + Environment.NewLine + ex.ToString(), Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            return(false);
                        }
                    }
                }

                if (_lbCambioDet)
                {
                    foreach (DataGridViewRow row in dgwLineas.Rows)
                    {
                        if (row.Index == dgwLineas.Rows.Count - 1)
                        {
                            break;
                        }

                        if (dgwLineas.IsCurrentRowDirty)
                        {
                            dgwLineas.CommitEdit(DataGridViewDataErrorContexts.Commit);
                        }

                        string sPlanta = cbbPlanta.SelectedValue.ToString();
                        string sLine   = Convert.ToString(row.Cells[1].Value);
                        string sNombre = Convert.ToString(row.Cells[2].Value);
                        string sArea   = Convert.ToString(row.Cells[3].Value);

                        LineaLogica line = new LineaLogica();
                        line.Planta = sPlanta;
                        line.Linea  = sLine;
                        line.Nombre = sNombre;
                        line.Area   = sArea;

                        if (LineaLogica.GuardarPta(line) == -1)
                        {
                            MessageBox.Show("Error al intentar guardar la linea " + sLine, Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return(false);
                        }
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Favor de notificar al Administrador" + Environment.NewLine + "EstacionLogica.Guardar(mod)" + Environment.NewLine + ex.ToString(), Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
        }
Esempio n. 13
0
        private void cbbArea_KeyDown(object sender, KeyEventArgs e)
        {
            try
            {
                if (e.KeyCode == Keys.Escape)
                {
                    Close();
                }

                if (e.KeyCode != Keys.Enter)
                {
                    return;
                }

                if (string.IsNullOrEmpty(cbbUsuario.Text))
                {
                    cbbUsuario.SelectedIndex = -1;
                    return;
                }

                string        sUsuario = cbbUsuario.Text.ToUpper().Trim().ToString();
                UsuarioLogica user     = new UsuarioLogica();
                user.Usuario = sUsuario;
                DataTable datos = UsuarioLogica.Consultar(user);
                if (datos.Rows.Count != 0)
                {
                    cbbUsuario.SelectedValue = datos.Rows[0]["usuario"].ToString();
                    cbbTurno.SelectedValue   = datos.Rows[0]["turno"].ToString();
                    cbbPlanta.SelectedValue  = datos.Rows[0]["planta"].ToString();
                    cbbPuesto.SelectedValue  = datos.Rows[0]["puesto"].ToString();

                    LineaLogica line = new LineaLogica();
                    line.Planta = cbbPlanta.SelectedValue.ToString();
                    DataTable dt = LineaLogica.ListarPta(line);
                    cbbLinea.DataSource    = dt;
                    cbbLinea.ValueMember   = "linea";
                    cbbLinea.DisplayMember = "linea";
                    cbbLinea.SelectedValue = datos.Rows[0]["linea"].ToString();

                    if (datos.Rows[0]["ind_ramp"].ToString() == "1")
                    {
                        chbRamp.Checked = true;
                    }
                    else
                    {
                        chbRamp.Checked = false;
                    }
                    if (!string.IsNullOrEmpty(datos.Rows[0]["rampeo"].ToString()))
                    {
                        txtRamp.Text = datos.Rows[0]["rampeo"].ToString();
                    }
                }
                else
                {
                    Inicio();
                    cbbUsuario.Text = sUsuario;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }
Esempio n. 14
0
        private bool Guardar()
        {
            try
            {
                if (!Valida())
                {
                    return(false);
                }

                LineaLogica linea = new LineaLogica();
                linea.Linea    = cbbLinea.Text.ToString().ToUpper();
                linea.Nombre   = txtNombre.Text.ToString();
                linea.Planta   = cbbPlanta.SelectedValue.ToString();
                linea.Area     = cbbArea.SelectedValue.ToString();
                linea.Material = cbbMaterial.SelectedValue.ToString();

                if (LineaLogica.Guardar(linea) == 0)
                {
                    MessageBox.Show("Error al intentar guardar la Linea", Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(false);
                }

                //BORRA ESTACIONES ELIMINADAS
                foreach (DataGridViewRow row in dgwLineasRemove.Rows)
                {
                    string sLinea = row.Cells[0].Value.ToString();
                    int    iCons  = 0;
                    if (int.TryParse(row.Cells[0].Value.ToString(), out iCons))
                    {
                        if (!string.IsNullOrEmpty(sLinea))
                        {
                            LinestdLogica lines = new LinestdLogica();
                            lines.Linea  = sLinea;
                            lines.Consec = iCons;
                            try
                            {
                                LinestdLogica.Eliminar(lines);
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show("Favor de Notificar al Administrador" + Environment.NewLine + "LineaLogica.Eliminar(mode);" + Environment.NewLine + ex.ToString(), Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                                return(false);
                            }
                        }
                    }
                }

                if (_lbCambioDet)
                {
                    foreach (DataGridViewRow row in dgwTurno1.Rows)
                    {
                        if (row.Index == dgwTurno1.Rows.Count - 1)
                        {
                            break;
                        }

                        if (dgwTurno1.IsCurrentRowDirty)
                        {
                            dgwTurno1.CommitEdit(DataGridViewDataErrorContexts.Commit);
                        }


                        string sHora = Convert.ToString(row.Cells[3].Value);
                        int    iCons = 0;
                        if (!int.TryParse(row.Cells[1].Value.ToString(), out iCons))
                        {
                            iCons = 0;
                        }

                        double dMeta = 0;
                        if (!double.TryParse(row.Cells[4].Value.ToString(), out dMeta))
                        {
                            dMeta = 0;
                        }

                        LinestdLogica lines = new LinestdLogica();
                        lines.Linea    = cbbLinea.SelectedValue.ToString();
                        lines.Consec   = iCons;
                        lines.Turno    = "1";
                        lines.Nombre   = sHora;
                        lines.Estandar = dMeta;
                        if (LinestdLogica.Guardar(lines) == -1)
                        {
                            MessageBox.Show("Error al intentar guardar la Hora " + sHora, Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return(false);
                        }
                    }
                }

                if (_lbCambioDet2)
                {
                    foreach (DataGridViewRow row in dgwTurno2.Rows)
                    {
                        if (row.Index == dgwTurno2.Rows.Count - 1)
                        {
                            break;
                        }

                        if (dgwTurno2.IsCurrentRowDirty)
                        {
                            dgwTurno2.CommitEdit(DataGridViewDataErrorContexts.Commit);
                        }


                        string sHora = Convert.ToString(row.Cells[3].Value);
                        int    iCons = 0;
                        if (!int.TryParse(row.Cells[1].Value.ToString(), out iCons))
                        {
                            iCons = 0;
                        }

                        double dMeta = 0;
                        if (!double.TryParse(row.Cells[4].Value.ToString(), out dMeta))
                        {
                            dMeta = 0;
                        }

                        LinestdLogica lines = new LinestdLogica();
                        lines.Linea    = cbbLinea.SelectedValue.ToString();
                        lines.Consec   = iCons;
                        lines.Turno    = "2";
                        lines.Nombre   = sHora;
                        lines.Estandar = dMeta;
                        if (LinestdLogica.Guardar(lines) == -1)
                        {
                            MessageBox.Show("Error al intentar guardar la Hora " + sHora, Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return(false);
                        }
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Favor de notificar al Administrador" + Environment.NewLine + "EstacionLogica.Guardar(mod)" + Environment.NewLine + ex.ToString(), Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
        }
Esempio n. 15
0
        private DataTable ImportarDatos(string _asPlanta, string _asArea, string _asGlobal)
        {
            DataTable dt = new DataTable();

            try
            {
                bool bInicial = false;
                //lineas de seccion 3 de laser
                DataTable   dtLine = new DataTable();
                LineaLogica line   = new LineaLogica();
                line.Planta = _asPlanta;
                line.Area   = _asArea;
                line.Global = _asGlobal;
                dtLine      = LineaLogica.ConsultarArea(line);

                dt.Columns.Add("linea", typeof(string));
                dt.Columns.Add("meta", typeof(string));
                dt.Columns.Add("real", typeof(string));
                dt.Columns.Add("cump", typeof(string));

                //ultimo reporte cargado de cesapp
                MetadiaLogica met = new MetadiaLogica();
                met.Planta = _asPlanta;
                met.Turno  = Global.gsTurno;
                //CultureInfo en = new CultureInfo("en-US");
                met.Fecha = DateTime.Today;
                if (DateTime.Now.Hour < 5)
                {
                    met.Fecha = DateTime.Today.AddDays(-1);
                }

                long lFolio = MetadiaLogica.LastFolioDia(met);

                if (lFolio == 0)
                {
                    if (_lsDiaAnt == "1")
                    {
                        lFolio = MetadiaLogica.LastFolio(met);
                    }
                    else
                    {
                        return(dt);
                    }
                    //cargar meta sin saldo
                    //bInicial = true;
                }
                met.Folio = lFolio;
                DataTable dtHora = MetadiaLogica.Consultar(met);
                _lsHora = dtHora.Rows[0]["hora"].ToString();

                if (_lsDiaAnt == "1")
                {
                    _lsHora = dtHora.Rows[0]["f_id"].ToString();
                }

                //cargar datos de daily processing
                DataTable     dtDaily = new DataTable();
                MetadetLogica med     = new MetadetLogica();
                med.Folio  = lFolio;
                med.Global = _asGlobal;
                med.Area   = _asArea;
                dtDaily    = MetadetLogica.VistaGrafica(med);
                foreach (DataRow row in dtDaily.Rows)
                {
                    DataRow r = dt.NewRow();
                    //string sUsuario = row[0].ToString();
                    string sMT   = row[0].ToString();
                    double dMeta = Convert.ToDouble(row[1].ToString());
                    double dReal = Convert.ToDouble(row[2].ToString());

                    double dPorc = dReal / dMeta;
                    dPorc = dPorc * 100;
                    dPorc = Math.Round(dPorc, 2);

                    r[0] = sMT;
                    r[1] = dMeta.ToString();
                    r[2] = dReal.ToString();
                    r[3] = dPorc.ToString();
                    dt.Rows.Add(r);
                }
                return(dt);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Favor de Notificar al Administrador" + Environment.NewLine + "Archivo sin formato Estandar" + Environment.NewLine + "ImportarDatosTxt.." + ex.ToString(), "ERROR " + Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            return(dt);
        }
Esempio n. 16
0
        private DataTable ImportarDatosTxt(string _asPlanta, string _asArea, string _asGlobal)
        {
            DataTable dt = new DataTable();

            try
            {
                //lineas de seccion 3 de laser
                DataTable   dtLine = new DataTable();
                LineaLogica line   = new LineaLogica();
                line.Planta = _asPlanta;
                line.Area   = _asArea;
                line.Global = _asGlobal;
                dtLine      = LineaLogica.ConsultarArea(line);

                dt.Columns.Add("linea", typeof(string));
                dt.Columns.Add("meta", typeof(string));
                dt.Columns.Add("real", typeof(string));
                dt.Columns.Add("cump", typeof(string));

                string sFile = _lsURL + @"\" + _lsFile;

                string[] records      = File.ReadAllLines(sFile);
                DateTime lastModified = File.GetLastWriteTime(sFile);
                _sFechaMod = lastModified.ToString();

                foreach (string record in records)
                {
                    DataRow  r      = dt.NewRow();
                    string[] fields = record.Split('\t');

                    if (string.IsNullOrEmpty(fields[0].ToString()))
                    {
                        continue;
                    }

                    string sMT   = fields[0].ToString();
                    string sMeta = fields[1].ToString().TrimStart().TrimEnd();
                    string sReal = fields[2].ToString().TrimStart().TrimEnd();

                    if (sMT != "TOTAL")
                    {
                        sMeta = sMeta.Replace(",", "");
                    }

                    int iCant = 0;
                    if (!int.TryParse(sMeta, out iCant))
                    {
                        iCant = 0;
                    }

                    string sCump = fields[3].ToString().TrimStart().TrimEnd();
                    sCump = sCump.Replace("%", "");

                    double dCant = 0;
                    if (!double.TryParse(sCump, out dCant))
                    {
                        continue;
                    }

                    foreach (DataRow row in dtLine.Rows)
                    {
                        string sLinea = row[1].ToString();
                        if (sLinea == sMT || sMT == "TOTAL")
                        {
                            r[0] = sMT;
                            r[1] = sMeta;
                            r[2] = sReal;
                            r[3] = sCump;
                            dt.Rows.Add(r);
                            break;
                        }
                    }
                }

                return(dt);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Favor de Notificar al Administrador" + Environment.NewLine + "Archivo sin formato Estandar" + Environment.NewLine + "ImportarDatosTxt.." + ex.ToString(), "ERROR " + Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            return(dt);
        }
Esempio n. 17
0
        private string ImportarDatos(string _asLinea)
        {
            string sReturn = string.Empty;

            try
            {
                //lineas de seccion 3 de laser
                DataTable   dtLine = new DataTable();
                LineaLogica line   = new LineaLogica();
                line.Linea = _asLinea;
                dtLine     = LineaLogica.ConsultarLine(line);
                string sPlanta = dtLine.Rows[0]["planta"].ToString();

                /****/
                //Notifiaciones pendientes
                MetadetLogica med = new MetadetLogica();
                med.Planta = sPlanta;
                med.Linea  = _asLinea;
                long      lFolio = 0;
                DataTable data   = MetadetLogica.ConsultarNoti(med);
                for (int i = 0; i < data.Rows.Count; i++)
                {
                    //enviar notificacion por carga pendiente
                    lFolio = long.Parse(data.Rows[i]["folio"].ToString());
                    int    iCons = int.Parse(data.Rows[i]["consec"].ToString());
                    string sHora = data.Rows[i]["hora"].ToString();
                    double dMta  = double.Parse(data.Rows[i]["meta"].ToString());
                    double dRel  = double.Parse(data.Rows[i]["real"].ToString());
                    double dPrc  = (dMta / dRel) * 100;
                    dPrc = Math.Round(dPrc, 2);
                    string sPorc = dPrc.ToString() + " %";

                    MotrarNotifiacion(_asLinea, sHora, sPorc);
                }

                //ultimo reporte cargado de cesapp
                MetadiaLogica met = new MetadiaLogica();
                met.Planta = sPlanta;
                met.Turno  = Global.gsTurno;
                met.Fecha  = DateTime.Today;
                lFolio     = MetadiaLogica.LastFolio(met);
                if (lFolio == 0)
                {
                    return(sReturn);
                }

                met.Folio = lFolio;

                //cargar datos de daily processing
                DataTable     dtDaily = new DataTable();
                MetadetLogica med2    = new MetadetLogica();
                med2.Folio = lFolio;
                med2.Linea = _asLinea;
                dtDaily    = MetadetLogica.VistaIndividual(med2);
                if (dtDaily.Rows.Count > 0)
                {
                    double dMeta = Double.Parse(dtDaily.Rows[0]["meta"].ToString());
                    double dReal = Double.Parse(dtDaily.Rows[0]["real"].ToString());
                    double dPorc = dReal / dMeta;
                    dPorc   = dPorc * 100;
                    dPorc   = Math.Round(dPorc, 2);
                    sReturn = dPorc.ToString();
                }

                return(sReturn);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Favor de Notificar al Administrador" + Environment.NewLine + "Archivo sin formato Estandar" + Environment.NewLine + "ImportarDatosTxt.." + ex.ToString(), "ERROR " + Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            return(sReturn);
        }