Example #1
0
    protected void btnAddEmployee_Click(object sender, EventArgs e)
    {
        try
        {
            string newEmpId = HfViewRights.Value;

            List <string> lstDuplicate = new List <string> {
            };
            List <string> lstNewEmpId  = new List <string> {
            };
            string strDuplicateName    = "";

            if (!string.IsNullOrEmpty(newEmpId))
            {
                string[] empidarray = newEmpId.Split(',');

                for (int i = 0; i < empidarray.Length; i++)
                {
                    string tempEmpId = empidarray[i];
                    bool   flag      = true;
                    for (int iRow = 0; iRow <= grdvCreatorApprover.Rows.Count - 1; iRow++)
                    {
                        HiddenField HfEmpIdInGrd = (HiddenField)grdvCreatorApprover.Rows[iRow].FindControl("HfCreatorGrd");
                        if (HfEmpIdInGrd.Value == tempEmpId)
                        {
                            lstDuplicate.Add(tempEmpId);
                            if (strDuplicateName == "")
                            {
                                strDuplicateName = strDuplicateName + grdvCreatorApprover.Rows[iRow].Cells[2].Text.ToString();
                            }
                            else
                            {
                                strDuplicateName = " " + strDuplicateName + " , " + grdvCreatorApprover.Rows[iRow].Cells[2].Text.ToString();
                            }
                            flag = false;
                            break;
                        }
                    }

                    if (flag)
                    {
                        lstNewEmpId.Add(tempEmpId);
                    }
                }

                if (!string.IsNullOrEmpty(strDuplicateName))
                {
                    Page page = HttpContext.Current.Handler as Page;
                    ScriptManager.RegisterStartupScript(page, page.GetType(), "err_msg", "alert('Employee " + strDuplicateName + " has already assigned view access rights.');", true);
                }

                if (lstNewEmpId.Count > 0)
                {
                    Rave.HR.BusinessLayer.FourC.FourC fourCBAL = new Rave.HR.BusinessLayer.FourC.FourC();
                    fourCBAL.AddDeleteViewAccessRights(lstNewEmpId, UserMailId, "Add");

                    getEmployeeData();

                    lblMessage.Visible        = true;
                    lblMessage.Text           = "Data Added Successfully!!!.";
                    lblMessage.Style["color"] = "blue";
                }
            }
        }
        catch (RaveHRException ex)
        {
            LogErrorMessage(ex);
        }
        catch (Exception ex)
        {
            RaveHRException objEx = new RaveHRException(ex.Message, ex, Sources.PresentationLayer, CLASS_NAME, "btnAddEmployee_Click", EventIDConstants.RAVE_HR_PROJECTS_PRESENTATION_LAYER);
            LogErrorMessage(objEx);
        }
    }
