예제 #1
0
        public override ValueObject Execute(TransactionContext trxContext, ValueObject arg)
        {
            MoldTypeVo inVo = (MoldTypeVo)arg;

            StringBuilder sqlQuery = new StringBuilder();

            sqlQuery.Append("Delete From m_mold_type");
            sqlQuery.Append(" Where	");
            sqlQuery.Append(" mold_type_id = :moldtypeid ");
            sqlQuery.Append(" and factory_cd = :faccd ;");

            //create command
            DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sqlQuery.ToString());

            //create parameter
            DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList();

            sqlParameter.AddParameterInteger("moldtypeid", inVo.MoldTypeId);
            sqlParameter.AddParameterString("faccd", UserData.GetUserData().FactoryCode);

            MoldTypeVo outVo = new MoldTypeVo {
                AffectedCount = sqlCommandAdapter.ExecuteNonQuery(sqlParameter)
            };

            return(outVo);
        }
예제 #2
0
        /// <summary>
        /// Fills all user records to gridview control
        /// </summary>
        private void GridBind(MoldTypeVo conditionInVo)
        {
            MoldType_dgv.DataSource = null;

            try
            {
                MoldTypeVo outVo = (MoldTypeVo)base.InvokeCbm(new GetMoldTypeMasterMntCbm(), conditionInVo, false);

                MoldType_dgv.AutoGenerateColumns = false;

                BindingSource bindingSource1 = new BindingSource(outVo.MoldTypeListVo, null);

                if (bindingSource1.Count > 0)
                {
                    MoldType_dgv.DataSource = bindingSource1;
                }
                else
                {
                    messageData = new MessageData("mmci00006", Properties.Resources.mmci00006, null); //mold type
                    logger.Info(messageData);
                    popUpMessage.Information(messageData, Text);
                }

                MoldType_dgv.ClearSelection();

                Update_btn.Enabled = false;

                Delete_btn.Enabled = false;
            }
            catch (Framework.ApplicationException exception)
            {
                popUpMessage.ApplicationError(exception.GetMessageData(), Text);
                logger.Error(exception.GetMessageData());
            }
        }
        public override ValueObject Execute(TransactionContext trxContext, ValueObject arg)
        {
            MoldTypeVo inVo = (MoldTypeVo)arg;

            StringBuilder sqlQuery = new StringBuilder();

            sqlQuery.Append("Update m_mold_type");
            sqlQuery.Append(" Set ");
            sqlQuery.Append(" mold_type_name = :moldtypename, ");
            sqlQuery.Append(" item_id = :itemid ");
            sqlQuery.Append(" Where	");
            sqlQuery.Append(" mold_type_id = :moldtypeid ;");

            //create command
            DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sqlQuery.ToString());

            //create parameter
            DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList();

            sqlParameter.AddParameterInteger("moldtypeid", inVo.MoldTypeId);
            sqlParameter.AddParameterString("moldtypename", inVo.MoldTypeName);
            sqlParameter.AddParameterInteger("itemid", inVo.ItemId);

            MoldTypeVo outVo = new MoldTypeVo {
                AffectedCount = sqlCommandAdapter.ExecuteNonQuery(sqlParameter)
            };

            return(outVo);
        }
