Example #1
0
        /// <summary>
        ///     Get selecte user information from people editor control
        /// </summary>
        /// <param name="people"></param>
        /// <param name="currentWeb"></param>
        /// <returns></returns>
        public SPFieldUserValue GetSingleUserFromPeopleEditor(PeopleEditor people, SPWeb currentWeb)
        {
            SPFieldUserValue userValue = null;

            try
            {
                if (people.ResolvedEntities.Count <= 1)
                {
                    PickerEntity user = (PickerEntity)people.ResolvedEntities[0];

                    switch ((string)user.EntityData["PrincipalType"])
                    {
                    case "User":
                        SPUser webUser = currentWeb.EnsureUser(user.Key);
                        userValue = new SPFieldUserValue(currentWeb, webUser.ID, webUser.Name);
                        break;

                    case "SharePointGroup":
                        SPGroup siteGroup = currentWeb.SiteGroups[user.EntityData["AccountName"].ToString()];
                        userValue = new SPFieldUserValue(currentWeb, siteGroup.ID, siteGroup.Name);
                        break;
                    }
                }
            }
            catch (Exception err)
            {
                LogErrorHelper objErr = new LogErrorHelper(LIST_SETTING_NAME, currentWeb);
                objErr.logSysErrorEmail(APP_NAME, err, "Error at GetSingleUserFromPeopleEditor function");
                objErr = null;

                SPDiagnosticsService.Local.WriteTrace(0, new SPDiagnosticsCategory(APP_NAME, TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected, err.Message.ToString(), err.StackTrace);
            }
            return(userValue);
        }
Example #2
0
        /// <summary>
        ///     Get multiple people information from people editor control
        /// </summary>
        /// <remarks>
        ///     References: http://blog.bugrapostaci.com/tag/spfielduservalue/
        /// </remarks>
        /// <param name="editor"></param>
        /// <returns></returns>
        public SPFieldUserValueCollection GetSelectedUsers(PeopleEditor editor, SPWeb currentWeb)
        {
            string selectedUsers = editor.CommaSeparatedAccounts;
            SPFieldUserValueCollection values = new SPFieldUserValueCollection();

            try
            {
                // commaseparatedaccounts returns entries that are comma separated. we want to split those up
                char[]   splitter    = { ',' };
                string[] splitPPData = selectedUsers.Split(splitter);
                // this collection will store the user values from the people editor which we'll eventually use
                // to populate the field in the list

                // for each item in our array, create a new sp user object given the loginname and add to our collection
                for (int i = 0; i < splitPPData.Length; i++)
                {
                    string loginName = splitPPData[i];
                    if (!string.IsNullOrEmpty(loginName))
                    {
                        SPUser           user = currentWeb.SiteUsers[loginName];
                        SPFieldUserValue fuv  = new SPFieldUserValue(currentWeb, user.ID, user.LoginName);
                        values.Add(fuv);
                    }
                }
            }
            catch (Exception err)
            {
                LogErrorHelper objErr = new LogErrorHelper(LIST_SETTING_NAME, currentWeb);
                objErr.logSysErrorEmail(APP_NAME, err, "Error at GetSelectedUsers function");
                objErr = null;

                SPDiagnosticsService.Local.WriteTrace(0, new SPDiagnosticsCategory(APP_NAME, TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected, err.Message.ToString(), err.StackTrace);
            }
            return(values);
        }
 internal static void Clear(this PeopleEditor editor)
 {
     editor.ResolvedEntities.Clear();
     editor.Accounts.Clear();
     editor.Entities.Clear();
     editor.CommaSeparatedAccounts = null;
     editor.ErrorMessage           = string.Empty;
 }
        protected void btnAssign_Click(object sender, EventArgs e)
        {
            var             closeLink    = (Control)sender;
            GridViewRow     row          = (GridViewRow)closeLink.NamingContainer;
            int             index        = row.RowIndex;
            string          IssueNo      = row.Cells[0].Text; // here we are
            DateTimeControl FirstrowDate = (DateTimeControl)gvIssueAdminView.Rows[index].FindControl("txtIssueDueDate");
            PeopleEditor    ppAuthor     = (PeopleEditor)gvIssueAdminView.Rows[index].FindControl("txtAssignTo");
            TextBox         Comments     = (TextBox)gvIssueAdminView.Rows[index].FindControl("txtcomments");

            if (ppAuthor.Entities.Count != 0)
            {
                SPSecurity.RunWithElevatedPrivileges(delegate()
                {
                    using (SPSite Osite = new SPSite(SPContext.Current.Site.ID))
                    {
                        using (SPWeb Oweb = Osite.OpenWeb())
                        {
                            SPList Olist   = Oweb.Lists[Utilities.IssueTrackerListName];
                            var Ospquery   = new SPQuery();
                            Ospquery.Query = @"<Where><Eq><FieldRef Name='Issue_x0020_No' /><Value Type='Text'>" + IssueNo + "</Value></Eq></Where>";
                            SPListItemCollection Olistcollection = Olist.GetItems(Ospquery);
                            foreach (SPListItem item in Olistcollection)
                            {
                                if (!FirstrowDate.IsDateEmpty)
                                {
                                    item["Issue Deadline"] = FirstrowDate.SelectedDate.ToShortDateString();
                                }
                                item["Assign To"]       = Utilities.UserValueCollection(Oweb, ppAuthor.CommaSeparatedAccounts.ToString() + ";");
                                item["Comments"]        = Comments.Text;
                                item["Issue Status"]    = "Assigned";
                                Oweb.AllowUnsafeUpdates = true;
                                item.Update();
                                Oweb.AllowUnsafeUpdates = false;

                                SPUser user = SPContext.Current.Web.EnsureUser(ppAuthor.CommaSeparatedAccounts.ToString());
                                Utilities.SendNotification(Oweb, user.Email + ";", "New Leave Application Issue has been assigned.", IssueNo, "Yes");
                                DataBind();
                            }
                        }
                    }
                });
            }
            else
            {
                lblerror.Text = "Please Enter Assigne To";
            }


            foreach (GridViewRow currentrow in gvIssueAdminView.Rows)
            {
                PeopleEditor ppAuthorNew = (PeopleEditor)currentrow.FindControl("txtAssignTo");
                ppAuthorNew.Accounts.Clear();
                ppAuthorNew.Entities.Clear();
                ppAuthorNew.ResolvedEntities.Clear();
            }
        }
        protected void dGridItemTarefa_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
        {
            ASPxGridView Grid   = sender as ASPxGridView;
            PeopleEditor objppp = (PeopleEditor)Grid.FindEditRowCellTemplateControl((GridViewDataColumn)Grid.Columns[6], "pppAdd");

            if (objppp != null)
            {
                e.NewValues["Responsavel"] = objppp.CommaSeparatedAccounts;
            }
        }
        public Control CreateControl()
        {
            PeopleEditor peopleEditor = new PeopleEditor();

            peopleEditor.AllowEmpty      = true;
            peopleEditor.AllowTypeIn     = true;
            peopleEditor.MaximumEntities = 1;
            peopleEditor.SelectionSet    = "User";

            return(peopleEditor);
        }
Example #7
0
 public static IEnumerable <SPUser> GetUsers(this PeopleEditor peopleEditor, SPWeb web)
 {
     foreach (PickerEntity pickerEntity in peopleEditor.ResolvedEntities)
     {
         if (IsEntityUser(pickerEntity))
         {
             SPUser user = web.EnsureUser(pickerEntity.Description);
             yield return(user);
         }
     }
 }
        protected void btnReject_Click(object sender, EventArgs e)
        {
            var         closeLink        = (Control)sender;
            GridViewRow row              = (GridViewRow)closeLink.NamingContainer;
            int         index            = row.RowIndex;
            string      IssueNo          = row.Cells[0].Text;
            TextBox     Comments         = (TextBox)gvIssueAdminView.Rows[index].FindControl("txtcomments");
            string      ApproverComments = Comments.Text.Trim();

            if (!string.IsNullOrEmpty(ApproverComments))
            {
                SPSecurity.RunWithElevatedPrivileges(delegate()
                {
                    using (SPSite Osite = new SPSite(SPContext.Current.Site.ID))
                    {
                        using (SPWeb Oweb = Osite.OpenWeb())
                        {
                            SPList Olist   = Oweb.Lists[Utilities.IssueTrackerListName];
                            var Ospquery   = new SPQuery();
                            Ospquery.Query = @"<Where><Eq><FieldRef Name='Issue_x0020_No' /><Value Type='Text'>" + IssueNo + "</Value></Eq></Where>";
                            SPListItemCollection Olistcollection = Olist.GetItems(Ospquery);
                            foreach (SPListItem item in Olistcollection)
                            {
                                string Author           = item["Author"].ToString();
                                string[] AuthorEmail    = Author.Split('#');
                                SPUser user             = SPContext.Current.Web.EnsureUser(AuthorEmail[1]);
                                item["Comments"]        = Comments.Text;
                                item["Issue Status"]    = "Rejected";
                                Oweb.AllowUnsafeUpdates = true;
                                item.Update();
                                Oweb.AllowUnsafeUpdates = false;
                                Utilities.SendNotification(Oweb, user.Email + ";", "New Leave Application Issue has been assigned.", IssueNo, "Yes");
                                DataBind();
                            }
                        }
                    }
                });
            }
            else
            {
                lblerror.Text = "Please Enter Comments";
            }

            DataBind();
            foreach (GridViewRow currentrow in gvIssueAdminView.Rows)
            {
                PeopleEditor ppAuthorNew = (PeopleEditor)currentrow.FindControl("txtAssignTo");
                ppAuthorNew.Accounts.Clear();
                ppAuthorNew.Entities.Clear();
                ppAuthorNew.ResolvedEntities.Clear();
            }
        }
Example #9
0
        public static SPFieldUserValueCollection PickUserValue(PeopleEditor peopleEditor)
        {
            SPFieldUserValueCollection fieldUserValues = new SPFieldUserValueCollection();
            foreach (PickerEntity entity in peopleEditor.ResolvedEntities)
            {
                SPPrincipal principal = MOSSPrincipal.FindUserOrSiteGroup(entity.Key);
                SPFieldUserValue userValue = new SPFieldUserValue(MOSSContext.Current.Web, principal.ID,principal.Name);

                fieldUserValues.Add(userValue);
            }

            return fieldUserValues;
        }
        protected void dGridItemTarefa_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
        {
            ASPxGridView Grid      = sender as ASPxGridView;
            PeopleEditor objppp    = (PeopleEditor)Grid.FindEditRowCellTemplateControl((GridViewDataColumn)Grid.Columns[6], "pppAdd");
            int          ID_TAREFA = Convert.ToInt32((sender as ASPxGridView).GetMasterRowKeyValue());

            e.NewValues["ID_TAREFA"] = ID_TAREFA;

            if (objppp != null)
            {
                e.NewValues["Responsavel"] = objppp.CommaSeparatedAccounts;
            }
        }
Example #11
0
        void SAVEbutton1_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                SPViewCollection viewCollection = currentList.Views;
                if (viewCollection.Count.ToString() == ViewState["CheckViewsCount"].ToString())
                {
                    int i = 0;
                    foreach (SPView currentView in viewCollection)
                    {
                        if (currentView.Title != "")
                        {
                            Control peopleEditorControl = MainPanel.FindControl("pe" + i.ToString());
                            if (peopleEditorControl != null)
                            {
                                PeopleEditor pe = (PeopleEditor)peopleEditorControl;

                                //if (pe.IsValid == false && pe.Entities.Count != 0)
                                //    return;

                                SaveToProperties(currentView, pe.CommaSeparatedAccounts, pe.Entities.Count);
                            }

                            i++;
                        }
                    }


                    if (this.chbxPermission.Checked)
                    {
                        SaveViceVersaToProperties(currentList, false);
                    }
                    else
                    {
                        SaveViceVersaToProperties(currentList, true);
                    }

                    Close();
                }
                else
                {
                    ViewState["CheckViewsCount"] = viewCollection.Count.ToString();
                    ClientScript.RegisterStartupScript(this.GetType(), "StatusScript",
                                                       @"<script type='text/javascript'>ExecuteOrDelayUntilScriptLoaded(Initialize, 'sp.js');
                                                        function Initialize() {
                                                            statusId = SP.UI.Status.addStatus('Please Save this Page Again. Incorrect number of Views!','', true); 
                                                            SP.UI.Status.setStatusPriColor(statusId, 'red');
                                                            }</script>");
                }
            }
        }
Example #12
0
        public static string GetPeopleEditorValue(PeopleEditor objPeopleEditor)
        {
            string    strResult = string.Empty;
            ArrayList list      = objPeopleEditor.ResolvedEntities;

            foreach (PickerEntity p in list)
            {
                string userId      = p.EntityData["SPUserID"].ToString();
                string DisplayName = p.EntityData["DisplayName"].ToString();
                strResult += userId + ";#" + DisplayName;
                strResult += ",";
            }
            return(strResult);
        }
Example #13
0
        private void GvGoalSetting_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                int id = int.Parse(gvGoalSetting.DataKeys[e.Row.RowIndex].Value.ToString());
                IDictionary <int, string> authors = (Dictionary <int, string>)ViewState["Authors"];
                string lgName;
                authors.TryGetValue(id, out lgName);

                PeopleEditor tbName1 = (PeopleEditor)e.Row.Cells[0].FindControl("tbName1");//获取 模板列的值
                tbName1.CommaSeparatedAccounts = lgName;
                //PickerEntity picker in tbName.ResolvedEntities.cou
            }
        }
