Ejemplo n.º 1
0
        private void bindingNavigatorAddNewItem_Click(object sender, EventArgs e)
        {
            codEmps = new List<int>();
            eSTADO_NOMINATextBox.Text = "1";

            hRM_ENC_NOMINABindingNavigatorSaveItem.Enabled = true;
            ClaseConexion conn2 = new ClaseConexion();
            hRM_DET_NOMINADataGridView.Visible = false;
            dataGridView1.Visible = true;
            string consultagrid = "SELECT HRM_EMPLEADO.COD_EMPLEADO, NOM_PRIMARIO, APELLIDOS, SALARIO, TIPO_INGRESO, VAL_INGRESO, TIPO_DEDUCCION, SALARIO * (VAL_DEDUCCION / 100) as Descuento, VAL_INGRESO + (SALARIO - SALARIO * (VAL_DEDUCCION / 100)) as Sueldo_Neto FROM  [Nomina].[dbo].[HRM_EMPLEADO] inner join Nomina.dbo.HRM_MADEDUCCION on HRM_EMPLEADO.COD_AREA = HRM_MADEDUCCION.COD_EMPLEADO inner join Nomina.dbo.HRM_ENC_DEDUCCION on HRM_MADEDUCCION.COD_ENC_DEDUCCION = HRM_ENC_DEDUCCION.COD_ENC_DEDUCCION  inner join  Nomina.dbo.HRM_DEDUCCION on HRM_ENC_DEDUCCION.COD_ENC_DEDUCCION = HRM_DEDUCCION.COD_ENC_DEDUCCION, Nomina.dbo.HRM_INGRESO ";
            //SqlCommand ejecugrid = new SqlCommand(consultagrid, conn);
            //ejecugrid.ExecuteNonQuery();
            DataTable tabla = new DataTable();
            SqlDataAdapter consultag2 = new SqlDataAdapter(consultagrid, conn2.abrirconexion());
            consultag2.Fill(tabla);
            dataGridView1.DataSource = tabla;
            //Me.DataGridView3.DefaultCellStyle.WrapMode = DataGridViewTriState.True
            this.dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
               int rango = dataGridView1.Rows.Count;
               Console.WriteLine(rango);
               try
               {

               foreach (DataGridViewRow row in dataGridView1.Rows)
               {
                   // string valorcol2 = row.Cells[1].Text;
                   codEmps.Add(Convert.ToInt32(row.Cells[0].Value));
                   brutos.Add(Convert.ToDecimal(row.Cells[3].Value));
                   netos.Add(Convert.ToDecimal(row.Cells[8].Value));
                   String seleccionaencombo = row.Cells[3].Value.ToString() + " " +row.Cells[8].Value.ToString();
                   Console.WriteLine(seleccionaencombo);
               }
               }
               catch (Exception)
               {

               }

            //for (int it = 0; it < rango -1; it++)
            //{
            //    Console.WriteLine(it);
            //    String seleccionaencombo = Convert.ToDecimal(dataGridView1.Rows.SharedRow(it).Cells[3].Value);
            //    Console.WriteLine(seleccionaencombo.ToString());
            ////    //String seleccionaencombo2 = dataGridView1.Rows.SharedRow(i).Cells[7].Value.ToString();
            ////    //Console.WriteLine(seleccionaencombo2);
            //}
               fEC_NOMINADateTimePicker.Text = "";
               fEC_PERIODODateTimePicker.Text = "";
        }
Ejemplo n.º 2
0
        private void DeduccionXarea_Load(object sender, EventArgs e)
        {
            DataGridView3.Visible = false;

             SqlConnection conn = new SqlConnection(connstring);
            conn.Open();
               ClaseConexion conn2 = new ClaseConexion();

            SqlDataAdapter consulta3 = new SqlDataAdapter("SELECT TOP 1000 [COD_AREA] as Codigo, [DES_AREA] as Area, [ESTADO_AREA] as Estado FROM [Nomina].[dbo].[HRM_AREA]", conn2.abrirconexion());

            DataSet ds = new DataSet();
            consulta3.Fill(ds, "HRM_AREA");
            ComboBox1.DataSource = ds.Tables[0];
            ComboBox1.ValueMember = "Area";

            SqlDataAdapter consulta2 = new SqlDataAdapter("SELECT TOP 1000 [COD_ENC_DEDUCCION], [TIPO_DEDUCCION], [ESTADO_DEDU] FROM [Nomina].[dbo].[HRM_ENC_DEDUCCION]", conn2.abrirconexion());
            DataSet ds2 = new DataSet();
            consulta2.Fill(ds2, "HRM_ENC_DEDUCCION");
            ComboBox2.DataSource = ds2.Tables[0];
            ComboBox2.ValueMember = "TIPO_DEDUCCION";

            //SqlDataAdapter consulta = new SqlDataAdapter("SELECT TOP 1000 [COD_AREA], [DES_AREA], [ESTADO_AREA] FROM [Nomina].[dbo].[HRM_AREA] INNER JOIN [Nomina].[dbo].[HRM_MADEDUCCION] ON HRM_AREA.COD_AREA = HRM_MADEDUCCION.COD_EMPLEADO", conn);
            //SqlDataAdapter consulta = new SqlDataAdapter("SELECT TOP 1000 [COD_AREA] as Codigo, [DES_AREA] as Area, [ESTADO_AREA] as Estado FROM [Nomina].[dbo].[HRM_AREA] where ESTADO_AREA = 1", conn2.abrirconexion());

            //    DataSet ds3 = new DataSet();
            //consulta.Fill(ds3, "HRM_AREA");
            //DataGridView2.DataSource = ds3.Tables[0];
            //DataGridView2.DefaultCellStyle.WrapMode = DataGridViewTriState.True;
            //DataGridView2.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;

            string consulta = "SELECT COD_AREA as Codigo, DES_AREA as Area, ESTADO_AREA as Estado FROM Nomina.dbo.HRM_AREA where ESTADO_AREA like '%1%' ";
               DataTable tabla = new DataTable();

            SqlDataAdapter consulta5 = new SqlDataAdapter(consulta, conn2.abrirconexion());
            consulta5.Fill(tabla);
            DataGridView2.DataSource = tabla;
            DataGridView2.DefaultCellStyle.WrapMode = DataGridViewTriState.True;
            DataGridView2.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;

            conn.Close();
        }
