protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "JoinTeam") { int rowIndex = Convert.ToInt32(e.CommandArgument); string teamID = GridView1.Rows[rowIndex].Cells[0].Text; string status = BLL_Team.queryJoinStatus(teamID, Session["loginSession"].ToString()); if (status == "未加入") { if (BLL_Team.joinTeam(teamID, Session["loginSession"].ToString())) { Page.ClientScript.RegisterStartupScript(Page.GetType(), "alert", "alert('加入成功!');", true); } else { Page.ClientScript.RegisterStartupScript(Page.GetType(), "alert", "alert('加入失败!');", true); } } else { if (BLL_Team.quitTeam(teamID, Session["loginSession"].ToString())) { Page.ClientScript.RegisterStartupScript(Page.GetType(), "alert", "alert('退出成功!');", true); } else { Page.ClientScript.RegisterStartupScript(Page.GetType(), "alert", "alert('退出失败!');", true); } } GridView1.DataBind(); } }
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (Session["loginSession"] == null) { return; } if (e.Row.RowType == DataControlRowType.DataRow && (e.Row.RowState == DataControlRowState.Normal || e.Row.RowState == DataControlRowState.Alternate)) { string teamID = ((DataRowView)e.Row.DataItem).Row.ItemArray[0].ToString(); string auditStatus = BLL_Team.queryJoinStatus(teamID, Session["loginSession"].ToString()); Label labelAuditStatus = (Label)e.Row.FindControl("JoinStatus"); labelAuditStatus.Text = auditStatus; if (auditStatus != "未加入") { Button joinButton = (Button)e.Row.FindControl("ButtonJoin"); joinButton.Text = "退出"; joinButton.CssClass = "btn btn-warning form-control"; //joinButton.Enabled = false; } } }
protected void ListView1_ItemCommand(object sender, ListViewCommandEventArgs e) { if (e.CommandName == "DeleteTeam") { int rowIndex = Convert.ToInt32(e.CommandArgument); TextBox textBoxTeamID = (TextBox)ListView1.Items[rowIndex].FindControl("TeamID"); string teamID = textBoxTeamID.Text; if (BLL_Team.deleteTeamByID(teamID)) { Page.ClientScript.RegisterStartupScript(Page.GetType(), "alert", "alert('删除成功!');", true); } else { Page.ClientScript.RegisterStartupScript(Page.GetType(), "alert", "alert('删除失败!');", true); } } else if (e.CommandName == "SaveTeam") { int rowIndex = Convert.ToInt32(e.CommandArgument); TextBox textBoxTeamID = (TextBox)ListView1.Items[rowIndex].FindControl("TeamID"); DropDownList textBoxAuditMode = (DropDownList)ListView1.Items[rowIndex].FindControl("AuditMode"); DropDownList textBoxScoreType = (DropDownList)ListView1.Items[rowIndex].FindControl("ScoreType"); //DropDownList textBoxExcelRatio = (DropDownList)ListView1.Items[rowIndex].FindControl("ExcelRatio"); DropDownList textBoxAnswerStatus = (DropDownList)ListView1.Items[rowIndex].FindControl("AnswerStatus"); TextBox textBoxCourceName = (TextBox)ListView1.Items[rowIndex].FindControl("CourceName"); DropDownList textBoxCourceTerm = (DropDownList)ListView1.Items[rowIndex].FindControl("CourceTerm"); TextBox textBoxStuClass = (TextBox)ListView1.Items[rowIndex].FindControl("StuClass"); TextBox textBoxIntroduce = (TextBox)ListView1.Items[rowIndex].FindControl("Introduce"); //TextBox textBoxComment = (TextBox)ListView1.Items[rowIndex].FindControl("Comment"); Team team = new Team(textBoxTeamID.Text, "", textBoxAuditMode.SelectedValue, textBoxScoreType.SelectedValue, "", textBoxAnswerStatus.SelectedValue, textBoxCourceName.Text, textBoxCourceTerm.SelectedValue, textBoxStuClass.Text, "", textBoxIntroduce.Text, ""); if (BLL_Team.modifyTeam(team)) { Page.ClientScript.RegisterStartupScript(Page.GetType(), "alert", "alert('保存成功!');", true); } else { Page.ClientScript.RegisterStartupScript(Page.GetType(), "alert", "alert('保存失败!');", true); } } else if (e.CommandName == "ShowMember") { try { int index = Convert.ToInt32(lastShow.Value); GridView gv = (GridView)ListView1.Items[index].FindControl("panel_hide").FindControl("members"); gv.DataSource = null; gv.DataBind(); } catch { } int rowIndex = Convert.ToInt32(e.CommandArgument); TextBox textBoxTeamID = (TextBox)ListView1.Items[rowIndex].FindControl("TeamID"); string teamID = textBoxTeamID.Text; GridView gridView = (GridView)ListView1.Items[rowIndex].FindControl("panel_hide").FindControl("members"); DataSet ds = BLL_Team.queryMember(teamID); ds.Tables[0].Columns[0].ColumnName = "用户名"; ds.Tables[0].Columns[1].ColumnName = "专业"; ds.Tables[0].Columns[2].ColumnName = "审核状态"; gridView.DataSource = ds; gridView.DataBind(); lastShow.Value = rowIndex.ToString(); } }