Ejemplo n.º 1
0
        /// <summary>
        /// 功能说明:增加当前用户的登录日志
        /// </summary>
        public void AddLogo(string username)
        {
            string depart = "";
            //根据当前用户名得到所在的部门
            U_UserNameBU user1 = new U_UserNameBU();

            depart = user1.GetDepart1(username);
            user1.Close();


            List <SearchField> list1 = new List <SearchField>();

            list1.Add(new SearchField("sname", username));
            list1.Add(new SearchField("endlogin", "", SearchOperator.空值));
            list1.Add(new SearchField("beginlogin", "", SearchOperator.非空值));
            DataSet ds = this.tabCommand.SearchData("*", list1);

            if (ds.Tables[0].Rows.Count == 0)
            {
                //表示没有用户登录日志记录,则增加一条新的数据记录;
                DataRow dr = ds.Tables[0].NewRow();
                dr["sname"]      = username;
                dr["depart"]     = depart;
                dr["beginlogin"] = DateTime.Now.ToString();
                ds.Tables[0].Rows.Add(dr);
            }
            else
            {
                //表示存在没有完整的用户日志记录
                DateTime dt0 = DateTime.Now;
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    DataRow  dr  = ds.Tables[0].Rows[i];
                    DateTime dt1 = DateTime.Parse(dr["beginlogin"].ToString());
                    if (dt0.Date != dt1.Date)
                    {
                        //日期不相等,则直接修改结束日期为17:30
                        dr["endlogin"] = dt1.Date.ToString("yyyy-MM-dd") + " 17:30:00";
                        DateTime dt2 = DateTime.Parse(dr["endlogin"].ToString());
                        TimeSpan sp1 = dt2 - dt1;
                        dr["time1"] = sp1.Minutes.ToString();

                        //同时新增一条当他记录
                        DataRow dr1 = ds.Tables[0].NewRow();
                        dr1["sname"]      = username;
                        dr1["depart"]     = depart;
                        dr1["beginlogin"] = DateTime.Now.ToString();
                        ds.Tables[0].Rows.Add(dr1);
                    }
                }
            }
            this.tabCommand.Update(ds);
            ds.AcceptChanges();
        }
Ejemplo n.º 2
0
        public DataSet GetFASP(string begintime, string endtime, string depart)
        {
            string sql1 = "select ZCzeren from ZCSPStatView";

            if (depart != "" && depart != null)
            {
                sql1 = sql1 + " where depart='" + depart + "'";
            }
            sql1 = sql1 + " group by ZCzeren";
            DataSet ds1  = this.tabCommand.TableComm.SearchData(sql1);
            string  sql2 = "select max(id) as mid,zcid,ZCzeren,kind from ZCSPStatView where 1=1";

            if (depart != "" && depart != null)
            {
                sql2 = sql2 + " and depart='" + depart + "'";
            }
            if (begintime != "" && begintime != null)
            {
                sql2 = sql2 + " and time0 > '" + begintime + "'";
            }
            if (endtime != "" && endtime != null)
            {
                sql2 = sql2 + " and time0 < '" + endtime + "'";
            }
            sql2 = sql2 + " group by ZCzeren,kind,zcid";
            DataSet   ds2  = this.tabCommand.TableComm.SearchData(sql2);
            DataSet   ds   = new DataSet();
            DataTable tab1 = new DataTable();

            tab1.Columns.Add("zeren");
            tab1.Columns.Add("depart");
            tab1.Columns.Add("count1");
            tab1.Columns.Add("count2");
            tab1.Columns.Add("count3");
            tab1.Columns.Add("count4");
            tab1.Columns.Add("count5");
            tab1.Columns.Add("count6");
            tab1.Columns.Add("count7");
            U_UserNameBU user1 = new U_UserNameBU();
            DataRow      dr    = null;

            for (int i = 0; i < ds1.Tables[0].Rows.Count; i++)
            {
                dr = tab1.NewRow();

                dr["zeren"]  = ds1.Tables[0].Rows[i][0].ToString();
                dr["count1"] = "0";
                dr["count2"] = "0";
                dr["count3"] = "0";
                dr["count4"] = "0";
                dr["count5"] = "0";
                dr["count6"] = "0";
                for (int j = 0; j < ds2.Tables[0].Rows.Count; j++)
                {
                    if (ds2.Tables[0].Rows[j]["ZCzeren"].ToString() == ds1.Tables[0].Rows[i][0].ToString())
                    {
                        if (ds2.Tables[0].Rows[j]["kind"].ToString() == "11")
                        {
                            dr["count1"] = Int32.Parse(dr["count1"].ToString()) + 1;
                        }
                        if (ds2.Tables[0].Rows[j]["kind"].ToString() == "12")
                        {
                            dr["count2"] = Int32.Parse(dr["count2"].ToString()) + 1;
                        }
                        if (ds2.Tables[0].Rows[j]["kind"].ToString() == "13")
                        {
                            dr["count3"] = Int32.Parse(dr["count3"].ToString()) + 1;
                        }
                        if (ds2.Tables[0].Rows[j]["kind"].ToString() == "14")
                        {
                            dr["count4"] = Int32.Parse(dr["count4"].ToString()) + 1;
                        }
                        if (ds2.Tables[0].Rows[j]["kind"].ToString() == "15")
                        {
                            dr["count5"] = Int32.Parse(dr["count5"].ToString()) + 1;
                        }
                        if (ds2.Tables[0].Rows[j]["kind"].ToString() == "16")
                        {
                            dr["count6"] = Int32.Parse(dr["count6"].ToString()) + 1;
                        }
                    }
                }
                dr["count7"] = Int32.Parse(dr["count1"].ToString()) + Int32.Parse(dr["count2"].ToString()) + Int32.Parse(dr["count3"].ToString()) + Int32.Parse(dr["count4"].ToString()) + Int32.Parse(dr["count5"].ToString()) + Int32.Parse(dr["count6"].ToString());
                dr["depart"] = user1.GetDepart1(ds1.Tables[0].Rows[i][0].ToString());
                tab1.Rows.Add(dr);
            }
            user1.Close();
            ds.Tables.Add(tab1);
            return(ds);
        }