public bool Delete(string empresaid, tb_plla_rubrosingreso BE)
 {
     //return tablaDA.Delete(empresaid, BE);
     bool zreturn = tablaDA.Delete(empresaid, BE);
     Sql_Error = tablaDA.Sql_Error;
     return zreturn;
 }
 public bool Copiar(string empresaid, tb_plla_rubrosingreso BE)
 {
     //return tablaDA.Update(empresaid, BE);
     bool zreturn = tablaDA.Copiar(empresaid, BE);
     Sql_Error = tablaDA.Sql_Error;
     return zreturn;
 }
 public bool Delete(string empresaid, tb_plla_rubrosingreso 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 DataSet GetAll_IR(string empresaid, tb_plla_rubrosingreso BE)
 {
     //return tablaDA.GetAll_IR(empresaid, BE);
     DataSet xreturn = null;
     xreturn = tablaDA.GetAll_IR(empresaid, BE);
     Sql_Error = tablaDA.Sql_Error;
     return xreturn;
 }
        public void RequeryRubroIngresoPlanilla()
        {
            var xvmcod = string.Empty;
            var xtipoplanilla = ".....";
            var vmxtipo = string.Empty;
            if (cmbtipo.SelectedValue != null)
            {
                vmxtipo = cmbtipo.SelectedValue.ToString();
            }
            if (cmbrubroingreso.SelectedValue != null)
            {
                xvmcod = cmbrubroingreso.SelectedValue.ToString();
            }

            if (cmbtipoplanilla.SelectedValue != null)
            {
                xtipoplanilla = cmbtipoplanilla.SelectedValue.ToString();
            }
            if (vmxtipo.Trim().Length > 0)
            {
                if (vmxtipo == "I")
                {
                    var BL = new tb_plla_rubrosingresoBL();
                    var BE = new tb_plla_rubrosingreso();

                    BE.tipoplla = xtipoplanilla;
                    BE.norden = 2;
                    BE.incluir_blanco = 1;
                    BE.nestado = 1;
                    cmbrubroingreso.DataSource = BL.GetAll_CONSULTA(VariablesPublicas.EmpresaID, BE).Tables[0];

                    cmbrubroingreso.ValueMember = "rubroid";
                    cmbrubroingreso.DisplayMember = "rubroname";
                    cmbrubroingreso.SelectedValue = xvmcod;
                }
                else
                {
                    var BL = new tb_plla_rubrosdescuentosBL();
                    var BE = new tb_plla_rubrosdescuentos();

                    BE.tipoplla = xtipoplanilla;
                    BE.norden = 2;
                    BE.incluir_blanco = 1;
                    BE.nestado = 1;
                    cmbrubroingreso.DataSource = BL.GetAll_CONSULTA(VariablesPublicas.EmpresaID, BE).Tables[0];
                    cmbrubroingreso.ValueMember = "rubroid";
                    cmbrubroingreso.DisplayMember = "rubroname";
                    cmbrubroingreso.SelectedValue = xvmcod;
                }
            }
            else
            {
                cmbrubroingreso.DataSource = null;
            }
        }
 private void btnnuevo_Click(object sender, EventArgs e)
 {
     if (!(TabControl1.SelectedIndex == 0))
     {
         TabControl1.SelectedIndex = 0;
     }
     u_n_opsel = 1;
     Blanquear();
     U_RefrescaControles();
     TabControl1.SelectedIndex = 0;
     TabControl1.SelectedIndex = 1;
     var BL = new tb_plla_rubrosingresoBL();
     var BE = new tb_plla_rubrosingreso();
     BE.tipo = GlobalVars.GetInstance().TipoRubroPlanillaPermanente;
     BE.tipoplla = cmbfiltrotipoplanilla.SelectedValue.ToString();
     txtcodigo.Text = BL.GetMAX_CODIGORUBROPLANILLA(VariablesPublicas.EmpresaID.ToString(), BE).Tables[0].Rows[0]["maximo_codigo"].ToString();
     cmbtipoplanilla.SelectedValue = cmbfiltrotipoplanilla.SelectedValue;
     chkactivo.Checked = true;
     cmbmodalidad.SelectedValue = "D";
     cmbtipo.SelectedValue = "I";
     txtdescripcion.Focus();
 }
        private void CargaDatos()
        {
            lbltotalregistros.Text = string.Empty;
            var xtipoplanilla = string.Empty;
            var nestado = 1;
            if (rbestado2.Checked)
            {
                nestado = 2;
            }
            if (rbestado3.Checked)
            {
                nestado = 3;
            }
            if (cboTipoplanilla.Enabled)
            {
                if (cboTipoplanilla.SelectedValue != null)
                {
                    xtipoplanilla = cboTipoplanilla.SelectedValue.ToString();
                }
            }
            var nposcolumnasortear = 0;
            var PrvSotOrder = default(SortOrder);
            var zordenado = false;
            var xcodcliente = "..";
            var xpalabra1 = string.Empty;
            var xpalabra2 = string.Empty;
            var xpalabra3 = string.Empty;
            if (txtfiltronombre.Text.Trim().Length > 0)
            {
                xpalabra1 = VariablesPublicas.Palabras(txtfiltronombre.Text, 1);
                xpalabra2 = VariablesPublicas.Palabras(txtfiltronombre.Text, 2);
                xpalabra3 = VariablesPublicas.Palabras(txtfiltronombre.Text, 3);
            }
            if (Examinar.CurrentRow != null)
            {
                xcodcliente = Examinar.Rows[Examinar.CurrentRow.Index].Cells["rubroid"].Value.ToString();
            }
            if (Examinar.SortedColumn != null)
            {
                nposcolumnasortear = Examinar.SortedColumn.Index;
                PrvSotOrder = Examinar.SortOrder;
                zordenado = true;
            }
            var BL = new tb_plla_rubrosingresoBL();
            var BE = new tb_plla_rubrosingreso();

            BE.tipoplla = xtipoplanilla;
            BE.descriplike1 = xpalabra1;
            BE.descriplike2 = xpalabra2;
            BE.descriplike3 = xpalabra3;
            BE.norden = 0;
            BE.incluir_blanco = 0;
            BE.nestado = nestado;
            tablaclientes = BL.GetAll_CONSULTA(VariablesPublicas.EmpresaID, BE).Tables[0];
            Examinar.AutoGenerateColumns = false;
            Examinar.DataSource = tablaclientes;

            VariablesPublicas.PintaEncabezados(Examinar);

            if (zordenado)
            {
                if (PrvSotOrder == SortOrder.Ascending)
                {
                    Examinar.Sort(Examinar.Columns[nposcolumnasortear], System.ComponentModel.ListSortDirection.Ascending);
                }
                else
                {
                    Examinar.Sort(Examinar.Columns[nposcolumnasortear], System.ComponentModel.ListSortDirection.Descending);
                }
            }
            else
            {
                Examinar.Sort(Examinar.Columns["rubroid"], System.ComponentModel.ListSortDirection.Ascending);
            }
            if (Examinar.CurrentRow == null)
            {
                if (Examinar.RowCount > 0)
                {
                    Examinar.CurrentCell = Examinar.Rows[0].Cells["rubroid"];
                }
            }
            for (lc_cont = 0; lc_cont <= Examinar.Rows.Count - 1; lc_cont++)
            {
                if (Examinar.Rows[lc_cont].Cells["rubroid"].Value.ToString() == xcodcliente)
                {
                    Examinar.CurrentCell = Examinar.Rows[lc_cont].Cells["rubroid"];
                    break;
                }
            }

            if (Examinar.RowCount > 0)
            {
                lbltotalregistros.Text = Examinar.RowCount.ToString() + " Registro(s)";
            }
            else
            {
                lbltotalregistros.Text = "NINGUN REGISTRO";
            }
            U_RefrescaControles();
        }
        private void btngrabar_Click(object sender, EventArgs e)
        {
            if (U_Validacion())
            {
                var tmpcursor = new DataTable();
                var BL = new tb_plla_rubrosingresoBL();
                var BE = new tb_plla_rubrosingreso();

                BE.rubroid = txtsigla.Text.ToString().Trim() + txtcodigo.Text.ToString().Trim();
                BE.tipoplla = cmbtipoplanilla.SelectedValue.ToString();
                BE.norden = 1;
                BE.incluir_blanco = 0;
                BE.nestado = 1;
                tmpcursor = BL.GetAll_CONSULTA1(VariablesPublicas.EmpresaID, BE).Tables[0];

                if (u_n_opsel == 1)
                {
                    var BL1 = new tb_plla_rubrosingresoBL();
                    var BE1 = new tb_plla_rubrosingreso();

                    BE1.rubroid = txtsigla.Text.ToString().Trim() + txtcodigo.Text.ToString().Trim();
                    BE1.tipoplla = cmbtipoplanilla.SelectedValue.ToString();
                    BE1.norden = 1;
                    BE1.incluir_blanco = 0;
                    BE1.nestado = 1;
                    tmpcursor = BL1.GetAll_CONSULTA1(VariablesPublicas.EmpresaID, BE1).Tables[0];

                    if (tmpcursor.Rows.Count > 0)
                    {
                        var BLm = new tb_plla_rubrosingresoBL();
                        var BEm = new tb_plla_rubrosingreso();
                        BEm.tipo = GlobalVars.GetInstance().TipoRubroPlanillaIngreso;
                        BEm.tipoplla = cboTipoplanilla.SelectedValue.ToString();
                        txtcodigo.Text = BLm.GetMAX_CODIGORUBROPLANILLA(VariablesPublicas.EmpresaID.ToString(), BEm).Tables[0].Rows[0]["maximo_codigo"].ToString();
                    }
                    tmpcursor.Rows.Add(VariablesPublicas.InsertIntoTable(tmpcursor));
                    tmpcursor.Rows[0]["rubroid"] = txtsigla.Text + txtcodigo.Text;
                    tmpcursor.Rows[0]["status"] = "0";
                }
                tmpcursor.Rows[0]["rubroname"] = txtdescripcion.Text;
                tmpcursor.Rows[0]["status"] = (chkactivo.Checked ? "0" : "9");
                tmpcursor.Rows[0]["tipoplla"] = cmbtipoplanilla.SelectedValue;
                tmpcursor.Rows[0]["edita"] = (chkeditable.Checked ? 1 : 0);
                tmpcursor.Rows[0]["visible"] = (chkvisible.Checked ? 1 : 0);
                tmpcursor.Rows[0]["modalidad"] = cmbmodalidad.SelectedValue;
                tmpcursor.Rows[0]["tipocalculo"] = cmbtipocalculo.SelectedValue;
                tmpcursor.Rows[0]["tiporubro"] = cmbtipo.SelectedValue;
                tmpcursor.Rows[0]["rubropdt"] = cmbrubrorpts.SelectedValue;
                tmpcursor.Rows[0]["montofijo"] = VariablesPublicas.StringtoDecimal(txtmontofijo.Text);
                tmpcursor.Rows[0]["redondeo"] = VariablesPublicas.StringtoDecimal(txtredondeo.Text);
                tmpcursor.AcceptChanges();

                var BLIU = new tb_plla_rubrosingresoBL();

                if (BLIU.Insert_Update(VariablesPublicas.EmpresaID, tmpcursor))
                {
                    seguridadlog();
                    U_CancelarEdicion(0);
                }
                else
                {
                    Frm_Class.ShowError(BLIU.Sql_Error, this);
                }
            }
        }
        private void btneliminar_Click(object sender, EventArgs e)
        {
            if (Examinar.CurrentRow != null)
            {
                var xnomcampo = string.Empty;
                var BL = new tb_plla_rubrosingresoBL();
                var BE = new tb_plla_rubrosingreso();

                BE.rubroid = Examinar.Rows[Examinar.CurrentRow.Index].Cells["tipoplla"].Value.ToString() + Examinar.Rows[Examinar.CurrentRow.Index].Cells["rubroid"].Value.ToString();
                tmpcursor = BL.GetAll_IR(VariablesPublicas.EmpresaID, BE).Tables[0];
                if (BL.Sql_Error.Length > 0)
                {
                    xnomcampo = BL.Sql_Error;
                    Frm_Class.ShowError(BL.Sql_Error, this);
                }
                else
                {
                    if (tmpcursor.Rows.Count == 0)
                    {
                    }
                    else
                    {
                        for (lc_cont = 0; lc_cont <= tmpcursor.Rows.Count - 1; lc_cont++)
                        {
                            xnomcampo = xnomcampo + tmpcursor.Rows[lc_cont]["relacion"] + "\r";
                            if (lc_cont + 1 == 10)
                            {
                                break;
                            }
                        }
                    }
                }
                if (xnomcampo.Length == 0)
                {
                    var BL1 = new tb_plla_rubrosingresoBL();
                    var BE1 = new tb_plla_rubrosingreso();

                    BE1.rubroid = Examinar.Rows[Examinar.CurrentRow.Index].Cells["rubroid"].Value.ToString();
                    BE1.tipoplla = Examinar.Rows[Examinar.CurrentRow.Index].Cells["tipoplla"].Value.ToString();
                    BE1.norden = 1;
                    BE1.incluir_blanco = 0;
                    BE1.nestado = 1;
                    tmptabla = BL1.GetAll_CONSULTA(VariablesPublicas.EmpresaID, BE1).Tables[0];
                    if (BL1.Sql_Error.Length == 0)
                    {
                        var message = "Desea eliminar datos del rubro  " + tmptabla.Rows[0]["rubroid"].ToString().Trim() + "-" + tmptabla.Rows[0]["rubroname"].ToString().Trim() + " ...?";
                        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 BLE = new tb_plla_rubrosingresoBL();

                            BLE.Eliminar(VariablesPublicas.EmpresaID, tmptabla);
                            if (BLE.Sql_Error.Length == 0)
                            {
                                var BLL = new tb_co_seguridadlogBL();
                                var BEL = new tb_co_seguridadlog();

                                BEL.moduloid = Name;
                                BEL.clave = VariablesPublicas.EmpresaID + Examinar.Rows[Examinar.CurrentRow.Index].Cells["tipoplla"].Value.ToString() + Examinar.Rows[Examinar.CurrentRow.Index].Cells["rubroid"].Value.ToString();
                                BEL.cuser = VariablesPublicas.Usuar;
                                BEL.fecha = DateTime.Now;
                                BEL.pc = VariablesPublicas.userip;
                                BEL.accion = "B";
                                BEL.detalle = "Rubro: " + txtdescripcion.Text;

                                BLL.Insert(VariablesPublicas.EmpresaID.ToString(), BEL);
                                Examinar.Rows.Remove(Examinar.CurrentRow);
                                Examinar.Refresh();
                                u_PintaDatos();
                            }
                            else
                            {
                                Frm_Class.ShowError(BLE.Sql_Error, this);
                            }
                        }
                    }
                    else
                    {
                        Frm_Class.ShowError(BL1.Sql_Error, this);
                    }
                }
                else
                {
                    MessageBox.Show(xnomcampo, "IMPOSIBLE ELIMINAR REGISTRO");
                }
            }
            U_RefrescaControles();
        }
 public DataSet GetMAX_CODIGORUBROPLANILLA(string empresaid, tb_plla_rubrosingreso 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(string empresaid, tb_plla_rubrosingreso 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("@rubroid", SqlDbType.Char, 3).Value = BE.rubroid;
                 cmd.Parameters.Add("@rubroname", SqlDbType.VarChar, 60).Value = BE.rubroname;
                 //cmd.Parameters.Add("@visible", SqlDbType.Bit).Value = BE.visible;
                 //cmd.Parameters.Add("@edita", SqlDbType.Bit).Value = BE.edita;
                 cmd.Parameters.Add("@modalidad", SqlDbType.Char, 2).Value = BE.modalidad;
                 //cmd.Parameters.Add("@redondeo", SqlDbType.Decimal).Value = BE.redondeo;
                 //cmd.Parameters.Add("@montofijo", SqlDbType.Decimal).Value = BE.montofijo;
                 cmd.Parameters.Add("@tipocalculo", SqlDbType.Char, 2).Value = BE.tipocalculo;
                 cmd.Parameters.Add("@tiporubro", SqlDbType.Char, 3).Value = BE.tiporubro;
                 cmd.Parameters.Add("@rubropdt", SqlDbType.Char, 4).Value = BE.rubropdt;
                 cmd.Parameters.Add("@status", SqlDbType.Char, 1).Value = BE.status;
             }
             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);
             }
         }
     }
 }
        private void Filtrar()
        {
            var sorted = default(SortOrder);
            var xnomcolumna = string.Empty;
            if ((dgProveedor.SortedColumn != null))
            {
                xnomcolumna = dgProveedor.Columns[dgProveedor.SortedColumn.Index].Name;
                sorted = dgProveedor.SortOrder;
            }

            var xpalabra1 = string.Empty;
            var xpalabra2 = string.Empty;
            var xpalabra3 = string.Empty;
            if (txtdescripcion.Enabled)
            {
                xpalabra1 = VariablesPublicas.Palabras(txtdescripcion.Text, 1);
                xpalabra2 = VariablesPublicas.Palabras(txtdescripcion.Text, 2);
                xpalabra3 = VariablesPublicas.Palabras(txtdescripcion.Text, 3);
            }
            var xtipoplla = string.Empty;
            if (_Planilla.Trim().Length == 0)
            {
                if (cmbtipoplanilla.Enabled)
                {
                    xtipoplla = cmbtipoplanilla.SelectedValue.ToString();
                }
            }
            else
            {
                xtipoplla = _Planilla;
            }
            var xvmccia = "..";
            if (cmbempresa.Enabled)
            {
                if (cmbempresa.SelectedValue != null)
                {
                    xvmccia = cmbempresa.SelectedValue.ToString();
                }
            }
            dgProveedor.DataSource = null;
            dgProveedor.AutoGenerateColumns = false;
            var BL = new tb_plla_rubrosingresoBL();
            var BE = new tb_plla_rubrosingreso();

            BE.tipoplla = xtipoplla;
            BE.descriplike1 = xpalabra1;
            BE.descriplike2 = xpalabra2;
            BE.descriplike3 = xpalabra3;
            dgProveedor.DataSource = BL.GetAll_CONSULTA_PLLA(VariablesPublicas.EmpresaID, BE).Tables[0];
            if (xnomcolumna.Trim().Length > 0)
            {
                if (sorted == SortOrder.Ascending)
                {
                    dgProveedor.Sort(dgProveedor.Columns[xnomcolumna], System.ComponentModel.ListSortDirection.Ascending);
                }
                else
                {
                    dgProveedor.Sort(dgProveedor.Columns[xnomcolumna], System.ComponentModel.ListSortDirection.Descending);
                }
            }
            else
            {
                dgProveedor.Sort(dgProveedor.Columns["rubroid"], System.ComponentModel.ListSortDirection.Ascending);
            }
            VariablesPublicas.PintaEncabezados(dgProveedor);
        }
 public bool Update(string empresaid, tb_plla_rubrosingreso BE)
 {
     using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
     {
         using (SqlCommand cmd = new SqlCommand("gspTbPllaRubrosingreso_UPDATE", cnx))
         {
             {
                 //cmd.Connection.ConnectionTimeout = 0;
                 cmd.CommandType = CommandType.StoredProcedure;
                 cmd.Parameters.Add("@tipoplla", SqlDbType.Char, 1).Value = BE.tipoplla;
                 cmd.Parameters.Add("@rubroid", SqlDbType.Char, 3).Value = BE.rubroid;
                 cmd.Parameters.Add("@rubroname", SqlDbType.VarChar, 60).Value = BE.rubroname;
                 cmd.Parameters.Add("@visible", SqlDbType.Bit).Value = BE.visible;
                 cmd.Parameters.Add("@edita", SqlDbType.Bit).Value = BE.edita;
                 cmd.Parameters.Add("@modalidad", SqlDbType.Char, 2).Value = BE.modalidad;
                 cmd.Parameters.Add("@redondeo", SqlDbType.Decimal).Value = BE.redondeo;
                 cmd.Parameters.Add("@montofijo", SqlDbType.Decimal).Value = BE.montofijo;
                 cmd.Parameters.Add("@tipocalculo", SqlDbType.Char, 2).Value = BE.tipocalculo;
                 cmd.Parameters.Add("@tiporubro", SqlDbType.Char, 3).Value = BE.tiporubro;
                 cmd.Parameters.Add("@rubropdt", SqlDbType.Char, 4).Value = BE.rubropdt;
                 cmd.Parameters.Add("@status", SqlDbType.Char, 1).Value = BE.status;
             }
             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 DataSet GetOne(string empresaid, tb_plla_rubrosingreso 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_CONSULTA_PLLA(string empresaid, tb_plla_rubrosingreso BE)
        {
            using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
            {
                using (SqlCommand cmd = new SqlCommand("gspTbPllaRubrosingresoPlla_CONSULTA", cnx))
                {
                    DataSet ds = new DataSet();
                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.AddWithValue("@tipoplla", string.IsNullOrEmpty(BE.tipoplla) ? (object)DBNull.Value : BE.tipoplla);
                        cmd.Parameters.AddWithValue("@rubroid", string.IsNullOrEmpty(BE.rubroid) ? (object)DBNull.Value : BE.rubroid);
                        cmd.Parameters.AddWithValue("@DESCLIKE1", string.IsNullOrEmpty(BE.descriplike1) ? (object)DBNull.Value : BE.descriplike1);
                        cmd.Parameters.AddWithValue("@DESCLIKE2", string.IsNullOrEmpty(BE.descriplike2) ? (object)DBNull.Value : BE.descriplike2);
                        cmd.Parameters.AddWithValue("@DESCLIKE3", string.IsNullOrEmpty(BE.descriplike3) ? (object)DBNull.Value : BE.descriplike3);

                        //cmd.Parameters.Add("@descartarrubros", SqlDbType.VarChar, 50).Value = BE.descartarrubros;
                        //@vesdescartar varchar(70)= NULL ,
                        //@descartartipoplla varchar(30)=NULL ,
                        //@descartartipopllarubro varchar(200)=NULL
                    }
                    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_rubrosingreso 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("@tipocalculo", SqlDbType.Char, 2).Value = BE.tipocalculo;
                 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 void ValidaRubroIngreso()
        {
            var zhallado = false;
            var xcodartic = string.Empty;
            xcodartic = examinarrubros.Rows[examinarrubros.CurrentRow.Index].Cells["rubroid"].Value.ToString();
            var xcodplanilla = "...";
            if (object.ReferenceEquals(examinaranexos.Rows[examinaranexos.CurrentRow.Index].Cells["tipoplla"].Value, DBNull.Value))
            {
            }
            else
            {
                xcodplanilla = examinaranexos.Rows[examinaranexos.CurrentRow.Index].Cells["tipoplla"].Value.ToString();
            }

            if (xcodartic.Trim().Length == 0)
            {
                examinarrubros.Rows[examinarrubros.CurrentRow.Index].Cells["rubroid"].Value = string.Empty;
                examinarrubros.Rows[examinarrubros.CurrentRow.Index].Cells["rubroname"].Value = string.Empty;
                zhallado = true;
            }
            else
            {
                var BL = new tb_plla_rubrosingresoBL();
                var BE = new tb_plla_rubrosingreso();
                BE.tipoplla = xcodplanilla;
                BE.rubroid = xcodartic;
                tmptabla = BL.GetAll_CONSULTA_PLLA(VariablesPublicas.EmpresaID, BE).Tables[0];
                if (BL.Sql_Error.Length == 0)
                {
                    if (tmptabla.Rows.Count > 0)
                    {
                        zhallado = true;
                        examinarrubros.Rows[examinarrubros.CurrentRow.Index].Cells["rubroid"].Value = tmptabla.Rows[0]["rubroid"].ToString().Trim();
                        examinarrubros.Rows[examinarrubros.CurrentRow.Index].Cells["rubroname"].Value = tmptabla.Rows[0]["rubroname"].ToString().Trim();
                    }
                }
            }
            if (!zhallado)
            {
                examinarrubros.Rows[examinarrubros.CurrentRow.Index].Cells["rubroid"].Value = j_rubro;
            }
            examinarrubros.Refresh();
        }
        private void btncopiar_Click(object sender, EventArgs e)
        {
            if (cmbtipoplanillaorigen.SelectedValue == null)
            {
                MessageBox.Show("Seleccione Tipo de Planilla Origen", "Mensaje del Sistema");
                return;
            }
            if (cmbtipoplanillaorigen.SelectedValue.ToString().Trim().Length == 0)
            {
                MessageBox.Show("Seleccione Tipo de Planilla Origen", "Mensaje del Sistema");
                return;
            }
            if (cmbtipoplanilladestino.SelectedValue == null)
            {
                MessageBox.Show("Seleccione Tipo de Planilla Destino", "Mensaje del Sistema");
                return;
            }
            if (cmbtipoplanilladestino.SelectedValue.ToString().Trim().Length == 0)
            {
                MessageBox.Show("Seleccione Tipo de Planilla Destino", "Mensaje del Sistema");
                return;
            }
            if (cmbtiporubro.SelectedValue == null)
            {
                MessageBox.Show("Seleccione Tipo de Rubro", "Mensaje del Sistema");
                return;
            }
            if (cmbtiporubro.SelectedValue.ToString().Trim().Length == 0)
            {
                MessageBox.Show("Seleccione Tipo de Rubro", "Mensaje del Sistema");
                return;
            }

            var message = "Desea copiar  Rubros desde planilla: " + cmbtipoplanillaorigen.Text + "\r" + "A: " + cmbtipoplanilladestino.Text + "...?" + "\r" + "\r" + "Los rubros existentes serán reemplazados";
            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_rubrosingresoBL();
                var BE = new tb_plla_rubrosingreso();

                BE.tipoplanillaorigen = cmbtipoplanillaorigen.SelectedValue.ToString();
                BE.tipoplanilladestino = cmbtipoplanilladestino.SelectedValue.ToString();
                BE.tiporubro = cmbtiporubro.SelectedValue.ToString();
                if (!BL.Copiar(VariablesPublicas.EmpresaID, BE))
                {
                    Frm_Class.ShowError(BL.Sql_Error, this);
                }
                else
                {
                    MessageBox.Show("Rubros copiados satisfactoriamente", "Mensaje del Sistema");
                    btnsalir_Click(sender, e);
                }
            }
        }