码迷,mamicode.com
首页 > Web开发 > 详细

ASPxGridView改变列颜色

时间:2018-08-26 23:40:34      阅读:225      评论:0      收藏:0      [点我收藏+]

标签:标签   color   OLE   生产线   EDA   sql   sel   方物   标识   

protected void ASPxGridView1_HtmlDataCellPrepared(object sender, ASPxGridViewTableDataCellEventArgs e)
{
string tJhso = e.GetValue("PLAN_SO").ToString();
string tJhdm = e.GetValue("PLAN_CODE").ToString();
string sql = " SELECT PLAN_CODE,PLAN_SO,CREATE_DATE,REMARK frOM DATA_PLANLOG where PLAN_SO=‘" + tJhso + "‘ and PLAN_CODE=‘" + tJhdm 
+ "‘ AND ROUNTING_SITE IN (SELECT PLINE_CODE FROM VW_USER_ROLE_PROGRAM WHERE USER_ID = ‘ "
+ theUserId + "‘ AND PROGRAM_CODE = ‘" + theProgramCode + "‘ AND COMPANY_CODE = ‘" + theCompanyCode + "‘) "
+ " ORDER BY CREATE_DATE,PLAN_CODE ";
dc.setTheSql(sql);
DataTable dt = dc.GetTable();
if (dt.Rows.Count > 0)
{
//一些不需设置颜色的列
if (e.DataColumn.Caption.ToString() == "计划确认标识") return;
if (e.DataColumn.Caption.ToString() == "BOM转换") return;
if (e.DataColumn.Caption.ToString() == "库房确认标识") return;
if (e.DataColumn.Caption.ToString() == "是否分配流水号") return;
if (e.DataColumn.Caption.ToString() == "三方要料") return;
if (e.DataColumn.Caption.ToString() == "库房要料") return;
if (e.DataColumn.Caption.ToString() == "三方物料接收状态") return;
if (e.DataColumn.Caption.ToString() == "库房发料接收状态") return;
if (e.DataColumn.Caption.ToString() == "生产确认标识") return;
if (e.DataColumn.Caption.ToString() == "柳汽标识") return;
if (e.DataColumn.Caption.ToString() == "改制返修是否转BOM") return;
//也可以根据FieldName进行判断
//if (e.DataColumn.FieldName.ToString() == "ORDER_CODE") return;

//给需要设置颜色的列设置颜色
e.Cell.BackColor = System.Drawing.Color.Cyan;
}

string status = e.GetValue("RUN_FLAG").ToString();
if (status == "N")
{
//一些不需设置颜色的列
if (e.DataColumn.Caption.ToString() == "计划确认标识") return;
if (e.DataColumn.Caption.ToString() == "BOM转换") return;
if (e.DataColumn.Caption.ToString() == "库房确认标识") return;
if (e.DataColumn.Caption.ToString() == "是否分配流水号") return;
if (e.DataColumn.Caption.ToString() == "三方要料") return;
if (e.DataColumn.Caption.ToString() == "库房要料") return;
if (e.DataColumn.Caption.ToString() == "三方物料接收状态") return;
if (e.DataColumn.Caption.ToString() == "库房发料接收状态") return;
if (e.DataColumn.Caption.ToString() == "生产确认标识") return;
if (e.DataColumn.Caption.ToString() == "柳汽标识") return;
if (e.DataColumn.Caption.ToString() == "改制返修是否转BOM") return;

//给需要设置颜色的列设置颜色
e.Cell.BackColor = System.Drawing.Color.Red;
}

status = e.GetValue("CONFIRM_FLAG").ToString();
if (status == "N")
{
//一些不需设置颜色的列
if (e.DataColumn.Caption.ToString() == "计划确认标识") return;
if (e.DataColumn.Caption.ToString() == "BOM转换") return;
if (e.DataColumn.Caption.ToString() == "库房确认标识") return;
if (e.DataColumn.Caption.ToString() == "是否分配流水号") return;
if (e.DataColumn.Caption.ToString() == "三方要料") return;
if (e.DataColumn.Caption.ToString() == "库房要料") return;
if (e.DataColumn.Caption.ToString() == "三方物料接收状态") return;
if (e.DataColumn.Caption.ToString() == "库房发料接收状态") return;
if (e.DataColumn.Caption.ToString() == "生产确认标识") return;
if (e.DataColumn.Caption.ToString() == "柳汽标识") return;
if (e.DataColumn.Caption.ToString() == "改制返修是否转BOM") return;

//给需要设置颜色的列设置颜色
e.Cell.BackColor = System.Drawing.Color.Yellow;
}

status = e.GetValue("BOM_FLAG").ToString();
if (status == "N")
{
//一些不需设置颜色的列
if (e.DataColumn.Caption.ToString() == "计划确认标识") return;
if (e.DataColumn.Caption.ToString() == "BOM转换") return;
if (e.DataColumn.Caption.ToString() == "库房确认标识") return;
if (e.DataColumn.Caption.ToString() == "是否分配流水号") return;
if (e.DataColumn.Caption.ToString() == "三方要料") return;
if (e.DataColumn.Caption.ToString() == "库房要料") return;
if (e.DataColumn.Caption.ToString() == "三方物料接收状态") return;
if (e.DataColumn.Caption.ToString() == "库房发料接收状态") return;
if (e.DataColumn.Caption.ToString() == "生产确认标识") return;
if (e.DataColumn.Caption.ToString() == "柳汽标识") return;
if (e.DataColumn.Caption.ToString() == "改制返修是否转BOM") return;

//给需要设置颜色的列设置颜色
e.Cell.BackColor = System.Drawing.Color.Green;
}

sql = " select plan_code from ms_sfjit_plan_log where gzdd IN (SELECT PLINE_CODE FROM VW_USER_ROLE_PROGRAM WHERE USER_ID = ‘ "
+ theUserId + "‘ AND PROGRAM_CODE = ‘" + theProgramCode + "‘ AND COMPANY_CODE = ‘" + theCompanyCode + "‘) "
+ " and plan_code=‘" + tJhdm + "‘ ";
dc.setTheSql(sql);
dt = dc.GetTable();
if (dt.Rows.Count > 0)
{
//给需要设置颜色的列设置颜色
if (e.DataColumn.FieldName.ToString() == "PLAN_CODE")
{
e.Cell.BackColor = System.Drawing.Color.FromArgb(128, 128, 64);
}
}

sql = " select plan_code from ms_kfjit_plan_log where gzdd IN (SELECT PLINE_CODE FROM VW_USER_ROLE_PROGRAM WHERE USER_ID = ‘ "
+ theUserId + "‘ AND PROGRAM_CODE = ‘" + theProgramCode + "‘ AND COMPANY_CODE = ‘" + theCompanyCode + "‘) "
+ " and plan_code=‘" + tJhdm + "‘ ";
dc.setTheSql(sql);
dt = dc.GetTable();
if (dt.Rows.Count > 0)
{
//给需要设置颜色的列设置颜色
if (e.DataColumn.FieldName.ToString() == "PLAN_SO")
{
e.Cell.BackColor = System.Drawing.Color.FromArgb(255, 0, 255);
}
}

sql = " select SO from atpusofjb where so=‘" + tJhso + "‘ ";
dc.setTheSql(sql);
dt = dc.GetTable();
if (dt.Rows.Count < 0)
{
//给需要设置颜色的列设置颜色
if (e.DataColumn.FieldName.ToString() == "PRODUCT_MODEL")
{
e.Cell.BackColor = System.Drawing.Color.FromArgb(0, 123, 123);
}
}

//string status = e.GetValue("RUN_FLAG").ToString();
//if (status == "N")
//{
// //第0列RMES_ID
// object c0 = e.DataColumn.Caption;
// //e.Cell.BackColor = System.Drawing.Color.Red;
// //第1列Command列
// //object c1 = e.Row.Cells[1];
// ////第2列 计划序
// //object c2 = e.Row.Cells[2];
// ////第3列 计划代码
// //object c3 = e.Row.Cells[3];
// ////第4列 生产线代码
// //object c4 = e.Row.Cells[4];
// //e.Row.Cells[0].BackColor = System.Drawing.Color.Red;
// //e.Row.Cells[1].BackColor = System.Drawing.Color.Red;
// //e.Row.Cells[2].BackColor = System.Drawing.Color.Red;
// //e.Row.Cells[3].BackColor = System.Drawing.Color.Red;
// //e.Row.Cells[4].BackColor = System.Drawing.Color.Red;

// if (e.DataColumn.Caption.ToString() == "计划代码")
// {
// e.Cell.BackColor = System.Drawing.Color.Red;
// }
//}
}

 
 
标签

ASPxGridView改变列颜色

标签:标签   color   OLE   生产线   EDA   sql   sel   方物   标识   

原文地址:https://www.cnblogs.com/qqhfeng/p/9539441.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!