示例#1
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);
        }
示例#2
0
        private void btnReport_Click(object sender, EventArgs e)
        {
            try
            {
                if (dgwDatadet.Rows.Count == 0)
                {
                    return;
                }

                Cursor = Cursors.WaitCursor;

                long   lFolio    = AccesoDatos.Consec(_lsProceso);
                double dMetaGlob = 0;
                double dRealGlob = 0;
                foreach (DataGridViewRow row in dgwDatadet.Rows)
                {
                    double dMeta = Convert.ToDouble(row.Cells[5].Value);
                    double dReal = Convert.ToDouble(row.Cells[6].Value);
                    dMetaGlob += dMeta;
                    dRealGlob += dReal;
                }

                MetadiaLogica met = new MetadiaLogica();
                met.Folio   = lFolio;
                met.Fecha   = DateTime.Today;
                met.Planta  = cbbPlanta.SelectedValue.ToString();
                met.Turno   = cbbTurno.SelectedValue.ToString();
                met.Hora    = cbbHora.Text.ToString();
                met.Meta    = dMetaGlob;
                met.Real    = dRealGlob;
                met.Usuario = Global.gsUsuario;
                if (MetadiaLogica.Guardar(met) == 0)
                {
                    MessageBox.Show("Error al intentar guardar" + Environment.NewLine + "MetadiaLogica.Guardar()", Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Cursor = Cursors.Default;
                    return;
                }

                //metadet
                foreach (DataGridViewRow row in dgwDatadet.Rows)
                {
                    string sUsuario = Convert.ToString(row.Cells[2].Value);
                    string sPlanta  = Convert.ToString(row.Cells[3].Value);
                    string sLinea   = Convert.ToString(row.Cells[4].Value);
                    double dMeta    = Convert.ToDouble(row.Cells[5].Value);
                    double dReal    = Convert.ToDouble(row.Cells[6].Value);
                    string sRamp    = string.Empty;
                    double dRampeo  = 0;
                    if (dMeta == 0)
                    {
                        dMeta = dReal;
                    }

                    UsuarioLogica user = new UsuarioLogica();
                    user.Usuario = sUsuario;
                    DataTable dtU = UsuarioLogica.Consultar(user);
                    sRamp = dtU.Rows[0]["ind_ramp"].ToString();
                    if (sRamp == "1")
                    {
                        dRampeo = double.Parse(dtU.Rows[0]["rampeo"].ToString());
                    }

                    if (dRampeo > 0)
                    {
                        dRampeo = dRampeo / 100;
                        double dRa = dMeta * dRampeo;
                        dMeta = dMeta - dRa;
                    }

                    double dPorc = dReal / dMeta;
                    if (dPorc < 0)
                    {
                        dPorc = 0;
                    }
                    dPorc = dPorc * 100;

                    MetadetLogica med = new MetadetLogica();
                    med.Folio   = lFolio;
                    med.Consec  = 0;
                    med.Usuario = sUsuario;
                    med.Planta  = sPlanta;
                    med.Linea   = sLinea;
                    med.Meta    = dMeta;
                    med.Real    = dReal;
                    med.Porcen  = Math.Round(dPorc, 2);

                    if (MetadetLogica.Guardar(med) == 0)
                    {
                        MessageBox.Show("Error al intentar guardar la Linea" + med, Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        Cursor = Cursors.Default;
                        return;
                    }
                }
                Cursor = Cursors.Default;
                Inicio();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Favor de notificar al Administrador" + Environment.NewLine + ex.ToString(), Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
        }
示例#3
0
        private void DailyProcessing()
        {
            DataTable dtData = new DataTable();

            _lsTurno = "2";
            DateTime dtTime = DateTime.Now;
            int      iHora  = dtTime.Hour;

            if (iHora >= 5 && iHora <= 16)
            {
                _lsTurno = "1";
            }

            if (iHora > 23)
            {
                iHora -= 23;
            }

            _lsHrReg = Convert.ToString(iHora).PadLeft(2, '0') + ":00";
            MetadiaLogica mdia = new MetadiaLogica();

            mdia.Hora = _lsHrReg;
            if (MetadiaLogica.Verificar(mdia))
            {
                return;
            }

            string sHrFile = DateTime.Now.Hour.ToString();

            iHora += 2;//CT zone

            if (iHora < 12)
            {
                sHrFile = iHora.ToString() + "am";
            }
            else
            {
                if (iHora > 23)
                {
                    if (iHora == 24)
                    {
                        iHora = 12;
                    }
                    else
                    {
                        iHora -= 24;
                    }
                    sHrFile = iHora.ToString() + "am";
                }
                else
                {
                    if (iHora > 12)
                    {
                        iHora -= 12;
                    }
                    sHrFile = iHora.ToString() + "pm";
                }
            }


            string sArchivo = _lsSynFile + sHrFile + ".xlsx";
            string sFile    = _lsSynURL + @"\" + sArchivo;

            if (!File.Exists(sFile))
            {
                return;
            }
            else
            {
                if (!FileLocked(sFile))
                {
                    dtData = CargarArchivo(sFile);
                }

                File.Delete(sFile);
            }
            // SAVE DATA
            if (dtData.Rows.Count > 0)
            {
                DataTable dtMt = new DataTable("Metadet");
                dtMt.Columns.Add("folio", typeof(long));
                dtMt.Columns.Add("consec", typeof(int));
                dtMt.Columns.Add("Usuario", typeof(string));
                dtMt.Columns.Add("Planta", typeof(string));
                dtMt.Columns.Add("Linea", typeof(string));
                dtMt.Columns.Add("Meta", typeof(double));
                dtMt.Columns.Add("Real", typeof(double));

                dtMt = CargarMT(dtData, dtMt);

                if (dtMt.Rows.Count > 0)
                {
                    try
                    {
                        Cursor = Cursors.WaitCursor;

                        long   lFolio    = AccesoDatos.Consec(_lsProceso);
                        double dMetaGlob = 0;
                        double dRealGlob = 0;
                        for (int x = 0; x < dtMt.Rows.Count; x++)
                        {
                            double dMeta = Convert.ToDouble(dtMt.Rows[x][5].ToString());
                            double dReal = Convert.ToDouble(dtMt.Rows[x][6].ToString());
                            dMetaGlob += dMeta;
                            dRealGlob += dReal;
                        }

                        MetadiaLogica met = new MetadiaLogica();
                        met.Folio = lFolio;
                        met.Fecha = DateTime.Today;
                        if (DateTime.Now.Hour < 5)
                        {
                            met.Fecha = DateTime.Today.AddDays(-1);
                        }
                        met.Planta  = _lsPlanta;
                        met.Turno   = _lsTurno;
                        met.Hora    = _lsHrReg;
                        met.Meta    = dMetaGlob;
                        met.Real    = dRealGlob;
                        met.Usuario = Global.gsUsuario;
                        if (MetadiaLogica.Guardar(met) == 0)
                        {
                            MessageBox.Show("Error al intentar guardar" + Environment.NewLine + "MetadiaLogica.Guardar()", Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                            Cursor = Cursors.Default;
                            return;
                        }

                        //metadet
                        for (int x = 0; x < dtMt.Rows.Count; x++)
                        {
                            string sUsuario = dtMt.Rows[x][2].ToString();
                            string sPlanta  = dtMt.Rows[x][3].ToString();
                            string sLinea   = dtMt.Rows[x][4].ToString();
                            double dMeta    = Convert.ToDouble(dtMt.Rows[x][5].ToString());
                            double dReal    = Convert.ToDouble(dtMt.Rows[x][6].ToString());
                            if (dMeta == 0)
                            {
                                dMeta = dReal;
                            }

                            if (_lsTurno == "2")
                            {
                                Metadet2Logica met2 = new Metadet2Logica();
                                met2.Usuario = sUsuario;

                                DataTable dtAnt = Metadet2Logica.Consultar(met2);
                                if (dtAnt.Rows.Count > 0)
                                {
                                    double dRealAnt = double.Parse(dtAnt.Rows[0][3].ToString());
                                    dReal -= dRealAnt;
                                }
                            }

                            string        sRamp   = string.Empty;
                            double        dRampeo = 0;
                            UsuarioLogica user    = new UsuarioLogica();
                            user.Usuario = sUsuario;
                            DataTable dtU = UsuarioLogica.Consultar(user);
                            sRamp = dtU.Rows[0]["ind_ramp"].ToString();
                            if (sRamp == "1")
                            {
                                dRampeo = double.Parse(dtU.Rows[0]["rampeo"].ToString());
                            }

                            if (dRampeo > 0)
                            {
                                dRampeo = dRampeo / 100;
                                double dRa = dMeta * dRampeo;
                                dMeta = dMeta - dRa;
                            }
                            if (dReal < 0)
                            {
                                dReal = 0;
                            }

                            double dPorc = dReal / dMeta;
                            if (dPorc < 0)
                            {
                                dPorc = 0;
                            }
                            dPorc = dPorc * 100;

                            MetadetLogica med = new MetadetLogica();
                            med.Folio   = lFolio;
                            med.Consec  = 0;
                            med.Usuario = sUsuario;
                            med.Planta  = sPlanta;
                            med.Linea   = sLinea;
                            med.Meta    = dMeta;
                            med.Real    = dReal;
                            med.Porcen  = Math.Round(dPorc, 2);

                            if (MetadetLogica.Guardar(med) == 0)
                            {
                                MessageBox.Show("Error al intentar guardar la Linea", Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                Cursor = Cursors.Default;
                                return;
                            }
                        }
                        Cursor = Cursors.Default;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Favor de notificar al Administrador" + Environment.NewLine + ex.ToString(), Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }
                }
            }
        }
示例#4
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);
        }