⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 report.cs

📁 这是一个考勤系统大家多多指教
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace kaoqin.rpt
{
    public partial class report : Form
    {
        public report()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            print();
        }

        private void print()
        {
            string sql = "select * from vwQueryPrint";
            bool where = false;

            if (this.txtCd.Text.Trim() != "")
            {
                string temp = " where cidao";
                string sign = ">";
                if (this.cbCd.SelectedIndex == 1)
                {
                    sign = "<";
                }
                if (this.cbCd.SelectedIndex == 2)
                {
                    sign = "=";
                }
                sql += temp + sign + "'" + this.txtCd.Text.Trim() + "' ";
                where = true;
            }

            if (this.txtZt.Text.Trim() != "")
            {
                string sign = ">";

                if (this.cbCd.SelectedIndex == 1)
                {
                    sign = "<";
                }
                else if (this.cbCd.SelectedIndex == 2)
                {
                    sign = "=";
                }

                if (where)
                {
                    string temp = " and zaotui";
                    sql += temp + sign + "'" + this.txtZt.Text.Trim() + "' ";
                }
                else
                {
                    string temp = " where zaotui ";
                    sql += temp + sign + "'" + this.txtZt.Text.Trim() + "' ";
                    where = true;
                }

            }


            if (this.txtKk.Text.Trim() != "")
            {
                string sign = ">";

                if (this.cbKk.SelectedIndex == 1)
                {
                    sign = "<";
                }
                else if (this.cbKk.SelectedIndex == 2)
                {
                    sign = "=";
                }

                if (where)
                {
                    string temp = " and kuangke ";
                    sql += temp + sign + "'" + this.txtKk.Text.Trim() + "' ";
                }
                else
                {
                    string temp = " where kuangke  ";
                    sql += temp + sign + "'" + this.txtKk.Text.Trim() + "' ";
                    where = true;
                }

            }


            if (this.txtQj.Text.Trim() != "")
            {
                string sign = ">";

                if (this.cbQj.SelectedIndex == 1)
                {
                    sign = "<";
                }
                else if (this.cbQj.SelectedIndex == 2)
                {
                    sign = "=";
                }

                if (where)
                {
                    string temp = " and qingjia ";
                    sql += temp + sign + "'" + this.txtQj.Text.Trim() + "' ";
                }
                else
                {
                    string temp = " where qingjia  ";
                    sql += temp + sign + "'" + this.txtQj.Text.Trim() + "' ";
                    where = true;
                }
            }

            if (this.txtXh.Text.Trim() != "")
            {
                string sign = "=";
                if (where)
                {
                    string temp = " and xuehao ";
                    sql += temp + sign + "'" + this.txtXh.Text.Trim() + "' ";
                }
                else
                {
                    string temp = " where xuehao  ";
                    sql += temp + sign + "'" + this.txtXh.Text.Trim() + "' ";
                    where = true;
                }
            }

            if (this.txtXm.Text.Trim() != "")
            {
                string sign = "=";
                if (where)
                {
                    string temp = " and studentName ";
                    sql += temp + sign + "'" + this.txtXm.Text.Trim() + "' ";
                }
                else
                {
                    string temp = " where studentName  ";
                    sql += temp + sign + "'" + this.txtXm.Text.Trim() + "' ";
                    where = true;
                }
            }

            if (this.cbBj.SelectedIndex != -1)
            {
                string sign = "=";
                if (where)
                {
                    string temp = " and className ";
                    sql += temp + sign + "'" + this.cbBj.SelectedItem.ToString() + "' ";
                }
                else
                {
                    string temp = " where className  ";
                    sql += temp + sign + "'" + this.cbBj.SelectedItem.ToString() + "' ";
                    where = true;
                }
            }

            if (this.cbXb.SelectedIndex != -1)
            {
                string sign = "=";
                if (where)
                {
                    string temp = " and departName ";
                    sql += temp + sign + "'" + this.cbXb.SelectedItem.ToString() + "' ";
                }
                else
                {
                    string temp = " where departName  ";
                    sql += temp + sign + "'" + this.cbXb.SelectedItem.ToString() + "' ";
                    where = true;
                }
            }
            DataTable dt = DB.getTable(sql);
            if (dt.Rows.Count == 0)
            {
                MessageBox.Show("对不起,没找到您要的记录!");
            }
            CrystalReport1 report = new CrystalReport1();
            report.SetDataSource(dt);
            this.crystalReportViewer2.ReportSource = report;
         
            //this.dataGrid1.DataSource = dt;
        }

        private void report_Load(object sender, EventArgs e)
        {

        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -