lu
2024-10-22 029703212622519325f9cb5129a5e9ced98bdfad
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
using DevExpress.Office.Model;
using DevExpress.XtraEditors;
using DevExpress.XtraLayout.Customization;
using Gs.DevApp.Entity;
using Gs.DevApp.ToolBox;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Data;
using System.Windows.Controls;
 
namespace Gs.DevApp.UserControl
{
    public partial class ShowRptWizard : DevExpress.XtraEditors.XtraForm
    {
 
        private string _reportType;
        public ShowRptWizard(string reportType)
        {
            _reportType = reportType;
            InitializeComponent();
            wizardControl1.NextClick += WizardControl1_NextClick;
            wizardControl1.FinishClick += WizardControl1_FinishClick;
        }
 
        private void WizardControl1_FinishClick(object sender, System.ComponentModel.CancelEventArgs e)
        {
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            foreach (DevExpress.XtraEditors.GroupControl ctrl in this.wizardPage2.Controls)
            {
                if (ctrl is GroupControl)
                {
                    GroupControl _grpBox = ctrl as GroupControl;
                    foreach (DevExpress.XtraEditors.CheckedListBoxControl _ckBox in _grpBox.Controls)
                    {
                        CheckedListBoxControl _kk = _ckBox as CheckedListBoxControl;
                        for (int i = 0; i < _ckBox.ItemCount; i++)
                        {
                            if (_ckBox.GetItemChecked(i))
                            {
                                if (sb.Length > 0)
                                    sb.Append(",");
                                sb.Append(_ckBox.GetItemValue(i).ToString());
                            }
                        }
                    }
                }
            }
            var _obj = new
            {
                rptType = _reportType,
                colDec = sb.ToString(),
            };
            try
            {
                string strJson = UtilityHelper.HttpPost("", "Report/EdtTemplate", JsonConvert.SerializeObject(_obj));
                ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson);
                if (_rtn.rtnCode > 0)
                {
                    Gs.DevApp.DevFrm.Sys.EasyRptDesign frm = new Gs.DevApp.DevFrm.Sys.EasyRptDesign(this._reportType);
                    frm.Show();
                }
            }
            catch (Exception ex)
            {
                ToolBox.MsgHelper.Warning("提示:" + ex.Message);
            }
        }
 
        private void WizardControl1_NextClick(object sender, DevExpress.XtraWizard.WizardCommandButtonClickEventArgs e)
        {
            if (this.wizardControl1.SelectedPage == this.welcomeWizardPage1)
            {
                _getTable();
                return;
            }
            if (this.wizardControl1.SelectedPage == this.wizardPage1)
            {
                _getZiDuan();
                return;
            }
        }
 
        private void _getTable()
        {
            chkTable.Items.Clear();
            var _obj = new
            {
            };
            string strReturn = "";
            try
            {
                strReturn = UtilityHelper.HttpPost("", "Report/GetTableList", JsonConvert.SerializeObject(_obj));
                ReturnModel<DataTable> dd = UtilityHelper.ReturnToList(strReturn);
                DataTable dt = dd.rtnData;
                chkTable.DisplayMember = "tableDesc";
                chkTable.ValueMember = "tableName";
                chkTable.DataSource = dt;
            }
            catch (Exception ex)
            {
                ToolBox.MsgHelper.Warning("提示:" + ex.Message);
            }
        }
        private void _getZiDuan()
        {
            this.wizardPage2.Controls.Clear();
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            for (int i = 0; i < chkTable.ItemCount; i++)
            {
                if (chkTable.GetItemChecked(i))
                {
                    if (sb.Length > 0)
                        sb.Append(",");
                    sb.Append(chkTable.GetItemValue(i).ToString());
                }
            }
            var _obj = new
            {
                tablesName = sb.ToString(),
            };
            try
            {
                string strReturn = UtilityHelper.HttpPost("", "Report/GetZiDuanList", JsonConvert.SerializeObject(_obj));
                JObject _job = JObject.Parse(strReturn);
                string rtnCode = _job["rtnCode"].ToString();
                if (int.Parse(rtnCode) > 0)
                {
                    var _table = _job["rtnData"];
                    foreach (var _col in _table)
                    {
                        DevExpress.XtraEditors.GroupControl grp = new DevExpress.XtraEditors.GroupControl();
                        grp.Size = new System.Drawing.Size(259, 420);
                        grp.Text = _col["tableName"].ToString();
                        grp.Dock = System.Windows.Forms.DockStyle.Left;
                        // grp.TabIndex = 0;
                        DevExpress.XtraEditors.CheckedListBoxControl chkZiDuan = new DevExpress.XtraEditors.CheckedListBoxControl();
                        chkZiDuan.CheckOnClick = true;
                        chkZiDuan.Dock = System.Windows.Forms.DockStyle.Fill;
                        var _tbCol = _col["colList"];
                        foreach (var _ccccc in _tbCol)
                        {
                            string _t = _ccccc["ziDuanName"].ToString();
                            chkZiDuan.Items.Add(_t);
                        }
                        grp.Controls.Add(chkZiDuan);
                        this.wizardPage2.Controls.Add(grp);
                    }
                }
            }
            catch (Exception ex)
            {
                ToolBox.MsgHelper.Warning("提示:" + ex.Message);
            }
        }
    }
}