public override ValueObject Execute(TransactionContext trxContext, ValueObject arg)
        {
            InventoryReasonVo inVo = (InventoryReasonVo)arg;

            StringBuilder sqlQuery = new StringBuilder();

            sqlQuery.Append("Update m_inventory_reason");
            sqlQuery.Append(" Set ");
            sqlQuery.Append(" inventory_reason_name = :inventoryreasonname ");
            sqlQuery.Append(" Where	");
            sqlQuery.Append(" inventory_reason_id = :inventoryreasonid ;");

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

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

            sqlParameter.AddParameterInteger("inventoryreasonid", inVo.InventoryReasonId);
            sqlParameter.AddParameterString("inventoryreasonname", inVo.InventoryReasonName);

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

            return(outVo);
        }
Пример #2
0
        /// <summary>
        /// Fills all user records to gridview control
        /// </summary>
        private void GridBind(InventoryReasonVo conditionInVo)
        {
            InventoryReasonDetails_dgv.DataSource = null;

            try
            {
                InventoryReasonVo outVo = (InventoryReasonVo)base.InvokeCbm(new GetInventoryReasonMasterMntCbm(), conditionInVo, false);

                InventoryReasonDetails_dgv.AutoGenerateColumns = false;

                BindingSource inventoryReasonBindingSource = new BindingSource(outVo.InventoryReasonListVo, null);

                if (inventoryReasonBindingSource.Count > 0)
                {
                    InventoryReasonDetails_dgv.DataSource = inventoryReasonBindingSource;
                }
                else
                {
                    messageData = new MessageData("mmci00006", Properties.Resources.mmci00006, null);
                    logger.Info(messageData);
                    popUpMessage.Information(messageData, Text);
                }

                InventoryReasonDetails_dgv.ClearSelection();

                Update_btn.Enabled = false;

                Delete_btn.Enabled = false;
            }
            catch (Framework.ApplicationException exception)
            {
                popUpMessage.ApplicationError(exception.GetMessageData(), Text);
                logger.Error(exception.GetMessageData());
            }
        }
Пример #3
0
        /// <summary>
        /// selects user record for updation and show Line form
        /// </summary>
        private void BindUpdateInventoryReasonData()
        {
            int selectedrowindex = InventoryReasonDetails_dgv.SelectedCells[0].RowIndex;

            InventoryReasonVo selectedInventoryReason = (InventoryReasonVo)InventoryReasonDetails_dgv.Rows[selectedrowindex].DataBoundItem;

            AddInventoryReasonMasterForm newAddForm = new AddInventoryReasonMasterForm(CommonConstants.MODE_UPDATE, selectedInventoryReason);

            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());
            }
        }
 /// <summary>
 /// For setting selected Line record into respective controls(textbox and combobox) for update operation
 /// passing selected Line data as parameter
 /// </summary>
 /// <param name="dgvLine"></param>
 private void LoadInventoryReasonData(InventoryReasonVo dgvInventoryReason)
 {
     if (dgvInventoryReason != null)
     {
         this.InventoryReasonCode_txt.Text = dgvInventoryReason.InventoryReasonCode;
         this.InventoryReasonName_txt.Text = dgvInventoryReason.InventoryReasonName;
     }
 }
Пример #5
0
        public override ValueObject Execute(TransactionContext trxContext, ValueObject arg)
        {
            InventoryReasonVo inVo = (InventoryReasonVo)arg;

            InventoryReasonVo outVo = new InventoryReasonVo();

            StringBuilder sqlQuery = new StringBuilder();

            sqlQuery.Append("Select * from m_inventory_reason ");
            sqlQuery.Append(" where 1 = 1 ");

            if (inVo.InventoryReasonCode != null)
            {
                sqlQuery.Append(" and inventory_reason_cd like :inventoryreasoncd ");
            }

            if (inVo.InventoryReasonName != null)
            {
                sqlQuery.Append(" and inventory_reason_name like :inventoryreasonname ");
            }

            sqlQuery.Append(" order by inventory_reason_cd");

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

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

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

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

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

            while (dataReader.Read())
            {
                InventoryReasonVo currOutVo = new InventoryReasonVo
                {
                    InventoryReasonId   = Convert.ToInt32(dataReader["inventory_reason_id"]),
                    InventoryReasonCode = dataReader["inventory_reason_cd"].ToString(),
                    InventoryReasonName = dataReader["inventory_reason_name"].ToString(),
                };

                outVo.InventoryReasonListVo.Add(currOutVo);
            }

            dataReader.Close();

            return(outVo);
        }
        /// <summary>
        /// constructor
        /// </summary>
        /// <param name="pmode"></param>
        /// <param name="LineItem"></param>
        public AddInventoryReasonMasterForm(string pmode, InventoryReasonVo InventoryReasonItem = null)
        {
            InitializeComponent();

            mode       = pmode;
            updateData = InventoryReasonItem;

            if (string.Equals(mode, CommonConstants.MODE_UPDATE))
            {
                this.Text = UpdateText_lbl.Text;
            }
        }
        /// <summary>
        /// checks duplicate FactoryCode
        /// </summary>
        /// <param name="lineVo"></param>
        /// <returns></returns>
        private InventoryReasonVo DuplicateCheck(InventoryReasonVo inventoryReasonVo)
        {
            InventoryReasonVo outVo = new InventoryReasonVo();

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

            return(outVo);
        }
