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 (sFastSQL.Trim() == "") 
 | 
            { 
 | 
                MessageBox.Show("没有输入条件!"); 
 | 
                return; 
 | 
            } 
 | 
            Display(sFastSQL); 
 | 
        } 
 | 
    } 
 | 
} 
 |