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

📄 signstatistic.aspx.cs

📁 OA系统源码 办公应用软件源码 asp.net 开发
💻 CS
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;
using MyOffice.BLL;
using MyOffice.Models;

public partial class MonuoalSign_SignStatistic : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack) {
           
            ListItem li = new ListItem();
            li.Text = "==请选择==";
            li.Value = 0 + "";
            ddlBranchs.Items.Add(li);
            ListItem lis = new ListItem();
            lis.Text = "==请选择==";
            lis.Value = 0 + "";
            ddlDeparts.Items.Add(lis);
            Branch();
        }
    }
    //查询所有机构
    public void Branch()
    {

        List<BranchInfoModel> liBrach = personManageBLL.AllSeBr();
        foreach (BranchInfoModel bim in liBrach)
        {
            ListItem list = new ListItem();
            list.Text = bim.BranchName;
            list.Value = bim.BranchId.ToString();
            ddlBranchs.Items.Add(list);
        }
    }
    //根据机构信息查询相应的部门信息
    protected void ddlBranchs_SelectedIndexChanged(object sender, EventArgs e)
    {
        int brachId = int.Parse(ddlBranchs.SelectedValue);
        List<DepartInfoModel> lisdeinfo = personManageBLL.SeDeBId(brachId);
        ddlDeparts.Items.Clear();
        foreach (DepartInfoModel dif in lisdeinfo)
        {
            ListItem listm = new ListItem();
            listm.Text = dif.DepartName;
            listm.Value = dif.DepartId.ToString();
            ddlDeparts.Items.Add(listm);
        }
    }
    protected void btnStatistic_Click(object sender, EventArgs e)
    {
        divReportUser.Visible = true;
        DateTime beginTime = DateTime.Parse(txtBeginTime.Text+" 00:00:00");
        DateTime endTime = DateTime.Parse(txtEndTime.Text+" 23:59:59");

        int BrachId = int.Parse(ddlBranchs.SelectedValue);
        int DepartId = int.Parse(ddlDeparts.SelectedValue);
        List<ManualSignModel> limansign = companyBLL.SeTimeBrDeManSign(beginTime,endTime,BrachId,DepartId);
        gvSignInfoStatistic.DataSource = limansign;
        gvSignInfoStatistic.DataBind();
        Unite(gvSignInfoStatistic);
        /* List<UserInfoModel> liusinfo = companyBLL.SelecTimekaoqin(beginTime,endTime,BrachId,DepartId);
        gvSignInfoStatistic.DataSource = liusinfo;
        gvSignInfoStatistic.DataBind();*/
    }
    protected void Unite(GridView gv)
    {
        int i;
        string LastType1;
        int LastCell;
        if (gv.Rows.Count > 0)
        {
            for (int j = 0; j < 7; j++)
            {
                if (j < 1 || j > 4)
                {
                    LastType1 = gv.Rows[0].Cells[j].Text;
                    gv.Rows[0].Cells[j].RowSpan = 1;
                    LastCell = 0;

                    for (i = 1; i < gv.Rows.Count; i++)
                    {
                        if (gv.Rows[i].Cells[j].Text == LastType1)
                        {
                            gv.Rows[i].Cells[j].Visible = false;
                            gv.Rows[LastCell].Cells[j].RowSpan++;
                        }
                        else
                        {
                            LastType1 = gv.Rows[i].Cells[j].Text;
                            LastCell = i;
                            gv.Rows[i].Cells[j].RowSpan = 1;
                        }
                    }
                }
            }
        }
    }
    protected void gvSignInfoStatistic_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow) {
            UserInfoModel usinfo = (UserInfoModel)Session["User"];
            lblReportUser.Text = usinfo.UserName;
            lblReportTime.Text = DateTime.Now.ToString();
            DateTime beginTime = DateTime.Parse(txtBeginTime.Text + " 00:00:00");
            DateTime endTime = DateTime.Parse(txtEndTime.Text + " 23:59:59");

            int manSignId = int.Parse(gvSignInfoStatistic.DataKeys[e.Row.RowIndex].Value.ToString());
            ManualSignModel msm = companyBLL.SelectManualId(manSignId);
            e.Row.Cells[0].Text = msm.Usinfo.UserName;
            //根据人员Id和时间查询出勤次数
            int count = 0;
            DateTime begin = DateTime.Parse(txtBeginTime.Text);
            DateTime end = DateTime.Parse(txtEndTime.Text);
            TimeSpan ts = end - begin;
            double totalDays = ts.TotalDays;
            double intTotalDays = Math.Ceiling(totalDays);
            int differDays = int.Parse(intTotalDays.ToString());
            for (int i = 0; i < differDays; i++)
            {
                DateTime datetime = begin.AddDays(i);
                if (datetime.DayOfWeek != DayOfWeek.Saturday && datetime.DayOfWeek != DayOfWeek.Sunday)
                {
                    count++;
                }
            }
            string zong = count + "";
            int chuqin = companyBLL.SeCountTimeId(msm.UserId, beginTime, endTime, 0);
            string zhi = chuqin + "";
            double panduan = double.Parse(zhi) / double.Parse(zong) * 100.0;
            double result = Math.Round(panduan, 2);
            e.Row.Cells[1].Text = result.ToString() + "%";
            //计算迟到次数
            WorkTimeModel wtm = companyBLL.SeWorkTime();
            DateTime GoWork = DateTime.Parse(wtm.OnDutyTime);
            List<ManualSignModel> limasign = companyBLL.AllSeMan(msm.UserId,beginTime,endTime,0);
            int chicount = 0;
            if (limasign.Count != 0) {
                foreach (ManualSignModel mag in limasign) {
                    DateTime gotimes = DateTime.Parse(mag.SignTime.Hour + ":" + mag.SignTime.Minute);
                    if (gotimes > GoWork) {
                        chicount++;
                    }
                }
            }
            e.Row.Cells[2].Text = count.ToString();
            //计算早退次数
            int zaocount = 0;
            DateTime OffWork = DateTime.Parse(wtm.OffDutyTime);
            List<ManualSignModel> manSign = companyBLL.AllSeMan(msm.UserId, beginTime, endTime, 1);
            if (limasign.Count != 0)
            {
                foreach (ManualSignModel sign in manSign)
                {
                    DateTime gotimes = DateTime.Parse(sign.SignTime.Hour + ":" + sign.SignTime.Minute);
                    if (gotimes < OffWork)
                    {
                        zaocount++;
                    }
                }
            }
            e.Row.Cells[3].Text = zaocount.ToString();
            //计算旷课次数
            int kuangcount = count - chuqin;
            e.Row.Cells[4].Text = kuangcount.ToString();
            e.Row.Cells[5].Text = msm.Usinfo.Depart.DepartName;
            e.Row.Cells[6].Text = msm.Usinfo.Depart.Branch.BranchName;

        }
        

    }
}

⌨️ 快捷键说明

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