Esempio n. 1
0
        /// <summary>
        /// Sets the Well Book Owners from Asset Team Mapping list
        /// </summary>
        /// <param name="lstWellbookOwners"></param>
        /// <param name="strSourcelistName"></param>
        /// <param name="strAddedListvalues"></param>
        /// <param name="blnEdit"></param>
        /// <param name="strSeletectedID"></param>
        protected void SetWellBookOwners(ListBox lstWellbookOwners, string strSourcelistName, string
            strAddedListvalues, bool blnEdit, string strSeletectedID)
        {
            DataTable objListData = null;
            DataTable objExistingEntries = null;
            DataRow objListRow;
            string strCurrentUsername = string.Empty;
            string strQuerystring = string.Empty;
            ListItem lstItem;
            try
            {
                strCurrentUsername = GetUserName();
                objWellBookBLL = new WellBookBLL();
                strQuerystring = @"<Where>
                 <Contains>
                    <FieldRef Name='Privileges' />
                    <Value Type='Text'>WO</Value>
                 </Contains>
                 </Where>";
                objListData = objWellBookBLL.GetListDetails(strParentSiteURL, strSourcelistName,
                    strQuerystring);
                if (objListData != null && objListData.Rows.Count > 0)
                {
                    /// Loop through the values in Asset team mapping based
                    lstWellbookOwners.Items.Clear();

                    for (int intRowIndex = 0; intRowIndex < objListData.Rows.Count; intRowIndex++)
                    {
                        objListRow = objListData.Rows[intRowIndex];
                        lstItem = new ListItem();
                        lstItem.Text = objListRow[DWBTITLECOLUMN].ToString();
                        lstItem.Value = objListRow[DWBTITLECOLUMN].ToString();
                        lstWellbookOwners.Items.Add(lstItem);

                    }

                    if (blnEdit)
                    {
                        strQuerystring = @"<Where><Eq><FieldRef Name='ID' /><Value Type='Counter'>" +
                            strSeletectedID + "</Value></Eq></Where>";

                        objExistingEntries = objWellBookBLL.GetListDetails(strParentSiteURL, strAddedListvalues,
                            strQuerystring);
                        string strexistingWellbookOnwer = string.Empty;
                        if (objExistingEntries != null && objExistingEntries.Rows.Count > 0)
                        {
                            for (int intRowIndex = 0; intRowIndex < objExistingEntries.Rows.Count; intRowIndex++)
                            {
                                objListRow = objExistingEntries.Rows[intRowIndex];
                                strexistingWellbookOnwer = objListRow["Well_Book_Owner"].ToString();
                            }
                            foreach (ListItem objListItem in lstWellbookOwners.Items)
                            {
                                if (strexistingWellbookOnwer.Contains(objListItem.Value))
                                {
                                    objListItem.Selected = true;
                                }
                            }
                        }
                    }
                }
            }
            catch
            { throw; }
            finally
            {
                if (objListData != null)
                    objListData.Dispose();
                if (objExistingEntries != null)
                    objExistingEntries.Dispose();
            }
        }