Example #14
0
        public static IEnumerable <SPGroup> GetGroups(this PeopleEditor peopleEditor, SPWeb web)
        {
            foreach (PickerEntity pickerEntity in peopleEditor.ResolvedEntities)
            {
                if (!IsEntityUser(pickerEntity))
                {
                    SPGroup group = web.SiteGroups.GetByName(pickerEntity.Description);

                    if (group != null)
                    {
                        yield return(group);
                    }
                }
            }
        }
Example #15
0
        public static void SetEntities(this PeopleEditor peopleEditor, IEnumerable <string> entities)
        {
            ArrayList entityArrayList = new ArrayList();

            if (entities != null)
            {
                foreach (string entitiy in entities)
                {
                    PickerEntity entity = peopleEditor.ValidateEntity(new PickerEntity {
                        Key = entitiy
                    });
                    entityArrayList.Add(entity);
                }
            }

            peopleEditor.UpdateEntities(entityArrayList);
        }
Example #16
0
        /// <summary>
        /// 新建和保存时进行判断,
        /// 保存时,业绩点之和不能大于1;新建时,如果业绩点之点等于1,则不能创建新的业绩点
        /// </summary>
        /// <param name="results"></param>
        /// <param name="btnEvent">Save/New</param>
        /// <returns></returns>
        private bool CheckRatio(ref List <string> results, string btnEvent = "Save")
        {
            lblMsg.Text = "";
            decimal tRatio = 0;

            SPWeb         web     = SPContext.Current.Web;
            List <int>    authors = new List <int>();
            List <string> result  = new List <string>();

            for (int i = 0; i < gvGoalSetting.Rows.Count; i++)
            {
                TextBox tbRatio = (TextBox)gvGoalSetting.Rows[i].Cells[1].FindControl("tbRatio1");//获取 模板列的值
                if (tbRatio.Text != "")
                {
                    tRatio += decimal.Parse(tbRatio.Text);
                }

                PeopleEditor tbName1 = (PeopleEditor)gvGoalSetting.Rows[i].Cells[0].FindControl("tbName1");//获取 模板列的值

                if (tbName1.ResolvedEntities.Count > 0)
                {
                    SPFieldUserValue user = GetUserValue(web, (PickerEntity)tbName1.ResolvedEntities[0]);
                    if (authors.Contains(user.User.ID))
                    {
                        lblMsg.Text = webObj.ShowMsgAuthor;
                        return(false);
                    }
                    else
                    {
                        authors.Add(user.LookupId);
                    }
                    result.Add(gvGoalSetting.DataKeys[i].Value.ToString() + ";" + user.User.ID + ";" + (tbRatio.Text == "" ? "0" : tbRatio.Text));
                }
            }
            tRatio = decimal.Round(tRatio, 2);
            ViewState["TotalRatio"] = tRatio;//所有已经输入的业绩
            if (btnEvent == "Save" && tRatio > TotalRatio || btnEvent == "New" && tRatio == TotalRatio)
            {
                lblMsg.Text = webObj.ShowMsg.Replace("N", (TotalRatio - tRatio).ToString());
                return(false);
            }

            results = result;
            return(true);
        }
        public static SPFieldUserValue GetSelectedUser(PeopleEditor pEditor)
        {
            SPFieldUserValue user = new SPFieldUserValue();

            try
            {
                string[] userarray = pEditor.CommaSeparatedAccounts.ToString().Split(',');
                if (userarray.Length > 0 && Convert.ToString(userarray[0]).Length > 0)
                {
                    return(Convert2Account(userarray[0]));
                }
            }
            catch (Exception ex)
            {
                LogMessage(ex, "BusinessLayer.GetSelectedUser");
            }
            return(user);
        }
        internal static SPFieldUserValue UserValue(this PeopleEditor editor)
        {
            var res = new SPFieldUserValue();
            var ctx = SPContext.Current;

            SPSecurity.RunWithElevatedPrivileges(
                () =>
            {
                using (var site = new SPSite(ctx.Site.ID))
                {
                    using (var web = site.OpenWeb(ctx.Web.ID))
                    {
                        editor.Validate();
                        if (editor.ResolvedEntities.Count <= 0)
                        {
                        }
                        else
                        {
                            var entity = editor.ResolvedEntities[0] as PickerEntity;
                            var id     = 0;
                            switch (entity.EntityData["PrincipalType"].ToString())
                            {
                            case "User":
                                id = Convert.ToInt32(entity.EntityData["SPUserID"]);
                                if (id <= 0)
                                {
                                    var u = web.EnsureUser(entity.Key);
                                    id    = u.ID;
                                }
                                break;

                            case "SharePointGroup":
                                id = Convert.ToInt32(entity.EntityData["SPGroupID"]);
                                break;
                            }
                            res = new SPFieldUserValue(web, id, entity.Key);
                        }
                    }
                }
            });
            return(res);
        }
        protected override void CreateChildControls()
        {
            pplEditor              = new PeopleEditor();
            pplEditor.ID           = "allowedPrincipalsSelector";
            pplEditor.SelectionSet = "SPGroup";
            pplEditor.MultiSelect  = true;

            this.Controls.Add(pplEditor);

            //setting the last set values as current values on custom toolpart
            MakeTemplateButtonWebPart wp = (MakeTemplateButtonWebPart)this.ParentToolPane.SelectedWebPart;

            if (wp != null)
            {
                this.pplEditor.CommaSeparatedAccounts = wp.CommaSeparatedAccounts;
                this.pplEditor.Validate();
            }

            base.CreateChildControls();
        }
