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

            StringBuilder sqlQuery = new StringBuilder();

            sqlQuery.Append("Update m_defective_category");
            sqlQuery.Append(" Set ");
            sqlQuery.Append(" defective_category_name = :defectiveCategoryname ");
            sqlQuery.Append(" Where	");
            sqlQuery.Append(" defective_category_id = :defectiveCategoryid ;");

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

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

            sqlParameter.AddParameterInteger("defectiveCategoryid", inVo.DefectiveCategoryId);
            sqlParameter.AddParameterString("defectiveCategoryname", inVo.DefectiveCategoryName);

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

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

            try
            {
                DefectiveCategoryVo outVo = (DefectiveCategoryVo)base.InvokeCbm(new GetDefectiveCategoryMasterMntCbm(), conditionInVo, false);

                DefectiveCategoryDetails_dgv.AutoGenerateColumns = false;

                BindingSource defectiveCategoryBindingSource = new BindingSource(outVo.DefectiveCategoryListVo, null);

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

                DefectiveCategoryDetails_dgv.ClearSelection();

                Update_btn.Enabled = false;

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

            DefectiveCategoryVo selectedDefectiveCategory = (DefectiveCategoryVo)DefectiveCategoryDetails_dgv.Rows[selectedrowindex].DataBoundItem;

            AddDefectiveCategoryForm newAddForm = new AddDefectiveCategoryForm(CommonConstants.MODE_UPDATE, selectedDefectiveCategory);

            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());
            }
        }
Example #4
0
 /// <summary>
 /// For setting selected DefectiveCategory record into respective controls(textbox and combobox) for update operation
 /// passing selected DefectiveCategory data as parameter
 /// </summary>
 /// <param name="dgvDefectiveCategory"></param>
 private void LoadDefectiveCategoryData(DefectiveCategoryVo dgvDefectiveCategory)
 {
     if (dgvDefectiveCategory != null)
     {
         this.DefectiveCategoryCode_txt.Text = dgvDefectiveCategory.DefectiveCategoryCode;
         this.DefectiveCategoryName_txt.Text = dgvDefectiveCategory.DefectiveCategoryName;
     }
 }
        public override ValueObject Execute(TransactionContext trxContext, ValueObject arg)
        {
            DefectiveCategoryVo inVo = (DefectiveCategoryVo)arg;

            DefectiveCategoryVo outVo = new DefectiveCategoryVo();

            StringBuilder sqlQuery = new StringBuilder();

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

            if (inVo.DefectiveCategoryCode != null)
            {
                sqlQuery.Append(" and defective_category_cd like :defectiveCategorycd ");
            }

            if (inVo.DefectiveCategoryName != null)
            {
                sqlQuery.Append(" and defective_category_name like :defectiveCategoryname ");
            }

            sqlQuery.Append(" order by defective_category_cd");

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

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

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

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

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

            while (dataReader.Read())
            {
                DefectiveCategoryVo currOutVo = new DefectiveCategoryVo();
                {
                    currOutVo.DefectiveCategoryId   = Convert.ToInt32(dataReader["defective_category_id"]);
                    currOutVo.DefectiveCategoryCode = dataReader["defective_category_cd"].ToString();
                    currOutVo.DefectiveCategoryName = dataReader["defective_category_name"].ToString();
                };

                outVo.DefectiveCategoryListVo.Add(currOutVo);
            }

            dataReader.Close();

            return(outVo);
        }
Example #6
0
        /// <summary>
        /// constructor
        /// </summary>
        /// <param name="pmode"></param>
        /// <param name="DefectiveCategoryItem"></param>
        public AddDefectiveCategoryForm(string pmode, DefectiveCategoryVo DefectiveCategoryItem = null)
        {
            InitializeComponent();

            mode = pmode;

            updateData = DefectiveCategoryItem;
            if (string.Equals(mode, CommonConstants.MODE_UPDATE))
            {
                this.Text = UpdateText_lbl.Text;
            }
        }
Example #7
0
        /// <summary>
        /// checks duplicate FactoryCode
        /// </summary>
        /// <param name="defectiveCategoryVo"></param>
        /// <returns></returns>
        private DefectiveCategoryVo DuplicateCheck(DefectiveCategoryVo defectiveCategoryVo)
        {
            DefectiveCategoryVo outVo = new DefectiveCategoryVo();

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

            return(outVo);
        }
