예제 #1
0
        /// <summary>
        /// Fills all user records to gridview control
        /// </summary>
        private void GridBind(EmployeeVo conditionInVo)
        {
            EmployeeDetails_dgv.DataSource = null;

            try
            {
                EmployeeVo outVo = (EmployeeVo)base.InvokeCbm(new GetEmployeeMasterMntCbm(), conditionInVo, false);

                EmployeeDetails_dgv.AutoGenerateColumns = false;

                BindingSource lineBindingSource = new BindingSource(outVo.EmployeeListVo, null);

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

                EmployeeDetails_dgv.ClearSelection();

                Update_btn.Enabled = false;

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

            EmployeeVo selectedEmployee = (EmployeeVo)EmployeeDetails_dgv.Rows[selectedrowindex].DataBoundItem;

            AddEmployeeMasterForm newAddForm = new AddEmployeeMasterForm(CommonConstants.MODE_UPDATE, selectedEmployee);

            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());
            }
        }
예제 #3
0
        public override ValueObject Execute(TransactionContext trxContext, ValueObject arg)
        {
            EmployeeVo inVo = (EmployeeVo)arg;

            StringBuilder sqlQuery = new StringBuilder();

            sqlQuery.Append("Update m_employee");
            sqlQuery.Append(" Set ");
            sqlQuery.Append(" employee_name = :empname, ");
            sqlQuery.Append(" department = :department, ");
            sqlQuery.Append(" is_active = :isactive ");
            sqlQuery.Append(" Where	");
            sqlQuery.Append(" employee_cd = :empcd ;");

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

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

            sqlParameter.AddParameterString("empname", inVo.EmployeeName);
            sqlParameter.AddParameterString("empcd", inVo.EmployeeCode);
            sqlParameter.AddParameterString("department", inVo.Department);
            sqlParameter.AddParameterInteger("isactive", inVo.IsActive);
            EmployeeVo outVo = new EmployeeVo {
                AffectedCount = sqlCommandAdapter.ExecuteNonQuery(sqlParameter)
            };

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

            StringBuilder sqlQuery = new StringBuilder();

            //create SQL
            sqlQuery.Append("Select em.employee_cd, em.employee_name, em.department, em.is_active ");
            sqlQuery.Append(" from m_employee em ");
            sqlQuery.Append(" where 1 = 1 ");

            if (inVo.EmployeeCode != null)
            {
                sqlQuery.Append(" and employee_cd like :empcd ");
            }

            if (inVo.EmployeeName != null)
            {
                sqlQuery.Append(" and employee_name like :empname ");
            }

            sqlQuery.Append(" order by em.employee_cd");

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

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

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

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

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

            EmployeeVo outVo = new EmployeeVo();

            while (dataReader.Read())
            {
                EmployeeVo currOutVo = new EmployeeVo();

                currOutVo.EmployeeCode = ConvertDBNull <string>(dataReader, "employee_cd");
                currOutVo.EmployeeName = ConvertDBNull <string>(dataReader, "employee_name");
                currOutVo.Department   = ConvertDBNull <string>(dataReader, "department");
                currOutVo.IsActive     = ConvertDBNull <int>(dataReader, "is_active");

                outVo.EmployeeListVo.Add(currOutVo);
            }

            dataReader.Close();

            return(outVo);
        }
 /// <summary>
 /// For setting selected Line record into respective controls(textbox and combobox) for update operation
 /// passing selected Line data as parameter
 /// </summary>
 /// <param name="dgvEmployee"></param>
 private void LoadEmployeeData(EmployeeVo dgvLine)
 {
     if (dgvLine != null)
     {
         this.EmployeeCode_txt.Text = dgvLine.EmployeeCode;
         this.EmployeeName_txt.Text = dgvLine.EmployeeName;
     }
 }
        /// <summary>
        /// constructor
        /// </summary>
        /// <param name="pmode"></param>
        /// <param name="EmployeeItem"></param>
        public AddEmployeeMasterForm(string pmode, EmployeeVo EmployeeItem = null)
        {
            InitializeComponent();

            mode = pmode;

            updateData = EmployeeItem;
            if (string.Equals(mode, CommonConstants.MODE_UPDATE))
            {
                this.Text = UpdateText_lbl.Text;
            }
        }
