当前位置: 首页>>代码示例>>C#>>正文


C# SPFieldLookupValue类代码示例

本文整理汇总了C#中SPFieldLookupValue的典型用法代码示例。如果您正苦于以下问题:C# SPFieldLookupValue类的具体用法?C# SPFieldLookupValue怎么用?C# SPFieldLookupValue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SPFieldLookupValue类属于命名空间,在下文中一共展示了SPFieldLookupValue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetActiveCustomers

        public static ArrayList GetActiveCustomers(DateTime hitDate, SPWeb web)
        {
            ArrayList results = new ArrayList();

            DateTime baseDate = new DateTime(hitDate.Year, hitDate.Month, 1);


                    var targetList = web.Lists.TryGetList("Karty pracy");

                    if (targetList != null)
                    {
                        targetList.Items.Cast<SPListItem>()
                            .Where(i => (DateTime)i["colData"] >= baseDate)
                            .Where(i => (DateTime)i["colData"] <= hitDate)
                            .Where(i => i["colCzyRozliczony"] == null || (bool)i["colCzyRozliczony"] != true)
                            .GroupBy(i => i["selKlient"])
                            .ToList()
                            .ForEach(item =>
                            {
                                string groupItemKey = item.Key.ToString();
                                int customerId = new SPFieldLookupValue(groupItemKey).LookupId;

                                results.Add(customerId);
                            });
                    }


                return results;

        }
开发者ID:RAWcom,项目名称:Rawcom.TS,代码行数:30,代码来源:Report.cs

示例2: Convert

        /// <summary>
        /// Converts the specified value.
        /// </summary>
        /// <param name="value">The value.</param>
        /// <param name="arguments">The arguments.</param>
        /// <returns>
        /// The converted value.
        /// </returns>
        public override object Convert(object value, DataRowConversionArguments arguments)
        {
            var lookupValue = value as SPFieldLookupValue;

            if (value == DBNull.Value)
            {
                return null;
            }

            if (lookupValue == null)
            {
                var stringValue = value as string;
                if (!string.IsNullOrEmpty(stringValue))
                {
                    lookupValue = new SPFieldLookupValue(stringValue);
                }
            }

            if (lookupValue != null)
            {
                var lookupField = new SPFieldLookup(arguments.FieldCollection, arguments.ValueKey);

                if (lookupField.LookupWebId == Guid.Empty || lookupField.LookupWebId == arguments.Web.ID)
                {
                    return GetLookupFieldValue(arguments.Web, lookupField.LookupList, this._projectedFieldName, lookupValue.LookupId);
                }

                using (var web = arguments.Web.Site.OpenWeb(lookupField.LookupWebId))
                {
                    return GetLookupFieldValue(web, lookupField.LookupList, this._projectedFieldName, lookupValue.LookupId);
                }
            }

            return null;
        }
开发者ID:GAlexandreBastien,项目名称:Dynamite-2010,代码行数:43,代码来源:ProjectedLookupValueDataRowConverter.cs

示例3: GetEmployeedetails

        internal Employee GetEmployeedetails(string name)
        {
            var empEntity = new Employee();
            using (var site = new SPSite(SPContext.Current.Site.Url))
            {
                using (var web = site.OpenWeb())
                {
                    SPUser user = web.CurrentUser;

                    hdnCurrentUsername.Value = user.Name;

                    SPListItemCollection currentUserDetails = GetListItemCollection(web.Lists[Utilities.EmployeeScreen], "Employee Name", name, "Status", "Active");
                    foreach (SPListItem currentUserDetail in currentUserDetails)
                    {
                        empEntity.EmpId = currentUserDetail[Utilities.EmployeeId].ToString();
                        empEntity.EmployeeType = currentUserDetail[Utilities.EmployeeType].ToString();
                        empEntity.Department = currentUserDetail[Utilities.Department].ToString();
                        empEntity.Desigination = currentUserDetail[Utilities.Designation].ToString();
                        empEntity.DOJ = DateTime.Parse(currentUserDetail[Utilities.DateofJoin].ToString());
                        empEntity.ManagerWithID = currentUserDetail[Utilities.Manager].ToString();
                        var spv = new SPFieldLookupValue(currentUserDetail[Utilities.Manager].ToString());
                        empEntity.Manager = spv.LookupValue;
                    }
                }
            }
            return empEntity;
        }
