示例#1
0
        public static int AddCloseSesion_to_HistorialSesion(string username, int nivel, DateTime horafecha, string pc, string observaciones)
        {
            string query = "INSERT INTO HistorialSesion (Username,Nivel,HoraFecha,PC,Observaciones) VALUES (@Username,@Nivel,@HoraFecha,@PC,@Observaciones)";
            clConexion objConexion = new clConexion();
            int ban = 0;
            try
            {
                using (SqlCommand cmd = new SqlCommand(query, objConexion.conexion()))
                {

                    cmd.CommandText = query;
                    cmd.CommandType = CommandType.Text;
                    cmd.Parameters.AddWithValue("@Username", username);
                    cmd.Parameters.AddWithValue("@Nivel", nivel);
                    cmd.Parameters.AddWithValue("@HoraFecha", horafecha);
                    cmd.Parameters.AddWithValue("@PC", pc);
                    cmd.Parameters.AddWithValue("@Observaciones", observaciones);
                    cmd.Connection = objConexion.conexion();
                    cmd.Connection.Open();
                    cmd.ExecuteNonQuery();
                }
            }
            catch (Exception ex)
            { ban = 1; }

            return ban;
        }
示例#2
0
 public void almacenaJubilados(int Id_Empleado,DateTime Fecha, bool Asist, int HorasExtra, string Actividad, string Lote, string Observacion)
 {
     int Asistencia, Falta;
     if (Asist == true)
     { Asistencia = 1; Falta = 0; }
     else
     { Asistencia = 0; Falta = 1; }
     clConexion objConexion = new clConexion();
     string query = "Insert into Asistencia_Eventual (Id_Empleado,Fecha,Rendimiento,Asistencia,faltas,Actividad,Lote1,Observacion)" +
         " values (@Id,@Fecha,@Rendimiento,@Asistencia,@Faltas,@Actividad,@Lote,@Observacion)";
     try
     {
         using (SqlCommand cmd = new SqlCommand(query, objConexion.conexion()))
         {
             cmd.CommandText = query;
             cmd.CommandType = CommandType.Text;
             cmd.Parameters.AddWithValue("@Id", Id_Empleado);
             cmd.Parameters.AddWithValue("@Fecha", Fecha);
             cmd.Parameters.AddWithValue("@Rendimiento", HorasExtra);
             cmd.Parameters.AddWithValue("@Asistencia", Asistencia);
             cmd.Parameters.AddWithValue("@Faltas", Falta);
             cmd.Parameters.AddWithValue("@Actividad", Actividad);
             cmd.Parameters.AddWithValue("@Lote", Lote);
             cmd.Parameters.AddWithValue("@Observacion", Observacion);
             cmd.Connection = objConexion.conexion();
             cmd.Connection.Open();
             cmd.ExecuteNonQuery();
         }
     }
     catch (Exception ex) { MessageBox.Show(ex.Message); }
 }
示例#3
0
        public void crea_Nomina(int IdNom)
        {
            string query = "INSERT INTO Reg_Nomina (IdNomina,Fecha1,Fecha2,NumEmpleados,SalOrdinario,Otros,Subsidios,Imss,Isr,Monto) values (@IdNomina,@Fecha1,@Fecha2,@numEmpleados,@SalOrdinario,@Otros,@Subsidios,@Imss,@Isr,@Monto)";
            clConexion objConexion = new clConexion();
            try
            {
                using (SqlCommand cmd = new SqlCommand(query, objConexion.conexion()))
                {
                    cmd.CommandText = query;
                    cmd.CommandType = CommandType.Text;
                    cmd.Parameters.AddWithValue("@IdNomina", IdNom);
                    cmd.Parameters.AddWithValue("@Fecha1",DateTime.Now);
                    cmd.Parameters.AddWithValue("@Fecha2", DateTime.Now);
                    cmd.Parameters.AddWithValue("@NumEmpleados", Convert.ToInt32(textBox1.Text));
                    cmd.Parameters.AddWithValue("@SalOrdinario", Convert.ToDouble(textBox2.Text));
                    cmd.Parameters.AddWithValue("@Otros", Convert.ToDouble(textBox3.Text) + Convert.ToDouble(textBox6.Text) + Convert.ToDouble(textBox8.Text));
                    cmd.Parameters.AddWithValue("@Subsidios", 0);
                    cmd.Parameters.AddWithValue("@Imss", 0);
                    cmd.Parameters.AddWithValue("@Isr", 0);
                    cmd.Parameters.AddWithValue("@Monto", Convert.ToDouble(textBox7.Text));
                    cmd.Connection = objConexion.conexion();
                    cmd.Connection.Open();
                    cmd.ExecuteNonQuery();
                    MessageBox.Show("Nomina Guardada Correctamente");
                    cmd.Connection.Close();
                }

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message+" Error al guardar la nomina");
            }
        }