예제 #7
0
        public override ValueObject Execute(TransactionContext trxContext, ValueObject arg)
        {
            EmployeeVo inVo = (EmployeeVo)arg;

            StringBuilder sqlQuery = new StringBuilder();


            sqlQuery.Append("Insert into m_employee");
            sqlQuery.Append(" ( ");
            sqlQuery.Append(" employee_cd, ");
            sqlQuery.Append(" employee_name, ");
            sqlQuery.Append(" department, ");
            sqlQuery.Append(" is_active, ");
            sqlQuery.Append(" registration_user_cd, ");
            sqlQuery.Append(" registration_date_time, ");
            sqlQuery.Append(" factory_cd ");
            sqlQuery.Append(" ) ");
            sqlQuery.Append("VALUES	");
            sqlQuery.Append(" ( ");
            sqlQuery.Append(" :empcd ,");
            sqlQuery.Append(" :empname ,");
            sqlQuery.Append(" :department ,");
            sqlQuery.Append(" :isactive ,");
            sqlQuery.Append(" :registrationusercode ,");
            sqlQuery.Append(" :registrationdatetime ,");
            sqlQuery.Append(" :factorycode ");
            sqlQuery.Append(" ); ");

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

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

            sqlParameter.AddParameterString("empcd", inVo.EmployeeCode);
            sqlParameter.AddParameterString("empname", inVo.EmployeeName);
            sqlParameter.AddParameterString("department", inVo.Department);
            sqlParameter.AddParameterInteger("isactive", inVo.IsActive);
            sqlParameter.AddParameterString("registrationusercode", inVo.RegistrationUserCode);
            sqlParameter.AddParameterDateTime("registrationdatetime", trxContext.ProcessingDBDateTime);
            sqlParameter.AddParameterString("factorycode", inVo.FactoryCode);

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

            return(outVo);
        }
        /// <summary>
        /// checks duplicate FactoryCode
        /// </summary>
        /// <param name="EmployeeVo"></param>
        /// <returns></returns>
        private EmployeeVo DuplicateCheck(EmployeeVo EmployeeVo)
        {
            EmployeeVo outVo = new EmployeeVo();

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

            return(outVo);
        }
예제 #9
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 = EmployeeDetails_dgv.SelectedCells[0].RowIndex;

            DataGridViewRow selectedRow = EmployeeDetails_dgv.Rows[selectedrowindex];

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

            if (dialogResult == DialogResult.OK)
            {
                EmployeeVo inVo = new EmployeeVo
                {
                    EmployeeCode = selectedRow.Cells["colEmployeeCode"].Value.ToString()
                };

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


            if (EmployeeCode_txt.Text != string.Empty)
            {
                inVo.EmployeeCode = EmployeeCode_txt.Text;
            }

            if (EmployeeName_txt.Text != string.Empty)
            {
                inVo.EmployeeName = EmployeeName_txt.Text;
            }

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

            StringBuilder sqlQuery = new StringBuilder();

            sqlQuery.Append("Select Count(*) as EmpCount from m_employee ");
            sqlQuery.Append(" where 1 = 1 ");

            if (inVo.EmployeeCode != null)
            {
                sqlQuery.Append(" and UPPER(employee_cd) = UPPER(:empcd)");
            }

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

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

            if (inVo.EmployeeCode != null)
            {
                sqlParameter.AddParameterString("empcd", inVo.EmployeeCode);
            }

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

            EmployeeVo outVo = new EmployeeVo();

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

            dataReader.Close();

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

            StringBuilder sqlQuery = new StringBuilder();

            sqlQuery.Append("Delete From m_employee");
            sqlQuery.Append(" Where	");
            sqlQuery.Append(" employee_cd = :empcd;");

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

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

            sqlParameter.AddParameterString("empcd", inVo.EmployeeCode);

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

            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)
        {
            EmployeeVo inVo = new EmployeeVo();

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

                if (!sch.IsASCII(EmployeeCode_txt.Text) || !sch.IsASCII(EmployeeName_txt.Text))
                {
                    messageData = new MessageData("mmce00003", Properties.Resources.mmce00003);
                    logger.Info(messageData);
                    popUpMessage.ConfirmationOkCancel(messageData, Text);

                    if (!sch.IsASCII(EmployeeCode_txt.Text))
                    {
                        EmployeeCode_txt.Focus();
                    }
                    else
                    {
                        EmployeeName_txt.Focus();
                    }

                    return;
                }

                inVo.EmployeeCode = EmployeeCode_txt.Text.Trim();
                inVo.EmployeeName = EmployeeName_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))
                {
                    EmployeeVo checkVo = DuplicateCheck(inVo);

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

                        return;
                    }
                }

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