/// <summary> /// 加载绑定 /// </summary> public void BindLoad() { if (txtNo.Value.Trim().Length != 0) { strWhere += " and L_No like '%" + txtNo.Value.Trim() + "%'"; } if (txtName.Value.Trim().Length != 0) { strWhere += " and L_Name like '%" + txtName.Value.Trim() + "%'"; } if (txtTel.Value.Trim().Length != 0) { strWhere += " and L_Tel like '%" + txtTel.Value.Trim() + "%'"; } if (txtIdCard.Value.Trim().Length != 0) { strWhere += " and L_IdCard like '%" + txtIdCard.Value.Trim() + "%'"; } if (txtBeginTime.Value.Trim().Length != 0 && txtEndTime.Value.Trim().Length != 0) { strWhere += " and (C_Time>='" + txtBeginTime.Value.Trim() + " 00:00:00' and C_Time<='" + txtEndTime.Value.Trim() + " 23:59:59')"; } int DataCount = ConsumptionBLL.CountNumber2(strWhere); //共多少条记录 int hPageSize = (DataCount % Convert.ToInt32(HCount.Value)) != 0 ? DataCount / Convert.ToInt32(HCount.Value) + 1 : DataCount / Convert.ToInt32(HCount.Value); //共多少页 HPageSize.Value = DataCount.ToString(); HAllPage.Value = hPageSize.ToString(); this.RpNews.DataSource = ConsumptionBLL.PageSelectConsumption2(Convert.ToInt32(HCount.Value), Convert.ToInt32(HNowPage.Value), strWhere, "C_Time", "desc"); this.RpNews.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { if (Session["Users"] != null) { users = (Users)Session["Users"]; } else { users = null; Response.Write("<script>parent.window.location.href='Login.aspx'</script>"); } if (!IsPostBack) { txtUserName.Value = users.U_Name.Trim(); if (Request.QueryString["id"] != null) { Live live = LiveBLL.GetIdByLive(Convert.ToInt32(Request.QueryString["id"])); if (live != null && live.L_Id != 0) { txtNo.Value = live.L_No.Trim(); RpNews.DataSource = ConsumptionBLL.AllData(" and L_Id=" + live.L_Id + " order by C_Time desc"); RpNews.DataBind(); } } } }
/// <summary> /// 消费累计 /// </summary> /// <param name="L_Id"></param> /// <returns></returns> public string GetSum(object L_Id) { string price = "无"; decimal i = ConsumptionBLL.ConsumptionSum(Convert.ToInt32(L_Id)); if (i != 0) { price = i.ToString(); } return(price); }
//删除 protected void ibDel_ItemDeleting(object sender, EventArgs e) { try { int Id = Convert.ToInt32((sender as LinkButton).CommandArgument); ConsumptionBLL.DeleteConsumption(Id); Response.Write("<script>alert('删除成功!');window.location.replace('ConsumptionAdd.aspx?id=" + Request.QueryString["id"] + "');</script>"); } catch { Response.Write("<script>alert('删除失败!');</script>"); } }
/// <summary> /// 添加,修改 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnUpdate_Click(object sender, EventArgs e) { if (btnUpdate.Text == "添加") { Consumption model = new Consumption(); model.C_Name = txtName.Value.Trim(); model.C_Price = Convert.ToDecimal(txtPrice.Value.Trim()); model.C_Time = Convert.ToDateTime(txtTime.Value.Trim()); Live live = LiveBLL.GetIdByLive(Convert.ToInt32(Request.QueryString["id"])); model.L_Id = live.L_Id; model.U_Id = users.U_Id; if (ConsumptionBLL.AddConsumption(model) > 0) { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('添加成功!');window.location.replace('ConsumptionAdd.aspx?id=" + Request.QueryString["id"] + "');</script>"); return; } else { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('添加失败!');</script>"); return; } } }
//分页查找 private void BindData(string strClass) { int nowPage = 1; switch (strClass) { case "next": nowPage = Convert.ToInt32(HNowPage.Value) + 1; break; case "up": nowPage = Convert.ToInt32(HNowPage.Value) - 1; break; case "end": nowPage = Convert.ToInt32(HAllPage.Value); break; default: nowPage = 1; break; } if (Convert.ToInt32(HAllPage.Value) <= 1) { LBEnd.Enabled = false; LBHome.Enabled = false; LBNext.Enabled = false; LBUp.Enabled = false; } else if (nowPage == 1) { LBHome.Enabled = false; LBUp.Enabled = false; LBNext.Enabled = true; LBEnd.Enabled = true; } else if (nowPage == Convert.ToInt32(HAllPage.Value)) { LBHome.Enabled = true; LBUp.Enabled = true; LBNext.Enabled = false; LBEnd.Enabled = false; } else { LBEnd.Enabled = true; LBHome.Enabled = true; LBNext.Enabled = true; LBUp.Enabled = true; } if (txtNo.Value.Trim().Length != 0) { strWhere += " and L_No like '%" + txtNo.Value.Trim() + "%'"; } if (txtName.Value.Trim().Length != 0) { strWhere += " and L_Name like '%" + txtName.Value.Trim() + "%'"; } if (txtTel.Value.Trim().Length != 0) { strWhere += " and L_Tel like '%" + txtTel.Value.Trim() + "%'"; } if (txtIdCard.Value.Trim().Length != 0) { strWhere += " and L_IdCard like '%" + txtIdCard.Value.Trim() + "%'"; } if (txtBeginTime.Value.Trim().Length != 0 && txtEndTime.Value.Trim().Length != 0) { strWhere += " and (C_Time>='" + txtBeginTime.Value.Trim() + " 00:00:00' and C_Time<='" + txtEndTime.Value.Trim() + " 23:59:59')"; } this.RpNews.DataSource = ConsumptionBLL.PageSelectConsumption2(Convert.ToInt32(HCount.Value), nowPage, strWhere, "C_Time", "desc"); this.RpNews.DataBind(); HNowPage.Value = nowPage.ToString(); PageMes.Text = string.Format("每页{0}条 第{1}页/共{2}页 共{3}条", HCount.Value, nowPage.ToString(), HAllPage.Value, HPageSize.Value); }