Example #1
0
        private void listadoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            List<Puesto> objPuesto = new List<Puesto>();
            Funciones objFuncion = new Funciones();
            objPuesto = objFuncion.llenarListaPuesto(objPuesto);

            string[,] ArrayEmpleados =
            {
            { "P", "E" }, { "Empleados de Planta", "Empleados Eventuales" }
            };

            for (int i = 0; i < 2; i++)
            {
                SaveFileDialog saveFileDialog1 = new SaveFileDialog();
                saveFileDialog1.Filter = "csv files (*.csv)|*.csv";
                saveFileDialog1.Title = ArrayEmpleados[1, i];
                if (saveFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK
                    && saveFileDialog1.FileName.Length > 0)
                {
                    int ban = 0;
                    try
                    {
                        FileInfo t = new FileInfo(saveFileDialog1.FileName);
                        StreamWriter Tex = t.CreateText();
                        clConexion objConexion = new clConexion();
                        string Cadena;
                        string queryExternos = "SELECT Id,Paterno,Materno,Nombre,Puesto, Rancho FROM Empleados WHERE Tipo = '"
                            + ArrayEmpleados[0, i] + "' AND Status = 1 AND Rancho != '-' ORDER BY Paterno ASC";
                        using (SqlCommand cmd = new SqlCommand(queryExternos, objConexion.conexion()))
                        {
                            SqlDataReader dr;
                            cmd.Connection = objConexion.conexion();
                            cmd.Connection.Open();
                            dr = cmd.ExecuteReader();
                            if (dr.HasRows == true)
                                while (dr.Read())
                                {
                                    double SalDiario = 0;
                                    foreach (Puesto puesto in objPuesto)
                                        if (dr[4].ToString() == puesto.NomPuesto)
                                            SalDiario = puesto.Sueldo;
                                    Cadena = dr[0].ToString() + "," + dr[1].ToString() + "," + dr[2].ToString() +
                                        "," + dr[3].ToString() + "," + SalDiario + "," + dr[4].ToString() + "," + dr[5].ToString();
                                    Tex.WriteLine(Cadena);
                                }
                        }
                        Tex.Write(Tex.NewLine);
                        Tex.Close();
                    }
                    catch (Exception ex)
                    { ban = 1; }
                    if (ban == 0)
                        MessageBox.Show("El Archivo " + saveFileDialog1.FileName +
                            " ha sido creado", "Sistema de Viñedos", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    else
                        MessageBox.Show("No se pudo crear el Padron de Empleados. Intente de Nuevo",
                            "Sistema de Viñedos", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Example #2
0
        private void concentradoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ///*************************
            ///FUNCION PARA CREAR LOS ARCHIVOS PARA TODOS LOS EMPLEADOS!!!
            ///************************
            ///
            Funciones objFuncion = new Funciones();
            List<ListRanchos> objListRanchos = new List<ListRanchos>();
            List<Puesto> objListPuestos = new List<Puesto>();
            List<Empleado> objListEmpleado = new List<Empleado>();
            objListEmpleado = objFuncion.llenarListaEmpleado(objListEmpleado);
            objListPuestos = objFuncion.llenarListaPuesto(objListPuestos);
            objListRanchos = objFuncion.cargaRanchos(objListRanchos);
            //CREACION DEL DATATABLE
            DataTable tabla_catalogo = new DataTable();
            DataColumn columna;
            DataRow renglon;
            //*************************************************
            //Primero CREAMOS LA COLUMNA DONDE IRAN LOS RANCHOS

            columna = new DataColumn();
            columna.DataType = Type.GetType("System.String");
            columna.ColumnName = "Rancho";
            columna.AutoIncrement = false;
            columna.Caption = "Ranchos";
            columna.ReadOnly = true;
            columna.Unique = true;
            tabla_catalogo.Columns.Add(columna);
            //**********************************************
            //CREAMOS LAS COLUMNAS DE LOS PUESTOS SEGUN LA RELACION: MAYORDOMOS, TRACTORISTAS, REGADORES, JORNALES, OTROS.
            foreach (Puesto puesto in objListPuestos)
            {
                if (puesto.NomPuesto == "Jornalero")
                {
                    columna = new DataColumn();
                    columna.DataType = Type.GetType("System.String");
                    columna.ColumnName = puesto.NomPuesto;
                    columna.AutoIncrement = false;
                    columna.Caption = puesto.NomPuesto;
                    columna.ReadOnly = true;
                    columna.Unique = true;
                    tabla_catalogo.Columns.Add(columna);
                }
            }

            DataGridView grid1 = new DataGridView();
            grid1.DataSource = tabla_catalogo;
            generaHtml(grid1, "Catalogo de Empleados");
        }
Example #3
0
        /// <summary>
        /// Estrucutura de la Cabecera
        /// 1.-Mano Obra Costos LOTE-ACTIVIDAD
        /// 2.-Mano Obra Costo Planta
        /// 3.-Mano Obra Costo Hectarea
        /// 4.-Mano Obra Costo Planta-Actividad        
        /// </summary>
        public static void excel(DataGridView dataGrid, string[] Cabecera)
        {
            List<ListActividades> objActividad = new List<ListActividades>();
            SaveFileDialog saveFileDialog1 = new SaveFileDialog();
            saveFileDialog1.Filter = "csv files (*.csv)|*.csv";
            saveFileDialog1.Title = Cabecera[1];
            if (saveFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK
                && saveFileDialog1.FileName.Length > 0)
            {
                int ban = 0;
                try
                {
                    string Cadena = "";
                    Funciones fnFunciones = new Funciones();
                    objActividad = fnFunciones.cargaListaActividades(objActividad);
                    FileInfo t = new FileInfo(saveFileDialog1.FileName);
                    StreamWriter Tex = t.CreateText();

                    for (int i = 1; i < Cabecera.Length; i++)
                        Tex.WriteLine(Cabecera[i]);

                    switch (int.Parse(Cabecera[0]))
                    {
                        case 1://COSTO MANO DE OBRA LOTE-ACTIVIDAD
                            int contActividad = 0;
                            foreach (ListActividades actividad in objActividad)
                            {
                                if (contActividad == 0)
                                    Cadena += "Lotes,";
                                Cadena += actividad.Actividad + ",";
                                contActividad = 1;
                            }
                            Cadena += "TOTAL";
                            Tex.WriteLine(Cadena);
                            for (int i = 0; i < dataGrid.Rows.Count; i++)
                            {
                                Cadena = "";
                                for (int x = 0; x < dataGrid.Columns.Count; x++)
                                    Cadena += dataGrid.Rows[i].Cells[x].Value + ",";
                                Tex.WriteLine(Cadena);
                            }
                            break;
                        case 2://Mano Obra Costo Planta
                            break;
                        case 3://Mano Obra Costo Hectarea

                            string[] Array_Cadena = new string[] { "","Costos,Montos"};
                            for (int j = 0; j < 2; j++)
                                Tex.WriteLine(Array_Cadena[j]);

                            for (int i = 0; i < dataGrid.Rows.Count; i++)
                            {
                                Cadena = "";
                                for (int x = 0; x < dataGrid.Columns.Count; x++)
                                    Cadena += dataGrid.Rows[i].Cells[x].Value + ",";
                                Tex.WriteLine(Cadena);
                            }
                            break;
                        case 4://Mano Obra Costo Planta-Actividad
                            break;
                        case 5:
                            break;
                    }
                    Tex.Write(Tex.NewLine);
                    Tex.Close();
                }
                catch (Exception ex)
                {
                    ban = 1;
                }
                if (ban == 0)
                    MessageBox.Show("El Archivo " + saveFileDialog1.FileName + " ha sido creado",
                        "Sistema de Viñedos", MessageBoxButtons.OK, MessageBoxIcon.Information);
                else
                    MessageBox.Show("No se pudo crear el archivo de Costos. Intente de Nuevo",
                        "Sistema de Viñedos", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #4
0
        public static void html(DataGridView dataGrid, string[] Cabecera)
        {
            int ban = 0;
            string Cadena = "";
            List<ListActividades> objActividad = new List<ListActividades>();
            SaveFileDialog saveFileDialog1 = new SaveFileDialog();
            saveFileDialog1.Filter = "HTML files (*.html)|*.html";
            saveFileDialog1.Title = Cabecera[1];
            if (saveFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK
                && saveFileDialog1.FileName.Length > 0)
            {
                try
                {
                    Funciones fnFunciones = new Funciones();
                    objActividad = fnFunciones.cargaListaActividades(objActividad);
                    //CREAMOS EL ARCHIVO CON EL NOMBRE Y RUTA PARA GUARDARLO
                    StreamWriter sw = new StreamWriter(saveFileDialog1.FileName);
                    //Se escribe el codigo HTML
                    sw.WriteLine("<html><title>" + saveFileDialog1.Title + "</title>");//Se abre el HTML y El TITULO se Establece
                    sw.WriteLine("<body>");//Se abre la etiqueta <BODY>

                    for (int i = 1; i < Cabecera.Length; i++)
                        sw.WriteLine(Cabecera[i]+"<br />");
                    sw.WriteLine("<table cellspacing='0' cellspading='0'>");//Se abre la etiqueta <TABLE>
                    switch (int.Parse(Cabecera[0]))
                    {
                        case 1://COSTO MANO DE OBRA LOTE-ACTIVIDAD
                            int contActividad = 0;
                            foreach (ListActividades actividad in objActividad)
                            {
                                if (contActividad == 0)
                                    Cadena += "<tr bgcolor='#25C0F3'><td>Lotes</td>";
                                Cadena += "<td>" + actividad.Actividad + "</td>";
                                contActividad = 1;
                            }
                            Cadena += "<td>TOTAL</td></tr>";
                            sw.WriteLine(Cadena);//ESTABLECE EL ENCABEZADO DE LA TABLA
                            int intercalado = 0;//Variable de control para el intercalado de color de las filas del reporte
                            for (int i = 0; i < dataGrid.Rows.Count; i++)
                            {
                                Cadena = "";
                                string tr_Color = "";
                                for (int x = 0; x < dataGrid.Columns.Count; x++)
                                    Cadena += "<td>" + dataGrid.Rows[i].Cells[x].Value + "</td>";
                                //*********INTERCALA EL COLOR DE LAS FILAS*************
                                if (intercalado == 0)
                                { tr_Color = ""; intercalado = 1; }
                                else if (intercalado == 1)
                                { tr_Color = " bgcolor='#A7EAFF'"; intercalado = 0; }
                                sw.WriteLine("<tr" + tr_Color + ">" + Cadena + "</tr>");
                            }
                            break;
                        case 2://Mano Obra Costo Planta
                            break;
                        case 3://Mano Obra Costo Hectarea

                            string[] Array_Cadena = new string[] { "", "Costos,Montos" };
                            for (int j = 0; j < 2; j++)
                                sw.WriteLine(Array_Cadena[j]);

                            for (int i = 0; i < dataGrid.Rows.Count; i++)
                            {
                                Cadena = "";
                                for (int x = 0; x < dataGrid.Columns.Count; x++)
                                    Cadena += dataGrid.Rows[i].Cells[x].Value + ",";
                                sw.WriteLine(Cadena);
                            }
                            break;
                        case 4://Mano Obra Costo Planta-Actividad
                            break;
                        case 5:
                            break;
                    }

                    sw.WriteLine("</table></body></html>");//SE CIERRAN LAS ETIQUETAS TABLE BODY Y HTML
                    //CERRAMOS EL ARCHIVO </HTML>
                    sw.Close();
                }
                catch (Exception ex)
                { ban = 1; }
                finally
                {
                    if (ban == 0)
                        MessageBox.Show("El Archivo " + saveFileDialog1.FileName + " ha sido creado",
                            "Sistema de Viñedos", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    else
                        MessageBox.Show("No se pudo crear el archivo de Costos. Intente de Nuevo",
                            "Sistema de Viñedos", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Example #5
0
 //BUSQUEDA DE EMPLEADO ATRAVES DE PALABRAS
 public void WordSearchFunction(string SearchQuery)
 {
     Funciones objFunciones = new Funciones();
     List<SearchFunction> objSearchFunction = new List<SearchFunction>();
     List<SearchFunction> AuxSearchFunction = new List<SearchFunction>();
     objSearchFunction = objFunciones.LoadEmp(objSearchFunction);
     foreach (SearchFunction objSF in objSearchFunction)
     {
         try
         {
             if (SearchQuery == objSF.NoEmpleado || SearchQuery == objSF.Paterno || SearchQuery == objSF.Materno || SearchQuery == objSF.Nombre
                 || SearchQuery == objSF.NoEmpleado + " " + objSF.Paterno || SearchQuery == objSF.NoEmpleado + " " + objSF.Materno || SearchQuery == objSF.NoEmpleado + " " + objSF.Nombre
                 || SearchQuery == objSF.Paterno + " " + objSF.Materno || SearchQuery == objSF.Paterno + " " + objSF.Nombre || SearchQuery == objSF.Materno + " " + objSF.Nombre
                 || SearchQuery == objSF.NoEmpleado + " " + objSF.Paterno + " " + objSF.Materno || SearchQuery == objSF.NoEmpleado + " " + objSF.Paterno + " " + objSF.Nombre
                 || SearchQuery == objSF.NoEmpleado + " " + objSF.Materno + " " + objSF.Nombre || SearchQuery == objSF.Paterno + " " + objSF.Materno + " " + objSF.Nombre
                 || SearchQuery == objSF.NoEmpleado + " " + objSF.Paterno + " " + objSF.Materno + " " + objSF.Nombre)
                 //SI LO ESCRITO EN EL TEXTBOX COINCIDE CON CUALQUIER COMBINACION MUESTRA EN EL GRID LOS RESULTADOS QUE COINCIDAN
                 AuxSearchFunction.Add(new SearchFunction(objSF.NoEmpleado, objSF.Paterno, objSF.Materno, objSF.Nombre));
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
     dataGridView2.DataSource = AuxSearchFunction;
 }