public static SelectList ToSelectList(this IEnumerable list, string selectedItem, string textFieldName, string valueFieldName, string captionName = "", string captionValue = "0")
        {
            SelectList selectList = new SelectList(list, valueFieldName, textFieldName, selectedItem);
            if (!string.IsNullOrEmpty(captionName))
            {
                var lst = selectList.ToList();
                lst.Insert(0, new SelectListItem
                    {
                        Text = captionName,
                        Value = captionValue
                    });
                selectList = new SelectList(lst.ToList(), "Value", "Text");
            }
            if (!string.IsNullOrEmpty(selectedItem) && selectList.SelectedValue == null)
            {

                SelectListItem item = selectList.ToList().FirstOrDefault(x => x.Value.ToLower() == selectedItem.ToLower());
                if (item != null && item.Value.ToLower() == selectedItem.ToLower())
                {
                    item.Selected = true;
                }
            }

            return selectList;
        }
Пример #2
0
 public ActionResult Create()
 {
     User user = GetCurrentUser();
     IEnumerable<User> _Users = GetMyUser();
     SelectList Users = new SelectList(_Users, "USERID", "USERNAME",user.USERID);
     var usersList = Users.ToList();
     ViewBag.UserId = usersList;
     return View(new Order { CustomerStatus= "新签", Idea= "自选", Product= "仅百度", ShopStatus= "未跟进", OrderStatus= "开通" });
 }
Пример #3
0
 public ActionResult DeleteUser(string sms)
 {
     TempData["Msg"] = sms;
     var Roles = from d in objBs.tuserBs.GetAll()
                 select d;
     var ddlUsers = new SelectList(Roles, "UserEmail", "UserEmail");
     ViewBag.ddlUsers = ddlUsers.ToList();
     return View();
 }
Пример #4
0
        public ActionResult datosEquipos(int equipo1)
        {
            var tel = (from e in db.Usuarios
                          where e.equipo_id == equipo1
                          select e).Select(model => model.telefono);

            SelectList datos = new SelectList(tel.ToList(), "telefono");
            return Json(datos.ToList());
        }
Пример #5
0
        public static SelectList GenericSelectList(AssetManagerContext db, Type entityType
            , string property, object selectedvalue)
        {
            var set = db.Set(entityType);
            var query = set.OrderBy(property)
                .Select("new(" + property + ")")
                .Distinct()
                ;

            SelectList selectlist = new SelectList(query, property, property, selectedvalue);
            string selected = selectedvalue.ToStringOrEmpty();

            if (!string.IsNullOrWhiteSpace(selected) && !selectlist.Contains(selectedvalue))
            {
                List<SelectListItem> list = selectlist.ToList();
                list.Add(new SelectListItem { Text = selected, Value = selected });
                list.Sort((x, y) => x.Text.CompareTo(y.Text));
                selectlist = new SelectList(list, "Value", "Text", selectedvalue);
            }
            return selectlist;
        }
Пример #6
0
        public ActionResult Edit(int id)
        {
            ShopModel shopModel = new ShopModel();
            Shop shopBaseInfo = shopModel.GetShop(id);
            UserModel userModel = new UserModel();
            UserInfo userInfo = userModel.GetUserInfo(User.Identity.Name);
            if(userInfo.UserGradeCategory.GradeLevel != 9 && shopBaseInfo.CreateBy != userInfo.Id)
                return Redirect("/");
            List<V_ShopDisheWithCategory> shopDisheWithCategory = shopModel.GetShopDishesWithCategory(id).OrderByDescending(r => r.DisheCategoryOrder).ToList();

            var shopCategories = shopModel.GetShopCategories();

            SelectList shopCategoryList = new SelectList(shopCategories, "Id", "Value");
            List<SelectListItem> shopCategorySelectList = shopCategoryList.ToList();

            for(int i = 0; i < shopCategorySelectList.Count; i++)
                if(shopCategorySelectList[i].Value == shopBaseInfo.CategoryId.ToString())
                {
                    shopCategorySelectList[i].Selected = true;
                    break;
                }
            ViewBag.ShopCategorySelectList = shopCategorySelectList;

            BaseDataModel baseDataModel = new BaseDataModel();
            var cityDistricts = baseDataModel.GetLocationsByParentId(214);
            ViewBag.CityDistrictSelectList = (new SelectList(cityDistricts, "Id", "Value")).ToList();

            List<ServiceArea> shopServiceAraes = shopModel.GetShopServiceAreas(id).ToList()
                .Select(r => new ServiceArea() { Id = r.AreaId, ParentId = r.ParentId, Value = r.ServiceArea, AreaType = r.AreaType }).ToList();
            ViewBag.ServiceAreaSelectList = shopServiceAraes;

            ViewBag.ShopDisheCategoryList = shopDisheWithCategory.GroupBy(r => new { r.CategoryId, r.CategoryValue })
                .Select(r => new SelectListItem() { Value = r.Key.CategoryId.ToString(), Text = r.Key.CategoryValue }).ToList();

            ViewBag.ShopLogo = Url.Content(shopImagePath + shopBaseInfo.Logo);
            ViewBag.OffsetTime = offsetTime;
            return View(new ShopDetailEditorModel(shopBaseInfo, shopDisheWithCategory));
        }