开发者ID:Praveenmanne,项目名称:LeaveApplication,代码行数:27,代码来源:ResignationFormUserControl.ascx.cs

示例4: ItemAdded

        /// <summary>
        /// An item was added.
        /// </summary>
        public override void ItemAdded(SPItemEventProperties properties) {
            base.ItemAdded(properties);

            try {
                _dbg = "butik";
                object oButik = properties.ListItem[new Guid("a209aa87-f7e4-46cf-8865-37ea0002294b")];
                string strButik = oButik as string;

                if (strButik != null) {
                    SPFieldLookupValue butik = new SPFieldLookupValue(strButik);
                    _dbg = "ct";
                    string contenttype = properties.ListItem.ContentType.Name;
                    _dbg = "id";
                    int id = properties.ListItemId;
                    _dbg = "set";
                    properties.ListItem["Title"] = contenttype + " #" + id.ToString() + " - " + butik.LookupValue;
                    _dbg = "klar";
                    properties.ListItem.Update();
                    _dbg = "upd";
                    WriteLog("ItemAdded", EventLogEntryType.Information, 1002);
                }
            }
            catch (Exception ex) {
                WriteLog("Message:\r\n" + ex.Message + "\r\n\r\nStacktrace:\r\n" + ex.StackTrace + "\r\n\r\nDebug:\r\n" + _dbg, EventLogEntryType.Error, 2002);
            }
        }
开发者ID:Jerntorget,项目名称:UPCOR.TillsynKommun,代码行数:29,代码来源:AktiviteterEventReceiver.cs

示例5: OnInit

 protected override void OnInit(EventArgs e)
 {
     CustomDropDownList field = base.Field as CustomDropDownList;
     if (field.AllowMultipleValues)
     {
         if (ControlMode == SPControlMode.Edit || ControlMode == SPControlMode.Display)
         {
             if (base.ListItemFieldValue != null)
             {
                 _fieldVals = base.ListItemFieldValue as SPFieldLookupValueCollection;
             }
             else { _fieldVals = new SPFieldLookupValueCollection(); }
         }
         if (ControlMode == SPControlMode.New) { _fieldVals = new SPFieldLookupValueCollection(); }
         base.OnInit(e);
         Initialize_multi_value((CustomDropDownList)this.Field);
     }
     else
     {
         if (ControlMode == SPControlMode.Edit || ControlMode == SPControlMode.Display)
         {
             if (base.ListItemFieldValue != null)
             {
                 _fieldVal = base.ListItemFieldValue as SPFieldLookupValue;
             }
             else { _fieldVal = new SPFieldLookupValue(); }
         }
         if (ControlMode == SPControlMode.New) { _fieldVal = new SPFieldLookupValue(); }
         base.OnInit(e);
         Initialize((CustomDropDownList)base.Field);
     }
 }
开发者ID:karayakar,项目名称:SharePoint,代码行数:32,代码来源:CustomDropDownListControl.cs

