Files
lserp_cs_5.0/插件库/Lskj.BaseInfo/Panel_GridPage.cs
T
2026-07-10 15:25:05 +08:00

90 lines
4.1 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CommonLib;
using Lskj.Common;
using DevExpress.XtraGrid.Views.Grid;
namespace Lskj.BaseInfo
{
public partial class Panel_GridPage : UserControl {
public string DLLCoid { get; set; }
public string formKey { get; set; }
public string FormText { get; set; }
public string OperatorId { get; set; }
public string OperatorName { get; set; }
public string Privilege { get; set; }
private DataTable dtColor;
public Panel_GridPage() {
InitializeComponent();
}
protected override void OnLoad(EventArgs e) {
string sqlCol = "select * from p_systembillauditAttachDetail where attachKey='" + formKey + "' order by orderid";
DataTable dtColumns = SqlHelper.ExecuteDataSet(sqlCol).Tables[0];
gridList.SetColumns(dtColumns);
gridList.SetDataSource(gridList.Sql);
String sqlRightMenu = "select * from p_systempopupmenu where tab='" + formKey + "' and visible2=0";
GridMenu gridMenu = new GridMenu(FormText, OperatorId, OperatorName, Privilege, DLLCoid, sqlRightMenu, gridList.gridControl);
gridMenu.BindGridMenu(formKey);
gridMenu.ShowMenuType = "sh";
String colorSql = "select * from p_systemwordbookcolor where tab='" + formKey + "' and isnull(useflag,0)=0 order by orderid";
dtColor = SqlHelper.ExecuteDataSet(colorSql).Tables[0];
gridList.gridView.RowCellStyle += new RowCellStyleEventHandler(gridView_RowCellStyle);
}
void gridView_RowCellStyle(object sender, RowCellStyleEventArgs e) {
if (e.RowHandle >= 0) {
DataRow row = gridList.gridView.GetDataRow(e.RowHandle);
string cond = string.Empty;
string color = string.Empty;
string forecolor = string.Empty;
foreach (DataRow dr in dtColor.Rows) {
List<string> condition = PubClass.GetParamValue(dr["condition"].ToString());
cond = dr["condition"].ToString();
foreach (string item in condition) {
string filedName = item.Replace("{", "").Replace("}", "");
cond = cond.Replace(item, row[filedName].ToString());
}
cond = PubClass.SqlToCode(cond);
color = dr["backcolor"] + "";
forecolor = dr["forcecolor"].ToString() + "";
string obj = Evaluator.Eval(cond) + "";
if (obj.IndexOf("true", StringComparison.OrdinalIgnoreCase) != -1) {
if (!string.IsNullOrEmpty(color)) {
System.Drawing.Color color1 = System.Drawing.ColorTranslator.FromHtml(color);
e.Appearance.BackColor = color1;
}
if (!string.IsNullOrEmpty(forecolor)) {
System.Drawing.Color foreColor = System.Drawing.ColorTranslator.FromHtml(forecolor);
e.Appearance.ForeColor = foreColor;
}
FontStyle fst = new FontStyle();
if (dr["ifBold"].ToString() == "1") {
fst = fst | FontStyle.Bold;
}
if (dr["ifItalic"].ToString() == "1") {
fst = fst | FontStyle.Italic;
}
if (dr["ifStrickOut"].ToString() == "1") {
fst = fst | FontStyle.Strikeout;
}
if (dr["ifUnderLine"].ToString() == "1") {
fst = fst | FontStyle.Underline;
}
e.Appearance.Font = new Font(e.Appearance.Font, fst);
}
}
}
}
}
}