コード例 #1
0
        private void FrmConstructionRpt_Load(object sender, EventArgs e)
        {
            var sql =
                "SELECT c.name 字段,p.value 说明 FROM sys.syscolumns c JOIN sys.systypes t ON c.xusertype=t.xusertype JOIN sys.sysobjects o ON c.id=o.id LEFT JOIN sys.extended_properties p ON c.id=p.major_id AND c.colid=p.minor_id WHERE o.name='tf_sgdantwo' AND t.name LIKE '%date%'";
            var ds = SqlHelper.ExecuteDataset(SqlHelper.GetConnection(), CommandType.Text, sql);

            comboBox2.DataSource    = ds.Tables[0];
            comboBox2.DisplayMember = "说明";
            comboBox2.ValueMember   = "字段";
            comboBox2.SelectedIndex = comboBox2.Items.Count - 1;
            checkBox1.Checked       = false;
            checkBox2.Checked       = false;
            checkBox3.Checked       = false;
            if (SqlHelper.UserType == Resources.UT_Input || SqlHelper.UserType == Resources.UT_Admin)
            {
                checkBox4.Visible = true;
                checkBox5.Visible = true;
            }
            sql = "SELECT distinct cust FROM dzdj.dbo.customer";
            ds  = SqlHelper.ExecuteDataset(SqlHelper.GetConnection(), CommandType.Text, sql);
            txtCust.SpellSearchSource = GetSpellBoxSource(ds.Tables[0]).ToArray();
            var acsc = new AutoCompleteStringCollection();

            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                acsc.Add(dr["cust"].ToString());
            }
            txtCust.AutoCompleteCustomSource = acsc;
        }
コード例 #2
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (textBox1.Text != "")
     {
         var sql   = $"SELECT TOP 1 * FROM udbz WHERE name='{textBox1.Text.Trim().ToUpper()}'";
         var sdra5 = SqlHelper.ExecuteReader(SqlHelper.GetConnection(), CommandType.Text, sql);
         if (sdra5.HasRows)
         {
             sdra5.Close();
             MessageBox.Show($"此工序名称【{textBox1.Text.Trim()}】已存在,请重新输入!!", "提示");
             textBox1.Text = "";
             textBox1.Focus();
             Goiss();
         }
         else
         {
             sdra5.Close();
             var sqltk = $"insert into udbz(name) values('{textBox1.Text.Trim().ToUpper()}')";
             SqlHelper.ExecuteNonQuery(SqlHelper.GetConnection(), CommandType.Text, sqltk);
             textBox1.Text = "";
             textBox1.Focus();
         }
     }
     else
     {
         MessageBox.Show("工序名称不能为空", "提示");
         textBox1.Focus();
     }
 }
コード例 #3
0
        /// <summary>
        ///     查询
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSearch_Click(object sender, EventArgs e)
        {
            CtrlUtil.ClearDgv(dataGridView1);
            var wheres = new List <string>();

            if (!string.IsNullOrEmpty(dtBegin.Text))
            {
                var time1 = Convert.ToDateTime(dtBegin.Value.Date.ToString("yyyy-MM-dd"));
                wheres.Add($" luodanriqi>='{time1}' ");
            }
            if (!string.IsNullOrEmpty(dtEnd.Text))
            {
                var dt = DateTime.Parse(dtEnd.Text).AddDays(1);
                wheres.Add($" luodanriqi<'{dt}' ");
            }
            if (txtWONo.Text.Trim().Length > 0)
            {
                wheres.Add($" shigongdanhao='{txtWONo.Text.Trim()}'");
            }
            if (txtOrderNo.Text.Trim().Length > 0)
            {
                wheres.Add($" dingdanhao like '%{txtOrderNo.Text.Trim()}%'");
            }
            if (ssbCust.Text.Trim().Length > 0)
            {
                wheres.Add($" kehu like '%{ssbCust.Text.Trim()}%'");
            }
            if (txtPartNo.Text.Trim().Length > 0)
            {
                wheres.Add($" chanpintuhao like '%{txtPartNo.Text.Trim()}%'");
            }
            if (txtPartName.Text.Trim().Length > 0)
            {
                wheres.Add($" chanpinmingcheng like '%{txtPartName.Text.Trim()}%'");
            }
            if (txtPageNo.Text.Trim().Length > 0)
            {
                wheres.Add($" tuzhiyema like '%{txtPageNo.Text.Trim()}%'");
            }

            var sql =
                "SELECT shigongdanhao 工单号,dingdanhao 生产单号,kehu 客户,jiaohuoqi 交货期,tuzhiyema 页码,DXFbianhao DXF," +
                "chanpintuhao 零件图号,chanpinmingcheng 零件名称,cailiao 材料,houdu 厚,changdu 长,kuandu 宽,dingdansuliang 下单数量," +
                "dantaoyongliang 单套用量,beizu 备注,gongyiliusheng 工艺流程,luodanriqi 下单日期,luodanyuan 录入人," +
                "xiugairiqi 修改日期,xiugairen 修改人,CASE WHEN cls_id='T' THEN '停用' ELSE '' END 是否停用,suhu 审核状态 FROM mf_sgdan ";

            //判断用户是否选择了条件
            if (wheres.Count > 0)
            {
                var where = string.Join(" AND ", wheres.ToArray());
                sql       = $"{sql} WHERE {@where} ORDER BY luodanriqi,dingdanhao,shigongdanhao";
            }
            _ds = SqlHelper.ExecuteDataset(SqlHelper.GetConnection(), CommandType.Text, sql);
            dataGridView1.DataSource = _ds.Tables[0];
            dataGridView1.Sort(dataGridView1.Columns[0], ListSortDirection.Ascending);
        }