Example #20
0
        public static IEnumerable <SPPrincipal> GetUsersOrGroups(this PeopleEditor peopleEditor, SPWeb web)
        {
            foreach (PickerEntity pickerEntity in peopleEditor.ResolvedEntities)
            {
                if (IsEntityUser(pickerEntity))
                {
                    SPUser user = web.EnsureUser(pickerEntity.Description);
                    yield return(user);
                }
                else
                {
                    SPGroup group = web.SiteGroups.GetByName(pickerEntity.Description);

                    if (group != null)
                    {
                        yield return(group);
                    }
                }
            }
        }
        private void InitializeChildControls()
        {
            DefaultValueAsTextBox      = new TextBox();
            DefaultValueAsPeopleEditor = new PeopleEditor {
                ValidatorEnabled = true, MultiSelect = true
            };
            DefaultValueAsListBox = new ListBox {
                EnableViewState = true
            };

            BeginDateLabel            = new Label();
            BeginDateLabel.Text       = "Begin";
            JqueryDatePickerBeginDate = new TextBox();
            EndDateLabel            = new Label();
            EndDateLabel.Text       = "End";
            JqueryDatePickerEndDate = new TextBox();

            SharepointListDropDownList = new DropDownList {
                AutoPostBack = true, EnableViewState = true
            };
            SharepointListDropDownList.SelectedIndexChanged += SharepointListDropDownListSelectedIndexChanged;
            SharepointListFieldDropDownList = new DropDownList {
                AutoPostBack = true, EnableViewState = true
            };
            AllowMultipleFieldsSelectedDropDownCheckBox = new CheckBox
            {
                Text         = "Allow multiple \"Field\" values to be selected.",
                AutoPostBack = true
            };

            ShowTitlesDropDownCheckBox = new CheckBox {
                Text = "Show Titles Drop down"
            };
            AllowMultipleTitlesSelectedDropDownCheckBox = new CheckBox {
                Text = "Allow multiple \"Title\" values to be selected."
            };
            IsPercentageCheckBox = new CheckBox {
                Text = "Is Percentage Value"
            };
        }
