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)
{
Some columns that do not need to be color-set
if (e.datacolumn.caption.tostring () = = "Plan Confirmation identification") return;
if (e.datacolumn.caption.tostring () = = "BOM conversion") return;
if (e.datacolumn.caption.tostring () = = "Warehouse Confirmation identification") return;
if (e.datacolumn.caption.tostring () = = "Whether to assign serial number") return;
if (e.datacolumn.caption.tostring () = = "Three-party to material") return;
if (e.datacolumn.caption.tostring () = = "Warehouse to material") return;
if (e.datacolumn.caption.tostring () = = "Three-party material receiving status") return;
if (e.datacolumn.caption.tostring () = = "Warehouse material receiving status") return;
if (e.datacolumn.caption.tostring () = = "Production Confirmation identification") return;
if (e.datacolumn.caption.tostring () = = "Willow Steam mark") return;
if (e.datacolumn.caption.tostring () = = "Restructuring rework or not to the BOM") return;
can also be judged according to FieldName
if (e.datacolumn.fieldname.tostring () = = "Order_code") return;
Set color for columns that need to be set
E.cell.backcolor = System.Drawing.Color.Cyan;
}
String status = E.getvalue ("Run_flag"). ToString ();
if (Status = = "N")
{
Some columns that do not need to be color-set
if (e.datacolumn.caption.tostring () = = "Plan Confirmation identification") return;
if (e.datacolumn.caption.tostring () = = "BOM conversion") return;
if (e.datacolumn.caption.tostring () = = "Warehouse Confirmation identification") return;
if (e.datacolumn.caption.tostring () = = "Whether to assign serial number") return;
if (e.datacolumn.caption.tostring () = = "Three-party to material") return;
if (e.datacolumn.caption.tostring () = = "Warehouse to material") return;
if (e.datacolumn.caption.tostring () = = "Three-party material receiving status") return;
if (e.datacolumn.caption.tostring () = = "Warehouse material receiving status") return;
if (e.datacolumn.caption.tostring () = = "Production Confirmation identification") return;
if (e.datacolumn.caption.tostring () = = "Willow Steam mark") return;
if (e.datacolumn.caption.tostring () = = "Restructuring rework or not to the BOM") return;
Set color for columns that need to be set
E.cell.backcolor = System.Drawing.Color.Red;
}
Status = E.getvalue ("Confirm_flag"). ToString ();
if (Status = = "N")
{
Some columns that do not need to be color-set
if (e.datacolumn.caption.tostring () = = "Plan Confirmation identification") return;
if (e.datacolumn.caption.tostring () = = "BOM conversion") return;
if (e.datacolumn.caption.tostring () = = "Warehouse Confirmation identification") return;
if (e.datacolumn.caption.tostring () = = "Whether to assign serial number") return;
if (e.datacolumn.caption.tostring () = = "Three-party to material") return;
if (e.datacolumn.caption.tostring () = = "Warehouse to material") return;
if (e.datacolumn.caption.tostring () = = "Three-party material receiving status") return;
if (e.datacolumn.caption.tostring () = = "Warehouse material receiving status") return;
if (e.datacolumn.caption.tostring () = = "Production Confirmation identification") return;
if (e.datacolumn.caption.tostring () = = "Willow Steam mark") return;
if (e.datacolumn.caption.tostring () = = "Restructuring rework or not to the BOM") return;
Set color for columns that need to be set
E.cell.backcolor = System.Drawing.Color.Yellow;
}
Status = E.getvalue ("Bom_flag"). ToString ();
if (Status = = "N")
{
Some columns that do not need to be color-set
if (e.datacolumn.caption.tostring () = = "Plan Confirmation identification") return;
if (e.datacolumn.caption.tostring () = = "BOM conversion") return;
if (e.datacolumn.caption.tostring () = = "Warehouse Confirmation identification") return;
if (e.datacolumn.caption.tostring () = = "Whether to assign serial number") return;
if (e.datacolumn.caption.tostring () = = "Three-party to material") return;
if (e.datacolumn.caption.tostring () = = "Warehouse to material") return;
if (e.datacolumn.caption.tostring () = = "Three-party material receiving status") return;
if (e.datacolumn.caption.tostring () = = "Warehouse material receiving status") return;
if (e.datacolumn.caption.tostring () = = "Production Confirmation identification") return;
if (e.datacolumn.caption.tostring () = = "Willow Steam mark") return;
if (e.datacolumn.caption.tostring () = = "Restructuring rework or not to the BOM") return;
Set color for columns that need to be set
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_i D = ' "
+ Theuserid +" ' and Program_code = ' "+ Theprogramcode +" ' and Company_code = ' "+ Thecompanycode +" ') "
+ "and plan_code= '" + TJHDM + "'";
Dc.setthesql (SQL);
dt = DC. GetTable ();
if (dt. Rows.Count > 0)
{
//Set color
if (e.datacolumn.fieldname.tostring () = = "Plan_code") for the column that you want to set the color
{
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)
{
Set color for columns that need to be set
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)
{
Set color for columns that need to be set
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")
//{
No. 0 Column rmes_id
Object C0 = e.datacolumn.caption;
E.cell.backcolor = System.Drawing.Color.Red;
1th Column Command column
Object C1 = E.row.cells[1];
2nd Column Planning
Object C2 = e.row.cells[2];
3rd Column Plan Code
Object c3 = E.row.cells[3];
4th Column Production Line code
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 () = = "Plan Code")
// {
E.cell.backcolor = System.Drawing.Color.Red;
// }
//}
}
Label
Aspxgridview Changing column colors