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; namespace Core.Mes.Client.Comm.Server { /// /// 基础数据查询 /// 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.comm.data.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.comm.data.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.comm.data.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.comm.data.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.comm.data.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.comm.data.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.comm.data.ComBaseInfo.getDeptBySection", new object[]{sectionId}, ob); if (dt.Rows.Count > 0) { return dt.Rows[0]["DEPARTNAME"].ToString(); } else { return ""; } } /// /// 通过科室查找对应的部门 将国内贸易部国外贸易部改成销售总公司 /// /// 科室ID /// /// 部门名称 public static string GetDepartBySectionIdChangeSale(string sectionId, OpeBase ob) { DataTable dt = ServerHelper.GetData("com.steering.comm.data.ComBaseInfo.getDeptBySection", new object[] { sectionId }, ob); if (dt.Rows.Count > 0) { if (sectionId.StartsWith("002001042001") || sectionId.StartsWith("002001042002") || sectionId.StartsWith("002001042003")) { return "销售总公司" ; } else { return dt.Rows[0]["DEPARTNAME"].ToString(); } } else { return ""; } } /// /// 通过科室查找对应的部门 /// /// 科室ID /// /// 部门ID public static string GetDepartIdBySectionId(string sectionId, OpeBase ob) { DataTable dt = ServerHelper.GetData("com.steering.comm.data.ComBaseInfo.getDeptBySection", new object[]{sectionId}, ob); if (dt.Rows.Count > 0) { return dt.Rows[0]["DEPARTID"].ToString(); } else { return ""; } } public static List GetListByValid(string[] arr) { List list = new List(); foreach (String DeptID in arr) { if (DeptID.StartsWith("002001042001")) { if (!list.Contains("100101")) list.Add("100101"); } if (DeptID.StartsWith("002001042002")) { if (!list.Contains("100102")) list.Add("100102"); } if (DeptID.StartsWith("002023")) { if (!list.Contains("100101")) list.Add("100101"); if (!list.Contains("100105")) list.Add("100105"); } } return list; } public static string[] GetArrByValid(string[] arr) { string[] list = new string[4]; int index = 0; foreach (String DeptID in arr) { if (DeptID.StartsWith("002001042001")) { if (!list.Contains("100101")) { list[index] = "100101"; index++; } } if (DeptID.StartsWith("002001042002")) { if (!list.Contains("100102")) { list[index] = "100102"; index++; } } if (DeptID.StartsWith("002023")) { if (!list.Contains("100105")) list[index] = "100105"; index++; } } return list; } public static ValueList GetSaleOrgByValid(string[] arr) { List list = GetListByValid(arr); ValueListItem[] items = new ValueListItem[list.Count]; ValueList valueList = new ValueList(); int index = 0; foreach (string saleorg in list) { ValueListItem listItem = new ValueListItem(); if (saleorg.Equals("100101")) listItem = new ValueListItem("100101", "国内贸易部"); else if (saleorg.Equals("100102")) listItem = new ValueListItem("100102", "国际贸易部"); else if (saleorg.Equals("100105")) listItem = new ValueListItem("100105", "天淮公司"); items[index] = listItem; index++; } if (list.Count <= 0) { ValueListItem listItem = new ValueListItem(); listItem = new ValueListItem("NONE", ""); items[1] = listItem; } valueList.ValueListItems.AddRange(items); return valueList; } public static string GetSaleOrg(string DeptID) { if (DeptID.IndexOf("002001042001") >= 0) { return "100101"; } if (DeptID.IndexOf("002001042002") >= 0) { return "100102"; } if (DeptID.IndexOf("002023") >= 0) { return "100105"; } return "NONE"; } /// /// 根据部门表的主键获取描述 /// /// /// /// public static string GetDepartmentDescByDepartid(string departId, OpeBase ob) { DataTable dt = ServerHelper.GetData("com.steering.comm.data.ComBaseInfo.getDepartDescByDepartId", new object[]{departId}, ob); if (dt.Rows.Count > 0) { return dt.Rows[0][0].ToString(); } return ""; } /// /// 通过用户ID获取科室 /// /// /// /// public static string[] GetUnitByUser(string userId, OpeBase ob) { DataTable dt = ServerHelper.GetData("com.steering.comm.data.ComBaseInfo.getUnitByUser", new object[] { userId }, ob); if (dt.Rows.Count > 0) { return new string[] { dt.Rows[0]["DEPTID"].ToString(), dt.Rows[0]["DEPARTNAME"].ToString() }; } return new string[] { "", "" }; } /// /// 通过用户名称获取科室 /// /// /// /// public static string[] GetUnitByUserName(string userName, OpeBase ob, params string[] department) { DataTable dt = ServerHelper.GetData("com.steering.comm.data.ComBaseInfo.getUnitByUserName", new object[] { userName, department }, ob); if (dt.Rows.Count > 0) { return new string[] { dt.Rows[0]["DEPTID"].ToString(), dt.Rows[0]["DEPARTNAME"].ToString() }; } if (userName == "admin") { return new string[] { "admin", "admin" }; } return new string[]{"", ""}; } } }