#region using System; using System.Data; using System.Drawing; using CSFrameworkV5.Business; using CSFrameworkV5.Common; using CSFrameworkV5.Core; using CSFrameworkV5.Language; using CSFrameworkV5.Library; using CSFrameworkV5.Library.CommonClass; using CSFrameworkV5.Library.UserControls; using CSFrameworkV5.Models; using DevExpress.XtraEditors.Controls; using DevExpress.XtraGrid.Views.Base; #endregion namespace CSFrameworkV5.SystemModule { public partial class frmSystemSettings : frmBaseDataForm { private DataRow _R; private ucPopupList _ucPopupList; public frmSystemSettings() { InitializeComponent(); _ucPopupList = new ucPopupList(); } private void btnEmpty_Click(object sender, EventArgs e) { ClearContainerEditorText(pnlSearch); } private void btnQuery_Click(object sender, EventArgs e) { DoRefreshData(null); } public override void DoDelete(IButtonInfo sender) { Msg.ShowError("系统参数不允许删除!"); return; var paramName = gvSummary.GetFocusedRowCellDisplayText(colParamName); if (Msg.AskQuestion("确定要删除此参数 [" + paramName + "] 吗?")) { gvSummary.DeleteRow(gvSummary.FocusedRowHandle); DoSave(null); } } public virtual void DoRefreshData(IButtonInfo sender) { try { frmWaitingEx.ShowMe(this); var dt = CommonData.GetSystemSettingsEx(txt_ParamName.Text, txt_ParamType.Text); gcSummary.DataSource = dt; } finally { frmWaitingEx.HideMe(this); } } /// /// 保存数据 /// /// public override void DoSave(IButtonInfo sender) { UpdateLastControl(); if (gcSummary.DataSource == null) return; var dt = gcSummary.DataSource as DataTable; dt = dt.GetChanges(); if (dt != null) { var bll = new bllBaseDataDict(); bll.DataDictBridge = BridgeFactory.CreateDataDictBridge( typeof(sys_SystemSettings)); var ok = bll.Update(dt); if (ok) { //重新加载系统参数类 var data = CommonData.GetSystemSettings4Program( Loginer.CurrentUser.DBID, Loginer.CurrentUser.Account); //系统配置 SystemSettings.Current.Load(data); //提交缓存 (gcSummary.DataSource as DataTable).AcceptChanges(); Msg.ShowInformation("保存成功!请重新打开数据窗体参数才能生效。"); } else { Msg.Warning("保存发生错误!"); } } else { Msg.Warning("没有修改数据,不需要保存!"); } } private void frmSystemSettings_Load(object sender, EventArgs e) { InitButtons(); rep_List.PopupFormSize = new Size(120, 80); _ucPopupList.OnItemClick += ucPopupList1_OnItemClick; DoRefreshData(null); DataBinderTools.BoundCheckEdit(repM_Check); } private void gvSummary_FocusedColumnChanged(object sender, FocusedColumnChangedEventArgs e) { LoadPopupControl(); } private void gvSummary_FocusedRowChanged(object sender, FocusedRowChangedEventArgs e) { LoadPopupControl(); } public override void InitButtons() { var btnClose = ToolbarRegister.CreateButton("btnClose", LanLib.Get("关闭"), ToolBarGroup.关闭窗体, Globals.LoadBitmap("32_Exit.png"), new Size(57, 28), false, true, DoClose); _buttons.AddButton(btnClose); var btnRefresh = ToolbarRegister.CreateButton("btnRefreshDataDict", LanLib.Get("刷新数据"), ToolBarGroup.数据操作, Globals.LoadBitmap("32_Refresh.png"), new Size(57, 28), true, true, DoRefreshData); _buttons.AddButton(btnRefresh); if (ButtonAuthorized(ButtonAuthority.DELETE)) { var btnDelete = ToolbarRegister.CreateButton("btnDelete", LanLib.Get("删除"), ToolBarGroup.数据操作, Globals.LoadBitmap("32_Del.png"), new Size(57, 28), false, true, DoDelete); Buttons.AddButton(btnDelete); } if (ButtonAuthorized(ButtonAuthority.EDIT)) { var btnSave = ToolbarRegister.CreateButton("btnSave", LanLib.Get("保存"), ToolBarGroup.数据操作, Globals.LoadBitmap("32_Save.png"), new Size(57, 28), false, true, DoSave); Buttons.AddButton(btnSave); } } private void LoadPopupControl() { _R = gvSummary.GetFocusedDataRow(); if (_R != null) { var list = ConvertEx.ToString(_R[sys_SystemSettings.ParamList]); var items = list.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries); if (items.Length > 0) { rep_List.TextEditStyle = TextEditStyles.DisableTextEditor; rep_List.PopupControl = _ucPopupList.PopupContainer; _ucPopupList.InitDataSource(items); } else { rep_List.TextEditStyle = TextEditStyles.Standard; rep_List.PopupControl = null; _ucPopupList.InitDataSource(new string[] { }); } } } private void menuCopy_Click(object sender, EventArgs e) { } private void menuSave_Click(object sender, EventArgs e) { DoSave(null); } private void ucPopupList1_OnItemClick(object item) { gvSummary.SetFocusedRowCellValue(sys_SystemSettings.ParamValue, item); } } }