Пример #7
0
        public ActionResult Create(int i = 1)
        {
            ShopModel shopModel = new ShopModel();
            var shopCategories = shopModel.GetShopCategories();

            SelectList shopCategoryList = new SelectList(shopCategories, "Id", "Value");
            List<SelectListItem> shopCategorySelectList = shopCategoryList.ToList();
            ViewBag.ShopCategorySelectList = shopCategorySelectList;

            BaseDataModel baseDataModel = new BaseDataModel();
            var cityDistricts = baseDataModel.GetLocationsByParentId(214);
            ViewBag.CityDistrictSelectList = (new SelectList(cityDistricts, "Id", "Value")).ToList();

            ViewBag.ServiceAreaSelectList = new List<ServiceArea>();
            ViewBag.ShopDisheCategoryList = new List<SelectListItem>();

            ViewBag.ShopLogo = Url.Content("/Contents/ShopImages/shop_default_icon.png");
            ViewBag.OffsetTime = offsetTime;

            return View("Edit");
        }
 public ActionResult CategoryCreate(int? Id, int? mesaj)
 {
     if (Session["user_id"] == null)
         return RedirectToAction("Default", "Home");
     int user_id = Convert.ToInt32(Session["user_id"].ToString());
     var u = db.dt_user.Where(a => a.state == 1 && a.ID == user_id).FirstOrDefault();
     if (u == null)
         return RedirectToAction("Default", "Home");
     ViewBag.userName = u.name + " " + u.surname;
     if (mesaj != null)
         TempData["mesaj"] = mesaj.ToString();
     int companyId;
     if (Id == null)
         companyId = 0;
     else
         companyId = (int)Id;
     List<SelectListItem> list = TumSirket(companyId);
     int companyid;
     if (Id == null)
         companyid = Convert.ToInt32(list.ToList().First().Value);
     else
         companyid = companyId;
     List<SelectListItem> listCategory = new SelectList(db.dt_category.ToList().Where(a => a.state == 1 && a.company_id == companyid), "ID", "name").ToList<SelectListItem>();
     SelectListItem it = new SelectListItem();
     it.Text = "Üst Kategori";
     it.Value = "0";
     listCategory.Add(it);
     ViewBag.company_id = list.ToList();
     ViewBag.upCategoryID = listCategory.ToList();
     return View();
 }
 /*----------Category data update,delete,select
 ---------Write 08.01.2013
 ---------M.Emin Yalçın-----*/
 public List<SelectListItem> TumSirket(int? Id)
 {
     List<SelectListItem> list = new SelectList(db.dt_company.ToList().Where(a => a.active == 1), "ID", "companyname", Id).ToList<SelectListItem>();
     return list.ToList();
 }
 public void SirketGoster(int Id, int parentId)
 {
     List<SelectListItem> list = new SelectList(db.dt_company.ToList().Where(a => a.active == 1 && a.ID != Id && a.parentID != Id), "ID", "companyname", parentId).ToList<SelectListItem>();
     SelectListItem it = new SelectListItem();
     it.Text = "Merkezi Şirket";
     it.Value = "0";
     list.Add(it);
     if (parentId == 0)
         list.Reverse();
     ViewBag.companyId = list.ToList();
 }
