雅琪诺MES智能条码管理系统
jingh
2021-04-14 4b7c59e6042aeb0908b43a7bae53d15c47a674c0
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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DBUtility;
 
namespace SCM
{
    public partial class frmHlpBillList : Form
    {
        public frmHlpBillList()
        {
            InitializeComponent();
        }
        public  string ViewName;
        public string tSQL;
        public string sDlgWhere = "";  //¿ìËÙ²éѯµÝÈë
        public frm_S_BillQueryCondition_Base frmCondition;
        /// <summary>
        /// ±ÜÃâÖØ¸´ÁÐ
        /// </summary>
        public string sPrimaryCol;  
        public Pub_Class.ClsPub.Enum_OKTag OKTag;
        public string sBillName="";
        Pub_Class.ClsGridListSum oSumGrid = new Pub_Class.ClsGridListSum();
        SCM.WMSWeb.WebService1 oWeb = new SCM.WMSWeb.WebService1();
 
 
        //³õʼ»¯GRID
        private void initGrid()
        {
           ClsPub1.initGridList(grdMain, this.Name);
        }
 
        
        //
        public Int32 Fun_GetCol(string sCol)
        {
            return DBUtility.Xt_BaseBillFun.Fun_GetCol(sCol, grdMain);
        }
 
        //ÏÔʾÄÚÈÝ
        private void Display()
        {
            //ClsCN SubCn = new ClsCN();
            DataSet DSet;
            string sSql = "";
            string sWhere = tSQL;  //ÌØÊâÌõ¼þ(ÈÕÆÚÏÞÖÆ£¬²¿ÃÅÏÞÖÆ)
            DBUtility.Xt_BaseBillFun.Sub_SQLWhere(ref sWhere);
 
            //¹ýÂËÌõ¼þ
            if (sDlgWhere != "")
            {
                sSql = "Select top 300 * from " + ViewName + " Where 1=1 " + sDlgWhere;
            }
            else
            {
                sSql = frmCondition.SqlStr + sWhere;
            }
            //
            DSet = oWeb.getDataSetBySQL(sSql, ViewName, ref DBUtility.ClsPub.sExeReturnInfo);
                //SubCn.RunProcReturn(sSql, ViewName, ref DBUtility.ClsPub.sExeReturnInfo);
            //Éú³ÉÊ×ÐбêÌâ
            if (DSet == null)
            {
                MessageBox.Show("ûÓзµ»ØÈκνá¹û,ÇëÔÚ¹ýÂË¿òÖеã»÷¡¾»Ö¸´¡¿°´Å¥,³¢ÊÔÔٴβéѯ£¡" + DBUtility.ClsPub.sExeReturnInfo);
                return;
            }
            //ÊͷŶ³½á
            DBUtility.Xt_BaseBillFun.CancelFrozenCol(grdMain);
            //°ó¶¨
            grdMain.DataSource = DSet.Tables[0].DefaultView;
            //ÉèÖúϼÆÁÐ
            string sTotalCol = "";
            sTotalCol = DBUtility.Gy_BaseFun.GetTotalCols(DSet);
            //ÉèÖÃ¶ÔÆëÁÐ
            //DBUtility.Xt_BaseBillFun.DisplayGridDuiQi(grdMain, ViewName);
            string[] sT;
            sT = sTotalCol.Split(Convert.ToChar(","));
            oSumGrid.BuildTotalCols(sT);
            //  
            //¶³½á
            int FrCol = 0;
            string s = "ÊÇ";
            ClsPub1.DisplayGrid(grdMain, this.Name, s, FrCol);
            //»­Ïß
            GraphLine();
            //
            Total();
 
            // 
        }
 
        private void timer1_Tick(object sender, EventArgs e)
        {
            timer1.Enabled = false;
            initGrid();
            Display();
        }
 
        private void tc_Click(object sender, EventArgs e)
        {
            OKTag = Pub_Class.ClsPub.Enum_OKTag.OKTag_Cancel;
            this.Visible = false;
        }
 
        private void sx_Click(object sender, EventArgs e)
        {
            timer1.Enabled = true;
        }
         
 
 
        private void frmHlpBillList_Load(object sender, EventArgs e)
        {
            oWeb.Url = ClsPub1.WEBSURL;
            frmCondition = new frm_S_BillQueryCondition_Base();
            //this.Text = ModCaption;
            //lblCaption.Text = ModCaption;
            oSumGrid.ogrdMain = grdMain;  //³õʼ»¯ new
            oSumGrid.oGridsum = grdSum;
            initGrid();
        }
 
        private void cx_Click(object sender, EventArgs e)
        {
            frmCondition = new frm_S_BillQueryCondition_Base();
            frmCondition.Tag = "";
            frmCondition.ViewName = ViewName;
            frmCondition.ModName = ViewName;
            frmCondition.ShowDialog();
            if (frmCondition.Tag.ToString() == "OK")
            {
                Display();
            }
        }
 
        private void bclk_Click(object sender, EventArgs e)
        {
            //±£´æÁпí
            DBUtility.ClsPub.SaveGridView(grdMain, this.Name,DBUtility.ClsPub.AppPath);
        }
 
        private void mrlk_Click(object sender, EventArgs e)
        {
            DBUtility.Xt_BaseBillFun.DefaultGridView(grdMain, this.Name);
        }
 