Ejemplo n.º 3
0
        private void Button1_Click(object sender, EventArgs e)
        {
            ClaseConexion conn2 = new ClaseConexion();
            //DataGridView1.Rows.Add(ComboBox2.Text);
            DataGridViewRow row = new DataGridViewRow();
            row.SetValues(ComboBox2.Text);

            //for (int i = 0; i < DataGridView1.Rows.Count - 1; i++)
            //{
                //if (DataGridView1.Rows.SharedRow(i).Cells[0].Value.ToString() != ComboBox2.SelectedText)
                //{
                    //DataGridView1.Rows.Add(ComboBox2.Text);
               // }

               // }
                    List<String> datos = new List<string>();

                    for (int i = 0; i < DataGridView1.Rows.Count - 1; i++)
                    {
                        string dato;
                        dato = DataGridView1.Rows.SharedRow(i).Cells[0].Value.ToString();
                        //DataGridView1.Rows.Add(ComboBox2.Text);
                        //DataGridView1.DataSource
                        datos.Add(dato);
                    }
                    if (datos.Contains(ComboBox2.Text))
                    {
                        Console.WriteLine("repetido");
                    }
                    else {
                        //nuevos = new List<int>();
                        DataGridView1.Rows.Add(ComboBox2.Text);
                        string tipo = ComboBox2.SelectedValue.ToString();
                        SqlCommand consultan = new SqlCommand("SELECT TOP 1 [COD_ENC_DEDUCCION] FROM [Nomina].[dbo].[HRM_ENC_DEDUCCION] where HRM_ENC_DEDUCCION.TIPO_DEDUCCION like '%" + tipo + "%'", conn2.abrirconexion());
                        int encdeduccion = Convert.ToInt32(consultan.ExecuteScalar());
                        //int encdeduccion = ;//.Columns[0].ToString());
                        //Console.WriteLine(encdeduccion);
                        //listadetalles.Add(encdeduccion);
                        nuevos.Add(encdeduccion);
                        //Console.WriteLine("repetido");
                    }
        }
Ejemplo n.º 4
0
        private void hRM_ENC_NOMINABindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            this.Validate();
            this.hRM_ENC_NOMINABindingSource.EndEdit();
            this.tableAdapterManager.UpdateAll(this.nominaDataSet);
            ClaseConexion conn2 = new ClaseConexion();
            SqlCommand consultan = new SqlCommand("SELECT TOP 1 [COD_ENCNOMINA] FROM [Nomina].[dbo].[HRM_ENC_NOMINA] order by COD_ENCNOMINA desc", conn2.abrirconexion());
            int encnomina = Convert.ToInt32(consultan.ExecuteScalar());
            int Contro = 0;
            try
            {
                foreach (int i2 in codEmps)
                {

                    Console.WriteLine("insert");
                    Console.WriteLine(i2);

                    string inserta = "INSERT INTO [dbo].[HRM_DET_NOMINA]([CAN_SUELDOBRUTO],[CAN_SUELDONETO],[COD_EMPLEADO],[COD_ENCNOMINA]) VALUES (@bruto, @neto, @codemple, @encnomina)";

                    SqlCommand Comando = new SqlCommand(inserta, conn2.abrirconexion());
                    Comando.Parameters.AddWithValue("@bruto", brutos[Contro]);
                    Comando.Parameters.AddWithValue("@neto", netos[Contro]);
                    Comando.Parameters.AddWithValue("@codemple", i2);
                    Comando.Parameters.AddWithValue("@encnomina", encnomina);
                    Comando.ExecuteNonQuery();
                    Contro++;
                }
            }
            catch (Exception)
            {
            }
        }