Пример #11
0
        public ActionResult Index(string CorporationName,string DepartmentId, string Owner, string TelePhone, string MobilePhone, string StartTime, string EndTime, int? page)
        {
            IEnumerable<Department> _Departments = GetMyDepartmentList();
            SelectList Departments = new SelectList(_Departments, "DEPARTMENTID", "DEPARTMENTNAME", DepartmentId);
            var DepartmentList = Departments.ToList();
            if (_Departments.Count() > 1)
            {
                DepartmentList.Insert(0, new SelectListItem() { Text = "全部", Value = "0" });
            }
            ViewBag.Department = DepartmentList;

            IEnumerable<User> _Users = GetMyUser(DepartmentId);
            SelectList Users = new SelectList(_Users, "USERID", "USERNAME", Owner);
            var usersList = Users.ToList();
            if (_Users.Count() > 1)
            {
                usersList.Insert(0, new SelectListItem() { Text = "全部", Value = "0" });
            }
            ViewBag.Owner = usersList;

            ViewBag.CorporationNameParams = CorporationName;
            ViewBag.DepartmentIdParams = DepartmentId;
            ViewBag.UserIdParams = Owner;
            ViewBag.TelePhoneParams = TelePhone;
            ViewBag.MobilePhoneParams = MobilePhone;

            ViewBag.StartTimeParams = StartTime;
            ViewBag.EndTimeParams = EndTime;

            var orders = from item in db.Order
                         select item;
            if (!string.IsNullOrEmpty(CorporationName))
            {
                orders = orders.Where(x => x.Customer.CorporationName.Contains(CorporationName));
            }
            if (!string.IsNullOrEmpty(TelePhone))
            {
                orders = orders.Where(x => x.Customer.Tel.Contains(TelePhone));
            }
            if (!string.IsNullOrEmpty(MobilePhone))
            {
                orders = orders.Where(x => x.Customer.MobileTel.Contains(MobilePhone));
            }

            long depId = Convert.ToInt64(DepartmentId);
            if (depId > 0)
            {
                orders = orders.Where(c => c.Customer.DepartmentID == depId);
            }
            if (Owner == null)
            {
                long id = GetCurrentUser().USERID;
                orders = orders.Where(x => x.UserId == id);
            }
            if (Owner != null && Owner != "0")
            {
                long userId = Convert.ToInt64(Owner);
                orders = orders.Where(x => x.UserId == userId);
            }
            if (!string.IsNullOrEmpty(StartTime) && !string.IsNullOrEmpty(EndTime))
            {
                DateTime st = DateTime.Parse(DateTime.Parse(StartTime).ToString("yyyy-MM-dd 00:00:00"));
                DateTime et = DateTime.Parse(DateTime.Parse(EndTime).ToString("yyyy-MM-dd 23:59:59"));
                orders = orders.Where(x => x.CreateDate.Value >= st && x.CreateDate <= et);
            }

            orders = orders.OrderByDescending(c => c.CreateDate);
            int pageNumber = (page ?? 1);
            return View(orders.ToPagedList(pageNumber, pageSize));
            //return View(new Person { Name = "Foo", Gender = "F", MaritalStatus = "M", Country = new string[] { "CN", "US","UK" } });
        }
 public List<SelectListItem> GetCategory(int? categoryId, int companyId)
 {
     List<SelectListItem> list = new SelectList(db.dt_category.ToList().Where(a => a.state == 1 && a.company_id == companyId && a.upCategoryID != categoryId && a.ID != categoryId), "ID", "name", categoryId).ToList<SelectListItem>();
     return list.ToList();
 }
