private void button1_Click(object sender, EventArgs e) { label2.Visible = true; label2.Text = "查询中..."; try { // BaseAccess dbhelper = BaseAccess.CreateDataBase(); // DataTable dt= dbhelper.GetDataTable("".AsSQLQuery() + "select Top 1 * from WMS_SYS_USERS"); //if (dt != null // && dt.Rows != null // && dt.Rows.Count > 0) //{ // MessageBox.Show("成功!"); BaseAccess dbhelper = BaseAccess.CreateDataBase(); DataTable dt = dbhelper.GetDataTable("".AsSQLQuery() + "select * from view_Loc_needcheck "); if (dt != null) { dataGridView1.DataSource = dt; label2.Text = "" + (dataGridView1.Rows.Count - 1).ToString() + "条"; } else { MessageBox.Show("未获取到数据!"); } } catch (Exception ex) { MessageBox.Show("异常" + ex.Message); } }
private void button1_Click_1(object sender, EventArgs e) { label3.Visible = true; BaseAccess dbhelper = BaseAccess.CreateDataBase(); //DataTable dt1 = dbhelper.GetDataTable("".AsSQLQuery() + " select '' as'完成日期', '' as'完成月份', '' as'时间段', '' as' 数量'"); //dataGridView2.DataSource = dt1; try { // BaseAccess dbhelper = BaseAccess.CreateDataBase(); DataTable dt = dbhelper.GetDataTable("".AsSQLQuery() + "select CompletedDate as 完成日期,CompletedMonth as 完成月份,CompletedHour as 时间段,OutCount as 数量 from View_HourPickInfo where CompletedDate between '" + dateTimePicker1.Text + "' and '" + dateTimePicker2.Text + "'order by CompletedDate,CompletedHour"); if (dt != null) { dataGridView2.DataSource = dt; label3.Text = "" + (dataGridView2.Rows.Count - 1).ToString() + "小时"; } else { MessageBox.Show("未获取到数据!"); } double j = 0; for (int i = 0; i < dataGridView2.Rows.Count - 1; i++) { j += Convert.ToDouble(dataGridView2.Rows[i].Cells["数量"].Value); //rowtemp.CreateCell(1).SetCellValue(dgv.Rows[i].Cells["Capital_assets_Name_G"].Value.ToString()); //rowtemp.CreateCell(2).SetCellValue(dgv.Rows[i].Cells["Capital_assets_Code_G"].Value.ToString()); //rowtemp.CreateCell(3).SetCellValue(dgv.Rows[i].Cells["Capital_assets_Model_G"].Value.ToString()); } label4.Visible = true; label4.Text = "总计:" + j.ToString() + "种"; } catch (Exception ex) { MessageBox.Show("异常" + ex.Message); } }
private void button1_Click(object sender, EventArgs e) { label2.Visible = true; dateTimePicker2.Value.AddDays(+1).ToString(); if (textBox1.Text.Length > 17) { MessageBox.Show("请输入正确的订单号"); } else { BaseAccess dbhelper = BaseAccess.CreateDataBase(); DataTable dt = dbhelper.GetDataTable("".AsSQLQuery() + "select TagInfo,Printtime from WMS_W_TagPrintLog where PrintResult=0 and TagInfo like '%出库%" + textBox1.Text + "%' and (Printtime >='" + dateTimePicker1.Text + "'and Printtime<= '" + dateTimePicker2.Value.AddDays(+1).ToString() + "')"); string[] a = new string[dt.Rows.Count]; DataTable dt2 = new DataTable(); dt2.Columns.Add(new DataColumn("合并订单号", typeof(string))); dt2.Columns.Add(new DataColumn("物料编码", typeof(string))); dt2.Columns.Add(new DataColumn("物料名称", typeof(string))); // dt2.Columns.Add(new DataColumn("出库条码", typeof(string))); dt2.Columns.Add(new DataColumn("库区", typeof(string))); dt2.Columns.Add(new DataColumn("订单号", typeof(string))); dt2.Columns.Add(new DataColumn("出库条码", typeof(string))); dt2.Columns.Add(new DataColumn("打印时间", typeof(string))); for (int i = 0; i < dt.Rows.Count; i++) { // a[i] = dt.Rows[i][0].ToString(); string[] cc = dt.Rows[i][0].ToString().Split(new char[] { ':', ',' }); if (cc.Length == 62) { string c = cc[19].Substring(1, cc[19].Length - 2); string b = cc[17].Substring(1, cc[17].Length - 2); string d = cc[15].Substring(1, cc[15].Length - 2); //string e1 = cc[13].Substring(1, cc[13].Length - 2); string e2 = cc[39].Substring(1, cc[39].Length - 2); string e3 = cc[21].Substring(1, cc[21].Length - 2); string e4 = cc[7].Substring(1, cc[7].Length - 2); string e5 = dt.Rows[i][1].ToString(); dt2.Rows.Add(c, b, d, e2, e3, e4, e5); } //if(cc.Length==57) //{ // string c = cc[17].Substring(1, cc[17].Length - 2); // string b = cc[15].Substring(1, cc[15].Length - 2); // string d = cc[13].Substring(1, cc[13].Length - 2); // //string e1 = cc[13].Substring(1, cc[13].Length - 2); // string e2 = cc[37].Substring(1, cc[37].Length - 2); // string e3 = cc[17].Substring(1, cc[17].Length - 2); // string e4 = cc[7].Substring(1, cc[7].Length - 2); // string e5 = dt.Rows[i][1].ToString(); // dt2.Rows.Add(c, b, d, e2, e3, e4, e5); //} if (cc.Length == 56) { string c = cc[15].Substring(1, cc[15].Length - 2); string b = cc[13].Substring(1, cc[13].Length - 2); string d = cc[11].Substring(1, cc[11].Length - 2); //string e1 = cc[13].Substring(1, cc[13].Length - 2); string e2 = cc[35].Substring(1, cc[35].Length - 2); string e3 = cc[17].Substring(1, cc[17].Length - 2); string e4 = cc[7].Substring(1, cc[7].Length - 2); string e5 = dt.Rows[i][1].ToString(); dt2.Rows.Add(c, b, d, e2, e3, e4, e5); } } // string[] ss= a[0].Split(new char[] {':',',' }); //dataGridView1.Rows[0].Cells[0].Value = ss[21]; // dt2.Rows.Add("dsadsad"); dataGridView1.DataSource = dt2; dataGridView1.Columns["合并订单号"].Width = 130; dataGridView1.Columns["出库条码"].Width = 130; dataGridView1.Columns["打印时间"].Width = 130; label2.Text = "共" + dt2.Rows.Count.ToString() + "记录"; } }