using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Infragistics.Win.UltraWinGrid;
using System.Drawing;
using CoreFS.CA06;
using Infragistics.Win.UltraWinEditors;
using System.Data;
using System.Windows.Forms;
using Core.Mes.Client.Comm.Server;
using Infragistics.Win.UltraWinMaskedEdit;
using System.Collections;
using Infragistics.Win;
using System.Text.RegularExpressions;
using System.IO;
namespace Core.StlMes.Client.YdmBcPipeManage
{
public class BaseMethod
{
///
/// 初始化下拉框
///
/// 下拉框
/// 请求的服务
/// 值成员
/// ob对象
/// 是否有空行
public static void InitComboEditor(UltraComboEditor uce, string methodId, string valueMember, OpeBase ob, bool isEmpty)
{
DataTable dt = ServerHelper.GetData(methodId, null, ob);
if (dt != null && dt.Rows.Count > 0)
{
if (isEmpty)
{
Object[] obj = new Object[] { "", "" };
DataRow dr = dt.NewRow();
dr.ItemArray = obj;
dt.Rows.InsertAt(dr, 0);
}
uce.DataSource = dt;
uce.ValueMember = valueMember;
SetComboItemHeight(uce);
}
}
///
/// 将下拉框绑定到GRID列
///
/// 下拉框(已经初始化完成)
/// 列名
/// 空间集合(每次只需填入this.Controls)
/// GRID
/// GRID的第几层结构
public static void BindColumn(UltraComboEditor uce, string ColumnName, System.Windows.Forms.Control.ControlCollection con, UltraGrid ug, int i)
{
con.Add(uce);
uce.Visible = false;
ug.DisplayLayout.Bands[i].Columns[ColumnName].EditorComponent = uce;
ug.DisplayLayout.Bands[i].Columns[ColumnName].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
SetComboItemHeight(uce);
}
///
/// 初始化下拉框 --带参数的
///
///
///
///
///
///
///
public static void InitComboEditorWithParmArr(UltraComboEditor uce, string methodId, string valueMember, OpeBase ob, bool isEmpty, params object[] parm)
{
DataTable dt = ServerHelper.GetData(methodId, parm, ob);
if (dt != null && dt.Rows.Count > 0)
{
if (isEmpty)
{
Object[] obj = new Object[] { "", "" };
DataRow dr = dt.NewRow();
dr.ItemArray = obj;
dt.Rows.InsertAt(dr, 0);
}
uce.DataSource = dt;
uce.ValueMember = valueMember;
uce.SelectedIndex = -1;
SetComboItemHeight(uce);
}
}
///
/// 设置UltraComboEditor中的中文和非中文统一高度。
///
///
public static void SetComboItemHeight(UltraComboEditor cmb)
{
foreach (ValueListItem item in cmb.Items)
{
if (Regex.IsMatch(item.DisplayText, @"[\u4e00-\u9fa5]+"))
{
item.Appearance.FontData.SizeInPoints = 9.0F;
}
else
{
item.Appearance.FontData.SizeInPoints = 10.5F;
}
}
}
///
/// UltraGrid可读
///
/// UltraGrid
/// 可编辑列
public static void setOtherColumnReadOnly(UltraGrid ugr, string[] keys)
{
keys.ToArray();
foreach (UltraGridColumn ugc in ugr.DisplayLayout.Bands[0].Columns)
{
if (!keys.Contains(ugc.Key))
{
ugc.CellActivation = Activation.ActivateOnly;
}
}
}
///
/// UltraGrid激活某行
///
/// UltraGrid
/// 列名
/// 对应的值
public static void UltraGridLocation(UltraGrid ug, String[] keys, String[] values)
{
if (ug.Rows.Count == 0)
{
return;
}
if (keys.Length == 0 || values.Length == 0 || values.Length != keys.Length)
{
return;
}
foreach (UltraGridRow ugr in ug.Rows)
{
Boolean flag = true;
for (int i = 0; i < keys.Length; i++)
{
if (!ugr.Cells[keys[i]].ToString().Equals(values[i]))
{
flag = false;
}
}
if (flag == true)
{
ugr.Activate();
return;
}
}
}
///
/// 设置列字段显示位置在右
///
/// UltraGrid
/// 要设置的列
public static void InitCellPosition(UltraGrid ug, string[] columnsKeys)
{
columnsKeys.ToArray();
foreach (UltraGridColumn ugc in ug.DisplayLayout.Bands[0].Columns)
{
if (columnsKeys.Contains(ugc.Key.ToString()))
{
ugc.CellAppearance.TextHAlign = Infragistics.Win.HAlign.Right;
}
}
}
///
/// 设置列字段显示位置在右
///
/// UltraGrid
/// 要设置的列
public static void InitCellPosition(UltraGrid ug, string[] columnsKeys,int dex)
{
columnsKeys.ToArray();
foreach (UltraGridColumn ugc in ug.DisplayLayout.Bands[dex].Columns)
{
if (columnsKeys.Contains(ugc.Key.ToString()))
{
ugc.CellAppearance.TextHAlign = Infragistics.Win.HAlign.Right;
}
}
}
///
/// 列求和
///
/// UltraGrid
/// 列数组
public static void GridColumnSum(UltraGrid ug, string[] columnKeys)
{
if (columnKeys.Length == 0)
{
return;
}
for (int i = 0; i < columnKeys.Length; i++)
{
ug.DisplayLayout.Bands[0].Summaries.Add(SummaryType.Sum, ug.DisplayLayout.Bands[0].Columns[columnKeys[i]], SummaryPosition.UseSummaryPositionColumn);
}
}
///
/// 设置UltraGrid行颜色
///
/// UltraGrid
/// 列
/// 值
/// 颜色
public static void SetUltraGridRowColor(UltraGrid ug, string[] columnKeys, string[] values, Color color)
{
if (ug.Rows.Count == 0 || columnKeys.Length == 0 || values.Length == 0 || color == null || values.Length != columnKeys.Length)
{
return;
}
foreach (UltraGridRow ugr in ug.Rows)
{
Boolean flag = true;
for (int i = 0; i < columnKeys.Length; i++)
{
if (!ugr.Cells[columnKeys[i]].Value.ToString().Equals(values[i]))
{
flag = false;
}
}
if (flag)
{
ugr.Appearance.BackColor = color;
}
}
}
///
/// 合并单元格
///
///
///
public static void MergedCell(UltraGrid ug, string[] columnKeys)
{
if (columnKeys.Length == 0)
{
return;
}
ug.DisplayLayout.Override.MergedCellStyle = MergedCellStyle.Never;
for (int i = 0; i < columnKeys.Length; i++)
{
ug.DisplayLayout.Bands[0].Columns[columnKeys[i]].MergedCellStyle = MergedCellStyle.Always;
}
}
///
/// 仓库数据权限
///
/// 页面配制信息(自定义参数)
/// 用户数据权限
/// 可查看仓库组成的字符串
public static string[] WarehousePermissions(String customInfo, String[] validDataPurviewIds, OpeBase ob)
{
string storageType = "";//仓库类别
string storageAttr = "";//仓库类型
if (customInfo.Length >= 0 && customInfo.Contains(","))
{
string[] strflg = customInfo.ToString().Split(new char[] { ',' });
storageType = strflg[0];
storageAttr = strflg[1];
}
DataTable dt = ServerHelper.GetData("com.steering.mes.mcp.common.WarehousePermissions.getWarehousePermissions", new object[] { storageType, storageAttr, validDataPurviewIds }, ob);
if (dt != null && dt.Rows.Count > 0)
{
string[] storages = new string[dt.Rows.Count];
for (int i = 0; i < dt.Rows.Count; i++)
{
storages[i] = dt.Rows[i]["STORAGE_NO"].ToString();
}
return storages;
}
else
{
return new string[1] { "" };
}
}
///
/// 仓库数据权限(用于报表)
///
/// 页面配制信息(自定义参数)
/// 用户数据权限
/// 可查看仓库组成的字符串
public static string[] WarehousePermissionsStore1(String[] validDataPurviewIds,string tt , OpeBase ob)
{
DataTable dt = ServerHelper.GetData("com.steering.mes.SendRecive.FrmFilpOutStorage.getWarehousePermissionsStore", new object[] { validDataPurviewIds ,""}, ob);
if (dt != null && dt.Rows.Count > 0)
{
string[] storages = new string[dt.Rows.Count];
for (int i = 0; i < dt.Rows.Count; i++)
{
storages[i] = dt.Rows[i]["STORAGE_NO"].ToString();
}
return storages;
}
else
{
return new string[1] { "" };
}
}
///
/// 仓库数据权限(用于报表)
///
/// 页面配制信息(自定义参数)
/// 用户数据权限
/// 可查看仓库组成的字符串
public static string[] WarehousePermissionsStore1(String[] validDataPurviewIds, OpeBase ob)
{
DataTable dt = ServerHelper.GetData("com.steering.mes.SendRecive.FrmFilpOutStorage.getWarehousePermissionsStore", new object[] { validDataPurviewIds }, ob);
if (dt != null && dt.Rows.Count > 0)
{
string[] storages = new string[dt.Rows.Count];
for (int i = 0; i < dt.Rows.Count; i++)
{
storages[i] = dt.Rows[i]["STORAGE_NO"].ToString();
}
return storages;
}
else
{
return new string[1] { "" };
}
}
///
/// 仓库数据权限(用于报表)
///
/// 页面配制信息(自定义参数)
/// 用户数据权限
/// 可查看仓库组成的字符串
public static string[] WarehousePermissionsStore(String[] validDataPurviewIds, OpeBase ob)
{
DataTable dt = ServerHelper.GetData("com.steering.mes.mcp.common.WarehousePermissions.getWarehousePermissionsStore", new object[] { validDataPurviewIds }, ob);
if (dt != null && dt.Rows.Count > 0)
{
string[] storages = new string[dt.Rows.Count];
for (int i = 0; i < dt.Rows.Count; i++)
{
storages[i] = dt.Rows[i]["STORAGE_NO"].ToString();
}
return storages;
}
else
{
return new string[1] { "" };
}
}
///
/// 数据权限查部门
///
/// 页面配制信息(自定义参数)
/// 用户数据权限
/// 可查看仓库组成的字符串
public static string[] WarehousePermissionsDepart(String[] validDataPurviewIds, OpeBase ob)
{
DataTable dt = ServerHelper.GetData("com.steering.mes.mcp.common.WarehousePermissions.getWarehousePermissionsDepart", new object[] { validDataPurviewIds }, ob);
if (dt != null && dt.Rows.Count > 0)
{
string[] storages = new string[dt.Rows.Count];
for (int i = 0; i < dt.Rows.Count; i++)
{
storages[i] = dt.Rows[i]["PID"].ToString();
}
return storages;
}
else
{
return new string[1] { "" };
}
}
///
/// 初始化仓库号下拉框
///
///
///
///
///
//public static void InitStorage(UltraComboEditor uce, String customInfo, String[] validDataPurviewIds, OpeBase ob)
//{
// string storageType = "";//仓库类别
// string storageAttr = "";//仓库类型
// if (customInfo.Length >= 0 && customInfo.Contains(","))
// {
// string[] strflg = customInfo.ToString().Split(new char[] { ',' });
// storageType = strflg[0];
// storageAttr = strflg[1];
// }
// DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.base.WarehousePermissions.getWarehousePermissions", new object[] { storageType, storageAttr, validDataPurviewIds }, ob);
// if (dt != null && dt.Rows.Count > 0)
// {
// uce.DataSource = dt;
// uce.DisplayMember = "STORAGE_NAME";
// uce.ValueMember = "STORAGE_NO";
// uce.SelectedIndex = 0;
// }
// else
// {
// uce.DataSource = null;
// }
//}
///
/// 初始化下拉框仓库名称
///
///
///
//public static void InitGpStorage(UltraComboEditor uce, OpeBase ob)
//{
// DataTable dtMapStatus = ServerHelper.GetData("Core.LgMes.Server.Stuffmanage.FrmBaseInformation.doQueryStorage", new object[] { }, ob);
// BaseMethod.InitComboEditor(uce, dtMapStatus, "BASENAME", "BASECODE");
//}
///
/// 初始化下拉框材料类别
///
///
///
//public static void InitProducFlagCom(UltraComboEditor uce, OpeBase ob)
//{
// DataTable dtProducFlag = ServerHelper.GetData("Core.LgMes.Server.Stuffmanage.FrmBaseInformation.queryMaterialSTyle", new object[] { }, ob);
// BaseMethod.InitComboEditor(uce, dtProducFlag, "BASENAME", "BASECODE");
//}
/////
///// 初始化下拉框材料状态
/////
/////
/////
//public static void InitMapStatusCom(UltraComboEditor uce, OpeBase ob)
//{
// DataTable dtMapStatus = ServerHelper.GetData("com.steering.pss.ydm.pipemanage.FrmPipeMagement.queryMaterialStatus", new object[] { }, ob);
// BaseMethod.InitComboEditor(uce, dtMapStatus, "BASENAME", "BASECODE");
//}
/////
///// 初始化下拉框材料状态
/////
/////
/////
//public static void InitMapStatusCom(UltraComboEditor uce, OpeBase ob, string flag)
//{
// DataTable dtMapStatus = ServerHelper.GetData("Core.LgMes.Server.Stuffmanage.FrmBaseInformation.queryMaterialStatus", new object[] { flag }, ob);
// BaseMethod.InitComboEditor(uce, dtMapStatus, "BASENAME", "BASECODE");
//}
/////
///// 初始化下拉框管坯物料码
/////
/////
/////
//public static void InitMaterialCom(UltraComboEditor uce, OpeBase ob)
//{
// DataTable dtMapStatus = ServerHelper.GetData("Core.LgMes.Server.Stuffmanage.FrmBaseInformation.doQueryMaterial", new object[] { }, ob);
// BaseMethod.InitComboEditor(uce, dtMapStatus, "BASENAME", "BASECODE");
//}
///
/// 初始下拉框
///
///
///
///
///
public static void InitComboEditor(UltraComboEditor uce, DataTable dt, String showName, String hideValue)
{
uce.DataSource = dt;
uce.DisplayMember = showName;
uce.ValueMember = hideValue;
}
///
/// 初始化下拉框仓库名称
///
///
///
public static void InitStorageNoGp(UltraComboEditor uce, OpeBase ob)
{
DataTable dtStorageNo = ServerHelper.GetData("com.steering.ydm.bc.FrmDeleteMatBcM.getStorageNoGp", new object[] { }, ob);
BaseMethod.InitComboEditor(uce, dtStorageNo, "STORAGE_NAME", "STORAGE_NO");
}
///
/// 初始化下拉框仓库名称
///
///
///
public static void InitStorageNo(UltraComboEditor uce, OpeBase ob)
{
DataTable dtStorageNo = ServerHelper.GetData("com.steering.ydm.bc.FrmDeleteMatBcM.getStorageNo", new object[] { }, ob);
BaseMethod.InitComboEditor(uce, dtStorageNo, "STORAGE_NAME", "STORAGE_NO");
}
///
/// 初始化下拉框装卸点
///
///
///
public static void InitUnLoad(UltraComboEditor uce, OpeBase ob,string plineCode)
{
DataTable dtStorageNo = ServerHelper.GetData("com.steering.Demand.sever.FrmBcM.getUnLoad", new object[] { plineCode }, ob);
BaseMethod.InitComboEditor(uce, dtStorageNo, "UNLOADING_DESC", "UNLOADING_CODE");
}
///
/// 初始化下拉框需求单位
///
///
///
public static void InitDemandUser(UltraComboEditor uce, OpeBase ob,string[] plineCode)
{
DataTable dtStorageNo = ServerHelper.GetData("com.steering.Demand.sever.FrmBcM.getDemandUser", new object[] { plineCode }, ob);
BaseMethod.InitComboEditor(uce, dtStorageNo, "PLINE_NAME", "PLINE_CODE");
}
///
/// 初始化下拉框工序判定结果
///
///
///
public static void InitJudgeResult(UltraComboEditor uce, OpeBase ob)
{
DataTable dtStorageNo = ServerHelper.GetData("com.steering.ydm.bc.FrmApplyCode.getJudgeResult", new object[] { }, ob);
BaseMethod.InitComboEditor(uce, dtStorageNo, "BASENAME", "BASECODE");
}
///
/// 初始下拉框
///
///
///
///
///
public static void InitComboEditor1(UltraComboEditor uce, DataTable dt, String showName, String hideValue)
{
uce.DataSource = dt;
uce.DisplayMember = showName;
uce.ValueMember = hideValue;
uce.SelectedIndex = 1;
}
///
/// 初始化下拉框产线
///
///
///
//public static void InitPline(UltraComboEditor uce, OpeBase ob)
//{
// DataTable dtPline = ServerHelper.GetData("com.steering.pss.ydm.pipemanage.FrmPipeInventoryIn.getPline", new object[] { }, ob);
// BaseMethod.InitComboEditor(uce, dtPline, "PLINE_NAME", "PLINE_CODE");
//}
/////
///// 初始化下拉框材料来源
/////
/////
/////
//public static void InitSourse(UltraComboEditor uce, OpeBase ob)
//{
// DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.pipemanage.FrmPipeInventoryIn.getSourse", new object[] { "8013" }, ob);
// BaseMethod.InitComboEditor1(uce, dt, "BASENAME", "BASECODE");
//}
/////
///// 初始化下拉框钢种
/////
/////
/////
//public static void InitGrade(UltraComboEditor uce, OpeBase ob)
//{
// DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.pipemanage.FrmPipeEnter.getGrade", new object[] { }, ob);
// BaseMethod.InitComboEditor(uce, dt, "GRADENAME", "GRADECODE");
//}
/////
///// 获取规格
/////
/////
/////
//public static void InitSpec(UltraComboEditor uce, OpeBase ob)
//{
// DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.pipemanage.FrmPipeEnter.getSpec", new object[] { }, ob);
// BaseMethod.InitComboEditor(uce, dt, "SPEC_NAME", "SPEC_CODE");
//}
/////
///// 获取扣型
/////
/////
/////
//public static void InitModel(UltraComboEditor uce, OpeBase ob)
//{
// DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.pipemanage.FrmPipeEnter.getModel", new object[] { }, ob);
// BaseMethod.InitComboEditor(uce, dt, "MODEL_DESC", "MODEL_CODE");
//}
/////
///// 获取品名
/////
/////
/////
//public static void InitProcduce(UltraComboEditor uce, OpeBase ob)
//{
// DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.base.BaseOperations.getProcduce", new object[] { }, ob);
// BaseMethod.InitComboEditor(uce, dt, "PRODUC_JX", "PRODUCCODE");
//}
/////
///// 获取钢级
/////
/////
/////
//public static void InitSteel(UltraComboEditor uce, OpeBase ob)
//{
// DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.base.BaseOperations.getSteel", new object[] { }, ob);
// BaseMethod.InitComboEditor(uce, dt, "STEELNAME", "STEELCODE");
//}
/////
///// 获取标准类别
/////
/////
/////
//public static void InitStdStyle(UltraComboEditor uce, OpeBase ob)
//{
// DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.base.BaseOperations.getStdStyle", new object[] { }, ob);
// BaseMethod.InitComboEditor(uce, dt, "STD_STYLE_DESC", "STD_STYLE");
//}
/////
///// 初始化下拉框原因
/////
/////
/////
//public static void InitReason(UltraComboEditor uce, OpeBase ob)
//{
// DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.pipemanage.FrmPipeInventoryIn.getSourse", new object[] { "8012" }, ob);
// BaseMethod.InitComboEditor(uce, dt, "BASENAME", "BASECODE");
//}
/////
///// 初始化下拉框综合判断结果
/////
/////
/////
//public static void InitJustResult(UltraComboEditor uce, OpeBase ob)
//{
// DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.pipemanage.FrmPipeInventoryIn.getSourse", new object[] { "407407" }, ob);
// BaseMethod.InitComboEditor(uce, dt, "BASENAME", "BASECODE");
//}
/////
///// 初始化下拉框所属权单位
/////
/////
/////
//public static void InitBelongCode(UltraComboEditor uce, OpeBase ob)
//{
// DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.pipemanage.FrmPipeInventoryIn.getBelongCode", new object[] { }, ob);
// BaseMethod.InitComboEditor(uce, dt, "DEPARTNAME", "DEPARTID");
//}
/////
///// 销售组织权限
/////
///// 数据权限
/////
///// 字符串数组
//public static string[] InitPermissions(string[] validDataPurviewIds, OpeBase ob)
//{
// string[] arr = null;
// DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.base.WarehousePermissions.getSalgPermissions", new object[] { validDataPurviewIds }, ob);
// if (dt != null && dt.Rows.Count > 0)
// {
// arr = new string[dt.Rows.Count];
// for (int i = 0; i < dt.Rows.Count; i++)
// {
// arr[i] = dt.Rows[i][0].ToString();
// }
// }
// return arr;
//}
/////
///// 炼钢权限
/////
///// 数据权限
/////
///// 字符串数组
//public static string[] InitLgPermissions(string[] validDataPurviewIds,string processNo, OpeBase ob)
//{
// string[] arr = null;
// DataTable dt = ServerHelper.GetData("Core.LgMes.Server.Common.ComLgValidDataPurviewIds.getLgPermissions", new object[] { validDataPurviewIds, processNo }, ob);
// if (dt != null && dt.Rows.Count > 0)
// {
// arr = new string[dt.Rows.Count];
// for (int i = 0; i < dt.Rows.Count; i++)
// {
// arr[i] = dt.Rows[i][0].ToString();
// }
// }
// return arr;
//}
/////
///// 获取PCode
/////
///// user_depatment
/////
//public static string GetPCode(string Department, OpeBase ob)
//{
// string Pcode = "";
// DataTable dt = ServerHelper.GetData("Core.LgMes.Server.Common.ComLgValidDataPurviewIds.getPCode", new Object[] { Department }, ob);
// if (dt.Rows.Count > 0)
// {
// Pcode = dt.Rows[0]["pline_code"].ToString();
// }
// return Pcode;
//}
///
/// 获取产线
///
/// 数据权限
///
/// 字符串数组
public static string[] getPCodePline(string[] arr1,OpeBase _ob)
{
string[] arr = null;
DataTable dt = ServerHelper.GetData("com.steering.ydm.bc.FrmFilpOutStorage.getPCode", new Object[] { arr1 },_ob);
if (dt != null && dt.Rows.Count > 0)
{
arr = new string[dt.Rows.Count];
for (int i = 0; i < dt.Rows.Count; i++)
{
arr[i] = dt.Rows[i][0].ToString();
}
return arr;
}
else
{
return new string[1] { "" };
}
}
public static string[] InitDropPlineCodePower(UltraComboEditor ugc, string[] validDataPurviewIds, OpeBase ob)
{
DataTable dt = ServerHelper.GetData("com.steering.ydm.bc.FrmFilpOutStorage.getPCode", new object[] { validDataPurviewIds }, ob);
if (dt != null && dt.Rows.Count > 0)
{
ugc.DataSource = dt;
ugc.ValueMember = "PLINE_CODE";
ugc.DisplayMember = "PLINE_NAME";
string[] plineArr = new string[dt.Rows.Count];
for (int i = 0; i < dt.Rows.Count; i++)
{
plineArr[i] = dt.Rows[i]["PLINE_CODE"].ToString();
}
return plineArr;
}
else
{
return null;
}
}
public static string[] InitDropPlineCodePower(List ugc, string[] validDataPurviewIds, OpeBase ob)
{
DataTable dt = ServerHelper.GetData("com.steering.ydm.bc.FrmFilpOutStorage.getPCode", new object[] { validDataPurviewIds }, ob);
if (dt != null && dt.Rows.Count > 0)
{
ugc.ForEach(p =>
{
p.DataSource = dt;
p.ValueMember = "PLINE_CODE";
p.DisplayMember = "PLINE_NAME";
});
string[] plineArr = new string[dt.Rows.Count];
for (int i = 0; i < dt.Rows.Count; i++)
{
plineArr[i] = dt.Rows[i]["PLINE_CODE"].ToString();
}
return plineArr;
}
else
{
return null;
}
}
///
/// 设置列显示位数
///
///
///
public static void setUltraGridColumnMaxInput(UltraGrid ug, string[] arr)
{
if (ug == null || arr == null || arr.Length == 0)
{
return;
}
arr.ToArray();
foreach (UltraGridColumn ugc in ug.DisplayLayout.Bands[0].Columns)
{
if (arr.Contains(ugc.Key.ToString()))
{
ugc.MaskClipMode = MaskMode.IncludeLiterals;
ugc.MaskInput = "{LOC}nn,nnn,nnn.nnn";
}
}
}
///
/// 键盘按下Ctrl+D,拷贝活动单元格的数据到所有已勾选的此列的单元格中
///
/// UltraGrid
///
/// 可以进行列名称
public static void setGridCopyActColumn(UltraGrid ugrid, KeyEventArgs e, params string[] strs)
{
if (e.Control && e.KeyCode == Keys.D)
{
if (ugrid != null && ugrid.ActiveRow != null)
{
UltraGridRow ugr = ugrid.ActiveRow;
foreach (string colName in strs)
{
if (ugrid.ActiveCell.Column.Key.Equals(colName))
{
if (ugr.Cells[colName].Activation != Activation.AllowEdit)
{
return;
}
ugrid.UpdateData();
ArrayList list = new ArrayList();
IQueryable checkRows = ugrid.Rows.AsQueryable().Where("CHK = 'True' ");
if (checkRows.Count() == 0)
{
return;
}
foreach (UltraGridRow uRow in checkRows)
{
if (uRow != ugr && uRow.Cells[colName].Activation == Activation.AllowEdit)
{
uRow.Cells[colName].Value = ugr.Cells[colName].Value;
}
}
}
}
}
}
}///
/// 初始年份
///
///
public static void InitYear(UltraComboEditor uce)
{
DataTable dtYear = new DataTable();
dtYear.Columns.Add("YEAR");
for (int i = 2000; i < 2200; i++)
{
DataRow dr = dtYear.NewRow();
dr["YEAR"] = i.ToString();
dtYear.Rows.Add(dr);
}
uce.DataSource = dtYear;
uce.DisplayMember = "YEAR";
uce.ValueMember = "YEAR";
}
///
/// 初始月份
///
///
public static void InitMonth(UltraComboEditor uce)
{
DataTable dtMonth = new DataTable();
dtMonth.Columns.Add("MONTH");
for (int i = 1; i < 13; i++)
{
DataRow dr = dtMonth.NewRow();
dr["MONTH"] = string.Format("{0:00}", i);
dtMonth.Rows.Add(dr);
}
uce.DataSource = dtMonth;
uce.DisplayMember = "MONTH";
uce.ValueMember = "MONTH";
}
///
/// 键盘按下Ctrl+D,拷贝活动单元格的数据到所有已勾选的此列的单元格中
///
/// UltraGrid
///
/// 可以进行列名称
public static void setGridCopyActColumn1(UltraGrid ugrid, KeyEventArgs e, params string[] strs)
{
if (e.Control && e.KeyCode == Keys.D)
{
if (ugrid != null && ugrid.ActiveRow != null)
{
UltraGridRow ugr = ugrid.ActiveRow;
foreach (string colName in strs)
{
if (ugrid.ActiveCell.Column.Key.Equals(colName))
{
if (ugr.Cells[colName].Activation != Activation.AllowEdit)
{
return;
}
ugrid.UpdateData();
ArrayList list = new ArrayList();
IQueryable checkRows = ugrid.Rows.AsQueryable().Where("CHOOSE = 'True' ");
if (checkRows.Count() == 0)
{
return;
}
foreach (UltraGridRow uRow in checkRows)
{
if (uRow != ugr && uRow.Cells[colName].Activation == Activation.AllowEdit)
{
uRow.Cells[colName].Value = ugr.Cells[colName].Value;
}
}
}
}
}
}
}
///
/// 获取表格中
///
/// 返回类
/// 数据表
/// 输入类
///
public static T GetTableToEntity(DataTable dt, T t)
{
String[] strColumns = null;
DataRow dr = dt.Rows[0];
try
{
if (dt.Columns.Count > 0)
{
int columnNum = 0;
columnNum = dt.Columns.Count;
strColumns = new string[columnNum];
for (int i = 0; i < dt.Columns.Count; i++)
{
strColumns[i] = dt.Columns[i].ColumnName.Replace("_", "");
}
System.Reflection.PropertyInfo[] pro = t.GetType().GetProperties();
foreach (System.Reflection.PropertyInfo item in pro)
{
for (int i = 0; i < strColumns.Length; i++)
{
if (string.Compare(item.Name.ToString(), strColumns[i].ToString(), true) == 0)
{
if (item.PropertyType == typeof(int?))
{
item.SetValue(t, Convert.ToInt32(dr[i].ToString3()), null);
}
else if (item.PropertyType == typeof(decimal?))
{
item.SetValue(t, Convert.ToDecimal(dr[i].ToString3()), null);
}
else
{
item.SetValue(t, dr[i].ToString(), null);
}
}
}
}
}
else
{
}
}
catch (Exception e)
{
System.Windows.Forms.MessageBox.Show("出错:", e.ToString());
}
return t;
}
///
/// 获取数据源中第一行数据赋到类中(grid 带下划线)
///
/// 返回类
/// 输入带数据的数据源
/// 输入类
///
public static T GetUltraGridToEntityNEW(UltraGrid _grid, T t)
{
String[] strColumns = null;
String[] strColumnsNew = null;
UltraGridRow dr = _grid.Rows[0];
int columnNum = dr.Cells.Count;
strColumns = new String[columnNum];
strColumnsNew = new String[columnNum];
for (int i = 0; i < columnNum; i++)
{
strColumns[i] = _grid.DisplayLayout.Bands[0].Columns[i].Key.ToString().Replace("_", "");
strColumnsNew[i] = _grid.DisplayLayout.Bands[0].Columns[i].Key.ToString();
}
System.Reflection.PropertyInfo[] pro = t.GetType().GetProperties();
foreach (System.Reflection.PropertyInfo item in pro)
{
for (int i = 0; i < strColumns.Length; i++)
{
if (string.Compare(item.Name.ToString(), strColumns[i].ToString(), true) == 0)
{
if (item.PropertyType == typeof(int?))
{
item.SetValue(t, Convert.ToInt32(dr.Cells[strColumnsNew[i]].Value.ToString3()), null);
}
else if (item.PropertyType == typeof(decimal?))
{
item.SetValue(t, Convert.ToDecimal(dr.Cells[strColumnsNew[i]].Value.ToString3()), null);
}
else
{
item.SetValue(t, Convert.ToString(dr.Cells[strColumnsNew[i]].Value.ToString()), null);
}
}
}
}
return t;
}
//调用本地程序打开查看服务器文件
///
/// 调用本地程序打开查看服务器文件
///
///
public static void ViewCarft_No(string pathName)
{
try
{
//删除本地文件
string tmpPath = Environment.CurrentDirectory + "\\Tmp\\";
DirectoryInfo di = new DirectoryInfo(tmpPath);
if (di.Exists == false)
{
di.Create();
return;
}
foreach (FileInfo fi in di.GetFiles())
{
try
{
fi.Delete();
}
catch { continue; }
}
//下载写入本地Tmp目录
if (pathName == "" || pathName == null) return;
List list = Core.Mes.Client.Comm.Server.FileHelper.Download(pathName);
foreach (FileBean bean in list)
{
FileStream fs = new FileStream(tmpPath + bean.getFileName(), FileMode.Create);
fs.Write(bean.getFile(), 0, bean.getFile().Length);
fs.Flush();
fs.Close();
System.Diagnostics.Process MyProcess = new System.Diagnostics.Process();
MyProcess.StartInfo.FileName = tmpPath + bean.getFileName();
MyProcess.StartInfo.Verb = "Open";
MyProcess.StartInfo.CreateNoWindow = true;
MyProcess.Start();
return;
}
}
catch { }
}
}
}