Пример #13
0
        public ActionResult Statics(StaticsSearchParams param)
        {
            ViewBag.IsRole = IsRole;
            User Current = GetCurrentUser();
            var statusSelectList = GetStatusList(param.Status).ToList();
            statusSelectList.Insert(0, new SelectListItem() { Text = "全部", Value = "" });
            ViewBag.Status = statusSelectList;

            //IEnumerable<User> _Users = GetMyUser();
            if (string.IsNullOrEmpty(param.Owner))
            {
                param.Owner = Current.USERID.ToString();
            }

            IEnumerable<Department> _Departments = GetMyDepartmentList();
            SelectList Departments = new SelectList(_Departments, "DEPARTMENTID", "DEPARTMENTNAME", param.DepartmentId);
            var DepartmentList = Departments.ToList();
            if (_Departments.Count() > 1)
            {
                DepartmentList.Insert(0, new SelectListItem() { Text = "全部", Value = "0" });
            }
            ViewBag.Department = DepartmentList;

            IEnumerable<User> _Users = GetMyUser(param.DepartmentId);
            SelectList Users = new SelectList(_Users, "USERID", "USERNAME", param.Owner);
            var usersList = Users.ToList();
            if (_Users.Count() > 1)
            {
                usersList.Insert(0, new SelectListItem() { Text = "全部", Value = "0" });
            }
            ViewBag.Owner = usersList;

            //SelectList Users = new SelectList(_Users, "USERID", "USERNAME", param.Owner);
            //var usersList = Users.ToList();
            //if (_Users.Count() > 1)
            //{
            //    usersList.Insert(0, new SelectListItem() { Text = "全部", Value = "0" });
            //}
            //ViewBag.Owner = usersList;

            ViewBag.NextContractStartTimeParams = param.NextContractStartTime;
            ViewBag.NextContractEndTimeParams = param.NextContractEndTime;

            ViewBag.CreateDateStartTimeParams = param.CreateDateStartTime;
            ViewBag.CreateDateEndTimeParams = param.CreateDateEndTime;

            string sql = @"select U.USERNAME, [Status],COUNT(0) Total from [dbo].[Customer] as  c
                                    inner join [dbo].[User] as u
                                    on c.[Owner]=u.USERID
                                    where  [PoolStatus]=1 {0}
                                    group by U.USERNAME, [Status]
                                    order by u.username,[Status],total desc";
            StringBuilder sb = new StringBuilder();
            if (!string.IsNullOrEmpty(param.Status) && param.Status != "0")
            {
                sb.AppendFormat(" and c.[Status]='{0}' ", param.Status);
            }
            if (!string.IsNullOrEmpty(param.Owner) && param.Owner != "0")
            {
                sb.AppendFormat(" and c.[Owner]={0} ", param.Owner);
            }
            if (!string.IsNullOrEmpty(param.NextContractStartTime) && !string.IsNullOrEmpty(param.NextContractEndTime))
            {
                sb.AppendFormat(" and c.[NextContactTime] >='{0} 00:00:00' and c.[NextContactTime]<='{1} 23:59:59' ", Convert.ToDateTime(param.NextContractStartTime).ToString("yyyy-MM-dd"), Convert.ToDateTime(param.NextContractEndTime).ToString("yyyy-MM-dd"));
            }
            if (!string.IsNullOrEmpty(param.CreateDateStartTime) && !string.IsNullOrEmpty(param.CreateDateEndTime))
            {
                sb.AppendFormat(" and c.[CreateDate] >='{0} 00:00:00' and c.[CreateDate]<='{1} 23:59:59' ", Convert.ToDateTime(param.CreateDateStartTime).ToString("yyyy-MM-dd"), Convert.ToDateTime(param.CreateDateEndTime).ToString("yyyy-MM-dd"));
            }
            if (Current.Role.ROLENAME == "销售经理")
            {
                //仅能看部门内数据
                sb.AppendFormat(" and  c.[DepartmentID]={0} ", Current.DEPARTMENTID);
            }
            else if (Current.Role.ROLENAME == "高级销售经理-群总" || Current.Role.ROLENAME == "销售总监" || Current.Role.ROLENAME == "高级管理员")
            {
                long depId = Convert.ToInt64(param.DepartmentId);
                if (depId > 0)
                {
                    sb.AppendFormat(" and  c.[DepartmentID]={0} ", param.DepartmentId);
                }
                else
                {
                    long currentUid = Current.USERID;
                    var authDeps = from auth in db.Authority
                                   where auth.UserId == currentUid
                                   select auth.DepartmentId;
                    if (authDeps.Count() > 0)
                    {
                        StringBuilder sbDepIds = new StringBuilder();
                        foreach (var item in authDeps)
                        {
                            if(sbDepIds.Length==0)
                            {
                                sbDepIds.Append(item);
                            }
                            else
                            {
                                sbDepIds.Append("," + item);
                            }
                        }
                        sb.AppendFormat(" and  c.[DepartmentID] in ({0}) ", sbDepIds.ToString());
                    }
                }
            }
            else
            {
                sb.AppendFormat(" and  c.[DepartmentID]={0} ", Current.DEPARTMENTID);
            }
            sql = string.Format(sql, sb.ToString());

            var RecordItem = db.Database.SqlQuery<Statics>(sql, new object[]{});

            string sumSQL = @"select U.USERNAME,COUNT(0) Total from [dbo].[Customer] as  c
                                    inner join [dbo].[User] as u
                                    on c.[Owner]=u.USERID
                                    where  [PoolStatus]=1 {0}
                                    group by U.USERNAME
                                    order by u.username,total desc";
            sumSQL = string.Format(sumSQL, sb.ToString());
            var RecordTotal = db.Database.SqlQuery<Statics>(sumSQL, new object[] { });

            CRMStatics items = new CRMStatics() { RecordItem = RecordItem, RecordTotal = RecordTotal };
            return View(items);
        }