コード例 #4
0
        private void Goiss()
        {
            const string sql = "SELECT id '序号',name '工序名称'FROM udbz ";
            var          ds  = SqlHelper.ExecuteDataset(SqlHelper.GetConnection(), CommandType.Text, sql);

            dataGridView1.DataSource       = ds.Tables[0];
            dataGridView1.Columns[0].Width = 100;
            dataGridView1.Columns[1].Width = 100;
            dataGridView1.Sort(dataGridView1.Columns[0], System.ComponentModel.ListSortDirection.Ascending);
        }
コード例 #5
0
        private void button2_Click(object sender, EventArgs e)
        {
            var kMMi = dataGridView1.SelectedCells[0].Value.ToString().Trim();

            if (MessageBox.Show("是否要删除所选择的行", "警告", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
            {
                var sql = $"delete FROM udodt WHERE IDO='{kMMi}'";
                SqlHelper.ExecuteNonQuery(SqlHelper.GetConnection(), CommandType.Text, sql);
                Goiss();
            }
        }
コード例 #6
0
 private void button5_Click(object sender, EventArgs e)//新建保存
 {
     if (textBox2.Text != "")
     {
         if (textBox4.Text != "")
         {
             if (comboBox1.Text != "")
             {
                 if (SqlHelper.UserName == "管理" && comboBox1.Text.Trim() == Resources.UT_Admin)
                 {
                     MessageBox.Show("此帐号不可以创建<admin>帐号,请重新输入!!", Resources.T提示);
                 }
                 else
                 {
                     var sql     = $"SELECT ID FROM IDPASS WHERE ID='{textBox2.Text.Trim()}'";
                     var sdddr1Q = SqlHelper.ExecuteReader(SqlHelper.GetConnection(), CommandType.Text, sql);
                     if (sdddr1Q.HasRows)
                     {
                         MessageBox.Show($"此帐号< {textBox2.Text.Trim()} >已存在,请重新输入!!", Resources.T提示);
                         textBox2.Text = "";
                         sdddr1Q.Close();
                     }
                     else
                     {
                         sdddr1Q.Close();
                         sql =
                             $"insert into IDPASS(ID,pass,name,leiq) values('{textBox2.Text.Trim()}','{textBox3.Text.Trim()}','{textBox4.Text.Trim()}','{comboBox1.Text.Trim()}')";
                         SqlHelper.ExecuteNonQuery(SqlHelper.GetConnection(), CommandType.Text, sql);
                         textBox2.Text  = "";
                         textBox3.Text  = "";
                         textBox4.Text  = "";
                         comboBox1.Text = "";
                         GetUserInfo();
                     }
                 }
             }
             else
             {
                 MessageBox.Show("帐号类型不能为空!", Resources.T提示);
             }
         }
         else
         {
             MessageBox.Show("姓名不能为空!", Resources.T提示);
             textBox4.Focus();
         }
     }
     else
     {
         MessageBox.Show("帐号不能为空!", Resources.T提示);
         textBox2.Focus();
     }
 }
コード例 #7
0
        private void FrmConstructionGather_Load(object sender, EventArgs e)
        {
            const string sql = "SELECT distinct cust FROM dzdj.dbo.customer";
            var          ds  = SqlHelper.ExecuteDataset(SqlHelper.GetConnection(), CommandType.Text, sql);

            ssbCust.SpellSearchSource = GetSpellBoxSource(ds.Tables[0]).ToArray();
            var acsc = new AutoCompleteStringCollection();

            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                acsc.Add(dr["cust"].ToString());
            }
            ssbCust.AutoCompleteCustomSource = acsc;
        }
コード例 #8
0
        private void GetUserInfo()
        {
            panel1.Visible = false;
            panel2.Visible = false;
            const string sql = "SELECT lu as '序号',ID as '帐号',pass as '密码',name as '用户姓名',leiq as '用户类型' FROM IDPASS";
            var          ds  = SqlHelper.ExecuteDataset(SqlHelper.GetConnection(), CommandType.Text, sql);

            dataGridView1.DataSource       = ds.Tables[0];
            dataGridView1.Columns[0].Width = 46;
            dataGridView1.Columns[1].Width = 80;
            dataGridView1.Columns[2].Width = 80;
            dataGridView1.Columns[3].Width = 80;
            dataGridView1.Columns[4].Width = 80;
            dataGridView1.Sort(dataGridView1.Columns[0], System.ComponentModel.ListSortDirection.Ascending);
        }
コード例 #9
0
        private void FrmPrint_Load(object sender, EventArgs e)
        {
            var sql = "SELECT a.*,c.Dept FROM udstr a LEFT JOIN dbo.udone b ON b.sgdhao=a.sgdhao " +
                      "LEFT JOIN DZDJ.dbo.TB_Dept c ON c.ID=b.DeptId " +
                      $"WHERE zling='{SqlHelper.ProcCardNo}' AND DeptId='{SqlHelper.DeptId}' ORDER BY a.gxone,a.gxtwo";

            SqlHelper.FillDataset(SqlHelper.GetConnection(), CommandType.Text, sql, _ds, new [] { "sql" });
            //var cr = new cncCryst();
            cncCryst1.Load(Application.StartupPath + "cncCryst.rpt");
            cncCryst1.SetDataSource(_ds.Tables[0]);
            //cr.SetParameterValue("procCardNo", SqlHelper.ProcCardNo);
            //cr.SetParameterValue("DeptId", SqlHelper.DeptId);

            //cr.ReportDocument.ParameterFields["Parm"].CurrentValues.AddValue(
            crystalReportViewer1.ReportSource = cncCryst1;
        }
コード例 #10
0
        private void button2_Click(object sender, EventArgs e)//修改
        {
            _mMid = dataGridView1.SelectedCells[0].Value.ToString().Trim();
            //MMid = Convert.ToInt32(dataGridView1.SelectedCells[0].Value);
            panel2.Visible = true;
            var sql = $"SELECT * FROM IDPASS WHERE lu='{_mMid}'";
            var sdr = SqlHelper.ExecuteReader(SqlHelper.GetConnection(), CommandType.Text, sql);

            sdr.Read();
            textBox8.Text  = sdr["lu"].ToString().Trim();
            textBox7.Text  = sdr["ID"].ToString().Trim();
            textBox6.Text  = sdr["pass"].ToString().Trim();
            textBox5.Text  = sdr["name"].ToString().Trim();
            comboBox2.Text = sdr["leiq"].ToString().Trim();
            sdr.Close();
        }
コード例 #11
0
        private void button3_Click(object sender, EventArgs e)//导入数据库
        {
            var strSql = "";

            if (dgvExcelView.RowCount == 0)
            {
                return;
            }
            ;
            var iUpdateCount = 0;

            using (var conn = SqlHelper.GetConnection())
            {
                conn.Open();

                using (var st = conn.BeginTransaction())
                {
                    try
                    {
                        for (var i = 0; i < dgvExcelView.RowCount - 1; i++)
                        {
                            var strId1 = dgvExcelView.Rows[i].Cells["工单号"].Value.ToString();
                            var strId2 = dgvExcelView.Rows[i].Cells["工序号"].Value.ToString();
                            var strId3 = decimal.Parse(dgvExcelView.Rows[i].Cells["序价"].Value + "");
                            var strId4 = decimal.Parse(dgvExcelView.Rows[i].Cells["件资合计"].Value + "");
                            //string strId4 = dgvExcelView.Rows[i].Cells["件资合计"].Value.ToString();
                            //string strId5 = dgvExcelView.Rows[i].Cells["id5"].Value.ToString();
                            if (strId1 == "" || strId2 == "")
                            {
                                continue;
                            }
                            strSql =
                                $"UPDATE tf_sgdantwo set xujia={strId3},hezhi='{strId4}' WHERE shigongdanhao='{strId1}' AND xuhao='{strId2}'";
                            iUpdateCount += SqlHelper.ExecuteNonQuery(st, CommandType.Text, strSql);
                        }
                        st.Commit();
                        MessageBox.Show($"更新成功{iUpdateCount}条记录");
                    }
                    catch (Exception ex)
                    {
                        st.Rollback();
                        MessageBox.Show(ex.Message);
                    }
                }
            }
        }
コード例 #12
0
 private void button8_Click(object sender, EventArgs e)//修改保存
 {
     if (textBox7.Text != "")
     {
         if (textBox6.Text != "")
         {
             if (textBox5.Text != "")
             {
                 if (comboBox2.Text != "")
                 {
                     if (SqlHelper.UserName == "管理" && comboBox1.Text.Trim() == Resources.UT_Admin)
                     {
                         MessageBox.Show("此帐号不可以修改成<admin>帐号,请重新输入!!", Resources.T提示);
                     }
                     else
                     {
                         var sql =
                             $"UPDATE IDPASS set ID='{textBox7.Text.Trim()}',pass='******',name='{textBox5.Text.Trim()}',leiq='{comboBox2.Text.Trim()}' WHERE lu='{_mMid}'";
                         SqlHelper.ExecuteNonQuery(SqlHelper.GetConnection(), CommandType.Text, sql);
                         GetUserInfo();
                     }
                 }
                 else
                 {
                     MessageBox.Show("帐号类型不能为空!", Resources.T提示);
                 }
             }
             else
             {
                 MessageBox.Show("姓名不能为空!", Resources.T提示);
                 textBox5.Focus();
             }
         }
         else
         {
             MessageBox.Show("密码不能为空!", Resources.T提示);
             textBox6.Focus();
         }
     }
     else
     {
         MessageBox.Show("帐号不能为空!", Resources.T提示);
         textBox7.Focus();
     }
 }
コード例 #13
0
 private void textBox4_TextChanged(object sender, EventArgs e)
 {
     if (textBox3.Text.Length == 4)
     {
         var sql = "SELECT zling as '工艺卡号',sgdhao as '工单号',ddhao as '生产单号',kehu as '客户'," +
                   "jhqi as '订单交期',tuhao as '产品图号', name as '产品名称',yema as '页码', cailiao as '材料'," +
                   "suliang as '订单数量',gxone as '序号',gxname as '工序名称',gxtwo as '加工工序',tiao as '调机时间'," +
                   "danjian as '单件加工',xuj as '序价',buzu as '补助',wssulia as '完成数量',hujii as '件资合计'," +
                   "wsbanz as'加工班组',bei3 as '生产员',wsriqi as '完成日期',cjriqi as '指令创日',lururiqi as '录入日期'," +
                   $"lururen as '录入人',qgriqi as '修改日期',qgren as '修改人' FROM udktr WHERE zling='{textBox4.Text.Trim()}'";
         var ds = SqlHelper.ExecuteDataset(SqlHelper.GetConnection(), CommandType.Text, sql);
         dataGridView1.DataSource        = ds.Tables[0];
         dataGridView1.Columns[0].Width  = 65;
         dataGridView1.Columns[1].Width  = 65;
         dataGridView1.Columns[2].Width  = 65;
         dataGridView1.Columns[3].Width  = 65;
         dataGridView1.Columns[4].Width  = 65;
         dataGridView1.Columns[5].Width  = 65;
         dataGridView1.Columns[6].Width  = 65;
         dataGridView1.Columns[7].Width  = 65;
         dataGridView1.Columns[8].Width  = 65;
         dataGridView1.Columns[9].Width  = 65;
         dataGridView1.Columns[10].Width = 65;
         dataGridView1.Columns[11].Width = 65;
         dataGridView1.Columns[12].Width = 65;
         dataGridView1.Columns[13].Width = 65;
         dataGridView1.Columns[14].Width = 90;
         dataGridView1.Columns[15].Width = 90;
         dataGridView1.Columns[16].Width = 65;
         dataGridView1.Columns[17].Width = 85;
         dataGridView1.Columns[18].Width = 65;
         dataGridView1.Columns[19].Width = 65;
         dataGridView1.Columns[20].Width = 65;
         dataGridView1.Columns[21].Width = 65;
         dataGridView1.Columns[22].Width = 65;
         dataGridView1.Columns[23].Width = 65;
         dataGridView1.Columns[24].Width = 65;
         dataGridView1.Columns[25].Width = 65;
         dataGridView1.Columns[26].Width = 65;
         dataGridView1.Sort(dataGridView1.Columns[0], System.ComponentModel.ListSortDirection.Ascending);
         //OnRowDataBound = "gvWOContent_RowDataBound";
     }
 }
コード例 #14
0
 private void button3_Click(object sender, EventArgs e)//删除
 {
     if (dataGridView1.SelectedRows.Count == 0)
     {
         MessageBox.Show("提示:请选择要删除的用户信息!", Resources.J警告);
     }
     else
     {
         var mMid = dataGridView1.SelectedCells[0].Value.ToString().Trim();
         if (MessageBox.Show($"是否要删除< {mMid} >序号用户", Resources.J警告, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
         {
             var sql = $"delete FROM IDPASS WHERE lu='{mMid}'";
             SqlHelper.ExecuteNonQuery(SqlHelper.GetConnection(), CommandType.Text, sql);
             GetUserInfo();
         }
         else
         {
             GetUserInfo();
         }
     }
 }
コード例 #15
0
ファイル: FrmPwd.cs プロジェクト: liweixue/LYH.WorkOrderMisDx
        private void button1_Click(object sender, EventArgs e)
        {
            var sql   = $"SELECT TOP 1 * FROM IDPASS WHERE ID='{textBox1.Text.Trim()}'";
            var s5Dr5 = SqlHelper.ExecuteReader(SqlHelper.GetConnection(), CommandType.Text, sql);

            if (s5Dr5.HasRows)
            {
                s5Dr5.Read();
                var adss = s5Dr5["pass"].ToString().Trim();
                if (textBox2.Text.Trim() == adss)
                {
                    if (textBox3.Text.Trim() == textBox4.Text.Trim())
                    {
                        sql = "";
                        sql = $"UPDATE IDPASS set pass='******' WHERE ID='{textBox1.Text.Trim()}'";
                        SqlHelper.ExecuteNonQuery(SqlHelper.GetConnection(), CommandType.Text, sql);
                        Close();
                    }
                    else
                    {
                        MessageBox.Show("新密码输入不一致,请重新输入!", "提示");
                        textBox3.Text = "";
                        textBox4.Text = "";
                        textBox3.Focus();
                    }
                }
                else
                {
                    MessageBox.Show("当前密码与登录的密码不一致,请重新输入!", "提示");
                    textBox2.Text = "";
                    textBox3.Text = "";
                    textBox4.Text = "";
                    textBox2.Focus();
                }
            }
        }
コード例 #16
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            textBox3.Text = "";
            textBox4.Text = "";
            var wheres = new List <string>();

            if (!string.IsNullOrEmpty(dateTimePicker3.Text))
            {
                wheres.Add($" lururiqi>='{dateTimePicker3.Text}' ");
            }
            if (!string.IsNullOrEmpty(dateTimePicker4.Text))
            {
                var dt = new DateTime();
                dt = DateTime.Parse(dateTimePicker4.Text).AddDays(1);
                wheres.Add($" lururiqi<'{dt}' ");
            }
            if (DateTime.Compare(dateTimePicker1.Value, dateTimePicker2.Value) < 0)
            {
                wheres.Add($" cjriqi>='{dateTimePicker1.Text}' ");
                var zdt = new DateTime();
                zdt = DateTime.Parse(dateTimePicker2.Text).AddDays(1);
                wheres.Add($" cjriqi<'{zdt}' ");
            }
            if (textBox1.Text.Trim().Length > 0)
            {
                wheres.Add($" ddhao like '%{textBox1.Text.Trim()}%'");
            }
            if (textBox2.Text.Trim().Length > 0)
            {
                wheres.Add($" kehu like '%{textBox2.Text.Trim()}%'");
            }
            if (textBox5.Text.Trim().Length > 0)
            {
                wheres.Add($" tuhao like '%{textBox5.Text.Trim()}%'");
            }
            if (textBox6.Text.Trim().Length > 0)
            {
                wheres.Add($" yema like '%{textBox6.Text.Trim()}%'");
            }
            if (textBox7.Text.Trim().Length > 0)
            {
                wheres.Add($" wsbanz like '%{textBox7.Text.Trim()}%'");
            }
            var sql = "SELECT zling as '工艺卡号',sgdhao as '工单号',ddhao as '生产单号',kehu as '客户'," +
                      "jhqi as '订单交期',tuhao as '产品图号', name as '产品名称',yema as '页码', cailiao as '材料'," +
                      "suliang as '订单数量',gxone as '序号',gxname as '工序名称',gxtwo as '加工工序',tiao as '调机时间'," +
                      "danjian as '单件加工',xuj as '序价',buzu as '补助',wssulia as '完成数量',hujii as '件资合计'," +
                      "wsbanz as'加工班组',bei3 as '生产员',wsriqi as '完成日期',cjriqi as '指令创日',lururiqi as '录入日期'," +
                      "lururen as '录入人',qgriqi as '修改日期',qgren as '修改人' FROM udktr";

            //判断用户是否选择了条件
            if (wheres.Count > 0)
            {
                var wh = string.Join(" AND ", wheres.ToArray());
                sql = $"{sql} WHERE {wh}ORDER BY zling, gxone,gxtwo";
            }
            var ds = SqlHelper.ExecuteDataset(SqlHelper.GetConnection(), CommandType.Text, sql);

            dataGridView1.DataSource        = ds.Tables[0];
            dataGridView1.Columns[0].Width  = 65;
            dataGridView1.Columns[1].Width  = 65;
            dataGridView1.Columns[2].Width  = 65;
            dataGridView1.Columns[3].Width  = 65;
            dataGridView1.Columns[4].Width  = 65;
            dataGridView1.Columns[5].Width  = 65;
            dataGridView1.Columns[6].Width  = 65;
            dataGridView1.Columns[7].Width  = 65;
            dataGridView1.Columns[8].Width  = 65;
            dataGridView1.Columns[9].Width  = 65;
            dataGridView1.Columns[10].Width = 65;
            dataGridView1.Columns[11].Width = 65;
            dataGridView1.Columns[12].Width = 65;
            dataGridView1.Columns[13].Width = 65;
            dataGridView1.Columns[14].Width = 90;
            dataGridView1.Columns[15].Width = 90;
            dataGridView1.Columns[16].Width = 65;
            dataGridView1.Columns[17].Width = 85;
            dataGridView1.Columns[18].Width = 65;
            dataGridView1.Columns[19].Width = 65;
            dataGridView1.Columns[20].Width = 65;
            dataGridView1.Columns[21].Width = 65;
            dataGridView1.Columns[22].Width = 65;
            dataGridView1.Columns[23].Width = 65;
            dataGridView1.Columns[24].Width = 65;
            dataGridView1.Columns[25].Width = 65;
            dataGridView1.Columns[26].Width = 65;
            dataGridView1.Sort(dataGridView1.Columns[0], System.ComponentModel.ListSortDirection.Ascending);
        }
コード例 #17
0
        /// <summary>
        ///     根据条件查找
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSearch_Click(object sender, EventArgs e) //查询
        {
            CtrlUtil.ClearDgv(dataGridView1);

            var    wheres = new List <string>();
            string d;

            if (!string.IsNullOrEmpty(comboBox2.Text.Trim()))
            {
                d = comboBox2.SelectedValue.ToString();
            }
            else
            {
                MessageBox.Show(@"请选择一个日期选项!");
                comboBox2.DroppedDown = true;
                return;
            }
            if (!string.IsNullOrEmpty(dateTimePicker1.Text))
            {
                wheres.Add($" {d}>='{dateTimePicker1.Text}' ");
            }
            if (!string.IsNullOrEmpty(dateTimePicker2.Text))
            {
                var dtp = DateTime.Parse(dateTimePicker2.Text).AddDays(1);
                wheres.Add($" {d}<'{dtp}' ");
            }
            if (txtWONo.Text.Trim().Length > 0)
            {
                wheres.Add($" a.shigongdanhao like '%{txtWONo.Text.Trim()}%'");
            }
            if (txtMONo.Text.Trim().Length > 0)
            {
                wheres.Add($" b.dingdanhao like '%{txtMONo.Text.Trim()}%'");
            }
            if (txtPartNo.Text.Trim().Length > 0)
            {
                wheres.Add($" b.chanpintuhao like '%{txtPartNo.Text.Trim()}%'");
            }
            if (txtTeam.Text.Trim().Length > 0)
            {
                wheres.Add($" a.shengchanyuan like '%{txtTeam.Text.Trim()}%'");
            }
            if (txtCust.Text.Trim().Length > 0)
            {
                wheres.Add($" b.kehu like '%{txtCust.Text.Trim()}%'");
            }
            if (txtPage.Text.Trim().Length > 0)
            {
                wheres.Add($" b.tuzhiyema like '%{txtPage.Text.Trim()}%'");
            }
            if (checkBox3.Checked)
            {
                wheres.Add(" a.xujah like '%C15%'");
            }
            if (checkBox2.Checked)
            {
                wheres.Add(" a.xujah not like '%C15%'");
            }
            if (SqlHelper.UserType == Resources.UT_Input || SqlHelper.UserType == Resources.UT_Admin)
            {
                if (checkBox4.Checked)
                {
                    wheres.Add(" a.xujah like '%W11.1%'");
                }
                else if (checkBox5.Checked)
                {
                    wheres.Add(" a.xujah not like '%W11.1%'");
                }
            }

            if (comboBox1.Text.Trim().Length > 0)
            {
                if (comboBox1.Text.Trim() == Resources.UT_Audit)
                {
                    wheres.Add(" a.suhu ='审核'");
                }
                else if (comboBox1.Text.Trim() == "未审核")
                {
                    wheres.Add(" a.suhu is null or a.suhu =''");
                }
            }
            //string sql = "SELECT shigongdanhao as  '工单号',ddhao as '生产单号',kehu as '客户',jhqi as '订单交期',"+
            //    "chanpintuhao as '产品图号', xuhao as '工序号',gongxumingcheng as '工序名称',shengchanyuan as '生产班组',"+
            //    "wanshengsuliang as'完成数量',jgsu as '加工数',xujah as'序价号',xujia as '序价',buzu as '补助',"+
            //    "gongsi as '公式类型',hezhi as '件资合计',lururiqi as '录入日期',luruyan as '录入人',"+
            //    "qiugairiqi as '修改日期',qgren as '修改人',suhu as '审核状态',suren as '审核人' FROM tf_sgdantwo ";
            var sql =
                "SELECT b.shigongdanhao '工单号',b.dingdanhao '生产单号',b.jiaohuoqi '订单交期',b.kehu '客户',b.tuzhiyema '页码',b.chanpintuhao '产品图号'," +
                "a.xuhao '工序号',a.gongxumingcheng '工序名称',a.shengchanyuan '生产班组',ISNULL(a.wanshengsuliang,0) '完成数量',a.jgsu '加工数'," +
                "RTRIM(a.xujah) '序价号',a.xujia '序价',a.buzu '补助',a.gongsi '公式类型',ISNULL(a.hezhi,0) '件资合计',a.lururiqi '录入日期'," +
                "RTRIM(a.luruyan) '录入人',a.qiugairiqi '修改日期',RTRIM(a.qgren) '修改人',RTRIM(a.suhu) '审核状态',RTRIM(a.suren) '审核人'," +
                "(CASE a.Checked WHEN 1 THEN '已核对' ELSE '' END) '核对状态',a.Checker '核对人',a.Chkdate '核对日期' " +
                "FROM dbo.tf_sgdantwo a LEFT JOIN dbo.mf_sgdan b ON a.shigongdanhao=b.shigongdanhao ";

            //判断用户是否选择了条件
            if (wheres.Count > 0)
            {
                var wh = string.Join(" AND ", wheres.ToArray());
                sql = $"{sql} WHERE {wh} ORDER BY a.shigongdanhao,xuhao";
            }
            var ds = SqlHelper.ExecuteDataset(SqlHelper.GetConnection(), CommandType.Text, sql);

            dataGridView1.DataSource = ds.Tables[0];
            dataGridView1.Sort(dataGridView1.Columns[0], ListSortDirection.Ascending);
        }