1
yhj
2024-07-24 5e5d945e91568b973faa27d8ab0bcef99fc4a6c5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
#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);
            }
        }
 
        /// <summary>
        ///     保存数据
        /// </summary>
        /// <param name="sender"></param>
        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);
        }
    }
}