Exemplo n.º 1
0
        private void SetCheckin()
        {
            bool editable   = true;
            bool miFinished = false;

            string        sql        = $@"
                SELECT LTRIM(RTRIM(allow_edit_flag)) editable
                FROM data0050 
                WHERE customer_part_number = '{jobName}'
                ";
            SqlDataReader dataReader = DBHelper.GetDataReader(sql);

            while (dataReader.Read())
            {
                if (dataReader["editable"].ToString() == "N")
                {
                    editable = false;
                    break;
                }
            }

            sql = $@"
                SELECT
	                LTRIM(RTRIM(MI完成知会时间)) mi_time,
	                LTRIM(RTRIM(BOM表完成知会时间)) bom_time
                FROM gc_data001 
                WHERE 生产部件 = '{jobName}'
                ";

            dataReader = DBHelper.GetDataReader(sql);
            while (dataReader.Read())
            {
                if (dataReader["mi_time"].ToString() != "")
                {
                    miFinished = true;
                    break;
                }
            }

            if (!editable && miFinished)
            {
                MessageBox.Show("此料号ERP已暂停编辑且MI已审核!\n\n修改后必须解锁并重新上传!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (!editable)
            {
                MessageBox.Show("此料号ERP已暂停编辑!\n\n修改后必须解锁并重新上传!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (miFinished)
            {
                MessageBox.Show("此料号MI已审核!\n\n修改后必须解锁并重新上传!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            if (job.NeedRollToLatest())
            {
                jobManager.SaveJob(job);
                appManager.RollAllToLatest(job);
                if (appManager.ErrorStatus() > 0)
                {
                    MessageBox.Show("Checkout时出错了,以下为错误详细信息!\n" + appManager.ErrorMessage());
                }
            }

            appManager.CheckOutAll(job, "");
            if (appManager.ErrorStatus() > 0)
            {
                MessageBox.Show("Checkout时出错了,以下为错误详细信息!\n" + appManager.ErrorMessage());
            }
            jobManager.CloseJob(job);
            jobManager.OpenJob(jobName);
        }