Example #22
0
        /// <summary>
        ///   Get multiple people information from people editor control
        /// </summary>
        /// <remarks>
        ///     References: http://kancharla-sharepoint.blogspot.com.au/2012/10/sometimes-we-need-to-get-all-people-or.html
        /// </remarks>
        /// <param name="people"></param>
        /// <param name="web"></param>
        /// <returns></returns>
        public SPFieldUserValueCollection GetPeopleFromPickerControl(PeopleEditor people, SPWeb web)
        {
            SPFieldUserValueCollection values = new SPFieldUserValueCollection();

            try
            {
                if (people.ResolvedEntities.Count > 0)
                {
                    for (int i = 0; i < people.ResolvedEntities.Count; i++)
                    {
                        PickerEntity user = (PickerEntity)people.ResolvedEntities[i];

                        switch ((string)user.EntityData["PrincipalType"])
                        {
                        case "User":
                            SPUser           webUser   = web.EnsureUser(user.Key);
                            SPFieldUserValue userValue = new SPFieldUserValue(web, webUser.ID, webUser.Name);
                            values.Add(userValue);
                            break;

                        case "SharePointGroup":
                            SPGroup          siteGroup  = web.SiteGroups[user.EntityData["AccountName"].ToString()];
                            SPFieldUserValue groupValue = new SPFieldUserValue(web, siteGroup.ID, siteGroup.Name);
                            values.Add(groupValue);
                            break;
                        }
                    }
                }
            }
            catch (Exception err)
            {
                LogErrorHelper objErr = new LogErrorHelper(LIST_SETTING_NAME, web);
                objErr.logSysErrorEmail(APP_NAME, err, "Error at GetPeopleFromPickerControl function");
                objErr = null;

                SPDiagnosticsService.Local.WriteTrace(0, new SPDiagnosticsCategory(APP_NAME, TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected, err.Message.ToString(), err.StackTrace);
            }

            return(values);
        }
Example #23
0
        private void BindPeoplePicker(PeopleEditor ppEditor, List<string> list)
        {
            string users = "";
            System.Collections.ArrayList entityArrayList = new System.Collections.ArrayList();
            PickerEntity entity = new PickerEntity();
            foreach (var item in list)
            {
                entity.Key = item;
                // this can be omitted if you're sure of what you are doing
                entity = ppEditor.ValidateEntity(entity);
                entityArrayList.Add(entity);
                users += item + ",";
            }

            //ppEditor.UpdateEntities(entityArrayList);
            if (list.Count > 0)
                ppEditor.CommaSeparatedAccounts = users.Remove(users.LastIndexOf(","), 1);
        }
        public Control BuildValueSelectorControl(SPField field, string displayValue)
        {
            Control control = null;
            if (field == null) { control = new TextBox() { CssClass = "ms-long", Text = displayValue.ToString() }; }
            else
            {

                switch (field.Type)
                {
                    case SPFieldType.Boolean:

                        CheckBox checkbox = new CheckBox() { };
                        if (!string.IsNullOrEmpty(displayValue))
                        {
                            bool value;
                            if (bool.TryParse(displayValue, out value))
                            {
                                checkbox.Checked = value;
                            }

                        }
                        control = checkbox;
                        break;

                    case SPFieldType.File:
                    case SPFieldType.Calculated:
                    case SPFieldType.Computed:
                    case SPFieldType.Currency:
                    case SPFieldType.Integer:
                    case SPFieldType.Note:
                    case SPFieldType.Number:
                    case SPFieldType.Text:
                    case SPFieldType.URL:
                    case SPFieldType.Invalid:
                        control = new TextBox() { CssClass = "ms-long", Text = displayValue.ToString() };
                        break;
                    case SPFieldType.Choice:
                        SPFieldChoice fieldChoice = (SPFieldChoice)field;
                        DropDownList ddlValueChoice = new DropDownList();

                        foreach (string value in fieldChoice.Choices)
                        {
                            ddlValueChoice.Items.Add(new ListItem(value));
                        }

                        ddlValueChoice.Items.Insert(0, string.Empty);
                        ddlValueChoice.SelectedIndex = ddlValueChoice.Items.IndexOf(ddlValueChoice.Items.FindByValue(displayValue));
                        control = ddlValueChoice;
                        break;

                    case SPFieldType.DateTime:
                        SPFieldDateTime fieldDate = (SPFieldDateTime)field;
                        DateTimeControl dtcValueDate = new DateTimeControl();
                        dtcValueDate.DateOnly = (fieldDate.DisplayFormat == SPDateTimeFieldFormatType.DateOnly);
                        if (!string.IsNullOrEmpty(displayValue.ToString()))
                        {
                            DateTime date;
                            if (DateTime.TryParse(displayValue.ToString(), out date))
                            {
                                dtcValueDate.SelectedDate = Convert.ToDateTime(date).ToUniversalTime();
                            }
                        }

                        control = dtcValueDate;
                        break;

                    case SPFieldType.Lookup:
                        SPFieldLookup fieldLookup = (SPFieldLookup)field;
                        control = generateLookupControl(control, fieldLookup, displayValue);
                        break;

                    case SPFieldType.MultiChoice:
                        SPFieldMultiChoice fieldMultichoice = (SPFieldMultiChoice)field;
                        CheckBoxList chkValueMultiChoice = new CheckBoxList();
                        foreach (string value in fieldMultichoice.Choices)
                        {
                            ListItem item = new ListItem(value);
                            string[] arr = displayValue.Split(SEPARATOR.ToCharArray());

                            item.Selected = arr.Contains(value);

                            chkValueMultiChoice.Items.Add(item);
                        }
                        control = chkValueMultiChoice;

                        HtmlGenericControl div2 = new HtmlGenericControl("div");
                        div2.Attributes.Add("style", "overflow: auto;height:100px;width:100%;");
                        div2.Controls.Add(chkValueMultiChoice);

                        control = div2;
                        break;

                    case SPFieldType.User:
                        SPFieldUser fieldUser = (SPFieldUser)field;
                        PeopleEditor peoValue = new PeopleEditor() { CssClass = "ms-long" };
                        peoValue.MultiSelect = fieldUser.AllowMultipleValues;
                        peoValue.SelectionSet = (fieldUser.SelectionMode == SPFieldUserSelectionMode.PeopleOnly) ? "User" : "User,SPGroup ";
                        if (!string.IsNullOrEmpty(displayValue))
                        {
                            string[] arr = displayValue.Split(SEPARATOR.ToCharArray());

                            ArrayList list = new ArrayList();
                            foreach (string s in arr)
                            {
                                PickerEntity peMember = new PickerEntity();
                                string[] arrPeMember = s.Split('#');
                                peMember.Key = arrPeMember[1];
                                peMember = peoValue.ValidateEntity(peMember);
                                list.Add(peMember);
                            }
                            peoValue.UpdateEntities(list);
                        }
                        control = peoValue;
                        break;
                    default:
                        control = new TextBox() { CssClass = "ms-long", Text = displayValue };
                        break;
                }
            }
            control.ID = GENERIC_CONTROL_ID;
            return control;
        }
        protected override void CreateChildControls()
        {
            if (base.Field == null)
            {
                return;
            }
            base.CreateChildControls();

            chkListExecutiveRoles = (CheckBoxList)TemplateContainer.FindControl("chkListExecutiveRoles");
            userPicker = (PeopleEditor)TemplateContainer.FindControl("userPicker");

            if (ControlMode == SPControlMode.New || ControlMode == SPControlMode.Edit)
            {
                SPWeb currentWeb = SPContext.Current.Web;
                SPList actionRequiredList = currentWeb.Lists["ExecutiveTasksRoleList"];

                foreach (SPListItem item in actionRequiredList.Items)
                {
                    SPFieldUserValue userValue = Utils.GetSPUserValue(item, "Assigned Person");
                    ListItem li = new ListItem(string.Format("{0} ({1})", item.Title, userValue.User.Name), string.Format("{0} ({1})", item.Title, userValue.User.LoginName));
                    chkListExecutiveRoles.Items.Add(li);
                }
            }
        }
Example #26
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SAVEbutton1.Click   += new EventHandler(SAVEbutton1_Click);
            CancelButton1.Click += new EventHandler(CancelButton1_Click);

            if (Request.QueryString["List"] != null)
            {
                listGuid    = new Guid(Request.QueryString["List"]);
                currentList = spWeb.Lists[listGuid];

                if (CheckCustomRights(currentList))
                {
                    Control tagTitleControl = Page.Header.FindControl("PlaceHolderPageTitle").Parent;
                    if (tagTitleControl != null)
                    {
                        AddTagTitle(tagTitleControl);
                    }

                    Control titleLinkControl = FindInnerControl(Page, "PlaceHolderPageTitleInTitleArea");
                    if (titleLinkControl != null)
                    {
                        AddLinkTitle(titleLinkControl);
                    }

                    PageDescriptionText.Text = "View Permission (Powered by SPGuys)";

                    GenerateInnerHtml();

                    if (!Page.IsPostBack)
                    {
                        SPViewCollection viewCollection = currentList.Views;
                        ViewState["CheckViewsCount"] = viewCollection.Count.ToString();

                        int i = 0;
                        foreach (SPView currentView in viewCollection)
                        {
                            if (currentView.Title != "")
                            {
                                Control peopleEditorControl = MainPanel.FindControl("pe" + i.ToString());
                                if (peopleEditorControl != null)
                                {
                                    PeopleEditor pe = (PeopleEditor)peopleEditorControl;
                                    pe.CommaSeparatedAccounts = SelectFromProperties(currentView);
                                }

                                i++;
                            }
                        }

                        if (SelectViceVersaFromProperties(currentSite, currentList, true))
                        {
                            this.chbxPermission.Checked = true;
                        }
                        else
                        {
                            this.chbxPermission.Checked = false;
                        }
                    }
                }
                else
                {
                    SPUtility.HandleAccessDenied(new UnauthorizedAccessException());
                }
            }
            else
            {
                SPUtility.HandleAccessDenied(new UnauthorizedAccessException());
            }
        }
        protected override void CreateChildControls()
        {
            try
            {
                #region Creacion de controles
                pnlFormulario       = new Panel();
                pnlFormulario.ID    = "pnlFormulario";
                pnlAdjuntos         = new Panel();
                pnlAdjuntos.ID      = "pnlAdjuntos";
                pnlAdjuntos.Visible = false;

                lblTipoCarta          = new Label();
                lblTipoCarta.Text     = "Tipo <span class='ms-formvalidation'>*</span>";
                lblDescTipoCarta      = new Label();
                lblDescTipoCarta.Text = "Tipo de correspondencia recibida";
                rblTipoCarta          = new RadioButtonList();
                rblTipoCarta.ID       = "rblTipoCarta";
                rblTipoCarta.Items.Add("INTERNA");
                rblTipoCarta.Items.Add("EXTERNA");
                rfvTipoCarta                   = new RequiredFieldValidator();
                rfvTipoCarta.ID                = "rfvTipoCarta";
                rfvTipoCarta.Text              = "<br/>Tiene que especificar un valor para este campo requerido.";
                rfvTipoCarta.Display           = ValidatorDisplay.Dynamic;
                rfvTipoCarta.ControlToValidate = "rblTipoCarta";
                rfvTipoCarta.SetFocusOnError   = true;

                lblOrigenCarta          = new Label();
                lblOrigenCarta.Text     = "Origen <span class='ms-formvalidation'>*</span>";
                lblDescOrigenCarta      = new Label();
                lblDescOrigenCarta.Text = "Origen de la correspondencia";
                rblOrigenCarta          = new RadioButtonList();
                rblOrigenCarta.ID       = "rblOrigenCarta";
                rblOrigenCarta.Items.Add(new ListItem("", "COMBO"));
                rblOrigenCarta.Items.Add(new ListItem("", "TEXTO"));
                rblOrigenCarta.SelectedIndex = 0;
                ddlOrigenCarta    = new DropDownList();
                ddlOrigenCarta.ID = "ddlOrigenCarta";
                ddlOrigenCarta.Attributes.Add("style", "width:385px;");
                ddlOrigenCarta.DataSource     = ConectorWebPart.RecuperarOrigenesCorrespondencia();
                ddlOrigenCarta.DataTextField  = "text";
                ddlOrigenCarta.DataValueField = "value";
                ddlOrigenCarta.DataBind();
                ddlOrigenCarta.Items.Insert(0, new ListItem("", string.Empty));
                ddlOrigenCarta.SelectedIndex = 0;
                txbOrigenCarta    = new TextBox();
                txbOrigenCarta.ID = "txbOrigenCarta";
                txbOrigenCarta.Attributes.Add("style", "width:385px;");
                ctvOrigenCarta                   = new CustomValidator();
                ctvOrigenCarta.ID                = "ctvOrigenCarta";
                ctvOrigenCarta.Text              = "<br/>Tiene que especificar un valor para este campo requerido.";
                ctvOrigenCarta.Display           = ValidatorDisplay.Dynamic;
                ctvOrigenCarta.ControlToValidate = "rblOrigenCarta";
                ctvOrigenCarta.ServerValidate   += new ServerValidateEventHandler(ctvOrigenCarta_ServerValidate);
                //rfvDdlOrigenCarta = new RequiredFieldValidator();
                //rfvDdlOrigenCarta.ID = "rfvDdlOrigenCarta";
                //rfvDdlOrigenCarta.Text = "<br/>Tiene que especificar un valor para este campo requerido.";
                //rfvDdlOrigenCarta.InitialValue = string.Empty;
                //rfvDdlOrigenCarta.Display = ValidatorDisplay.Dynamic;
                //rfvDdlOrigenCarta.ControlToValidate = "ddlOrigenCarta";
                //rfvDdlOrigenCarta.Enabled = false;
                //rfvTxbOrigenCarta = new RequiredFieldValidator();
                //rfvTxbOrigenCarta.ID = "rfvTxbOrigenCarta";
                //rfvTxbOrigenCarta.Text = "<br/>Tiene que especificar un valor para este campo requerido.";
                //rfvTxbOrigenCarta.Display = ValidatorDisplay.Dynamic;
                //rfvTxbOrigenCarta.ControlToValidate = "txbOrigenCarta";
                //rfvTxbOrigenCarta.Enabled = false;

                lblReferencia          = new Label();
                lblReferencia.Text     = "Referencia <span class='ms-formvalidation'>*</span>";
                lblDescReferencia      = new Label();
                lblDescReferencia.Text = "<br/>Referencia de la carta";
                txbReferencia          = new InputFormTextBox();
                txbReferencia.ID       = "txbReferencia";
                txbReferencia.Attributes.Add("style", "width:385px;");
                txbReferencia.RichText     = false;
                txbReferencia.RichTextMode = SPRichTextMode.Compatible;
                txbReferencia.Rows         = 5;
                txbReferencia.TextMode     = TextBoxMode.MultiLine;
                rfvReferencia                   = new RequiredFieldValidator();
                rfvReferencia.ID                = "rfvReferencia";
                rfvReferencia.Text              = "<br/>Tiene que especificar un valor para este campo requerido.";
                rfvReferencia.Display           = ValidatorDisplay.Dynamic;
                rfvReferencia.ControlToValidate = "txbReferencia";
                rfvReferencia.SetFocusOnError   = true;

                lblFechaCarta                 = new Label();
                lblFechaCarta.Text            = "Fecha origen <span class='ms-formvalidation'>*</span>";
                lblDescFechaCarta             = new Label();
                lblDescFechaCarta.Text        = "Fecha de la correspondencia";
                dtcFechaCarta                 = new DateTimeControl();
                dtcFechaCarta.ID              = "dtcFechaCarta";
                dtcFechaCarta.IsRequiredField = true;
                dtcFechaCarta.DateOnly        = true;

                lblFechaRecibida                 = new Label();
                lblFechaRecibida.Text            = "Fecha recibida <span class='ms-formvalidation'>*</span>";
                lblDescFechaRecibida             = new Label();
                lblDescFechaRecibida.Text        = "Fecha de recepción de la carta";
                dtcFechaRecibida                 = new DateTimeControl();
                dtcFechaRecibida.ID              = "dtcFechaRecibida";
                dtcFechaRecibida.IsRequiredField = true;
                dtcFechaRecibida.SelectedDate    = DateTime.Now;

                lblDestinatario          = new Label();
                lblDestinatario.Text     = "Destinatario <span class='ms-formvalidation'>*</span>";
                lblDescDestinatario      = new Label();
                lblDescDestinatario.Text = "<br/>Destinatario indicado en la carta";
                txbDestinatario          = new TextBox();
                txbDestinatario.ID       = "txbDestinatario";
                txbDestinatario.Attributes.Add("style", "width:385px;");
                rfvDestinatario                   = new RequiredFieldValidator();
                rfvDestinatario.ID                = "rfvDestinatario";
                rfvDestinatario.Text              = "<br/>Tiene que especificar un valor para este campo requerido.";
                rfvDestinatario.Display           = ValidatorDisplay.Dynamic;
                rfvDestinatario.ControlToValidate = "txbDestinatario";
                rfvDestinatario.SetFocusOnError   = true;

                lblDirigidaA             = new Label();
                lblDirigidaA.Text        = "Dirigida a <span class='ms-formvalidation'>*</span>";
                lblDescDirigidaA         = new Label();
                lblDescDirigidaA.Text    = "Usuario(s) al(os) cual(es) será enviada la notificación de correspondencia. El primero usuario definido en este campo será el dueño de esta correspondencia.";
                pedDirigidaA             = new PeopleEditor();
                pedDirigidaA.ID          = "pedDirigidaA";
                pedDirigidaA.AllowEmpty  = false;
                pedDirigidaA.MultiSelect = true;
                pedDirigidaA.Rows        = 1;
                pedDirigidaA.PlaceButtonsUnderEntityEditor = false;
                rfvDirigidaA                   = new RequiredFieldValidator();
                rfvDirigidaA.ID                = "rfvDirigidaA";
                rfvDirigidaA.Text              = "<br/>Tiene que especificar un valor para este campo requerido.";
                rfvDirigidaA.Display           = ValidatorDisplay.Dynamic;
                rfvDirigidaA.ControlToValidate = "pedDirigidaA";
                rfvDirigidaA.SetFocusOnError   = true;

                lblNumCarta          = new Label();
                lblNumCarta.Text     = "Num. ó Cite";
                lblDescNumCarta      = new Label();
                lblDescNumCarta.Text = "<br/>Código de indentificación de la carta";
                txbNumCarta          = new TextBox();
                txbNumCarta.ID       = "txbNumCarta";
                txbNumCarta.Attributes.Add("style", "width:385px;");

                lblAdjunto          = new Label();
                lblAdjunto.Text     = "Adjunto <span class='ms-formvalidation'>*</span>";
                lblDescAdjunto      = new Label();
                lblDescAdjunto.Text = "<br/>Indica si la correspondencia trae documentos adjuntos o no";
                txbAdjunto          = new TextBox();
                txbAdjunto.ID       = "txbAdjunto";
                txbAdjunto.Attributes.Add("style", "width:385px;");
                rfvAdjunto                   = new RequiredFieldValidator();
                rfvAdjunto.ID                = "rfvAdjunto";
                rfvAdjunto.Text              = "<br/>Tiene que especificar un valor para este campo requerido.";
                rfvAdjunto.Display           = ValidatorDisplay.Dynamic;
                rfvAdjunto.ControlToValidate = "txbAdjunto";
                rfvAdjunto.SetFocusOnError   = true;

                lblClase          = new Label();
                lblClase.Text     = "Clase de documento <span class='ms-formvalidation'>*</span>";
                lblDescClase      = new Label();
                lblDescClase.Text = "";
                txbClase          = new TextBox();
                txbClase.ID       = "txbClase";
                txbClase.Attributes.Add("style", "width:385px;");
                rfvClase                   = new RequiredFieldValidator();
                rfvClase.ID                = "rfvClase";
                rfvClase.Text              = "<br/>Tiene que especificar un valor para este campo requerido.";
                rfvClase.Display           = ValidatorDisplay.Dynamic;
                rfvClase.ControlToValidate = "txbClase";
                rfvClase.SetFocusOnError   = true;

                lblPrioridad          = new Label();
                lblPrioridad.Text     = "Prioridad <span class='ms-formvalidation'>*</span>";
                lblDescPrioridad      = new Label();
                lblDescPrioridad.Text = "<br/>Prioridad de la correspondencia";
                ddlPrioridad          = new DropDownList();
                ddlPrioridad.ID       = "ddlPrioridad";
                ddlPrioridad.Attributes.Add("style", "width:150px;");
                ddlPrioridad.Items.Add("NORMAL");
                ddlPrioridad.Items.Add("URGENTE");
                ddlPrioridad.SelectedIndex = 0;

                lblPrivada          = new Label();
                lblPrivada.Text     = "Privada";
                lblDescPrivada      = new Label();
                lblDescPrivada.Text = "<br/>Si se marca, esta carta será leida solo por el(los) usuario(s) indicado(s) en el campo \"Dirigida a\"";
                chkPrivada          = new CheckBox();
                chkPrivada.ID       = "chkPrivada";
                chkPrivada.Checked  = true;

                lblHojaDeRuta          = new Label();
                lblHojaDeRuta.Text     = "Hoja de ruta";
                lblDescHojaDeRuta      = new Label();
                lblDescHojaDeRuta.Text = "<br/>Si se marca, imprime la hoja de ruta";
                chkHojaDeRuta          = new CheckBox();
                chkHojaDeRuta.ID       = "chkHojaDeRuta";
                chkHojaDeRuta.Checked  = true;

                lblArchivo          = new Label();
                lblArchivo.Text     = "Archivo";
                lblDescArchivo      = new Label();
                lblDescArchivo.Text = "<br/>Descripción de la ubicación física final de la correspondencia";
                txbArchivo          = new InputFormTextBox();
                txbArchivo.ID       = "txbArchivo";
                txbArchivo.Attributes.Add("style", "width:385px;");
                txbArchivo.RichText     = false;
                txbArchivo.RichTextMode = SPRichTextMode.Compatible;
                txbArchivo.Rows         = 5;
                txbArchivo.TextMode     = TextBoxMode.MultiLine;

                lblAdjuntos                     = new Label();
                lblAdjuntos.Text                = "Adjuntos";
                lblDescAdjuntos                 = new Label();
                lblDescAdjuntos.Text            = "Seleccione el o los archivos que desea adjuntar a este registro de correspondencia";
                grvAdjuntos                     = new GridView();
                grvAdjuntos.ID                  = "grvAdjuntos";
                grvAdjuntos.GridLines           = GridLines.None;
                grvAdjuntos.ForeColor           = Color.FromArgb(51, 51, 51);
                grvAdjuntos.CellPadding         = 4;
                grvAdjuntos.AutoGenerateColumns = false;
                grvAdjuntos.DataKeyNames        = new string[] { "RutaArchivo" };
                grvAdjuntos.RowStyle.BackColor  = Color.FromArgb(227, 234, 235);
                //grvAdjuntos.HeaderStyle.BackColor = Color.FromArgb(28, 94, 85);
                grvAdjuntos.HeaderStyle.Font.Bold = true;
                //grvAdjuntos.HeaderStyle.ForeColor = Color.FromArgb(255, 255, 255);
                grvAdjuntos.AlternatingRowStyle.BackColor = Color.White;
                grvAdjuntos.Width = Unit.Percentage(100);
                //grvAdjuntos.RowDataBound += new GridViewRowEventHandler(grvAdjuntos_RowDataBound);

                #region Adicion de columnas al Grid
                TemplateField    chkAdjuntar = new TemplateField();
                CheckBoxTemplate chkBox      = new CheckBoxTemplate();
                chkAdjuntar.ItemTemplate = chkBox;

                BoundField bflNombreArchivo = new BoundField();
                bflNombreArchivo.HeaderText = "Nombre archivo";
                bflNombreArchivo.DataField  = "NombreArchivo";

                BoundField bflTipoArchivo = new BoundField();
                bflTipoArchivo.HeaderText = "Tipo";
                bflTipoArchivo.DataField  = "TipoArchivo";

                ImageField imfVistaPrevia = new ImageField();
                imfVistaPrevia.HeaderText        = "Vista Previa";
                imfVistaPrevia.DataImageUrlField = "VistaPrevia";

                BoundField bflRutaArchivo = new BoundField();
                bflRutaArchivo.HeaderText = "URL";
                bflRutaArchivo.DataField  = "RutaArchivo";
                bflRutaArchivo.Visible    = false;

                grvAdjuntos.Columns.Add(chkAdjuntar);
                grvAdjuntos.Columns.Add(bflNombreArchivo);
                grvAdjuntos.Columns.Add(bflTipoArchivo);
                grvAdjuntos.Columns.Add(imfVistaPrevia);
                grvAdjuntos.Columns.Add(bflRutaArchivo);

                grvAdjuntos.DataSource = ConectorWebPart.RecuperarDocumentosFP().Tables["DataTable"];
                grvAdjuntos.DataBind();
                #endregion

                btnAdjuntarArchivos         = new LinkButton();
                btnAdjuntarArchivos.ID      = "btnAdjuntarArchivos";
                btnAdjuntarArchivos.Text    = "Adjuntar Archivos";
                btnAdjuntarArchivos.ToolTip = "Ver el panel de adjuntar archivos.";
                btnAdjuntarArchivos.Attributes.Add("style", "font-size:8.5pt;");
                btnAdjuntarArchivos.Click           += new EventHandler(btnAdjuntarArchivos_Click);
                btnAdjuntarArchivos.CausesValidation = false; //OJO
                btnFinalizarRegistro         = new Button();
                btnFinalizarRegistro.ID      = "btnFinalizarRegistro";
                btnFinalizarRegistro.Text    = "Finalizar";
                btnFinalizarRegistro.ToolTip = "Finalizar el registro de nueva correspondencia.";
                btnFinalizarRegistro.Visible = true;
                btnFinalizarRegistro.Attributes.Add("style", "width:140px; font-size:8.5pt;");
                btnFinalizarRegistro.Click += new EventHandler(btnFinalizarRegistro_Click);
                //btnIrAtras = new Button();
                //btnIrAtras.ID = "btnIrAtras";
                //btnIrAtras.Text = "Ir Atras";
                //btnIrAtras.ToolTip = "Volver al formulario de registro";
                //btnIrAtras.Visible = false;
                //btnIrAtras.Attributes.Add("style", "width:140px; font-size:8.5pt;");
                //btnIrAtras.Click += new EventHandler(btnIrAtras_Click);
                btnCancelar             = new GoBackButton();
                btnCancelar.ID          = "btnCancelar";
                btnCancelar.ControlMode = SPControlMode.New;
                #endregion

                #region Adiccion de controles
                pnlFormulario.Controls.Add(new LiteralControl("<table border='0' cellspacing='0' width='100%'>"));
                pnlFormulario.Controls.Add(new LiteralControl("<tr><td colspan='2' style='border-bottom:1px black solid'><b>Datos de la Correspondencia</b></td></tr>"));

                pnlFormulario.Controls.Add(new LiteralControl("<tr><td width='190px' valign='top' class='ms-formlabel'><H3 class='ms-standardheader'><nobr>"));
                pnlFormulario.Controls.Add(lblTipoCarta);
                pnlFormulario.Controls.Add(new LiteralControl("</nobr></H3></td><td width='500px' valign='top' class='ms-formbody'>"));
                pnlFormulario.Controls.Add(rblTipoCarta);
                pnlFormulario.Controls.Add(lblDescTipoCarta);
                pnlFormulario.Controls.Add(rfvTipoCarta);
                pnlFormulario.Controls.Add(new LiteralControl("</td></tr>"));

                pnlFormulario.Controls.Add(new LiteralControl("<tr><td width='190px' valign='top' class='ms-formlabel'><H3 class='ms-standardheader'><nobr>"));
                pnlFormulario.Controls.Add(lblOrigenCarta);
                pnlFormulario.Controls.Add(new LiteralControl("</nobr></H3></td><td width='500px' valign='top' class='ms-formbody'>"));
                pnlFormulario.Controls.Add(new LiteralControl("<table><tr><td>"));
                pnlFormulario.Controls.Add(rblOrigenCarta);
                pnlFormulario.Controls.Add(new LiteralControl("</td><td>"));
                pnlFormulario.Controls.Add(ddlOrigenCarta);
                pnlFormulario.Controls.Add(new LiteralControl("<br/>"));
                pnlFormulario.Controls.Add(txbOrigenCarta);
                pnlFormulario.Controls.Add(new LiteralControl("</td></tr></table>"));
                pnlFormulario.Controls.Add(lblDescOrigenCarta);
                pnlFormulario.Controls.Add(ctvOrigenCarta);
                pnlFormulario.Controls.Add(new LiteralControl("</td></tr>"));

                pnlFormulario.Controls.Add(new LiteralControl("<tr><td width='190px' valign='top' class='ms-formlabel'><H3 class='ms-standardheader'><nobr>"));
                pnlFormulario.Controls.Add(lblReferencia);
                pnlFormulario.Controls.Add(new LiteralControl("</nobr></H3></td><td width='500px' valign='top' class='ms-formbody'>"));
                pnlFormulario.Controls.Add(txbReferencia);
                pnlFormulario.Controls.Add(lblDescReferencia);
                pnlFormulario.Controls.Add(rfvReferencia);
                pnlFormulario.Controls.Add(new LiteralControl("</td></tr>"));

                pnlFormulario.Controls.Add(new LiteralControl("<tr><td width='190px' valign='top' class='ms-formlabel'><H3 class='ms-standardheader'><nobr>"));
                pnlFormulario.Controls.Add(lblFechaCarta);
                pnlFormulario.Controls.Add(new LiteralControl("</nobr></H3></td><td width='500px' valign='top' class='ms-formbody'>"));
                pnlFormulario.Controls.Add(dtcFechaCarta);
                pnlFormulario.Controls.Add(lblDescFechaCarta);
                pnlFormulario.Controls.Add(new LiteralControl("</td></tr>"));

                pnlFormulario.Controls.Add(new LiteralControl("<tr><td width='190px' valign='top' class='ms-formlabel'><H3 class='ms-standardheader'><nobr>"));
                pnlFormulario.Controls.Add(lblFechaRecibida);
                pnlFormulario.Controls.Add(new LiteralControl("</nobr></H3></td><td width='500px' valign='top' class='ms-formbody'>"));
                pnlFormulario.Controls.Add(dtcFechaRecibida);
                pnlFormulario.Controls.Add(lblDescFechaRecibida);
                pnlFormulario.Controls.Add(new LiteralControl("</td></tr>"));

                pnlFormulario.Controls.Add(new LiteralControl("<tr><td width='190px' valign='top' class='ms-formlabel'><H3 class='ms-standardheader'><nobr>"));
                pnlFormulario.Controls.Add(lblDestinatario);
                pnlFormulario.Controls.Add(new LiteralControl("</nobr></H3></td><td width='500px' valign='top' class='ms-formbody'>"));
                pnlFormulario.Controls.Add(txbDestinatario);
                pnlFormulario.Controls.Add(lblDescDestinatario);
                pnlFormulario.Controls.Add(rfvDestinatario);
                pnlFormulario.Controls.Add(new LiteralControl("</td></tr>"));

                pnlFormulario.Controls.Add(new LiteralControl("<tr><td width='190px' valign='top' class='ms-formlabel'><H3 class='ms-standardheader'><nobr>"));
                pnlFormulario.Controls.Add(lblDirigidaA);
                pnlFormulario.Controls.Add(new LiteralControl("</nobr></H3></td><td width='500px' valign='top' class='ms-formbody'>"));
                pnlFormulario.Controls.Add(pedDirigidaA);
                pnlFormulario.Controls.Add(lblDescDirigidaA);
                pnlFormulario.Controls.Add(rfvDirigidaA);
                pnlFormulario.Controls.Add(new LiteralControl("</td></tr>"));

                pnlFormulario.Controls.Add(new LiteralControl("<tr><td width='190px' valign='top' class='ms-formlabel'><H3 class='ms-standardheader'><nobr>"));
                pnlFormulario.Controls.Add(lblNumCarta);
                pnlFormulario.Controls.Add(new LiteralControl("</nobr></H3></td><td width='500px' valign='top' class='ms-formbody'>"));
                pnlFormulario.Controls.Add(txbNumCarta);
                pnlFormulario.Controls.Add(lblDescNumCarta);
                pnlFormulario.Controls.Add(new LiteralControl("</td></tr>"));

                pnlFormulario.Controls.Add(new LiteralControl("<tr><td width='190px' valign='top' class='ms-formlabel'><H3 class='ms-standardheader'><nobr>"));
                pnlFormulario.Controls.Add(lblAdjunto);
                pnlFormulario.Controls.Add(new LiteralControl("</nobr></H3></td><td width='500px' valign='top' class='ms-formbody'>"));
                pnlFormulario.Controls.Add(txbAdjunto);
                pnlFormulario.Controls.Add(lblDescAdjunto);
                pnlFormulario.Controls.Add(rfvAdjunto);
                pnlFormulario.Controls.Add(new LiteralControl("</td></tr>"));

                pnlFormulario.Controls.Add(new LiteralControl("<tr><td width='190px' valign='top' class='ms-formlabel'><H3 class='ms-standardheader'><nobr>"));
                pnlFormulario.Controls.Add(lblClase);
                pnlFormulario.Controls.Add(new LiteralControl("</nobr></H3></td><td width='500px' valign='top' class='ms-formbody'>"));
                pnlFormulario.Controls.Add(txbClase);
                pnlFormulario.Controls.Add(lblDescClase);
                pnlFormulario.Controls.Add(rfvClase);
                pnlFormulario.Controls.Add(new LiteralControl("</td></tr>"));

                pnlFormulario.Controls.Add(new LiteralControl("<tr><td width='190px' valign='top' class='ms-formlabel'><H3 class='ms-standardheader'><nobr>"));
                pnlFormulario.Controls.Add(lblPrioridad);
                pnlFormulario.Controls.Add(new LiteralControl("</nobr></H3></td><td width='500px' valign='top' class='ms-formbody'>"));
                pnlFormulario.Controls.Add(ddlPrioridad);
                pnlFormulario.Controls.Add(lblDescPrioridad);
                pnlFormulario.Controls.Add(new LiteralControl("</td></tr>"));

                pnlFormulario.Controls.Add(new LiteralControl("<tr><td width='190px' valign='top' class='ms-formlabel'><H3 class='ms-standardheader'><nobr>"));
                pnlFormulario.Controls.Add(lblPrivada);
                pnlFormulario.Controls.Add(new LiteralControl("</nobr></H3></td><td width='500px' valign='top' class='ms-formbody'>"));
                pnlFormulario.Controls.Add(chkPrivada);
                pnlFormulario.Controls.Add(lblDescPrivada);
                pnlFormulario.Controls.Add(new LiteralControl("</td></tr>"));

                pnlFormulario.Controls.Add(new LiteralControl("<tr><td width='190px' valign='top' class='ms-formlabel'><H3 class='ms-standardheader'><nobr>"));
                pnlFormulario.Controls.Add(lblHojaDeRuta);
                pnlFormulario.Controls.Add(new LiteralControl("</nobr></H3></td><td width='500px' valign='top' class='ms-formbody'>"));
                pnlFormulario.Controls.Add(chkHojaDeRuta);
                pnlFormulario.Controls.Add(lblDescHojaDeRuta);
                pnlFormulario.Controls.Add(new LiteralControl("</td></tr>"));

                pnlFormulario.Controls.Add(new LiteralControl("<tr><td width='190px' valign='top' class='ms-formlabel'><H3 class='ms-standardheader'><nobr>"));
                pnlFormulario.Controls.Add(lblArchivo);
                pnlFormulario.Controls.Add(new LiteralControl("</nobr></H3></td><td width='500px' valign='top' class='ms-formbody'>"));
                pnlFormulario.Controls.Add(txbArchivo);
                pnlFormulario.Controls.Add(lblDescArchivo);
                pnlFormulario.Controls.Add(new LiteralControl("</td></tr>"));
                pnlFormulario.Controls.Add(new LiteralControl("</table>"));

                pnlAdjuntos.Controls.Add(new LiteralControl("<table border='0' cellspacing='0' width='100%'>"));
                pnlAdjuntos.Controls.Add(new LiteralControl("<tr><td colspan='2' style='border-bottom:1px black solid'><b>Archivos Adjuntos</b></td></tr>"));
                pnlAdjuntos.Controls.Add(new LiteralControl("<tr><td width='190px' valign='top' class='ms-formlabel'><H3 class='ms-standardheader'><nobr>"));
                pnlAdjuntos.Controls.Add(lblAdjuntos);
                pnlAdjuntos.Controls.Add(new LiteralControl("</nobr></H3></td><td width='500px' valign='top' class='ms-formbody'>"));
                pnlAdjuntos.Controls.Add(lblDescAdjuntos);
                pnlAdjuntos.Controls.Add(grvAdjuntos);
                pnlAdjuntos.Controls.Add(new LiteralControl("</td></tr>"));
                pnlAdjuntos.Controls.Add(new LiteralControl("</table>"));

                this.Controls.Add(pnlFormulario);
                this.Controls.Add(pnlAdjuntos);
                this.Controls.Add(new LiteralControl("<table border='0' cellspacing='0' width='100%'>"));
                this.Controls.Add(new LiteralControl("<tr><td style='text-align:right' class='ms-toolbar'>"));
                this.Controls.Add(new LiteralControl("<table><tr><td width='99%' class='ms-toolbar'><IMG SRC='/_layouts/images/blank.gif' width='1' height='18'/></td>"));
                this.Controls.Add(new LiteralControl("<td nowrap='nowrap' class='ms-toolbar'>"));
                this.Controls.Add(btnAdjuntarArchivos);
                this.Controls.Add(new LiteralControl("</td><td class='ms-separator'> </td><td class='ms-toolbar' align='right'>"));
                this.Controls.Add(btnFinalizarRegistro);
                this.Controls.Add(new LiteralControl("</td><td class='ms-separator'> </td><td class='ms-toolbar' align='right'>"));
                this.Controls.Add(btnCancelar);
                //this.Controls.Add(btnIrAtras);
                this.Controls.Add(new LiteralControl("</td></tr></table>"));
                this.Controls.Add(new LiteralControl("</td></tr>"));
                this.Controls.Add(new LiteralControl("</table>"));
                #endregion
            }
            catch (Exception ex)
            {
                Literal error = new Literal();
                error.Text = ex.Message;

                this.Controls.Clear();
                this.Controls.Add(error);
            }
        }
