Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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);
        }