示例#1
0
 public ModifyDemarcateToolForm(DemarcateTools tools)
 {
     demarcateTools = tools;
     InitializeComponent();
     dtpDemarcateDate.Format       = DateTimePickerFormat.Custom;
     dtpDemarcateDate.CustomFormat = "yyyy-MM-dd";
 }
示例#2
0
        public DemarcateTools GetOneDemarcateTool(string serialNum)
        {
            string           sql            = $"select * from DemarcateTools where SerialNum='{serialNum}' and Status!='{DemarcateStatusDeclare.OffGrade}'";
            SQLiteDataReader reader         = SQLHelper.ReadTableBySql(sql);
            DemarcateTools   demarcateTools = new DemarcateTools();

            if (!reader.HasRows)
            {
                reader.Close();
                return(null);
            }
            if (reader.Read())
            {
                try
                {
                    demarcateTools = new DemarcateTools
                    {
                        SerialNum = reader["SerialNum"].ToString(),
                        Cycle     = Convert.ToInt32(reader["Cycle"]),
                        LastTime  = Convert.ToDateTime(reader["LastTime"].ToString()).ToString("yyyy-MM-dd"),
                        NextTime  = Convert.ToDateTime(reader["NextTime"].ToString()).ToString("yyyy-MM-dd"),
                        Status    = reader["Status"].ToString()
                    };
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"GetOneDemarcateTool failed, error message is: {ex.Message}");
                }
            }
            reader.Close();
            return(demarcateTools);
        }
示例#3
0
 private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     if (dataGridView1.Columns[e.ColumnIndex] is DataGridViewButtonColumn && e.RowIndex > -1)
     {
         DataGridViewButtonCell btnCell = dataGridView1.CurrentCell as DataGridViewButtonCell;
         if (btnCell != null)
         {
             DemarcateTools          demarcateTools          = getOneDemarcateToolFromGrid();
             ModifyDemarcateToolForm modifyDemarcateToolForm = new ModifyDemarcateToolForm(demarcateTools);
             modifyDemarcateToolForm.Text = "修改";
             if (modifyDemarcateToolForm.ShowDialog() == DialogResult.OK)
             {
                 refreshDataViewGrid();
             }
         }
     }
 }
