You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
354 lines
14 KiB
C#
354 lines
14 KiB
C#
using DevExpress.XtraEditors;
|
|
using SqlSugar;
|
|
using System.Collections.Generic;
|
|
using System.Web.UI.WebControls;
|
|
using ZJ_BYD.DB;
|
|
|
|
namespace ZJ_BYD.Common
|
|
{
|
|
public class BindCombox
|
|
{
|
|
/// <summary>
|
|
/// 绑定数据类型
|
|
/// </summary>
|
|
/// <param name="comboBoxEdit"></param>
|
|
public static void BindDataType(ComboBoxEdit comboBoxEdit)
|
|
{
|
|
comboBoxEdit.Properties.Items.Add(new ListItem { Text = "bool", Value = "bool" });
|
|
comboBoxEdit.Properties.Items.Add(new ListItem { Text = "short", Value = "short" });
|
|
comboBoxEdit.Properties.Items.Add(new ListItem { Text = "ushort", Value = "ushort" });
|
|
comboBoxEdit.Properties.Items.Add(new ListItem { Text = "int", Value = "int" });
|
|
comboBoxEdit.Properties.Items.Add(new ListItem { Text = "float", Value = "float" });
|
|
comboBoxEdit.Properties.Items.Add(new ListItem { Text = "double", Value = "double" });
|
|
comboBoxEdit.Properties.Items.Add(new ListItem { Text = "string", Value = "string" });
|
|
}
|
|
|
|
/// <summary>
|
|
/// 绑定机型下拉框
|
|
/// </summary>
|
|
/// <param name="cmbMachineType"></param>
|
|
public static void BindMachineType(ComboBoxEdit cmbMachineType)
|
|
{
|
|
var machineTypes = MskCodeHelper.QueryMskCodes()
|
|
.Select(m => new ListItem
|
|
{
|
|
Value = m.ProductSfcCode,
|
|
Text = m.ProductSfcCode
|
|
}).Distinct().ToList();
|
|
foreach (var item in machineTypes)
|
|
{
|
|
cmbMachineType.Properties.Items.Add(item);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 绑定机型下拉框
|
|
/// </summary>
|
|
/// <param name="cmbMachineType"></param>
|
|
public static void BindMachineTypeForAhead(ComboBoxEdit cmbMachineType)
|
|
{
|
|
var machineTypes = MskCodeHelper.QueryMskCodes()
|
|
.Select(m => new ListItem
|
|
{
|
|
Value = SqlFunc.MergeString(m.Category, "_", m.ProductSfcCode),
|
|
Text = m.ProductSfcCode
|
|
}).Distinct().ToList();
|
|
foreach (var item in machineTypes)
|
|
{
|
|
cmbMachineType.Properties.Items.Add(item);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 绑定机型下拉框
|
|
/// </summary>
|
|
/// <param name="cmbMachineType"></param>
|
|
public static void MainBindMachineType(LookUpEdit control)
|
|
{
|
|
var list = MskCodeHelper.QueryMskCodes()
|
|
.Select(m => new ListItem
|
|
{
|
|
Value = m.SortIndex.ToString(),
|
|
Text = m.Category
|
|
}).Distinct().ToList();
|
|
control.Properties.ValueMember = "Value";
|
|
control.Properties.DisplayMember = "Text";
|
|
control.Properties.DataSource = list;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 手动打印时绑定机型
|
|
/// </summary>
|
|
/// <param name="control"></param>
|
|
public static void BindMachieTypeForLookUp(LookUpEdit control)
|
|
{
|
|
var list = MskCodeHelper.QueryMskCodes()
|
|
.Select(m => new ListItem
|
|
{
|
|
Value = m.BarCodeChar,
|
|
Text = m.ProductSfcCode.Trim('*')
|
|
}).ToList();
|
|
control.Properties.ValueMember = "Value";
|
|
control.Properties.DisplayMember = "Text";
|
|
control.Properties.DataSource = list;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 绑定机型-主界面
|
|
/// </summary>
|
|
/// <param name="control"></param>
|
|
public static void BindMachieTypeMainForLookUp(LookUpEdit control)
|
|
{
|
|
var list = MskCodeHelper.QueryMskCodes()
|
|
.Select(m => new ListItem
|
|
{
|
|
Value = m.Category,
|
|
Text = m.Category
|
|
}).ToList();
|
|
control.Properties.ValueMember = "Value";
|
|
control.Properties.DisplayMember = "Text";
|
|
control.Properties.DataSource = list;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 绑定使用状态
|
|
/// </summary>
|
|
/// <param name="control"></param>
|
|
public static void BindUseStatusForLookUp(LookUpEdit control)
|
|
{
|
|
var list = new List<ListItem>();
|
|
list.Add(new ListItem() { Value = "false", Text = "未使用" });
|
|
list.Add(new ListItem() { Value = "true", Text = "使用中" });
|
|
control.Properties.ValueMember = "Value";
|
|
control.Properties.DisplayMember = "Text";
|
|
control.Properties.DataSource = list;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据路线绑定工位下拉框
|
|
/// </summary>
|
|
/// <param name="cmbStation"></param>
|
|
/// <param name="category"></param>
|
|
public static void BindStationByCategory(ComboBoxEdit cmbStation, string category)
|
|
{
|
|
var defaultItem = new ListItem
|
|
{
|
|
Value = "",
|
|
Text = "--请选择--",
|
|
};
|
|
var stations = StationHelper.QueryActiveStations()
|
|
.WhereIF(!string.IsNullOrWhiteSpace(category), m => m.Category == category)
|
|
.OrderBy(m => m.Category).OrderBy(m => m.SortIndex)
|
|
.Select(m => new ListItem
|
|
{
|
|
Value = m.StationCode,
|
|
Text = SqlFunc.MergeString(m.Category, "_", m.StationName, "(", m.StationCode, ")")
|
|
}).ToList();
|
|
stations.Insert(0, defaultItem);
|
|
foreach (var item in stations)
|
|
{
|
|
cmbStation.Properties.Items.Add(item);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 绑定工位下拉框
|
|
/// </summary>
|
|
/// <param name="cmbStation"></param>
|
|
public static void BindStation(ComboBoxEdit cmbStation)
|
|
{
|
|
var defaultItem = new ListItem
|
|
{
|
|
Value = "",
|
|
Text = "--请选择--",
|
|
};
|
|
var stations = StationHelper.QueryActiveStations()
|
|
.OrderBy(m => m.Category).OrderBy(m => m.SortIndex)
|
|
.Select(m => new ListItem
|
|
{
|
|
Value = m.StationCode,
|
|
Text = SqlFunc.MergeString(m.Category, "-", m.StationName)
|
|
}).ToList();
|
|
stations.Insert(0, defaultItem);
|
|
foreach (var item in stations)
|
|
{
|
|
cmbStation.Properties.Items.Add(item);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 绑定工位
|
|
/// </summary>
|
|
/// <param name="control"></param>
|
|
/// <param name="defaultVal"></param>
|
|
public static void BindStationForLookUp(LookUpEdit control, string defaultVal = "")
|
|
{
|
|
var list = new List<ListItem>();
|
|
var defaultItem = new ListItem
|
|
{
|
|
Value = "",
|
|
Text = "--请选择--",
|
|
};
|
|
list.Add(defaultItem);
|
|
list = StationHelper.QueryActiveStations()
|
|
.OrderBy(m => m.Category).OrderBy(m => m.SortIndex)
|
|
.Select(m => new ListItem
|
|
{
|
|
Value = m.StationCode,
|
|
Text = SqlFunc.MergeString(m.Category, "-", m.StationName)
|
|
}).ToList();
|
|
if (!string.IsNullOrWhiteSpace(defaultVal))
|
|
{
|
|
control.EditValue = defaultVal;
|
|
}
|
|
control.Properties.ValueMember = "Value";
|
|
control.Properties.DisplayMember = "Text";
|
|
control.Properties.DataSource = list;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 通过机型绑定工位下拉框
|
|
/// </summary>
|
|
/// <param name="comboBoxEdit"></param>
|
|
/// <param name="machineTypeCode"></param>
|
|
public static void BindStationByMachineType(ComboBoxEdit comboBoxEdit, string machineTypeCode)
|
|
{
|
|
var list = MskCodeHelper.QueryMaChineTypeStationVM(machineTypeCode).ToList();
|
|
if (list.Count > 0)
|
|
{
|
|
foreach (var item in list)
|
|
{
|
|
var listItem = new ListItem
|
|
{
|
|
Value = item.StationCode,
|
|
Text = $"{item.Category}-{item.StationName}({item.StationCode})"
|
|
};
|
|
comboBoxEdit.Properties.Items.Add(listItem);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 绑定系统模式下拉框
|
|
/// </summary>
|
|
/// <param name="comboBoxEdit"></param>
|
|
public static void BindSystemMode(ComboBoxEdit comboBoxEdit)
|
|
{
|
|
comboBoxEdit.Properties.Items.Add(new ListItem { Text = "MES在线模式", Value = "1" });
|
|
comboBoxEdit.Properties.Items.Add(new ListItem { Text = "MES离线模式", Value = "0" });
|
|
}
|
|
|
|
/// <summary>
|
|
/// 绑定是否下拉框
|
|
/// </summary>
|
|
/// <param name="comboBoxEdit"></param>
|
|
public static void BindIsOk(ComboBoxEdit comboBoxEdit)
|
|
{
|
|
comboBoxEdit.Properties.Items.Add(new ListItem { Text = "是", Value = "1" });
|
|
comboBoxEdit.Properties.Items.Add(new ListItem { Text = "否", Value = "0" });
|
|
}
|
|
|
|
/// <summary>
|
|
/// 绑定字段
|
|
/// </summary>
|
|
/// <param name="comboBoxEdit"></param>
|
|
/// <param name="stationCode"></param>
|
|
public static void BindResultColumn(ComboBoxEdit comboBoxEdit, string stationCode)
|
|
{
|
|
comboBoxEdit.Properties.Items.Clear();
|
|
var usedCols = PlcPointHelper.GetUsedCol(stationCode);
|
|
for (int i = 1; i < 51; i++)
|
|
{
|
|
var val = string.Format("Column{0}", i);
|
|
if (usedCols.Count > 0)
|
|
{
|
|
if (!usedCols.Contains(val))
|
|
{
|
|
comboBoxEdit.Properties.Items.Add(new ListItem { Text = val, Value = val });
|
|
}
|
|
}
|
|
else
|
|
{
|
|
comboBoxEdit.Properties.Items.Add(new ListItem { Text = val, Value = val });
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 绑定地域
|
|
/// </summary>
|
|
/// <param name="control"></param>
|
|
public static void BindAreaForLookUp(LookUpEdit control)
|
|
{
|
|
var list = new List<ListItem>();
|
|
var defaultItem = new ListItem
|
|
{
|
|
Value = "",
|
|
Text = "--请选择--",
|
|
};
|
|
list = AreaHelper.QueryAreas()
|
|
.Select(m => new ListItem
|
|
{
|
|
Value = m.AreaCode,
|
|
Text = m.AreaName,
|
|
Selected = m.DefaultSelected
|
|
}).ToList();
|
|
list.Insert(0, defaultItem);
|
|
control.Properties.ValueMember = "Value";
|
|
control.Properties.DisplayMember = "Text";
|
|
control.Properties.DataSource = list;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 绑定线路
|
|
/// </summary>
|
|
/// <param name="control"></param>
|
|
public static void BindCategoryForLookUp(LookUpEdit control)
|
|
{
|
|
var list = new List<ListItem>();
|
|
var defaultItem = new ListItem
|
|
{
|
|
Value = "",
|
|
Text = "--请选择--",
|
|
};
|
|
|
|
list = MskCodeHelper.QueryMskCodes()
|
|
.Select(m => new ListItem
|
|
{
|
|
Value = m.Category,
|
|
Text = m.Category,
|
|
Selected = m.IsUsed
|
|
}).Distinct().ToList();
|
|
list.Insert(0, defaultItem);
|
|
control.Properties.DataSource = list;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 绑定工厂
|
|
/// </summary>
|
|
/// <param name="control"></param>
|
|
/// <param name="areaCode"></param>
|
|
public static void BindDeptForLookUp(LookUpEdit control, string areaCode)
|
|
{
|
|
var list = new List<ListItem>();
|
|
var defaultItem = new ListItem
|
|
{
|
|
Value = "",
|
|
Text = "--请选择--",
|
|
};
|
|
|
|
list = DeptHelper.QueryDeptsByAreaCode(areaCode)
|
|
.Select(m => new ListItem
|
|
{
|
|
Value = m.DeptCode,
|
|
Text = m.DeptName,
|
|
Selected = m.DefaultSelected
|
|
}).ToList();
|
|
list.Insert(0, defaultItem);
|
|
control.Properties.ValueMember = "Value";
|
|
control.Properties.DisplayMember = "Text";
|
|
control.Properties.DataSource = list;
|
|
}
|
|
}
|
|
}
|