コード例 #1
0
 public static CustomList<HousekeepingHierarchy> GetAllHousekeepingHierarchy(Int32 hKID)
 {
     ConnectionManager conManager = new ConnectionManager(ConnectionName.HR);
     CustomList<HousekeepingHierarchy> HousekeepingHierarchyCollection = new CustomList<HousekeepingHierarchy>();
     IDataReader reader = null;
     String sql = "select *from HousekeepingHierarchy where HKID=" + hKID;
     try
     {
         conManager.OpenDataReader(sql, out reader);
         while (reader.Read())
         {
             HousekeepingHierarchy newHousekeepingHierarchy = new HousekeepingHierarchy();
             newHousekeepingHierarchy.SetData(reader);
             HousekeepingHierarchyCollection.Add(newHousekeepingHierarchy);
         }
         return HousekeepingHierarchyCollection;
     }
     catch(Exception ex)
     {
         throw (ex);
     }
     finally
     {
         if (reader != null && !reader.IsClosed)
             reader.Close();
     }
 }
コード例 #2
0
        public static CustomList <HousekeepingHierarchy> GetAllHousekeepingHierarchy(Int32 hKID)
        {
            ConnectionManager conManager = new ConnectionManager(ConnectionName.HR);
            CustomList <HousekeepingHierarchy> HousekeepingHierarchyCollection = new CustomList <HousekeepingHierarchy>();
            IDataReader reader = null;
            String      sql    = "select *from HousekeepingHierarchy where HKID=" + hKID;

            try
            {
                conManager.OpenDataReader(sql, out reader);
                while (reader.Read())
                {
                    HousekeepingHierarchy newHousekeepingHierarchy = new HousekeepingHierarchy();
                    newHousekeepingHierarchy.SetData(reader);
                    HousekeepingHierarchyCollection.Add(newHousekeepingHierarchy);
                }
                return(HousekeepingHierarchyCollection);
            }
            catch (Exception ex)
            {
                throw (ex);
            }
            finally
            {
                if (reader != null && !reader.IsClosed)
                {
                    reader.Close();
                }
            }
        }
コード例 #3
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {

                CustomList<HouseKeepingValue> lstHKEntry = HouseKeepingList;
                if (lstHKEntry.Count == 0)
                {
                    HouseKeepingValue newHouseKeepingEntry = new HouseKeepingValue();
                    lstHKEntry.Add(newHouseKeepingEntry);
                }
                CustomList<HouseKeepingValue> lstParent = ParentList;
                CustomList<HousekeepingHierarchy> lstChild = ChildList;
                CustomList<HousekeepingHierarchy> savedList = new CustomList<HousekeepingHierarchy>();
                foreach (HouseKeepingValue hKV in lstParent)
                {
                    if (hKV.IsSaved)
                    {
                        HousekeepingHierarchy childObj = ChildList.Find(f => f.ParentID == hKV.HKID);
                        if (childObj.IsNotNull())
                        {
                            savedList.Add(childObj);
                        }
                        else
                        {
                            HousekeepingHierarchy obj = new HousekeepingHierarchy();
                            obj.ParentID = hKV.HKID;
                            savedList.Add(obj);
                        }
                    }
                    else
                    {
                        HousekeepingHierarchy childObj = ChildList.Find(f => f.ParentID == hKV.HKID);
                        if (childObj.IsNotNull())
                        {
                            childObj.Delete();
                            savedList.Add(childObj);
                        }
                    }
                }

                SetDataFromControls(ref lstHKEntry);

                if (!CheckUserAuthentication(lstHKEntry)) return;
                manager.SaveHKEntry(ref lstHKEntry, ref savedList);
                this.SuccessMessage = (StaticInfo.SavedSuccessfullyMsg);
            }
            catch (SqlException ex)
            {
                this.ErrorMessage = (ExceptionHelper.getSqlExceptionMessage(ex));
            }
            catch (Exception ex)
            {
                this.ErrorMessage = (ExceptionHelper.getExceptionMessage(ex));
            }
        }