Пример #1
0
        private void SelectLogTypeForm_Load(object sender, EventArgs e)
        {
            List <string> logTypes = WriteLog.GetLogTypes();

            comboBox1.Items.Clear();
            comboBox1.Items.Add("--不限--");
            foreach (string logT in logTypes)
            {
                comboBox1.Items.Add(logT);
            }
            comboBox1.SelectedIndex = 0;
        }
Пример #2
0
        private int LoadLogs(string logtype = null)
        {
            List <string> logTypes = WriteLog.GetLogTypes();

            comboBox1.Items.Clear();
            comboBox1.Items.Add("--不限--");
            foreach (string logT in logTypes)
            {
                comboBox1.Items.Add(logT);
            }
            loadOver = false;
            if (logtype == null)
            {
                comboBox1.SelectedIndex = 0;
            }
            else
            {
                comboBox1.SelectedIndex = comboBox1.Items.IndexOf(logtype);
            }
            loadOver = true;
            string logType = null;

            if (comboBox1.SelectedItem.ToString() != "--不限--")
            {
                logType = comboBox1.SelectedItem.ToString();
            }
            dataGridView1.DataSource = WriteLog.GetLogs(index, size, logType, out allCount);
            pageCount = allCount / size;
            int R = allCount % size;

            if (R > 0)
            {
                pageCount++;
            }
            int begin = size * index;

            if (pageCount == 0)
            {
                textBox1.Text = "0/0";
            }
            else
            {
                int r = begin + size;
                if (pageCount == 1)
                {
                    r = begin + R;
                }
                else if (pageCount > 1 && index == pageCount - 1)
                {
                    if (R == 0)
                    {
                        r = begin + size;
                    }
                    else
                    {
                        r = begin + R;
                    }
                }
                textBox1.Text = Convert.ToString(begin + 1) + "-" + r + "/" + allCount + " 当前第" + (index + 1) + "页,共" + pageCount + "页(每页" + size + "条记录)";
            }
            return(pageCount);
        }