//打印
        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            string s = string.Empty;

            SqlConnect.ConnectStr connect = new SqlConnect.ConnectStr("ERP");
            string s1  = connect.GetConnectStr("ERP");
            int    ijk = 0;

            for (int i = 0; i < dataGridView1.Rows.Count; i++)
            {
                if (dataGridView1.Rows[i].Selected == true)
                {
                    s   = dataGridView1.Rows[i].Cells[1].Value.ToString();
                    ijk = ijk + 1;
                }
            }
            if (ijk > 1)
            {
                MessageBox.Show("请逐一单据打印", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            List <Com.Hui.Controls.ReportParameter> list = new List <Com.Hui.Controls.ReportParameter>();

            list.Add(new Com.Hui.Controls.ReportParameter("bdbh", s));
            Com.Hui.Controls.ReportHelper.PrintReport("cllydjyt.frx", list, s1, true);
        }
Beispiel #2
0
        //查询
        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;//等待
            dt.Clear();
            SqlConnect.ConnectStr connect = new SqlConnect.ConnectStr("ERP");
            string s = connect.GetConnectStr("ERP");
            string connectionString = s;

            using (SqlConnection conn = new SqlConnection(connectionString))
            {
                conn.Open();
                using (SqlCommand cmd = conn.CreateCommand())
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.CommandText = "AfterPrintingDaily3";
                    SqlParameter[] para =
                    {
                        new SqlParameter("@DAH1",  SqlDbType.VarChar),
                        new SqlParameter("@DAH2",  SqlDbType.VarChar),
                        new SqlParameter("@DAH3",  SqlDbType.VarChar),
                        new SqlParameter("@DAH4",  SqlDbType.VarChar),
                        new SqlParameter("@DAH5",  SqlDbType.VarChar),
                        new SqlParameter("@TIME1", SqlDbType.DateTime),
                        new SqlParameter("@TIME2", SqlDbType.DateTime)
                    };
                    para[0].Value = toolStripComboBox1.Text; //班组
                    para[1].Value = toolStripComboBox2.Text; //机台名称
                    para[2].Value = toolStripTextBox1.Text;  //工单号
                    para[3].Value = toolStripTextBox2.Text;  //产品名称
                    para[4].Value = toolStripTextBox3.Text;  //部门名称
                    para[5].Value = sdate.Value.ToString("yyyy-MM-dd") + " 00:00:00";
                    para[6].Value = edate.Value.ToString("yyyy-MM-dd") + " 23:59:59";
                    try
                    {
                        cmd.CommandTimeout = 60 * 60 * 1000;
                        cmd.Parameters.AddRange(para);// 将参数加入命令对象
                        SqlDataAdapter adapter = new SqlDataAdapter(cmd);
                        adapter.Fill(dt);
                        conn.Close();
                        dataGridView1.DataSource = dt;
                        dataGridView1.RowsDefaultCellStyle.BackColor            = Color.Aquamarine;
                        dataGridView1.AlternatingRowsDefaultCellStyle.BackColor = Color.Bisque;
                        dataGridView1.RowsDefaultCellStyle.Font = new Font("微软雅黑", 8, FontStyle.Regular);
                        dataGridView1.Refresh();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
            }
            this.Cursor = Cursors.Default;//正常状态
        }
        //查询
        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;//等待
            dt.Clear();
            SqlConnect.ConnectStr connect = new SqlConnect.ConnectStr("ERP");
            string s = connect.GetConnectStr("ERP");
            string connectionString = s;

            using (SqlConnection conn = new SqlConnection(connectionString))
            {
                conn.Open();
                using (SqlCommand cmd = conn.CreateCommand())
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.CommandText = ProName;
                    SqlParameter[] para =
                    {
                        new SqlParameter("@WLMC",    SqlDbType.VarChar),
                        new SqlParameter("@WLLB",    SqlDbType.VarChar),
                        new SqlParameter("@ZBXH_CK", SqlDbType.VarChar),
                        new SqlParameter("@WLZL",    SqlDbType.VarChar),
                        new SqlParameter("@WLFL",    SqlDbType.VarChar),
                        new SqlParameter("@WLBH",    SqlDbType.VarChar)
                    };
                    para[0].Value = toolStripTextBox2.Text;
                    para[1].Value = ConvertWLDL("");
                    para[2].Value = ConvertCK(toolStripComboBox3.Text);
                    para[3].Value = ConvertWLZL("");
                    para[4].Value = ConvertWLFL(toolStripComboBox4.Text.ToString());
                    para[5].Value = toolStripTextBox1.Text;
                    try
                    {
                        cmd.CommandTimeout = 60 * 60 * 1000;
                        cmd.Parameters.AddRange(para);// 将参数加入命令对象
                        SqlDataAdapter adapter = new SqlDataAdapter(cmd);
                        adapter.Fill(dt);
                        conn.Close();
                        dataGridView1.DataSource = dt;
                        dataGridView1.RowsDefaultCellStyle.BackColor            = Color.Aquamarine;
                        dataGridView1.AlternatingRowsDefaultCellStyle.BackColor = Color.Bisque;
                        dataGridView1.RowsDefaultCellStyle.Font = new Font("微软雅黑", 8, FontStyle.Regular);
                        dataGridView1.Refresh();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
            }
            this.Cursor = Cursors.Default;//正常状态
        }
        //查询
        private void toolStripButton3_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;//等待
            dt.Clear();
            SqlConnect.ConnectStr connect = new SqlConnect.ConnectStr("ERP");
            string s = connect.GetConnectStr("ERP");
            string connectionString = s;

            using (SqlConnection conn = new SqlConnection(connectionString))
            {
                conn.Open();
                using (SqlCommand cmd = conn.CreateCommand())
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.CommandText = "YUAN_CLCRK_Query";
                    SqlParameter[] para =
                    {
                        new SqlParameter("@STARTTIME", SqlDbType.DateTime),
                        new SqlParameter("@ENDTIME",   SqlDbType.DateTime)
                    };
                    para[0].Value = sdate.Value.ToString("yyyy-MM-dd") + " 00:00:00";
                    para[1].Value = edate.Value.ToString("yyyy-MM-dd") + " 23:59:59";
                    try
                    {
                        cmd.CommandTimeout = 60 * 60 * 10000;
                        cmd.Parameters.AddRange(para);// 将参数加入命令对象
                        SqlDataAdapter adapter = new SqlDataAdapter(cmd);
                        adapter.Fill(dt);
                        conn.Close();
                        dataGridView1.DataSource = dt;
                        dataGridView1.RowsDefaultCellStyle.BackColor            = Color.Azure;
                        dataGridView1.AlternatingRowsDefaultCellStyle.BackColor = Color.WhiteSmoke;
                        toolStripLabel2.Text = "总行数:" + (dt.Rows.Count).ToString();
                        dataGridView1.RowsDefaultCellStyle.Font = new Font("微软雅黑", 8, FontStyle.Regular);
                        dataGridView1.Refresh();
                        this.dataGridView1.Columns["XH"].Visible   = false;
                        this.dataGridView1.Columns["ZBXH"].Visible = false;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
            }
            this.Cursor = Cursors.Default;//正常状态
        }
        //查询
        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;//等待
            dt.Clear();
            SqlConnect.ConnectStr connect = new SqlConnect.ConnectStr("ERP");
            string s = connect.GetConnectStr("ERP");
            string connectionString = s;

            using (SqlConnection conn = new SqlConnection(connectionString))
            {
                conn.Open();
                using (SqlCommand cmd = conn.CreateCommand())
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.CommandText = "xinbanyinshuaribao";
                    SqlParameter[] para =
                    {
                        new SqlParameter("@zdrq", SqlDbType.DateTime),
                        new SqlParameter("@byb",  SqlDbType.SmallInt),
                        new SqlParameter("@zydy", SqlDbType.VarChar)
                    };
                    para[0].Value = sdate.Value.ToString("yyyy-MM-dd") + " 00:00:00";
                    para[1].Value = Convert.ToInt16(toolStripComboBox1.SelectedIndex);
                    para[2].Value = toolStripComboBox2.Text;
                    try
                    {
                        cmd.CommandTimeout = 60 * 60 * 1000;
                        cmd.Parameters.AddRange(para);// 将参数加入命令对象
                        SqlDataAdapter adapter = new SqlDataAdapter(cmd);
                        adapter.Fill(dt);
                        conn.Close();
                        dataGridView1.DataSource = dt;
                        dataGridView1.RowsDefaultCellStyle.BackColor            = Color.Aquamarine;
                        dataGridView1.AlternatingRowsDefaultCellStyle.BackColor = Color.Bisque;
                        dataGridView1.RowsDefaultCellStyle.Font = new Font("微软雅黑", 8, FontStyle.Regular);
                        dataGridView1.Refresh();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
            }
            this.Cursor = Cursors.Default;//正常状态
        }
Beispiel #6
0
 //查询
 private void toolStripButton2_Click(object sender, EventArgs e)
 {
     this.Cursor = Cursors.WaitCursor;//等待
     if (toolStripTextBox3.Text.Equals(""))
     {
         dt.Clear();
         SqlConnect.ConnectStr connect = new SqlConnect.ConnectStr("ERP");
         string s = connect.GetConnectStr("ERP");
         string connectionString = s;
         using (SqlConnection conn = new SqlConnection(connectionString))
         {
             conn.Open();
             using (SqlCommand cmd = conn.CreateCommand())
             {
                 cmd.CommandType = CommandType.StoredProcedure;
                 cmd.CommandText = ProName;
                 SqlParameter[] para =
                 {
                     new SqlParameter("@DAH1",      SqlDbType.VarChar),
                     new SqlParameter("@DAH2",      SqlDbType.VarChar),
                     new SqlParameter("@STARTTIME", SqlDbType.DateTime),
                     new SqlParameter("@ENDTIME",   SqlDbType.DateTime)
                 };
                 para[0].Value = toolStripTextBox1.Text;
                 para[1].Value = toolStripTextBox2.Text;
                 para[2].Value = sdate.Value.ToString("yyyy-MM-dd") + " 00:00:00";
                 para[3].Value = edate.Value.ToString("yyyy-MM-dd") + " 23:59:59";
                 try
                 {
                     cmd.CommandTimeout = 60 * 60 * 10000;
                     cmd.Parameters.AddRange(para);// 将参数加入命令对象
                     SqlDataAdapter adapter = new SqlDataAdapter(cmd);
                     adapter.Fill(dt);
                     conn.Close();
                     dataGridView1.DataSource = dt;
                     dataGridView1.RowsDefaultCellStyle.BackColor            = Color.Aquamarine;
                     dataGridView1.AlternatingRowsDefaultCellStyle.BackColor = Color.Bisque;
                     toolStripLabel6.Text = "总行数:" + (dt.Rows.Count).ToString();
                     dataGridView1.RowsDefaultCellStyle.Font = new Font("微软雅黑", 8, FontStyle.Regular);
                     dataGridView1.Refresh();
                     //获得datatable的列名
                     List <string> ls = SqlHelper.GetColumnsByDataTable(dt);
                     toolStripComboBox1.ComboBox.DataSource = ls;
                 }
                 catch (Exception ex)
                 {
                     MessageBox.Show(ex.Message);
                 }
             }
         }
     }
     else
     {
         try {
             //获得现在所选列的列索引
             int       i            = toolStripComboBox1.ComboBox.SelectedIndex;
             string    dtcolounname = toolStripComboBox1.SelectedItem.ToString();
             DataRow[] dr           = dt.Select(dtcolounname + " like '%" + toolStripTextBox3.Text + "%'");
             DataTable dtt          = new DataTable();
             dtt = dt.Clone();
             if (dr.Length > 0)
             {
                 foreach (DataRow drVal in dr)
                 {
                     dtt.ImportRow(drVal);
                 }
             }
             dataGridView1.DataSource = dtt;
             toolStripLabel6.Text     = "总行数:" + (dtt.Rows.Count).ToString();
         }
         catch
         {
             MessageBox.Show("此列暂不支持筛选", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     this.Cursor = Cursors.Default;//正常状态
 }
Beispiel #7
0
 //查询
 private void toolStripButton2_Click(object sender, EventArgs e)
 {
     if (toolStripComboBox1.Text == "")
     {
         return;
     }
     if (toolStripComboBox2.Text == "")
     {
         return;
     }
     if (toolStripTextBox1.Text.Equals(""))
     {
         dt.Clear();
         this.Cursor = Cursors.WaitCursor;//等待
         SqlConnect.ConnectStr connect = new SqlConnect.ConnectStr("ERP");
         string s = connect.GetConnectStr("ERP");
         string connectionString = s;
         using (SqlConnection conn = new SqlConnection(connectionString))
         {
             conn.Open();
             using (SqlCommand cmd = conn.CreateCommand())
             {
                 cmd.CommandType = CommandType.StoredProcedure;
                 cmd.CommandText = ProName;
                 SqlParameter[] para =
                 {
                     new SqlParameter("@Years",  SqlDbType.Int),
                     new SqlParameter("@Months", SqlDbType.Int),
                     new SqlParameter("@Days",   SqlDbType.Int)
                 };
                 para[0].Value = Convert.ToInt16(toolStripComboBox2.Text);
                 para[1].Value = Convert.ToInt16(toolStripComboBox1.Text);
                 para[2].Value = Convert.ToInt16(PanDuan(toolStripComboBox2.Text, toolStripComboBox1.Text));
                 try
                 {
                     cmd.CommandTimeout = 60 * 60 * 1000;
                     cmd.Parameters.AddRange(para);// 将参数加入命令对象
                     SqlDataAdapter adapter = new SqlDataAdapter(cmd);
                     adapter.Fill(dt);
                     conn.Close();
                     DataGridViewShow(dt);
                     //获得datatable的列名
                     List <string> ls = SqlHelper.GetColumnsByDataTable(dt);
                     toolStripComboBox3.ComboBox.DataSource = ls;
                 }
                 catch (Exception ex)
                 {
                     MessageBox.Show(ex.Message);
                 }
             }
         }
     }
     else
     {
         try {
             //获得现在所选列的列索引
             int       i            = toolStripComboBox3.ComboBox.SelectedIndex;
             string    dtcolounname = toolStripComboBox3.SelectedItem.ToString();
             DataRow[] dr           = dt.Select(dtcolounname + " like '%" + toolStripTextBox1.Text + "%'");
             DataTable dtt          = new DataTable();
             dtt = dt.Clone();
             if (dr.Length > 0)
             {
                 foreach (DataRow drVal in dr)
                 {
                     dtt.ImportRow(drVal);
                 }
             }
             dataGridView1.DataSource = dtt;
             toolStripLabel3.Text     = "总行数:" + (dtt.Rows.Count).ToString();
         }
         catch
         {
             MessageBox.Show("此列暂不支持筛选", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     this.Cursor = Cursors.Default;//正常状态
 }