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

            StringBuilder sqlQuery = new StringBuilder();

            sqlQuery.Append("Delete From m_process_flow_rule");
            sqlQuery.Append(" Where	");
            sqlQuery.Append(" process_flow_rule_id = :processflowruleid ");
            sqlQuery.Append(" and factory_cd = :faccd ;");

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

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

            sqlParameter.AddParameterInteger("processflowruleid", inVo.ProcessFlowRuleId);
            sqlParameter.AddParameterString("faccd", UserData.GetUserData().FactoryCode);

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

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

            processFlowRuleDatatable = new DataTable();
            processFlowRuleDatatable.Columns.Add("ProcessFlowRuleId", typeof(string));
            processFlowRuleDatatable.Columns.Add("Comment", typeof(string));

            try
            {
                ItemVo ItemOutVo = (ItemVo)base.InvokeCbm(new GetItemMasterMntCbm(), new ItemVo(), false);

                foreach (ItemVo it in ItemOutVo.ItemListVo)
                {
                    itemDatatable.Rows.Add(it.ItemId, it.ItemCode);
                }

                ProcessFlowRuleVo proceesFlowRuleVo = (ProcessFlowRuleVo)base.InvokeCbm(new GetProcessFlowRuleMasterMntCbm(), new ProcessFlowRuleVo(), false);

                foreach (ProcessFlowRuleVo pf in proceesFlowRuleVo.ProcessFlowRuleListVo)
                {
                    processFlowRuleDatatable.Rows.Add(pf.ProcessFlowRuleId, pf.Comment);
                }
            }
            catch (Framework.ApplicationException exception)
            {
                popUpMessage.ApplicationError(exception.GetMessageData(), Text);
                logger.Error(exception.GetMessageData());
            }
        }