Example #28
0
        private void GenerateInnerHtml()
        {
            StringBuilder innerHtml0 = new StringBuilder();

            innerHtml0.Remove(0, innerHtml0.Length);

            SPViewCollection viewCollection = currentList.Views;

            innerHtml0.AppendLine("<table width='99%' class='ms-v4propertysheetspacing' border='0' cellSpacing='0' cellPadding='0'>");
            innerHtml0.AppendLine("<tbody>");
            innerHtml0.AppendLine(@"");


            LiteralControl nullSection = new LiteralControl(innerHtml0.ToString());

            MainPanel.Controls.Add(nullSection);

            int i = 0;

            foreach (SPView currentView in viewCollection)
            {
                if (currentView.Title != "")
                {
                    StringBuilder innerHtml = new StringBuilder();
                    innerHtml.Remove(0, innerHtml.Length);
                    innerHtml.AppendLine("<td class='ms-sectionline' height='1' colSpan='2'><img alt='' src='/_layouts/images/blank.gif' width='1' height='1'></td>");
                    innerHtml.AppendLine(@"
                    <tr>
                    <td class='ms-descriptiontext' vAlign='top'>
                        <table border='0' cellpadding='1' cellspacing='0' width='100%'>
                            <tr>
                                <td class='ms-sectionheader' style='padding-top: 4px;' height='22' valign='top'>
                                    <h3 class='ms-standardheader ms-inputformheader'>
                                        " + currentView.Title + @"
                                    </h3>
                                </td>
                            </tr>
                            <tr>
                                <td class='ms-descriptiontext ms-inputformdescription'>
                                        You can enter User names, Group names, Active Directory group names or e-mail addresses <b>which will not have the permission for this View</b>.
                                        <br />Separate them with semicolons.
                                        <br />
                                </td>
                                <td>
                                    <img src='/_layouts/images/blank.gif' width='8' height='1' alt='' />
                                </td>
                            </tr>
                        </table>
                    </td>");


                    innerHtml.AppendLine(@"<td class='ms-authoringcontrols ms-inputformcontrols' valign='top' align='left' width='40%'>");
                    innerHtml.AppendLine(@"
                <table border='0' width='100%' cellspacing='0' cellpadding='0'>
                    <tr>
                        <td width='9px'>
                            <img src='/_layouts/images/blank.gif' width='9' height='7' alt='' />
                        </td>
                        <td>
                            <img src='/_layouts/images/blank.gif' width='150' height='7' alt='' />
                        </td>
                        <td width='10px'>
                            <img src='/_layouts/images/blank.gif' width='10' height='1' alt='' />
                        </td>
                    </tr>
                    <tr>
                        <td />
                        <td class='ms-authoringcontrols'>
                            <table class='ms-authoringcontrols' border='0' width='100%' cellspacing='0' cellpadding='0'>
                                <tr>
                                    <td class='ms-authoringcontrols' colspan='2'>
                                        <span>Users/Groups:</span>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <img src='/_layouts/images/blank.gif' width='1' height='3' style='display: block'
                                            alt='' />
                                    </td>
                                </tr>
                                <tr>
                                    <td align='left' class='' valign='top'>");

                    LiteralControl firstSection = new LiteralControl(innerHtml.ToString());
                    MainPanel.Controls.Add(firstSection);

                    PeopleEditor peopleEditor = new PeopleEditor();
                    peopleEditor.ID = "pe" + i.ToString();

                    peopleEditor.SelectionSet     = "User,DL,SecGroup,SPGroup";
                    peopleEditor.AllowEmpty       = true;
                    peopleEditor.Rows             = 3;
                    peopleEditor.ValidatorEnabled = true;
                    peopleEditor.MultiSelect      = true;

                    MainPanel.Controls.Add(peopleEditor);

                    StringBuilder innerHtml2 = new StringBuilder();
                    innerHtml2.Remove(0, innerHtml2.Length);
                    innerHtml2.AppendLine(@"
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                        </table>
                        </td>
                       </tr>");
                    LiteralControl secondSection = new LiteralControl(innerHtml2.ToString());
                    MainPanel.Controls.Add(secondSection);

                    i++;
                }
            }

            StringBuilder innerHtml3 = new StringBuilder();

            innerHtml3.Remove(0, innerHtml3.Length);
            innerHtml3.AppendLine("</tbody>");
            innerHtml3.AppendLine("</table>");

            LiteralControl thirdSection = new LiteralControl(innerHtml3.ToString());

            MainPanel.Controls.Add(thirdSection);
        }
        protected override void CreateChildControls()
        {
            SPWeb spWeb = SPControl.GetContextWeb(this.Context);
            SPUser user = spWeb.CurrentUser;

            HtmlForm form = new HtmlForm();
            form.ID = "frmAddSignature";
            form.Method = "post";
            form.DefaultButton = "btnOK";
            body.Controls.Add(form);

            form.Controls.Add(new LiteralControl(@"<div style=""padding: 20px"">"));
            form.Controls.Add(new LiteralControl("Add your signature by entering your password<br /><br />"));
            form.Controls.Add(new LiteralControl(@"<div style=""margin-left: 20px"">"));

            Table table = new Table();
            form.Controls.Add(table);

            #region User row
            TableRow rowUser = new TableRow();
            table.Controls.Add(rowUser);

            TableCell cellUserLabel = new TableCell();
            cellUserLabel.Controls.Add(new LiteralControl(@"<h3 class=""ms-standardheader"" style=""font-size: 0.7em"">User </h3>"));
            rowUser.Controls.Add(cellUserLabel);

            TableCell cellUserControl = new TableCell();
            rowUser.Controls.Add(cellUserControl);

            pedUser = new PeopleEditor();
            pedUser.ID = "pedUser";
            pedUser.AllowEmpty = false;
            pedUser.AutoPostBack = true;
            pedUser.SelectionSet = "User";
            pedUser.Width = Unit.Pixel(200);
            pedUser.PlaceButtonsUnderEntityEditor = false;
            pedUser.Rows = 1;
            pedUser.MultiSelect = false;
            pedUser.ValidatorEnabled = true;
            pedUser.CommaSeparatedAccounts = user.ToString();
            cellUserControl.Controls.Add(pedUser);

            TableRow rowUsernameValidation = new TableRow();
            table.Controls.Add(rowUsernameValidation);

            TableCell cellUsernameValidationSpacer = new TableCell();
            rowUsernameValidation.Controls.Add(cellUsernameValidationSpacer);

            TableCell cellUsernameValidation = new TableCell();
            cellUsernameValidation.Controls.Add(new LiteralControl(@"<div id=""usernameMessageDiv"" class=""ms-formvalidation""></div>"));
            rowUsernameValidation.Controls.Add(cellUsernameValidation);
            #endregion

            #region Reason row
            TableRow rowReason = new TableRow();
            table.Controls.Add(rowReason);

            TableCell cellReasonLabel = new TableCell();
            cellReasonLabel.Controls.Add(new LiteralControl(@"<h3 class=""ms-standardheader"" style=""font-size: 0.7em"">Reason </h3>"));
            rowReason.Controls.Add(cellReasonLabel);

            TableCell cellReasonControl = new TableCell();
            rowReason.Controls.Add(cellReasonControl);

            DropDownList ddlReason = new DropDownList();
            ddlReason.ID = "ddlReason";
            ddlReason.AutoPostBack = false;
            ddlReason.Items.Add(new ListItem("Approved"));
            ddlReason.Items.Add(new ListItem("Reviewed"));
            ddlReason.Items.Add(new ListItem("Rejected"));
            ddlReason.SelectedIndex = 0;
            ddlReason.BorderWidth = Unit.Pixel(1);
            ddlReason.BorderColor = Color.FromArgb(165, 165, 165);
            ddlReason.BorderStyle = BorderStyle.Solid;
            cellReasonControl.Controls.Add(ddlReason);

            /*
            TextBox txtReason = new TextBox();
            txtReason.ID = "txtReason";
            txtReason.Width = Unit.Pixel(250);
            txtReason.BorderWidth = Unit.Pixel(1);
            txtReason.BorderColor = Color.FromArgb(165, 165, 165);
            txtReason.BorderStyle = BorderStyle.Solid;
            cellReasonControl.Controls.Add(txtReason); 
            */
            #endregion

            #region Password row
            TableRow rowPassword = new TableRow();
            table.Controls.Add(rowPassword);

            TableCell cellPasswordLabel = new TableCell();
            cellPasswordLabel.Controls.Add(new LiteralControl(@"<h3 class=""ms-standardheader"" style=""font-size: 0.7em"">Password </h3>"));
            rowPassword.Controls.Add(cellPasswordLabel);

            TableCell cellPasswordControl = new TableCell();
            rowPassword.Controls.Add(cellPasswordControl);

            TextBox txtPassword = new TextBox();
            txtPassword.ID = "txtPassword";
            txtPassword.TextMode = TextBoxMode.Password;
            txtPassword.Width = Unit.Pixel(157);
            txtPassword.BorderWidth = Unit.Pixel(1);
            txtPassword.BorderColor = Color.FromArgb(165, 165, 165);
            txtPassword.BorderStyle = BorderStyle.Solid;
            cellPasswordControl.Controls.Add(txtPassword);

            TableRow rowPasswordValidation = new TableRow();
            table.Controls.Add(rowPasswordValidation);

            TableCell cellPasswordValidationSpacer = new TableCell();
            rowPasswordValidation.Controls.Add(cellPasswordValidationSpacer);

            TableCell cellPasswordValidation = new TableCell();
            cellPasswordValidation.Controls.Add(new LiteralControl(@"<div id=""errorMessageDiv"" class=""ms-formvalidation""><br /></div>"));
            rowPasswordValidation.Controls.Add(cellPasswordValidation);
            #endregion

            form.Controls.Add(new LiteralControl(@"</div>"));

            form.Controls.Add(new LiteralControl(@"<div style=""position: absolute; bottom: 20px; right: 24px;"">"));

            Button btnOK = new Button();
            btnOK.ID = "btnOK";
            btnOK.Text = "OK";
            btnOK.Width = new Unit(64, UnitType.Pixel);
            btnOK.OnClientClick = @"javascript:TestPasswordAsync(); return false;";
            form.Controls.Add(btnOK);

            form.Controls.Add(new LiteralControl("&nbsp;"));

            Button btnCancel = new Button();
            btnCancel.ID = "btnCancel";
            btnCancel.Text = "Cancel";
            btnCancel.Width = new Unit(64, UnitType.Pixel);
            btnCancel.OnClientClick = @"javascript:window.close(); return false;";
            form.Controls.Add(btnCancel);

            form.Controls.Add(new LiteralControl(@"</div>"));
            form.Controls.Add(new LiteralControl(@"</div>"));

            body.Attributes.Add("onload", "document.getElementById('txtPassword').focus();");

            base.CreateChildControls();
        }
 internal static bool HasResolvedEntries(this PeopleEditor editor)
 {
     return(editor.ResolvedEntities.Count > 0);
 }
 public static string GetPickerEntities(PeopleEditor Editor, char separator)
 {
     Editor.RequireNotNull("Editor");
     if (Editor.Entities.Count == 0)
     {
         return string.Empty;
     }
     PickerEntity firstEntity = (PickerEntity)Editor.Entities[0];
     StringBuilder sb = new StringBuilder(firstEntity.Key);
     foreach (PickerEntity entity in Editor.Entities.OfType<PickerEntity>().Skip(1))
     {
         sb.AppendFormat("{0}{1}", separator, entity.Key);
     }
     return sb.ToString();
 }
 public string GetPickerEntities(PeopleEditor Editor, char separator)
 {
     return SharePointUtilities.GetPickerEntities(Editor, separator);
 }