protected void GvDataType_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.Attributes.Add("onMouseOver", "Color=this.style.backgroundColor;this.style.backgroundColor='#ADEAEA'"); e.Row.Attributes.Add("onMouseOut", "this.style.backgroundColor=Color;"); switch (e.Row.Cells[10].Text) { case "1": e.Row.Cells[10].Text = "保存"; if (e.Row.Cells[11].Text != "") { e.Row.Cells[11].ForeColor = System.Drawing.Color.Red; } if (e.Row.Cells[12].Text != "") { e.Row.Cells[12].ForeColor = System.Drawing.Color.Red; } break; case "2": e.Row.Cells[10].Text = "提交"; break; case "3": e.Row.Cells[10].Text = "院审批通过"; break; case "4": e.Row.Cells[10].Text = "校审批通过"; break; } } if (e.Row.RowIndex > -1) { e.Row.Cells[0].Text = (WebPager1.Pagesize * (Convert.ToInt32((WebPager1.FindControl("lblCurpage") as Label).Text) - 1) + e.Row.RowIndex + 1).ToString(); } }
//鼠标经过背景色改变 protected void GvDataType_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.Attributes.Add("onMouseOver", "Color=this.style.backgroundColor;this.style.backgroundColor='#ADEAEA'"); e.Row.Attributes.Add("onMouseOut", "this.style.backgroundColor=Color;"); //对于Grideview中库存册数的设置 string bi = e.Row.Cells[5].Text; //按照book_id来找 string sql3 = "select remain_num from Storage_management_end where " + "book_id='" + bi + "' " //统计这本书的需求册数(用BookID锁定) + "and state_id= 1"; //代表还可以领 int total_num = 0; SqlDataReader reader3 = SQLHelper.ExecuteReader(sql3); while (reader3.Read()) { total_num += Convert.ToInt32(reader3[0].ToString());//计算总量 } e.Row.Cells[9].Text = total_num.ToString(); } if (e.Row.RowIndex > -1) { e.Row.Cells[1].Text = (WebPager1.Pagesize * (Convert.ToInt32((WebPager1.FindControl("lblCurpage") as Label).Text) - 1) + e.Row.RowIndex + 1).ToString(); } }
//鼠标经过背景色改变,GridView的内容设置 protected void GvDataType_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.Attributes.Add("onMouseOver", "Color=this.style.backgroundColor;this.style.backgroundColor='#ADEAEA'"); e.Row.Attributes.Add("onMouseOut", "this.style.backgroundColor=Color;"); //对于Gridview中需求册数的设置 string sql1 = "select BookID,Publish,Version from Abook_message_stu where " + "id='" + (e.Row.Cells[6].FindControl("lbId") as Label).Text.ToString() + "' " + "and get_id=0";//查找不同的书籍 SqlDataReader reader1 = SQLHelper.ExecuteReader(sql1); string bi = "", pu = "", vs = ""; while (reader1.Read()) { bi = reader1["BookID"].ToString();//得到这本书的BookID pu = reader1["Publish"].ToString(); vs = reader1["Version"].ToString(); string sql2 = "select count(*) from Abook_message_stu where " + "BookID='" + bi + "'" + "and ClassName='" + Class.Text + "' " + "and get_id=0 " + "and Publish='" + pu + "' " + "and Version='" + vs + "'";//统计这本书的需求册数(用BookID和ClassName锁定) SqlDataReader reader2 = SQLHelper.ExecuteReader(sql2); while (reader2.Read()) { e.Row.Cells[8].Text = reader2[0].ToString(); } } //对于Grideview中库存册数的设置 string sql3 = "select remain_num from Storage_management_end where " + "book_id='" + bi + "' " //统计这本书的需求册数(用BookID锁定) + "and state_id= 1"; //代表还可以领 int total_num = 0; SqlDataReader reader3 = SQLHelper.ExecuteReader(sql3); while (reader3.Read()) { total_num += Convert.ToInt32(reader3[0].ToString());//计算总量 } e.Row.Cells[9].Text = total_num.ToString(); //对GridView中领取数量TextBox内容的设置 int nn = Convert.ToInt32(e.Row.Cells[8].Text); int sn = Convert.ToInt32(e.Row.Cells[9].Text); int tbc = (nn < sn?nn:sn); (e.Row.Cells[10].FindControl("tbGetNum") as TextBox).Text = Convert.ToString(tbc); } if (e.Row.RowIndex > -1) { e.Row.Cells[1].Text = (WebPager1.Pagesize * (Convert.ToInt32((WebPager1.FindControl("lblCurpage") as Label).Text) - 1) + e.Row.RowIndex + 1).ToString(); } }
//鼠标经过背景色改变 protected void GvDataType_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.Attributes.Add("onMouseOver", "Color=this.style.backgroundColor;this.style.backgroundColor='#ADEAEA'"); e.Row.Attributes.Add("onMouseOut", "this.style.backgroundColor=Color;"); } if (e.Row.RowIndex > -1) { e.Row.Cells[0].Text = (WebPager1.Pagesize * (Convert.ToInt32((WebPager1.FindControl("lblCurpage") as Label).Text) - 1) + e.Row.RowIndex + 1).ToString(); } }
//鼠标经过背景色改变 protected void GvDataType_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.Attributes.Add("onMouseOver", "Color=this.style.backgroundColor;this.style.backgroundColor='#ADEAEA'"); e.Row.Attributes.Add("onMouseOut", "this.style.backgroundColor=Color;"); } ////设置状态栏颜色及内容 //if (e.Row.Cells[5].Text == "1") //{ // e.Row.Cells[5].Text = "保存"; //} //for (int i = 0; i <= GridView1.Rows.Count - 1; i++) //{ // Label lb1 = this.GridView1.Rows[i].Cells[0].FindControl("L15") as Label; // switch (lb1.Text) // { // case "1": lb1.Text = "保存"; break; // case "2": lb1.Text = "提交"; break; // case "4": lb1.Text = "审批通过"; break; // } //} ////对校审批一栏的设置 //for (int i = 0; i <= GridView1.Rows.Count - 1; i++) //{ // Label lb1 = this.GridView1.Rows[i].Cells[0].FindControl("L15") as Label; // Label lb2 = this.GridView1.Rows[i].Cells[0].FindControl("L16") as Label; // if (lb1.Text == "保存") // { // if (lb2.Text == "") // { // lb2.Text = "未审批"; // } // else // { // GridView1.Rows[i].Cells[5].ForeColor = System.Drawing.Color.Red; // } // } // if (lb1.Text == "提交") // lb2.Text = "未审批"; // else if (lb1.Text == "审批通过" && lb2.Text == "") // lb2.Text = "同意"; //} if (e.Row.RowIndex > -1) { e.Row.Cells[1].Text = (WebPager1.Pagesize * (Convert.ToInt32((WebPager1.FindControl("lblCurpage") as Label).Text) - 1) + e.Row.RowIndex + 1).ToString(); } }
protected void GvDataType_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.Attributes.Add("onMouseOver", "Color=this.style.backgroundColor;this.style.backgroundColor='#ADEAEA'"); e.Row.Attributes.Add("onMouseOut", "this.style.backgroundColor=Color;"); double price = Convert.ToDouble(e.Row.Cells[6].Text); double discount = Convert.ToDouble(e.Row.Cells[7].Text) / 100; if (price == 0) { e.Row.Cells[8].Text = "价格待定"; } else { e.Row.Cells[8].Text = (price * discount).ToString(); } } if (e.Row.RowIndex > -1) { e.Row.Cells[1].Text = (WebPager1.Pagesize * (Convert.ToInt32((WebPager1.FindControl("lblCurpage") as Label).Text) - 1) + e.Row.RowIndex + 1).ToString(); } }
//鼠标经过背景色改变 protected void GvDataType_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.Attributes.Add("onMouseOver", "Color=this.style.backgroundColor;this.style.backgroundColor='#ADEAEA'"); e.Row.Attributes.Add("onMouseOut", "this.style.backgroundColor=Color;"); //对于Gridview中总册数的设置 string bi = e.Row.Cells[2].Text; //ISBN string cn = e.Row.Cells[1].Text; //班级名称 string sql1 = "select count(*) from Abook_message_stu where BookID='" + bi + "' and ClassName='" + cn + "'and get_id=1"; //统计符合这条信息的条数 SqlDataReader reader1 = SQLHelper.ExecuteReader(sql1); while (reader1.Read()) { e.Row.Cells[9].Text = reader1[0].ToString(); } } if (e.Row.RowIndex > -1) { e.Row.Cells[0].Text = (WebPager1.Pagesize * (Convert.ToInt32((WebPager1.FindControl("lblCurpage") as Label).Text) - 1) + e.Row.RowIndex + 1).ToString(); } }