王 垚
2022-04-06 9167264eeb081fdbb94d8a1d2f76f35a6ccdd5fe
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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using gregn6Lib;
using SQLHelper;
 
namespace WarM
{
    public partial class Pt_RadiumCarvingCodeBillList : Form
    {
        public Pt_RadiumCarvingCodeBillList()
        {
            InitializeComponent();
        }
        public DBUtility.frmBillQueryCondition_New frmCondition;
        const string ViewName = "h_v_IF_RadiumCarvingCodeBillList";
        const string ModCaption = "镭雕码导出";
        public Pt_RadiumCarvingCodeBillList oFrm;
        Pub_Class.ClsGridListSum oSumGrid = new Pub_Class.ClsGridListSum();
        public Int32 iTopRow = 0;//画横线
        int _ScrollValue = 0;//刷新 回位
 
        #region  固定代码
        //初始化网格
        private void initGrid()
        {
            DBUtility.Xt_BaseBillFun.initGridList(grdMain,this.Name);
        }
        //
        //显示
        private void Display(string sFastSQL)
        {
            ClsCN SubCn = new ClsCN();
            DataSet DSet;
            string sSql = "";
            //sSql = "Select * from " + ViewName + " Where 1=1 " + sWhere + " order by 单据号 desc,hsubid ";
            sSql = string.Format(@"select b.DeviceSerialNum,a.SerialNo as 镭雕码 ,a.CarveTime as 返回日期,b.spreadno 流传单号  from ZD_Ld..ld_serialno a
                                   left join ZD_Ld..ld_serial b on a.SerialId = b.id
                                   where 1=1 " + sFastSQL + " order by a.CarveTime");
            DSet = SubCn.RunProcReturn(sSql, ViewName, ref DBUtility.ClsPub.sExeReturnInfo);
            //生成首行标题
            if (DSet == null)
            {
                MessageBox.Show("没有返回任何结果,请在过滤框中点击【恢复】按钮,尝试再次查询!" + DBUtility.ClsPub.sExeReturnInfo);
                return;
            }
            //释放冻结
            DBUtility.Xt_BaseBillFun.CancelFrozenCol(grdMain);
            //刷新后,回滚到原位置
            int selectRows = 0;
            if (grdMain.CurrentRow != null)
            {
                selectRows = DBUtility.ClsPub.isInt(grdMain.CurrentRow.Index);
            }
            //绑定
            grdMain.DataSource = DSet.Tables[0].DefaultView;
            //刷新后,回滚到原位置
            if (grdMain.Rows.Count > _ScrollValue)
            {
                grdMain.FirstDisplayedScrollingRowIndex = _ScrollValue;
                //iTopRow = _ScrollValue;
            }
            if (grdMain.Rows.Count > 0 && grdMain.Rows.Count > selectRows)
            {
                grdMain.Rows[selectRows].Selected = true;
            }
            //设置合计列
            string sTotalCol = "";
            sTotalCol = DBUtility.Gy_BaseFun.GetTotalCols(DSet);
            string[] sT;
            sT = sTotalCol.Split(Convert.ToChar(","));
            oSumGrid.BuildTotalCols(sT);
            //  
            //冻结
            int FrCol = DBUtility.ClsPub.isInt(frmCondition.txtFrozenCol.Text);
            string s = frmCondition.cmbHComplete.Text;
            DBUtility.Xt_BaseBillFun.DisplayGrid(grdMain, this.Name, s, FrCol);
            //画线
            GraphLine();
            //
            
            // 
        }
      
        //退出
        private void tc_Click(object sender, EventArgs e)
        {
            this.Close();
        }
 
        //
        private Int32 Fun_GetCol(string sCol)
        {
            return DBUtility.Xt_BaseBillFun.Fun_GetCol(sCol, grdMain);
        }
 
        //镭雕码数据加载
        private void Pt_RadiumCarvingCodeBillList_Load(object sender, EventArgs e)
        {
            //
            frmCondition = new DBUtility.frmBillQueryCondition_New();
            this.Text = ModCaption;
            lblCaption.Text = ModCaption;
            oSumGrid.ogrdMain = grdMain;  //初始化 new
            oSumGrid.oGridsum = grdSum;
            //初始化快速过滤
            dtpHBDate.Value = DateTime.Today;
            dtpHEDate.Value = DateTime.Today;
            dtpHBDate.Checked = true;
            dtpHEDate.Checked = true;
            //
            initGrid();
            Sub_FastQuery();
        }
 
        //查询
        private void cx_Click(object sender, EventArgs e)
        {
            frmCondition = new DBUtility.frmBillQueryCondition_New();
            SetCondition(frmCondition, ViewName, this.Name);
            frmCondition.ShowDialog();
            if (frmCondition.Tag.ToString() == "OK")
            {
                Sub_FastQuery();
            }
        }
 
        public void SetCondition(DBUtility.frmBillQueryCondition_New frmCondition, string ViewName, string Name)
        {
            frmCondition.Tag = "";
            frmCondition.ViewName = ViewName;
            frmCondition.ModName = Name;
        }
 
        private void bclk_Click(object sender, EventArgs e)
        {
            //保存列宽
            DBUtility.Xt_BaseBillFun.SaveGrid(grdMain, this.Name);
        }
 
        private void mrlk_Click(object sender, EventArgs e)
        {
            DBUtility.Xt_BaseBillFun.DefaultGridView(grdMain, this.Name);
        }
        // 
        private void GraphLine()
        {
            //显示
            lbljl.Text = "共有 " + grdMain.RowCount.ToString() + " 条记录";
 
        }
 
        private void GraphicsGrid()
        {
            //画底线
            DBUtility.Xt_BaseBillFun.GraphicsGrid(grdMain);
        }
 
        //
        private void grdMain_Paint(object sender, PaintEventArgs e)
        {
            GraphicsGrid();
        }
      
        //导出
        private void dc_Click(object sender, EventArgs e)
        {
            DBUtility.Gy_BaseFun.DataToExcel(this.Text, grdMain);
        }
 
        #endregion
 
        //快速过滤
        private void btnOK_Click(object sender, EventArgs e)
        {
            Sub_FastQuery();
        }
 
        //快速过滤
        private void Sub_FastQuery()
        {
            string sFastSQL="";
            //判断开始日期
            if (dtpHBDate.Checked)
            {
                sFastSQL = sFastSQL + " and a.CarveTime>='" + dtpHBDate.Value.ToString("yyyy-MM-dd")+" 00:00:00"+ "'";
            }
            //判断结束日期
            if (dtpHEDate.Checked)
            {
                sFastSQL = sFastSQL + " and a.CarveTime<='" + dtpHEDate.Value.ToString("yyyy-MM-dd") + " 23:59:59" + "'";
            }
            //判断流传单号
            if (SpreadNo.Text.ToString().Trim() != "") 
            {
                sFastSQL = sFastSQL + " and b.spreadno like '%"+ SpreadNo.Text.ToString().Trim() + "%'";
            }
            //判断镭雕码
            if (SpreadCar.Text.ToString().Trim() != "")
            {
                sFastSQL = sFastSQL + " and a.SerialNo like '%" + SpreadCar.Text.ToString().Trim() + "%'";
            }
            //判断机台编号
            if (SpreadNo.Text.ToString().Trim() != "")
            {
                sFastSQL = sFastSQL + " and b.DeviceSerialNum='" + SpreadNo.Text.ToString().Trim() + "'";
            }
            if (sFastSQL.Trim() == "")
            {
                MessageBox.Show("没有输入条件!");
                return;
            }
            Display(sFastSQL);
        }
    }
}