示例#4
0
        private void btnFinish_Click(object sender, EventArgs e)
        {
            DemarcateTools demarcateTools = demarcateRecordManage.getOneDemarcateToolBySerialNum(txtSerialNum.Text.Trim());

            try
            {
                DemarcateHistory demarcateHistory = new DemarcateHistory
                {
                    DemarcateNum  = qRCodePrintForm.demarcateRecords.DemarcateNum,
                    SerialNum     = qRCodePrintForm.demarcateRecords.SerialNum,
                    Cycle         = demarcateTools.Cycle,
                    LastTime      = demarcateTools.LastTime,
                    DemarcateTime = DateTime.Now.ToString("yyyy-MM-dd"),
                    NextTime      = DateTime.Now.AddDays(demarcateTools.Cycle).ToString("yyyy-MM-dd"),
                    CheckMan      = qRCodePrintForm.demarcateRecords.Examinant
                };
                int affected = demarcateRecordManage.AddDemarcateHistory(demarcateHistory);
                if (affected < 1)
                {
                    throw new Exception("系统出现错误,请重新校准!");
                }
                string sql = $"update DemarcateTools set LastTime='{demarcateHistory.DemarcateTime}',NextTime='{demarcateHistory.NextTime}' where SerialNum='{demarcateDataUploadForm.SerialNum}'";
                affected = demarcateRecordManage.UpdateOneDemarcateToolBySql(sql);
                if (affected < 1)
                {
                    throw new Exception("系统出现错误,请重新校准!");
                }
                //更新维修次数
                ToolsInfo toolsInfo   = toolsInfoManage.QueryOneToolsInfo(qRCodePrintForm.demarcateRecords.SerialNum);
                int       repairTimes = toolsInfo.RepairTimes++;
                sql      = $"update ToolsInfo set RepairTimes={repairTimes} where SerialNum='{toolsInfo.SerialNum}'";
                affected = toolsInfoManage.UpdateToolsInfoBySql(sql);
                if (affected < 1)
                {
                    throw new Exception("系统出现错误,请重新校准!");
                }
                MessageBox.Show($"工具{txtSerialNum.Text.Trim()}校准完成!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            IsdemarcateFinsih = true;
        }
示例#5
0
 public string AddOneDemarcateTool(DemarcateTools demarcateTools)
 {
     try
     {
         if (demarcateRecordService.IsToolExistInDemarcateTools(demarcateTools.SerialNum))
         {
             return("记录已经存在!");
         }
         int affectedRow = demarcateRecordService.InsertDemarcateTools2Db(demarcateTools);
         if (affectedRow < 1)
         {
             return("添加数据库失败,数据库操作失败");
         }
         return("提交成功");
     }
     catch
     {
         return("error");
     }
 }
示例#6
0
        private DemarcateRecords GetDemarcateRecords()
        {
            ToolsInfo      toolsInfo      = toolsInfoManage.QueryOneToolsInfo(txtSerialNum.Text.Trim());
            DemarcateTools demarcateTools = demarcateRecordManage.getOneDemarcateToolBySerialNum(txtSerialNum.Text.Trim());

            if (toolsInfo == null || demarcateTools == null)
            {
                MessageBox.Show("工具序列号有误!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(null);
            }
            string nextTime = DateTime.Now.AddDays(demarcateTools.Cycle).ToString("d");

            return(new DemarcateRecords
            {
                DemarcateNum = "",
                SerialNum = toolsInfo.SerialNum,
                WorkStation = toolsInfo.Workstation,
                Validity = nextTime,
                Examinant = "",
                CheckTime = DateTime.Now.ToString("d")
            });
        }
示例#7
0
        private void btnNextStep_Click(object sender, EventArgs e)
        {
            if (pageNum == 1)
            {
                if (txtSerialNum.Text.Trim() == "")
                {
                    MessageBox.Show("序列号不能为空,请输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                if (cmbCheckMan.Text.Trim() == "")
                {
                    MessageBox.Show("校准检查员不能为空,请输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                if (!isToolsExist(txtSerialNum.Text.Trim()))
                {
                    if (!toolsInfoManage.IsToolExistInDb(txtSerialNum.Text.Trim()))
                    {
                        MessageBox.Show("仓库中不存在序列号为" + txtSerialNum.Text.Trim() + "的工具,请先录入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    if (MessageBox.Show("工具序列号不在校准计划中,是否继续?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.Cancel)
                    {
                        return;
                    }
                }
                try
                {
                    checkManManage.AddOneName(cmbCheckMan.Text.Trim());
                }
                catch (Exception ex)
                {
                    Console.Write("add name fail", ex.Message);
                }
            }
            pageNum++;
            DemarcateTools demarcateTools = demarcateRecordManage.getOneDemarcateToolBySerialNum(txtSerialNum.Text.Trim());

            if (pageNum == 2)
            {
                if (Convert.ToDateTime(demarcateTools.NextTime) > DateTime.Now)
                {
                    pageNum--;
                    if (MessageBox.Show($"该工具的预计校准日期为{demarcateTools.NextTime},确定要继续校准吗?", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information) == DialogResult.Cancel)
                    {
                        return;
                    }
                }

                btnNextStep.Text = "下一步";
                //btnLastStep.Visible = true;
                btnNextStep.Enabled = true;
                btnLastStep.Enabled = true;
                foreach (Control c in panel2.Controls)
                {
                    c.Visible = false;
                }
                demarcateDataUploadForm.FormBorderStyle = FormBorderStyle.None;
                demarcateDataUploadForm.Dock            = DockStyle.Fill;
                demarcateDataUploadForm.TopLevel        = false;
                demarcateDataUploadForm.SerialNum       = txtSerialNum.Text.Trim();
                demarcateDataUploadForm.CheckMan        = cmbCheckMan.Text.Trim();
                panel2.Controls.Add(demarcateDataUploadForm);
                demarcateDataUploadForm.Show();
            }
            if (pageNum == 3)
            {
                if (!demarcateDataUploadForm.CalcDemarcateResult())
                {
                    pageNum--;
                    return;
                }
                if (!demarcateDataUploadForm.DemarcateResult)
                {
                    pageNum--;
                    demarcateDataUploadForm.setResultLabel("校准结果:不合格");
                    if (MessageBox.Show("校准结果不合格,是否重新校准?\n点击确定将会清除校准数据\n点击取消将会把工具标记为待修", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                    {
                        demarcateDataUploadForm.reDemarcateActon();
                        demarcateDataUploadForm.setResultLabel("校准结果:");
                    }
                    else
                    {
                        MaintainManageInfo maintainManageInfo = new MaintainManageInfo
                        {
                            ToolSerialName = txtSerialNum.Text.Trim(),
                            ToolModeName   = toolsInfoManage.QueryOneToolsInfo(txtSerialNum.Text.Trim()).Model,
                            SendFixTime    = DateTime.Now.ToString("yyyy-MM-dd"),
                            Detail         = DemarcateStatusDeclare.OffGrade
                        };
                        string msg = maintainInfoManage.RegisterBreakTool(maintainManageInfo);
                        if (!msg.Contains("成功"))
                        {
                            MessageBox.Show($"移至待修出错!原因:{msg}", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    return;
                }
                btnNextStep.Text = "进入下一个工具校准";
                //btnNextStep.Location = new Point(btnNextStep.Location.X -90, btnNextStep.Location.Y);
                btnNextStep.Enabled = true;
                //btnLastStep.Visible = true;
                btnLastStep.Enabled = true;
                btnFinsih.Visible   = true;
                btnFinsih.Location  = new Point(btnNextStep.Location.X - btnFinsih.Width - 15, btnNextStep.Location.Y);
                panel3.Controls.Add(btnFinsih);
                btnFinsih.BringToFront();
                foreach (Control c in panel2.Controls)
                {
                    c.Visible = false;
                }
                qRCodePrintForm.demarcateRecords = demarcateDataUploadForm.GetDemarcateRecords();
                qRCodePrintForm.FormBorderStyle  = FormBorderStyle.None;
                qRCodePrintForm.Dock             = DockStyle.Fill;
                //qRCodePrintForm.Location = new Point(panel2.Location.X + (panel2.Width - qRCodePrintForm.Width)/2, 0);
                qRCodePrintForm.Width    = panel2.Width;
                qRCodePrintForm.TopLevel = false;
                panel2.Controls.Add(qRCodePrintForm);
                qRCodePrintForm.Show();

                //Graphics g = gbStep.CreateGraphics();
            }
            if (pageNum == 4)
            {
                if (IsdemarcateFinsih)
                {
                    toolStripButton2_Click(null, null);
                    return;
                }
                try
                {
                    DemarcateHistory demarcateHistory = new DemarcateHistory
                    {
                        DemarcateNum  = qRCodePrintForm.demarcateRecords.DemarcateNum,
                        SerialNum     = qRCodePrintForm.demarcateRecords.SerialNum,
                        Cycle         = demarcateTools.Cycle,
                        LastTime      = demarcateTools.LastTime,
                        DemarcateTime = DateTime.Now.ToString("yyyy-MM-dd"),
                        NextTime      = DateTime.Now.AddDays(demarcateTools.Cycle).ToString("yyyy-MM-dd"),
                        CheckMan      = qRCodePrintForm.demarcateRecords.Examinant
                    };
                    int affected = demarcateRecordManage.AddDemarcateHistory(demarcateHistory);
                    if (affected < 1)
                    {
                        throw new Exception("系统出现错误,请重新校准!");
                    }
                    string sql = $"update DemarcateTools set LastTime='{demarcateHistory.DemarcateTime}',NextTime='{demarcateHistory.NextTime}' where SerialNum='{demarcateDataUploadForm.SerialNum}'";
                    affected = demarcateRecordManage.UpdateOneDemarcateToolBySql(sql);
                    if (affected < 1)
                    {
                        throw new Exception("系统出现错误,请重新校准!");
                    }
                    //更新维修次数
                    ToolsInfo toolsInfo   = toolsInfoManage.QueryOneToolsInfo(qRCodePrintForm.demarcateRecords.SerialNum);
                    int       repairTimes = toolsInfo.RepairTimes++;
                    sql      = $"update ToolsInfo set RepairTimes={repairTimes} where SerialNum='{toolsInfo.SerialNum}'";
                    affected = toolsInfoManage.UpdateToolsInfoBySql(sql);
                    if (affected < 1)
                    {
                        throw new Exception("系统出现错误,请重新校准!");
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                toolStripButton2_Click(null, null);
            }
        }
示例#8
0
 public int InsertDemarcateTools2Db(DemarcateTools demarcateTools)
 {
     return(SQLHelper.InsertValuesByStruct("DemarcateTools", demarcateTools));
 }
示例#9
0
 public int UpdateOneDemarcateTools(DemarcateTools demarcateTools)
 {
     return(SQLHelper.UpdateValuesByStruct("DemarcateTools", demarcateTools, new string[] { "SerialNum" }, new string[] { demarcateTools.SerialNum }));
 }
示例#10
0
 public int DeleteOneDemarcateTools(DemarcateTools demarcateTools)
 {
     return(SQLHelper.DeleteValuesAND("DemarcateTools", new string[] { "SerialNum" }, new string[] { demarcateTools.SerialNum }, new string[] { "=" }));
 }
示例#11
0
 public int UpdateOneDemarcateTool(DemarcateTools demarcateTools)
 {
     return(demarcateRecordService.UpdateOneDemarcateTools(demarcateTools));
 }
示例#12
0
 public int DeleteOneDemarcateTools(DemarcateTools demarcateTools)
 {
     return(demarcateRecordService.DeleteOneDemarcateTools(demarcateTools));
 }