using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using CoreFS.CA06;
using System.Windows.Forms;
using Infragistics.Win.UltraWinEditors;
using Infragistics.Win;
using System.Text.RegularExpressions;
using Core.Mes.Client.Comm.Server;
namespace Core.StlMes.Client.Mcp.Control
{
///
/// 基础数据查询
///
public class ClsBaseInfo
{
///
/// 设置UltraComboEditor中的中文和非中文统一高度。
///
///
public static void SetComboItemHeight(UltraComboEditor cmb)
{
cmb.Update();
foreach (ValueListItem item in cmb.Items)
{
if (Regex.IsMatch(item.DisplayText.ToString2(), @"[\u4e00-\u9fa5]+"))
{
item.Appearance.FontData.SizeInPoints = 9.0F;
}
else
{
item.Appearance.FontData.SizeInPoints = 10.5F;
}
}
}
///
/// 获取指定分类的公用基础信息
///
/// 快速索引码
/// 界面OB对象
/// 查询数据集
public static DataTable GetComBaseInfo(string sortCode, OpeBase ob)
{
return ServerHelper.GetData("com.steering.comm.db.ClsBaseInfo.getComBaseInfo", new object[] { sortCode }, ob);
}
///
/// 查询管理部门基础信息
///
/// 界面OB对象
/// 查询数据集
public static DataTable GetDepartmentInfo(OpeBase ob)
{
string sortCode = "90";
return GetComBaseInfo(sortCode, ob);
}
///
/// 加载基础数据到下拉框中
///
///
///
///
///
///
public static bool FillComBaseInfo(UltraComboEditor cmb, string sortCode, OpeBase ob, bool hasBlankLine)
{
DataTable dt = GetComBaseInfo(sortCode, ob);
if (hasBlankLine && dt != null && dt.Rows.Count > 0)
{
DataRow dr = dt.NewRow();
dt.Rows.InsertAt(dr, 0);
}
cmb.DataSource = dt;
cmb.DisplayMember = "BASENAME";
cmb.ValueMember = "BASECODE";
SetComboItemHeight(cmb);
return true;
}
///
/// 加载基础数据到下拉框中
///
///
///
///
///
///
public static bool FillComBaseInfo(ComboBox cmb, string sortCode, OpeBase ob, bool hasBlankLine)
{
DataTable dt = GetComBaseInfo(sortCode, ob);
if (hasBlankLine && dt != null && dt.Rows.Count > 0)
{
DataRow dr = dt.NewRow();
dt.Rows.InsertAt(dr, 0);
}
cmb.DataSource = dt;
cmb.DisplayMember = "BASENAME";
cmb.ValueMember = "BASECODE";
return true;
}
/////
///// 拼音助记码控件填充管理部门基础信息
/////
///// 需填充的拼音助记码控件
///// 界面OB对象
///// 是否包含空行
///// 查询数据集
//public static bool FillDepartmentInfo(Control.DataFilterControl df, OpeBase ob, bool hasBlankLine)
//{
// DataTable dt = GetDepartmentInfo(ob);
// if (hasBlankLine && dt != null && dt.Rows.Count > 0)
// {
// DataRow dr = dt.NewRow();
// dt.Rows.InsertAt(dr, 0);
// }
// df.DataSource = dt;
// df.DisplayMember = "BASENAME";
// df.ValueMember = "BASECODE";
// df.FilterMember = "MNEMONIC_CODE";
// return true;
//}
///
/// 加载品种名称
///
/// 需填充的控件
/// 界面OB对象
/// 是否包含空行
/// 是否加载成功
public static bool FillProduc_StyleInfo(UltraComboEditor cmb, OpeBase ob, bool hasBlankLine)
{
DataTable dt = GetComBaseInfo("4050", ob);
if (hasBlankLine && dt != null && dt.Rows.Count > 0)
{
DataRow dr = dt.NewRow();
dt.Rows.InsertAt(dr, 0);
}
cmb.DataSource = dt;
cmb.DisplayMember = "BASENAME";
cmb.ValueMember = "BASECODE";
SetComboItemHeight(cmb);
return true;
}
///
/// 加载品种名称
///
/// 需填充的控件
/// 界面OB对象
/// 是否包含空行
/// 是否加载成功
public static bool FillProduc_StyleInfo(ComboBox cmb, OpeBase ob, bool hasBlankLine)
{
DataTable dt = GetComBaseInfo("4050", ob);
if (hasBlankLine && dt != null && dt.Rows.Count > 0)
{
DataRow dr = dt.NewRow();
dt.Rows.InsertAt(dr, 0);
}
cmb.DataSource = dt;
cmb.DisplayMember = "BASENAME";
cmb.ValueMember = "BASECODE";
return true;
}
///
/// 加载标准类型
///
/// 需填充的控件
/// 界面OB对象
/// 是否包含空行
/// 是否加载成功
public static bool FillStdType(UltraComboEditor cmb, OpeBase ob, bool hasBlankLine)
{
DataTable dt = new DataTable();
DataColumn[] dc = new DataColumn[]{new DataColumn("NAME"), new DataColumn("CODE")};
dt.Columns.AddRange(dc);
dt.Rows.Add(new object[] { "订货标准", "G" });
dt.Rows.Add(new object[] {"协议标准", "X"});
dt.Rows.Add(new object[] {"Alpha", "K"});
dt.Rows.Add(new object[] {"内控", "N"});
dt.Rows.Add(new object[]{"试验标准", "S"});
dt.Rows.Add(new object[]{"成分偏差标准", "P"});
if (hasBlankLine && dt != null && dt.Rows.Count > 0)
{
DataRow dr = dt.NewRow();
dt.Rows.InsertAt(dr, 0);
}
cmb.DataSource = dt;
cmb.DisplayMember = "NAME";
cmb.ValueMember = "CODE";
SetComboItemHeight(cmb);
return true;
}
///
/// 加载冶金规范项目
///
/// 需填充的控件
/// 界面OB对象
/// 是否包含空行
/// 是否加载成功
public static bool FillMscItem(ComboBox cmb, OpeBase ob, bool hasBlankLine)
{
DataTable dt = GetComBaseInfo("4030", ob);
if (hasBlankLine && dt != null && dt.Rows.Count > 0)
{
DataRow dr = dt.NewRow();
dt.Rows.InsertAt(dr, 0);
}
cmb.DataSource = dt;
cmb.DisplayMember = "BASENAME";
cmb.ValueMember = "BASECODE";
return true;
}
///
/// 加载冶金规范项目
///
/// 需填充的控件
/// 界面OB对象
/// 是否包含空行
/// 是否加载成功
public static bool FillMscItem(UltraComboEditor cmb, OpeBase ob, bool hasBlankLine)
{
DataTable dt = GetComBaseInfo("4030", ob);
if (hasBlankLine && dt != null && dt.Rows.Count > 0)
{
DataRow dr = dt.NewRow();
dt.Rows.InsertAt(dr, 0);
}
cmb.DataSource = dt;
cmb.DisplayMember = "BASENAME";
cmb.ValueMember = "BASECODE";
SetComboItemHeight(cmb);
return true;
}
///
/// 加载管理部门
///
/// 需填充的控件
/// 界面OB对象
/// 是否包含空行
/// 是否加载成功
public static bool FillDepartment(UltraComboEditor cmb, OpeBase ob, bool hasBlankLine)
{
DataTable dt = ServerHelper.GetData("com.steering.mes.mcp.collarMaterial.ComBaseInfo.getDepartment",
new object[]{}, ob);
if (hasBlankLine && dt != null && dt.Rows.Count > 0)
{
DataRow dr = dt.NewRow();
dt.Rows.InsertAt(dr, 0);
}
cmb.DataSource = dt;
cmb.DisplayMember = "DEPARTNAME";
cmb.ValueMember = "DEPARTID";
SetComboItemHeight(cmb);
return true;
}
///
/// 加载管理部门
///
/// 需填充的控件
/// 界面OB对象
/// 是否包含空行
/// 是否加载成功
public static bool FillDepartment(ComboBox cmb, OpeBase ob, bool hasBlankLine)
{
DataTable dt = ServerHelper.GetData("com.steering.mes.mcp.collarMaterial.ComBaseInfo.getDepartment",
new object[]{}, ob);
if (hasBlankLine && dt != null && dt.Rows.Count > 0)
{
DataRow dr = dt.NewRow();
dt.Rows.InsertAt(dr, 0);
}
cmb.DataSource = dt;
cmb.DisplayMember = "DEPARTNAME";
cmb.ValueMember = "DEPARTID";
return true;
}
///
/// 通过管理部门ID加载科室
///
/// 需填充的控件
/// 界面OB对象
/// 是否包含空行
/// 是否加载成功
public static bool FillSectionByDepartId(string departmentId, ComboBox cmb, OpeBase ob, bool hasBlankLine)
{
DataTable dt = ServerHelper.GetData("com.steering.mes.mcp.collarMaterial.ComBaseInfo.getSection",
new object[]{}, ob);
dt.DefaultView.RowFilter = "PID = '"+ departmentId +"'";
if (hasBlankLine && dt != null && dt.Rows.Count > 0)
{
DataRow dr = dt.NewRow();
dt.Rows.InsertAt(dr, 0);
}
cmb.DataSource = dt;
cmb.DisplayMember = "DEPARTNAME";
cmb.ValueMember = "DEPARTID";
return true;
}
///
/// 通过管理部门ID加载科室
///
/// 需填充的控件
/// 界面OB对象
/// 是否包含空行
/// 是否加载成功
public static bool FillSectionByDepartId(string departmentId, UltraComboEditor cmb, OpeBase ob, bool hasBlankLine)
{
DataTable dt = ServerHelper.GetData("com.steering.mes.mcp.collarMaterial.ComBaseInfo.getSection",
new object[]{}, ob);
dt.DefaultView.RowFilter = "PID = '"+ departmentId +"'";
if (hasBlankLine && dt != null && dt.Rows.Count > 0)
{
DataRow dr = dt.NewRow();
dt.Rows.InsertAt(dr, 0);
}
cmb.DataSource = dt;
cmb.DisplayMember = "DEPARTNAME";
cmb.ValueMember = "DEPARTID";
SetComboItemHeight(cmb);
return true;
}
///
/// 加载所有管理科室
///
/// 需填充的控件
/// 界面OB对象
/// 是否包含空行
/// 是否加载成功
public static bool FillSection(UltraComboEditor cmb, OpeBase ob, bool hasBlankLine)
{
DataTable dt = ServerHelper.GetData("com.steering.mes.mcp.collarMaterial.ComBaseInfo.getSection",
new object[]{}, ob);
if (hasBlankLine && dt != null && dt.Rows.Count > 0)
{
DataRow dr = dt.NewRow();
dt.Rows.InsertAt(dr, 0);
}
cmb.DataSource = dt;
cmb.DisplayMember = "DEPARTNAME";
cmb.ValueMember = "DEPARTID";
SetComboItemHeight(cmb);
return true;
}
///
/// 加载所有管理科室
///
/// 需填充的控件
/// 界面OB对象
/// 是否包含空行
/// 是否加载成功
public static bool FillSection(ComboBox cmb, OpeBase ob, bool hasBlankLine)
{
DataTable dt = ServerHelper.GetData("com.steering.mes.mcp.collarMaterial.ComBaseInfo.getSection",
new object[]{}, ob);
if (hasBlankLine && dt != null && dt.Rows.Count > 0)
{
DataRow dr = dt.NewRow();
dt.Rows.InsertAt(dr, 0);
}
cmb.DataSource = dt;
cmb.DisplayMember = "DEPARTNAME";
cmb.ValueMember = "DEPARTID";
return true;
}
///
/// 加载水压公式
///
/// 需填充的控件
/// 界面OB对象
/// 是否包含空行
/// 是否加载成功
public static bool FillWtrExpress(ComboBox cmb, OpeBase ob, bool hasBlankLine)
{
DataTable dt = GetComBaseInfo("4053", ob);
if (hasBlankLine && dt != null && dt.Rows.Count > 0)
{
DataRow dr = dt.NewRow();
dt.Rows.InsertAt(dr, 0);
}
cmb.DataSource = dt;
cmb.DisplayMember = "BASENAME";
cmb.ValueMember = "BASECODE";
return true;
}
///
/// 加载水压公式
///
/// 需填充的控件
/// 界面OB对象
/// 是否包含空行
/// 是否加载成功
public static bool FillWtrExpress(UltraComboEditor cmb, OpeBase ob, bool hasBlankLine)
{
DataTable dt = GetComBaseInfo("4053", ob);
if (hasBlankLine && dt != null && dt.Rows.Count > 0)
{
DataRow dr = dt.NewRow();
dt.Rows.InsertAt(dr, 0);
}
cmb.DataSource = dt;
cmb.DisplayMember = "BASENAME";
cmb.ValueMember = "BASECODE";
return true;
}
///
/// 通过科室查找对应的部门
///
/// 科室ID
///
/// 部门名称
public static string GetDepartBySectionId(string sectionId, OpeBase ob)
{
DataTable dt = ServerHelper.GetData("com.steering.mes.mcp.collarMaterial.ComBaseInfo.getDeptBySection", new object[] { sectionId }, ob);
if (dt.Rows.Count > 0)
{
return dt.Rows[0]["DEPARTNAME"].ToString();
}
else
{
return "";
}
}
///
/// 通过科室查找对应的部门
///
/// 科室ID
///
/// 部门ID
public static string GetDepartIdBySectionId(string sectionId, OpeBase ob)
{
DataTable dt = ServerHelper.GetData("com.steering.mes.mcp.collarMaterial.ComBaseInfo.getDeptBySection", new object[] { sectionId }, ob);
if (dt.Rows.Count > 0)
{
return dt.Rows[0]["DEPARTID"].ToString();
}
else
{
return "";
}
}
public static string GetSaleOrg(string DeptID)
{
if (DeptID.IndexOf("002002") >= 0)
{
return "100102";
}
if (DeptID.IndexOf("002001004") >= 0)
{
return "100101";
}
if (DeptID.IndexOf("002001005") >= 0)
{
return "100103";
}
if (DeptID.IndexOf("002023001") >= 0)
{
return "100105";
}
return "NONE";
}
///
/// 根据部门表的主键获取描述
///
///
///
///
public static string GetDepartmentDescByDepartid(string departId, OpeBase ob)
{
DataTable dt = ServerHelper.GetData("com.steering.mes.mcp.collarMaterial.ComBaseInfo.getDepartDescByDepartId",
new object[]{departId}, ob);
if (dt.Rows.Count > 0)
{
return dt.Rows[0][0].ToString();
}
return "";
}
}
}