示例6: RespondToDelegationUpdating

        /// <summary>
        /// Responds to delegation updating.
        /// </summary>
        /// <param name="properties">The properties.</param>
        /// <param name="web">The web.</param>
        public static void RespondToDelegationUpdating(SPItemEventProperties properties, SPWeb web)
        {
            SPFieldLookupValue statusValue = new SPFieldLookupValue(properties.AfterProperties[DelegationsFields.DelegationStatus.Name].ToString());
            string description = properties.AfterProperties[DelegationsFields.DelegationNote.Name].ToString();
            var list = web.Lists[properties.ListId];
            var listItem = list.Items.GetItemById(properties.ListItemId);

            if (statusValue.LookupId == Draft)
            {
                if (String.IsNullOrEmpty(description))
                {
                    properties.Cancel = true;
                    properties.ErrorMessage = "Description cannot be empty.";
                    properties.Status = SPEventReceiverStatus.CancelWithError;
                }
                else
                {
                    SPFieldUserValue userValue = new SPFieldUserValue(properties.Web, properties.ListItem[SPBuiltInFieldId.Author].ToString());
                    Permissions.GrantPermission(web, listItem, userValue.User.Name, SPRoleType.Contributor);
                    SendMail(web, userValue.User.Email, description);
                }
            }
            else if (statusValue.LookupId == ForApproval)
            {
                SPFieldUserValue userValue = new SPFieldUserValue(web, properties.ListItem[SPBuiltInFieldId.Author].ToString());
                Permissions.RevokePremission(web, listItem, userValue.User.Name);
                SendMail(web, approvalEmail, properties.ListItem.Url);
            }
            else if (statusValue.LookupId == Approved)
            {
                SPFieldUserValue userValue = new SPFieldUserValue(properties.Web, properties.ListItem[SPBuiltInFieldId.Author].ToString());
                Permissions.GrantPermission(web, listItem, userValue.User.Name, SPRoleType.Reader);
                SendMail(web, userValue.User.Email, properties.ListItem.Url);
            }
        }
开发者ID:radata,项目名称:lsolilo-sharepoint,代码行数:40,代码来源:DelegationApprovalCycle.cs

示例7: ItemAdded

        /// <summary>
        /// An item was added.
        /// </summary>
        public override void ItemAdded(SPItemEventProperties properties) {
            base.ItemAdded(properties);

            try {
                string lopnummerStr = properties.Web.Properties["lopnummer"];
                int lopnummer;
                if (int.TryParse(lopnummerStr, out lopnummer)) {
                    string nyttLopnummer = (lopnummer + 1).ToString();
                    string code = properties.Web.Properties["municipalAreaCode"];
                    string letter = properties.Web.Properties["municipalRegionLetter"];
                    string kundnummer = letter + code + "-" + nyttLopnummer;
                    string strAdress = (string)properties.ListItem[new Guid("b5c833ef-df4e-44f3-9ed5-316ed61a59c9")];
                    if (!string.IsNullOrEmpty(strAdress)) {
                        SPFieldLookupValue adress = new SPFieldLookupValue(strAdress);
                        properties.ListItem[new Guid("fa564e0f-0c70-4ab9-b863-0177e6ddd247")] = adress.LookupValue;
                    }
                    else {
                        properties.ListItem[new Guid("fa564e0f-0c70-4ab9-b863-0177e6ddd247")] = kundnummer;
                    }
                    properties.ListItem[new Guid("353eabaa-f0d3-40cc-acc3-4c6b23d3a64f")] = kundnummer;
                    
                    properties.ListItem.Update();
                    properties.Web.Properties["lopnummer"] = nyttLopnummer;
                    properties.Web.Properties.Update();
                }
                WriteLog("Success", EventLogEntryType.Information, 1000);
            }
            catch (Exception ex) {
                WriteLog("Message:\r\n" + ex.Message + "\r\n\r\nStacktrace:\r\n" + ex.StackTrace, EventLogEntryType.Error, 2000);
            }
        }
开发者ID:Jerntorget,项目名称:UPCOR.TillsynKommun,代码行数:34,代码来源:KundkortEventReceiver.cs