Пример #14
0
 public ActionResult Register(string sms)
 {
     TempData["Msg"] = sms;
     var Roles = from d in objBs.roleBs.GetAll()
                 select d;
     var ddlRoles = new SelectList(Roles, "RoleId", "RoleDesc");
     ViewBag.ddlRoles = ddlRoles.ToList();
     return View();
 }
Пример #15
0
        public ActionResult Week(string CorporationName, string fromType, string Owner, string status, string NextContractStartTime, string NextContractEndTime, int? page)
        {
            InitPageSize();
            var sourceFromList = GetSourceFrom(fromType).ToList();
            var statusSelectList = GetStatusList(status).ToList();
            sourceFromList.Insert(0, new SelectListItem() { Text = "全部", Value = "" });
            statusSelectList.Insert(0, new SelectListItem() { Text = "全部", Value = "" });
            ViewBag.SourceFrom = sourceFromList;
            ViewBag.Status = statusSelectList;

            IEnumerable<User> _Users = GetMyUser();
            SelectList Users = new SelectList(_Users, "USERID", "USERNAME", Owner);
            var usersList = Users.ToList();
            if (_Users.Count() > 1)
            {
                usersList.Insert(0, new SelectListItem() { Text = "全部", Value = "0" });
            }
            ViewBag.Owner = usersList;

            ViewBag.CorporationNameParams = CorporationName;
            ViewBag.UserIdParams = Owner;
            ViewBag.fromTypeParams = fromType;
            ViewBag.StatusParams = status;
            ViewBag.NextContractStartTimeParams = NextContractStartTime;
            ViewBag.NextContractEndTimeParams = NextContractEndTime;

            DateTime beginDate;
            DateTime endDate;
            DateTime nowDate = DateTime.Now;
            beginDate = nowDate.Date.AddDays(1 - Convert.ToInt32(nowDate.DayOfWeek.ToString("d")));
            endDate = beginDate.Date.AddDays(7).AddSeconds(-1);

            var customers = from item in db.Customer
                            where item.PoolStatus.Value == privateTag && item.CreateDate.Value >= beginDate && item.CreateDate.Value <= endDate
                            select item;

            if (!string.IsNullOrEmpty(CorporationName))
            {
                customers = customers.Where(x => x.CorporationName.Contains(CorporationName));
            }
            if (Owner == null)
            {
                long id = GetCurrentUser().USERID;
                customers = customers.Where(x => x.Owner == id);
            }
            if (Owner != null && Owner != "0")
            {
                long userId = Convert.ToInt64(Owner);
                customers = customers.Where(x => x.Owner == userId);
            }
            if (!string.IsNullOrEmpty(fromType))
            {
                customers = customers.Where(x => x.SourseFrom == fromType);
            }
            if (!string.IsNullOrEmpty(status))
            {
                customers = customers.Where(x => x.Status == status);
            }
            if (!string.IsNullOrEmpty(NextContractStartTime) && !string.IsNullOrEmpty(NextContractEndTime))
            {
                DateTime st = DateTime.Parse(DateTime.Parse(NextContractStartTime).ToString("yyyy-MM-dd 00:00:00"));
                DateTime et = DateTime.Parse(DateTime.Parse(NextContractEndTime).ToString("yyyy-MM-dd 23:59:59"));
                customers = customers.Where(x => x.NextContactTime.Value >= st && x.NextContactTime <= et);
            }

            //过滤角色数据
            customers = Filter(customers);

            customers = customers.OrderByDescending(c => c.CreateDate);
            int pageNumber = (page ?? 1);
            return View(customers.ToPagedList(pageNumber, pageSize));
        }