Beispiel #3
0
        public override ValueObject Execute(TransactionContext trxContext, ValueObject arg)
        {
            ProcessFlowRuleVo inVo = (ProcessFlowRuleVo)arg;

            ProcessFlowRuleVo outVo = new ProcessFlowRuleVo();

            StringBuilder sqlQuery = new StringBuilder();

            sqlQuery.Append("Select * from m_process_flow_rule ");
            sqlQuery.Append(" where factory_cd = :faccd ");

            if (inVo.ProcessFlowRuleCode != null)
            {
                sqlQuery.Append(" and process_flow_rule_cd like :processflowrulecd ");
            }

            if (inVo.Comment != null)
            {
                sqlQuery.Append(" and comment like :comment ");
            }

            sqlQuery.Append(" order by process_flow_rule_cd");

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

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

            sqlParameter.AddParameterString("faccd", UserData.GetUserData().FactoryCode);
            if (inVo.ProcessFlowRuleCode != null)
            {
                sqlParameter.AddParameterString("processflowrulecd", inVo.ProcessFlowRuleCode + "%");
            }

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


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

            while (dataReader.Read())
            {
                ProcessFlowRuleVo currOutVo = new ProcessFlowRuleVo
                {
                    ProcessFlowRuleId   = Convert.ToInt32(dataReader["process_flow_rule_id"]),
                    ProcessFlowRuleCode = dataReader["process_flow_rule_cd"].ToString(),
                    Comment             = dataReader["comment"].ToString(),
                };

                outVo.ProcessFlowRuleListVo.Add(currOutVo);
            }

            dataReader.Close();

            return(outVo);
        }
        /// <summary>
        /// Fills all user records to gridview control
        /// </summary>
        private void GridBind(ProcessFlowRuleVo conditionInVo)
        {
            ProcessFlowRule_dgv.DataSource = null;

            try
            {
                ProcessFlowRuleVo outVo = (ProcessFlowRuleVo)base.InvokeCbm(new GetProcessFlowRuleMasterMntCbm(), conditionInVo, false);

                ProcessFlowRule_dgv.AutoGenerateColumns = false;

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

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

                ProcessFlowRule_dgv.ClearSelection();

                Update_btn.Enabled = false;

                Delete_btn.Enabled = false;
            }
            catch (Framework.ApplicationException exception)
            {
                popUpMessage.ApplicationError(exception.GetMessageData(), Text);
                logger.Error(exception.GetMessageData());
            }
        }
        /// <summary>
        /// selects user record for updation and show user form
        /// </summary>
        private void BindUpdateUserData()
        {
            int selectedrowindex = ProcessFlowRule_dgv.SelectedCells[0].RowIndex;

            ProcessFlowRuleVo selectedData = (ProcessFlowRuleVo)ProcessFlowRule_dgv.Rows[selectedrowindex].DataBoundItem;

            AddProcessFlowRuleForm newAddForm = new AddProcessFlowRuleForm(CommonConstants.MODE_UPDATE, selectedData);

            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 user record into respective controls(textbox and combobox) for update operation
        /// passing selected user data as parameter
        /// </summary>
        /// <param name="dgvData"></param>
        private void LoadUserData(ProcessFlowRuleVo dgvData)
        {
            if (dgvData != null)
            {
                ProcessFlowRuleCode_txt.Text = dgvData.ProcessFlowRuleCode;

                Comment_txt.Text = dgvData.Comment;
            }
        }
        /// <summary>
        /// constructor for the form
        /// </summary>
        /// <param name="pmode"></param>
        /// <param name="dataItem"></param>
        public AddProcessFlowRuleForm(string pmode, ProcessFlowRuleVo dataItem = null)
        {
            InitializeComponent();

            mode = pmode;

            updateData = dataItem;
            if (string.Equals(mode, CommonConstants.MODE_UPDATE))
            {
                this.Text = UpdateText_lbl.Text;
            }
        }
        /// <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 = ProcessFlowRule_dgv.SelectedCells[0].RowIndex;

            DataGridViewRow selectedRow = ProcessFlowRule_dgv.Rows[selectedrowindex];

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

            if (dialogResult == DialogResult.OK)
            {
                ProcessFlowRuleVo inVo = new ProcessFlowRuleVo
                {
                    ProcessFlowRuleId = Convert.ToInt32(selectedRow.Cells["colProcessFlowRuleId"].Value),
                };

                try
                {
                    ProcessFlowRuleVo outVo = (ProcessFlowRuleVo)base.InvokeCbm(new DeleteProcessFlowRuleMasterMntCbm(), 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
            }
        }
        /// <summary>
        /// checks duplicate Process Code
        /// </summary>
        /// <param name="processVo"></param>
        /// <returns></returns>
        private ProcessFlowRuleVo DuplicateCheck(ProcessFlowRuleVo machineVo)
        {
            ProcessFlowRuleVo outVo = new ProcessFlowRuleVo();

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

            return(outVo);
        }
        /// <summary>
        /// Creates seacrh condition as per user inputs
        /// </summary>
        /// <returns>search condition</returns>
        private ProcessFlowRuleVo FormConditionVo()
        {
            ProcessFlowRuleVo inVo = new ProcessFlowRuleVo();

            if (ProcessFlowRuleCode_txt.Text != string.Empty)
            {
                inVo.ProcessFlowRuleCode = ProcessFlowRuleCode_txt.Text;
            }

            if (Comment_txt.Text != string.Empty)
            {
                inVo.Comment = Comment_txt.Text;
            }

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

            StringBuilder sqlQuery = new StringBuilder();

            sqlQuery.Append("Insert into m_process_flow_rule");
            sqlQuery.Append(" ( ");
            sqlQuery.Append(" process_flow_rule_cd, ");
            sqlQuery.Append(" comment, ");
            sqlQuery.Append(" registration_user_cd, ");
            sqlQuery.Append(" registration_date_time, ");
            sqlQuery.Append(" factory_cd ");
            sqlQuery.Append(" ) ");
            sqlQuery.Append("VALUES	");
            sqlQuery.Append(" ( ");
            sqlQuery.Append(" :processflowrulecd ,");
            sqlQuery.Append(" :comment ,");
            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("processflowrulecd", inVo.ProcessFlowRuleCode);
            sqlParameter.AddParameterString("comment", inVo.Comment);
            sqlParameter.AddParameterString("registrationusercode", inVo.RegistrationUserCode);
            //sqlParameter.AddParameterDateTime("registrationdatetime", inVo.RegistrationDateTime);
            sqlParameter.AddParameterString("factorycode", inVo.FactoryCode);

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

            return(outVo);
        }
Beispiel #12
0
        public override ValueObject Execute(TransactionContext trxContext, ValueObject arg)
        {
            ProcessFlowRuleVo inVo = (ProcessFlowRuleVo)arg;

            StringBuilder sqlQuery = new StringBuilder();

            sqlQuery.Append("Select Count(*) as RuleCount from m_process_flow_rule ");
            sqlQuery.Append(" where factory_cd = :faccd ");

            if (inVo.ProcessFlowRuleCode != null)
            {
                sqlQuery.Append(" and UPPER(process_flow_rule_cd) = UPPER(:processflowrulecd)");
            }

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

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

            sqlParameter.AddParameterString("faccd", UserData.GetUserData().FactoryCode);
            if (inVo.ProcessFlowRuleCode != null)
            {
                sqlParameter.AddParameterString("processflowrulecd", inVo.ProcessFlowRuleCode);
            }

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

            ProcessFlowRuleVo outVo = new ProcessFlowRuleVo();

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

            dataReader.Close();

            return(outVo);
        }
        /// <summary>
        /// inserts/updates ProcessFlowRule on ok click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Ok_btn_Click(object sender, EventArgs e)
        {
            if (CheckMandatory())
            {
                var sch = StringCheckHelper.GetInstance();

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

                    if (string.IsNullOrEmpty(ProcessFlowRuleCode_txt.Text))
                    {
                        ProcessFlowRuleCode_txt.Focus();
                    }
                    else
                    {
                        Comment_txt.Focus();
                    }

                    return;
                }

                ProcessFlowRuleVo inVo = new ProcessFlowRuleVo
                {
                    ProcessFlowRuleCode = ProcessFlowRuleCode_txt.Text.Trim(),
                    Comment             = Comment_txt.Text.Trim(),
                    //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))
                {
                    ProcessFlowRuleVo checkVo = DuplicateCheck(inVo);

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

                        return;
                    }
                }

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

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

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