예제 #4
0
        /// <summary>
        /// event to delete the selected record
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Delete_btn_Click(object sender, EventArgs e)
        {
            int selectedrowindex = MoldType_dgv.SelectedCells[0].RowIndex;

            DataGridViewRow selectedRow = MoldType_dgv.Rows[selectedrowindex];

            messageData = new MessageData("mmcc00004", Properties.Resources.mmcc00004, selectedRow.Cells["colMoldTypeCode"].Value.ToString());

            DialogResult dialogResult = popUpMessage.ConfirmationOkCancel(messageData, Text);

            if (dialogResult == DialogResult.OK)
            {
                MoldTypeVo inVo = new MoldTypeVo
                {
                    MoldTypeId = Convert.ToInt32(selectedRow.Cells["colMoldTypeId"].Value),
                    //RegistrationDateTime = DateTime.Now.ToString("yyyy/MM/dd/ HH:mm:ss"),
                    RegistrationUserCode = UserData.GetUserData().UserCode,
                    MoldTypeCode         = selectedRow.Cells["colMoldTypeCode"].Value.ToString()
                };

                try
                {
                    MoldTypeVo checkVo = CheckRelation(inVo);

                    if (checkVo != null && checkVo.AffectedCount > 0)
                    {
                        messageData = new MessageData("mmce00007", Properties.Resources.mmce00007, MOLD.ToString());
                        popUpMessage.Information(messageData, Text);
                        return;
                    }

                    MoldTypeVo outVo = (MoldTypeVo)base.InvokeCbm(new DeleteMoldTypeMasterMntCbm(), inVo, false);

                    if (outVo.AffectedCount > 0)
                    {
                        messageData = new MessageData("mmci00003", Properties.Resources.mmci00003, null);
                        logger.Info(messageData);
                        popUpMessage.Information(messageData, Text);

                        GridBind(FormConditionVo());
                    }
                    else if (outVo.AffectedCount == 0)
                    {
                        messageData = new MessageData("mmci00007", Properties.Resources.mmci00007, null);
                        logger.Info(messageData);
                        popUpMessage.Information(messageData, Text);
                        GridBind(FormConditionVo());
                    }
                }
                catch (Framework.ApplicationException exception)
                {
                    popUpMessage.ApplicationError(exception.GetMessageData(), Text);
                    logger.Error(exception.GetMessageData());
                }
            }
            else if (dialogResult == DialogResult.Cancel)
            {
                //do something else
            }
        }
예제 #5
0
        /// <summary>
        /// selects user record for updation and show user form
        /// </summary>
        private void BindUpdateUserData()
        {
            int selectedrowindex = MoldType_dgv.SelectedCells[0].RowIndex;

            MoldTypeVo selectedMoldType = (MoldTypeVo)MoldType_dgv.Rows[selectedrowindex].DataBoundItem;

            AddMoldTypeForm newAddForm = new AddMoldTypeForm(CommonConstants.MODE_UPDATE, selectedMoldType);

            newAddForm.ShowDialog(this);

            if (newAddForm.IntSuccess > 0)
            {
                messageData = new MessageData("mmci00002", Properties.Resources.mmci00002, null);
                logger.Info(messageData);
                popUpMessage.Information(messageData, Text);

                GridBind(FormConditionVo());
            }
            else if (newAddForm.IntSuccess == 0)
            {
                messageData = new MessageData("mmci00007", Properties.Resources.mmci00007, null);
                logger.Info(messageData);
                popUpMessage.Information(messageData, Text);
                GridBind(FormConditionVo());
            }
        }
예제 #6
0
        /// <summary>
        /// For setting selected user record into respective controls(textbox and combobox) for update operation
        /// passing selected user data as parameter
        /// </summary>
        /// <param name="dgvMoldType"></param>
        private void LoadUserData(MoldTypeVo dgvMoldType)
        {
            if (dgvMoldType != null)
            {
                this.MoldTypeCode_txt.Text = dgvMoldType.MoldTypeCode;

                this.MoldTypeName_txt.Text = dgvMoldType.MoldTypeName;

                this.Item_cmb.SelectedValue = dgvMoldType.ItemId.ToString();
            }
        }
예제 #7
0
        /// <summary>
        /// Constructor for the  form
        /// </summary>
        /// <param name="pmode"></param>
        /// <param name="userItem"></param>
        public AddMoldTypeForm(string pmode, MoldTypeVo userItem = null)
        {
            InitializeComponent();

            mode = pmode;

            updateData = userItem;
            if (string.Equals(mode, CommonConstants.MODE_UPDATE))
            {
                this.Text = UpdateText_lbl.Text;
            }
        }
