private void GetPayType() { DataTable dt = AusFinInfoManager.GetList(""); this.type.DataSource = dt; this.type.DataBind(); }
/// <summary> /// 绑定付款类别数据 /// </summary> private void GetPayType() { #region 控制相同单位不能选择相同类别的代码(目前不用) //string u = Request.QueryString["unit"]; //string it = Request.QueryString["item"]; //string[] unit = u.Remove(u.LastIndexOf(','), 1).Split(','); //得到单位id值集合 //string[] item = it.Remove(it.LastIndexOf(','), 1).Split(','); //得到类别集合 //string thisUnit = Request.QueryString["thisUnit"].Trim(); //string sqlitem = ""; //筛选类别的条件 //DataTable payType = null; //if (unit.Contains(thisUnit)) //如果所选择的那行的单位,已经选择过 //{ // for (int i = 0; i < unit.Length; i++) // { // if (unit[i] == thisUnit) // { // sqlitem += item[i] + "','"; // } // } // string sql = " itemname not in('" + sqlitem + "')"; // payType = AusFinInfoManager.GetList(sql); //} //else //{ // payType = AusFinInfoManager.GetList(""); //} //this.type.DataSource = payType; //this.type.DataBind(); #endregion this.type.DataSource = AusFinInfoManager.GetList(""); this.type.DataBind(); }
/// <summary> /// 添加数据 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void ibtnAdd_Click(object sender, ImageClickEventArgs e) { AusFinInfo ausFinInfo = new AusFinInfo(); ausFinInfo.itemname = this.txtTypeName.Text.ToString(); AusFinInfo ausFinInfocount = AusFinInfoManager.GetModelByName(this.txtTypeName.Text); if (ausFinInfocount == null) { bool count = AusFinInfoManager.Add(ausFinInfo); if (count == true) { Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "add", "<script>alert('添加成功');window.location='AusFinList.aspx'</script>", false); } else { Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "add", "<script>alert('添加失败')</script>", false); } } else { Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "", "alert('类型名称不能重复!');", true); } }
/// <summary> /// 加载第一步数据 /// </summary> private void loadAusFin() { int id = Convert.ToInt32(Request.QueryString["id"]); AusFinInfo ausFin = AusFinInfoManager.GetModel(id); txtTypeName.Text = ausFin.itemname; }
/// <summary> /// 绑定数据列表 /// </summary> private void getFin() { DataTable ausFin = AusFinInfoManager.GetList(strwhere); this.type.DataSource = ausFin; this.type.DataBind(); }
/// <summary> /// 绑定付款类别 /// </summary> private void BindOutComeType() { ddlpayitem.Items.Clear(); DataTable dt = AusFinInfoManager.GetList(""); DataRow dr = dt.NewRow(); dr["itemname"] = "——请选择——"; dr["id"] = "0"; dt.Rows.InsertAt(dr, 0); ddlpayitem.DataTextField = "itemname"; ddlpayitem.DataValueField = "id"; ddlpayitem.DataSource = dt; ddlpayitem.DataBind(); }
private void LoadPaymentType() { ddlPaymentType.Items.Clear(); DataTable dt = AusFinInfoManager.GetList(""); ddlPaymentType.Items.Add(new ListItem("——请选择——", "")); for (int i = 0; i < dt.Rows.Count; i++) { ListItem adItem = new ListItem(); adItem.Text = dt.Rows[i]["itemname"].ToString(); adItem.Value = dt.Rows[i]["itemname"].ToString(); ddlPaymentType.Items.Add(adItem); } }
/// <summary> /// 更新数据 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void ibtnAdd_Click(object sender, ImageClickEventArgs e) { AusFinInfo ausFinInfo = new AusFinInfo(); ausFinInfo.id = Convert.ToInt32(Request.QueryString["id"]); ausFinInfo.itemname = this.txtTypeName.Text.ToString(); AusFinInfo ausFinInfocount = AusFinInfoManager.GetModelByName(this.txtTypeName.Text); if (ausFinInfocount == null) { bool count = AusFinInfoManager.Update(ausFinInfo); if (count == true) { Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "add", "<script>alert('更新成功');window.location='AusFinList.aspx'</script>", false); } else { Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "add", "<script>alert('更新失败')</script>", false); } } else { if (ausFinInfocount.id == ausFinInfo.id) //判断其与所需要更新的类别的ID是否一样,如果一样可以更新。如果不一样就不能更新 { bool count = AusFinInfoManager.Update(ausFinInfo); if (count == true) { Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "add", "<script>alert('更新成功');window.location='AusFinList.aspx'</script>", false); } else { Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "add", "<script>alert('更新失败')</script>", false); } } else { Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "", "alert('类型名称不能重复!');", true); } } }
//编辑删除 protected void cuslist_ItemCommand(object source, RepeaterCommandEventArgs e) { string id = e.CommandArgument.ToString(); switch (e.CommandName) { case "Update": Response.Redirect("UpdateAusFin.aspx?id=" + id); break; case "Delete": bool del = AusFinInfoManager.Delete(Convert.ToInt32(id)); if (del == true) { Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "add", "<script>alert('删除成功');window.location='AusFinList.aspx'</script>", false); } else { Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "add", "<script>alert('删除失败')</script>", true); } break; } }