Exemplo n.º 1
0
    /// <summary>
    /// Gets the project details.
    /// </summary>
    /// <returns></returns>
    private BusinessEntities.RaveHRCollection GetProjectDetails(int employeeID)
    {
        Rave.HR.BusinessLayer.Employee.ProjectDetails objProjectDetailsBAL;
        BusinessEntities.ProjectDetails objProjectDetails;

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

        try
        {
            objProjectDetailsBAL = new Rave.HR.BusinessLayer.Employee.ProjectDetails();
            objProjectDetails    = new BusinessEntities.ProjectDetails();

            objProjectDetails.EMPId = employeeID;

            raveHRCollection = objProjectDetailsBAL.GetProjectDetails(objProjectDetails);
        }
        catch (RaveHRException ex)
        {
            throw ex;
        }
        catch (Exception ex)
        {
            RaveHRException objEx = new RaveHRException(ex.Message, ex, Sources.PresentationLayer, CLASS_NAME, "GetProjectDetails", EventIDConstants.RAVE_HR_EMPLOYEE_PRESENTATION_LAYER);
            LogErrorMessage(objEx);
        }

        return(raveHRCollection);
    }
Exemplo n.º 2
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.ProjectDetails objProjectDetailsBAL;

        BusinessEntities.ProjectDetails   objProjectDetails;
        BusinessEntities.RaveHRCollection objSaveProjectDetailsCollection = new BusinessEntities.RaveHRCollection();

        try
        {
            objProjectDetailsBAL = new Rave.HR.BusinessLayer.Employee.ProjectDetails();

            if (gvProjectDetails.Rows[0].Cells[0].Text != NO_RECORDS_FOUND_MESSAGE)
            {
                for (int i = 0; i < gvProjectDetails.Rows.Count; i++)
                {
                    objProjectDetails = new BusinessEntities.ProjectDetails();
                    Label ProjectId = (Label)gvProjectDetails.Rows[i].FindControl(PROJECTID);
                    Label Mode      = (Label)gvProjectDetails.Rows[i].FindControl(MODE);

                    objProjectDetails.ProjectId       = int.Parse(ProjectId.Text);
                    objProjectDetails.EMPId           = int.Parse(EMPId.Value);
                    objProjectDetails.Organisation    = gvProjectDetails.Rows[i].Cells[2].Text;
                    objProjectDetails.ProjectName     = gvProjectDetails.Rows[i].Cells[1].Text;
                    objProjectDetails.ProjectLocation = gvProjectDetails.Rows[i].Cells[3].Text;
                    objProjectDetails.ClientName      = gvProjectDetails.Rows[i].Cells[4].Text;
                    objProjectDetails.ProjectSize     = int.Parse(gvProjectDetails.Rows[i].Cells[5].Text);
                    objProjectDetails.OnsiteDuration  = gvProjectDetails.Rows[i].Cells[6].Text;
                    objProjectDetails.Role            = gvProjectDetails.Rows[i].Cells[7].Text;
                    objProjectDetails.Description     = gvProjectDetails.Rows[i].Cells[8].Text;
                    objProjectDetails.Resposibility   = gvProjectDetails.Rows[i].Cells[9].Text;
                    objProjectDetails.Mode            = int.Parse(Mode.Text);

                    Label LocationId = (Label)gvProjectDetails.Rows[i].FindControl(ProjectLocationId);
                    objProjectDetails.LocationId = Convert.ToInt32(LocationId.Text);

                    Label ProjectDoneID = (Label)gvProjectDetails.Rows[i].FindControl(ProjectDoneStatus);
                    objProjectDetails.ProjectDone = Convert.ToInt32(ProjectDoneID.Text);

                    objSaveProjectDetailsCollection.Add(objProjectDetails);
                }
            }
            BusinessEntities.RaveHRCollection objDeleteProjectDetailsCollection = (BusinessEntities.RaveHRCollection)ViewState[PROJECTDETAILSDELETE];

            if (objDeleteProjectDetailsCollection != null)
            {
                BusinessEntities.ProjectDetails obj = null;

                for (int i = 0; i < objDeleteProjectDetailsCollection.Count; i++)
                {
                    objProjectDetails = new BusinessEntities.ProjectDetails();
                    obj = (BusinessEntities.ProjectDetails)objDeleteProjectDetailsCollection.Item(i);

                    objProjectDetails.ProjectId       = obj.ProjectId;
                    objProjectDetails.EMPId           = obj.EMPId;
                    objProjectDetails.ProjectName     = obj.ProjectName;
                    objProjectDetails.Organisation    = obj.Organisation;
                    objProjectDetails.ClientName      = obj.ClientName;
                    objProjectDetails.ProjectSize     = obj.ProjectSize;
                    objProjectDetails.Role            = obj.Role;
                    objProjectDetails.ProjectLocation = obj.ProjectLocation;
                    objProjectDetails.OnsiteDuration  = obj.OnsiteDuration;
                    objProjectDetails.Description     = obj.Description;
                    objProjectDetails.Resposibility   = obj.Resposibility;
                    objProjectDetails.ProjectSize     = obj.ProjectSize;
                    objProjectDetails.Mode            = obj.Mode;
                    objProjectDetails.LocationId      = objProjectDetails.LocationId;
                    objProjectDetails.ProjectDone     = obj.ProjectDone;
                    objProjectDetails.ProjectDoneName = obj.ProjectDoneName;
                    objSaveProjectDetailsCollection.Add(objProjectDetails);
                }
            }
            objProjectDetailsBAL.Manipulation(objSaveProjectDetailsCollection);

            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 (gvProjectDetails.Rows.Count == 0)
            {
                btnSave.Visible = false;
            }

            lblMessage.Text = "Project 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_EMPLOYEE_PRESENTATION_LAYER);
            LogErrorMessage(objEx);
        }
    }