예제 #8
0
        /// <summary>
        /// checks duplicate mold type Code
        /// </summary>
        /// <param name="mtypecVo"></param>
        /// <returns></returns>
        private MoldTypeVo DuplicateCheck(MoldTypeVo mtypecVo)
        {
            MoldTypeVo outVo = new MoldTypeVo();

            try
            {
                outVo = (MoldTypeVo)base.InvokeCbm(new CheckMoldTypeMasterMntCbm(), mtypecVo, false);
            }
            catch (Framework.ApplicationException exception)
            {
                popUpMessage.ApplicationError(exception.GetMessageData(), Text);
                logger.Error(exception.GetMessageData());
            }

            return(outVo);
        }
        public override ValueObject Execute(TransactionContext trxContext, ValueObject arg)
        {
            MoldTypeVo inVo = (MoldTypeVo)arg;

            StringBuilder sqlQuery = new StringBuilder();

            sqlQuery.Append("Insert into m_mold_type");
            sqlQuery.Append(" ( ");
            sqlQuery.Append(" mold_type_cd, ");
            sqlQuery.Append(" mold_type_name, ");
            sqlQuery.Append(" item_id, ");
            sqlQuery.Append(" registration_user_cd, ");
            sqlQuery.Append(" registration_date_time, ");
            sqlQuery.Append(" factory_cd ");
            sqlQuery.Append(" ) ");
            sqlQuery.Append("VALUES	");
            sqlQuery.Append(" ( ");
            sqlQuery.Append(" :moldtypecd ,");
            sqlQuery.Append(" :moldtypename ,");
            sqlQuery.Append(" :itemid ,");
            sqlQuery.Append(" :registrationusercode ,");
            sqlQuery.Append(" now() ,");
            sqlQuery.Append(" :factorycode ");
            sqlQuery.Append(" ); ");

            //create command
            DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sqlQuery.ToString());

            //create parameter
            DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList();

            sqlParameter.AddParameterString("moldtypecd", inVo.MoldTypeCode);
            sqlParameter.AddParameterString("moldtypename", inVo.MoldTypeName);
            sqlParameter.AddParameterInteger("itemid", inVo.ItemId);
            sqlParameter.AddParameterString("registrationusercode", inVo.RegistrationUserCode);
            //sqlParameter.AddParameterDateTime("registrationdatetime", inVo.RegistrationDateTime);
            sqlParameter.AddParameterString("factorycode", inVo.FactoryCode);

            MoldTypeVo outVo = new MoldTypeVo {
                AffectedCount = sqlCommandAdapter.ExecuteNonQuery(sqlParameter)
            };

            return(outVo);
        }
예제 #10
0
        public override ValueObject Execute(TransactionContext trxContext, ValueObject arg)
        {
            MoldTypeVo inVo = (MoldTypeVo)arg;

            StringBuilder sqlQuery = new StringBuilder();

            sqlQuery.Append("select Count(mo.mold_cd) as MoldCount from m_mold_type mt");
            sqlQuery.Append(" inner join m_mold mo on mt.mold_type_id = mo.mold_type_id");
            sqlQuery.Append(" where mt.factory_cd = :faccd ");

            if (inVo.MoldTypeCode != null)
            {
                sqlQuery.Append(" and UPPER(mt.mold_type_cd) = UPPER(:moldtypecd)");
            }

            //create command
            DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sqlQuery.ToString());

            //create parameter
            DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList();

            sqlParameter.AddParameterString("faccd", UserData.GetUserData().FactoryCode);

            if (inVo.MoldTypeCode != null)
            {
                sqlParameter.AddParameterString("moldtypecd", inVo.MoldTypeCode);
            }

            //execute SQL
            IDataReader dataReader = sqlCommandAdapter.ExecuteReader(trxContext, sqlParameter);

            MoldTypeVo outVo = new MoldTypeVo();

            while (dataReader.Read())
            {
                outVo.AffectedCount = Convert.ToInt32("0" + dataReader["MoldCount"]);
            }

            dataReader.Close();

            return(outVo);
        }
예제 #11
0
        /// <summary>
        /// form country and factory data for combo
        /// </summary>
        private void FormDatatableFromVo()
        {
            moldTypeDatatable = new DataTable();
            moldTypeDatatable.Columns.Add("id");
            moldTypeDatatable.Columns.Add("code");

            try
            {
                MoldTypeVo moldTypeOutVo = (MoldTypeVo)base.InvokeCbm(new GetMoldTypeMasterMntCbm(), new MoldTypeVo(), false);

                foreach (MoldTypeVo moldType in moldTypeOutVo.MoldTypeListVo)
                {
                    moldTypeDatatable.Rows.Add(moldType.MoldTypeId, moldType.MoldTypeCode);
                }
            }
            catch (Framework.ApplicationException exception)
            {
                popUpMessage.ApplicationError(exception.GetMessageData(), Text);
                logger.Error(exception.GetMessageData());
            }
        }
