Ejemplo n.º 1
0
    protected void btnRegister_Click(object sender, EventArgs e)
    {
        clearLabelMsg();
        
        Vacancy vacancy = new Vacancy();

        if (!validateAllData(vacancy) && isGeneralOrGSpecific != 0)
        {
            return;
        }

        VacancyRegistrationAndEvaluationManager manager = new VacancyRegistrationAndEvaluationManager(vacancy);
        TransactionResponse response = manager.addNewVacancy();

        if (response.isSuccessful())
        {
            //update promotion table for the specified minute number

            Promotion promotion = new Promotion();

            if (vacancy.VacancyOpenedFor == "2")
            {
                if (DropDPromMinNumb.SelectedValue != "-1")
                {
                    string[] splitter = new string[] { PageConstants.GREATER_GREATER_THAN };
                    MinNumInfo = (DropDPromMinNumb.SelectedValue).Split(splitter, StringSplitOptions.RemoveEmptyEntries);
                    applicantEID = MinNumInfo[0].Trim();
                    MinNumber = MinNumInfo[1].Trim();

                    promotion.EmpID = applicantEID;
                    promotion.MinuteNo = MinNumber;

                    PromotionManager promotionManager = new PromotionManager(promotion);
                    TransactionResponse promotionResponse = promotionManager.updatePromotion(promotion, vacancy.VacancyNo);
                    if (!promotionResponse.isSuccessful())
                    {
                        clearLabelMsg();
                        msgPanel.Visible = true;
                        ErroroDIV.Visible = true;
                        lblErrorMsg.Text = promotionResponse.getMessage();
                        return;
                    }
                }
                else
                {
                    lblvacForPromotion.Visible = true;
                    lblvacForPromotion.Text = "You can't register vacancy for promotion now. If you want to register vacancy for promotion please first register promotion."+
                    "Or if promotion is already registered please contact you manager to assign promotion to you.";
                }
            }

            clearLabelMsg();
            msgPanel.Visible = true;
            SucessDIV.Visible = true;
            lblSuccessMessage.Text = response.getMessage();

            btnRegister.Visible = false;
            btnCancel.Visible = true;

            PromotionAssigment promotionAssigment = new PromotionAssigment();
            promotionAssigment.MinuteNo = MinNumber;

            if (isVacncyForPromotion)
            {
                //REMOVE THIS TASK FROM HR_MANGERS MAIL BOX
                NotificationManager notificationManager = new NotificationManager(promotion);
                TransactionResponse delteResponse = notificationManager.deleteNotificationForAssignedPromotionforSpecificHROfficer(Membership.GetUser());
                if (!delteResponse.isSuccessful())
                {
                    //check if Warning Message is already logged, if so just add on it
                    if (WarnDIV.Visible)
                    {
                        msgPanel.Visible = true;
                        ErroroDIV.Visible = true;
                        lblWarningMsg.Text = lblWarningMsg.Text + " and " + delteResponse.getMessage() + delteResponse.getErrorCode();
                    }
                    else
                    {
                        msgPanel.Visible = true;
                        ErroroDIV.Visible = true;
                        lblWarningMsg.Text = delteResponse.getMessage() + delteResponse.getErrorCode();
                    }
                }
            }
        }
        else
        {
            msgPanel.Visible = true;
            ErroroDIV.Visible = true;
            lblErrorMsg.Text = response.getMessage() + response.getErrorCode();
        }
    }