Exemplo n.º 1
0
    /// <summary>
    /// Gets the certification details.
    /// </summary>
    /// <returns></returns>
    private BusinessEntities.RaveHRCollection GetCertificationDetails(int employeeID)
    {
        Rave.HR.BusinessLayer.Employee.CertificationDetails objCertificationDetailsBAL;
        BusinessEntities.CertificationDetails objCertificationDetails;

        // Initialise Collection class object
        BusinessEntities.RaveHRCollection raveHRCollection = new BusinessEntities.RaveHRCollection();

        try
        {
            objCertificationDetailsBAL = new Rave.HR.BusinessLayer.Employee.CertificationDetails();
            objCertificationDetails    = new BusinessEntities.CertificationDetails();

            //objCertificationDetails.EMPId = 14;
            objCertificationDetails.EMPId = employeeID;

            raveHRCollection = objCertificationDetailsBAL.GetCertificationDetails(objCertificationDetails);
        }
        catch (RaveHRException ex)
        {
            throw ex;
        }
        catch (Exception ex)
        {
            RaveHRException objEx = new RaveHRException(ex.Message, ex, Sources.PresentationLayer, CLASS_NAME, "GetCertificationDetails", EventIDConstants.RAVE_HR_PROJECTS_PRESENTATION_LAYER);
            LogErrorMessage(objEx);
        }

        return(raveHRCollection);
    }
    /// <summary>
    /// Handles the Click event of the btnAdd control.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        Rave.HR.BusinessLayer.Employee.CertificationDetails objCertificationDetailsBAL;

        if (ValidateControls())
        {
            BusinessEntities.CertificationDetails objCertificationDetails = new BusinessEntities.CertificationDetails();
            objCertificationDetailsBAL = new Rave.HR.BusinessLayer.Employee.CertificationDetails();

            if (gvCertification.Rows[0].Cells[0].Text == NO_RECORDS_FOUND_MESSAGE)
            {
                CertificationDetailsCollection.Clear();
            }

            objCertificationDetails.CertificationName = txtName.Text;
            objCertificationDetails.CertificateDate   = Convert.ToDateTime(ucDatePickerCertificationDate.Text);
            if (ucDatePickerCertficationValidDate.Text != "")
            {
                objCertificationDetails.CertificateValidDate = Convert.ToDateTime(ucDatePickerCertficationValidDate.Text);
            }
            // Mohamed :Issue 50440 : 10/04/2014 : Starts
            // Desc : Remove Mandatory validation from "TotalScore" and "OutOf" Fields
            objCertificationDetails.Score = float.Parse(txtTotalScore.Text == "" ? "0" : txtTotalScore.Text);
            objCertificationDetails.OutOf = float.Parse(txtOutOf.Text == "" ? "0" : txtOutOf.Text);
            // Mohamed :Issue 50440 : 10/04/2014 : Ends
            objCertificationDetails.Mode  = 1;
            objCertificationDetails.EMPId = int.Parse(EMPId.Value);

            CertificationDetailsCollection.Add(objCertificationDetails);

            objCertificationDetailsBAL.AddCertificationDetails(objCertificationDetails);

            this.PopulateGrid(objCertificationDetails.EMPId);

            this.ClearControls();
            //To solved the issue no 19221
            //Comment by Rahul P
            //Start
            //btnAddRow.Text = CommonConstants.BTN_AddRow;
            btnAddRow.Text = "Save";
            //End
            lblMessage.Text = "Certification details saved successfully.";
        }
    }
