Exemplo n.º 1
0
 public PromotionManager(PromotionAssigment promotionAssigment)
 {
     this.promotionAssigment = promotionAssigment;
 }
Exemplo n.º 2
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();
        }
    }
    protected void btnConfirmComplete_Click(object sender, EventArgs e)
    {
        PromotionAssigment promotionAssigment = new PromotionAssigment();

        string minNo = DropDownLMinuteNo.SelectedItem.Text;
        if (minNo != "-1")
        {
            lblminNo.Visible = false;
            string[] splitVacancyDetail = minNo.Split(new string[] { PageConstants.GREATER_GREATER_THAN }, StringSplitOptions.None);
            promotionAssigment.MinuteNo = splitVacancyDetail[1].Trim();

        }
        else
        {
            resetAllControl();
            lblminNo.Visible = true;
            return;
        }

        Promotion promotion = new Promotion();

        promotion.MinuteNo = promotionAssigment.MinuteNo;

        PromotionManager promotionManager = new PromotionManager(promotion);
        TransactionResponse promotionResponse = promotionManager.updatePromotionStatus(promotion, PromotionConstants.PROMOTION_NOT_NEED_VACANCY_CANT_POSTED_BY_DISTRICT);

        if (!promotionResponse.isSuccessful())
        {
            msgPanel.Visible = true;
            ErroroDIV.Visible = true;
            lblErrorMsg.Text = "Error occured while update promotion status. Please contact your system administrator.";
            return;
        }

        //REMOVE THIS TASK FROM HR_MANGERS MAIL BOX

        NotificationManager notificationManager = new NotificationManager(promotionAssigment);
        TransactionResponse delteResponse = notificationManager.deleteNotificationForAssignedPromotion(Membership.GetUser());
        if (!delteResponse.isSuccessful())
        {
            //check if Warning Message is already logged, if so just add on it
            if (WarnDIV.Visible)
            {
                msgPanel.Visible = true;
                lblWarningMsg.Text = lblWarningMsg.Text + " and " + delteResponse.getMessage() + delteResponse.getErrorCode();
            }
            else
            {
                msgPanel.Visible = true;
                WarnDIV.Visible = true;
                lblWarningMsg.Text = delteResponse.getMessage() + delteResponse.getErrorCode();
            }
        }
        else
        {
            PanelConfirmVacancyComplete.Visible = false;
            msgPanel.Visible = true;
            SucessDIV.Visible = true;
            lblSuccessMessage.Text = "Operation Success!";


            btnAssignNew.Visible = false;
            btnAssignPromotion.Visible = true;

            populateAssignedPromotion();
            AssignPromotionPanel.Visible = true;
        }
    }
    private bool vaidateInputAndFillData(PromotionAssigment promotionAssigment)
    {
        bool trackall = true;

        string minNo = null;
        string hrOfficerID = null;

        lblminNo.Visible = true;
        lblHROfficer.Visible = true;
        lblDeadLine4HROfficer.Visible = true;

        minNo = DropDownLMinuteNo.SelectedItem.Text;
        if (DropDownLMinuteNo.SelectedValue != (NOTSELECTED))
        {
            lblminNo.Visible = false;
            string[] splitVacancyDetail = minNo.Split(new string[] { PageConstants.GREATER_GREATER_THAN }, StringSplitOptions.None);
            promotionAssigment.MinuteNo = splitVacancyDetail[1].Trim();
        }
        else
        {
            trackall = false;
        }

        hrOfficerID = DropDownHROfficerList.SelectedValue;
        if (hrOfficerID != "-1")
        {
            lblHROfficer.Visible = false;
            promotionAssigment.HROfficerID = hrOfficerID.Trim();
        }
        else
        {
            trackall = false;
        }

        string AssigmentdeadLine = null;
        try
        {
            AssigmentdeadLine = Convert.ToDateTime(txtdeadLine.Text.Trim()).ToShortDateString();

            if (AssigmentdeadLine.Trim() != "" && AssigmentdeadLine.Trim() != null)
            {
                lblDeadLine4HROfficer.Visible = false;
                promotionAssigment.DeadLine = AssigmentdeadLine.Trim();
            }
            else
            {
                trackall = false;
            }
        }
        catch (FormatException)
        {
            clearMsgPanel();
            msgPanel.Visible = true;
            ErroroDIV.Visible = true;
            lblErrorMsg.Text = "Please enter deadline date in the format 'MM/dd/YYYY' and then try again.";
            return false;
        }

        promotionAssigment.Remark = txtRemark.Text.Trim();

        return trackall;
    }
    protected void btnAssignPromotion_Click(object sender, EventArgs e)
    {
        clearMsgPanel();
        PromotionAssigment promotionAssigment = new PromotionAssigment();

        if (vaidateInputAndFillData(promotionAssigment))
        {
            PromotionManager promotionAssigmentManager = new PromotionManager(promotionAssigment);
            TransactionResponse response = promotionAssigmentManager.addNewPromotionAssignment();

            if (response.isSuccessful())
            {
                msgPanel.Visible = true;
                SucessDIV.Visible = true;
                lblSuccessMessage.Text = response.getMessage();

                AssignPromotionPanel.Visible = true;
                btnAssignNew.Visible = true;
                btnAssignPromotion.Visible = false;

                //REGISTER NOTIFICATION ABOUT THIS ASSIGNMENT TO HR OFFICER
                //HERE THE CIRRENT USER (i.e., HR Manager) IS THE SENDER AND HR OFFICERs ARE THE RECEIVERS
                NotificationManager notificationManager = new NotificationManager(promotionAssigment);
                TransactionResponse notificationResponse = notificationManager.addNotificationForPromotioAssignement(Membership.GetUser());
                if (!notificationResponse.isSuccessful())
                {
                    msgPanel.Visible = true;
                    WarnDIV.Visible = true;
                    lblWarningMsg.Text = notificationResponse.getMessage() + notificationResponse.getErrorCode();
                }

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

                Promotion promotion = new Promotion();

                promotion.MinuteNo = promotionAssigment.MinuteNo;

                PromotionManager promotionManager = new PromotionManager(promotion);
                TransactionResponse promotionResponse = promotionManager.updatePromotionStatus(promotion, PromotionConstants.PROMOTION_ASSIGNED);

                if (!promotionResponse.isSuccessful())
                {
                    msgPanel.Visible = true;
                    ErroroDIV.Visible = true;
                    lblErrorMsg.Text = "Error occured while update promotion status. Please contact your system administrator.";
                    return;
                }
            }
            else
            {
                msgPanel.Visible = true;
                WarnDIV.Visible = true;
                lblWarningMsg.Text = response.getMessage() + response.getErrorCode();
            }
        }

    }
 // use this Constractor when you work on notification of Vacancy
 public NotificationManager(PromotionAssigment promotionAssigment)
 {
     this.notification = new Notification();
     this.promotionAssigment = promotionAssigment;
 }