示例#4
0
        public static int AddContactoTelefonico(int Id, string nombre, string numero, string direccion, string ciudad, string estado, string email, string web)
        {
            string query = "INSERT INTO DirectorioTelefonico (Id,Nombre,Numero,Direccion,Ciudad,Estado,Email,Web) VALUES (@Id,@Nombre,@Numero,@Direccion,@Ciudad,@Estado,@Email,@Web)";
            clConexion objConexion = new clConexion();
            int ban = 0;
            try
            {
                using (SqlCommand cmd = new SqlCommand(query, objConexion.conexion()))
                {
                    cmd.CommandText = query;
                    cmd.CommandType = CommandType.Text;
                    cmd.Parameters.AddWithValue("@Id", Id);
                    cmd.Parameters.AddWithValue("@Nombre", nombre);
                    cmd.Parameters.AddWithValue("@Numero", numero);
                    cmd.Parameters.AddWithValue("@Direccion", direccion);
                    cmd.Parameters.AddWithValue("@Ciudad", ciudad);
                    cmd.Parameters.AddWithValue("@Estado", estado);
                    cmd.Parameters.AddWithValue("@Email", email);
                    cmd.Parameters.AddWithValue("@Web", web);
                    cmd.Connection = objConexion.conexion();
                    cmd.Connection.Open();
                    cmd.ExecuteNonQuery();
                }
            }
            catch (Exception ex)
            { ban = 1; }

            return ban;
        }
