点击事件触发此方法
private void selectCurryCode_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
{
判断所选是否为空
if (this.SelectBeneficiary == null)
return;
//获取待选择项
通过字典获取数据方法获取对应数据
var dictList = VineERP.Utils.CommonDictHelper.GetCommonDictList("Currency");
判断是否存在数据
if (dictList == null || dictList.Count == 0)
return;
构造弹框
frmSelectedDialog<sys_common_dict> dialog = new frmSelectedDialog<sys_common_dict>("Code,CodeName", "代码,币种", "50,80");
dialog.AllowMultiSelect = true; //设置多选
获取控件所分配的窗体
dialog.Parent = this.ParentForm;
//根据当前内容,设置已选项
if (!string.IsNullOrEmpty(this.SelectBeneficiary.CurrencyCode))
{
将已选择项进行拆分
var codeArr = this.SelectBeneficiary.CurrencyCode.Split(',').ToList();
dialog.SelectedEntities = new List<sys_common_dict>();
默认勾选已选
foreach (var code in codeArr)
{
var dict = dictList.Find(p => p.Code == code);
if (dict != null)
dialog.SelectedEntities.Add(dict);
}
}
//传递待选择项,并返回选择项并处理
dialog.ShowDialog(dictList, p =>
{
if (p.SelectedEntities == null || p.SelectedEntities.Count == 0)
return;
this.SelectBeneficiary.CurrencyCode = string.Empty;
显示所有数据
foreach (var dict in p.SelectedEntities)
{
this.SelectBeneficiary.CurrencyCode += string.Format("{0}{1}",
string.IsNullOrEmpty(this.SelectBeneficiary.CurrencyCode) ? "" : ",", dict.Code);
}
});
}
1 private void textBeneficiary_ItemChanged(object sender, EdwFramework.Controls.ChangedEventArgs e) 2 { 3 this.SelectBeneficiary.ChecklistInformation(); 4 } 5 6 /// <summary> 7 /// 弹出币种选择框 8 /// </summary> 9 /// <param name="sender"></param> 10 /// <param name="e"></param> 11 private void selectCurryCode_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) 12 { 13 if (this.SelectBeneficiary == null) 14 return; 15 16 //获取待选择项 17 var dictList = VineERP.Utils.CommonDictHelper.GetCommonDictList("Currency"); 18 if (dictList == null || dictList.Count == 0) 19 return; 20 21 frmSelectedDialog<sys_common_dict> dialog = new frmSelectedDialog<sys_common_dict>("Code,CodeName", "代码,币种", "50,80"); 22 dialog.AllowMultiSelect = true; //设置多选 23 dialog.Parent = this.ParentForm; 24 //根据当前内容,设置已选项 25 if (!string.IsNullOrEmpty(this.SelectBeneficiary.CurrencyCode)) 26 { 27 var codeArr = this.SelectBeneficiary.CurrencyCode.Split(',').ToList(); 28 dialog.SelectedEntities = new List<sys_common_dict>(); 29 foreach (var code in codeArr) 30 { 31 var dict = dictList.Find(p => p.Code == code); 32 if (dict != null) 33 dialog.SelectedEntities.Add(dict); 34 } 35 } 36 //传递待选择项,并返回选择项并处理 37 dialog.ShowDialog(dictList, p => 38 { 39 if (p.SelectedEntities == null || p.SelectedEntities.Count == 0) 40 return; 41 42 this.SelectBeneficiary.CurrencyCode = string.Empty; 43 foreach (var dict in p.SelectedEntities) 44 { 45 this.SelectBeneficiary.CurrencyCode += string.Format("{0}{1}", 46 string.IsNullOrEmpty(this.SelectBeneficiary.CurrencyCode) ? "" : ",", dict.Code); 47 } 48 49 }); 50 }
弹框例子
private void sel_CustomCodeList_Click(object sender, EventArgs e)
{
if (this.CurrCostParam == null || this.ViewState == ModelViewState.Normal)
return;
var RateService = EngineContext.Current.Resolve<IRepository<Customer>>();
string companyid = User.CompanyId;
var tempList = RateService.Search(p=>p.Companyid == companyid,false);
frmSelectedDialog<Customer> dialog = new frmSelectedDialog<Customer>("CustomCode,ShortName", "代码,名称", "100,120");
dialog.AllowMultiSelect = true;
dialog.Parent = this.ParentForm;
//根据当前内容,设置已选项
if(!string.IsNullOrEmpty(this.CurrCostParam.CustomCodeList))
{
var codeArr = this.CurrCostParam.CustomCodeList.Split(',').ToList();
dialog.SelectedEntities = new List<Customer>();
foreach(var code in codeArr)
{
var dict = tempList.Find(p => p.CustomCode == code);
if (dict != null)
dialog.SelectedEntities.Add(dict);
}
}
//传递带选项,并返回选择项并处理
dialog.ShowDialog(tempList,p=>
{
this.sel_CustomCodeList.Items.Clear();
this.CurrCostParam.CustomCodeList =string.Empty;
if (p.SelectedEntities == null || p.SelectedEntities.Count == 0)
return;
foreach(var dict in p.SelectedEntities)
{
this.sel_CustomCodeList.Items.Add(dict.CustomCode);
this.CurrCostParam.CustomCodeList +=string.Format("{0}{1}",
string.IsNullOrEmpty(this.CurrCostParam.CustomCodeList) ? "" : ",", dict.CustomCode);
}
});
}
排除已选过的客户
private List<Customer> custList = new List<Customer>();
/// <summary>
/// 客户代码选择事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void sel_CustomCodeList_Click(object sender, EventArgs e)
{
if (this.CurrCostParam == null || this.ViewState == ModelViewState.Normal)
return;
custList = VineERP.Utils.CustomerHelper.GetAllCustom(this.CurrCostParam.Companyid);
if (custList == null || custList.Count == 0)
{
MessageDxUtil.ShowError("客户信息不存在");
return;
}
#region 排除已设置客户
string sql = string.Format(@"select fdw.List(a.CustomCodeList)
from tblCostParam a
where a.CustomCodeList !='{0}' and a.Companyid='{1}'",
this.CurrCostParam.CustomCodeList, this.CurrCostParam.Companyid);
var useCusotm = EdwFramework.Core.SqlClientFactory.Instance.ExecuteScalar(sql);
if (!string.IsNullOrEmpty(useCusotm))
{
var useCustlist = useCusotm.Split(',').ToList();
foreach (var cust in useCustlist)
{
if (string.IsNullOrEmpty(cust))
continue;
custList.RemoveAll(p => p.CustomCode == cust);
}
}
if (custList == null || custList.Count == 0)
{
MessageDxUtil.ShowError("所有客户都已完成成本参数设定");
return;
}
#endregion
frmSelectedDialog<Customer> dialog = new frmSelectedDialog<Customer>("CustomCode,ShortName", "代码,名称", "100,120");
dialog.AllowMultiSelect = true;
dialog.Parent = this.ParentForm;
//根据当前内容,设置已选项
if(!string.IsNullOrEmpty(this.CurrCostParam.CustomCodeList))
{
var codeArr = this.CurrCostParam.CustomCodeList.Split(',').ToList();
dialog.SelectedEntities = new List<Customer>();
foreach(var code in codeArr)
{
var dict = custList.Find(p => p.CustomCode == code);
if (dict != null)
dialog.SelectedEntities.Add(dict);
}
}
//传递带选项,并返回选择项并处理
dialog.ShowDialog(custList, p =>
{
this.sel_CustomCodeList.Items.Clear();
this.CurrCostParam.CustomCodeList =string.Empty;
if (p.SelectedEntities == null || p.SelectedEntities.Count == 0)
return;
foreach(var dict in p.SelectedEntities)
{
this.sel_CustomCodeList.Items.Add(dict.CustomCode);
this.CurrCostParam.CustomCodeList +=string.Format("{0}{1}",
string.IsNullOrEmpty(this.CurrCostParam.CustomCodeList) ? "" : ",", dict.CustomCode);
}
});
}