Example #1
0
        private void SaveToFile()
        {
            string strProcedureName = $"{className}.{MethodBase.GetCurrentMethod().Name}";

            try
            {
                FileStream fs   = new FileStream(fileMaterialPreparation, FileMode.Create);
                byte[]     data = Encoding.UTF8.GetBytes(mps.ToJSON());
                fs.Write(data, 0, data.Length);
                fs.Flush();
                fs.Close();
            }
            catch (Exception error)
            {
                WriteLog.Instance.Write(error.Message, strProcedureName);
                WriteLog.Instance.Write(error.StackTrace, strProcedureName);
            }
        }
Example #2
0
        private void btnBegin_Click(object sender, EventArgs e)
        {
            string strProcedureName = $"{className}.{MethodBase.GetCurrentMethod().Name}";

            if (currentFurnace == null)
            {
                XtraMessageBox.Show(
                    "程序问题,请联系开发人员予以解决!",
                    strProcedureName,
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
                return;
            }

            #region 数据检验
            if (currentFurnace.OperatorCode.Trim() == "")
            {
                XtraMessageBox.Show(
                    "请刷卡记录您的身份!",
                    "系统信息",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
                edtOperatorCode.Focus();
                return;
            }
            if (currentFurnace.PWOs.Count <= 0)
            {
                if (XtraMessageBox.Show(
                        "没有添加工单信息!\n    如果该炉次是试样,请忽略提示信息," +
                        "点击“Yes”按钮,否则请点击“No”按钮",
                        "提问",
                        MessageBoxButtons.YesNo,
                        MessageBoxIcon.Question,
                        MessageBoxDefaultButton.Button2) == DialogResult.No)
                {
                    XtraMessageBox.Show(
                        "还没有添加工单信息,请至少增加一个生产工单!",
                        "系统信息",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error);
                    btnPWONew.Focus();
                    return;
                }
            }
            #endregion

            #region 记录生产开始
            WriteLog.Instance.WriteBeginSplitter(strProcedureName);
            try
            {
                int    errCode     = 0;
                string errText     = "";
                string batchNumber = "";

                IRAPMESBatchClient.Instance.usp_SaveFact_BatchProductionStart_QuenchAndTemper(
                    IRAPUser.Instance.CommunityID,
                    stationInfo.T216LeafID,
                    stationInfo.T107LeafID,
                    currentFurnace.OperatorCode,
                    0,
                    GenerateBatchProductionStartXML(currentFurnace.PWOs),
                    IRAPUser.Instance.SysLogID,
                    ref batchNumber,
                    out errCode,
                    out errText);
                WriteLog.Instance.Write(
                    string.Format("({0}){1}", errCode, errText),
                    strProcedureName);
                if (errCode != 0)
                {
                    XtraMessageBox.Show(
                        string.Format("在生产开始时发生错误:[{0}]", errText),
                        "系统信息",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error);
                    return;
                }
                else
                {
                    currentFurnace.BatchNumber = batchNumber;
                }
            }
            finally
            {
                WriteLog.Instance.WriteEndSplitter(strProcedureName);
            }
            #endregion

            #region 生产开始成功后
            currentFurnace.BatchStartDate = DateTime.Now;
            currentFurnace.PrdtStatus     = ProductionStatus.Busy;

            batchNos.Add(currentFurnace);
            ImageListBoxItem item = ilstBatchNos.SelectedItem as ImageListBoxItem;
            item.Description = currentFurnace.BatchNumber;

            InitFurnaceInfo(currentFurnace);

            ilstBatchNos.Items.Add(new FurnaceInfo(), -1);

            // 从备料列表中删除已经开始生产的备料
            if (currentFurnace.MPDescription != "")
            {
                TMaterialPreparationInfos mps =
                    LoadFromFile <TMaterialPreparationInfos>(tempMaterialPreparationFile);
                for (int i = 0; i < mps.Count; i++)
                {
                    if (mps.Items[i].Title == currentFurnace.MPDescription)
                    {
                        mps.Items.RemoveAt(i);
                        break;
                    }
                }
                SaveToFile(tempMaterialPreparationFile, mps.ToJSON());
            }
            #endregion
        }