/// <summary> /// 项目下拉框获取数据 /// </summary> /// <param name="model"></param> public void GetProjects(UI001ViewModel model) { // 从数据库获取数据 using (EntityDao db = new EntityDao()) { model.ProjectItems = new ObservableCollection <TB_Project>(db.FindAll <TB_Project>()); } // 从Xml文件中获取上次选择项目 Dictionary <string, string> dic = ComUtility.GetXmValues(model.Page.ToString()); string project = dic["project"]; if (string.IsNullOrWhiteSpace(project)) { return; } // 默认选择上次选择项目 foreach (TB_Project item in model.ProjectItems) { if (item.CD == project) { model.SelectedProjectItem = item; GetDataItems(model); return; } } }
/// <summary> /// /// </summary> /// <param name="model"></param> public void GetUsers(UI002ViewModel model) { using (EntityDao db = new EntityDao()) { model.Items = new ObservableCollection <UI002Item>(db.FindAll <UI002Item>("select Cd,Name,GroupId as 'Group',IP,'0' as 'Delete' from tb_user")); } }
public DataSourceResult GetDataSource( [ModelBinder(typeof(WebApiDataSourceRequestModelBinder))] DataSourceRequest request) { var ordenes = EntityDao.FindAll().Where(o => !o.Programado); return(ordenes.ToDataSourceResult(request, e => Mapper.EntityToModel(e, new OrderModel()))); }
public DataSourceResult GetDataSource( [ModelBinder(typeof(WebApiDataSourceRequestModelBinder))] DataSourceRequest request) { var transaction = SessionHelper.Current.BeginTransaction(); try { var tickets = EntityDao.FindAll(); if (Usuario.Empleado == null || Usuario.Empleado.TipoEmpleado == null) { return(GetResult(tickets, request)); } switch (Usuario.Empleado.TipoEmpleado.Codigo) { case "SR": tickets = tickets.Where(t => t.SupervisorRuta.Id == Usuario.Empleado.Id); break; case "JF": tickets = tickets.Where(t => t.SupervisorVenta.Id == Usuario.Empleado.Id); break; case "V": tickets = tickets.Where(t => t.Vendedor.Id == Usuario.Empleado.Id); break; } return(GetResult(tickets, request)); } finally { transaction.Rollback(); } }
public IHttpActionResult GetCantidadPorEstado(int distritoId, int baseId) { var w = EntityDao.FindAll(); if (distritoId != -1) { w = w.Where(t => t.Empresa.Id == distritoId); } if (baseId != -1) { w = w.Where(t => t.Linea.Id == baseId); } w = w.Where(t => t.FechaHoraEstado >= DateTime.UtcNow.AddHours(-24)); var list = w.ToList().GroupBy(t => t.UltimoEstado) .Select( g => new CantidadPorEstadoModel { Cantidad = g.Count(), Estado = CultureManager.GetLabel(TicketRechazo.GetEstadoLabelVariableName(g.Key)) }); return(Json(list.ToArray())); }
public void GetDataItems(UI001ViewModel model) { using (EntityDao db = new EntityDao()) { StringBuilder sql = new StringBuilder(); List <MySqlParameter> param = new List <MySqlParameter>(); sql.AppendLine("SELECT "); sql.AppendLine(" @rownum := @rownum +1 AS rownum,"); sql.AppendLine(" B.Group,"); sql.AppendLine(" B.CD,"); sql.AppendLine(" B.Name,"); sql.AppendLine(" B.Type,"); sql.AppendLine(" B.DateEnd,"); sql.AppendLine(" D.Name AS Work,"); sql.AppendLine(" C.UserCD,"); sql.AppendLine(" C.DatePeFrom,"); sql.AppendLine(" C.DatePeEnd,"); sql.AppendLine(" C.DateReFrom,"); sql.AppendLine(" C.DateReEnd,"); sql.AppendLine(" C.Percent,"); sql.AppendLine(" C.Back"); sql.AppendLine("FROM (SELECT @rownum := 0) r,"); sql.AppendLine("TB_project AS A"); sql.AppendLine("INNER JOIN tb_function AS B"); sql.AppendLine("ON A.CD = B.ProjectCD"); sql.AppendLine("INNER JOIN tb_wbstype AS C"); sql.AppendLine("ON A.CD = C.ProjectCD"); sql.AppendLine("AND B.CD = C.CD"); sql.AppendLine("INNER JOIN tb_type AS D"); sql.AppendLine("ON D.Type = '04'"); sql.AppendLine("AND C.Type = D.Value"); param.Add(new MySqlParameter("Language", App.Language)); sql.AppendLine("AND D.Language = @Language"); param.Add(new MySqlParameter("CD", model.SelectedProjectItem.CD)); sql.AppendLine("WHERE A.CD = @CD"); sql.AppendLine("ORDER BY"); sql.AppendLine("B.Group,B.CD,C.Type"); model.DataItems = new ObservableCollection <UI001DataItem>(db.FindAll <UI001DataItem>(sql.ToString(), param)); } }
public DataSourceResult GetDataSource([ModelBinder(typeof(WebApiDataSourceRequestModelBinder))] DataSourceRequest request) { var insumos = EntityDao.FindAll(); return(insumos.ToDataSourceResult(request, i => Mapper.EntityToModel(i, new InsumoModel()))); }