private bool DoEdit(int id) { bool result = true; int PartnerID = id; string Partnername = this.txtPartnername.Text; string StarLevel = this.txtStarLevel.Text; string StarICO = this.txtStarICO.Text; string Remark = this.txtRemark.Value; WebSiteModel.Partner model = new WebSiteModel.Partner(); model.PartnerID = PartnerID; model.Partnername = Partnername; model.StarLevel = StarLevel; model.StarICO = StarICO; model.Remark = Remark; WebSiteData.Partner bll = new WebSiteData.Partner(); bll.Update(model); if (!bll.Update(model)) { result = false; } return(result); }
private bool DoAdd() { bool result = true; string Partnername = this.txtPartnername.Text; string StarLevel = this.txtStarLevel.Text; string StarICO = this.txtStarICO.Text; string Remark = this.txtRemark.Value; WebSiteModel.Partner model = new WebSiteModel.Partner(); model.Partnername = Partnername; model.StarLevel = StarLevel; model.StarICO = StarICO; model.Remark = Remark; WebSiteData.Partner bll = new WebSiteData.Partner(); if (bll.Add(model) < 1) { result = false; } return(result); }
private void ShowInfo(int PartnerID) { WebSiteData.Partner bll = new WebSiteData.Partner(); WebSiteModel.Partner model = bll.GetModel(PartnerID); this.lblPartnerID.Text = model.PartnerID.ToString(); this.txtPartnername.Text = model.Partnername; this.txtStarLevel.Text = model.StarLevel; this.txtStarICO.Text = model.StarICO; this.txtRemark.Value = model.Remark; }
//保存等级 protected void btnSaveSort_Click(object sender, EventArgs e) { WebSiteData.Partner bll = new WebSiteData.Partner(); for (int i = 0; i < this.rptList.Items.Count; i++) { int id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value); int sortId; if (!int.TryParse(((TextBox)rptList.Items[i].FindControl("txtStarLevel")).Text.Trim(), out sortId)) { sortId = 99; } bll.UpdateField(id, "StarLevel=" + sortId.ToString()); } JscriptMsg("保存排序成功啦!", Utils.CombUrlTxt("PartnerList.aspx", urlParams, txtKeywords.Text), "Success"); }
/// <summary> /// 绑定合作伙伴信息 /// </summary> private void PartnerBind() { WebSiteData.Partner partner = new WebSiteData.Partner(); //获得某一个站点所有的数据分类 DataTable dt = partner.GetList("").Tables[0]; this.ddlPartner.Items.Clear(); this.ddlPartner.Items.Add(new ListItem("合作伙伴", ""));//默认值是0 foreach (DataRow dr in dt.Rows) { string Id = dr["PartnerID"].ToString(); string Title = dr["Partnername"].ToString().Trim(); this.ddlPartner.Items.Add(new ListItem(Title, Id)); } }
/// <summary> /// 组合查询的条件 /// </summary> /// <param name="_strWhere">组合条件</param> /// <param name="_orderby"></param> private void RptBind(string _strWhere, string _orderby) { //得到第几页数据 this.page = DTRequest.GetQueryInt("page", 1); //绑定关键字 this.txtKeywords.Text = this.keywords; WebSiteData.Partner mdata = new WebSiteData.Partner(); //参数分别是:每页条数 第几页 查询条件 排序条件 数据总数 this.rptList.DataSource = mdata.GetList(this.pageSize, this.page, _strWhere, _orderby, out this.totalCount); this.rptList.DataBind(); //绑定页码 txtPageNum.Text = this.pageSize.ToString(); string pageUrl = Utils.CombUrlTxt("PartnerList.aspx", urlParamsPage, this.keywords, "__id__"); PageContent.InnerHtml = Utils.OutPageList(this.pageSize, this.page, this.totalCount, pageUrl, 8); litCount.Text = this.totalCount.ToString(); }
//批量删除 protected void btnDelete_Click(object sender, EventArgs e) { bool bl = true;//标记变量 WebSiteData.Partner bll = new WebSiteData.Partner(); //遍历提交过来的对象集合 for (int i = 0; i < this.rptList.Items.Count; i++) { int id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value); CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId"); if (cb.Checked) { if (bll.Delete(id)) { //将捕获代码的程序 放置在最底层 bl = true; } else { //表示其中有一个选项没有删除成功 bl = false; Response.Write("出错的ID为" + id.ToString()); break; } } } if (bl) { JscriptMsg("批量删除成功啦!", Utils.CombUrlTxt("PartnerList.aspx", urlParams, this.keywords), "Success"); } else { JscriptMsg("批量删除操作中...有一个没有删除成功!", "back", "Error"); } }
//批量添加合作伙伴 protected void btnMutil_Click(object sender, EventArgs e) { string[] arr = this.txtPartnername.Text.Split('|'); WebSiteData.Partner dal = new WebSiteData.Partner(); int n = 0; for (int i = 0; i < arr.Length; i++) { string Partnername = arr[i]; string StarLevel = this.txtStarLevel.Text; string StarICO = this.txtStarICO.Text; string Remark = this.txtRemark.Value; WebSiteModel.Partner model = new WebSiteModel.Partner(); model.Partnername = Partnername; model.StarLevel = StarLevel; model.StarICO = StarICO; model.Remark = Remark; n = dal.Add(model); if (n < 1) { Response.Write("<span>添加失败了!</span>"); continue; } else { Response.Write("<span>添加成功了!</span>"); } } }