frm_TaskInfo.cs
3.21 KB
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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using HHWCS.Common;
using MySql.Data.MySqlClient;
namespace HHWCS.View
{
public partial class Frm_TaskInfo : Form
{
public Frm_TaskInfo()
{
InitializeComponent();
FormInit();
}
private void FormInit()
{
Dictionary<String,String> status = new Dictionary<string, string>();
status.Add("0", "生成任务");
status.Add("10", "下达任务");
status.Add("20", "开始执行");
status.Add("30", "到达站台");
status.Add("40", "完成");
cbx_Status.DataSource = status.ToList();
cbx_Status.DisplayMember = "value";
cbx_Status.ValueMember = "key";
}
private void button1_Click(object sender, EventArgs e)
{
DataSet ds = MySqlHelper.ExecuteDataset(APP.ConnectionString, "select * from task");
dgv_1.DataSource = ds.Tables[0];
//using(MySqlConnection connection = new MySqlConnection("server=172.16.29.40;user id=root;password=hhsoftware;persistsecurityinfo=True;database=huaheng"))
//{
// MySqlCommand command = new MySqlCommand("select * from task",connection);
// MySqlDataAdapter mySqlDataAdapter = new MySqlDataAdapter();
// mySqlDataAdapter.SelectCommand = command;
// DataTable dt = new DataTable();
// mySqlDataAdapter.Fill(dt);
// dataGridView1.DataSource = dt;
// MessageBox.Show("ok");
//}
}
private void btn_Query_Click(object sender, EventArgs e)
{
String sql = "select * from task where 1=1 ";
String status = (String) cbx_Status.SelectedValue;
if (!String.IsNullOrEmpty(status))
{
sql += " and status = '" + status + "'";
}
if (!String.IsNullOrEmpty(txt_Task.Text))
{
sql += " and id = " + txt_Task.Text;
}
if (!String.IsNullOrEmpty(txt_Pallete.Text))
{
sql += " and containerCode = '" + txt_Pallete.Text + "'";
}
DataSet ds = MySqlHelper.ExecuteDataset(APP.MysqlConnection, sql);
if (ds == null||ds.Tables.Count==0)
{
MessageBox.Show("未找到数据");
}
dgv_1.DataSource = ds.Tables[0].AsEnumerable().Select(x => new {
仓库 = x["warehouseCode"],
任务号 = x["id"],
托盘=x["containerCode"],
状态 = x["status"],
任务类型 = APP.GetTaskType(x["type"].ToString()),
优先级 = x["priority"],
站台 =x["station"],
源库位=x["sourceLocation"],
目标库位=x["destinationLocation"],
创建者=x["createdBy"],
创建时间=x["created"]
}).ToList();
APP.FormatDgv2(dgv_1);
}
}
}