private void bindEmployee()
        {
            EmployeeParas paras = new EmployeeParas();

            //paras.storeNum = ddlStoreNum.SelectedItem.Value;
            paras.modelId = modelInfo.getModelId(modelInfo.ModelId.reservation);
            PageRecord page = null;

            this.rptEmp.DataSource = eh.LoadEmployeeByParasForPick(paras, ref page);
            this.rptEmp.DataBind();
        }
Exemplo n.º 2
0
        /// <summary>
        /// 查询全部数据
        /// </summary>
        /// <param name="tablename">表名</param>
        /// <param name="where">条件 包含分组 和排序  例子 条件开头为#是排序(#+ asc #- desc) 开头为##是分组 </param>
        /// <param name="columns">查询字段</param>
        /// <param name="having">分组后条件</param>
        /// <param name="tab">多表联查时 字段较多时 将各表字段用别名区分开  例子 键:demo.test(数据库.表)  值:tt(数据表别名)</param>
        /// <returns></returns>
        private PageRecord GetPageData(string tablename, Record where, PageRecord pageRec, List <string> columns, Record having = null, List <Record> tab = null)
        {
            string column = "";

            if (!columns.IsBlank())
            {
                column = getcolumns(columns);
            }
            else if (!tab.IsBlank())
            {
                column = getcolumns(tab);
            }
            var con = Connection();

            column = column.IsBlank() ? "*" : column;
            try
            {
                if (con.code != 200)
                {
                    return(pageRec);
                }
                string cons = where?.getWhere ?? "";
                string havs = having?.getHaving ?? "";
                string sql1 = "select count(1) as num from (" + string.Format(EnumHelper.GetEnumDescription(Operation.Select), column, tablename, cons, havs) + $" limit {(pageRec.page - 1) * pageRec.limit},{pageRec.limit}";
                string sql  = string.Format(EnumHelper.GetEnumDescription(Operation.Select), column, tablename, cons, havs) + ")xhc";
                var    bvo  = Query(sql1);
                if (!(bvo.IsBlank() || bvo[0].GetInt("num") == 0))
                {
                    pageRec.records = Query(sql);
                }
                return(pageRec);
            }
            catch
            {
                return(pageRec);
            }
            finally
            {
            }
        }
Exemplo n.º 3
0
        // take manager id as argument
        public PageRecord <UserView> GetManagerEmployees(int id, PagingModel paging)
        {
            var userInfo = from u in context.Users
                           where id == u.ManagerID
                           select new UserView()
            {
                UserID   = u.UserID,
                Name     = u.Name,
                LastName = u.LastName,
                JobTitle = u.JobTitle,
                Email    = u.Email,
                Mobile   = u.Mobile,
            };

            var user = new PageRecord <UserView>
            {
                Data        = userInfo.ToList(),
                TotalRecord = userInfo.Count(),
            };

            if (!string.IsNullOrEmpty(paging.SearchValue))
            {
                user.Data = user.Data
                            .Where(u => u.Name.ToLower().Contains(paging.SearchValue.ToLower()) ||
                                   u.LastName.ToLower().Contains(paging.SearchValue.ToLower()) ||
                                   u.JobTitle.ToLower().Contains(paging.SearchValue.ToLower()) ||
                                   u.Email.ToLower().Contains(paging.SearchValue.ToLower()) ||
                                   u.Mobile.ToLower().Contains(paging.SearchValue.ToLower())).ToList();
            }
            user.TotalFilteredRecord = user.Data.Count();
            //  sorting
            //  user.Data = user.Data.OrderBy(paging.SortCol + " " + paging.SortDir).ToList;
            user.Data = user.Data.OrderBy(u => u.UserID).ToList();
            // paging
            user.Data = user.Data.Skip(paging.DisplayStart).Take(paging.DisplayLength).ToList();
            return(user);
        }
        // Display all valacation for managaer's employees
        public PageRecord <VacationView> DisplayVacations(int id, int role, PagingModel paging)
        {
            IQueryable <VacationView> innerJoinQuery = null;

            if (role == 0)
            {
                innerJoinQuery = from v in context.Vacations
                                 join u in context.Users on v.EmployeeID equals u.UserID
                                 where id == u.ManagerID && v.Status != Statuses.Draft
                                 select new VacationView
                {
                    EmployeeID      = u.UserID,
                    Name            = u.Name,
                    LastName        = u.LastName,
                    VacationID      = v.VacationID,
                    Description     = v.Description,
                    Attatchment     = v.Attatchment,
                    StartDate       = v.StartDate,
                    EndDate         = v.EndDate,
                    Status          = v.Status,
                    Type            = v.Type,
                    RejectionReason = v.RejectionReason
                };
            }
            else if (role == 1)
            {
                innerJoinQuery = from v in context.Vacations
                                 join u in context.Users on v.EmployeeID equals u.UserID
                                 where id == v.EmployeeID
                                 select new VacationView
                {
                    EmployeeID      = u.UserID,
                    Name            = u.Name,
                    LastName        = u.LastName,
                    VacationID      = v.VacationID,
                    Description     = v.Description,
                    Attatchment     = v.Attatchment,
                    StartDate       = v.StartDate,
                    EndDate         = v.EndDate,
                    Status          = v.Status,
                    Type            = v.Type,
                    RejectionReason = v.RejectionReason
                };
            }
            var vacation = new PageRecord <VacationView>
            {
                Data        = innerJoinQuery.ToList(),
                TotalRecord = innerJoinQuery.Count(),
            };

            if (!string.IsNullOrEmpty(paging.SearchValue))
            {
                vacation.Data = vacation.Data
                                .Where(u => u.Name.ToLower().Contains(paging.SearchValue.ToLower()) ||
                                       u.VacationID.ToString().Contains(paging.SearchValue.ToLower()) ||
                                       u.EmployeeID.ToString().Contains(paging.SearchValue.ToLower()) ||
                                       u.LastName.ToLower().Contains(paging.SearchValue.ToLower()) ||
                                       u.StartDate.ToString().Contains(paging.SearchValue.ToLower()) ||
                                       u.EndDate.ToString().Contains(paging.SearchValue.ToLower()) ||
                                       u.Status.ToString().Contains(paging.SearchValue.ToLower()) ||
                                       u.Type.ToString().Contains(paging.SearchValue.ToLower())).ToList();
            }
            vacation.TotalFilteredRecord = vacation.Data.Count();
            //  sorting
            //  userInfo = vacation.OrderBy(paging.SortCol + " " + paging.SortDir);
            vacation.Data = vacation.Data.OrderBy(u => u.VacationID).ToList();
            // paging
            vacation.Data = vacation.Data.Skip(paging.DisplayStart).Take(paging.DisplayLength).ToList();
            return(vacation);
        }
