Exemple #1
0
        /// <summary>
        /// Checks mandatory fields
        /// </summary>
        /// <returns></returns>
        private bool CheckMandatory()
        {
            if (MoldCode_txt.Text == string.Empty)
            {
                messageData = new MessageData("mmce00002", Properties.Resources.mmce00002, MoldCode_lbl.Text);
                popUpMessage.Warning(messageData, Text);

                MoldCode_txt.Focus();

                return(false);
            }

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

                MoldName_txt.Focus();

                return(false);
            }

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

            //    MoldType_cmb.Focus();

            //    return false;
            //}

            return(true);
        }
        /// <summary>
        /// Handles Load event for mold data Insert/Update operations
        /// Loading mold data for update mold data and binding controls with selected mold record
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void AddMoldForm_Load(object sender, EventArgs e)
        {
            if (!this.DesignMode)
            {
                this.ProductionDate_dtp.Clear();

                FormDatatableFromVo();

                ComboBind(MoldType_cmb, moldTypeDatatable, "code", "id");

                MoldCode_txt.Select();

                if (string.Equals(mode, CommonConstants.MODE_UPDATE))
                {
                    LoadUserData(updateData);

                    MoldCode_txt.Enabled = false;

                    MoldName_txt.Select();
                }
            }
        }
Exemple #3
0
        /// <summary>
        /// Handles Load event for mold data Insert/Update operations
        /// Loading mold data for update mold data and binding controls with selected mold record
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AddMoldNewForm_Load(object sender, EventArgs e)
        {
            this.ProductionDate_dtp.Clear();

            FormDatatableFromVo();

            ComboBind(MoldType_cmb, moldTypeDatatable, "code", "id");

            MoldCode_txt.Select();
            int ProcessMoldId = 0;

            if (string.Equals(mode, CommonConstants.MODE_UPDATE))
            {
                LoadUserData(updateData);

                ProcessMoldId = updateData.MoldId;

                MoldCode_txt.Enabled = false;

                MoldName_txt.Select();
            }

            BindGrid(ProcessMoldId);
        }
        /// <summary>
        /// update data to db
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected virtual void Ok_btn_Click(object sender, EventArgs e)
        {
            if (CheckMandatory())
            {
                var sch = StringCheckHelper.GetInstance();

                if (string.IsNullOrEmpty(MoldCode_txt.Text) || string.IsNullOrEmpty(MoldName_txt.Text))
                {
                    messageData = new MessageData("mmce00003", Properties.Resources.mmce00003);
                    logger.Info(messageData);
                    popUpMessage.ConfirmationOkCancel(messageData, Text);

                    if (string.IsNullOrEmpty(MoldCode_txt.Text))
                    {
                        MoldCode_txt.Focus();
                    }
                    else
                    {
                        MoldName_txt.Focus();
                    }

                    return;
                }

                MoldVo inVo = new MoldVo();

                inVo.MoldCode   = MoldCode_txt.Text.Trim();
                inVo.MoldName   = MoldName_txt.Text.Trim();
                inVo.MoldTypeId = Convert.ToInt32(MoldType_cmb.SelectedValue);

                if (!string.IsNullOrEmpty(Weight_txt.Text))
                {
                    inVo.Weight = Convert.ToDecimal(Weight_txt.Text);
                }

                if (!string.IsNullOrEmpty(Height_txt.Text))
                {
                    inVo.Height = Convert.ToDecimal(Height_txt.Text);
                }

                if (!string.IsNullOrEmpty(Width_txt.Text))
                {
                    inVo.Width = Convert.ToDecimal(Width_txt.Text);
                }

                if (!string.IsNullOrEmpty(Depth_txt.Text))
                {
                    inVo.Depth = Convert.ToDecimal(Depth_txt.Text);
                }

                if (!string.IsNullOrWhiteSpace(ProductionDate_dtp.Text))
                {
                    inVo.ProductionDate = Convert.ToDateTime(ProductionDate_dtp.Value);
                }

                inVo.Comment = Comment_txt.Text;

                if (!string.IsNullOrEmpty(LifeShotCount_txt.Text))
                {
                    inVo.LifeShotCount = Convert.ToInt32(LifeShotCount_txt.Text);
                }

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

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

                        return;
                    }
                }

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

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

                        MoldVo outVo = (MoldVo)base.InvokeCbm(new UpdateMoldMasterMntCbm(), 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();
                }
            }
        }