public bool Delete(string empresaid, tb_plla_rubrosafectosleyestrabempl BE)
 {
     using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
     {
         using (SqlCommand cmd = new SqlCommand("gspTbPllaRubrosingreso_DELETE", cnx))
         {
             {
                 cmd.CommandType = CommandType.StoredProcedure;
                 cmd.Parameters.Add("@tipoplla", SqlDbType.Char, 1).Value = BE.tipoplla;
                 cmd.Parameters.Add("@rubroid", SqlDbType.Char, 3).Value = BE.rubroid;
             }
             try
             {
                 cnx.Open();
                 if (cmd.ExecuteNonQuery() > 0)
                 {
                     return true;
                 }
                 else
                 {
                     return false;
                 }
             }
             catch (Exception ex)
             {
                 Sql_Error = ex.Message;
                 throw new Exception(ex.Message);
             }
         }
     }
 }
 public bool Delete(string empresaid, tb_plla_rubrosafectosleyestrabempl BE)
 {
     //return tablaDA.Delete(empresaid, BE);
     bool zreturn = tablaDA.Delete(empresaid, BE);
     Sql_Error = tablaDA.Sql_Error;
     return zreturn;
 }
 public DataSet GetMAX_CODIGORUBROPLANILLA(string empresaid, tb_plla_rubrosafectosleyestrabempl BE)
 {
     //return tablaDA.GetAll_CONSULTA(empresaid, BE);
     DataSet xreturn = null;
     xreturn = tablaDA.GetMAX_CODIGORUBROPLANILLA(empresaid, BE);
     Sql_Error = tablaDA.Sql_Error;
     return xreturn;
 }
 public DataSet GetAll_IR(string empresaid, tb_plla_rubrosafectosleyestrabempl BE)
 {
     //return tablaDA.GetAll_IR(empresaid, BE);
     DataSet xreturn = null;
     xreturn = tablaDA.GetAll_IR(empresaid, BE);
     Sql_Error = tablaDA.Sql_Error;
     return xreturn;
 }
        private void save()
        {
            if (u_Validate())
            {
                if (Examinar.IsCurrentCellInEditMode)
                {
                    Examinar.CommitEdit(DataGridViewDataErrorContexts.Commit);
                }
                Tabla.AcceptChanges();
                for (lc_cont = 0; lc_cont <= Tabla.Rows.Count - 1; lc_cont++)
                {
                    Tabla.Rows[lc_cont]["perianio"] = spnperiodo.Value.ToString();
                    Tabla.Rows[lc_cont]["perimes"] = cboMes.SelectedValue;
                    Tabla.Rows[lc_cont]["tipoplla"] = cboTipoplanilla.SelectedValue;
                }
                Tabla.AcceptChanges();

                var BL = new tb_plla_rubrosafectosleyestrabemplBL();
                var BE = new tb_plla_rubrosafectosleyestrabempl();

                BE.perianio = spnperiodo.Value.ToString();
                BE.perimes = cboMes.SelectedValue.ToString();
                BE.tipoplla = cboTipoplanilla.SelectedValue.ToString();
                if (BL.Insert_Update(VariablesPublicas.EmpresaID, BE, Tabla))
                {
                    U_CancelarEdicion(0);
                }
                else
                {
                    Frm_Class.ShowError(BL.Sql_Error, this);
                }
            }
        }
 private void CargaDatos()
 {
     var xcodmes = "99";
     var xtipoplanilla = ".";
     var sorted = default(SortOrder);
     var xnomcolumna = string.Empty;
     if (cboMes.SelectedValue != null)
     {
         xcodmes = cboMes.SelectedValue.ToString();
     }
     if (cboTipoplanilla.SelectedValue != null)
     {
         xtipoplanilla = cboTipoplanilla.SelectedValue.ToString();
     }
     if (Examinar.SortedColumn != null)
     {
         xnomcolumna = Examinar.Columns[Examinar.SortedColumn.Index].Name;
         sorted = Examinar.SortOrder;
     }
     var BL = new tb_plla_rubrosafectosleyestrabemplBL();
     var BE = new tb_plla_rubrosafectosleyestrabempl();
     BE.perianio = spnperiodo.Value.ToString();
     BE.perimes = xcodmes;
     BE.tipoplla = xtipoplanilla;
     Tabla = BL.GetAll_CONSULTA(VariablesPublicas.EmpresaID, BE).Tables[0];
     Examinar.AutoGenerateColumns = false;
     Examinar.DataSource = Tabla;
 }
 public bool Update(string empresaid, tb_plla_rubrosafectosleyestrabempl BE)
 {
     using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
     {
         using (SqlCommand cmd = new SqlCommand("gspTbPllaRubrosingreso_UPDATE", cnx))
         {
             {
                 cmd.CommandTimeout = 0;
                 cmd.CommandType = CommandType.StoredProcedure;
                 cmd.Parameters.Add("@tipoplla", SqlDbType.Char, 1).Value = BE.tipoplla;
                 cmd.Parameters.Add("@perianio", SqlDbType.Char, 4).Value = BE.perianio;
                 cmd.Parameters.Add("@perimes", SqlDbType.Char, 2).Value = BE.perimes;
                 cmd.Parameters.Add("@rubroid", SqlDbType.Char, 3).Value = BE.rubroid;
                 cmd.Parameters.Add("@onpt", SqlDbType.Decimal).Value = BE.onpt;
                 cmd.Parameters.Add("@essaludt", SqlDbType.Decimal).Value = BE.essaludt;
                 cmd.Parameters.Add("@senatit", SqlDbType.Decimal).Value = BE.senatit;
                 cmd.Parameters.Add("@sctrt", SqlDbType.Decimal).Value = BE.sctrt;
                 cmd.Parameters.Add("@otrost", SqlDbType.Decimal).Value = BE.otrost;
                 cmd.Parameters.Add("@onpe", SqlDbType.Decimal).Value = BE.onpe;
                 cmd.Parameters.Add("@essalude", SqlDbType.Decimal).Value = BE.essalude;
                 cmd.Parameters.Add("@senatie", SqlDbType.Decimal).Value = BE.senatie;
                 cmd.Parameters.Add("@sctre", SqlDbType.Decimal).Value = BE.sctre;
                 cmd.Parameters.Add("@otrose", SqlDbType.Decimal).Value = BE.otrose;
             }
             try
             {
                 cnx.Open();
                 if (cmd.ExecuteNonQuery() > 0)
                 {
                     return true;
                 }
                 else
                 {
                     return false;
                 }
             }
             catch (Exception ex)
             {
                 Sql_Error = ex.Message;
                 throw new Exception(ex.Message);
             }
         }
     }
 }
        public bool Insert_Update(string empresaid, tb_plla_rubrosafectosleyestrabempl BE, DataTable TablaDatos)
        {
            using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
            {
                bool xreturn = true;
                int lcont = 0;
                using (SqlCommand cmd = new SqlCommand("gspTbPllaRubrosafectosleyestrabempl_Eliminar_A", cnx))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add("@perianio", SqlDbType.Char, 4).Value = BE.perianio;
                    cmd.Parameters.Add("@perimes", SqlDbType.Char, 2).Value = BE.perimes;
                    cmd.Parameters.Add("@tipoplla", SqlDbType.Char, 1).Value = BE.tipoplla;
                    try
                    {
                        cnx.Open();
                        if (cmd.ExecuteNonQuery() > 0)
                        {
                            xreturn = true;
                        }
                        else
                        {
                            xreturn = false;
                        }
                        cnx.Close();
                    }
                    catch (Exception ex)
                    {
                        Sql_Error = ex.Message;
                        //throw new Exception(ex.Message);
                        xreturn = false;
                        cnx.Close();
                    }
                }
                for (lcont = 0; lcont <= TablaDatos.Rows.Count - 1; lcont++)
                {
                    using (SqlCommand cmd = new SqlCommand("gspTbPllaRubrosafectosleyestrabempl_InsertUpdate", cnx))
                    {
                        cmd.CommandTimeout = 0;
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add("@tipoplla", SqlDbType.Char, 1).Value = TablaDatos.Rows[lcont]["tipoplla"];
                        cmd.Parameters.Add("@perianio", SqlDbType.Char, 4).Value = TablaDatos.Rows[lcont]["perianio"];
                        cmd.Parameters.Add("@perimes", SqlDbType.Char, 2).Value = TablaDatos.Rows[lcont]["perimes"];
                        cmd.Parameters.Add("@rubroid", SqlDbType.Char, 3).Value = TablaDatos.Rows[lcont]["rubroid"];
                        cmd.Parameters.Add("@onpt", SqlDbType.Decimal).Value = TablaDatos.Rows[lcont]["onpt"];
                        cmd.Parameters.Add("@essaludt", SqlDbType.Decimal).Value = TablaDatos.Rows[lcont]["essaludt"];
                        cmd.Parameters.Add("@senatit", SqlDbType.Decimal).Value = TablaDatos.Rows[lcont]["senatit"];
                        cmd.Parameters.Add("@sctrt", SqlDbType.Decimal).Value = TablaDatos.Rows[lcont]["sctrt"];
                        cmd.Parameters.Add("@otrost", SqlDbType.Decimal).Value = TablaDatos.Rows[lcont]["otrost"];
                        cmd.Parameters.Add("@onpe", SqlDbType.Decimal).Value = TablaDatos.Rows[lcont]["onpe"];
                        cmd.Parameters.Add("@essalude", SqlDbType.Decimal).Value = TablaDatos.Rows[lcont]["essalude"];
                        cmd.Parameters.Add("@senatie", SqlDbType.Decimal).Value = TablaDatos.Rows[lcont]["senatie"];
                        cmd.Parameters.Add("@sctre", SqlDbType.Decimal).Value = TablaDatos.Rows[lcont]["sctre"];
                        cmd.Parameters.Add("@otrose", SqlDbType.Decimal).Value = TablaDatos.Rows[lcont]["otrose"];

                        try
                        {
                            cnx.Open();
                            if (cmd.ExecuteNonQuery() > 0)
                            {
                                xreturn = true;
                            }
                            else
                            {
                                xreturn = false;
                            }
                            cnx.Close();
                        }
                        catch (Exception ex)
                        {
                            Sql_Error = ex.Message;
                            //throw new Exception(ex.Message);
                            xreturn = false;
                            cnx.Close();
                        }
                    }
                }
                return xreturn;
            }
        }
        public DataSet GetOne(string empresaid, tb_plla_rubrosafectosleyestrabempl BE)
        {
            using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
            {
                using (SqlCommand cmd = new SqlCommand("gspTbPllaRubrosingreso_SELECT", cnx))
                {
                    DataSet ds = new DataSet();
                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add("@tipoplla", SqlDbType.Char, 1).Value = BE.tipoplla;
                        cmd.Parameters.Add("@rubroid", SqlDbType.Char, 3).Value = BE.rubroid;
                    }

                    try
                    {
                        cnx.Open();
                        using (SqlDataAdapter da = new SqlDataAdapter(cmd))
                        {
                            da.Fill(ds);
                        }
                        return ds;
                    }
                    catch (Exception ex)
                    {
                        Sql_Error = ex.Message;
                        throw new Exception(ex.Message);
                    }
                }
            }
        }
 public DataSet GetAll_CONSULTA1(string empresaid, tb_plla_rubrosafectosleyestrabempl BE)
 {
     using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
     {
         using (SqlCommand cmd = new SqlCommand("gspTbPllaRubrosingreso_CONSULTA1", cnx))
         {
             DataSet ds = new DataSet();
             {
                 cmd.CommandType = CommandType.StoredProcedure;
                 cmd.Parameters.Add("@rubroid", SqlDbType.Char, 3).Value = BE.rubroid;
                 cmd.Parameters.Add("@tipoplla", SqlDbType.Char, 1).Value = BE.tipoplla;
                 cmd.Parameters.Add("@descriplike1", SqlDbType.VarChar, 60).Value = BE.descriplike1;
                 cmd.Parameters.Add("@descriplike2", SqlDbType.VarChar, 60).Value = BE.descriplike2;
                 cmd.Parameters.Add("@descriplike3", SqlDbType.VarChar, 60).Value = BE.descriplike3;
                 cmd.Parameters.Add("@norden", SqlDbType.Int).Value = BE.norden;
                 cmd.Parameters.Add("@incluir_blanco", SqlDbType.Int).Value = BE.incluir_blanco;
                 cmd.Parameters.Add("@nestado", SqlDbType.Int).Value = BE.nestado;
                 cmd.Parameters.Add("@descartarrubros", SqlDbType.VarChar, 50).Value = BE.descartarrubros;
             }
             try
             {
                 cnx.Open();
                 using (SqlDataAdapter da = new SqlDataAdapter(cmd))
                 {
                     da.Fill(ds);
                 }
                 return ds;
             }
             catch (Exception ex)
             {
                 Sql_Error = ex.Message;
                 throw new Exception(ex.Message);
             }
         }
     }
 }
 public DataSet GetAll(string empresaid, tb_plla_rubrosafectosleyestrabempl BE)
 {
     using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
     {
         using (SqlCommand cmd = new SqlCommand("gspTbPllaRubrosingreso_SEARCH", cnx))
         {
             DataSet ds = new DataSet();
             {
                 cmd.CommandType = CommandType.StoredProcedure;
                 cmd.Parameters.Add("@tipoplla", SqlDbType.Char, 1).Value = BE.tipoplla;
                 cmd.Parameters.Add("@perianio", SqlDbType.Char, 4).Value = BE.perianio;
                 cmd.Parameters.Add("@perimes", SqlDbType.Char, 2).Value = BE.perimes;
                 cmd.Parameters.Add("@rubroid", SqlDbType.Char, 3).Value = BE.rubroid;
                 //cmd.Parameters.Add("@onpt", SqlDbType.Decimal).Value = BE.onpt;
                 //cmd.Parameters.Add("@essaludt", SqlDbType.Decimal).Value = BE.essaludt;
                 //cmd.Parameters.Add("@senatit", SqlDbType.Decimal).Value = BE.senatit;
                 //cmd.Parameters.Add("@sctrt", SqlDbType.Decimal).Value = BE.sctrt;
                 //cmd.Parameters.Add("@otrost", SqlDbType.Decimal).Value = BE.otrost;
                 //cmd.Parameters.Add("@onpe", SqlDbType.Decimal).Value = BE.onpe;
                 //cmd.Parameters.Add("@essalude", SqlDbType.Decimal).Value = BE.essalude;
                 //cmd.Parameters.Add("@senatie", SqlDbType.Decimal).Value = BE.senatie;
                 //cmd.Parameters.Add("@sctre", SqlDbType.Decimal).Value = BE.sctre;
                 //cmd.Parameters.Add("@otrose", SqlDbType.Decimal).Value = BE.otrose;
             }
             try
             {
                 cnx.Open();
                 using (SqlDataAdapter da = new SqlDataAdapter(cmd))
                 {
                     da.Fill(ds);
                 }
                 return ds;
             }
             catch (Exception ex)
             {
                 Sql_Error = ex.Message;
                 throw new Exception(ex.Message);
             }
         }
     }
 }
 public bool Insert_Update(string empresaid, tb_plla_rubrosafectosleyestrabempl BE, DataTable TablaDatos)
 {
     //return tablaDA.Insert(empresaid, BE);
     bool zreturn = tablaDA.Insert_Update(empresaid, BE, TablaDatos);
     Sql_Error = tablaDA.Sql_Error;
     return zreturn;
 }