lu
2025-04-14 ecb7a60de1639f520712ce95f99414b0dd2c9713
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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
using Gs.DevApp.Entity;
using Gs.DevApp.ToolBox;
using Newtonsoft.Json;
using System;
using System.Data;
 
namespace Gs.DevApp.UserControl
{
    public partial class UcLookHuoZhu : DevExpress.XtraEditors.XtraUserControl
    {
 
        /// <summary>
        ///    
        /// </summary>
        public string OrgId
        {
            get;
            set;
        }
        public string HzId
        {
            get;
            set;
        }
        public bool IsReadly { set; get; }
 
        public UcLookHuoZhu()
        {
            InitializeComponent();
            txt_hzabc.Properties.NullText = "请选择货主";
            txt_hzlxabc.Properties.NullText = "请选择货主类型";
            this.txt_hzlxabc.SelectedIndexChanged += (s, e) =>
            {
                txt_hzabc.EditValue = null;
                int _strType = txt_hzlxabc.SelectedIndex;
                string _orgId = OrgId;
                this.searchLookUpEdit1View.Columns.Clear();
                txt_hzabc.Properties.DataSource = null;
                if (_strType <= 0) return;
                string _strMeth = "";
                string _DisplayMember = "";
                string _ValueMember = "";
                PageQueryModel pgq = new PageQueryModel(1, 999999, "", "", "", "");
                DevExpress.XtraGrid.Columns.GridColumn gridColumn5 = new DevExpress.XtraGrid.Columns.GridColumn();
                DevExpress.XtraGrid.Columns.GridColumn gridColumn1 = new DevExpress.XtraGrid.Columns.GridColumn();
                DevExpress.XtraGrid.Columns.GridColumn gridColumn2 = new DevExpress.XtraGrid.Columns.GridColumn();
                DevExpress.XtraGrid.Columns.GridColumn gridColumn4 = new DevExpress.XtraGrid.Columns.GridColumn();
                DevExpress.XtraGrid.Columns.GridColumn gridColumn3 = new DevExpress.XtraGrid.Columns.GridColumn();
                switch (_strType)
                {
                    case 1://组织
                        pgq = new PageQueryModel(1, 999999, "FID", "asc", "", " and IS_STATUS=1");
                        _strMeth = "Organization/GetListPage";
                        _DisplayMember = "name";
                        _ValueMember = "fid";
                        gridColumn1.Caption = "组织ID";
                        gridColumn1.FieldName = "fid";
                        gridColumn1.Name = "gridColumn1";
                        gridColumn5.Caption = "组织名称";
                        gridColumn5.FieldName = "name";
                        gridColumn5.Name = "gridColumn5";
                        gridColumn5.Visible = true;
                        gridColumn2.Caption = "组织编号";
                        gridColumn2.FieldName = "fNumber";
                        gridColumn2.MinWidth = 80;
                        gridColumn2.Name = "gridColumn2";
                        gridColumn2.UnboundDataType = typeof(string);
                        gridColumn2.Visible = true;
                        gridColumn2.VisibleIndex = 1;
                        gridColumn2.Width = 80;
                        gridColumn4.Caption = "guid";
                        gridColumn4.FieldName = "guid";
                        gridColumn4.Name = "gridColumn4";
                        break;
                    case 2://供应商
                        pgq = new PageQueryModel(1, 999999, "org.FNumber asc ,a.supp_no", "asc", "", " and a.FSubsidiary ='" + _orgId + "'");
                        _strMeth = "MesSupplierManager/GetListPage";
                        _DisplayMember = "suppName";
                        _ValueMember = "id";
                        gridColumn5.Caption = "使用组织";
                        gridColumn5.FieldName = "fSubsidiary";
                        gridColumn5.Name = "gridColumn5";
                        gridColumn5.Visible = true;
                        gridColumn5.VisibleIndex = 0;
                        gridColumn1.Caption = "供应商ID";
                        gridColumn1.FieldName = "id";
                        gridColumn1.MaxWidth = 100;
                        gridColumn1.MinWidth = 80;
                        gridColumn1.Name = "gridColumn1";
                        gridColumn1.UnboundDataType = typeof(string);
                        gridColumn1.Width = 100;
                        gridColumn2.Caption = "供应商编号";
                        gridColumn2.FieldName = "suppNo";
                        gridColumn2.MinWidth = 80;
                        gridColumn2.Name = "gridColumn2";
                        gridColumn2.Visible = true;
                        gridColumn2.VisibleIndex = 2;
                        gridColumn2.Width = 80;
                        gridColumn3.Caption = "供应商名称";
                        gridColumn3.FieldName = "suppName";
                        gridColumn3.MinWidth = 100;
                        gridColumn3.Name = "gridColumn3";
                        gridColumn3.Visible = true;
                        gridColumn3.VisibleIndex = 1;
                        gridColumn3.Width = 100;
                        gridColumn4.Caption = "guid";
                        gridColumn4.FieldName = "guid";
                        gridColumn4.Name = "gridColumn4";
                        break;
                    case 3://客户
                        pgq = new PageQueryModel(1, 999999, "org.FNumber asc ,a.cust_no", "asc", "", " and a.FSubsidiary ='" + _orgId + "'");
                        _strMeth = "MesCustomerManager/GetListPage";
                        _DisplayMember = "custName";
                        _ValueMember = "id";
                        gridColumn5.Caption = "所在组织";
                        gridColumn5.FieldName = "fSubsidiary";
                        gridColumn5.MinWidth = 200;
                        gridColumn5.Name = "gridColumn5";
                        gridColumn5.Visible = true;
                        gridColumn5.VisibleIndex = 0;
                        gridColumn5.Width = 200;
                        gridColumn1.Caption = "客户ID";
                        gridColumn1.FieldName = "id";
                        gridColumn1.MinWidth = 50;
                        gridColumn1.Name = "gridColumn1";
                        gridColumn1.Visible = true;
                        gridColumn1.VisibleIndex = 1;
                        gridColumn2.Caption = "客户编号";
                        gridColumn2.FieldName = "custNo";
                        gridColumn2.MinWidth = 80;
                        gridColumn2.Name = "gridColumn2";
                        gridColumn2.Visible = true;
                        gridColumn2.VisibleIndex = 2;
                        gridColumn2.Width = 80;
                        gridColumn3.Caption = "客户名称";
                        gridColumn3.FieldName = "custName";
                        gridColumn3.MinWidth = 100;
                        gridColumn3.Name = "gridColumn3";
                        gridColumn3.Visible = true;
                        gridColumn3.VisibleIndex = 3;
                        gridColumn3.Width = 100;
                        gridColumn4.Caption = "guid";
                        gridColumn4.FieldName = "guid";
                        gridColumn4.Name = "gridColumn4";
                        break;
                }
                this.searchLookUpEdit1View.Columns.AddRange(new DevExpress.XtraGrid.Columns.GridColumn[] {
                            gridColumn1,
                            gridColumn5,
                            gridColumn3,
                            gridColumn2,
                           gridColumn4 });
                var json = JsonConvert.SerializeObject(pgq);
                try
                {
                    var strReturn = UtilityHelper.HttpPost("", _strMeth, json);
                    var rtn = UtilityHelper.ReturnToTablePage(strReturn);
                    var dt = rtn.rtnData.list;
                    txt_hzabc.Properties.DataSource = dt;
                    txt_hzabc.Properties.DisplayMember = _DisplayMember;
                    txt_hzabc.Properties.ValueMember = _ValueMember;
                    txt_hzabc.ForceInitialize();
                    txt_hzabc.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
                    if (!string.IsNullOrEmpty(HzId))
                        SetHzId(HzId);
                }
                catch (Exception ex)
                {
                    MsgHelper.Warning("提示:" + ex.Message);
                }
            };
        }
 
