Пример #1
0
        public static EvalNotes getPreviouslySavedEvalNotes(string strEmpDisplayName, string Active_Rate_Goals_Year)
        {
            EvalNotes notes = new EvalNotes();

            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                SPSite oSite  = new SPSite(SPContext.Current.Web.Url);
                SPWeb spWeb   = oSite.OpenWeb();
                SPList spList = spWeb.GetList(SPUrlUtility.CombineUrl(spWeb.ServerRelativeUrl, "lists/" + "ObjsEvalNotes"));
                if (spList != null)
                {
                    SPQuery qry = new SPQuery();
                    qry.Query   =
                        @"   <Where>
                                          <And>
                                             <Eq>
                                                <FieldRef Name='Emp' />
                                                <Value Type='User'>" + strEmpDisplayName + @"</Value>
                                             </Eq>
                                             <Eq>
                                                <FieldRef Name='ObjsYear' />
                                                <Value Type='Text'>" + Active_Rate_Goals_Year + @"</Value>
                                             </Eq>
                                          </And>
                                       </Where>";
                    SPListItemCollection results = spList.GetItems(qry);
                    if (results.Count > 0)
                    {
                        notes.ReasonForRating1or5 = (results[0]["Note_ReasonForRating1or5"])?.ToString() ?? "";
                        notes.RecommendedCourses  = results[0]["Note_RecommendedCourses"]?.ToString() ?? "";
                    }
                }
            });

            return(notes);
        }
Пример #2
0
        public static void Save_or_Update_Objs_EvalNotes(string login_name_to_convert_to_SPUser, string Active_Rate_Goals_Year, EvalNotes evalnotes)
        {
            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                SPSite oSite             = new SPSite(SPContext.Current.Web.Url);
                SPWeb spWeb              = oSite.OpenWeb();
                spWeb.AllowUnsafeUpdates = true;
                SPList spList            = spWeb.GetList(SPUrlUtility.CombineUrl(spWeb.ServerRelativeUrl, "lists/" + "ObjsEvalNotes"));
                SPUser user              = SPContext.Current.Web.EnsureUser(login_name_to_convert_to_SPUser);
                string strEmpDisplayName = user.Name;

                #region Check if there is already a record for same Employee

                SPQuery qry = new SPQuery();
                qry.Query   =
                    @"   <Where>
                                          <And>
                                             <Eq>
                                                <FieldRef Name='Emp' />
                                                <Value Type='User'>" + strEmpDisplayName + @"</Value>
                                             </Eq>
                                             <Eq>
                                                <FieldRef Name='ObjsYear' />
                                                <Value Type='Text'>" + Active_Rate_Goals_Year + @"</Value>
                                             </Eq>
                                          </And>
                                       </Where>";
                SPListItemCollection results = spList.GetItems(qry);

                #endregion Check if there is already a record for same Employee

                if (results.Count > 0)
                {
                    SPListItem oListItem = spList.GetItemById(int.Parse(results[0]["ID"].ToString()));
                    oListItem["Note_ReasonForRating1or5"] = evalnotes.ReasonForRating1or5;
                    oListItem["Note_RecommendedCourses"]  = evalnotes.RecommendedCourses;
                    oListItem.Update();
                }
                else
                {
                    SPListItem oListItem  = spList.AddItem();
                    oListItem["Emp"]      = SPContext.Current.Web.EnsureUser(login_name_to_convert_to_SPUser);
                    oListItem["ObjsYear"] = Active_Rate_Goals_Year;
                    oListItem["Note_ReasonForRating1or5"] = evalnotes.ReasonForRating1or5;
                    oListItem["Note_RecommendedCourses"]  = evalnotes.RecommendedCourses;
                    oListItem.Update();
                }

                spWeb.AllowUnsafeUpdates = false;
            });
        }
Пример #3
0
        private void SaveToSP()
        {
            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                SPSite oSite             = new SPSite(SPContext.Current.Web.Url);
                SPWeb spWeb              = oSite.OpenWeb();
                spWeb.AllowUnsafeUpdates = true;
                SPList spList            = spWeb.GetList(SPUrlUtility.CombineUrl(spWeb.ServerRelativeUrl, "lists/" + "SkillsRating"));

                #region Remove any previous Ratings of same Emp and Year, by updating "deleted" to 1

                SPQuery qry = new SPQuery();
                qry.Query   =
                    @"   <Where>
                                          <And>
                                             <Eq>
                                                <FieldRef Name='Emp' />
                                                <Value Type='User'>" + strEmpDisplayName + @"</Value>
                                             </Eq>
                                             <Eq>
                                                <FieldRef Name='ObjYear' />
                                                <Value Type='Text'>" + Active_Rate_Goals_Year + @"</Value>
                                             </Eq>
                                          </And>
                                       </Where>";
                qry.ViewFieldsOnly             = true;
                qry.ViewFields                 = @"<FieldRef Name='ID' />";
                SPListItemCollection listItems = spList.GetItems(qry);

                foreach (SPListItem item in listItems)
                {
                    SPListItem itemToUpdate = spList.GetItemById(item.ID);
                    itemToUpdate["deleted"] = 1;
                    itemToUpdate.Update();
                }

                #endregion Remove any previous Ratings of same Emp and Year, by updating "deleted" to 1

                #region Add the new Ratings

                foreach (GridViewRow row in gvw_Std_Skills.Rows)
                {
                    SPListItem oListItem = spList.AddItem();
                    oListItem["Title"]   = row.Cells[0].Text;
                    var dd = row.Cells[1].FindControl("ddl_Std_Skill_Rating") as DropDownList;
                    oListItem["Rating"]  = int.Parse(dd.SelectedValue);
                    oListItem["Emp"]     = SPContext.Current.Web.EnsureUser(intended_Emp.login_name_to_convert_to_SPUser);
                    oListItem["ObjYear"] = Active_Rate_Goals_Year;
                    oListItem.Update();
                }

                #endregion Add the new Ratings

                spWeb.AllowUnsafeUpdates = false;

                foreach (GridViewRow row in gvwRate.Rows)
                {
                    DropDownList ddlObjRating = row.FindControl("ddlObjRating") as DropDownList;
                    tblObjectives.Rows[row.RowIndex]["AccRating"] = ddlObjRating.SelectedItem.Text;
                }

                SetProgress_DAL.Update_Objectives("AccRating", tblObjectives);

                EvalNotes evalnotes           = new EvalNotes();
                evalnotes.ReasonForRating1or5 = txtNote_ReasonForRating1or5.Text;
                evalnotes.RecommendedCourses  = txtNote_RecommendedCourses.Text;

                SetProgress_DAL.Save_or_Update_Objs_EvalNotes(intended_Emp.login_name_to_convert_to_SPUser, Active_Rate_Goals_Year, evalnotes);
            });
        }