Example #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 = DefectiveCategoryDetails_dgv.SelectedCells[0].RowIndex;

            DataGridViewRow selectedRow = DefectiveCategoryDetails_dgv.Rows[selectedrowindex];

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

            if (dialogResult == DialogResult.OK)
            {
                DefectiveCategoryVo inVo = new DefectiveCategoryVo
                {
                    DefectiveCategoryId = Convert.ToInt32(selectedRow.Cells["colDefectiveCategoryId"].Value)
                };

                try
                {
                    DefectiveCategoryVo outVo = (DefectiveCategoryVo)base.InvokeCbm(new DeleteDefectiveCategoryMasterMntCbm(), 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
            }
        }
Example #9
0
        /// <summary>
        /// Creates seacrh condition as per user inputs
        /// </summary>
        /// <returns>search condition</returns>
        private DefectiveCategoryVo FormConditionVo()
        {
            DefectiveCategoryVo inVo = new DefectiveCategoryVo();


            if (DefectiveCategoryCode_txt.Text != string.Empty)
            {
                inVo.DefectiveCategoryCode = DefectiveCategoryCode_txt.Text;
            }

            if (DefectiveCategoryName_txt.Text != string.Empty)
            {
                inVo.DefectiveCategoryName = DefectiveCategoryName_txt.Text;
            }

            return(inVo);
        }
Example #10
0
        public override ValueObject Execute(TransactionContext trxContext, ValueObject arg)
        {
            DefectiveCategoryVo inVo = (DefectiveCategoryVo)arg;

            StringBuilder sqlQuery = new StringBuilder();

            sqlQuery.Append("Insert into m_defective_category");
            sqlQuery.Append(" ( ");
            sqlQuery.Append(" defective_category_cd, ");
            sqlQuery.Append(" defective_category_name, ");
            sqlQuery.Append(" registration_user_cd, ");
            sqlQuery.Append(" registration_date_time, ");
            sqlQuery.Append(" factory_cd ");
            sqlQuery.Append(" ) ");
            sqlQuery.Append("VALUES	");
            sqlQuery.Append(" ( ");
            sqlQuery.Append(" :defectiveCategorycd ,");
            sqlQuery.Append(" :defectiveCategoryname ,");
            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("defectiveCategorycd", inVo.DefectiveCategoryCode);
            sqlParameter.AddParameterString("defectiveCategoryname", inVo.DefectiveCategoryName);
            sqlParameter.AddParameterString("registrationusercode", inVo.RegistrationUserCode);
            //sqlParameter.AddParameterDateTime("registrationdatetime", inVo.RegistrationDateTime);
            sqlParameter.AddParameterString("factorycode", inVo.FactoryCode);

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

            return(outVo);
        }
Example #11
0
        private void FormDatatableFromVo()
        {
            defectiveCategoryDatatable = new DataTable();
            defectiveCategoryDatatable.Columns.Add("id");
            defectiveCategoryDatatable.Columns.Add("name");

            try
            {
                DefectiveCategoryVo defectiveCategoryOutVo = (DefectiveCategoryVo)base.InvokeCbm(new GetDefectiveCategoryMasterMntCbm(), new DefectiveCategoryVo(), false);

                foreach (DefectiveCategoryVo defectiveCategory in defectiveCategoryOutVo.DefectiveCategoryListVo)
                {
                    defectiveCategoryDatatable.Rows.Add(defectiveCategory.DefectiveCategoryId, defectiveCategory.DefectiveCategoryName);
                }
            }
            catch (Framework.ApplicationException exception)
            {
                popUpMessage.ApplicationError(exception.GetMessageData(), Text);
                logger.Error(exception.GetMessageData());
            }
        }
        public override ValueObject Execute(TransactionContext trxContext, ValueObject arg)
        {
            DefectiveCategoryVo inVo = (DefectiveCategoryVo)arg;

            StringBuilder sqlQuery = new StringBuilder();

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

            if (inVo.DefectiveCategoryCode != null)
            {
                sqlQuery.Append(" and UPPER(defective_category_cd) = UPPER(:defectiveCategorycd)");
            }

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

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

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

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

            DefectiveCategoryVo outVo = new DefectiveCategoryVo();

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

            dataReader.Close();

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

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

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

                    if (string.IsNullOrEmpty(DefectiveCategoryCode_txt.Text))
                    {
                        DefectiveCategoryCode_txt.Focus();
                    }
                    else
                    {
                        DefectiveCategoryName_txt.Focus();
                    }

                    return;
                }

                inVo.DefectiveCategoryCode = DefectiveCategoryCode_txt.Text.Trim();
                inVo.DefectiveCategoryName = DefectiveCategoryName_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))
                {
                    DefectiveCategoryVo checkVo = DuplicateCheck(inVo);

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

                        return;
                    }
                }

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