public DataSet GetAll(string empresaid, tb_plla_pdt_tabla17 BE)
 {
     using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
     {
         using (SqlCommand cmd = new SqlCommand("gspTbPllaPdtTabla17_SEARCH", cnx))
         {
             DataSet ds = new DataSet();
             {
                 cmd.CommandType = CommandType.StoredProcedure;
                 cmd.Parameters.Add("@motfinperiodid", SqlDbType.Char, 2).Value = BE.motfinperiodid;
                 cmd.Parameters.Add("@motfinperiodname", SqlDbType.VarChar, 60).Value = BE.motfinperiodname;
             }
             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_pdt_tabla17 BE)
 {
     using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
     {
         using (SqlCommand cmd = new SqlCommand("gspTbPllaPdtTabla17_CONSULTA", cnx))
         {
             DataSet ds = new DataSet();
             {
                 cmd.CommandType = CommandType.StoredProcedure;
                 cmd.Parameters.AddWithValue("@motfinperiodid", string.IsNullOrEmpty(BE.motfinperiodid) ? (object)DBNull.Value : BE.motfinperiodid);
                 cmd.Parameters.AddWithValue("@nomlike1", string.IsNullOrEmpty(BE.nomlike1) ? (object)DBNull.Value : BE.nomlike1);
                 cmd.Parameters.AddWithValue("@nomlike2", string.IsNullOrEmpty(BE.nomlike2) ? (object)DBNull.Value : BE.nomlike2);
                 cmd.Parameters.AddWithValue("@nomlike3", string.IsNullOrEmpty(BE.nomlike3) ? (object)DBNull.Value : BE.nomlike3);
                 cmd.Parameters.Add("@norden", SqlDbType.Int).Value = BE.norden;
                 cmd.Parameters.Add("@incluir_blanco", SqlDbType.Int).Value = BE.incluir_blanco;
             }
             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 Delete(string empresaid, tb_plla_pdt_tabla17 BE)
 {
     using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
     {
         using (SqlCommand cmd = new SqlCommand("gspTbPllaPdtTabla17_DELETE", cnx))
         {
             {
                 cmd.CommandType = CommandType.StoredProcedure;
                 cmd.Parameters.Add("@motfinperiodid", SqlDbType.Char, 2).Value = BE.motfinperiodid;
             }
             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_pdt_tabla17 BE, DataTable Detalle)
 {
     //return tablaDA.Insert(empresaid, BE);
     bool zreturn = tablaDA.Insert_Update(empresaid, BE, Detalle);
     Sql_Error = tablaDA.Sql_Error;
     return zreturn;
 }
 public bool Insert(string empresaid, tb_plla_pdt_tabla17 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_pdt_tabla17 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_pdt_tabla17 BE)
 {
     //return tablaDA.GetAll_MaxCodigo(empresaid, BE);
     DataSet xreturn = null;
     xreturn = tablaDA.GetAll_MaxCodigo(empresaid, BE);
     Sql_Error = tablaDA.Sql_Error;
     return xreturn;
 }
 private void Frm_TrabajadoresBaja_Load(object sender, EventArgs e)
 {
     EnlazarControles();
     txtjefe.Enabled = true;
     txtjefe.ReadOnly = false;
     var BL = new tb_plla_pdt_tabla17BL();
     var BE = new tb_plla_pdt_tabla17();
     cbMotivoCese.DisplayMember = "descripcion";
     cbMotivoCese.ValueMember = "motfinperiodid";
     cbMotivoCese.DataSource = BL.GetAll_Consulta(VariablesPublicas.EmpresaID, BE).Tables[0];
 }
 public bool Insert_Update(string empresaid, tb_plla_pdt_tabla17 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("gspTbPllaPdtTabla17_InsertUpdate", cnx))
             {
                 cmd.CommandTimeout = 0;
                 cmd.CommandType = CommandType.StoredProcedure;
                 cmd.Parameters.Add("@motfinperiodid", SqlDbType.Char, 2).Value = Detalle.Rows[lcont]["motfinperiodid"];
                 cmd.Parameters.Add("@motfinperiodname", SqlDbType.VarChar, 60).Value = Detalle.Rows[lcont]["motfinperiodname"];
                 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 GetAll_MaxCodigo(string empresaid, tb_plla_pdt_tabla17 BE)
 {
     using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
     {
         using (SqlCommand cmd = new SqlCommand("gspTbPllaPdtTabla17_MaxMotivoCese", 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_IR(string empresaid, tb_plla_pdt_tabla17 BE)
 {
     using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
     {
         using (SqlCommand cmd = new SqlCommand("gspTbPllaPdtTabla17_IR", cnx))
         {
             DataSet ds = new DataSet();
             {
                 cmd.CommandType = CommandType.StoredProcedure;
                 cmd.Parameters.AddWithValue("@motfinperiodid", string.IsNullOrEmpty(BE.motfinperiodid) ? (object)DBNull.Value : BE.motfinperiodid);
             }
             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 U_Validacion()
 {
     var xmsg = string.Empty;
     var objeto = new object();
     if (txtdescripcion.Text.Trim().Length == 0)
     {
         xmsg = "Ingrese Descripción";
         objeto = txtdescripcion;
     }
     if (!(VM_DESCRIPCION == txtdescripcion.Text) & u_n_opsel > 1)
     {
         xnomcampo = string.Empty;
         var BL = new tb_plla_pdt_tabla17BL();
         var BE = new tb_plla_pdt_tabla17();
         BE.motfinperiodid = txtcodigo.Text.Trim();
         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);
             return false;
         }
         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)
         {
             if (!(MessageBox.Show("DESCRIPCION ANTERIOR :" + VM_DESCRIPCION + " SE USA EN " + "\r" + xnomcampo + "\r" + "DESEA REEMPLAZAR DESCRIPCION ...?", "Mensaje del Sistema", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes))
             {
                 return false;
             }
         }
     }
     if (xmsg.Trim().Length > 0)
     {
         MessageBox.Show(xmsg.Trim(), "Error en Ingreso de Datos");
         if ((objeto != null))
         {
             objeto = Focus();
         }
     }
     return xmsg.Trim().Length == 0;
 }
        private void CargaDatos()
        {
            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["motfinperiodid"].Value.ToString();
            }
            if ((Examinar.SortedColumn != null))
            {
                nposcolumnasortear = Examinar.SortedColumn.Index;
                PrvSotOrder = Examinar.SortOrder;
                zordenado = true;
            }
            var BL = new tb_plla_pdt_tabla17BL();
            var BE = new tb_plla_pdt_tabla17();
            BE.nomlike1 = xpalabra1;
            BE.nomlike2 = xpalabra2;
            BE.nomlike3 = xpalabra3;
            BE.norden = 1;
            BE.incluir_blanco = 0;
            tablaclientes = BL.GetAll_Consulta(VariablesPublicas.EmpresaID, BE).Tables[0];
            if (BL.Sql_Error.Length > 0)
            {
                Frm_Class.ShowError(BL.Sql_Error, this);
                return;
            }
            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["motfinperiodid"], System.ComponentModel.ListSortDirection.Ascending);
            }
            if (Examinar.CurrentRow == null)
            {
                if (Examinar.RowCount > 0)
                {
                    Examinar.CurrentCell = Examinar.Rows[0].Cells["motfinperiodid"];
                }
            }
            for (lc_cont = 0; lc_cont <= Examinar.Rows.Count - 1; lc_cont++)
            {
                if (Examinar.Rows[lc_cont].Cells["motfinperiodid"].Value.ToString() == xcodcliente)
                {
                    Examinar.CurrentCell = Examinar.Rows[lc_cont].Cells["motfinperiodid"];
                    break;
                }
            }
        }
 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_pdt_tabla17BL();
     var BE = new tb_plla_pdt_tabla17();
     txtcodigo.Text = BL.GetAll_MaxCodigo(VariablesPublicas.EmpresaID.ToString(), BE).Tables[0].Rows[0]["maximo_codigo"].ToString();
     txtdescripcion.Focus();
 }
        private void btngrabar_Click(object sender, EventArgs e)
        {
            if (U_Validacion())
            {
                var BL = new tb_plla_pdt_tabla17BL();
                var BE = new tb_plla_pdt_tabla17();
                BE.motfinperiodid = txtcodigo.Text.Trim();
                BE.norden = 1;
                BE.incluir_blanco = 0;
                tmpcursor = BL.GetAll_Consulta(VariablesPublicas.EmpresaID, BE).Tables[0];

                if (u_n_opsel == 1)
                {
                    while (1 == 1)
                    {
                        BE.motfinperiodid = txtcodigo.Text.Trim();
                        tmpcursor = BL.GetAll_Consulta(VariablesPublicas.EmpresaID, BE).Tables[0];
                        if (BL.Sql_Error.Length > 0)
                        {
                            Frm_Class.ShowError(BL.Sql_Error + "\r" + "Error al buscar código", this);
                            return;
                        }
                        if (tmpcursor.Rows.Count > 0)
                        {
                            var BLMX = new tb_plla_pdt_tabla17BL();
                            var BEMX = new tb_plla_pdt_tabla17();
                            txtcodigo.Text = BLMX.GetAll_MaxCodigo(VariablesPublicas.EmpresaID.ToString(), BEMX).Tables[0].Rows[0]["maximo_codigo"].ToString();
                        }
                        else
                        {
                            break;
                        }
                    }
                    tmpcursor = BL.GetAll_Consulta(VariablesPublicas.EmpresaID, BE).Tables[0];
                    tmpcursor.Rows.Add(VariablesPublicas.InsertIntoTable(tmpcursor));
                    tmpcursor.Rows[0]["motfinperiodid"] = txtcodigo.Text;
                }
                tmpcursor.Rows[0]["motfinperiodname"] = txtdescripcion.Text.Trim();
                tmpcursor.AcceptChanges();
                if (BL.Insert_Update(VariablesPublicas.EmpresaID, BE, tmpcursor))
                {
                    seguridadlog();
                    U_CancelarEdicion(0);
                }
                else
                {
                    Frm_Class.ShowError(BL.Sql_Error, this);
                }
            }
        }
        private void btneliminar_Click(object sender, EventArgs e)
        {
            if ((Examinar.CurrentRow != null))
            {
                xnomcampo = string.Empty;
                var BL = new tb_plla_pdt_tabla17BL();
                var BE = new tb_plla_pdt_tabla17();
                BE.motfinperiodid = Examinar.Rows[Examinar.CurrentRow.Index].Cells["motfinperiodid"].Value.ToString().Trim();
                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 BLEL = new tb_plla_pdt_tabla17BL();
                    var BEEL = new tb_plla_pdt_tabla17();
                    BEEL.motfinperiodid = Examinar.Rows[Examinar.CurrentRow.Index].Cells["motfinperiodid"].Value.ToString();
                    BEEL.norden = 1;
                    BEEL.incluir_blanco = 0;
                    tmptabla = BLEL.GetAll_Consulta(VariablesPublicas.EmpresaID, BEEL).Tables[0];
                    if (BLEL.Sql_Error.Length == 0)
                    {
                        var message = "Desea eliminar datos  " + tmptabla.Rows[0]["motfinperiodid"].ToString().Trim() + "-" + tmptabla.Rows[0]["motfinperiodname"].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)
                        {
                            BLEL.Delete(VariablesPublicas.EmpresaID, BE);
                            if (BLEL.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["motfinperiodid"].Value.ToString();
                                BEL.cuser = VariablesPublicas.Usuar;
                                BEL.fecha = DateTime.Now;
                                BEL.pc = VariablesPublicas.userip;
                                BEL.accion = "B";
                                BEL.detalle = "Descripción: " + txtdescripcion.Text;
                                BLL.Insert(VariablesPublicas.EmpresaID.ToString(), BEL);
                                Examinar.Rows.Remove(Examinar.CurrentRow);

                                Examinar.Refresh();
                                u_PintaDatos();
                            }
                            else
                            {
                                Frm_Class.ShowError(BLEL.Sql_Error, this);
                            }
                        }
                    }
                    else
                    {
                        Frm_Class.ShowError(BLEL.Sql_Error, this);
                    }
                }
                else
                {
                    MessageBox.Show(xnomcampo, "IMPOSIBLE ELIMINAR REGISTRO");
                }
            }
            U_RefrescaControles();
        }