Пример #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                SPSecurity.RunWithElevatedPrivileges(delegate()
                {
                    divSuccess.Visible = false;

                    #region Check for year to use

                    Active_Rate_Goals_Year = EnableYear_DAL.read_Active_Rate_Goals_Year();
                    if (Active_Rate_Goals_Year == "NoRateGoalsActiveYear")
                    {
                        Active_Rate_Goals_Year = read_Year_to_display_if_none_active();
                    }
                    lblActiveYear.Text = Active_Rate_Goals_Year;

                    #endregion Check for year to use

                    #region Check for Emp to use (QueryString or current logged-in user)

                    if (Request.QueryString["empid"] != null)
                    {
                        strEmpDisplayName = Request.QueryString["empid"].ToString();
                    }
                    else
                    {
                        strEmpDisplayName = SPContext.Current.Web.CurrentUser.Name;             //"Test spuser_1"; //"sherif abdellatif";
                    }

                    intended_Emp = Emp_DAL.get_Emp_Info(strEmpDisplayName);
                    bind_Emp_Info();

                    #endregion Check for Emp to use (QueryString or current logged-in user)

                    if (Request.QueryString["mode"] != null && Request.QueryString["mode"] == "hr")
                    {
                        btnHRApprove.Visible = true;
                        btnSubmit.Visible    = false;
                    }

                    if (!IsPostBack)
                    {
                        ReadOnly_Mode = false;

                        #region Check current WorkFlow Status And current logged-in user To decide if ReadOnly_Mode

                        tblObjectives = SetObjectives_DAL.getPreviouslySavedObjectives(strEmpDisplayName, Active_Rate_Goals_Year).GetDataTable();

                        #region If no Objectives found, display a warning regarding that and stop proceeding
                        if (tblObjectives == null || tblObjectives.Rows.Count == 0)
                        {
                            Make_NoObjectivesFound_Mode();
                            return;
                        }
                        #endregion

                        string st = tblObjectives.Rows[0]["Status"].ToString().Trim().ToLower();
                        string p1 = WF_States.Objectives_ProgressSet_by_Emp.ToString().Trim().ToLower();
                        string p2 = WF_States.ObjsAndSkills_Rated.ToString().Trim().ToLower();
                        string p3 = WF_States.ApprovedBy_HRCommittee.ToString().Trim().ToLower();

                        if (st == p1 || st == p2 || st == p3)
                        {
                            lblProgressNotSet_Warning.Visible = false;
                        }
                        else
                        {
                            lblProgressNotSet_Warning.Visible = true;
                        }

                        if (st == p2 || st == p3)
                        {
                            ReadOnly_Mode = true;
                        }
                        else if (strEmpDisplayName == SPContext.Current.Web.CurrentUser.Name)
                        {
                            ReadOnly_Mode = true;
                        }

                        #endregion Check current WorkFlow Status And current logged-in user To decide if ReadOnly_Mode

                        #region Data Binding To UI Controls

                        txtNote1.Text   = SetObjectives_DAL.getPreviouslySavedNote1(strEmpDisplayName, Active_Rate_Goals_Year);
                        EvalNotes notes = SetObjectives_DAL.getPreviouslySavedEvalNotes(strEmpDisplayName, Active_Rate_Goals_Year);
                        txtNote_ReasonForRating1or5.Text = notes.ReasonForRating1or5;
                        txtNote_RecommendedCourses.Text  = notes.RecommendedCourses;

                        if (!Check_If_Emp_and_Year_saved_before())
                        {
                            getStandardSkills();
                        }

                        Bind_Data_To_Controls();

                        #endregion Data Binding To UI Controls
                    }

                    if (ReadOnly_Mode == true)
                    {
                        Make_ReadOnly_Mode();
                    }
                });
            }
            catch (Exception ex)
            {
                Send_Exception_Email(ex.Message);
            }
        }