/// <summary>
        /// 窗体加载事件
        /// </summary>
        private void FrmProductionScheduleBom_InputSingle_Load(object sender, EventArgs e)
        {
            try
            {
                bomDAO.QueryDesignBomList(designBomListTable, bomListAutoId, psBomAutoId);
                if (designBomListTable.Rows.Count == 0)
                {
                    MessageHandler.ShowMessageBox("未查询到设计Bom的信息,请重新操作。");
                    this.DialogResult = DialogResult.Cancel;
                    this.Close();
                    return;
                }

                textPbBomNo.Text    = DataTypeConvert.GetString(designBomListTable.Rows[0]["PbBomNo"]);
                textMaterielNo.Text = DataTypeConvert.GetString(designBomListTable.Rows[0]["LevelMaterielNo"]);
                if (textMaterielNo.Text.Trim() == "")
                {
                    textMaterielNo.Text = DataTypeConvert.GetString(designBomListTable.Rows[0]["MaterielNo"]);
                }
                double remainQty      = DataTypeConvert.GetDouble(designBomListTable.Rows[0]["RemainQty"]);
                double psBomRemainQty = DataTypeConvert.GetDouble(designBomListTable.Rows[0]["PSBomRemainQty"]);
                textRemainQty.Text   = DataTypeConvert.GetString(remainQty);
                textOKRemainQty.Text = DataTypeConvert.GetString(psBomRemainQty);
                bool hasLevel = DataTypeConvert.GetBoolean(designBomListTable.Rows[0]["HasLevel"]);

                int isBuy = 1;
                if (DataTypeConvert.GetInt(designBomListTable.Rows[0]["IsMaterial"]) == 2)
                {
                    DataTable wpTable = new DataTable();
                    bomDAO.QueryWorkProcess(wpTable, textMaterielNo.Text, "");
                    if (wpTable.Rows.Count == 0)
                    {
                        MessageHandler.ShowMessageBox("没有查询到当前要操作的基本工序信息,请重新操作。");
                        this.DialogResult = DialogResult.Cancel;
                        this.Close();
                        return;
                    }
                    isBuy = DataTypeConvert.GetInt(wpTable.Rows[0]["IsBuy"]);
                    labMaterielNo.Text = "工序编号";
                    labDesc.Text       = "(注:基本工序信息如果设定为不购买,则不能修改上面的购买方式)";
                }
                else
                {
                    DataTable partsCodeTable = commonDAO.QuerySinglePartsCode(textMaterielNo.Text);
                    if (partsCodeTable.Rows.Count == 0)
                    {
                        MessageHandler.ShowMessageBox("没有查询到当前要操作的物料基础信息,请重新操作。");
                        this.DialogResult = DialogResult.Cancel;
                        this.Close();
                        return;
                    }
                    isBuy = DataTypeConvert.GetInt(partsCodeTable.Rows[0]["IsBuy"]);
                }

                if (psBomAutoId == 0)
                {
                    if (psBomRemainQty >= remainQty)
                    {
                        MessageHandler.ShowMessageBox("已经计划的数量大于或者等于设计Bom的数量,不可以再输入生产计划信息,请重新操作。");
                        this.DialogResult = DialogResult.Cancel;
                        this.Close();
                        return;
                    }

                    if (psBomRemainQty == 0)
                    {
                        spinRemainQty.Value = DataTypeConvert.GetDecimal(remainQty);
                        spinRemainQty.Properties.MaxValue = DataTypeConvert.GetDecimal(remainQty);
                        spinRemainQty.Properties.MinValue = 0;
                    }
                    else
                    {
                        spinRemainQty.Value = DataTypeConvert.GetDecimal(remainQty - psBomRemainQty);
                        spinRemainQty.Properties.MaxValue = DataTypeConvert.GetDecimal(remainQty - psBomRemainQty);
                        spinRemainQty.Properties.MinValue = 0;
                    }

                    if (isBuy == 0)
                    {
                        radioType.SelectedIndex = 1;
                        radioType.ReadOnly      = true;
                    }
                    else
                    {
                        radioType.SelectedIndex = 0;
                        radioType.ReadOnly      = false;
                    }

                    datePlanDate.DateTime = BaseSQL.GetServerDateTime().Date.AddDays(14);

                    labLevel.Visible         = hasLevel;
                    radioLevel.Visible       = hasLevel;
                    radioLevel.SelectedIndex = 0;
                }
                else
                {
                    DataTable psBomTable = bomDAO.QueryProductionScheduleBom(psBomAutoId);
                    //int isall = DataTypeConvert.GetInt(designBomListTable.Rows[0]["IsAll"]);
                    //radioType.ReadOnly = false;
                    //radioType.SelectedIndex = isall == 1 ? 0 : 1;

                    radioType.SelectedIndex = DataTypeConvert.GetInt(psBomTable.Rows[0]["IsBuy"]) == 1 ? 0 : 1;
                    spinRemainQty.Value     = DataTypeConvert.GetDecimal(psBomTable.Rows[0]["RemainQty"]);
                    if (spinRemainQty.Value < DataTypeConvert.GetDecimal(remainQty - psBomRemainQty))
                    {
                        spinRemainQty.Value = DataTypeConvert.GetDecimal(remainQty - psBomRemainQty);
                    }
                    spinRemainQty.Properties.MaxValue = DataTypeConvert.GetDecimal(remainQty - psBomRemainQty);
                    //spinRemainQty.ReadOnly = isall == 1;

                    if (isBuy == 0)
                    {
                        radioType.ReadOnly = true;
                    }
                    else
                    {
                        radioType.ReadOnly = false;
                    }

                    datePlanDate.DateTime = DataTypeConvert.GetDateTime(psBomTable.Rows[0]["PlanDate"]);

                    labLevel.Visible         = false;
                    radioLevel.Visible       = false;
                    radioLevel.SelectedIndex = 0;
                }
            }
            catch (Exception ex)
            {
                ExceptionHandler.HandleException(this.Text + "--窗体加载事件错误。", ex);
            }
        }