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
#region
 
using System;
using System.Data;
using System.Drawing.Imaging;
using CSFrameworkV5.Business;
using CSFrameworkV5.Common;
using CSFrameworkV5.Core;
using CSFrameworkV5.Library;
using CSFrameworkV5.Library.CommonClass;
 
#endregion
 
namespace CSFrameworkV5.SystemModule
{
    /// <summary>
    ///     公司资料设置
    /// </summary>
    public partial class frmCompanyInfo : frmBaseDataDictionary
    {
        public frmCompanyInfo()
        {
            InitializeComponent();
        }
 
        private void BindingSummaryEditor(DataTable summary)
        {
            DoBindingEditorPanel(gcDetailEditor, summary);
        }
 
        protected override void ButtonStateChanged(UpdateType currentState)
        {
            var accessable = currentState == UpdateType.Add ||
                             currentState == UpdateType.Modify;
            base.SetDetailEditorsAccessable(gcDetailEditor, accessable);
            base.ButtonStateChanged(currentState);
 
            //禁用数据操作按钮
            _buttons.GetButtonByName("btnView").Enable = false;
            _buttons.GetButtonByName("btnAdd").Enable = false;
            _buttons.GetButtonByName("btnDelete").Enable = false;
            _buttons.GetButtonByName("btnPrint").Enable = false;
            _buttons.GetButtonByName("btnPreview").Enable = false;
            _buttons.GetButtonByName("btnRefreshDataDict").Enable = false;
        }
 
        public override void DoCancel(IButtonInfo sender)
        {
            if (!Msg.AskQuestion("要取消修改吗?")) return;
 
            _BLL.GetSummaryData(true); //获取数据
            BindingSummaryEditor(_BLL.SummaryTable); //绑定输入控件
 
            _UpdateType = UpdateType.None;
            SetViewMode();
            ButtonStateChanged(_UpdateType);
        }
 
        public override void DoEdit(IButtonInfo sender)
        {
            _UpdateType = UpdateType.Modify;
            SetEditMode();
            ButtonStateChanged(_UpdateType);
        }
 
        public override void DoSave(IButtonInfo sender)
        {
            UpdateLastControl();
 
            if (txtCompanyCode.Text == "")
            {
                Msg.Warning("公司编号不能为空!");
                txtCompanyCode.Focus();
                return;
            }
 
            if (txtNativeName.Text == "")
            {
                Msg.Warning("公司中文名称不能为空!");
                txtNativeName.Focus();
                return;
            }
 
            if (txtLogo.Image != null && txtLogo.Image.Width > 250)
            {
                var img = CImageLibrary.ResizeImage(txtLogo.Image, 250, 110);
                txtLogo.Image = img;
                var bs =
                    CImageLibrary.GetImageBytes(img, ImageFormat.Png); //PNG格式清晰
                SetEditorBindingValue(txtLogo, bs, true);
            }
 
            if (_BLL.Update())
            {
                _UpdateType = UpdateType.None;
                SetViewMode();
                ButtonStateChanged(_UpdateType);
                Msg.ShowInformation("保存成功!");
            }
            else
            {
                Msg.ShowInformation("保存失败!");
            }
        }
 
        private void frmCompanyInfo_Load(object sender, EventArgs e)
        {
            _BLL = new bllCompanyInfo(); //业务逻辑层
            _BLL.GetSummaryData(true); //获取数据
            _DetailGroupControl = gcDetailEditor;
            _SummaryView = new DevGridView(gvSummary);
 
            InitializeForm();
            BindingSummaryEditor(_BLL.SummaryTable); //绑定输入控件
            ButtonStateChanged(UpdateType.None);
            ShowDetailPage(true);
            tpSummary.Hide();
        }
 
        public override void SetParameter(object param)
        {
            //if (param != null)
            //    Msg.ShowInformation(param.ToStringEx());
        }
    }
}