protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { try { int id = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Values[0].ToString()); string Title = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("Title")).Text; string Describe = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("Describe")).Text; AgreementModel mode = new AgreementModel(); mode.AgreementID = id; mode.Title = Title; mode.Describe = Describe; AgreementBLL Pinfo = new AgreementBLL(); if (Pinfo.Update(mode)) { GridView1.EditIndex = -1; BindData(); } } catch (Exception erro) { Response.Write("错误信息:" + erro.Message); } }
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { try { int id = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Values[0].ToString()); AgreementBLL Pinfo = new AgreementBLL(); if (Pinfo.Delete(id)) { GridView1.EditIndex = -1; BindData(); } } catch (Exception erro) { Response.Write("错误信息:" + erro.Message); } }
protected void butSubmit_Click(object sender, EventArgs e) { try { AgreementBLL con = new AgreementBLL(); AgreementModel model = new AgreementModel(); model.Title = Title.Text.Trim(); model.Describe = Describe.Text.Trim(); model.GameID = Convert.ToInt32(Request.QueryString["gameid"]); if (con.Add(model) > 0) { Page.RegisterStartupScript("", "<script language=javascript>alert('添加成功!')</script>"); } } catch(Exception ex) { Page.RegisterStartupScript("", "<script language=javascript>alert('添加失败,填写重复!')</script>"); } }
/// <summary> /// 初始化加载 /// </summary> public void Bind() { ddlSolution.Items.Clear(); DataSet ds = new SolutionBLL().GetList(""); ddlSolution.DataSource = ds; ddlSolution.DataTextField = "SlnName"; ddlSolution.DataValueField = "SlnID"; ddlSolution.DataBind(); ddlSolution.SelectedValue = SlnID; ddlAgreement.Items.Clear(); ddlAgreement.Items.Add(new ListItem("全部", "0")); DataSet ds2 = new AgreementBLL().GetList(" gameid=" + ddlSolution.SelectedValue, ddlSolution.SelectedValue); for (int i = 0; i < ds2.Tables[0].Rows.Count; i++) { ddlAgreement.Items.Add(new ListItem(ds2.Tables[0].Rows[i]["Title"].ToString(), ds2.Tables[0].Rows[i]["AgreementID"].ToString())); } //ddlAgreement.DataSource = ds2; //ddlAgreement.DataTextField = "Title"; //ddlAgreement.DataValueField = "AgreementID"; //ddlAgreement.DataBind(); ddlAgreement.SelectedValue = "0"; DataSet ds3 = new AgreementBLL().GetList(" gameid=" + ddlSolution.SelectedValue, ddlSolution.SelectedValue); DataSet ds4 = new ContractBLL().GetList(" SlnID=" + ddlSolution.SelectedValue); TreeList.Nodes.Clear(); leftStyle = "display:none;"; for (int i = 0; i < ds3.Tables[0].Rows.Count; i++) { leftStyle = ""; TreeNode node = new TreeNode(); node.Text = ds3.Tables[0].Rows[i]["Title"].ToString(); node.Value = ds3.Tables[0].Rows[i]["AgreementID"].ToString(); node.Target = "0"; node.Expanded = false; TreeList.Nodes.Add(node); //TreeList(0, node); TreeList.DataBind(); } for (int i = 0; i < ds4.Tables[0].Rows.Count; i++) { if (Convert.ToInt32(ds4.Tables[0].Rows[i]["AgreementID"]) > 0) { for (int j = 0; j < TreeList.Nodes.Count; j++) { TreeNode node = TreeList.Nodes[j]; if (ds4.Tables[0].Rows[i]["AgreementID"].ToString() == node.Value) { TreeNode nodes = new TreeNode(); nodes.Text = ds4.Tables[0].Rows[i]["uname"].ToString(); nodes.Value = ds4.Tables[0].Rows[i]["ID"].ToString(); node.ChildNodes.Add(nodes); } } } } //TreeList.Attributes.Add("onclick", "HandleCheckEvent()"); // if (!string.IsNullOrEmpty(hi_SlnId.Value)) // { // } if (ddlSolution.Text.Length > 0) { BindContract(Convert.ToInt32(ddlSolution.Text)); } }
protected void ddlSolution_SelectedIndexChanged(object sender, EventArgs e) { SetCookies(string.Empty, ddlSolution.Text); BindContract(Convert.ToInt32(ddlSolution.SelectedValue)); try { if (!string.IsNullOrEmpty(GetCookies(ddlSolution.Text))) { DropGetList.SelectedValue = GetCookies(ddlSolution.Text); } else { DropGetList.SelectedValue = ContractID; } } catch { } QueryResult(); ddlAgreement.Items.Clear(); ddlAgreement.Items.Add(new ListItem("全部", "0")); DataSet ds2 = new AgreementBLL().GetList(" gameid=" + ddlSolution.SelectedValue, ddlSolution.SelectedValue); for (int i = 0; i < ds2.Tables[0].Rows.Count; i++) { ddlAgreement.Items.Add(new ListItem(ds2.Tables[0].Rows[i]["Title"].ToString(), ds2.Tables[0].Rows[i]["AgreementID"].ToString())); } DataSet ds3 = new AgreementBLL().GetList(" gameid=" + ddlSolution.SelectedValue, ddlSolution.SelectedValue); DataSet ds4 = new ContractBLL().GetList(" SlnID=" + ddlSolution.SelectedValue); TreeList.Nodes.Clear(); for (int i = 0; i < ds3.Tables[0].Rows.Count; i++) { TreeNode node = new TreeNode(); node.Text = ds3.Tables[0].Rows[i]["Title"].ToString(); node.Value = ds3.Tables[0].Rows[i]["AgreementID"].ToString(); node.Target = "0"; node.Expanded = false; TreeList.Nodes.Add(node); //TreeList(0, node); TreeList.DataBind(); } for (int i = 0; i < ds4.Tables[0].Rows.Count; i++) { if (Convert.ToInt32(ds4.Tables[0].Rows[i]["AgreementID"]) > 0) { for (int j = 0; j < TreeList.Nodes.Count; j++) { TreeNode node = TreeList.Nodes[j]; if (ds4.Tables[0].Rows[i]["AgreementID"].ToString() == node.Value) { TreeNode nodes = new TreeNode(); nodes.Text = ds4.Tables[0].Rows[i]["uname"].ToString(); nodes.Value = ds4.Tables[0].Rows[i]["ID"].ToString(); node.ChildNodes.Add(nodes); } } } } }