예제 #12
0
        /// <summary>
        /// Creates seacrh condition as per user inputs
        /// </summary>
        /// <returns>search condition</returns>
        private MoldTypeVo FormConditionVo()
        {
            MoldTypeVo inVo = new MoldTypeVo();

            if (MoldTypeCode_txt.Text != string.Empty)
            {
                inVo.MoldTypeCode = MoldTypeCode_txt.Text;
            }

            if (MoldTypeName_txt.Text != string.Empty)
            {
                inVo.MoldTypeName = MoldTypeName_txt.Text;
            }

            if (Item_cmb.SelectedIndex > -1)
            {
                inVo.ItemId = Convert.ToInt32(Item_cmb.SelectedValue);
            }

            return(inVo);
        }
예제 #13
0
        public override ValueObject Execute(TransactionContext trxContext, ValueObject arg)
        {
            MoldTypeVo inVo = (MoldTypeVo)arg;

            StringBuilder sqlQuery = new StringBuilder();

            //create SQL
            sqlQuery.Append("Select mt.mold_type_id, mt.mold_type_cd, mt.mold_type_name, li.item_id, li.item_cd ");
            sqlQuery.Append("from m_mold_type mt ");
            sqlQuery.Append("inner join m_local_item li on  li.item_id = mt.item_id ");
            sqlQuery.Append(" where mt.factory_cd = :faccd ");

            if (inVo.MoldTypeCode != null)
            {
                sqlQuery.Append(" and mt.mold_type_cd like :moldtypecd ");
            }

            if (inVo.MoldTypeName != null)
            {
                sqlQuery.Append(" and mt.mold_type_name like :moldtypename ");
            }

            if (inVo.ItemId != 0)
            {
                sqlQuery.Append(" and mt.item_id = :itemid ");
            }

            sqlQuery.Append(" order by mt.mold_type_cd");

            //create command
            DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sqlQuery.ToString());

            //create parameter
            DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList();

            sqlParameter.AddParameterString("faccd", UserData.GetUserData().FactoryCode);

            if (inVo.MoldTypeCode != null)
            {
                sqlParameter.AddParameterString("moldtypecd", inVo.MoldTypeCode + "%");
            }

            if (inVo.MoldTypeName != null)
            {
                sqlParameter.AddParameterString("moldtypename", inVo.MoldTypeName + "%");
            }
            if (inVo.ItemId != 0)
            {
                sqlParameter.AddParameterInteger("itemid", inVo.ItemId);
            }

            //execute SQL
            IDataReader dataReader = sqlCommandAdapter.ExecuteReader(trxContext, sqlParameter);

            MoldTypeVo outVo = new MoldTypeVo();

            while (dataReader.Read())
            {
                MoldTypeVo currOutVo = new MoldTypeVo
                {
                    MoldTypeId   = Convert.ToInt32(dataReader["mold_type_id"]),
                    MoldTypeCode = dataReader["mold_type_cd"].ToString(),
                    MoldTypeName = dataReader["mold_type_name"].ToString(),
                    ItemId       = Convert.ToInt32(dataReader["item_id"]),
                    ItemCode     = dataReader["item_cd"].ToString()
                };
                outVo.MoldTypeListVo.Add(currOutVo);
            }
            dataReader.Close();

            return(outVo);
        }
예제 #14
0
        /// <summary>
        /// inserts/updates mold type on button click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Ok_btn_Click(object sender, EventArgs e)
        {
            var sch = StringCheckHelper.GetInstance();

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

                    if (string.IsNullOrEmpty(MoldTypeCode_txt.Text))
                    {
                        MoldTypeCode_txt.Focus();
                    }
                    else if (string.IsNullOrEmpty(MoldTypeName_txt.Text))
                    {
                        MoldTypeName_txt.Focus();
                    }
                    return;
                }
                MoldTypeVo inVo = new MoldTypeVo
                {
                    MoldTypeCode = MoldTypeCode_txt.Text.Trim(),
                    MoldTypeName = MoldTypeName_txt.Text.Trim(),
                    ItemId       = Convert.ToInt32(Item_cmb.SelectedValue),
                    //RegistrationDateTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"),
                    RegistrationUserCode = UserData.GetUserData().UserCode,
                    FactoryCode          = UserData.GetUserData().FactoryCode
                };

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

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


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

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

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