示例8: Update_LookupRefFields

        /// <summary>
        /// aktualizuje pole _NazwaPrezentowana
        /// </summary>
        private static void Update_LookupRefFields(SPListItem item)
        {
            // aktualizacja odwołań do lookupów
            item["_TypZawartosci"] = item["ContentType"].ToString();
            item["_Biuro"] = item["selBiuro"] != null ? new SPFieldLookupValue(item["selBiuro"].ToString()).LookupValue : string.Empty;
            item["_ZatrudniaPracownikow"] = item["colZatrudniaPracownikow"] != null && (bool)item["colZatrudniaPracownikow"] ? "TAK" : string.Empty;

            if (item["selDedykowanyOperator_Podatki"] != null)
            {
                item["_DedykowanyOperator_Podatki"] = new SPFieldLookupValue(item["selDedykowanyOperator_Podatki"].ToString()).LookupValue;
            }
            if (item["selDedykowanyOperator_Kadry"] != null)
            {
                item["_DedykowanyOperator_Kadry"] = new SPFieldLookupValue(item["selDedykowanyOperator_Kadry"].ToString()).LookupValue;
            }
            if (item["selDedykowanyOperator_Audyt"] != null)
            {
                item["_DedykowanyOperator_Audyt"] = new SPFieldLookupValue(item["selDedykowanyOperator_Audyt"].ToString()).LookupValue;
            }

            //nazwa prezentowana
            string np = string.Empty;
            switch (item.ContentType.Name)
            {
                case "KPiR":
                case "KSH":
                    np = string.Format("{0} NIP:{1}",
                        item["colNazwaSkrocona"]!=null?item["colNazwaSkrocona"].ToString(): item.Title,
                        item["colNIP"] != null ? item["colNIP"].ToString() : string.Empty);
                    break;
                case "Firma":
                    string nazwa = item["colNazwa"]!=null?item["colNazwa"].ToString():string.Empty;
                    string nip = item["colNIP"] != null ? item["colNIP"].ToString() : string.Empty;
                    np = string.Format(@"::{0} NIP:{1}", nazwa, nip );
                    break;
                case "Firma zewnętrzna":
                    string nazwaFirmyZewn = item["colNazwa"] != null ? item["colNazwa"].ToString() : string.Empty;
                    np = "::" + nazwaFirmyZewn.Trim() + "::";
                    break;
                case "Osoba fizyczna":
                    string npNazwsko = item["colNazwisko"] != null ? item["colNazwisko"].ToString().Trim() : string.Empty;
                    string npImie = item["colImie"] != null ? item["colImie"].ToString().Trim() : string.Empty;
                    string npPESEL = item["colPESEL"] != null ? item["colPESEL"].ToString().Trim() : string.Empty;
                    np = string.Format(@":{0} {1} PESEL:{2}", npNazwsko, npImie, npPESEL);
                    break;
                case "Klient":
                    np = "?"+item["colNazwaSkrocona"].ToString();
                    break;
                case "Powiązanie":
                    np = string.Format(@"{0}\{1}",
                        BLL.Tools.Get_LookupValue(item, "selKlient_NazwaSkrocona"),
                        BLL.Tools.Get_LookupValue(item, "selKlient"));
                    break;
                default:
                    break;
            }
            item["_NazwaPrezentowana"] = np;
            item.SystemUpdate();
        }
开发者ID:fraczo,项目名称:Biuromagda,代码行数:62,代码来源:tabKlienciER.cs

示例9: ShouldItAlsoUpdateTheLookupValue

        public void ShouldItAlsoUpdateTheLookupValue()
        {
            using (var site = new SPSite("http://winsrv2008"))
            using (var web = site.OpenWeb())
            {
                var list = web.Lists["Assets"];
                var item = list.GetItemById(262);
                item["Room"] = new SPFieldLookupValue(19, null);
                item.Update();
            }

        }
开发者ID:danielalexandrecosta,项目名称:domaindrivensharepoint,代码行数:12,代码来源:WhenUpdatingTheValueOfALookupFieldsId.cs

示例10: Execute

        const string targetList = @"Faktury elektroniczne - import"; //"intFakturyElektroniczne";

        public static void Execute(SPListItem item, SPWeb web)
        {
            int okresId = new SPFieldLookupValue(item["selOkres"].ToString()).LookupId;

            SPList list = web.Lists.TryGetList(targetList);

            list.Items.Cast<SPListItem>()
                .ToList()
                .ForEach(oItem =>
                {
                    Import_Faktura(oItem, okresId);
                });
        }
开发者ID:fraczo,项目名称:Biuromagda,代码行数:15,代码来源:ImportFakturElektronicznych.cs