Exemplo n.º 5
0
        private void UpdateTabs()
        {
            if (!IsContentVisible || m_suspendedDashboard)
            {
                return;
            }
            //tabControl1.TabPages.Clear();
            try
            {
                m_updatingTabs      = true;
                tabControl1.Enabled = false;

                var widgets = TreeNodeExtension.GetAllWidgets(m_selectedObject);

                int pgindex = 0;
                foreach (IWidget widget in widgets)
                {
                    TabPage pg = FindPage(widget, pgindex);
                    if (pg != null)
                    {
                        if (tabControl1.TabPages.IndexOf(pg) != pgindex)
                        {
                            int origindex = tabControl1.TabPages.IndexOf(pg);
                            tabControl1.TabPages.RemoveAt(origindex);
                            tabControl1.TabPages.Insert(pgindex, pg);
                            List <PageRecord> tmp  = new List <PageRecord>(m_loadedPages);
                            PageRecord        orig = tmp[origindex];
                            tmp[pgindex].Dispose();
                            tmp.RemoveAt(origindex);
                            tmp.Insert(pgindex, orig);
                            m_loadedPages = tmp.ToArray();
                        }
                        m_loadedPages[pgindex].isloaded = false;
                        m_loadedPages[pgindex].ReplaceWidget(widget);
                        pg.Text       = Texts.Get(widget.PageTitle);
                        pg.ImageIndex = m_imgCache.GetImageIndex(widget.Image);
                    }
                    else
                    {
                        List <PageRecord> tmp    = new List <PageRecord>(m_loadedPages);
                        PageRecord        newrec = new PageRecord();
                        newrec.widget = widget;
                        tabControl1.TabPages.Insert(pgindex, Texts.Get(widget.PageTitle));
                        tabControl1.TabPages[pgindex].ImageIndex = m_imgCache.GetImageIndex(widget.Image);
                        tmp.Insert(pgindex, newrec);
                        m_loadedPages = tmp.ToArray();
                    }
                    pgindex++;
                }
                try
                {
                    while (tabControl1.TabPages.Count > widgets.Count)
                    {
                        tabControl1.SelectedIndex = 0;
                        tabControl1.TabPages.RemoveAt(widgets.Count);
                    }
                    List <PageRecord> tmp = new List <PageRecord>(m_loadedPages);
                    for (int i = widgets.Count; i < tmp.Count; i++)
                    {
                        tmp[i].Dispose();
                    }
                    tmp.RemoveRange(widgets.Count, tmp.Count - widgets.Count);
                    m_loadedPages = tmp.ToArray();
                }
                catch (Exception)
                {
                    tabControl1.TabPages.Clear();
                    foreach (PageRecord pgrec in m_loadedPages)
                    {
                        pgrec.Dispose();
                    }
                    m_loadedPages = new PageRecord[] { };
                    UpdateTabs();
                }
            }
            finally
            {
                m_updatingTabs      = false;
                tabControl1.Enabled = true;
            }
            LoadCurPage();
        }