public DataSet GetAll(string empresaid, tb_co_tipocompras BE)
 {
     using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
     {
         using (SqlCommand cmd = new SqlCommand("gspTbCoTipocompras_SEARCH", cnx))
         {
             DataSet ds = new DataSet();
             {
                 cmd.CommandTimeout = 0;
                 cmd.CommandType = CommandType.StoredProcedure;
                 cmd.Parameters.Add("@tipoid", SqlDbType.Char, 2).Value = BE.tipoid;
                 cmd.Parameters.Add("@tiponame", SqlDbType.VarChar, 100).Value = BE.tiponame;
                 cmd.Parameters.Add("@cuenta1id", SqlDbType.Char, 10).Value = BE.cuenta1id;
                 cmd.Parameters.Add("@cuenta1name", SqlDbType.VarChar, 100).Value = BE.cuenta1name;
                 cmd.Parameters.Add("@cuenta2id", SqlDbType.Char, 10).Value = BE.cuenta2id;
                 cmd.Parameters.Add("@cuenta2name", SqlDbType.VarChar, 100).Value = BE.cuenta2name;
                 cmd.Parameters.Add("@moneda", SqlDbType.VarChar, 100).Value = BE.moneda;
             }
             try
             {
                 cnx.Open();
                 using (SqlDataAdapter da = new SqlDataAdapter(cmd))
                 {
                     da.Fill(ds);
                 }
                 return ds;
             }
             catch (Exception ex)
             {
                 throw new Exception(ex.Message);
             }
         }
     }
 }
 public bool Delete(string empresaid, tb_co_tipocompras BE)
 {
     using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
     {
         using (SqlCommand cmd = new SqlCommand("gspTbCoTipocompras_DELETE", cnx))
         {
             {
                 cmd.CommandTimeout = 0;
                 cmd.CommandType = CommandType.StoredProcedure;
                 cmd.Parameters.Add("@tipoid", SqlDbType.Char, 3).Value = BE.tipoid;
             }
             try
             {
                 cnx.Open();
                 if (cmd.ExecuteNonQuery() > 0)
                 {
                     return true;
                 }
                 else
                 {
                     return false;
                 }
             }
             catch (Exception ex)
             {
                 throw new Exception(ex.Message);
             }
         }
     }
 }
 public DataSet GetAll_IR(string empresaid, tb_co_tipocompras 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 llenar_Tipocompra()
        {
            try
            {
                tb_co_tipocomprasBL BL = new tb_co_tipocomprasBL();
                tb_co_tipocompras BE = new tb_co_tipocompras();

                switch (cboCriterioBusqueda.SelectedItem.ToString())
                {
                    case "Código":
                        BE.tipoid = txtCadenaBuscar.Text.Trim().ToUpper();
                        break;
                    case "Descripción":
                        BE.tiponame = txtCadenaBuscar.Text.Trim().ToUpper();
                        break;
                    default:
                        BE.tipoid = txtCadenaBuscar.Text.Trim().ToUpper();
                        break;
                }

                Sw_LOad = false;
                if (GridExaminar.RowCount > 0)
                {
                    GridExaminar.Focus();
                    GridExaminar.BeginEdit(true);
                }
                GridExaminar.AutoGenerateColumns = false;
                GridExaminar.DataSource = BL.GetAll(VariablesPublicas.EmpresaID.ToString(), BE).Tables[0];
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 public bool Update(string empresaid, tb_co_tipocompras BE)
 {
     return tablaDA.Update(empresaid, BE);
 }
 public bool Insert(string empresaid, tb_co_tipocompras BE)
 {
     return tablaDA.Insert(empresaid, BE);
 }
 public String GetNextCod(string empresaid, tb_co_tipocompras BE)
 {
     return tablaDA.GetNextCod(empresaid, BE);
 }
 public DataSet GetAll(string empresaid, tb_co_tipocompras BE)
 {
     return tablaDA.GetAll(empresaid, BE);
 }
        private BindingSource NewMethodDoc()
        {
            tb_co_tipocomprasBL BL = new tb_co_tipocomprasBL();
            tb_co_tipocompras BE = new tb_co_tipocompras();

            DataTable tcompra = BL.GetAll(VariablesPublicas.EmpresaID.ToString(), BE).Tables[0];
            DataRowCollection rows = tcompra.Rows;

            object[] cell;
            Dictionary<string, string> dic = new Dictionary<string, string>();
            BindingSource binding = new BindingSource();

            foreach (DataRow item in rows)
            {
                cell = item.ItemArray;
                dic.Add(cell[0].ToString(), cell[0].ToString() + " - " + cell[1].ToString());
                cell = null;
            }
            binding.DataSource = dic;
            return binding;
        }
 public DataSet GetAll_IR(string empresaid, tb_co_tipocompras BE)
 {
     using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
     {
         using (SqlCommand cmd = new SqlCommand("gspTbCoTipocompras_SEARCH_IR", cnx))
         {
             DataSet ds = new DataSet();
             {
                 cmd.CommandTimeout = 0;
                 cmd.CommandTimeout = 0;
                 cmd.CommandType = CommandType.StoredProcedure;
                 cmd.Parameters.Add("@perianio", SqlDbType.Char, 4).Value = BE.perianio;
                 cmd.Parameters.Add("@tipoid", SqlDbType.Char, 2).Value = BE.tipoid;
             }
             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(string empresaid, tb_co_tipocompras BE)
        {
            using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
            {
                using (SqlCommand cmd = new SqlCommand("gspTbCoTipocompras_INSERT", cnx))
                {
                    cmd.CommandTimeout = 0;
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add("@tipoid", SqlDbType.Char, 2).Value = BE.tipoid;
                    cmd.Parameters.Add("@tiponame", SqlDbType.VarChar, 100).Value = BE.tiponame;
                    cmd.Parameters.Add("@cuenta1id", SqlDbType.Char, 10).Value = BE.cuenta1id;
                    cmd.Parameters.Add("@cuenta1name", SqlDbType.VarChar, 100).Value = BE.cuenta1name;
                    cmd.Parameters.Add("@cuenta2id", SqlDbType.Char, 10).Value = BE.cuenta2id;
                    cmd.Parameters.Add("@cuenta2name", SqlDbType.VarChar, 100).Value = BE.cuenta2name;
                    cmd.Parameters.Add("@moneda", SqlDbType.VarChar, 100).Value = BE.moneda;

                    try
                    {
                        cnx.Open();
                        if (cmd.ExecuteNonQuery() > 0)
                        {
                            return true;
                        }
                        else
                        {
                            return false;
                        }
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(ex.Message);
                    }
                }
            }
        }
        public String GetNextCod(string empresaid, tb_co_tipocompras BE)
        {
            String newcod="";

            using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
            {
                using (SqlCommand cmd = new SqlCommand("gspTbCoTipocompras_SEARCH_nextcod", cnx))
                {
                    cmd.CommandTimeout = 0;
                    cmd.CommandType = CommandType.StoredProcedure;
                    try
                    {
                        cnx.Open();
                        SqlDataReader reader= cmd.ExecuteReader();
                        if (reader.Read() )
                        {
                            newcod=Convert.ToString(reader["nextcod"]);
                        }
                        return newcod;
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(ex.Message);
                    }
                }
            }
        }