Пример #16
0
        public ActionResult Index(string CorporationName,string fromType,string DepartmentId,string Owner,string status,string NextContractStartTime,string NextContractEndTime,string TelePhone,string MobilePhone,string UpdateStartTime,string UpdateEndTime,int? page)
        {
            InitPageSize();

            ViewBag.IsRole = IsRole;

            var sourceFromList = GetSourceFrom(fromType).ToList();
            var statusSelectList = GetStatusList(status).ToList();
            sourceFromList.Insert(0, new SelectListItem() { Text = "全部", Value = "" });
            statusSelectList.Insert(0, new SelectListItem() { Text = "全部", Value = "" });
            ViewBag.SourceFrom = sourceFromList;
            ViewBag.Status = statusSelectList;

            IEnumerable<Department> _Departments = GetMyDepartmentList();
            SelectList Departments = new SelectList(_Departments, "DEPARTMENTID", "DEPARTMENTNAME", DepartmentId);
            var DepartmentList = Departments.ToList();
            if (_Departments.Count() > 1)
            {
                DepartmentList.Insert(0, new SelectListItem() { Text = "全部", Value = "0" });
            }
            ViewBag.Department = DepartmentList;

            IEnumerable<User> _Users=GetMyUser(DepartmentId);
            SelectList Users = new SelectList(_Users, "USERID", "USERNAME", Owner);
            var usersList = Users.ToList();
            if (_Users.Count() > 1)
            {
                usersList.Insert(0, new SelectListItem() { Text = "全部", Value = "0" });
            }
            ViewBag.Owner = usersList;

            ViewBag.CorporationNameParams = CorporationName;
            ViewBag.DepartmentIdParams = DepartmentId;
            ViewBag.UserIdParams = Owner;
            ViewBag.fromTypeParams = fromType;
            ViewBag.StatusParams = status;
            ViewBag.NextContractStartTimeParams = NextContractStartTime;
            ViewBag.NextContractEndTimeParams = NextContractEndTime;
            ViewBag.TelePhoneParams = TelePhone;
            ViewBag.MobilePhoneParams = MobilePhone;

            ViewBag.UpdateStartTimeParams = UpdateStartTime;
            ViewBag.UpdateEndTimeParams = UpdateEndTime;

            var customers = from item in db.Customer
                        where item.PoolStatus.Value==privateTag
                        select item;
            if (!string.IsNullOrEmpty(CorporationName))
            {
                customers = customers.Where(x => x.CorporationName.Contains(CorporationName));
            }
            if (!string.IsNullOrEmpty(TelePhone))
            {
                customers = customers.Where(x => x.Tel.Contains(TelePhone));
            }
            if (!string.IsNullOrEmpty(MobilePhone))
            {
                customers = customers.Where(x => x.MobileTel.Contains(MobilePhone));
            }

            long depId = Convert.ToInt64(DepartmentId);
            if (depId > 0)
            {
                customers = customers.Where(c => c.DepartmentID == depId);
            }
            if (Owner == null)
            {
                long id=GetCurrentUser().USERID;
                customers = customers.Where(x => x.Owner == id);
            }
            if (Owner != null && Owner != "0")
            {
                long userId = Convert.ToInt64(Owner);
                customers = customers.Where(x => x.Owner == userId);
            }
            if (!string.IsNullOrEmpty(fromType))
            {
                customers = customers.Where(x => x.SourseFrom == fromType);
            }
            if (!string.IsNullOrEmpty(status))
            {
                customers = customers.Where(x => x.Status == status);
            }
            if (!string.IsNullOrEmpty(NextContractStartTime) && !string.IsNullOrEmpty(NextContractEndTime))
            {
                DateTime st = DateTime.Parse(DateTime.Parse(NextContractStartTime).ToString("yyyy-MM-dd 00:00:00"));
                DateTime et = DateTime.Parse(DateTime.Parse(NextContractEndTime).ToString("yyyy-MM-dd 23:59:59"));
                customers = customers.Where(x => x.NextContactTime.Value >= st && x.NextContactTime <= et);
            }
            if (!string.IsNullOrEmpty(UpdateStartTime) && !string.IsNullOrEmpty(UpdateEndTime))
            {
                DateTime st = DateTime.Parse(DateTime.Parse(UpdateStartTime).ToString("yyyy-MM-dd 00:00:00"));
                DateTime et = DateTime.Parse(DateTime.Parse(UpdateEndTime).ToString("yyyy-MM-dd 23:59:59"));
                customers = customers.Where(x => x.LastModify.Value >= st && x.LastModify <= et);
            }

            //过滤角色数据
            customers =Filter(customers);

            customers = customers.OrderByDescending(c => c.CreateDate);
            int pageNumber = (page ?? 1);
            return View(customers.ToPagedList(pageNumber, pageSize));
        }
