Beispiel #1
0
        public List <SelectListItem> GetAllEmployeeNames()
        {
            List <SelectListItem> EmployeeNameList = new List <SelectListItem>();

            try
            {
                string empid = Session["UserID"].ToString();
                //string empName = String.Format("{0} {1}", Session["FirstName"].ToString(), Session["LastName"].ToString());
                MTSHRDataLayer.EmployeeLeave EmployeeNamedata = new MTSHRDataLayer.EmployeeLeave();
                var EmployeeNames = EmployeeNamedata.GetAllEmployeeNames();
                EmployeeNameList.Add(new SelectListItem()
                {
                    Value = "", Text = "----Select Employee----"
                });
                for (int i = 0; i < EmployeeNames.Tables[0].Rows.Count; i++)
                {
                    string ID = EmployeeNames.Tables[0].Rows[i]["id"].ToString();
                    EmployeeNameList.Add(new SelectListItem()
                    {
                        Text = EmployeeNames.Tables[0].Rows[i]["EmployeeName"].ToString(), Value = ID
                    });
                }
                //EmployeeNameList.RemoveAt(EmployeeNameList.IndexOf(new SelectListItem() { Value = empid, Text = empName }));
            }
            catch (Exception exec)
            {
                BaseExceptionHandler.HandleException(ref exec);
            }
            return(EmployeeNameList);
        }
        public List <SelectListItem> GetAllEmployeeNames()
        {
            MTSHRDataLayer.EmployeeLeave EmployeeNamedata = new MTSHRDataLayer.EmployeeLeave();
            var EmployeeNames = EmployeeNamedata.GetAllEmployeeNames();
            List <SelectListItem> EmployeeNameList = new List <SelectListItem>();

            //EmployeeNameList.Insert(0, new SelectListItem() { Value = "0", Text = "----Select Employee NameA----" });
            for (int i = 0; i < EmployeeNames.Tables[0].Rows.Count; i++)
            {
                EmployeeNameList.Add(new SelectListItem()
                {
                    Text = EmployeeNames.Tables[0].Rows[i]["EmployeeName"].ToString(), Value = EmployeeNames.Tables[0].Rows[i]["id"].ToString()
                });
            }

            return(EmployeeNameList.OrderBy(o => o.Text).ToList());
            // EmployeeNameList.Insert(0, new SelectListItem() { Value = "0", Text = "----Select ALL----" });
            // return EmployeeNameList;
        }