public bool Delete(string empresaid, tb_plla_feriados BE)
 {
     //return tablaDA.Delete(empresaid, BE);
     bool zreturn = tablaDA.Delete(empresaid, BE);
     Sql_Error = tablaDA.Sql_Error;
     return zreturn;
 }
 public bool Delete(string empresaid, tb_plla_feriados BE)
 {
     using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
     {
         using (SqlCommand cmd = new SqlCommand("gspTbPllaFeriados_DELETE", 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("@peridia", SqlDbType.Char, 2).Value = BE.peridia;
             }
             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 Copiar(string empresaid, tb_plla_feriados BE)
 {
     using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
     {
         using (SqlCommand cmd = new SqlCommand("gspTbPllaFeriados_COPIAR", cnx))
         {
             {
                 cmd.CommandTimeout = 0;
                 cmd.CommandType = CommandType.StoredProcedure;
                 cmd.Parameters.Add("@perianioini", SqlDbType.Char, 4).Value = BE.perianioini;
                 cmd.Parameters.Add("@perianiofin", SqlDbType.Char, 4).Value = BE.perianiofin;
                 cmd.Parameters.Add("@deleteoall", SqlDbType.Int).Value = BE.deleteoall;
             }
             try
             {
                 cnx.Open();
                 if (cmd.ExecuteNonQuery() > 0)
                 {
                     return true;
                 }
                 else
                 {
                     return false;
                 }
             }
             catch (Exception ex)
             {
                 Sql_Error = ex.Message;
                 throw new Exception(ex.Message);
             }
         }
     }
 }
 private void btnCopiar_Click(object sender, EventArgs e)
 {
     if (spnperiodo.Value == spnperiodod.Value)
     {
         MessageBox.Show("Periodos deben ser distintos", "Mensaje del Sistema");
         return;
     }
     var BL = new tb_plla_feriadosBL();
     var BE = new tb_plla_feriados();
     BE.perianioini = spnperiodo.Value.ToString();
     BE.perianiofin = spnperiodod.Value.ToString();
     BE.deleteoall = (chkdel.Checked ? 1 : 0);
     BL.Copiar(VariablesPublicas.EmpresaID, BE);
     if (BL.Sql_Error.Length > 0)
     {
         Frm_Class.ShowError(BL.Sql_Error, this);
     }
     else
     {
         if ((_LpDelegado != null))
         {
             _LpDelegado(true);
         }
         Close();
     }
 }
 public DataSet GetOne(string empresaid, tb_plla_feriados 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_feriados 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_feriados BE)
 {
     //return tablaDA.GetAll_CONSULTAIR(empresaid, BE);
     DataSet xreturn = null;
     xreturn = tablaDA.GetAll_CONSULTAIR(empresaid, BE);
     Sql_Error = tablaDA.Sql_Error;
     return xreturn;
 }
        public bool Insert_Update(string empresaid, tb_plla_feriados 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("gspTbPllaFeriados_InsertUpdate", cnx))
                    {
                        cmd.CommandTimeout = 0;
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add("@perianio", SqlDbType.Char, 4).Value = Detalle.Rows[lcont]["perianio"];
                        cmd.Parameters.Add("@perimes", SqlDbType.Char, 2).Value = Detalle.Rows[lcont]["perimes"];
                        cmd.Parameters.Add("@peridia", SqlDbType.Char, 2).Value = Detalle.Rows[lcont]["peridia"];
                        cmd.Parameters.Add("@descrip", SqlDbType.VarChar, 30).Value = Detalle.Rows[lcont]["descrip"];
                        //cmd.Parameters.Add("@status", SqlDbType.Bit).Value = Detalle.Rows[lcont]["status"];

                        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_feriados BE)
 {
     using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
     {
         using (SqlCommand cmd = new SqlCommand("gspTbPllaFeriados_SELECT", cnx))
         {
             DataSet ds = new DataSet();
             {
                 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("@peridia", SqlDbType.Char, 2).Value = BE.peridia;
             }
             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_CONSULTACCOSTO(string empresaid, tb_plla_plantilla_contratos BE)
 //{
 //    using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
 //    {
 //        using (SqlCommand cmd = new SqlCommand("gspTbPllaCcostogen_CONSULTASelectAll", cnx))
 //        {
 //            DataSet ds = new DataSet();
 //            {
 //                cmd.CommandType = CommandType.StoredProcedure;
 //                cmd.Parameters.AddWithValue("@empresaid", string.IsNullOrEmpty(BE.empresaid) ? (object)DBNull.Value : BE.empresaid);
 //                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.AddWithValue("@ccostodescartar", string.IsNullOrEmpty(BE.ccostodescartar) ? (object)DBNull.Value : BE.ccostodescartar);
 //            }
 //            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_feriados BE)
 {
     using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
     {
         using (SqlCommand cmd = new SqlCommand("gspTbPllaFeriados_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_CONSULTAIR(string empresaid, tb_plla_feriados BE)
 {
     using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
     {
         using (SqlCommand cmd = new SqlCommand("gspTbPllaFeriados_IR", cnx))
         {
             DataSet ds = new DataSet();
             {
                 cmd.CommandType = CommandType.StoredProcedure;
                 cmd.Parameters.AddWithValue("@perianio", string.IsNullOrEmpty(BE.perianio) ? (object)DBNull.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_feriados 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 CargaDatos()
        {
            int nposcolumnasortear = 0;
            SortOrder PrvSotOrder = default(SortOrder);
            bool zordenado = false;
            string xcodcliente = "..";
            string xpalabra1 = "";
            string xpalabra2 = "";
            string xpalabra3 = "";
            string xperiodo = "";
            if (spnperiodo.Enabled)
            {
                //if ((spnperiodo.Value != null))
                //{
                    if ((!object.ReferenceEquals(spnperiodo.Value, DBNull.Value)))
                    {
                        xperiodo = spnperiodo.Value.ToString();
                    }
                //}
            }
            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["d_fecha"].Value.ToString();
            }
            if ((Examinar.SortedColumn != null))
            {
                nposcolumnasortear = Examinar.SortedColumn.Index;
                PrvSotOrder = Examinar.SortOrder;
                zordenado = true;
            }
            tb_plla_feriadosBL BL = new tb_plla_feriadosBL();
            tb_plla_feriados BE = new tb_plla_feriados();
            BE.perianio = xperiodo;
            BE.nomlike1 = xpalabra1;
            BE.nomlike2 = xpalabra2;
            BE.nomlike3 = xpalabra3;
            tablaclientes = BL.GetAll_CONSULTA(VariablesPublicas.EmpresaID, BE).Tables[0];
            //tablaclientes = ocapa.CaeSoft_GetAllFeriados(xperiodo, "", "", xpalabra1, xpalabra2, xpalabra3);
            if (BL.Sql_Error.Length > 0)
            {
                Frm_Class.ShowError(BL.Sql_Error, this);
                return;
            }
            Examinar.AutoGenerateColumns = false;
            Examinar.DataSource = tablaclientes;
            //if (!(txtdescripcion.MaxLength == tablaclientes.Columns["descrip"].MaxLength))
            //{
            //    txtdescripcion.MaxLength = tablaclientes.Columns["descrip"].MaxLength;
            //}

            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["d_fecha"], System.ComponentModel.ListSortDirection.Ascending);
            }
            if (Examinar.CurrentRow == null)
            {
                if (Examinar.RowCount > 0)
                {
                    Examinar.CurrentCell = Examinar.Rows[0].Cells["d_fecha"];
                }
            }
            //if (Examinar.RowCount > 0)
            //{
            //    lbltotalregistros.Text = Examinar.RowCount.ToString + " Registro(s)";
            //}
            //else
            //{
            //    lbltotalregistros.Text = "";
            //}
            for (lc_cont = 0; lc_cont <= Examinar.Rows.Count - 1; lc_cont++)
            {
                if (Examinar.Rows[lc_cont].Cells["d_fecha"].Value.ToString() == xcodcliente)
                {
                    Examinar.CurrentCell = Examinar.Rows[lc_cont].Cells["descrip"];
                    break;
                }
            }
        }
 private void btngrabar_Click(object sender, EventArgs e)
 {
     if (U_Validacion())
     {
         tb_plla_feriadosBL BL = new tb_plla_feriadosBL();
         tb_plla_feriados BE = new tb_plla_feriados();
         BE.perianio = spnperiodo.Value.ToString();
         BE.perimes = cmbmes.SelectedValue.ToString();
         BE.peridia = txtdias.Text.Trim();
         tmpcursor = BL.GetAll_CONSULTA(VariablesPublicas.EmpresaID, BE).Tables[0];
         //tmpcursor = ocapa.CaeSoft_GetAllFeriados(cmbperiodo.SelectedValue, cmbmes.SelectedValue, txtdias.Text, "", "", "");
         if (tmpcursor.Rows.Count == 0)
         {
             tmpcursor.Rows.Add(VariablesPublicas.InsertIntoTable(tmpcursor));
         }
         tmpcursor.Rows[0]["perianio"] = spnperiodo.Value;
         tmpcursor.Rows[0]["perimes"] = cmbmes.SelectedValue;
         tmpcursor.Rows[0]["peridia"] = txtdias.Text.Trim();
         tmpcursor.Rows[0]["descrip"] = txtdescripcion.Text.Trim();
         tmpcursor.AcceptChanges();
         if (BL.Insert_Update(VariablesPublicas.EmpresaID, BE, tmpcursor))
         {
             seguridadlog();
             //SeguridadLogic.InsertUpdateVariables(Name, cmbperiodo.SelectedValue + cmbmes.SelectedValue + txtdias.Text, "Descripción:" + txtdescripcion.Text, GlobalVars.GetInstance.UserID, "M", UtilitariosInterface.InformacionPC());
             U_CancelarEdicion(0);
         }
         else
         {
             Frm_Class.ShowError(BL.Sql_Error, this);
         }
     }
 }
        private void btneliminar_Click(object sender, EventArgs e)
        {
            if ((Examinar.CurrentRow != null))
            {
                xnomcampo = "";

                if (xnomcampo.Length == 0)
                {
                    tb_plla_feriadosBL BL = new tb_plla_feriadosBL();
                    tb_plla_feriados BE = new tb_plla_feriados();
                    BE.perianio = Examinar.Rows[Examinar.CurrentRow.Index].Cells["perianio"].Value.ToString();
                    BE.perimes = Examinar.Rows[Examinar.CurrentRow.Index].Cells["perimes"].Value.ToString();
                    BE.peridia = Examinar.Rows[Examinar.CurrentRow.Index].Cells["peridia"].Value.ToString();
                    tmptabla = BL.GetAll_CONSULTA(VariablesPublicas.EmpresaID, BE).Tables[0];
                    //tmptabla = ocapa.CaeSoft_GetAllFeriados(Examinar.Rows(Examinar.CurrentRow.Index).Cells("perianio").Value, Examinar.Rows(Examinar.CurrentRow.Index).Cells("MES").Value, Examinar.Rows(Examinar.CurrentRow.Index).Cells("peridia").Value, "", "", "");
                    if (BL.Sql_Error.Length == 0)
                    {
                        string message = "Desea eliminar datos  " + tmptabla.Rows[0]["perianio"].ToString().Trim() + "/" + tmptabla.Rows[0]["mesdia"].ToString().Trim() + "-" + tmptabla.Rows[0]["descrip"].ToString().Trim() + " ...?";
                        string caption = "Mensaje del Sistema";
                        MessageBoxButtons buttons = MessageBoxButtons.YesNo;
                        DialogResult result;
                        // Muestra el cuadro de mensaje.
                        result = MessageBox.Show(this, message, caption, buttons, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
                        if (result == DialogResult.Yes)
                        {
                        //if (Interaction.MsgBox("Desea eliminar datos " + tmptabla.Rows[0]["perianio"].ToString().Trim() + "/" + tmptabla.Rows[0]["MESDIA"].ToString().Trim() + "-" + tmptabla.Rows[0]["descrip"].ToString().Trim(), 4 + 32 + 256, "") == 6)
                        //{
                            BL.Eliminar(VariablesPublicas.EmpresaID, tmptabla);
                            if (BL.Sql_Error.Length == 0)
                            {
                                tb_co_seguridadlogBL BLL = new tb_co_seguridadlogBL();
                                tb_co_seguridadlog BEL = new tb_co_seguridadlog();

                                BEL.moduloid = Name;
                                BEL.clave = VariablesPublicas.EmpresaID + Examinar.Rows[Examinar.CurrentRow.Index].Cells["perianio"].Value.ToString() + Examinar.Rows[Examinar.CurrentRow.Index].Cells["perimes"].Value.ToString() + Examinar.Rows[Examinar.CurrentRow.Index].Cells["peridia"].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);
                                //SeguridadLogic.InsertUpdateVariables(Name, cmbperiodo.SelectedValue + cmbmes.SelectedValue + txtdias.Text, "Descripción:" + txtdescripcion.Text, GlobalVars.GetInstance.UserID, "b", UtilitariosInterface.InformacionPC());
                                Examinar.Rows.Remove(Examinar.CurrentRow);

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