Пример #17
0
        public ActionResult BatchOperation(string CustomerIds)
        {
            ViewBag.CustomerIds = CustomerIds;

            User currentUser = GetCurrentUser();

            var statusSelectList = GetStatusList(string.Empty).ToList();
            statusSelectList.Insert(0, new SelectListItem() { Text = "", Value = "" });
            ViewBag.Status = statusSelectList;

            SelectList Users = new SelectList(GetMyUser(), "USERID", "USERNAME", currentUser.USERID);
            var usersList = Users.ToList();
            usersList.Insert(0, new SelectListItem() { Text = "", Value = "0" });

            ViewBag.Owner = usersList;
            ViewBag.NextContractTimeParams = null;
            return View();
        }
 public ActionResult CategoryCreate()
 {
     var user = db.dt_user.FirstOrDefault();
     if (Session["personel_id"] == null)
         return RedirectToAction("Default", "Home");
     else
     {
         int personel_id = Convert.ToInt32(Session["personel_id"]);
         user = db.dt_user.Where(a => a.state == 1 && a.ID == personel_id).FirstOrDefault();
         if (user == null)
             return RedirectToAction("Default", "Home");
         ViewBag.userName = user.name + " " + user.surname;
     }
     List<SelectListItem> listCategory = new SelectList(db.dt_category.ToList().Where(a => a.state == 1 && a.company_id == user.company_id), "ID", "name").ToList<SelectListItem>();
     SelectListItem it = new SelectListItem();
     it.Text = "Üst Kategori";
     it.Value = "0";
     listCategory.Add(it);
     ViewBag.upCategoryID = listCategory.ToList();
     return View();
 }
        /*----------Hata data update,delete,select
        ---------Write 10.01.2013
        ---------M.Emin Yalçın-----*/
        public ActionResult ErrorShow(int? companyId, int? userId, int? mesaj)
        {
            if (Session["user_id"] == null)
                return RedirectToAction("Default", "Home");
            int user_id1 = Convert.ToInt32(Session["user_id"].ToString());
            var u = db.dt_user.Where(a => a.state == 1 && a.ID == user_id1).FirstOrDefault();
            if (u == null)
                return RedirectToAction("Default", "Home");
            ViewBag.userName = u.name + " " + u.surname;
            if (mesaj != null)
                TempData["mesaj"] = mesaj.ToString();
            int company_id = 0; int user_id = 0;
            List<SelectListItem> listCompany;
            List<SelectListItem> listUser;
            if (companyId == null)
            {
                listCompany = new SelectList(db.dt_company.ToList().Where(a => a.active == 1), "ID", "companyname").ToList<SelectListItem>();
                if (userId == null)
                {
                    listUser = new SelectList(db.dt_user.ToList().Where(a => a.state == 1 && a.company_id == Convert.ToInt32(listCompany.ToList().First().Value) && a.unvan_id != 1), "ID", "name").ToList<SelectListItem>();
                    company_id = Convert.ToInt32(listCompany.ToList().First().Value);
                    user_id = Convert.ToInt32(listUser.ToList().First().Value);
                }
                else
                {
                    user_id = (int)userId;
                    listUser = new SelectList(db.dt_user.ToList().Where(a => a.state == 1 && a.unvan_id != 1 && a.company_id == company_id), "ID", "name", userId).ToList<SelectListItem>();
                }
            }
            else
            {
                company_id = (int)companyId;
                listCompany = new SelectList(db.dt_company.ToList().Where(a => a.active == 1), "ID", "companyname", companyId).ToList<SelectListItem>();
                if (userId == null)
                {
                    listUser = new SelectList(db.dt_user.ToList().Where(a => a.state == 1 && a.company_id == Convert.ToInt32(company_id) && a.unvan_id != 1), "ID", "name").ToList<SelectListItem>();
                    user_id = Convert.ToInt32(listUser.ToList().First().Value);
                }
                else
                {
                    user_id = (int)userId;
                    listUser = new SelectList(db.dt_user.ToList().Where(a => a.state == 1 && a.unvan_id != 1 && a.company_id == company_id), "ID", "name", userId).ToList<SelectListItem>();
                }
            }

            var error = from er in db.dt_error
                        join cat in db.dt_category on er.category_id equals cat.ID
                        join us in db.dt_user on er.user_id equals us.ID
                        join com in db.dt_company on us.company_id equals com.ID
                        where er.user_id == user_id && us.company_id == company_id && er.state == 1
                        select new error
                        {
                            ID = er.ID,
                            name = er.errorName,
                            errorKod = er.errorKod,
                            keyWords = er.errorKeys,
                            content = er.errorContent,
                            user = us.name,
                            category = cat.name,
                            company = com.companyname,
                            date = er.date
                        };
            ViewBag.companyId = listCompany.ToList();
            ViewBag.userId = listUser.ToList();
            return View(error.ToList());
        }
