Beispiel #1
0
        public void Init()
        {
            DataTable dt, dtLookUp = new DataTable();

            dt       = dataLookup.GetLookUpItems(-1, LookUpID);
            dtLookUp = dt.DefaultView.ToTable(true, "ClientID", "LookUpId", "LookUPName", "IsCore", "HaveChild", "LookUpType");
            foreach (DataRow dr in dtLookUp.Rows)
            {
                Name       = dr["LookUPName"] == DBNull.Value ? "" : dr["LookUPName"].ToString();
                IsCore     = dr["IsCore"] == DBNull.Value ? false : Convert.ToBoolean(dr["IsCore"]);
                lookupType = dr["LookUpType"] == DBNull.Value ?  LookUpType._None :  (LookUpType)dr["LookUpType"];
                HaveChild  = dr["HaveChild"] == DBNull.Value ? false : Convert.ToBoolean(dr["HaveChild"]);
            }
            foreach (DataRow dr in dt.Rows)
            {
                LookUpItem item = new LookUpItem {
                    ItemID         = dr["LookupInstanceID"] == DBNull.Value ? -1 : Convert.ToInt32(dr["LookupInstanceID"]),
                    LookUpID       = this.LookUpID,
                    Name           = dr["LookUpItemName"] == DBNull.Value ? "" : Convert.ToString(dr["LookUpItemName"]),
                    ShortName      = dr["ShortName"] == DBNull.Value ? "" : Convert.ToString(dr["ShortName"]),
                    Order          = dr["Order"] == DBNull.Value ? -1 : Convert.ToInt32(dr["Order"]),
                    ParentLookUpID = dr["ParentLookUpID"] == DBNull.Value ? -1 : Convert.ToInt32(dr["ParentLookUpID"]),
                };
                LookUpItems.Add(item);
            }
        }
Beispiel #2
0
        public int AddLookUpItem(int lookupID, LookUpItem lookUpItem)
        {
            int inext;

            if (lookUpItem.ItemID > 0)
            {
                if (dataLookup.SaveItem(-1, lookUpItem.ItemID, lookupID, lookUpItem.Name, lookUpItem.ShortName, lookUpItem.Order, lookUpItem.ParentLookUpID))
                {
                    inext = lookUpItem.ItemID;
                }
                else
                {
                    inext = -1;
                };
            }
            else
            {
                inext = dataLookup.SaveItem(-1, lookupID, lookUpItem.Name, lookUpItem.ShortName, lookUpItem.Order, lookUpItem.ParentLookUpID);
            }
            return(inext);
        }