using System; using System.Collections.Generic; using System.Drawing; using System.Windows.Forms; using System.Linq; using QM.Common; using QMAPP.Entity; using QMAPP.FJC.Entity; using QMAPP.FJC.Entity.Andon; using QMAPP.FJC.Entity.Basic; using QMAPP.FJC.Entity.ODS; using QMAPP.FJC.Entity.Operation; using QMAPP.ServicesAgent; using QMAPP.FJC.Entity.Stocktaking; using QMAPP.MD.Entity; namespace QMAPP.WinForm.Common { public class BasicData { #region 获取班次下拉列表 /// /// 获取班次下拉列表 /// /// public List GetShiftComboxSource() { QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent(); ProduceShift entity = new ProduceShift(); List list = new List(); try { //获取工序信息 list = agent.InvokeServiceFunction>("ProduceShiftBLL_GetWorkcenterShifts", ""); //是否带空项填充返回值 list.Insert(0, new ProduceShift()); return list; } catch (Exception ex) { throw ex; } } #endregion /// /// 获取播放类型下拉列表 /// /// public List GetVideoInfoList() { //获取类别 VideoTypeEntity searchModel = new VideoTypeEntity(); //执行查询 List list = new List(); QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent(); list = agent.InvokeServiceFunction>("VideoTypeBLL_GetAllList"); //是否带空项填充返回值 list.Insert(0, new VideoTypeEntity()); return list; } /// /// 获取设备下拉列表 /// /// public List GetMachineInfoList(string[] processType, bool isWithEmpty) { //获取类别 MachineInfo searchModel = new MachineInfo(); if (processType.Length > 0) { searchModel.PROCESSTYPES = "'" + string.Join("','", processType) + "'"; } searchModel.PRODUCELINE = EnumGeter.PRODUCELINE.B9.ToString(); //执行查询 List list = new List(); QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent(); list = agent.InvokeServiceFunction>("MachineInfoBLL_GetAllList", searchModel); list = list.OrderBy(p => p.MACHINENAME).ToList() ; //是否带空项填充返回值 if (isWithEmpty) { list.Insert(0, new MachineInfo()); } return list; } /// /// 获取设备下拉列表20171105 /// /// public List GetMachineList(string ordertype, bool isWithEmpty) { //获取类别 MachineInfo searchModel = new MachineInfo(); searchModel.PRODUCELINE = EnumGeter.PRODUCELINE.B9.ToString(); WorkCell info = new WorkCell(); info.WORKCELL_CODE = ordertype; //执行查询 List list = new List(); QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent(); list = agent.InvokeServiceFunction>("MachineInfoBLL_GetMachineForOrderList", new MachineInfo(), info); //是否带空项填充返回值 if (isWithEmpty) { list.Insert(0, new MachineInfo()); } return list; } /// /// 获取设备下拉列表 /// /// public List GetMachineInfoAndModelList(string[] processType, bool isWithEmpty) { //获取类别 MachineInfo searchModel = new MachineInfo(); if (processType.Length > 0) { searchModel.PROCESSTYPES = string.Join(",", processType); } searchModel.PRODUCELINE = EnumGeter.PRODUCELINE.B9.ToString(); //执行查询 List list = new List(); QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent(); list = agent.InvokeServiceFunction>(B9BasicService.MachineInfoBLL_GetAllListAndModels.ToString(), searchModel); list = list.OrderBy(p => p.MACHINENAME).ToList(); //是否带空项填充返回值 if (isWithEmpty) { list.Insert(0, new MachineInfo { MACHINENAME = "", MACHINECODDE = "" }); } return list; } public List GetMachineInfoMachineCheck() { //获取类别 //执行查询 List list = new List(); QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent(); list = agent.InvokeServiceFunction>("MachineInfoBLL_GetMachineInfoMachineCheck"); list.Insert(0, new MachineInfo { MACHINENAME = "", MACHINECODDE = "" }); return list; } /// /// 获取原材料下拉列表 /// /// public List GetMaterielInfoList(string materialType, bool isWithEmpty) { //获取类别 MD.Entity.Material searchModel = new MD.Entity.Material(); searchModel.MATERIAL_TYPE_CODE = materialType; //searchModel.PRODUCELINE = EnumGeter.PRODUCELINE.B9.ToString(); //执行查询 List list = new List(); QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent(); list = agent.InvokeServiceFunction>("MaterialBLL_GetMaterialList", searchModel); list = list.OrderBy(p => p.MATERIAL_NAME).ToList(); //是否带空项填充返回值 if (isWithEmpty) { list.Insert(0, new MD.Entity.Material()); } return list; } /// /// 获取操作人下拉列表 /// /// public List GetOperatorInfoList(string processType, bool isWithEmpty) { //获取类别 OperatorInfo searchModel = new OperatorInfo(); searchModel.PROCESSTYPE = processType; //执行查询 List list = new List(); QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent(); list = agent.InvokeServiceFunction>(B9BasicService.OperatorInfoBLL_GetAllList.ToString(), searchModel); //是否带空项填充返回值 if (isWithEmpty) { list.Insert(0, new OperatorInfo()); } return list; } /// /// 获取操作人下拉列表 /// /// public List GetOperatorInfoComboxSource(string processType, bool isWithEmpty) { List list = new List(); //获取类别 List listEntity = GetOperatorInfoList(processType, isWithEmpty); foreach (var item in listEntity) { list.Add(new ListItem(item.OPERATOR, item.OPERATORCODE)); } return list; } /// /// 获取发货料架下拉列表 /// /// public List GetMaterialShelfTypeList(string productType, bool isWithEmpty) { //获取类别 MaterialShelfType searchModel = new MaterialShelfType(); if (!string.IsNullOrEmpty(productType)) { searchModel.PRODUCTTYPE = productType; } //执行查询 List list = new List(); QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent(); list = agent.InvokeServiceFunction>(B9BasicService.MaterialShelfTypeBLL_GetAllList.ToString(), searchModel); //是否带空项填充返回值 if (isWithEmpty) { list.Insert(0, new MaterialShelfType()); } return list; } /// /// 读取零件类别下拉列表 /// /// public List GetProductBasicList(string productType, bool isWithEmpty) { //获取类别 ProductBasic searchModel = new ProductBasic(); if (!string.IsNullOrEmpty(productType)) { searchModel.PRODUCTMAINTYPE = productType; } //执行查询 List list = new List(); QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent(); list = agent.InvokeServiceFunction>(B9BasicService.ProductBasicBLL_GetAllList.ToString(), searchModel); //是否带空项填充返回值 if (isWithEmpty) { list.Insert(0, new ProductBasic()); } return list; } /// /// 读取零件类别下拉列表 /// /// public List GetProductBasicList(ProductBasic searchModel, bool isWithEmpty) { //执行查询 List list = new List(); QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent(); list = agent.InvokeServiceFunction>(B9BasicService.ProductBasicBLL_GetAllList.ToString(), searchModel); //是否带空项填充返回值 if (isWithEmpty) { list.Insert(0, new ProductBasic()); } return list; } /// /// 读取零件类别下拉列表 /// /// public List GetMaterialTypeList(MaterialClass searchModel, bool isWithEmpty) { //执行查询 List list = new List(); QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent(); list = agent.InvokeServiceFunction>("MaterialClassBLL_GetAllList", searchModel); list = list.OrderBy(p => p.MATERIAL_TYPE_NAME).ToList(); //是否带空项填充返回值 if (isWithEmpty) { list.Insert(0, new MaterialClass()); } return list; } /// /// 读取产品项目下拉列表 /// /// public List GetProjectList(bool isWithEmpty) { //执行查询 List list = new List(); QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent(); list = agent.InvokeServiceFunction>("ProjectBLL_GetAllList", new Project { }); list = list.OrderBy(p => p.PROJECT_NAME).ToList(); //是否带空项填充返回值 if (isWithEmpty) { list.Insert(0, new Project()); } return list; } /// /// 读取Dictionary.xml下拉列表 /// /// public List GetDictionaryList(string kind) { List listItem = new List(); Dictionary dicts = null; QMFrameWork.Common.Util.ModelDictionaryHandler.TryGetModelDictionary(kind.ToString(), out dicts); foreach (string item in dicts.Keys) { listItem.Add(new ListItem(item, dicts[item])); } return listItem; } /// /// 获取班次下拉列表 /// /// public List GetProduceShiftComboxSource(ProduceShift condition, bool isWithEmpty) { //执行查询 List listEntity = new List(); List list = new List(); QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent(); listEntity = agent.InvokeServiceFunction>(B9BasicService.ProduceShiftBLL_GetAllList.ToString(), condition); //是否带空项填充返回值 if (isWithEmpty) { listEntity.Insert(0, new ProduceShift { PRODUCESHIFTNAME = string.Empty, PRODUCESHIFTTCODE = string.Empty }); } foreach (var item in listEntity) { list.Add(new ListItem(item.PRODUCESHIFTNAME, item.PRODUCESHIFTTCODE)); } return list; } public List GetPrintModelCopy(string formFlag) { //获取类别 //执行查询 List list = new List(); QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent(); list = agent.InvokeServiceFunction>(B9IPCService.PrintModelCopyBLL_GetPrintModelCopyList.ToString(), formFlag); //是否带空项填充返回值 return list; } /// /// 读取物料类别下拉列表 /// /// public List GetMaterialTypeList(string ordertype, bool isWithEmpty) { //执行查询 List list = new List(); WorkCell info = new WorkCell(); info.WORKCELL_CODE = ordertype; QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent(); list = agent.InvokeServiceFunction>("MaterialBLL_GetMaterialClassWithType", new MaterialClass(), info); //是否带空项填充返回值 if (isWithEmpty) { list.Insert(0, new MaterialClass()); } return list; } /// /// 获取物料号下拉 /// /// public List GetmaterialCodeList(string materialType, bool isWithEmpty) { //获取类别 QMAPP.MD.Entity.Material searchModel = new QMAPP.MD.Entity.Material(); searchModel.MATERIAL_TYPE_CODE = materialType; //执行查询 List list = new List(); QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent(); list = agent.InvokeServiceFunction>("MaterialBLL_GetAllList", searchModel); //是否带空项填充返回值 if (isWithEmpty) { list.Insert(0, new QMAPP.MD.Entity.Material()); } return list; } /// /// 批量报废读取物料类别下拉列表 /// /// public List GetMaterialClassToMendRecorderWasteForm(bool isWithEmpty) { //执行查询 List list = new List(); QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent(); list = agent.InvokeServiceFunction>("MaterialBLL_GetMaterialClassToMendRecorderWasteForm"); //是否带空项填充返回值 if (isWithEmpty) { list.Insert(0, new MaterialClass()); } return list; } /// /// 获取工序下拉列表 /// /// public List GetWorkCellList(bool isWithEmpty) { //执行查询 List list = new List(); QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent(); list = agent.InvokeServiceFunction>("WorkCellBLL_GetAllList", new WorkCell()); list = list.OrderBy(p => p.WORKCELL_NAME).ToList(); //是否带空项填充返回值 if (isWithEmpty) { list.Insert(0, new WorkCell()); } return list; } /// /// 根据扫描条码获取之前工序下拉列表 /// 筛选工序 /// /// public List GetMainOperationWorkCell(string ProductCode) { //执行查询 List list = new List(); QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent(); list = agent.InvokeServiceFunction>("MainOperationBLL_GetMainOperationWorkCell", ProductCode, true); if (list.Count > 0) { foreach (MainOperation item in list) { item.WORKCELL_NAME = item.WORKCELL_NAME + ":" + item.PRODUCTCODE; } list.Insert(0, new MainOperation()); } //为空就是注塑件 else { list = agent.InvokeServiceFunction>("MainOperationBLL_GetMainOperationWorkCell", ProductCode, false); foreach (MainOperation item in list) { item.WORKCELL_NAME = "注塑机"; item.WORKCELL_CODE = "INJECTION"; } } return list; } /// /// 获取出库原因 /// /// /// public List GetOutReasonList(bool isWithEmpty) { //执行查询 List list = new List(); QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent(); list = agent.InvokeServiceFunction>("ProductOutBLL_GetOutReasonList", new OutReason()); //是否带空项填充返回值 if (isWithEmpty) { list.Insert(0, new OutReason()); } return list; } /// /// 获取输入值 /// /// /// public List GetInputValueList(string checkcode, bool isWithEmpty) { InputValue searchModel = new InputValue(); searchModel.CHECKITEMCODE = checkcode; //执行查询 List list = new List(); QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent(); list = agent.InvokeServiceFunction>("ProductCheckBLL_GetInputValueList", searchModel); //是否带空项填充返回值 if (isWithEmpty) { list.Insert(0, new InputValue { INPUTVALUE = string.Empty }); } return list; } /// /// 获取呼叫类型 /// /// public List GetConfigDetailComboxSource(string MainTypeCode, bool isWithEmpty) { //执行查询 List list = new List(); //List list = new List(); QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent(); list = agent.InvokeServiceFunction>("ConfigDetailBLL_GetAllList", MainTypeCode); //是否带空项填充返回值 if (isWithEmpty) { list.Insert(0, new ConfigDetail { DetailTypeName = string.Empty, DetailTypeCode = string.Empty }); } //foreach (ConfigDetail item in list) //{ // item.DetailTypeName = item.DetailTypeCode + "/" + item.DetailTypeName; //} return list; } //自定义ComboBox下拉内容的宽度 public void AdjustComboBoxDropDownListWidth(object comboBox) { Graphics g = null; Font font = null; try { ComboBox senderComboBox = null; if (comboBox is ComboBox) senderComboBox = (ComboBox)comboBox; else if (comboBox is ToolStripComboBox) senderComboBox = ((ToolStripComboBox)comboBox).ComboBox; else return; int width = senderComboBox.Width; g = senderComboBox.CreateGraphics(); font = senderComboBox.Font; //checks if a scrollbar will be displayed. //If yes, then get its width to adjust the size of the drop down list. int vertScrollBarWidth = (senderComboBox.Items.Count > senderComboBox.MaxDropDownItems) ? SystemInformation.VerticalScrollBarWidth : 0; int newWidth; foreach (object s in senderComboBox.Items) //Loop through list items and check size of each items. { if (s != null) { newWidth = (int)g.MeasureString(s.ToString().Trim(), font).Width + vertScrollBarWidth; if (width < newWidth) width = newWidth; //set the width of the drop down list to the width of the largest item. } } senderComboBox.DropDownWidth = width; } catch { } finally { if (g != null) g.Dispose(); } } #region 获取全部工作中心下拉列表 /// /// 获取工作中心下拉列表 /// /// 数据源 public List GetAllWorkCenterComboxSource() { var workCenter = new WorkCenter(); QMAPP.ServicesAgent.ServiceAgent wcfAgent = ClientContext.GetServiceAgent(); //ServiceAgent wcfAgent = this.GetServiceAgent(); try { var dataResult = wcfAgent.InvokeServiceFunction>> ("WorkCenterBLL_GetWorkCenterList", workCenter); return dataResult.Result; } catch (Exception ex) { throw ex; } } public List GetFactoryWorkCenterComboxSource(string factoryCode) { ServiceAgent wcfAgent = ClientContext.GetServiceAgent(); try { var dataResult = wcfAgent.InvokeServiceFunction>> ("WorkCenterBLL_GetWorkCenterList", new WorkCenter { FACTORY_CODE = factoryCode }); return dataResult.Result; } catch (Exception ex) { throw ex; } } #endregion #region 获取工位下拉列表(联动) /// /// 获取工序下拉列表 /// /// 数据源 public List GetWorkLocComboxSource(string workCenterCode) { List list = new List(); ServiceAgent wcfAgent = ClientContext.GetServiceAgent(); try { if (string.IsNullOrEmpty(workCenterCode) == false) { list = wcfAgent.InvokeServiceFunction> ("WorkLocBLL_GetWorkLocFromWorkCenterCodeList", workCenterCode); //foreach (WorkLoc item in dataResult) //{ // item.WORKLOC_NAME = item.WORKLOC_NAME; // list.Add(item); //} } return list; } catch (Exception ex) { throw ex; } } #endregion #region 获取原材料信息,根据T_PP_ORDERENTITY MATERIALTYPE 过滤 /// /// 获取原材料信息,根据T_PP_ORDERENTITY MATERIALTYPE 过滤 /// /// public List GetMaterialInfoByType(string OrderType, bool isWithEmpty) { QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent(); OrderIndentity OrderSearch = new OrderIndentity(); if (!string.IsNullOrEmpty(OrderType)) { OrderSearch.ORDER_TYPE = OrderType; OrderSearch = agent.InvokeServiceFunction("MaterialBLL_GetOrderInfo", OrderSearch); } //获取类别 QMAPP.MD.Entity.Material searchModel = new QMAPP.MD.Entity.Material(); if (!string.IsNullOrEmpty(OrderSearch.MATERIALTYPE)) { string str = string.Join(",", OrderSearch.MATERIALTYPE); searchModel.MATERIALTYPES = "'" + str.Replace(",", "','") + "'"; } //执行查询 List list = new List(); list = agent.InvokeServiceFunction>("MaterialBLL_GetAllList", searchModel); //是否带空项填充返回值 if (isWithEmpty) { list.Insert(0, new QMAPP.MD.Entity.Material()); } return list; } #endregion /// /// 获取物料信息 /// /// /// /// public List GetMaterialInfoList(string materialCode, bool isWithEmpty) { QMAPP.MD.Entity.Material searchModel = new QMAPP.MD.Entity.Material(); searchModel.MATERIAL_CODE = materialCode; //执行查询 List list = new List(); QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent(); list = agent.InvokeServiceFunction>("MaterialBLL_GetMaterialInfoListBy", searchModel); //是否带空项填充返回值 if (list.Count > 0) { foreach (QMAPP.MD.Entity.Material item in list) { item.MATERIAL_NAME = item.MATERIAL_NAME + ":" + item.MATERIAL_CODE; } } if (isWithEmpty) { list.Insert(0, new QMAPP.MD.Entity.Material { MATERIAL_NAME = "", MATERIAL_CODE = "" }); } return list; } /// /// /// /// /// /// public QMAPP.MD.Entity.Material GetMaterialInfo(string materialCode) { QMAPP.MD.Entity.Material searchModel = new QMAPP.MD.Entity.Material(); searchModel.MATERIAL_CODE = materialCode; //执行查询 QMAPP.MD.Entity.Material MaterialInfo = new QMAPP.MD.Entity.Material(); QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent(); MaterialInfo = agent.InvokeServiceFunction("MaterialBLL_GetMaterialInfo", searchModel); return MaterialInfo; } } }