Пример #8
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 = InventoryReasonDetails_dgv.SelectedCells[0].RowIndex;

            DataGridViewRow selectedRow = InventoryReasonDetails_dgv.Rows[selectedrowindex];

            messageData = new MessageData("mmcc00004", Properties.Resources.mmcc00004, selectedRow.Cells["colInventoryReasonName"].Value.ToString());
            DialogResult dialogResult = popUpMessage.ConfirmationOkCancel(messageData, Text);

            if (dialogResult == DialogResult.OK)
            {
                InventoryReasonVo inVo = new InventoryReasonVo
                {
                    InventoryReasonId = Convert.ToInt32(selectedRow.Cells["colInventoryReasonId"].Value)
                };

                try
                {
                    InventoryReasonVo outVo = (InventoryReasonVo)base.InvokeCbm(new DeleteInventoryReasonMasterMntCbm(), 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
            }
        }
Пример #9
0
        /// <summary>
        /// Creates seacrh condition as per user inputs
        /// </summary>
        /// <returns>search condition</returns>
        private InventoryReasonVo FormConditionVo()
        {
            InventoryReasonVo inVo = new InventoryReasonVo();


            if (InventoryReasonCode_txt.Text != string.Empty)
            {
                inVo.InventoryReasonCode = InventoryReasonCode_txt.Text;
            }

            if (InventoryReasonName_txt.Text != string.Empty)
            {
                inVo.InventoryReasonName = InventoryReasonName_txt.Text;
            }

            return(inVo);
        }
Пример #10
0
        public override ValueObject Execute(TransactionContext trxContext, ValueObject arg)
        {
            InventoryReasonVo inVo = (InventoryReasonVo)arg;

            StringBuilder sqlQuery = new StringBuilder();

            sqlQuery.Append("Insert into m_inventory_reason");
            sqlQuery.Append(" ( ");
            sqlQuery.Append(" inventory_reason_cd, ");
            sqlQuery.Append(" inventory_reason_name, ");
            sqlQuery.Append(" registration_user_cd, ");
            sqlQuery.Append(" registration_date_time, ");
            sqlQuery.Append(" factory_cd ");
            sqlQuery.Append(" ) ");
            sqlQuery.Append("VALUES	");
            sqlQuery.Append(" ( ");
            sqlQuery.Append(" :inventoryreasoncd ,");
            sqlQuery.Append(" :inventoryreasonname ,");
            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("inventoryreasoncd", inVo.InventoryReasonCode);
            sqlParameter.AddParameterString("inventoryreasonname", inVo.InventoryReasonName);
            sqlParameter.AddParameterString("registrationusercode", inVo.RegistrationUserCode);
            //sqlParameter.AddParameterDateTime("registrationdatetime", inVo.RegistrationDateTime);
            sqlParameter.AddParameterString("factorycode", inVo.FactoryCode);

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

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

            StringBuilder sqlQuery = new StringBuilder();

            sqlQuery.Append("Select Count(*) as InventoryCount from m_inventory_reason ");
            sqlQuery.Append(" where 1 = 1 ");

            if (inVo.InventoryReasonCode != null)
            {
                sqlQuery.Append(" and UPPER(inventory_reason_cd) = UPPER(:inventoryreasoncd)");
            }

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

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

            if (inVo.InventoryReasonCode != null)
            {
                sqlParameter.AddParameterString("inventoryreasoncd", inVo.InventoryReasonCode);
            }

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

            InventoryReasonVo outVo = new InventoryReasonVo();

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

            dataReader.Close();

            return(outVo);
        }
        /// <summary>
        /// update data to db
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Ok_btn_Click(object sender, EventArgs e)
        {
            InventoryReasonVo inVo = new InventoryReasonVo();

            if (CheckMandatory())
            {
                var sch = StringCheckHelper.GetInstance();

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

                    if (string.IsNullOrEmpty(InventoryReasonCode_txt.Text))
                    {
                        InventoryReasonCode_txt.Focus();
                    }
                    else
                    {
                        InventoryReasonName_txt.Focus();
                    }

                    return;
                }

                inVo.InventoryReasonCode = InventoryReasonCode_txt.Text.Trim();
                inVo.InventoryReasonName = InventoryReasonName_txt.Text.Trim();
                //inVo.RegistrationDateTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                inVo.RegistrationUserCode = UserData.GetUserData().UserCode;
                inVo.FactoryCode          = UserData.GetUserData().FactoryCode;

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

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

                        return;
                    }
                }

                try
                {
                    if (string.Equals(mode, CommonConstants.MODE_ADD))
                    {
                        InventoryReasonVo outVo = (InventoryReasonVo)base.InvokeCbm(new AddInventoryReasonMasterMntCbm(), inVo, false);
                        IntSuccess = outVo.AffectedCount;
                    }
                    else if (string.Equals(mode, CommonConstants.MODE_UPDATE))
                    {
                        inVo.InventoryReasonId = updateData.InventoryReasonId;
                        InventoryReasonVo outVo = (InventoryReasonVo)base.InvokeCbm(new UpdateInventoryReasonMasterMntCbm(), 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();
                }
            }
        }