Example #2
0
    protected void grdvCreatorApprover_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        lblMessage.Visible = false;



        if (e.CommandName == "Edt")
        {
            GridViewRow row            = (GridViewRow)((Control)e.CommandSource).NamingContainer;
            HiddenField HfProjectId    = (HiddenField)row.FindControl("hfProjectId");
            HiddenField HfDepartmentId = (HiddenField)row.FindControl("HfDepartmentId");
            HiddenField HfCreatorGrd   = (HiddenField)row.FindControl("HfCreatorGrd");
            HiddenField HfReviewerGrd  = (HiddenField)row.FindControl("HfReviewerGrd");

            btnAdd.Enabled    = false;
            btnUpdate.Enabled = true;

            HfCreator.Value  = HfCreatorGrd.Value;
            HfReviewer.Value = HfReviewerGrd.Value;

            txtCreator.Text  = row.Cells[2].Text;
            txtReviewer.Text = row.Cells[3].Text;

            //Declaring COllection class object
            BusinessEntities.RaveHRCollection   raveHRCollection = new BusinessEntities.RaveHRCollection();
            Rave.HR.BusinessLayer.Common.Master master           = new Rave.HR.BusinessLayer.Common.Master();
            raveHRCollection = master.FillDepartmentDropDownBL();

            ddlDepartment.Items.Clear();
            ddlDepartment.DataSource     = raveHRCollection;
            ddlDepartment.DataTextField  = Common.CommonConstants.DDL_DataTextField;
            ddlDepartment.DataValueField = Common.CommonConstants.DDL_DataValueField;
            ddlDepartment.DataBind();
            ddlDepartment.Items.Insert(CommonConstants.ZERO, CommonConstants.SELECT);


            ddlDepartment.SelectedValue = HfDepartmentId.Value;

            if (HfDepartmentId.Value == "1")
            {
                ddlProject.Enabled = true;

                Rave.HR.BusinessLayer.MRF.MRFDetail mrfProjectName = new Rave.HR.BusinessLayer.MRF.MRFDetail();
                raveHRCollection = mrfProjectName.GetProjectName();

                ddlProject.Items.Clear();
                ddlProject.DataSource     = raveHRCollection;
                ddlProject.DataTextField  = CommonConstants.DDL_DataTextField;
                ddlProject.DataValueField = CommonConstants.DDL_DataValueField;

                // Bind the data to dropdown
                ddlProject.DataBind();
                // Default value of dropdown is "Select"
                ddlProject.Items.Insert(CommonConstants.ZERO, CommonConstants.SELECT);


                if (!string.IsNullOrEmpty(HfProjectId.Value))
                {
                    ddlProject.SelectedValue = HfProjectId.Value;
                }
            }
            else
            {
                ddlProject.SelectedItem.Text = "SELECT";
            }

            ddlDepartment.Enabled = false;
            ddlProject.Enabled    = false;
        }
        else if (e.CommandName == "Del")
        {
            try
            {
                if (rblAdminSelectionOption.SelectedIndex == 0)
                {
                    GridViewRow row            = (GridViewRow)((Control)e.CommandSource).NamingContainer;
                    HiddenField HfProjectId    = (HiddenField)row.FindControl("hfProjectId");
                    HiddenField HfDepartmentId = (HiddenField)row.FindControl("HfDepartmentId");
                    HiddenField HfCreatorGrd   = (HiddenField)row.FindControl("HfCreatorGrd");
                    HiddenField HfReviewerGrd  = (HiddenField)row.FindControl("HfReviewerGrd");


                    Rave.HR.BusinessLayer.FourC.FourC fourCBAL = new Rave.HR.BusinessLayer.FourC.FourC();
                    int depId  = int.Parse(HfDepartmentId.Value);
                    int projId = 0;

                    if (depId == 1)
                    {
                        projId = int.Parse(HfProjectId.Value);
                    }


                    fourCBAL.AddUpdateDeleteCreatorReviewer(depId, projId, HfCreator.Value, HfReviewer.Value, UserMailId, "Delete");
                    FillCreatorApproverData();

                    ClearControl();

                    lblMessage.Visible        = true;
                    lblMessage.Text           = "Data Deleted Successfully!!!.";
                    lblMessage.Style["color"] = "blue";
                }
                else
                {
                    GridViewRow   row          = (GridViewRow)((Control)e.CommandSource).NamingContainer;
                    HiddenField   HfCreatorGrd = (HiddenField)row.FindControl("HfCreatorGrd");
                    List <string> ls           = new List <string> {
                    };
                    ls.Add(HfCreatorGrd.Value);

                    if (ls.Count > 0 && !string.IsNullOrEmpty(HfCreatorGrd.Value))
                    {
                        Rave.HR.BusinessLayer.FourC.FourC fourCBAL = new Rave.HR.BusinessLayer.FourC.FourC();
                        fourCBAL.AddDeleteViewAccessRights(ls, UserMailId, "Delete");

                        getEmployeeData();

                        lblMessage.Visible        = true;
                        lblMessage.Text           = "Data Added Successfully!!!.";
                        lblMessage.Style["color"] = "blue";
                    }
                }
            }
            catch (RaveHRException ex)
            {
                LogErrorMessage(ex);
            }
            catch (Exception ex)
            {
                RaveHRException objEx = new RaveHRException(ex.Message, ex, Sources.PresentationLayer, CLASS_NAME, "grdvCreatorApprover_RowCommand", EventIDConstants.RAVE_HR_PROJECTS_PRESENTATION_LAYER);
                LogErrorMessage(objEx);
            }
        }
    }