示例#5
0
 //FUNCION PARA EXTRAER LA INFO DEL EMPLEADO (TRABAJO)
 public void LoadEmpInfoRanch(int NoEmpleado)
 {
     string[] queryPart = {"Fecha, Asist, HE, Actividad, Lote1", "Fecha, Asist, Rendimiento, Actividad, Lote1","Fecha, Plantas, Precio, Actividad, Lote1","Fecha, Descripcion, Importe, Rancho"};
     string[] queryPart2 = { "Asistencia_Planta_Resp", "Asistencia_Eventual_Resp", "Asistencia_OD_Resp", "Cobro_Externos_Resp" };
     clConexion objConexion = new clConexion();
     try
     {
         for (int i = 0; i < 4; i++)
         {
             string query = "SELECT " + queryPart[i] + " FROM " + queryPart2[i] + " WHERE Id_Empleado = " + NoEmpleado+" ORDER BY Fecha";
             using (SqlDataAdapter adapter = new SqlDataAdapter(query, objConexion.conexion()))
             {
                 DataTable dt = new DataTable();
                 adapter.Fill(dt);
                 dataGridView1.DataSource = dt;
                 if (dt.Rows.Count != 0)
                     break;
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
示例#6
0
        public void buscaContrato(int id)
        {
            gbLista.Visible = false;
            gbInfo.Visible = true;
            string query = "SELECT * From Ref_Contratos where Id = "+id+"";
            string query2 = "SELECT * From Contratos where Id = "+id+"";
            clConexion objConexion = new clConexion();
            try
            {
                using (SqlCommand cmd = new SqlCommand(query, objConexion.conexion()))
                {
                    SqlDataReader dr;
                    cmd.Connection = objConexion.conexion();
                    cmd.Connection.Open();
                    dr = cmd.ExecuteReader();
                    if (dr.HasRows == false)
                    {

                    }
                    else
                    {
                      //Traer los Nombres de los empleados que estan registrados en ese contrato y ponerlos en el grid.
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            try
            {
                using (SqlCommand cmd = new SqlCommand(query2, objConexion.conexion()))
                {
                    SqlDataReader dr;
                    cmd.Connection = objConexion.conexion();
                    cmd.Connection.Open();
                    dr = cmd.ExecuteReader();
                    if (dr.HasRows == false)
                    {

                    }
                    else
                    {
                        while (dr.Read())
                        {
                            label7.Text = dr[0].ToString();
                            label8.Text = dr[1].ToString();
                            label9.Text = dr[3].ToString();
                        }

                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
示例#7
0
        public void cargaDatos(int id)
        {
            idmod = id;
            tcRegistro.Visible = true;
            btnGuardar.Visible = true;
            btnGuardar.Text = "Modificar";
            btnCancelar.Visible = true;
            gbBusqueda.Visible = false;
            grid1.Visible = false;
            string query = "SELECT * FROM EMPLEADOS WHERE Id=" + id + "";

            if (id > 4999)
                rbEventual.Checked = true;
            else
                rbPlanta.Checked = true;

            clConexion objConexion = new clConexion();
            DataTable dt = new DataTable();
            limpiar();
            try
            {
                using (SqlDataAdapter adapter = new SqlDataAdapter(query, objConexion.conexion()))
                {
                    adapter.Fill(dt);
                    txtNumero.Text = dt.Rows[0]["Id"].ToString();
                    txtPaterno.Text = dt.Rows[0]["Paterno"].ToString();
                    txtMaterno.Text = dt.Rows[0]["Materno"].ToString();
                    txtNombre.Text = dt.Rows[0]["Nombre"].ToString();
                    mtxtTelefono.Text = dt.Rows[0]["Telefono"].ToString();
                    txtDireccion.Text = dt.Rows[0]["Direccion"].ToString();
                    dtFechanac.Value = Convert.ToDateTime(dt.Rows[0]["Fechanac"]);
                    txtEstado.Text = dt.Rows[0]["Estado"].ToString();
                    txtCiudad.Text = dt.Rows[0]["Ciudad"].ToString();
                    txtNss.Text = dt.Rows[0]["Nss"].ToString();
                    txtRfc.Text = dt.Rows[0]["Rfc"].ToString();
                    txtCurp.Text = dt.Rows[0]["Curp"].ToString();
                    if (Convert.ToChar(dt.Rows[0]["Sexo"].ToString()) == 'M')
                        rbMasculino.Checked = true;
                    else if (Convert.ToChar(dt.Rows[0]["Sexo"].ToString()) == 'F')
                        rbFemenino.Checked = true;
                    pbFoto.ImageLocation = dt.Rows[0]["foto"].ToString();
                    cbPuesto.Text = dt.Rows[0]["Puesto"].ToString();
                    cbRancho2.Text = dt.Rows[0]["Rancho"].ToString();
                    dtFechaBaja.Value = Convert.ToDateTime(dt.Rows[0]["FechaBaja"].ToString());
                    dtIngreso.Value = Convert.ToDateTime(dt.Rows[0]["Fechaing"].ToString());
                }
            }
            catch (Exception ex)
            { MessageBox.Show(ex.Message); }
        }
示例#8
0
 public void almacenaExternos(int IdEmpleado, DateTime Fecha, string Descripcion, double Importe, string Rancho)
 {
     clConexion objConexion = new clConexion();
     string query = "Insert into Cobro_Externos (Id_Empleado,Fecha,Descripcion,Importe,Rancho) values (@Id_Empleado,@Fecha,@Descripcion,@Importe,@Rancho)";
     using (SqlCommand cmd = new SqlCommand(query, objConexion.conexion()))
     {
         cmd.CommandText = query;
         cmd.CommandType = CommandType.Text;
         cmd.Parameters.AddWithValue("@Id_Empleado", IdEmpleado);
         cmd.Parameters.AddWithValue("@Fecha", Fecha);
         cmd.Parameters.AddWithValue("@Descripcion", Descripcion);
         cmd.Parameters.AddWithValue("@Importe", Importe);
         cmd.Parameters.AddWithValue("@Rancho", Rancho);
         cmd.Connection = objConexion.conexion();
         cmd.Connection.Open();
         cmd.ExecuteNonQuery();
     }
 }
示例#9
0
 public void cargaEmpleados()
 {
     string query = "SELECT Id,Paterno, Materno, Nombre FROM EMPLEADOS ORDER BY Paterno ASC";
     clConexion objConexion = new clConexion();
     try
     {
         using (SqlDataAdapter adapter = new SqlDataAdapter(query, objConexion.conexion()))
         {
             DataTable dt = new DataTable();
             adapter.Fill(dt);
             dataGridView2.DataSource = dt;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
示例#10
0
 public void ActualizaRancho(int Id,string Rancho)
 {
     string update = "UPDATE Empleados SET Rancho = @Rancho WHERE Id = " + Id;
     clConexion objConexion = new clConexion();
     try
     {
         using (SqlCommand updatecmd = new SqlCommand(update, objConexion.conexion()))
         {
             updatecmd.Parameters.AddWithValue("@Rancho", Rancho);
             updatecmd.Connection = objConexion.conexion();
             updatecmd.Connection.Open();
             updatecmd.ExecuteNonQuery();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
示例#11
0
        public void cargaRancho(DataGridViewComboBoxColumn column)
        {
            string queryPuesto = "Select Clave,Rancho from R";
            clConexion objConexion = new clConexion();

            try
            {
                using (SqlDataAdapter adapter = new SqlDataAdapter(queryPuesto, objConexion.conexion()))
                {
                    DataTable dt = new DataTable();
                    adapter.Fill(dt);
                    column.DataSource = dt;
                    column.ValueMember = dt.Columns[1].ToString();
                    column.DisplayMember = dt.Columns[1].ToString();
                }

            }
            catch (Exception ex)
            { }
        }
示例#12
0
 public void loadComboSesionUsers()
 {
     string query = "SELECT username from Sesion";
     clConexion objConexion = new clConexion();
     try
     {
         using (SqlDataAdapter adapter = new SqlDataAdapter(query, objConexion.conexion()))
         {
             DataTable dt = new DataTable();
             adapter.Fill(dt);
             comboBox1.DataSource = dt;
             comboBox1.ValueMember = dt.Columns[0].ToString();
             comboBox1.DisplayMember = dt.Columns[0].ToString();
         }
     }
     catch (Exception ex)
     {
         comboBox1.Items.Add("No hay usuarios conectados");
     }
 }
示例#13
0
        public void CargaRanchoGeneral()
        {
            string query = "SELECT Clave,Rancho from R";
            clConexion objConexion = new clConexion();
            try
            {
                using (SqlDataAdapter adapter = new SqlDataAdapter(query, objConexion.conexion()))
                {
                    DataTable dt = new DataTable();
                    adapter.Fill(dt);
                    comboBox1.DataSource = dt;
                    comboBox1.ValueMember = dt.Columns[0].ToString();
                    comboBox1.DisplayMember = dt.Columns[1].ToString();
                }

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
示例#14
0
        public Entrada()
        {
            InitializeComponent();
            string query3 = "SELECT * from Articulos";
            clConexion objConexion = new clConexion();
            try
            {
                using (SqlDataAdapter adapter = new SqlDataAdapter(query3, objConexion.conexion()))
                {
                    DataTable dt = new DataTable();
                    adapter.Fill(dt);
                    Producto.DataSource = dt;
                    Producto.ValueMember = dt.Columns[0].ToString();
                    Producto.DisplayMember = dt.Columns[1].ToString();
                }

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
示例#15
0
 public void ActualizaRanchodeCuadrilla(int Cuadrilla, string Rancho)
 {
     string update = "";
     if (eventualesToolStripMenuItem.Checked == true)
         update = "UPDATE Cuadrillas SET RanchoEventual = @Rancho WHERE Id = " + Cuadrilla;
     if (plantaToolStripMenuItem.Checked == true)
         update = "UPDATE Cuadrillas SET Rancho = @Rancho WHERE Id = " + Cuadrilla;
     clConexion objConexion = new clConexion();
     try
     {
         using (SqlCommand updatecmd = new SqlCommand(update, objConexion.conexion()))
         {
             updatecmd.Parameters.AddWithValue("@Rancho", Rancho);
             updatecmd.Connection = objConexion.conexion();
             updatecmd.Connection.Open();
             updatecmd.ExecuteNonQuery();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
示例#16
0
        public Contratos()
        {
            InitializeComponent();
            string query2 = "SELECT * From Actividad";
            clConexion objConexion = new clConexion();

            try
            {
                using (SqlDataAdapter adapter = new SqlDataAdapter(query2, objConexion.conexion()))
                {
                    DataTable dt = new DataTable();
                    adapter.Fill(dt);
                    cbActividad.DataSource = dt;
                    cbActividad.ValueMember = dt.Columns[0].ToString();
                    cbActividad.DisplayMember = dt.Columns[1].ToString();
                }

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
示例#17
0
 ///*****************************************************************
 ///*****************************************************************
 ///*****************************************************************
 ///***********FUNCION PARA CARGAR INFORMACION EN EL KARDEX**********
 ///*****************************************************************
 ///*****************************************************************
 ///*****************************************************************
 ///*****************************************************************
 public void LoadKardexInfo(int NoEmpleado)
 {
     string query = "SELECT Rancho, Fechaing, Puesto, Foto, Zona, Sexo FROM Empleados WHERE Id = " + NoEmpleado;
     clConexion objConexion = new clConexion();
     try
     {
         using (SqlCommand cmd = new SqlCommand(query, objConexion.conexion()))
         {
             SqlDataReader dr;
             cmd.Connection = objConexion.conexion();
             cmd.Connection.Open();
             dr = cmd.ExecuteReader();
             if (dr.HasRows == true)
                 while (dr.Read())
                 {
                     DateTime FechaIngreso = new DateTime();
                     string Fecha_Ingreso = "";
                     txtRancho.Text = "Rancho: " + dr[0].ToString();
                     FechaIngreso = Convert.ToDateTime(dr[1].ToString());
                     Fecha_Ingreso = FechaIngreso.ToString("F", new System.Globalization.CultureInfo("es-ES"));
                     txtFechaIngreso.Text = "Fecha Ingreso: " + Fecha_Ingreso.Substring(0, Fecha_Ingreso.Length - 7);
                     txtPuesto.Text = "Puesto: " + dr[2].ToString();
                     txtZona.Text = "Zona: " + dr[4].ToString();
                     if (dr[3].ToString() == "")
                         if (dr[5].ToString() == "M")
                             pictureBox1.ImageLocation = @"C:/VinedosImages/male-icon.jpg";
                         else if (dr[5].ToString() == "F")
                             pictureBox1.ImageLocation = @"C:/VinedosImages/female-icon.jpg";
                     LoadEmpInfoRanch(NoEmpleado);
                 }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
示例#18
0
 //*************************************************************
 //*************************************************************
 //*************************************************************
 //CARGA LISTA DE SEARCHFUNCTION PARA LA BUSQUEDA DE PALABRASSSS
 //*************************************************************
 //*************************************************************
 //*************************************************************
 public List<SearchFunction> LoadEmp(List<SearchFunction> objSearchFunction)
 {
     clConexion objConexion = new clConexion();
     string query = "SELECT Id, Paterno, Materno, Nombre FROM Empleados";
     try
     {
         using (SqlCommand cmd = new SqlCommand(query, objConexion.conexion()))
         {
             SqlDataReader dr;
             cmd.Connection = objConexion.conexion();
             cmd.Connection.Open();
             dr = cmd.ExecuteReader();
             if (dr.HasRows == true)
                 while (dr.Read())
                     objSearchFunction.Add(new SearchFunction(dr[0].ToString(), dr[1].ToString(), dr[2].ToString(), dr[3].ToString()));
             cmd.Connection.Close();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     return objSearchFunction;
 }
示例#19
0
 /****LLENA LA LISTA PUESTO CON LA TABLA****/
 public List<Puesto> llenarListaPuesto(List<Puesto> puesto)
 {
     clConexion objConexion = new clConexion();
     string queryPuesto = "SELECT * FROM Puestos ORDER BY clave";
     try
     {
         using (SqlCommand cmd = new SqlCommand(queryPuesto, objConexion.conexion()))
         {
             SqlDataReader dr;
             cmd.Connection = objConexion.conexion();
             cmd.Connection.Open();
             dr = cmd.ExecuteReader();
             if (dr.HasRows == false)
                 MessageBox.Show("No Hay Empleados Registrados", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
             else
                 while (dr.Read())
                     //llena arreglo con la tabla Puestos **TODOS LOS CAMPOS**
                     puesto.Add(new Puesto(Convert.ToInt32(dr[0].ToString()), Convert.ToString(dr[1].ToString()),
                         Convert.ToDouble(dr[2].ToString()), Convert.ToDouble(dr[3].ToString()), Convert.ToDouble(dr[4].ToString()),
                         Convert.ToDouble(dr[5].ToString()), Convert.ToDouble(dr[6].ToString()), Convert.ToString(dr[7].ToString())));
             cmd.Connection.Close();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message + " Error del sistema");
     }
     return puesto;
 }
示例#20
0
 public static int DeleteContactoTelefonico(int Id)
 {
     int ban = 0;
     string query = "DELETE FROM DirectorioTelefonico WHERE Id = " + Id;
     clConexion objConexion = new clConexion();
     try
     {
         using (SqlCommand cmd = new SqlCommand(query, objConexion.conexion()))
         {
             cmd.CommandText = query;
             cmd.CommandType = CommandType.Text;
             cmd.Connection = objConexion.conexion();
             cmd.Connection.Open();
             cmd.ExecuteNonQuery();
         }
     }
     catch (Exception ex)
     { ban = 1; }
     return ban;
 }
示例#21
0
        /****CARGA LA LISTA EMPLEADO DESDE LA TABLA****/
        public List<Empleado> llenarListaEmpleado(List<Empleado> empleado)
        {
            string queryEmpleado = "SELECT Id, Paterno, Materno,Nombre, Puesto,Tipo, Rancho, Fechaing, SalarioDiario FROM Empleados WHERE Status = 1 ORDER BY Id";
            clConexion objConexion = new clConexion();
            try
            {
                using (SqlCommand cmd = new SqlCommand(queryEmpleado, objConexion.conexion()))
                {
                    SqlDataReader dr;
                    cmd.Connection = objConexion.conexion();
                    cmd.Connection.Open();
                    dr = cmd.ExecuteReader();
                    if (dr.HasRows == false)
                        MessageBox.Show("No Hay Empleados Registrados", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    else
                        while (dr.Read())
                            //guarda Id, Nombre paterno materno, puesto, tipo empleado y rancho
                            empleado.Add(new Empleado(Convert.ToInt32(dr[0].ToString()), Convert.ToString(dr[1].ToString()),
                                Convert.ToString(dr[2].ToString()), Convert.ToString(dr[3].ToString()), Convert.ToString(dr[4].ToString()),
                                Convert.ToString(dr[5].ToString()), Convert.ToString(dr[6].ToString()),Convert.ToDateTime(dr[7].ToString()),
                                Convert.ToDouble(dr[8].ToString())));
                    //Agregar campo SalarioDiario
                        //sizeEmpleados = i;
                    cmd.Connection.Close();
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + " Error al cargar datos de empleados");
            }
            return empleado;
        }
示例#22
0
 //*** LLENA LA LISTA DE FACTOR INTEGRACION DESDE DB ***\\
 public List<ListFactorIntegracion> llenaFactorIntegracion(List<ListFactorIntegracion> objFactorIntegracion)
 {
     clConexion objConexion = new clConexion();
     string query = "SELECT * FROM Factor_Integracion";
     try
     {
         using (SqlCommand cmd = new SqlCommand(query, objConexion.conexion()))
         {//Carga los datos de ISR
             SqlDataReader dr;
             cmd.Connection = objConexion.conexion();
             cmd.Connection.Open();
             dr = cmd.ExecuteReader();
             if (dr.HasRows == false)
                 MessageBox.Show("Error con datos de Factor de integracion", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
             else
             {
                 while (dr.Read())
                     //guarda la info en la lista
                     objFactorIntegracion.Add(new ListFactorIntegracion(Convert.ToInt32(dr[0].ToString()), Convert.ToInt32(dr[1].ToString()),
                         Convert.ToInt32(dr[2].ToString()), Convert.ToDouble(dr[3].ToString()), Convert.ToInt32(dr[4].ToString()),
                         Convert.ToInt32(dr[5].ToString()), Convert.ToDouble(dr[6].ToString()), Convert.ToDouble(dr[7].ToString()),
                         Convert.ToDouble(dr[8].ToString())));
             }
             cmd.Connection.Close();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     //Regresa el objeto Lista
     return objFactorIntegracion;
 }
示例#23
0
        //***--------|||-------***\\
        /****LLENA ARREGLOS CON TABLAS DE ISR****/
        public void llenaArrISR()
        {
            clConexion objConexion = new clConexion();
            string queryEmpleado = "SELECT * FROM Isr_Cuota";
            try
            {
                using (SqlCommand cmd = new SqlCommand(queryEmpleado, objConexion.conexion()))
                {//Carga los datos de ISR
                    SqlDataReader dr;
                    cmd.Connection = objConexion.conexion();
                    cmd.Connection.Open();
                    dr = cmd.ExecuteReader();
                    if (dr.HasRows == false)
                        MessageBox.Show("Error con datos de ISR", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    else
                    {
                        int i = 0;
                        while (dr.Read())
                        {
                            //guarda Limite inferior, superior, cuota fija y porcentaje
                            arrISR[0, i] = Convert.ToDouble(dr[0].ToString());
                            arrISR[1, i] = Convert.ToDouble(dr[1].ToString());
                            arrISR[2, i] = Convert.ToDouble(dr[2].ToString());
                            arrISR[3, i] = Convert.ToDouble(dr[3].ToString());
                            i++;
                        }

                    }
                    cmd.Connection.Close();
                }
                queryEmpleado = "SELECT * FROM Isr_Subsidio";
                using (SqlCommand cmd = new SqlCommand(queryEmpleado, objConexion.conexion()))
                {//Carga los datos de subsidio para ISR
                    SqlDataReader dr;
                    cmd.Connection = objConexion.conexion();
                    cmd.Connection.Open();
                    dr = cmd.ExecuteReader();
                    if (dr.HasRows == false)
                        MessageBox.Show("Error con datos de ISR", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    else
                    {
                        int j = 0;
                        while (dr.Read())
                        {
                            //inferior, superior y subsidio
                            arrSubsidio[0, j] = Convert.ToDouble(dr[0].ToString());
                            arrSubsidio[1, j] = Convert.ToDouble(dr[1].ToString());
                            arrSubsidio[2, j] = Convert.ToDouble(dr[2].ToString());
                            j++;
                        }
                    }
                    cmd.Connection.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + " No se puede cargar datos de ISR");
            }
        }
示例#24
0
 //Crea tabla previa a calculo de costos
 public List<ListCostoManoObra> GeneraTablaCosto(List<ListCostoManoObra> objCostoManoObra, string queryPlanta)
 {
     List<Puesto> objPuesto = new List<Puesto>();
     List<Empleado> objEmpleado = new List<Empleado>();
     objPuesto = llenarListaPuesto(objPuesto);
     objEmpleado = llenarListaEmpleado(objEmpleado);
     clConexion objConexion = new clConexion();
     try
     {
         //Listar Empleados de Planta en la Nomina\\
         using (SqlCommand cmd = new SqlCommand(queryPlanta, objConexion.conexion()))
         {
             SqlDataReader dr;
             cmd.Connection = objConexion.conexion();
             cmd.Connection.Open();
             dr = cmd.ExecuteReader();
             if (dr.HasRows == false)
                 MessageBox.Show("No hay registros de Asistencia", "PLANTA", MessageBoxButtons.OK, MessageBoxIcon.Error);
             else
             {
                 while (dr.Read())
                 {
                     int Id_Empleado = int.Parse(dr[0].ToString());
                     DateTime Fecha = Convert.ToDateTime(dr[1].ToString());
                     int HorasExtra = int.Parse(dr[2].ToString());
                     int Asistencias = int.Parse(dr[3].ToString());
                     string Actividad = dr[4].ToString();
                     string Lote = dr[5].ToString();
                     string Rancho = dr[6].ToString();
                     string Puesto = "";
                     double SalarioDiario = 0, Otros = 0;
                     foreach (Empleado empleado in objEmpleado)//busca puesto de empleado
                         if (empleado.Id == Id_Empleado)
                         { Puesto = empleado.Puesto; break; }
                     foreach (Puesto puesto in objPuesto)//busca salario y otros ingresos del empleado segun su puesto
                         if (puesto.NomPuesto == Puesto)
                         {
                             SalarioDiario = puesto.Sueldo;
                             Otros = puesto.Otros;
                             break;
                         }
                     objCostoManoObra.Add(new ListCostoManoObra(Id_Empleado, SalarioDiario, Otros, Rancho, Lote, Actividad, HorasExtra, Fecha));
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     return objCostoManoObra;
 }
示例#25
0
 public List<Consultas.SalidaCosto> fillSalidas(List<Consultas.SalidaCosto> objSalida, string rancho, string lote)
 {
     string query =
         "SELECT Producto, UM, Rancho, Importe FROM salidas WHERE Rancho = '" + rancho + "' AND Lote = '" + lote + "'";
     clConexion objConexion = new clConexion();
     try
     {
         //Listar Empleados de Planta en la Nomina\\
         using (SqlCommand cmd = new SqlCommand(query, objConexion.conexion()))
         {
             SqlDataReader dr;
             cmd.Connection = objConexion.conexion();
             cmd.Connection.Open();
             dr = cmd.ExecuteReader();
             if (dr.HasRows == true)
             {
                 while (dr.Read())
                     objSalida.Add(new Consultas.SalidaCosto(dr[0].ToString(), dr[1].ToString(),
                         dr[2].ToString(), Convert.ToDouble(dr[3].ToString())));
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     return objSalida;
 }
示例#26
0
 //carga datos de Ranchos en lista
 public List<ListRanchos> cargaRanchos(List<ListRanchos> objRanchos)
 {
     string queryPlanta = "SELECT * FROM R";
     clConexion objConexion = new clConexion();
     try
     {
         //Listar Empleados de Planta en la Nomina\\
         using (SqlCommand cmd = new SqlCommand(queryPlanta, objConexion.conexion()))
         {
             SqlDataReader dr;
             cmd.Connection = objConexion.conexion();
             cmd.Connection.Open();
             dr = cmd.ExecuteReader();
             if (dr.HasRows == false)
                 MessageBox.Show("No hay registros de Ranchos", "Ranchos", MessageBoxButtons.OK, MessageBoxIcon.Error);
             else
             {
                 while (dr.Read())
                     objRanchos.Add(new ListRanchos(dr[0].ToString(), dr[1].ToString(),
                         dr[2].ToString(), Convert.ToDouble(dr[3].ToString())));
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     return objRanchos;
 }
示例#27
0
 //carga la lista Lotes de la DB
 public List<ListLotes> cargaListalotes(List<ListLotes> objLotes, string RanchoValue)
 {
     string query = "SELECT * FROM Lotes WHERE Rancho ='" + RanchoValue + "'";
     clConexion objConexion = new clConexion();
     int index = 0;
     try
     {
         using (SqlCommand cmd = new SqlCommand(query, objConexion.conexion()))
         {
             SqlDataReader dr;
             cmd.Connection = objConexion.conexion();
             cmd.Connection.Open();
             dr = cmd.ExecuteReader();
             if (dr.HasRows == true)
                 while (dr.Read())
                     objLotes.Add(new ListLotes(index++, dr[0].ToString(), dr[1].ToString(),
                         dr[2].ToString(), Convert.ToDouble(dr[3].ToString()),
                         dr[4].ToString(), Convert.ToDouble(dr[5].ToString())));
             cmd.Connection.Close();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message + "LOTES");
     }
     return objLotes;
 }
示例#28
0
 /****TRAE EL MAXIMO DE NOMINA****/
 public int maximo_Nomina()
 {
     int maximo=0;
     string query = "select max(idNomina) from Reg_NominaPlanta";
     clConexion objConexion = new clConexion();
     try
     {
         using (SqlCommand cmd = new SqlCommand(query, objConexion.conexion()))
         {
             cmd.CommandText = query;
             cmd.CommandType = CommandType.Text;
             cmd.Connection = objConexion.conexion();
             cmd.Connection.Open();
             maximo = Convert.ToInt32(cmd.ExecuteScalar());
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     maximo += 1;
     return maximo;
 }
示例#29
0
 //carga la lista actividades desde la DB
 public List<ListActividades> cargaListaActividades(List<ListActividades> objActividades)
 {
     string query = "SELECT * FROM Actividad ORDER BY Clave";
     clConexion objConexion = new clConexion();
     try
     {
         using (SqlCommand cmd = new SqlCommand(query, objConexion.conexion()))
         {
             SqlDataReader dr;
             cmd.Connection = objConexion.conexion();
             cmd.Connection.Open();
             dr = cmd.ExecuteReader();
             if (dr.HasRows == false)
                 MessageBox.Show("No Hay Actividades Registradas", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
             else
                 while (dr.Read())
                     objActividades.Add(new ListActividades(int.Parse(dr[0].ToString()), dr[1].ToString()));
             cmd.Connection.Close();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     return objActividades;
 }
示例#30
0
        //**** OBTIENE LAS HORAS EXTRA EN DOMINGO PARA CALCULAR PRIMA DOMINICAL****\\
        public int HExtraDomingo(int NoEmpleado)
        {
            int HExtraDomingo = 0;
            clConexion objConexion = new clConexion();
            string queryEmpleado = "SELECT * FROM Asistencia_Planta WHERE Id_Empleado = "+NoEmpleado;
            try
            {
                using (SqlCommand cmd = new SqlCommand(queryEmpleado, objConexion.conexion()))
                {//Carga los datos de la asistencia de planta segun el NoEmpleado
                    SqlDataReader dr;
                    cmd.Connection = objConexion.conexion();
                    cmd.Connection.Open();
                    dr = cmd.ExecuteReader();
                    if (dr.HasRows == false)
                        MessageBox.Show("Error al cargar datos del Empleado: " + NoEmpleado, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    else
                    {
                        while (dr.Read())
                        {
                            //busca el dia Domingo en la asistencia del empleado y obtiene las horas extra para sacar la prima dominical

                            DateTime dt = Convert.ToDateTime(dr[1].ToString());
                            string DiaSemana = dt.DayOfWeek.ToString();
                            if (DiaSemana == "Sunday" && Convert.ToInt32(dr[3].ToString()) != 0)//Verifica si el dia de asistencia del empleado es Domingo (Sunday)
                                HExtraDomingo = Convert.ToInt32(dr[3].ToString());//Extrae las horas extra trabajas si es Domingo
                        }
                    }
                    cmd.Connection.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            return HExtraDomingo;
        }