Пример #20
0
 public static ICollection<SelectListItem> AccountClasses()
 {
     var EntityState = new SelectList(Enum.GetValues(typeof(AccountClasses)).Cast<AccountClasses>().Select(v => new SelectListItem
     {
         Text = v.ToString(),
         Value = ((int)v).ToString()
     }).ToList(), "Value", "Text");
     return EntityState.ToList();
 }
        /*----------Personel data update,delete,select
        ---------Write 09.01.2013
        ---------M.Emin Yalçın-----*/
        public ActionResult PersonelShow(int? Id, int? mesaj)
        {
            if (Session["user_id"] == null)
                return RedirectToAction("Default", "Home");
            int user_id = Convert.ToInt32(Session["user_id"].ToString());
            var u = db.dt_user.Where(a => a.state == 1 && a.ID == user_id).FirstOrDefault();
            if (u == null)
                return RedirectToAction("Default", "Home");
            ViewBag.userName = u.name + " " + u.surname;
            if (mesaj != null)
                TempData["mesaj"] = mesaj.ToString();
            int companyid;
            List<SelectListItem> listCompany;
            if (Id == null)
            {
                listCompany = new SelectList(db.dt_company.ToList().Where(a => a.active == 1), "ID", "companyname").ToList<SelectListItem>();
                companyid = Convert.ToInt32(listCompany.ToList().First().Value);
            }
            else
            {
                listCompany = new SelectList(db.dt_company.ToList().Where(a => a.active == 1), "ID", "companyname", Id).ToList<SelectListItem>();
                companyid = Convert.ToInt32(Id);
            }
            ViewBag.companyId = listCompany;
            var personel = from per in db.dt_user
                           join com in db.dt_company on per.company_id equals com.ID
                           join tit in db.lu_unvan on per.unvan_id equals tit.ID
                           where per.company_id == companyid && per.state == 1 && per.unvan_id != 1
                           select new personel
                           {
                               Id = per.ID,
                               name = per.name,
                               surname = per.surname,
                               Company = com.companyname,
                               state = per.state,
                               title = tit.name,
                               nationality = per.nationality,
                               password = per.password,
                               userName = per.username,
                               adress = per.adress
                           };

            return View(personel.ToList());
        }
 private SelectList AddFirstItem(SelectList list)
 {
     List<SelectListItem> _list = list.ToList();
     _list.Insert(0, new SelectListItem() { Value = "-2", Text = "All" });
     return new SelectList((IEnumerable<SelectListItem>)_list, "Value", "Text");
 }
 public void SirketGoster()
 {
     List<SelectListItem> list = new SelectList(db.dt_company.ToList().Where(a => a.active == 1), "ID", "companyname").ToList<SelectListItem>();
     SelectListItem it = new SelectListItem();
     it.Text = "Merkezi Şirket";
     it.Value = "0";
     list.Add(it);
     ViewBag.companyId = list.ToList();
 }