public bool Delete(string empresaid, tb_plla_valor_uit BE)
 {
     using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
     {
         using (SqlCommand cmd = new SqlCommand("[gspTbPllavalorUIT_DELETE", cnx))
         {
             {
                 cmd.CommandType = CommandType.StoredProcedure;
                 cmd.Parameters.Add("@perianio", SqlDbType.Char).Value = BE.perianio;
             }
             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(string empresaid, tb_plla_valor_uit BE)
 {
     //return tablaDA.Insert(empresaid, BE);
     bool zreturn = tablaDA.Insert(empresaid, BE);
     Sql_Error = tablaDA.Sql_Error;
     return zreturn;
 }
 public DataSet GetOne(string empresaid, tb_plla_valor_uit BE)
 {
     //return tablaDA.GetOne(empresaid, tipoplla);
     DataSet xreturn = null;
     xreturn = tablaDA.GetOne(empresaid, BE);
     Sql_Error = tablaDA.Sql_Error;
     return xreturn;
 }
 public DataSet GetAll_MaxCodigo(string empresaid, tb_plla_valor_uit BE)
 {
     //return tablaDA.GetAll_MaxRubro(empresaid, BE);
     DataSet xreturn = null;
     xreturn = tablaDA.GetAll_MaxCodigo(empresaid, BE);
     Sql_Error = tablaDA.Sql_Error;
     return xreturn;
 }
 public DataSet GetAll_CONSULTAIR(string empresaid, tb_plla_valor_uit BE)
 {
     //return tablaDA.GetAll_CONSULTAIR(empresaid, BE);
     DataSet xreturn = null;
     xreturn = tablaDA.GetAll_CONSULTAIR(empresaid, BE);
     Sql_Error = tablaDA.Sql_Error;
     return xreturn;
 }
 public DataSet GetAll(string empresaid, tb_plla_valor_uit BE)
 {
     using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
     {
         using (SqlCommand cmd = new SqlCommand("[gspTbPllavalorUIT_SEARCH", cnx))
         {
             DataSet ds = new DataSet();
             {
                 cmd.CommandType = CommandType.StoredProcedure;
                 cmd.Parameters.Add("@perianio", SqlDbType.Char).Value = BE.perianio;
                 cmd.Parameters.Add("@perimes", SqlDbType.Char).Value = BE.perimes;
                 //cmd.Parameters.Add("@valoruit", SqlDbType.Decimal).Value = BE.valoruit;
                 //cmd.Parameters.Add("@cantidad", SqlDbType.Decimal).Value = BE.cantidad;
                 //cmd.Parameters.Add("@porcent", SqlDbType.Decimal).Value = BE.porcent;
                 //cmd.Parameters.Add("@mes_cal", SqlDbType.Decimal).Value = BE.mes_cal;
                 cmd.Parameters.Add("@status", SqlDbType.Char).Value = BE.status;
                 //cmd.Parameters.Add("@sdomin", SqlDbType.Decimal).Value = BE.sdomin;
             }
             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 Update(string empresaid, tb_plla_valor_uit BE)
 {
     using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
     {
         using (SqlCommand cmd = new SqlCommand("[gspTbPllavalorUIT_UPDATE", cnx))
         {
             {
                 cmd.CommandTimeout = 0;
                 cmd.CommandType = CommandType.StoredProcedure;
                 cmd.Parameters.Add("@perianio", SqlDbType.Char).Value = BE.perianio;
                 cmd.Parameters.Add("@perimes", SqlDbType.Char).Value = BE.perimes;
                 cmd.Parameters.Add("@valoruit", SqlDbType.Decimal).Value = BE.valoruit;
                 cmd.Parameters.Add("@cantidad", SqlDbType.Decimal).Value = BE.cantidad;
                 cmd.Parameters.Add("@porcent", SqlDbType.Decimal).Value = BE.porcent;
                 cmd.Parameters.Add("@mes_cal", SqlDbType.Decimal).Value = BE.mes_cal;
                 cmd.Parameters.Add("@status", SqlDbType.Char).Value = BE.status;
                 cmd.Parameters.Add("@sdomin", SqlDbType.Decimal).Value = BE.sdomin;
             }
             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_valor_uit BE, DataTable Detalle)
 {
     using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
     {
         bool xreturn = true;
         int lcont = 0;
         for (lcont = 0; lcont <= Detalle.Rows.Count - 1; lcont++)
         {
             using (SqlCommand cmd = new SqlCommand("gspTbPllavalorUIT_InsertUpdate", cnx))
             {
                 cmd.CommandTimeout = 0;
                 cmd.CommandType = CommandType.StoredProcedure;
                 cmd.Parameters.Add("@perianio", SqlDbType.Char).Value = Detalle.Rows[lcont]["perianio"];
                 cmd.Parameters.Add("@perimes", SqlDbType.Char).Value = Detalle.Rows[lcont]["perimes"];
                 cmd.Parameters.Add("@valoruit", SqlDbType.Decimal).Value = Detalle.Rows[lcont]["valoruit"];
                 cmd.Parameters.Add("@cantidad", SqlDbType.Decimal).Value = Detalle.Rows[lcont]["cantidad"];
                 cmd.Parameters.Add("@porcent", SqlDbType.Decimal).Value = Detalle.Rows[lcont]["porcent"];
                 cmd.Parameters.Add("@mes_cal", SqlDbType.Decimal).Value = Detalle.Rows[lcont]["mes_cal"];
                 cmd.Parameters.Add("@status", SqlDbType.Char).Value = Detalle.Rows[lcont]["status"];
                 cmd.Parameters.Add("@sdomin", SqlDbType.Decimal).Value = Detalle.Rows[lcont]["sdomin"];
                 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_valor_uit BE)
        {
            using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
            {
                using (SqlCommand cmd = new SqlCommand("[gspTbPllavalorUIT_SELECT", cnx))
                {
                    DataSet ds = new DataSet();
                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add("@perianio", SqlDbType.Char).Value = BE.perianio;
                    }

                    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_MaxCodigo(string empresaid, tb_plla_valor_uit BE)
 {
     using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
     {
         using (SqlCommand cmd = new SqlCommand("[gspTbPllavalorUIT_MAXCODIGO", cnx))
         {
             DataSet ds = new DataSet();
             {
                 cmd.CommandType = CommandType.StoredProcedure;
             }
             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_CONSULTA(string empresaid, tb_plla_valor_uit BE)
 {
     using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
     {
         using (SqlCommand cmd = new SqlCommand("gspTbPllavalorUIT_CONSULTA", cnx))
         {
             DataSet ds = new DataSet();
             {
                 cmd.CommandType = CommandType.StoredProcedure;
                 cmd.Parameters.AddWithValue("@perianio", string.IsNullOrEmpty(BE.perianio) ? (object)DBNull.Value : BE.perianio);
                 //cmd.Parameters.Add("@perianio", SqlDbType.Char, 4).Value = BE.perianio;
             }
             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_valor_uit BE, DataTable Detalle)
 {
     //return tablaDA.Insert(empresaid, BE);
     bool zreturn = tablaDA.Insert_Update(empresaid, BE, Detalle);
     Sql_Error = tablaDA.Sql_Error;
     return zreturn;
 }
 private void Accion(int naccion)
 {
     switch (naccion)
     {
         case 1:
             u_n_opsel = 1;
             U_RefrescaControles();
             Blanquear();
             txtcodigo.Text = VariablesPublicas.perianio;
             if ((Examinar.CurrentRow != null))
             {
                 Examinar.CurrentRow.Selected = false;
             }
             break;
         case 2:
             POnedatos();
             u_n_opsel = 2;
             U_RefrescaControles();
             Examinar.CurrentRow.Selected = true;
             break;
         case 3:
             xnomcampo = "";
             if ((Examinar.CurrentRow != null))
             {
                 if (xnomcampo.Length == 0)
                 {
                     var message = "Desea Eliminar Registro ...?";
                     var caption = "Mensaje del Sistema";
                     var buttons = MessageBoxButtons.YesNo;
                     DialogResult result;
                     result = MessageBox.Show(this, message, caption, buttons, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
                     if (result == DialogResult.Yes)
                     {
                         var BL = new tb_plla_valor_uitBL();
                         var BE = new tb_plla_valor_uit();
                         BE.perianio = Examinar.Rows[Examinar.CurrentRow.Index].Cells["perianio"].Value.ToString().Trim();
                         tmpcursor = BL.GetAll_CONSULTA(VariablesPublicas.EmpresaID, BE).Tables[0];
                         if (BL.Sql_Error.Length == 0)
                         {
                             if (BL.Eliminar(VariablesPublicas.EmpresaID, tmpcursor))
                             {
                                 for (lc_cont = 0; lc_cont <= Tabla.Rows.Count - 1; lc_cont++)
                                 {
                                     if (Tabla.Rows[lc_cont]["perianio"].ToString() == Examinar.Rows[Examinar.CurrentRow.Index].Cells["perianio"].Value.ToString())
                                     {
                                         Tabla.Rows[lc_cont].Delete();
                                         Tabla.AcceptChanges();
                                         break;
                                     }
                                 }
                                 Examinar.Refresh();
                             }
                             else
                             {
                                 Frm_Class.ShowError(BL.Sql_Error, this);
                             }
                         }
                         else
                         {
                             Frm_Class.ShowError(BL.Sql_Error, this);
                         }
                     }
                 }
                 else
                 {
                     MessageBox.Show(xnomcampo, "IMPOSIBLE ELIMINAR REGISTRO");
                 }
             }
             break;
     }
 }
 private void save()
 {
     if (u_Validate())
     {
         tmpcursor = null;
         var BL = new tb_plla_valor_uitBL();
         var BE = new tb_plla_valor_uit();
         BE.perianio = txtcodigo.Text.Trim();
         tmpcursor = BL.GetAll_CONSULTA(VariablesPublicas.EmpresaID, BE).Tables[0];
         if (BL.Sql_Error.Length > 0)
         {
             Frm_Class.ShowError(BL.Sql_Error, this);
             return;
         }
         if (tmpcursor.Rows.Count == 0)
         {
             tmpcursor.Rows.Add(VariablesPublicas.INSERTINTOTABLE(tmpcursor));
         }
         tmpcursor.Rows[tmpcursor.Rows.Count - 1]["perianio"] = txtcodigo.Text.Trim();
         tmpcursor.Rows[tmpcursor.Rows.Count - 1]["perimes"] = cmbmes.SelectedValue;
         tmpcursor.Rows[tmpcursor.Rows.Count - 1]["valoruit"] = VariablesPublicas.StringtoDecimal(txtvaloruit.Text);
         tmpcursor.Rows[tmpcursor.Rows.Count - 1]["status"] = '0';
         tmpcursor.Rows[tmpcursor.Rows.Count - 1]["sdomin"] = VariablesPublicas.StringtoDecimal(txtsueldomin.Text);
         tmpcursor.AcceptChanges();
         if (BL.Insert_Update(VariablesPublicas.EmpresaID, BE, tmpcursor))
         {
             U_CancelarEdicion(0);
         }
         else
         {
             Frm_Class.ShowError(BL.Sql_Error, this);
         }
     }
 }
 private void CargaDatos()
 {
     var sorted = default(SortOrder);
     var xnomcolumna = string.Empty;
     if ((Examinar.SortedColumn != null))
     {
         xnomcolumna = Examinar.Columns[Examinar.SortedColumn.Index].Name;
         sorted = Examinar.SortOrder;
     }
     var BL = new tb_plla_valor_uitBL();
     var BE = new tb_plla_valor_uit();
     Tabla = BL.GetAll_CONSULTA(VariablesPublicas.EmpresaID, BE).Tables[0];
     Examinar.AutoGenerateColumns = false;
     Examinar.DataSource = Tabla;
     if (xnomcolumna.Trim().Length > 0)
     {
         if (sorted == SortOrder.Ascending)
         {
             Examinar.Sort(Examinar.Columns[xnomcolumna], System.ComponentModel.ListSortDirection.Ascending);
         }
         else
         {
             Examinar.Sort(Examinar.Columns[xnomcolumna], System.ComponentModel.ListSortDirection.Descending);
         }
     }
     else
     {
         Examinar.Sort(Examinar.Columns["perianio"], System.ComponentModel.ListSortDirection.Descending);
     }
 }