示例11: Execute

        const string targetList = @"Faktury za obsługę - import"; //"intFakturyZaObsluge";

        #endregion Fields

        #region Methods

        internal static void Execute(Microsoft.SharePoint.SPItemEventProperties properties, Microsoft.SharePoint.SPWeb web)
        {
            SPListItem sItem = properties.ListItem;
            int okresId = new SPFieldLookupValue(sItem["selOkres"].ToString()).LookupId;

            SPList list = web.Lists.TryGetList(targetList);

            list.Items.Cast<SPListItem>()
                .ToList()
                .ForEach(item =>
                {
                    Import_DaneOFakturze(web, item, okresId);
                });
        }
开发者ID:fraczo,项目名称:Animus,代码行数:20,代码来源:ImportFakturZaObsluge.cs

示例12: FromSpValue

	    public object FromSpValue(object value)
		{
			if (value == null||string.IsNullOrEmpty(Field.LookupList))
				return null;

			if (!Field.AllowMultipleValues)
			{
				var fieldValue = new SPFieldLookupValue(value.ToString());

				return new ObjectReference(new Guid(Field.LookupList), fieldValue.LookupId, fieldValue.LookupValue);
			}

			var fieldValues = new SPFieldLookupValueCollection(value.ToString());

			return fieldValues.Select(fieldValue => new ObjectReference(new Guid(Field.LookupList), fieldValue.LookupId, fieldValue.LookupValue)).ToList();
		}
开发者ID:s-KaiNet,项目名称:Untech.SharePoint,代码行数:16,代码来源:LookupFieldConverter.cs

示例13: AddTask

        /// <summary>
        /// This method adds tasks ref to the list in the root site.
        /// </summary>
        /// <param name="Task">SPListItem</param>
        public int AddTask(string Title, DateTime DueDate, string Approver, string DocumentAuthor, string TaskUrl, SPWeb Web, SPFieldLookupValue PublicationLocation)
        {
            SPList ObjTaskList = Web.Lists["Document Approval Tasks"];
            SPListItem _newTask = ObjTaskList.Items.Add();
            _newTask["Title"] = Title;

            _newTask["Document Approver"] = Web.SiteGroups[Approver];
            //SPHelper.SetFieldValueUser(_newTask, "Document Approver",Approver);
            SPHelper.SetFieldValueUser(_newTask, "Document Author",DocumentAuthor);
            _newTask["Due Date"] = DueDate;
            _newTask["Task Ref"] = TaskUrl;
            _newTask["Published Location"] = PublicationLocation;
            _newTask.SystemUpdate();
            Web.Update();
            return _newTask.ID;
        }
开发者ID:infinitimods,项目名称:clif-sharepoint,代码行数:20,代码来源:DocumentApprovalTasks.cs