        private void GraphicsGrid()
        {
            DBUtility.Xt_BaseBillFun.GraphicsGrid(grdMain);
        }
 
        // 
        private void GraphLine()
        {
            int MainIDCol = Fun_GetCol("hmainid");
            int SubIDCol = Fun_GetCol("hsubid");
            string s ="ÊÇ";
            long n = 0;
            //DBUtility.Xt_BaseBillFun.GraphLine(grdMain, MainIDCol, SubIDCol, s, ref n);
            //ÏÔʾ
            lbldj.Text = "²éѯ³ö " + n.ToString() + " Õŵ¥¾Ý";
            lbljl.Text = "¹²ÓР" + grdMain.RowCount.ToString() + " Ìõ¼Ç¼";
 
        }
        //ÊÇ·ñÔÊÐí·µ»Ø
        private bool AllowBack()  //Lock
        {
            string stmp="";
            int PrimaryCol; 
            if (sPrimaryCol.Trim() != "")
            {
                //¸ù¾ÝÃû³Æ  µÃµ½ÁкÅ
                PrimaryCol = Fun_GetCol(sPrimaryCol);
                if (PrimaryCol == 0)
                {
                    return true; //ûÓÐÕÒµ½
                }
                else
                {
                    for (int i = 0; i < grdMain.SelectedRows.Count; i++)
                    { 
                        if (stmp == "")
                        {
                            stmp = DBUtility.ClsPub.isStrNull(grdMain.Rows[grdMain.SelectedRows[i].Index].Cells[PrimaryCol].Value);
                        }
                        if (stmp != DBUtility.ClsPub.isStrNull(grdMain.Rows[grdMain.SelectedRows[i].Index].Cells[PrimaryCol].Value))
                            return false;
                    }
                }
            }
            else
            {
                return true;
            }
            return true;
        }
 
        //ºÏ¼Æ new
        private void Total()
        {
            if (grdMain.Rows.Count > 0 && grdMain.ColumnCount > 0)
            {
                oSumGrid.SetGridsum();
                oSumGrid.Total();
            }
        }
        //ºÏ¼Æ new
        private void grdMain_ColumnWidthChanged(object sender, DataGridViewColumnEventArgs e)
        {
            Total();
        }
        //ºÏ¼Æ new
        private void grdMain_CellMouseUp(object sender, DataGridViewCellMouseEventArgs e)
        {
            Total();
        }
 
 
        //·µ»ØÐÅÏ¢
        private void Sub_DataBack()
        {
            if (!AllowBack())
            {
                MessageBox.Show("²»ÔÊÐíÑ¡Ôñ²»Í¬µÄ" + sPrimaryCol + "£¡", "Ìáʾ");
                return;
            }
            OKTag = Pub_Class.ClsPub.Enum_OKTag.OKTag_OK;
            this.Visible = false;
        }
 
       
      
        private void timer2_Tick(object sender, EventArgs e)
        {
            timer2.Enabled = false;
            frmCondition = new frm_S_BillQueryCondition_Base();
            frmCondition.Tag = "";
            frmCondition.ViewName = ViewName;
            frmCondition.ModName = ViewName;
            frmCondition.ShowDialog();
            if (frmCondition.Tag.ToString() == "OK")
            {
                timer1.Enabled = true;
            }
        }
 
        private void grdMain_Paint(object sender, PaintEventArgs e)
        {
            GraphicsGrid();
        }
 
        private void fh_Click(object sender, EventArgs e)
        {
            Sub_DataBack();
        }
 
        private void button1_Click(object sender, EventArgs e)
        {
            grdMain.Columns[5].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
        }
 
 
        #region  ¿ìËÙ²éѯ
 
        private void btnOK_Click(object sender, EventArgs e)
        {
            Sub_FastQuery();
        }
 
        //¿ìËÙ¹ýÂË
        private void Sub_FastQuery()
        {
            string sFastSQL = "";
            //µ¥¾ÝºÅ
            if (txtHBillNo.Text.Trim() != "")
            {
                sFastSQL = sFastSQL + " and µ¥¾ÝºÅ like '%" + txtHBillNo.Text + "%'";
            }
            //ÎïÁÏ´úÂë
            if (txtHMaterNumber.Text.Trim() != "")
            {
                sFastSQL = sFastSQL + " and ÎïÁÏ´úÂë like '%" + txtHMaterNumber.Text.Trim() + "%'";
            }
            //ÎïÁÏÃû³Æ
            if (txtHMaterName.Text.Trim() != "")
            {
                sFastSQL = sFastSQL + " and ÎïÁÏÃû³Æ like '%" + txtHMaterName.Text + "%'";
            }
            //ÎïÁϹæ¸ñÐͺÅ
            if (txtHMaterModel.Text.Trim() != "")
            {
                sFastSQL = sFastSQL + " and ¹æ¸ñÐͺŠlike '%" + txtHMaterModel.Text + "%'";
            }
            if (sFastSQL.Trim() == "")
            {
                MessageBox.Show("ûÓÐÊäÈëÌõ¼þ!");
                return;
            }
            sDlgWhere = sFastSQL;
            Display();
            sDlgWhere = "";
        }
 
 
        #endregion
 
 
        
    }
}