做了个考勤系统,现在审核页面有问题
public partial class LoginAdmin_ShenHe : System.Web.UI.Page{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (!Page.IsPostBack)
{
if (Session["User"] == null || Session["User"].ToString() == "")
{
Response.Write("<script>alert('超时,请重新登录!');top.location.href='../Login.aspx'</script>"); return;
}
}
if (Session["User"] == null || Session["User"].ToString() == "")
{
Response.Write("<script>alert('超时,请重新登录!');top.location.href='../Login.aspx'</script>"); return;
}
Bind();
}
}
#region 绑定Gridview
public void Bind()
{
IList<Kaoqin> list = KaoqinManager.GetKaoqinByState();
this.GridView1.DataSource = list;
this.GridView1.DataBind();
}
//员工名称
public string UserName(object userid)
{
int id = Convert.ToInt32(userid.ToString());
User user = UserManager.GetUserByUserid(id);
if (user != null)
{
return user.Username;
}
else
{
return "";
}
}
//休假时间
public string XiujiaName(object XiujiaId)
{
int id = Convert.ToInt32(XiujiaId.ToString());
if (id != 0)
{
Xiujia xiujia = XiujiaManager.GetXiujiaByXid(id);
return xiujia.Xname;
}
else
{
return "";
}
}
//时间
public string Time(object time, object outTime)
{
DateTime name = Convert.ToDateTime(time);
if (name.ToString() == outTime.ToString())
{
return "";
}
else if (name.Year > 2009)
{
return time.ToString();
}
else
{
return "";
}
}
#region 查询
protected void btnSelect_Click(object sender, EventArgs e)
{
List<Kaoqin> kaoqinList = new List<Kaoqin>();
string userName = this.txtSelectUserName.Text.Trim();
List<User> list = UserManager.GetUserByUserName(userName);
if (list != null)
{
foreach (User user in list)
{
List<Kaoqin> kq = KaoqinManager.GetKaoqinByUserId(user.Userid);
foreach (Kaoqin kaoqin in kq)
{
kaoqinList.Add(kaoqin);
}
}
}
this.GridView1.DataSource = kaoqinList;
this.GridView1.DataBind();
}
#endregion
protected void Button1_Click(object sender, EventArgs e)
{
foreach (GridViewRow row in GridView1.Rows)
{
CheckBox checkBox = row.FindControl("cboCheck") as CheckBox;
if (checkBox.Checked)
{
int id = Convert.ToInt32(GridView1.DataKeys[row.RowIndex].Value);
Kaoqin kaoqin=new Kaoqin();
kaoqin.Kid=id;
kaoqin.State=1;
KaoqinManager.ModifyKaoqinByStatus(kaoqin);
this.ClientScript.RegisterStartupScript(this.GetType(),"","alert('审核成功!');",true);
Response.Redirect("ShenHe.aspx");
}
}
}
这是管审核的类
#region 查询未通过审核的考勤记录
public static List<Kaoqin> GetKaoqinByState()
{
string sql = "select * from kaoqin where state=0 order by kid desc";
List<Kaoqin> list = new List<Kaoqin>();
try
{
DataTable table = DBHelper.GetDataSet(sql);
foreach (DataRow row in table.Rows)
{
Kaoqin kaoqin = new Kaoqin();
if (!Convert.IsDBNull(row["kid"]))
kaoqin.Kid = (int)row["kid"];
if (!Convert.IsDBNull(row["userid"]))
kaoqin.Userid = (int)row["userid"];
if (!Convert.IsDBNull(row["kintime"]))
kaoqin.Kintime = (DateTime)row["kintime"];
if (!Convert.IsDBNull(row["kouttime"]))
kaoqin.Kouttime = (DateTime)row["kouttime"];
if (!Convert.IsDBNull(row["xiujiaid"]))
kaoqin.Xiujiaid = (int)row["xiujiaid"];
if (!Convert.IsDBNull(row["state"]))
kaoqin.State = (int)row["state"];
list.Add(kaoqin);
}
return list;
}
现在是这样一种状态,领导审核的时候所有部门的员工考勤信息都显示出来了,我需要把员工的考勤信息按照部门显示,并且审核。具体比如:“登录的考勤记录员是信息科的,那么审核页面里显示的都是信息科的考勤记录。”这样的话代码如何修改啊,需要修改审核的类啊,还是需要修绑定数据,考勤表中没有部门id,只有考勤id和用户id 。