Exemple #1
0
        public static CustomList <AbsentEntry> GetAllAbsentEntry()
        {
            ConnectionManager        conManager            = new ConnectionManager(ConnectionName.HR);
            CustomList <AbsentEntry> AbsentEntryCollection = new CustomList <AbsentEntry>();
            IDataReader  reader = null;
            const String sql    = "select *from AbsentEntry";

            try
            {
                conManager.OpenDataReader(sql, out reader);
                while (reader.Read())
                {
                    AbsentEntry newAbsentEntry = new AbsentEntry();
                    newAbsentEntry.SetData(reader);
                    AbsentEntryCollection.Add(newAbsentEntry);
                }
                AbsentEntryCollection.InsertSpName = "spInsertAbsentEntry";
                AbsentEntryCollection.UpdateSpName = "spUpdateAbsentEntry";
                AbsentEntryCollection.DeleteSpName = "spDeleteAbsentEntry";
                return(AbsentEntryCollection);
            }
            catch (Exception ex)
            {
                throw (ex);
            }
            finally
            {
                if (reader != null && !reader.IsClosed)
                {
                    reader.Close();
                }
            }
        }
 protected void btnDelete_Click(object sender, EventArgs e)
 {
     try
     {
         CustomList <HRM_Emp> empList                   = (CustomList <HRM_Emp>)HttpContext.Current.Session["View_EmpList"];
         CustomList <HRM_Emp> checkedEmpList            = empList.FindAll(f => f.IsChecked);
         CustomList <ASL.Hr.DAO.AbsentEntry> AbsentList = new CustomList <ASL.Hr.DAO.AbsentEntry>();
         TimeSpan ts   = (txtToDate.Text.ToDateTime(ASL.STATIC.StaticInfo.GridDateFormat) - txtFromDate.Text.ToDateTime(ASL.STATIC.StaticInfo.GridDateFormat));
         int      days = ts.Days + 1;
         for (int i = 0; i < days; i++)
         {
             foreach (HRM_Emp emp in checkedEmpList)
             {
                 ASL.Hr.DAO.AbsentEntry newObj = new ASL.Hr.DAO.AbsentEntry();
                 newObj.EmpID      = emp.EmpKey;
                 newObj.AbsentDate = txtFromDate.Text.ToDateTime().AddDays(i);
                 newObj.Delete();
                 AbsentList.Add(newObj);
             }
         }
         if (AbsentList.Count != 0)
         {
             //if (!CheckUserAuthentication(AbsentList)) return;
             _manager.SaveAbsentList(ref AbsentList);
             ((PageBase)this.Page).SuccessMessage = (StaticInfo.DeletedSuccessfullyMsg);
         }
     }
     catch (SqlException ex)
     {
         ((PageBase)this.Page).ErrorMessage = (ExceptionHelper.getSqlExceptionMessage(ex));
     }
     catch (Exception ex)
     {
         ((PageBase)this.Page).ErrorMessage = (ExceptionHelper.getExceptionMessage(ex));
     }
 }