/// <summary> /// 绑定Grid /// </summary> protected void BindGrid() { SLoginDiaryBB loginDiaryBB = new SLoginDiaryBB(); DataSet ds = new DataSet(); try { string strWhere = this.StrWhere; if (this.loginStartDate.Text != "") { strWhere += " and loginDate>='" + this.loginStartDate.Text + "'"; } if (this.loginEndDate.Text != "") { strWhere += " and loginDate<'" + Convert.ToDateTime(this.loginEndDate.Text).AddDays(1).ToString() + "'"; } if (this.empNm.Text != "") { strWhere += " and (empNm like '%" + this.empNm.Text + "%' or empNo like '%" + this.empNm.Text + "%')"; } ds = loginDiaryBB.GetVList(strWhere); this.grid.DataSource = ds.Tables[0]; this.grid.DataBind(); //赋值记录条数、页面总数 this.Label3.Text = ds.Tables[0].Rows.Count.ToString(); this.Label2.Text = this.grid.PageCount.ToString(); this.currPage.Text = (this.grid.PageIndex + 1).ToString(); } finally { loginDiaryBB.Dispose(); } }
/// <summary> /// 删除 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnDel_Click(object sender, EventArgs e) { bool retChecked = false; SLoginDiaryBB loginDiaryBB = new SLoginDiaryBB(); try { //获取选中的数据Id foreach (GridViewRow gvrow in this.grid.Rows) { CheckBox chkId = (CheckBox)gvrow.FindControl("chkId"); if (chkId.Checked == true) { retChecked = true; int id = int.Parse(chkId.ValidationGroup); loginDiaryBB.DeleteRecord(id); } } } catch (Exception ex) { this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true); return; } finally { loginDiaryBB.Dispose(); } if (retChecked) { this.BindGrid(); } }
private void LoginDiary() { SLoginDiaryBB loginDiaryBB = new SLoginDiaryBB(); SLoginDiaryData loginDiaryData = new SLoginDiaryData(); try { loginDiaryData.empNo = this.txtUsername.Value.Trim(); if (Session["UserData"] != null) { loginDiaryData.empId = ((HEemployeeData)Session["UserData"]).empId; loginDiaryData.isLogined = true; } //获取客户端IP地址 string uip = ""; if (Request.ServerVariables["HTTP_VIA"] != null) { uip = Request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString(); } else { uip = Request.ServerVariables["REMOTE_ADDR"].ToString(); } loginDiaryData.loginIp = uip; loginDiaryData.loginDate = DateTime.Now.ToString(); loginDiaryBB.AddRecord(loginDiaryData); } catch { } finally { loginDiaryBB.Dispose(); } }