async public Task <bool> ReadyDeathToolsList() { if (await Server.GetReadyDeathTools(Global.LoginInfo.user_id, Global.LoginInfo.user_code)) { // maxPageNum = (Global.ToolsList.num.list_num / Convert.ToInt32(Global.ToolsList.num.page_num)) + 1; int list_num = Global.ReadyDeathTools.Count; page = 1; maxPageNum = (list_num / 100) + 1; lb_cur.Text = "第" + page + "页"; // var sum = Global.ToolsList.num.list_num / Global.PageNum; // maxPageNum = sum == 0 ? 1 : sum; lb_sum.Text = "共" + maxPageNum + "页"; // curPage = cur; if (maxPageNum != comboBox1.Items.Count) { Global.AddComboxNum(comboBox1, maxPageNum); } dataGridView1.DataSource = Global.ReadyDeathTools; // dataGridView1.RowHeadersVisible = false; for (int i = 0; i < dataGridView1.Rows.Count; i++) { if (i % 2 == 0) { dataGridView1.Rows[i].DefaultCellStyle.BackColor = Color.LightBlue; } var t = dataGridView1.Rows[i].Cells; } if (Global.ReadyDeathTools.Count >= 0) { dataGridView1.Columns[0].HeaderText = "工具标识"; dataGridView1.Columns[1].HeaderText = "传感器标识"; dataGridView1.Columns[2].HeaderText = "站点id标识"; dataGridView1.Columns[3].HeaderText = "科目id标识"; dataGridView1.Columns[4].HeaderText = "领用人id标识"; dataGridView1.Columns[5].HeaderText = "工具名称"; dataGridView1.Columns[6].HeaderText = "工具型号"; dataGridView1.Columns[7].HeaderText = "工具编号"; dataGridView1.Columns[8].HeaderText = "工具类别"; dataGridView1.Columns[9].HeaderText = "出厂日期"; dataGridView1.Columns[10].HeaderText = "购买日期"; dataGridView1.Columns[11].HeaderText = "试验日期"; dataGridView1.Columns[12].HeaderText = "试验周期(月)"; dataGridView1.Columns[13].HeaderText = "生命周期(月)"; dataGridView1.Columns[14].HeaderText = "生产厂商"; dataGridView1.Columns[15].HeaderText = "传感器名称"; dataGridView1.Columns[16].HeaderText = "科目名称"; dataGridView1.Columns[17].HeaderText = "下次试验日期"; dataGridView1.Columns[18].HeaderText = "报废日期"; dataGridView1.Columns[19].HeaderText = "是否在库"; dataGridView1.Columns[20].HeaderText = "去向"; for (int i = 0; i < dataGridView1.Columns.Count; i++) { dataGridView1.Columns[i].ReadOnly = true; dataGridView1.Columns[i].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; } } } return(true); }
async private void GetSensorList() { if (await Server.GetSensorList(Global.LoginInfo.user_id, Global.LoginInfo.user_code, CurPage, Global.PageNum)) { dataGridView1.DataSource = Global.SensorList.list; lb_cur.Text = "第" + Global.SensorList.num.page + "页"; maxPageNum = Global.SensorList.num.list_num / Global.PageNum + 1; lb_sum.Text = "共" + maxPageNum + "页"; comboBox1.Items.Clear(); Global.AddComboxNum(comboBox1, maxPageNum); for (int i = 0; i < dataGridView1.Rows.Count; i++) { if (i % 2 == 0) { dataGridView1.Rows[i].DefaultCellStyle.BackColor = System.Drawing.Color.LightBlue; } } dataGridView1.Columns[0].HeaderText = "传感器ID"; dataGridView1.Columns[1].HeaderText = "站点ID"; dataGridView1.Columns[2].HeaderText = "名称"; dataGridView1.Columns[3].HeaderText = "序列码"; dataGridView1.Columns[4].HeaderText = "编号"; dataGridView1.Columns[5].HeaderText = "备注"; for (int i = 0; i < dataGridView1.Columns.Count; i++) { //拉伸列宽来填满表格 dataGridView1.Columns[i].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; } } }
async public Task <bool> ReadUserList(int page) { int x = 1; await Server.GetStationList(); await Server.GetUserList(Global.LoginInfo.user_id, Global.LoginInfo.user_code, page, 100); if (Global.UserList.list == null) { MessageBox.Show("获取用户列表失败,无权限"); return(false); } maxPageNum = (Global.UserList.num.list_num / Convert.ToInt32(Global.UserList.num.page_num)) + 1; // int list_num = Global.ToolsList.list.Count; lb_cur.Text = "第" + page + "页"; lb_sum.Text = "共" + maxPageNum + "页"; maxPageNum--; if (maxPageNum != comboBox1.Items.Count) { Global.AddComboxNum(comboBox1, maxPageNum); } foreach (var user in Global.UserList.list) { user.num = x.ToString(); x++; var k = Global.StationList.Find(t => t.station_id == Convert.ToInt32(user.station_id)); user.station_id = k == null ? "其他" : k.name; switch (user.role) { case "1": user.role = "1|普通专员"; break; case "2": user.role = "2|站点管理员"; break; case "3": user.role = "3|局管理员"; break; default: user.role = "其他"; break; } } dataGridView1.DataSource = Global.UserList.list; dataGridView1.RowHeadersVisible = false; if (Global.UserList.num.list_num > 0) { dataGridView1.Columns[0].HeaderText = "序号"; dataGridView1.Columns[1].HeaderText = "用户姓名"; dataGridView1.Columns[2].HeaderText = "用户生产班组"; dataGridView1.Columns[3].HeaderText = "用户名 (工号)"; dataGridView1.Columns[4].HeaderText = "用户角色"; dataGridView1.Columns[5].HeaderText = "初始密码"; dataGridView1.Columns[6].HeaderText = "站点id标识"; dataGridView1.Columns[7].Visible = false; dataGridView1.Columns[8].Visible = false; for (int i = 0; i < dataGridView1.Columns.Count; i++) { dataGridView1.Columns[i].ReadOnly = true; dataGridView1.Columns[i].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; } for (int i = 0; i < dataGridView1.Rows.Count; i++) { if (i % 2 == 0) { dataGridView1.Rows[i].DefaultCellStyle.BackColor = Color.LightBlue; } var t = dataGridView1.Rows[i].Cells; } } return(true); }
async public Task <bool> TableReceiveList(int cur) { if (await Server.GetReceiveList(Global.LoginInfo.user_id, Global.LoginInfo.user_code, cur, Global.PageNum)) { lb_cur.Text = "第" + Global.ReceiveList.num.page + "页"; maxPageNum = Global.ReceiveList.num.list_num / Global.PageNum + 1; lb_sum.Text = "共" + maxPageNum + "页"; curPage = cur; isInit = true; Global.AddComboxNum(comboBox1, maxPageNum); comboBox1.SelectedIndex = Global.ReceiveList.num.page - 1; isInit = false; //此处不应该改全局变量里的List来改变显示内容 //for (int i = 0; i < Global.ReceiveList.list.Count; i++) //{ // if (Global.ReceiveList.list[i].type == "1") // { // Global.ReceiveList.list[i].return_time = ""; // Global.ReceiveList.list[i].return_user_id = ""; // Global.ReceiveList.list[i].return_user_name = ""; // Global.ReceiveList.list[i].type = "未归还"; // } // else // { // Global.ReceiveList.list[i].type = "已归还"; // } //} dataGridView1.DataSource = Global.ReceiveList.list; for (int i = 0; i < dataGridView1.Rows.Count; i++) { if (i % 2 == 0) { dataGridView1.Rows[i].DefaultCellStyle.BackColor = System.Drawing.Color.LightBlue; } var t = dataGridView1.Rows[i].Cells; var type = t[10].Value as string; if (type == "1")//type { t[10].Style = color_danger; //对value的修改会影响绑定的List,务必注意 t[9].Value = t[7].Value = t[14].Value = t[5].Value = ""; t[10].Value = "未归还"; } else if (type == "2") { //对value的修改会影响绑定的List,务必注意 t[10].Value = "已归还"; if (t[9].Value as string == "1") { t[9].Value = "完好"; } else { t[9].Value = "否"; t[9].Style = color_danger; } } if (t[8].Value as string == "1")//领用时 { t[8].Value = "完好"; } else { t[8].Value = "否"; t[9].Style = color_danger; } } if (dataGridView1.ColumnCount > 0) { dataGridView1.Columns[0].HeaderText = "记录id"; dataGridView1.Columns[1].HeaderText = "工具id"; dataGridView1.Columns[2].HeaderText = "站点id"; dataGridView1.Columns[3].HeaderText = "工作票号id"; dataGridView1.Columns[4].HeaderText = "领用人id"; dataGridView1.Columns[5].HeaderText = "归还人id"; dataGridView1.Columns[6].HeaderText = "领用时间"; dataGridView1.Columns[7].HeaderText = "归还时间"; dataGridView1.Columns[8].HeaderText = "领用时是否完好"; dataGridView1.Columns[9].HeaderText = "归还时是否完好"; dataGridView1.Columns[10].HeaderText = "是否归还"; dataGridView1.Columns[11].HeaderText = "工具名称"; dataGridView1.Columns[12].HeaderText = "工具编号"; dataGridView1.Columns[13].HeaderText = "领用人名称"; dataGridView1.Columns[14].HeaderText = "归还人名称"; dataGridView1.Columns[15].HeaderText = "工作票号"; } for (int i = 0; i < dataGridView1.Columns.Count; i++) { //全部列不可修改 dataGridView1.Columns[i].ReadOnly = true; //拉伸列宽来填满表格 dataGridView1.Columns[i].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; } } return(true); }
async public Task <bool> TestList(int cur) { if (cur <= 0) { cur = 1; } if (await Server.GetTestList(Global.LoginInfo.user_id, Global.LoginInfo.user_code, Global.SelectedTaskId, cur, Global.PageNum)) { if (Global.TestList.list == null) { Global.SelectedTaskId = -1; dataGridView1.DataSource = null; MessageBox.Show("无定期检查记录"); return(true); } maxPageNum = (Global.TestList.num.list_num / Convert.ToInt32(Global.TestList.num.page_num)) + 1; lb_cur.Text = "第" + Global.TestList.num.page + "页"; lb_sum.Text = "共" + maxPageNum + "页"; curPage = cur; if (maxPageNum != comboBox1.Items.Count) { Global.AddComboxNum(comboBox1, maxPageNum); } //await Server.GetStationList(); foreach (var test in Global.TestList.list) { foreach (var msg in test.defect_msg) { switch (msg) { case "true": test.defect_msgs = "完好"; break; case "false": test.defect_msgs = "尚未检测"; break; default: test.defect_msgs += msg + "\r\n"; break; } } } dataGridView1.DataSource = Global.TestList.list; dataGridView1.RowsDefaultCellStyle.WrapMode = DataGridViewTriState.True; dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; dataGridView1.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells; for (int i = 0; i < dataGridView1.Rows.Count; i++) { if (i % 2 == 0) { dataGridView1.Rows[i].DefaultCellStyle.BackColor = Color.LightBlue; } var t = dataGridView1.Rows[i].Cells; } dataGridView1.Columns[0].HeaderText = "检测记录id标识"; dataGridView1.Columns[1].HeaderText = "工具ID"; dataGridView1.Columns[2].HeaderText = "工器具名称"; dataGridView1.Columns[3].HeaderText = "工器具编号"; dataGridView1.Columns[4].HeaderText = "工作票ID"; dataGridView1.Columns[5].HeaderText = "检查时间"; dataGridView1.Columns[6].HeaderText = "类别名称"; dataGridView1.Columns[7].HeaderText = "缺陷"; //dataGridView1.Columns[0].Visible = false; } return(true); }
async public Task <bool> TableToolsList(int cur) { int x = 1; if (cur <= 0) { cur = 1; } if (await Server.GetToolsList(Global.LoginInfo.user_id, Global.LoginInfo.user_code, cur, Global.PageNum)) { maxPageNum = (Global.ToolsList.num.list_num / Convert.ToInt32(Global.ToolsList.num.page_num)) + 1; // int list_num = Global.ToolsList.list.Count; // page = 1; // maxPageNum = (list_num / Global.PageNum) + 1; lb_cur.Text = "第" + Global.ToolsList.num.page + "页"; // var sum = Global.ToolsList.num.list_num / Global.PageNum; // maxPageNum = sum == 0 ? 1 : sum; lb_sum.Text = "共" + maxPageNum + "页"; curPage = cur; if (maxPageNum != comboBox1.Items.Count) { Global.AddComboxNum(comboBox1, maxPageNum); } await Server.GetStationList(); foreach (var Tool in Global.ToolsList.list) { Tool.order = (x + Convert.ToInt32(Global.ToolsList.num.page_num) * (cur - 1)).ToString(); x++; if (Tool.user_id == "0") { Tool.user_id = "无人领用"; } if (Tool.in_depot == "true") { Tool.in_depot = "是"; } else { Tool.in_depot = "否"; } if (Tool.user_name == "false") { Tool.user_name = "无去向(在库)"; } if (Global.StationList.Find(t => t.station_id == Convert.ToInt32(Tool.station_id)) != null) { Tool.station_id = Global.StationList.Find(t => t.station_id == Convert.ToInt32(Tool.station_id)).name + '(' + Tool.station_id + ')'; } else { Tool.station_id = "其他"; } } dataGridView1.DataSource = Global.ToolsList.list; for (int i = 0; i < dataGridView1.Rows.Count; i++) { if (i % 2 == 0) { dataGridView1.Rows[i].DefaultCellStyle.BackColor = Color.LightBlue; } var t = dataGridView1.Rows[i].Cells; if (DateTime.Parse(dataGridView1.Rows[i].Cells[12].Value.ToString()) != null) { if (DateTime.Now > DateTime.Parse(dataGridView1.Rows[i].Cells[12].Value.ToString())) { dataGridView1.Rows[i].DefaultCellStyle.BackColor = Color.Red; } else if ((DateTime.Parse(dataGridView1.Rows[i].Cells[12].Value.ToString()) - DateTime.Now).Days < 30) { dataGridView1.Rows[i].DefaultCellStyle.BackColor = Color.Orange; } } if (DateTime.Parse(dataGridView1.Rows[i].Cells[19].Value.ToString()) != null) { if (DateTime.Now > DateTime.Parse(dataGridView1.Rows[i].Cells[19].Value.ToString())) { dataGridView1.Rows[i].DefaultCellStyle.BackColor = Color.Red; } else if ((DateTime.Parse(dataGridView1.Rows[i].Cells[19].Value.ToString()) - DateTime.Now).Days < 30) { dataGridView1.Rows[i].DefaultCellStyle.BackColor = Color.Orange; } } } // dataGridView1.RowHeadersVisible = false; dataGridView1.Columns[0].HeaderText = "序号"; dataGridView1.Columns[1].HeaderText = "工具标识"; dataGridView1.Columns[2].HeaderText = "传感器标识"; dataGridView1.Columns[3].HeaderText = "站点id标识"; dataGridView1.Columns[4].HeaderText = "科目id标识"; dataGridView1.Columns[5].HeaderText = "领用人id标识"; dataGridView1.Columns[6].HeaderText = "工具名称"; dataGridView1.Columns[7].HeaderText = "工具型号"; dataGridView1.Columns[8].HeaderText = "工具编号"; dataGridView1.Columns[9].HeaderText = "工具类别"; dataGridView1.Columns[10].HeaderText = "出厂日期"; dataGridView1.Columns[11].HeaderText = "购买日期"; dataGridView1.Columns[12].HeaderText = "试验日期"; dataGridView1.Columns[13].HeaderText = "试验周期(月)"; dataGridView1.Columns[14].HeaderText = "生命周期(月)"; dataGridView1.Columns[15].HeaderText = "生产厂商"; //dataGridView1.Columns[15].HeaderText = "是否删除"; dataGridView1.Columns[16].HeaderText = "传感器名称"; dataGridView1.Columns[17].HeaderText = "科目名称"; dataGridView1.Columns[18].HeaderText = "下次试验日期"; dataGridView1.Columns[19].HeaderText = "报废日期"; dataGridView1.Columns[20].HeaderText = "是否在库"; dataGridView1.Columns[21].HeaderText = "去向"; for (int i = 0; i < dataGridView1.Columns.Count; i++) { //全部列不可修改 dataGridView1.Columns[i].ReadOnly = true; //拉伸列宽来填满表格 dataGridView1.Columns[i].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; } } return(true); }
async public Task <bool> ReadyTestToolsList() { if (await Server.GetReadyTestTools(Global.LoginInfo.user_id, Global.LoginInfo.user_code)) { // maxPageNum = (Global.ToolsList.num.list_num / Convert.ToInt32(Global.ToolsList.num.page_num)) + 1; int list_num = Global.ReadyTestTools.Count; page = 1; maxPageNum = (list_num / 100) + 1; lb_cur.Text = "第" + page + "页"; // var sum = Global.ToolsList.num.list_num / Global.PageNum; // maxPageNum = sum == 0 ? 1 : sum; lb_sum.Text = "共" + maxPageNum + "页"; // curPage = cur; if (maxPageNum != comboBox1.Items.Count) { Global.AddComboxNum(comboBox1, maxPageNum); } //foreach (var Tool in Global.ReadyTestTools) //{ // if (Tool.user_id == "0") // { // Tool.user_id = "无人领用"; // } // if (Tool.in_depot == "true") // { // Tool.in_depot = "是"; // } // else // { // Tool.in_depot = "否"; // } // if (Tool.user_name == "false") // { // Tool.user_name = "无去向(在库)"; // } // if (Global.StationList.Find(t => t.station_id == Convert.ToInt32(Tool.station_id)) != null) // { // Tool.station_id = Global.StationList.Find(t => t.station_id == Convert.ToInt32(Tool.station_id)).name + '(' + Tool.station_id + ')'; // } // else // { // Tool.station_id = "其他"; // } //} dataGridView1.DataSource = Global.ReadyTestTools; for (int i = 0; i < dataGridView1.Rows.Count; i++) { if (i % 2 == 0) { dataGridView1.Rows[i].DefaultCellStyle.BackColor = Color.LightBlue; } var t = dataGridView1.Rows[i].Cells; } if (Global.ReadyTestTools.Count >= 0) { dataGridView1.Columns[0].HeaderText = "工具标识"; dataGridView1.Columns[1].HeaderText = "传感器标识"; dataGridView1.Columns[2].HeaderText = "站点id标识"; dataGridView1.Columns[3].HeaderText = "科目id标识"; dataGridView1.Columns[4].HeaderText = "领用人id标识"; dataGridView1.Columns[5].HeaderText = "工具名称"; dataGridView1.Columns[6].HeaderText = "工具型号"; dataGridView1.Columns[7].HeaderText = "工具编号"; dataGridView1.Columns[8].HeaderText = "工具类别"; dataGridView1.Columns[9].HeaderText = "出厂日期"; dataGridView1.Columns[10].HeaderText = "购买日期"; dataGridView1.Columns[11].HeaderText = "试验日期"; dataGridView1.Columns[12].HeaderText = "试验周期(月)"; dataGridView1.Columns[13].HeaderText = "生命周期(月)"; dataGridView1.Columns[14].HeaderText = "生产厂商"; // dataGridView1.Columns[15].HeaderText = "是否删除"; dataGridView1.Columns[15].HeaderText = "传感器名称"; dataGridView1.Columns[16].HeaderText = "科目名称"; dataGridView1.Columns[17].HeaderText = "下次试验日期"; dataGridView1.Columns[18].HeaderText = "报废日期"; dataGridView1.Columns[19].HeaderText = "是否在库"; dataGridView1.Columns[20].HeaderText = "去向"; for (int i = 0; i < dataGridView1.Columns.Count; i++) { dataGridView1.Columns[i].ReadOnly = true; dataGridView1.Columns[i].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; } } } return(true); }
async public Task <bool> GetTaskList(int cur) { if (SelectedWorkTypeId == null) { MessageBox.Show("请选择一个工作任务"); return(false); } if (cur <= 0) { cur = 1; } if (await Server.GetTaskList(Global.LoginInfo.user_id, Global.LoginInfo.user_code, cur, Global.PageNum, SelectedWorkTypeId)) { if (Global.TaskList.list == null) { dataGridView1.DataSource = null; MessageBox.Show("无工作票记录"); return(false); } maxPageNum = (Global.TaskList.num.list_num / Convert.ToInt32(Global.TaskList.num.page_num)) + 1; // int list_num = Global.ToolsList.list.Count; // page = 1; // maxPageNum = (list_num / Global.PageNum) + 1; lb_cur.Text = "第" + Global.TaskList.num.page + "页"; // var sum = Global.ToolsList.num.list_num / Global.PageNum; // maxPageNum = sum == 0 ? 1 : sum; lb_sum.Text = "共" + maxPageNum + "页"; if (maxPageNum != comboBox2.Items.Count) { Global.AddComboxNum(comboBox2, maxPageNum); } dataGridView1.DataSource = Global.TaskList.list; if (Global.TaskList.list.Count > 0) { dataGridView1.Columns[0].HeaderText = "事件编号ID"; dataGridView1.Columns[1].HeaderText = "工作类型"; dataGridView1.Columns[2].HeaderText = "作业票单号"; dataGridView1.Columns[3].HeaderText = "生产班组"; dataGridView1.Columns[4].HeaderText = "创建时间"; dataGridView1.Columns[5].HeaderText = "站点"; dataGridView1.Columns[6].HeaderText = "工作是否完成"; dataGridView1.Columns[7].HeaderText = "备注"; //dataGridView1.Columns[5].Visible = false; for (int i = 0; i < dataGridView1.Columns.Count; i++) { dataGridView1.Columns[i].ReadOnly = true; dataGridView1.Columns[i].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; } for (int i = 0; i < dataGridView1.Rows.Count; i++) { if (i % 2 == 0) { dataGridView1.Rows[i].DefaultCellStyle.BackColor = Color.LightBlue; } var t = dataGridView1.Rows[i].Cells; switch (t[6].Value.ToString()) { case "1": t[6].Value = "未完成"; break; case "2": t[6].Value = "已完成"; break; default: break; } } } } return(true); }