Пример #1
0
        private void iniciarBusqueda(bool lastPage)
        {
            datagridviewNE1.Columns.Clear();
            int offset             = 0;
            int p                  = constants.stringToInt(textBox2.Text);
            sqlDateBaseManager sql = new sqlDateBaseManager();

            if (checkBox1.Checked == false)
            {
                if (textBox1.Text == "")
                {
                    c           = sql.countCotizaciones(org_search, false, "", false);
                    paginas     = (int)Math.Ceiling((float)c / div);
                    label4.Text = "Páginas: " + (paginas);
                    label2.Text = "Total de registros en (" + constants.user + "): " + c;
                    if (lastPage == false)
                    {
                        p      = p > 0 ? p - 1 : 0;
                        offset = p;
                    }
                    else
                    {
                        if (paginas > 0)
                        {
                            offset = paginas - 1;
                        }
                        else
                        {
                            offset = 0;
                        }
                        textBox2.Text = paginas.ToString();
                    }
                    sql.dropTableCotizacionesOnGridView(datagridviewNE1, org_search, false, "", false, offset * div, div);
                }
                else
                {
                    c           = sql.countCotizaciones(org_search, false, textBox1.Text, true);
                    paginas     = (int)Math.Ceiling((float)c / div);
                    label4.Text = "Páginas: " + (paginas);
                    label2.Text = "Total de registros en (" + constants.user + "): " + c;
                    if (lastPage == false)
                    {
                        p      = p > 0 ? p - 1 : 0;
                        offset = p;
                    }
                    else
                    {
                        if (paginas > 0)
                        {
                            offset = paginas - 1;
                        }
                        else
                        {
                            offset = 0;
                        }
                        textBox2.Text = paginas.ToString();
                    }
                    sql.dropTableCotizacionesOnGridView(datagridviewNE1, org_search, false, textBox1.Text, true, offset * div, div);
                }
            }
            else
            {
                if (textBox1.Text == "")
                {
                    c           = sql.countCotizaciones(org_search, true, "", false);
                    paginas     = (int)Math.Ceiling((float)c / div);
                    label4.Text = "Páginas: " + (paginas);
                    label2.Text = "Total de registros: " + c;
                    if (lastPage == false)
                    {
                        p      = p > 0 ? p - 1 : 0;
                        offset = p;
                    }
                    else
                    {
                        if (paginas > 0)
                        {
                            offset = paginas - 1;
                        }
                        else
                        {
                            offset = 0;
                        }
                        textBox2.Text = paginas.ToString();
                    }
                    sql.dropTableCotizacionesOnGridView(datagridviewNE1, org_search, true, "", false, offset * div, div);
                }
                else
                {
                    c           = sql.countCotizaciones(org_search, true, textBox1.Text, true);
                    paginas     = (int)Math.Ceiling((float)c / div);
                    label4.Text = "Páginas: " + (paginas);
                    label2.Text = "Total de registros: " + c;
                    if (lastPage == false)
                    {
                        p      = p > 0 ? p - 1 : 0;
                        offset = p;
                    }
                    else
                    {
                        if (paginas > 0)
                        {
                            offset = paginas - 1;
                        }
                        else
                        {
                            offset = 0;
                        }
                        textBox2.Text = paginas.ToString();
                    }
                    sql.dropTableCotizacionesOnGridView(datagridviewNE1, org_search, true, textBox1.Text, true, offset * div, div);
                }
            }
            setIndicador();
        }