        /// <summary>
        /// 读取货主id
        /// </summary>
        /// <returns></returns>
        public string GetHzId()
        {
            var row2 = txt_hzabc.GetSelectedDataRow() as DataRowView;
            if (row2 != null)
            {
                string inHz = txt_hzlxabc.SelectedIndex > 1 ? row2["Id"].ToString() : row2["fid"].ToString();
                return inHz;
            }
            return "";
        }
        /// <summary>
        /// 读取货主类型
        /// </summary>
        /// <returns></returns>
        public string GetHzLx()
        {
            if (txt_hzlxabc.SelectedIndex <= 0)
                return "";
            string id = txt_hzlxabc.Text.Trim();
            return id;
        }
 
 
        /// <summary>
        /// 设置
        /// </summary>
        /// <param name="Code"></param>
        public void SetHzId(string Code)
        {
            if (Code == "-1" || string.IsNullOrEmpty(Code))
            {
                txt_hzabc.EditValue = null;
                return;
            }
            txt_hzabc.EditValue = Int64.Parse(((Code.ToString().Trim())));
            txt_hzabc.Text = Code;
        }
        /// <summary>
        /// 设置
        /// </summary>
        /// <param name="Code"></param>
        public void SetHzLx(string Code)
        {
            if (string.IsNullOrEmpty(Code))
                txt_hzlxabc.SelectedIndex = 0;
            else
                txt_hzlxabc.Text = Code;
        }
    }
}