コード例 #1
0
        /// <summary>
        /// Checks mandatory fields
        /// </summary>
        /// <returns></returns>
        private bool CheckMandatory()
        {
            if (CastingMachineFurnaceCode_txt.Text == string.Empty)
            {
                messageData = new MessageData("mmce00002", Properties.Resources.mmce00002, CastingMachineFurnaceCode_lbl.Text);
                popUpMessage.Warning(messageData, Text);

                CastingMachineFurnaceCode_txt.Focus();

                return(false);
            }

            if (CastingMachineFurnaceName_txt.Text == string.Empty)
            {
                messageData = new MessageData("mmce00002", Properties.Resources.mmce00002, CastingMachineFurnaceName_lbl.Text);
                popUpMessage.Warning(messageData, Text);

                CastingMachineFurnaceName_txt.Focus();

                return(false);
            }

            if (Equipment_cmb.Text == string.Empty || Equipment_cmb.SelectedIndex < 0)
            {
                messageData = new MessageData("mmce00002", Properties.Resources.mmce00002, Equipment_lbl.Text);
                popUpMessage.Warning(messageData, Text);

                Equipment_cmb.Focus();

                return(false);
            }

            return(true);
        }
コード例 #2
0
        /// <summary>
        /// inserts new record
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Ok_btn_Click(object sender, EventArgs e)
        {
            CastingMachineFurnaceVo inVo = new CastingMachineFurnaceVo();
            var sch = StringCheckHelper.GetInstance();

            if (CheckMandatory() == true)
            {
                if (string.IsNullOrEmpty(CastingMachineFurnaceCode_txt.Text) || string.IsNullOrEmpty(CastingMachineFurnaceName_txt.Text))
                {
                    messageData = new MessageData("mmce00003", Properties.Resources.mmce00003);
                    logger.Info(messageData);
                    popUpMessage.ConfirmationOkCancel(messageData, Text);

                    if (string.IsNullOrEmpty(CastingMachineFurnaceCode_txt.Text))
                    {
                        CastingMachineFurnaceCode_txt.Focus();
                    }
                    else if (string.IsNullOrEmpty(CastingMachineFurnaceName_txt.Text))
                    {
                        CastingMachineFurnaceName_txt.Focus();
                    }
                    return;
                }
                inVo.CastingMachineFurnaceCode = CastingMachineFurnaceCode_txt.Text.Trim();

                inVo.CastingMachineFurnaceName = CastingMachineFurnaceName_txt.Text.Trim();

                inVo.EquipmentId = Convert.ToInt32(Equipment_cmb.SelectedValue.ToString());

                inVo.RegistrationUserCode = UserData.GetUserData().UserCode;

                //inVo.RegistrationDateTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");

                inVo.FactoryCode = UserData.GetUserData().FactoryCode;

                if (string.Equals(mode, CommonConstants.MODE_ADD))
                {
                    CastingMachineFurnaceVo checkVo = DuplicateCheck(inVo);

                    if (checkVo != null && checkVo.AffectedCount > 0)
                    {
                        messageData = new MessageData("mmce00001", Properties.Resources.mmce00001, CastingMachineFurnaceCode_lbl.Text + " : " + CastingMachineFurnaceCode_txt.Text);
                        logger.Info(messageData);
                        popUpMessage.ConfirmationOkCancel(messageData, Text);

                        return;
                    }
                }

                try
                {
                    if (string.Equals(mode, CommonConstants.MODE_ADD))
                    {
                        CastingMachineFurnaceVo outVo = (CastingMachineFurnaceVo)base.InvokeCbm(new AddCastingMachineFurnaceMasterMntCbm(), inVo, false);

                        IntSuccess = outVo.AffectedCount;
                    }
                    else if (mode.Equals(CommonConstants.MODE_UPDATE))
                    {
                        inVo.CastingMachineFurnaceId = updateData.CastingMachineFurnaceId;

                        CastingMachineFurnaceVo outVo = (CastingMachineFurnaceVo)base.InvokeCbm(new UpdateCastingMachineFurnaceMasterMntCbm(), inVo, false);

                        IntSuccess = outVo.AffectedCount;
                    }
                }
                catch (Framework.ApplicationException exception)
                {
                    popUpMessage.ApplicationError(exception.GetMessageData(), Text);
                    logger.Error(exception.GetMessageData());
                    return;
                }

                if ((IntSuccess > 0) || (IntSuccess == 0))
                {
                    this.Close();
                }
            }
        }