示例14: PendingLeaves

        public void PendingLeaves()
        {
            try
            {
                using (var site = new SPSite(SPContext.Current.Site.Url))
                {
                    using (var web = site.OpenWeb())
                    {
                        var managerList = web.Lists.TryGetList(Utilities.ReportingTo);
                        var leavelist = web.Lists.TryGetList(Utilities.LeaveRequest);

                        var pendings = GetListItemCollection(leavelist, "Status", "Pending", "Year",
                                                                                 hdnCurrentYear.Value);
                        if (pendings.Count > 0)
                        {
                            DataTable table = PendingstableStructure();

                            if (leavelist != null)
                            {

                                var managerListDetails = managerList.GetItems();
                                foreach (SPListItem managerListDetail in managerListDetails)
                                {
                                    DataRow dataRow = table.NewRow();
                                    var spv = new SPFieldLookupValue(managerListDetail["Reporting Managers"].ToString());

                                    dataRow["Manager"] = spv.LookupValue;
                                    var pendingDetails = GetListItemCollection(leavelist, "Status", "Pending", "Year",
                                                                               hdnCurrentYear.Value, "RequestedTo",
                                                                               spv.LookupValue);
                                    dataRow["No Of Leave Pending"] = pendingDetails.Count;
                                    table.Rows.Add(dataRow);
                                }
                                btnUpdate.Enabled = false;
                            }

                            ViewState["PendingResult"] = table;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                lblErr.Text = ex.Message;
            }
        }
开发者ID:Praveenmanne,项目名称:LeaveApplication,代码行数:46,代码来源:UpdateEmployeeLeavesUserControl.ascx.cs

示例15: AddPurchase

        private void AddPurchase()
        {
            SPFieldLookupValueCollection RequestDetails = new SPFieldLookupValueCollection();

            var RequestDetailList = Utility.GetListFromURL(Constants.REQUEST_DETAIL_LIST_URL, SPContext.Current.Web);
            foreach (RepeaterItem RequestDetail in repeaterRequestDetail.Items)
            {
                TextBox txtProductName = RequestDetail.FindControl("txtProductName") as TextBox;
                TextBox txtQuantity = RequestDetail.FindControl("txtQuantity") as TextBox;
                TextBox txtPrice = RequestDetail.FindControl("txtPrice") as TextBox;
                TextBox txtDescription = RequestDetail.FindControl("txtDescription") as TextBox;
                if (!string.IsNullOrEmpty(txtProductName.Text))
                {
                    SPListItem RequestDetailItem = RequestDetailList.AddItem();
                    RequestDetailItem[SPBuiltInFieldId.Title] = txtProductName.Text;
                    RequestDetailItem["Quantity"] = txtQuantity.Text.Replace(",", string.Empty);
                    RequestDetailItem["Price"] = txtPrice.Text.Replace(",", string.Empty);
                    RequestDetailItem["Description"] = txtDescription.Text;
                    RequestDetailItem.Update();
                    SPFieldLookupValue spFieldLookupValue = new SPFieldLookupValue(RequestDetailItem.ID, RequestDetailItem.Title);
                    RequestDetails.Add(spFieldLookupValue);
                }
            }

            var purchaseList = Utility.GetListFromURL(Constants.REQUEST_LIST_URL, SPContext.Current.Web);
            SPListItem purchaseItem = SPContext.Current.ListItem;
            purchaseItem[SPBuiltInFieldId.Title] = ffTitle.Value;//Constants.PURCHASE_TITLE_PREFIX + literalUserRequestValue.Text;
            purchaseItem["DateRequest"] = DateTime.Now;
            purchaseItem["UserRequest"] = SPContext.Current.Web.CurrentUser;
            purchaseItem["DepartmentRequest"] = literalDepartmentRequestValue.Text;
            purchaseItem["TypeOfApproval"] = hiddenTypeOfApproval.Value;
            purchaseItem["RequestDetail"] = RequestDetails;
            purchaseItem["References"] = ffReferences.Value; //PurchaseHelper.GetMultipleItemSelectionValues(purchaseReferences);
            if(peChief.IsValid && peChief.ResolvedEntities.Count > 0)
                purchaseItem["Chief"] = SPContext.Current.Web.EnsureUser(((PickerEntity)peChief.ResolvedEntities[0]).Key); //ffChief.Value; //
            if (peBuyer.IsValid && peBuyer.ResolvedEntities.Count > 0)
                purchaseItem["Buyer"] = SPContext.Current.Web.EnsureUser(((PickerEntity)peBuyer.ResolvedEntities[0]).Key); //ffBuyer.Value; //
            if (peApprover.IsValid && peApprover.ResolvedEntities.Count > 0)
                purchaseItem["Approver"] = SPContext.Current.Web.EnsureUser(((PickerEntity)peApprover.ResolvedEntities[0]).Key); //ffApprover.Value; //
            if (peAccountant.IsValid && peAccountant.ResolvedEntities.Count > 0)
                purchaseItem["Accountant"] = SPContext.Current.Web.EnsureUser(((PickerEntity)peAccountant.ResolvedEntities[0]).Key); //ffAccountant.Value; //
            if (peConfirmer.IsValid && peConfirmer.ResolvedEntities.Count > 0)
                purchaseItem["Confirmer"] = SPContext.Current.Web.EnsureUser(((PickerEntity)peConfirmer.ResolvedEntities[0]).Key); //ffConfirmer.Value; //

            SaveButton.SaveItem(SPContext.Current, false, "");
        }
开发者ID:chutinhha,项目名称:tvmcorptvs,代码行数:46,代码来源:PurchaseNewForm.ascx.cs


注:本文中的SPFieldLookupValue类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。