public IHttpActionResult Post(int distritoId, int baseId, [FromBody] OrderSelectionModel orderSelectionModel) { var routeCode = BuildRouteCode(orderSelectionModel.StartDateTime, orderSelectionModel.IdVehicle, orderSelectionModel.IdVehicleType, orderSelectionModel.LogisticsCycleType, distritoId, baseId); // Agrupo por OrderId var odByOrderId = orderSelectionModel.OrderDetailList.Where(od => od.Cuaderna != 0).GroupBy(od => od.OrderId); // foreach (var group in odByOrderId) { var order = EntityDao.FindById(group.Key); group.ToList().ForEach(od => { // Se asigna el ajuste y la cuaderna asignada var orderDetail = order.OrderDetails.Single(item => item.Id == od.Id); orderDetail.Ajuste = od.Ajuste; orderDetail.Cuaderna = od.Cuaderna; orderDetail.Estado = OrderDetail.Estados.Ruteado; }); // Programo por Orden RoutingService.Programming(order, routeCode, orderSelectionModel.IdVehicle, orderSelectionModel.StartDateTime, orderSelectionModel.LogisticsCycleType, orderSelectionModel.IdVehicleType); } return(Ok()); }
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 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(); } }
/// <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")); } }
/// <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; } } }
public IEnumerable <EmpleadoModel> GetEmpleadosModel(int distritoId, int baseId, string tipoEmpleadoCodigo) { return (EntityDao.GetByCodigoTipoEmpleado(new[] { distritoId }, new[] { baseId }, tipoEmpleadoCodigo) .Select(e => Mapper.EntityToModel(e, new EmpleadoModel())) .ToList()); }
public void Login(WD001ViewModel model) { if (string.IsNullOrWhiteSpace(model.UserId) || string.IsNullOrWhiteSpace(model.PassWord)) { return; } using (EntityDao db = new EntityDao()) { List <MySqlParameter> para = new List <MySqlParameter>(); StringBuilder sql = new StringBuilder(); sql.AppendLine("select * from tb_user"); para.Add(new MySqlParameter("CD", model.UserId)); sql.AppendLine("where CD = @CD"); para.Add(new MySqlParameter("Password", model.PassWord)); sql.AppendLine(" and Password = md5(@Password)"); sql.AppendLine(" and DateStart <= CURDATE()"); sql.AppendLine(" and CURDATE() <= DateEnd"); sql.AppendLine(" and DelFlg = '0'"); TB_User user = db.FindSingle <TB_User>(sql.ToString(), para); if (user != null) { App.LoginUser = user; model.UserName = user.Name; } else { } } }
public IEnumerable <ItemModel> GetComboItem(int distritoId, int baseId) { var empresa = (new DAL.DAO.BusinessObjects.EmpresaDAO()).FindById(distritoId); var linea = (new DAL.DAO.BusinessObjects.LineaDAO()).FindById(baseId); return(EntityDao.FindByEmpresaYLineaAndUser(empresa, linea, Usuario) .Select(t => Mapper.ToItem(t)).OrderBy(m => m.Value).ToList()); }
public IEnumerable <ItemModel> GetComboItem(int distritoId) { var list = ItemModel.None.ToList(); list.AddRange(EntityDao.GetByEmpresa(distritoId).Select(t => Mapper.ToItem(t))); return(list); }
public bool SaveRole_FormAndFunctioin(int roleId, string allMenuids, string selectedFormIds, string selectedFunctionIds, string userName) { if (string.IsNullOrEmpty(allMenuids)) { return(true); } return(EntityDao.SaveRole_FormAndFunctioin(roleId, allMenuids, selectedFormIds, selectedFunctionIds, userName)); }
public DataSourceResult GetDataSource( [ModelBinder(typeof(WebApiDataSourceRequestModelBinder))] DataSourceRequest filter, int distritoId, int baseId) { var filterValue = GetFilterValue(filter.Filters, "Codigo"); return(EntityDao.FindByCodeLike(distritoId, baseId, filterValue.ToString()).ToDataSourceResult(filter, e => Mapper.EntityToModel(e, new ViajeDistribucionModel()))); }
public IEnumerable <ItemModel> GetEmpleados(int distritoId, int baseId, string tipoEmpleadoCodigo) { return (EntityDao.GetByCodigoTipoEmpleado(new[] { distritoId }, new[] { baseId }, tipoEmpleadoCodigo) .Select(e => Mapper.ToItem(e)) .ToList()); //var tp = DAOFactory.GetDao<TipoEmpleadoDAO>().FindByCodigo(distritoId, baseId, tipoEmpleadoCodigo); //return tp != null ? EntityDao.GetList(new[] { distritoId }, new[] { baseId }, new[] { tp.Id}, new int[] { }).Select(e => Mapper.ToItem(e)).ToList() : new List<ItemModel>(); }
public IHttpActionResult PutItem(int id, TicketRechazoModel rechazoModel) { var ticketEntity = EntityDao.FindById(id); ticketEntity.ChangeEstado((TicketRechazo.Estado)Enum.Parse(typeof(TicketRechazo.Estado), rechazoModel.Estado), rechazoModel.Observacion, Usuario.Empleado); EntityDao.SaveOrUpdate(ticketEntity); return(Ok()); }
public IEnumerable <ItemModel> GetNextEstado(int ticketId) { var ticket = EntityDao.FindById(ticketId); var estados = TicketRechazo.Next(ticket.UltimoEstado); return(estados.Select(e => new ItemModel { Key = (int)e, Value = CultureManager.GetLabel(TicketRechazo.GetEstadoLabelVariableName(e)) })); }
public IHttpActionResult GetItem(int id) { var rechazo = EntityDao.FindById(id); var rechazoModel = new TicketRechazoModel(); Mapper.EntityToModel(rechazo, rechazoModel); return(Json(rechazoModel)); }
public static void Update() { using (EntityDao db = new EntityDao()) { db.DeleteAll("delete from tb_type"); AddDatas(db, typeof(EnumLevel), EnumType.Type_01.GetValue()); } }
public IEnumerable <ItemModel> GetEmpleados(int distritoId, int baseId) { var empleados = EntityDao.GetList(new List <int> { distritoId }, new List <int> { baseId }, new List <int>(), new List <int>()); return(empleados.Select(e => Mapper.ToItem(e)).OrderBy(e => e.Value).ToList()); }
public ArticuloWindow(Articulo articulo) : base(Gtk.WindowType.Toplevel) { this.Build(); EntityDao <Articulo> articuloDao = new EntityDao <Articulo>(); entryNombre.Text = articulo.Nombre; buttonSave.Clicked += delegate { articulo.Nombre = entryNombre.Text; articuloDao.Save(articulo); }; }
public IEnumerable <TipoCocheModel> GetComboItem(int distritoId, int baseId) { return(new List <TipoCocheModel>(EntityDao.FindByEmpresasAndLineas( new List <int> { distritoId }, new List <int> { baseId }, Usuario) .Select(t => Mapper.EntityToModel(t, new TipoCocheModel())))); }
public static void Update() { using (EntityDao db = new EntityDao()) { db.DeleteAll("delete from tb_type"); AddDatas(db, typeof(PageEnum), EnumType.Type_01.GetValue()); AddDatas(db, typeof(EnumLevel), EnumType.Type_02.GetValue()); AddDatas(db, typeof(EnumDevLang), EnumType.Type_03.GetValue()); AddDatas(db, typeof(EnumDevType), EnumType.Type_04.GetValue()); AddDatas(db, typeof(EnumLanguage), EnumType.Type_05.GetValue()); AddDatas(db, typeof(EnumMessage), EnumType.Type_06.GetValue()); } }
public IEnumerable <ItemModel> GetEmpleado(int distritoId, int baseId, int empleadoId) { var empleado = EntityDao.GetById(distritoId, baseId, empleadoId); if (empleado == null) { return(Enumerable.Empty <ItemModel>()); } var l = new List <ItemModel> { Mapper.ToItem(empleado) }; return(l); }
public IEnumerable <EmpleadoModel> GetEmpleadoModel(int distritoId, int baseId, int empleadoId) { var empleado = EntityDao.GetById(distritoId, -1, empleadoId); if (empleado == null) { return(Enumerable.Empty <EmpleadoModel>()); } var l = new List <EmpleadoModel> { Mapper.EntityToModel(empleado, new EmpleadoModel()) }; return(l); }
public IEnumerable <ItemModel> GetComboItem(int distritoId, int baseId, int tipoCocheId, bool excludeNone = false) { var list = ItemModel.None.ToList(); if (excludeNone) { list = new List <ItemModel>(); } list.AddRange( EntityDao.GetList(new[] { distritoId }, new[] { baseId }, new[] { tipoCocheId }) .Select(t => Mapper.ToItem(t)).OrderBy(t => t.Value)); return(list); }
public IEnumerable <ItemModel> GetComboItem(int distritoId, int baseId) { var list = ItemModel.All.ToList(); var empresa = (new DAL.DAO.BusinessObjects.EmpresaDAO()).FindById(distritoId); var linea = (new DAL.DAO.BusinessObjects.LineaDAO()).FindById(baseId); list.AddRange( EntityDao.FindByEmpresaLineaYUsuario(empresa, linea, Usuario) .Cast <TipoMensaje>() .OrderBy(m => m.Descripcion) .Select(t => Mapper.ToItem(t)) ); return(list); }
public MainWindow() : base(Gtk.WindowType.Toplevel) { Build(); //var list = new[] { //new { Id = 1, Nombre = "Artículo 1"}, // new { Id = 2, Nombre = "Artículo 2"}, // new { Id = 3, Nombre = "Artículo 3"} //}; Title = "Artículo"; EntityDao <Articulo> articuloDao = new EntityDao <Articulo>(); TreeViewHelper.Fill(treeView, new string[] { "Id", "Nombre", "Precio", "Categoria" }, articuloDao.Enumerable); newAction.Activated += delegate { //new ArticuloWindow(new Articulo()); Articulo articulo = new Articulo(); articulo.Nombre = "Articulo " + DateTime.Now.ToString(); articulo.Precio = new decimal(new Random().NextDouble() * 100); articulo.Categoria = (ulong)new Random().Next(3) + 1; articuloDao.Save(articulo); }; editAction.Activated += delegate { object id = TreeViewHelper.GetId(treeView); Articulo articulo = articuloDao.Load(id); new ArticuloWindow(articulo); }; deleteAction.Activated += delegate { if (WindowHelper.Confirm(this, "¿Quieres eliminar el registro?")) { object id = TreeViewHelper.GetId(treeView); articuloDao.Delete(id); } }; refreshAction.Activated += delegate { TreeViewHelper.Fill(treeView, new string[] { "Id", "Nombre", "Precio", "Categoria" }, articuloDao.Enumerable); }; treeView.Selection.Changed += delegate { refreshUI(); }; refreshUI(); }
private static void AddDatas(EntityDao db, Type type, string typeValue) { List <EnumItem> list = type.GetList(); List <TB_Type> datas = new List <TB_Type>(); list.ForEach(x => datas.Add(new TB_Type() { Type = typeValue, Value = x.Value, Name = x.Description, InserterCd = "CD0000", InserteTime = db.DbConectTime, UpdaterCd = "CD0000", UpdateTime = db.DbConectTime, })); db.Add(datas); }
public IHttpActionResult GetPromedioPorRol(int distritoId, int baseId) { var w = EntityDao.GetPromedioPorRol(distritoId, baseId); var vend = w.FirstOrDefault(e => e.TipoEmpleado == "V"); var sup = w.FirstOrDefault(e => e.TipoEmpleado == "SR"); var jef = w.FirstOrDefault(e => e.TipoEmpleado == "JF"); var otr = w.Where(e => e.TipoEmpleado != "V" && e.TipoEmpleado != "SR" && e.TipoEmpleado != "JF"); var promedios = new { vendedor = (vend == null ? 0 : vend.Promedio) / 60, supervisorVentas = (sup == null ? 0 : sup.Promedio) / 60, jefeVentas = (jef == null ? 0 : jef.Promedio) / 60, otros = (otr.Sum(e => e.Promedio) / 60) / Math.Max(1, otr.Count()) }; return(Json(promedios)); }
public void Init(MainWindowViewModel model) { using (EntityDao db = new EntityDao()) { List <MySqlParameter> para = new List <MySqlParameter>(); StringBuilder sql = new StringBuilder(); sql.AppendLine("select * from tb_user"); para.Add(new MySqlParameter("IP", ComUtility.GetLocalIPV4().ToString())); sql.AppendLine("where IP = @IP"); sql.AppendLine(" and DateStart <= CURDATE()"); sql.AppendLine(" and CURDATE() <= DateEnd"); sql.AppendLine(" and DelFlg = '0'"); TB_User user = db.FindSingle <TB_User>(sql.ToString(), para); if (user != null) { App.LoginUser = user; } } }
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)); } }