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

📄 mattendance.aspx.cs

📁 oa办公系统
💻 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.Data.SqlClient;

public partial class MAttendance : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["uname"] != null && Session["role"].ToString() == "1")
        {
            if (!IsPostBack)
            {
                band();

            }
        }
    }
    private void band()
    {
        staff s = new staff();
        this.gridattendance.DataSource = s.SelectAllAttendance();
        this.gridattendance.DataBind();
    }
    protected void gridattendance_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            //鼠标经过时,行背景色变 
             e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='#ECF3E1'");
           // 鼠标移出时,行背景色变 
              e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='#FFFFFF'");
            DataRowView dv = (DataRowView)e.Row.DataItem;
            if (Convert.ToString(dv["ondutyStatus"]) == "1")
            {
                ((Label)e.Row.FindControl("labstatus1")).Text = "正常上班";
            }
            else if (Convert.ToString(dv["ondutyStatus"]) == "0")
            {
                ((Label)e.Row.FindControl("labstatus1")).Text = "迟到";
                ((Label)e.Row.FindControl("labstatus1")).ForeColor = System.Drawing.Color.Red;
            }
            else if (Convert.ToString(dv["ondutyStatus"]) == "")
            {
                ((Label)e.Row.FindControl("labstatus1")).Text = "旷工";
                ((Label)e.Row.FindControl("labstatus1")).ForeColor = System.Drawing.Color.Red;
            }
            if (Convert.ToString(dv["offdutyStatus"]) == "1")
            {
                ((Label)e.Row.FindControl("labstatus2")).Text = "正常下班";
            }
            else if ((Convert.ToString(dv["offdutyStatus"]) == "0"))
            {
                ((Label)e.Row.FindControl("labstatus2")).Text = "早退";
                ((Label)e.Row.FindControl("labstatus2")).ForeColor = System.Drawing.Color.Red;
            }
            else if ((Convert.ToString(dv["offdutyStatus"]) == ""))
            {
                ((Label)e.Row.FindControl("labstatus2")).Text = "旷工";
                ((Label)e.Row.FindControl("labstatus2")).ForeColor = System.Drawing.Color.Red;
            }
        }
    }
    protected void gridattendance_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        this.gridattendance.PageIndex = e.NewPageIndex;
        band();
    }
    protected void btnsearch_Click(object sender, EventArgs e)
    {
        if (this.t_id.Text != "")
        {
            staff s = new staff();
            this.gridattendance.DataSource = s.SelectAttendance(this.t_id.Text.Trim().ToString(), this.dropmonth.SelectedValue.ToString());
            this.gridattendance.DataBind();
            SqlDataReader dr = s.SelectTotle(this.t_id.Text.Trim().ToString(), this.dropmonth.SelectedValue.ToString());
            if (dr.Read())
            {
                string later = dr["later"].ToString();
                string early = dr["early"].ToString();
                int nowork = Convert.ToInt32(dr["nowork1"]) + Convert.ToInt32(dr["nowork2"]);
                lablater.Text = "<Font color=red>迟到:</font>" + later + "次";
                labearly.Text = "<Font color=red>早退:</font>" + early + "次";
                labnowork.Text = "<Font color=red>旷工:</font>" + nowork + "次";
            }
        }
        else
        {
            Response.Write("<script>alert('员工编号不能为空!')</script>");
        }
    }
}

⌨️ 快捷键说明

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