Exemplo n.º 1
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;
        }
Exemplo n.º 2
0
        //excel operation
        public string ExportSingleData2Excel(string filePath, DemarcateHistory demarcateHistory)
        {
            int affected = 0;

            try
            {
                affected = demarcateRecordService.CreateDemarcateHistoryExcelTable(filePath);
                //if (affected < 1) return "创建导出文件失败";
            }catch (Exception ex)
            {
                Console.WriteLine($"CreateMaintainManageInfoExcelTable fail: {ex.Message}");
            }
            affected = demarcateRecordService.InsertDemarcateHistory2ExcelTable(filePath, demarcateHistory);
            if (affected < 1)
            {
                return("导出数据失败1");
            }
            return("导出数据成功");
        }
Exemplo n.º 3
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);
            }
        }
Exemplo n.º 4
0
 public int InsertDemarcateHistory(DemarcateHistory demarcateHistory)
 {
     return(SQLHelper.InsertValuesByStruct("DemarcateHistory", demarcateHistory));
 }
Exemplo n.º 5
0
 public int AddDemarcateHistory(DemarcateHistory demarcateHistory)
 {
     return(demarcateRecordService.InsertDemarcateHistory(demarcateHistory));
 }