Exemplo n.º 3
0
    /// <summary>
    /// Handles the Click event of the btnSave control.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
    protected void btnSave_Click(object sender, EventArgs e)
    {
        Rave.HR.BusinessLayer.Employee.CertificationDetails objCertificationDetailsBAL;

        BusinessEntities.CertificationDetails objCertificationDetails;
        BusinessEntities.RaveHRCollection     objSaveCertificationDetailsCollection = new BusinessEntities.RaveHRCollection();

        try
        {
            objCertificationDetailsBAL = new Rave.HR.BusinessLayer.Employee.CertificationDetails();

            if (gvCertification.Rows[0].Cells[0].Text != NO_RECORDS_FOUND_MESSAGE)
            {
                for (int i = 0; i < gvCertification.Rows.Count; i++)
                {
                    objCertificationDetails = new BusinessEntities.CertificationDetails();
                    Label CertificationId = (Label)gvCertification.Rows[i].FindControl(CERTIFICATIONID);
                    Label Mode            = (Label)gvCertification.Rows[i].FindControl(MODE);

                    objCertificationDetails.CertificationId      = int.Parse(CertificationId.Text);
                    objCertificationDetails.EMPId                = int.Parse(EMPId.Value);
                    objCertificationDetails.CertificationName    = gvCertification.Rows[i].Cells[0].Text;
                    objCertificationDetails.CertificateDate      = Convert.ToDateTime(gvCertification.Rows[i].Cells[1].Text);
                    objCertificationDetails.CertificateValidDate = Convert.ToDateTime(gvCertification.Rows[i].Cells[2].Text);
                    objCertificationDetails.Score                = float.Parse(gvCertification.Rows[i].Cells[3].Text);
                    objCertificationDetails.OutOf                = float.Parse(gvCertification.Rows[i].Cells[4].Text);
                    objCertificationDetails.Mode = int.Parse(Mode.Text);
                    objSaveCertificationDetailsCollection.Add(objCertificationDetails);
                }
            }
            BusinessEntities.RaveHRCollection objDeleteCertificationDetailsCollection = (BusinessEntities.RaveHRCollection)ViewState[CERTIFICATIONDETAILSDELETE];

            if (objDeleteCertificationDetailsCollection != null)
            {
                BusinessEntities.CertificationDetails obj = null;

                for (int i = 0; i < objDeleteCertificationDetailsCollection.Count; i++)
                {
                    objCertificationDetails = new BusinessEntities.CertificationDetails();
                    obj = (BusinessEntities.CertificationDetails)objDeleteCertificationDetailsCollection.Item(i);

                    objCertificationDetails.CertificationId      = obj.CertificationId;
                    objCertificationDetails.EMPId                = obj.EMPId;
                    objCertificationDetails.CertificationName    = obj.CertificationName;
                    objCertificationDetails.CertificateDate      = obj.CertificateDate;
                    objCertificationDetails.CertificateValidDate = obj.CertificateValidDate;
                    objCertificationDetails.Score                = obj.Score;
                    objCertificationDetails.OutOf                = obj.OutOf;
                    objCertificationDetails.Mode = obj.Mode;

                    objSaveCertificationDetailsCollection.Add(objCertificationDetails);
                }
            }
            objCertificationDetailsBAL.Manipulation(objSaveCertificationDetailsCollection);

            if (ViewState.Count > 0)
            {
                ViewState.Clear();
            }

            if (EMPId.Value != string.Empty)
            {
                int empID = Convert.ToInt32(EMPId.Value);
                //Refresh the grip after saving
                this.PopulateGrid(empID);
            }

            if (gvCertification.Rows.Count == 0)
            {
                btnSave.Visible = false;
            }

            lblMessage.Text = "Certification details saved successfully.";
        }
        catch (RaveHRException ex)
        {
            LogErrorMessage(ex);
        }
        catch (Exception ex)
        {
            RaveHRException objEx = new RaveHRException(ex.Message, ex, Sources.PresentationLayer, CLASS_NAME, "btnSave_Click", EventIDConstants.RAVE_HR_PROJECTS_PRESENTATION_LAYER);
            LogErrorMessage(objEx);
        }
    }
    /// <summary>
    /// Handles the Click event of the btnUpdate control.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        Rave.HR.BusinessLayer.Employee.CertificationDetails objCertificationDetailsBAL;
        BusinessEntities.CertificationDetails objCertificationDetails = new BusinessEntities.CertificationDetails();

        if (ValidateControls())
        {
            objCertificationDetailsBAL = new Rave.HR.BusinessLayer.Employee.CertificationDetails();
            int rowIndex       = 0;
            int deleteRowIndex = -1;
            int temp           = 0;

            if (ViewState[DELETEROWINDEX] != null)
            {
                deleteRowIndex = Convert.ToInt32(ViewState[DELETEROWINDEX].ToString());
            }

            //Update the grid view according the row, which is selected for editing.
            if (ViewState[ROWINDEX] != null)
            {
                rowIndex = Convert.ToInt32(ViewState[ROWINDEX].ToString());
                if (deleteRowIndex != -1 && deleteRowIndex < rowIndex)
                {
                    rowIndex--;
                }
                Label CertificationId = (Label)gvCertification.Rows[rowIndex].FindControl(CERTIFICATIONID);
                Label Mode            = (Label)gvCertification.Rows[rowIndex].FindControl(MODE);

                gvCertification.Rows[rowIndex].Cells[0].Text = txtName.Text;
                gvCertification.Rows[rowIndex].Cells[1].Text = ucDatePickerCertificationDate.Text;
                gvCertification.Rows[rowIndex].Cells[2].Text = ucDatePickerCertficationValidDate.Text;
                gvCertification.Rows[rowIndex].Cells[3].Text = txtTotalScore.Text;
                gvCertification.Rows[rowIndex].Cells[4].Text = txtOutOf.Text;

                if (int.Parse(CertificationId.Text) == 0)
                {
                    Mode.Text = "1";
                }
                else
                {
                    Mode.Text = "2";
                }
                ImageButton btnImg = (ImageButton)gvCertification.Rows[rowIndex].FindControl(IMGBTNDELETE);
                btnImg.Enabled            = true;
                ViewState[ROWINDEX]       = null;
                ViewState[DELETEROWINDEX] = null;
            }

            //Mohamed : Issue 50200 : 28/03/2014 : Starts
            //Desc :  Aryabhatta has raised 2 issues in RMS
            //for (int i = 0; i < CertificationDetailsCollection.Count; i++)
            //{

            objCertificationDetails = (BusinessEntities.CertificationDetails)CertificationDetailsCollection.Item(rowIndex);

            Label Grid_CertificationId = (Label)gvCertification.Rows[rowIndex].FindControl(CERTIFICATIONID);
            Label Grid_Mode            = (Label)gvCertification.Rows[rowIndex].FindControl(MODE);

            objCertificationDetails.CertificationId   = int.Parse(Grid_CertificationId.Text);
            objCertificationDetails.EMPId             = int.Parse(EMPId.Value);
            objCertificationDetails.CertificationName = gvCertification.Rows[rowIndex].Cells[0].Text;
            objCertificationDetails.CertificateDate   = Convert.ToDateTime(gvCertification.Rows[rowIndex].Cells[1].Text);
            if (gvCertification.Rows[rowIndex].Cells[2].Text != "")
            {
                objCertificationDetails.CertificateValidDate = Convert.ToDateTime(gvCertification.Rows[rowIndex].Cells[2].Text);
            }
            objCertificationDetails.Score = float.Parse(gvCertification.Rows[rowIndex].Cells[3].Text);
            objCertificationDetails.OutOf = float.Parse(gvCertification.Rows[rowIndex].Cells[4].Text);
            objCertificationDetails.Mode  = int.Parse(Grid_Mode.Text);
            //}

            this.DoDataBind();

            objCertificationDetailsBAL.UpdateCertificationDetails(objCertificationDetails);

            //Mohamed : Issue 50200 : 28/03/2014 : Ends

            //Clear all the fields after inserting row into gridview
            this.ClearControls();

            btnAddRow.Visible    = true;
            btnUpdate.Visible    = false;
            btnCancelRow.Visible = false;
            //To solved the issue no 19221
            //Comment by Rahul P
            //Start
            btnCancel.Visible = true;
            //End
            //Enabling all the edit buttons.
            for (int i = 0; i < gvCertification.Rows.Count; i++)
            {
                ImageButton btnImgEdit = (ImageButton)gvCertification.Rows[i].FindControl(IMGBTNEDIT);
                btnImgEdit.Enabled = true;
            }
            HfIsDataModified.Value = string.Empty;

            lblMessage.Text = "Certification details updated successfully.";
        }
    }
    /// <summary>
    /// Handles the RowDeleting event of the gvCertification control.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="System.Web.UI.WebControls.GridViewDeleteEventArgs"/> instance containing the event data.</param>
    protected void gvCertification_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        int     deleteRowIndex = 0;
        int     rowIndex       = -1;
        Boolean Flag           = false;

        Rave.HR.BusinessLayer.Employee.CertificationDetails objCertificationDetailsBAL;
        BusinessEntities.CertificationDetails objCertificationDetails = new BusinessEntities.CertificationDetails();
        objCertificationDetailsBAL = new Rave.HR.BusinessLayer.Employee.CertificationDetails();

        deleteRowIndex = e.RowIndex;

        objCertificationDetails = (BusinessEntities.CertificationDetails)CertificationDetailsCollection.Item(deleteRowIndex);
        if (objCertificationDetails.Mode == 1)
        {
            Flag = true;
        }
        objCertificationDetails.Mode = 3;

        if (ViewState[CERTIFICATIONDETAILSDELETE] != null)
        {
            BusinessEntities.RaveHRCollection objDeleteCertificationDetailsCollection = (BusinessEntities.RaveHRCollection)ViewState[CERTIFICATIONDETAILSDELETE];
            objDeleteCertificationDetailsCollection.Add(objCertificationDetails);

            ViewState[CERTIFICATIONDETAILSDELETE] = objDeleteCertificationDetailsCollection;
        }
        else
        {
            BusinessEntities.RaveHRCollection objDeleteCertificationDetailsCollection1 = new BusinessEntities.RaveHRCollection();

            objDeleteCertificationDetailsCollection1.Add(objCertificationDetails);

            ViewState[CERTIFICATIONDETAILSDELETE] = objDeleteCertificationDetailsCollection1;
        }

        CertificationDetailsCollection.RemoveAt(deleteRowIndex);

        ViewState[DELETEROWINDEX] = deleteRowIndex;

        DoDataBind();

        objCertificationDetailsBAL.DeleteCertificationDetails(objCertificationDetails);

        if (ViewState[ROWINDEX] != null)
        {
            rowIndex = Convert.ToInt32(ViewState[ROWINDEX].ToString());
            //check edit index with deleted index if edit index is greater than or equal to delete index then rowindex decremented.
            if (rowIndex != -1 && deleteRowIndex <= rowIndex)
            {
                rowIndex--;
                //store the rowindex in viewstate.
                ViewState[ROWINDEX] = rowIndex;
            }

            ImageButton btnImg = (ImageButton)gvCertification.Rows[rowIndex].FindControl(IMGBTNDELETE);
            btnImg.Enabled = false;

            //Disabling all the edit buttons.
            for (int i = 0; i < gvCertification.Rows.Count; i++)
            {
                if (rowIndex != i)
                {
                    ImageButton btnImgEdit = (ImageButton)gvCertification.Rows[i].FindControl(IMGBTNEDIT);
                    btnImgEdit.Enabled = false;
                }
            }
        }

        lblMessage.Text = "Certification details deleted successfully.";
    }