4.3.2 统计系统 内容来自www.paper51.com copyright paper51.com 图4-7 时间统计分析工作 copyright paper51.com 统计系统无权限的设置,进入统计系统将直接进入的是时间统计分析工作,分别显示了近30天内创建和完成了的工作,具体代码: 内容来自论文无忧网 www.paper51.com
copyright paper51.com
统计按钮的具体代码,分为两部分:首先是对在具体的创建时间条件下显示出工作信息,并能计算出当前条件下的工作总条数,具体代码如下: 内容来自www.paper51.com
paper51.com
………… paper51.com string cq=TextBox1.Text;//接收创建的开始时间 paper51.com string cs=TextBox2.Text;//接受创建的结束时间 内容来自论文无忧网 www.paper51.com SqlConnection conn=new SqlConnection("server=(local);database=jihua;user id='sa';password='123';"); copyright paper51.com
SqlDataAdapter da=new SqlDataAdapter("select work_id as 工作编号,work_name as 工作名称,zhuangtai as 状态,jingji as 紧急重要程度,contain as 内容,wancheng as 完成情况,creattime as 创建时间,creatname as 创建者,flishtime as 完成时间 from works where creattime>='"+cq+"' and creattime <='"+cs+"'",conn);//定义查询时间段内的工作的字符串 内容来自论文无忧网 www.paper51.com
DataSet db=new DataSet(); 内容来自论文无忧网 www.paper51.com conn.Open(); 内容来自论文无忧网 www.paper51.com da.Fill(db,"works1"); paper51.com DataView dv=new DataView(db.Tables["works1"]); copyright paper51.com
DataGrid1.DataSource=db; copyright paper51.com
DataGrid1.DataBind(); 内容来自www.paper51.com
Label1.Text="在"+cq+"到"+cs+"时间内共创建了"+dv.Count+"条工作计划"; paper51.com conn.Close(); paper51.com
………… paper51.com
内容来自www.paper51.com
http://www.paper51.com
copyright paper51.com 其次是计算出当前数据库中的工作总条数,具体代码如下: paper51.com
内容来自论文无忧网 www.paper51.com
………… 内容来自论文无忧网 www.paper51.com
SqlConnection conn1=new SqlConnection("server=(local);database=jihua;user id='sa';password='123';"); 内容来自www.paper51.com conn1.Open(); copyright paper51.com SqlDataAdapter myAdapter=new SqlDataAdapter("select count(work_id) as 总数 from works",conn1);//定义计算出工作的总条数的字符串 http://www.paper51.com DataSet ds=new DataSet(); 内容来自论文无忧网 www.paper51.com DataTable dt=new DataTable(); paper51.com dt=ds.Tables.Add("A"); http://www.paper51.com DataColumn dc=new DataColumn(); copyright paper51.com http://www.paper51.com
http://www.paper51.com paper51.com paper51.com dc=dt.Columns.Add("总数"); paper51.com myAdapter.Fill(ds.Tables["A"]); 内容来自www.paper51.com string i=Convert.ToString(ds.Tables["A"].Rows[0]["总数"]); copyright paper51.com
Label3.Text="现在系统中共有"+i+"条工作";//显示当前系统中工作的总数 内容来自www.paper51.com conn1.Close(); 内容来自www.paper51.com ………… copyright paper51.com
分析按钮的功能是分析在统计按钮的条件下,工作各种状态的条数。具体代码如下: http://www.paper51.com
内容来自www.paper51.com ………… paper51.com string cq=TextBox1.Text; paper51.com string cs=TextBox2.Text; copyright paper51.com SqlConnection conn=new SqlConnection("server=(local);database=jihua;user id='sa';password='123';"); 内容来自www.paper51.com SqlDataAdapter da=new SqlDataAdapter("select zhuangtai from works where creattime>='"+cq+"' and creattime <='"+cs+"' and zhuangtai='将做'",conn); copyright paper51.com SqlDataAdapter dc=new SqlDataAdapter("select zhuangtai from works where creattime>='"+cq+"' and creattime <='"+cs+"' and zhuangtai='进行中'",conn); paper51.com
SqlDataAdapter dd=new SqlDataAdapter("select zhuangtai from works where creattime>='"+cq+"' and creattime <='"+cs+"' and zhuangtai='完成'",conn); 内容来自www.paper51.com
SqlDataAdapter de=new SqlDataAdapter("select zhuangtai from works where creattime>='"+cq+"' and creattime <='"+cs+"' and zhuangtai='审查完成'",conn); 内容来自论文无忧网 www.paper51.com
SqlDataAdapter df=new SqlDataAdapter("select jingji from works where creattime>='"+cq+"' and creattime <='"+cs+"' and jingji='紧急重要'",conn); paper51.com SqlDataAdapter dg=new SqlDataAdapter("select jingji from works where creattime>='"+cq+"' and creattime <='"+cs+"' and jingji='重要不紧急'",conn); 内容来自www.paper51.com SqlDataAdapter dh=new SqlDataAdapter("select jingji from works where creattime>='"+cq+"' and creattime <='"+cs+"' and jingji='紧急不重要'",conn); copyright paper51.com SqlDataAdapter di=new SqlDataAdapter("select jingji from works where creattime>='"+cq+"' and creattime <='"+cs+"' and jingji='不紧急不重要'",conn); 内容来自论文无忧网 www.paper51.com DataSet db=new DataSet(); 内容来自论文无忧网 www.paper51.com …………… http://www.paper51.com
DataSet di1=new DataSet(); http://www.paper51.com
conn.Open(); http://www.paper51.com da.Fill(db,"works1"); 内容来自论文无忧网 www.paper51.com DataView dv=new DataView(db.Tables["works1"]); 内容来自www.paper51.com Label4.Text="分析:将做:"+dv.Count+"条;"; copyright paper51.com
………… 内容来自www.paper51.com di.Fill(di1,"works8"); 内容来自论文无忧网 www.paper51.com DataView dv7=new DataView(di1.Tables["works8"]); 内容来自www.paper51.com Label11.Text="不紧急不重要:"+dv7.Count+"条;"; 内容来自论文无忧网 www.paper51.com
conn.Close(); 内容来自论文无忧网 www.paper51.com
|