using System;
using System.Collections;
using System.Configuration;
using System.Data;
public partial class Apps_repository_faqConfirm : System.Web.UI.Page
{
#region 变量
#endregion
#region 事件方法
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
LoadPage();
tableTitle.Text = "待审批";
prepareViewed.Visible = false;
}
}
//全部选择
protected void selectAll_Click(object sender, EventArgs e)
{
for (int i = 0; i < this.GridView1.Rows.Count; i++)
{
((CheckBox)GridView1.Rows[i].FindControl("chkSelect")).Checked = true;
}
}
// 全部评分
protected void scoreAll_Click(object sender, EventArgs e)
{
string scoreValue = ddlScoreAll.SelectedValue;
int stringCount = GridView1.Rows.Count;
for (int i = 0; i < stringCount; i++)
{
if (((CheckBox)GridView1.Rows[i].FindControl("chkSelect")).Checked)
{
((DropDownList)GridView1.Rows[i].FindControl("ddlScore")).SelectedValue = scoreValue;
}
}
}
//审批通过
protected void passAll_Click(object sender, EventArgs e)
{
UpDatePassData();
LoadPage();
}
//拒绝通过
protected void rejectAll_Click(object sender, EventArgs e)
{
UpDateRejectData();
LoadPage();
}
//待审批
protected void prepareViewed_Click(object sender, EventArgs e)
{
Response.Redirect(this.Request.Url.ToString());
}
//已审批通过
protected void viewed_Click(object sender, EventArgs e)
{
LoadPassData();
tableTitle.Text = "已审批通过";
passAll.Enabled = false;
rejectAll.Enabled = false;
scoreAll.Enabled = false;
prepareViewed.Visible = true;
}
//未审批通过
protected void notViewed_Click(object sender, EventArgs e)
{
LoadRejectData();
tableTitle.Text = "未审批通过";
passAll.Enabled = false;
rejectAll.Enabled = false;
scoreAll.Enabled = false;
prepareViewed.Visible = true;
}
#endregion
#region 私有方法
public void LoadPage()
{
string sql = "select *From t_info where info_check=0";
DataTable dt = MySQLHelper.GetDataTable(sql);
GridView1.DataSource = dt;
GridView1.DataBind();
}
public void LoadPassData()
{
string sql = "select *From t_info where info_check=1";
DataTable dt = MySQLHelper.GetDataTable(sql);
GridView1.DataSource = dt;
GridView1.DataBind();
for (int i = 0; i < GridView1.Rows.Count; i++)
{
((DropDownList)(GridView1.Rows[i].FindControl("ddlScore"))).SelectedValue = dt.Rows[i]["info_score"].ToString();
}
}
public void LoadRejectData()
{
string sql = "select *From t_info where info_check=2";
DataTable dt = MySQLHelper.GetDataTable(sql);
GridView1.DataSource = dt;
GridView1.DataBind();
for (int i = 0; i < GridView1.Rows.Count; i++)
{
((DropDownList)(GridView1.Rows[i].FindControl("ddlScore"))).SelectedValue = dt.Rows[i]["info_score"].ToString();
}
}
/// <summary>
/// 检查选择项 返回选择项INFO_ID数组
/// </summary>
/// <returns>INFO_ID</returns>
public string[,] CheckIsSelected()
{
int stringCount = GridView1.Rows.Count;
string[,] isSelected = new string[2, stringCount];
for (int i = 0; i < stringCount; i++)
{
if (((CheckBox)GridView1.Rows[i].FindControl("chkSelect")).Checked)
{
isSelected[0, i] = GridView1.DataKeys[GridView1.Rows[i].RowIndex].Value.ToString();
isSelected[1, i] = ((DropDownList)(GridView1.Rows[i].FindControl("ddlScore"))).SelectedValue;
}
}
return isSelected;
}
/// <summary>
/// 更新审批拒绝数据
/// </summary>
public void UpDateRejectData()
{
string[,] info_Score = CheckIsSelected();
for (int i = 0; i < info_Score.Length / 2; i++)
{
if (info_Score[0, i] != null)
{
string sql = string.Format("update t_info set info_check=2 ,Info_Score={0} where Info_id ={1} ", info_Score[1, i], info_Score[0, i]);
MySQLHelper.ExecuteNonQuery(sql);
}
}
}
/// <summary>
/// 更新审批通过数据
/// </summary>
public void UpDatePassData()
{
string[,] info_Score = CheckIsSelected();
for (int i = 0; i < info_Score.Length / 2; i++)
{
if (info_Score[0, i] != null)
{
string sql = string.Format("update t_info set info_check =1,Info_Score={0} where info_id= {1}", info_Score[1, i], info_Score[0, i]);
MySQLHelper.ExecuteNonQuery(sql);
}
}
}
#endregion
}