public FilterWindowView(IObjectSpace objectSpace, IModelView model, bool isRoot, List<FilterColumn> list)
     : base(isRoot)
 {
     this.objectSpace = objectSpace;
     base.model = model;
     control = new FilterWindowControl(list);
 }
 /// <summary>
 /// Find the vector in model space from the point to the viewers eye.
 /// </summary>
 /// <param name="modelView"></param>
 /// <param name="mathUtility"></param>
 /// <param name="p"></param>
 /// <returns></returns>
 private static MathVector ViewVector(IModelView modelView, IMathUtility mathUtility, IMathPoint p)
 {
     var world2screen = modelView.Transform;
     var pScreen = (MathPoint) p.MultiplyTransform(world2screen);
     var vv = (IMathVector) mathUtility.CreateVector(new[] {0.0, 0, 1});
     var pScreenUp = (MathPoint) pScreen.AddVector(vv);
     var pWorldDelta = (MathPoint) pScreenUp.MultiplyTransform((MathTransform) world2screen.Inverse());
     var viewVector = (MathVector) p.Subtract(pWorldDelta);
     return viewVector;
 }
Example #3
0
 public static void SetModel(this View view,IModelView modelView,bool suspendLayout) {
     ISupportUpdate supportUpdate = null;
     if (suspendLayout) {
         var compositeView = view as CompositeView;
         if (compositeView!=null) {
             supportUpdate = compositeView.LayoutManager.Container as ISupportUpdate;
             if (supportUpdate != null) supportUpdate.BeginUpdate();
         }
     }
     try {
         view.SetModel(modelView);
     }
     finally {
         if (supportUpdate!=null)
             supportUpdate.EndUpdate();
     }
 }
 protected virtual bool HasRights(ChoiceActionItem item, IModelView view) {
     var data = (ViewShortcut)item.Data;
     if (view == null) {
         throw new ArgumentException(string.Format("Cannot find the '{0}' view specified by the shortcut: {1}",
                                                   data.ViewId, data));
     }
     Type type = (view is IModelObjectView) ? ((IModelObjectView)view).ModelClass.TypeInfo.Type : null;
     if (type != null) {
         if (!string.IsNullOrEmpty(data.ObjectKey) && !data.ObjectKey.StartsWith("@")) {
             try {
                 using (IObjectSpace space = CreateObjectSpace()) {
                     object objectByKey = space.GetObjectByKey(type, space.GetObjectKey(type, data.ObjectKey));
                     return (DataManipulationRight.CanRead(type, null, objectByKey, null, space) &&
                             DataManipulationRight.CanNavigate(type, objectByKey, space));
                 }
             } catch {
                 return true;
             }
         }
         return DataManipulationRight.CanNavigate(type, null, null);
     }
     return true;
 }
Example #5
0
 public DocView(IModelView mv, DocumentEventHandler doc)
 {
     _mView = (ModelView)mv;
     _parent = doc;
 }
Example #6
0
        protected override IEnumerable <IToolbaritem> VerToolbar(IGestionService service, IModelView model)
        {
            var objModel = model as PedidosComprasModel;
            var result   = base.VerToolbar(service, model).ToList();

            result.Add(new ToolbarSeparatorModel());

            result.Add(CreateComboImprimir(objModel));
            result.Add(new ToolbarActionModel()
            {
                Icono = "fa fa-envelope-o",
                OcultarTextoSiempre = true,
                Texto = General.LblEnviaremail,
                Url   = "javascript:eventAggregator.Publish('Enviarpedido',\'\')"
            });
            return(result);
        }
Example #7
0
 public DocView(IModelView mv, DocumentEventHandler doc)
 {
     mView  = (ModelView)mv;
     parent = doc;
 }
        public override void create(IModelView obj)
        {
            using (var tran = TransactionScopeBuilder.CreateTransactionObject())
            {
                var model = obj as SeguimientosModel;
                var currentValidationService = _validationService as SeguimientosValidation;
                var estadoFinalizado         = new Estados();
                model.Id = NextId();

                if (model.Fechadocumento == null)
                {
                    model.Fechadocumento = DateTime.Now;
                }

                if (model.Tipo == (int)DocumentoEstado.Oportunidades)
                {
                    var modelPadre = _db.Oportunidades.Where(f => f.empresa == Empresa && f.referencia == model.Origen).FirstOrDefault();

                    if (model.Cerrado)
                    {
                        modelPadre.cerrado     = true;
                        modelPadre.fechacierre = model.Fecharesolucion;
                        modelPadre.fkreaccion  = model.Fkreaccion;
                        estadoFinalizado       = _db.Estados.Where(f => f.documento == (int)DocumentoEstado.Oportunidades && f.tipoestado == (int)TipoEstado.Finalizado).SingleOrDefault()
                                                 ?? _db.Estados.Where(f => f.documento == (int)DocumentoEstado.Todos && f.tipoestado == (int)TipoEstado.Finalizado).SingleOrDefault();
                    }

                    modelPadre.fketapa = model.Fketapa;
                    modelPadre.fechaultimoseguimiento = model.Fechadocumento;
                    if (model.Fechaproximoseguimiento != null)
                    {
                        modelPadre.fechaproximoseguimiento = model.Fechaproximoseguimiento;
                    }

                    //Rai
                    //Se van totalizando los costes imputados de los seguimientos
                    modelPadre.coste += model.Coste;

                    var converterModel = FConverterModel.Instance.CreateConverterModelService <OportunidadesModel, Oportunidades>(_context, _db, Empresa);
                    var modelview      = converterModel.GetModelView(modelPadre);

                    var service = FService.Instance.GetService(typeof(OportunidadesModel), _context);
                    service.edit(modelview);
                }
                else if (model.Tipo == (int)DocumentoEstado.Proyectos)
                {
                    var modelPadre = _db.Proyectos.Where(f => f.empresa == Empresa && f.referencia == model.Origen).FirstOrDefault();

                    if (model.Cerrado)
                    {
                        modelPadre.cerrado     = true;
                        modelPadre.fechacierre = model.Fecharesolucion;
                        modelPadre.fkreaccion  = model.Fkreaccion;
                        estadoFinalizado       = _db.Estados.Where(f => f.documento == (int)DocumentoEstado.Proyectos && f.tipoestado == (int)TipoEstado.Finalizado).SingleOrDefault()
                                                 ?? _db.Estados.Where(f => f.documento == (int)DocumentoEstado.Todos && f.tipoestado == (int)TipoEstado.Finalizado).SingleOrDefault();
                    }

                    modelPadre.fketapa = model.Fketapa;
                    modelPadre.fechaultimoseguimiento = model.Fechadocumento;
                    if (model.Fechaproximoseguimiento != null)
                    {
                        modelPadre.fechaproximoseguimiento = model.Fechaproximoseguimiento;
                    }

                    //Rai
                    //Se van totalizando los costes imputados de los seguimientos
                    modelPadre.coste += model.Coste;

                    var converterModel = FConverterModel.Instance.CreateConverterModelService <ProyectosModel, Proyectos>(_context, _db, Empresa);
                    var modelview      = converterModel.GetModelView(modelPadre);

                    var service = FService.Instance.GetService(typeof(ProyectosModel), _context);
                    service.edit(modelview);
                }
                else if (model.Tipo == (int)DocumentoEstado.Campañas)
                {
                    var modelPadre = _db.Campañas.Where(f => f.empresa == Empresa && f.referencia == model.Origen).FirstOrDefault();

                    if (model.Cerrado)
                    {
                        modelPadre.cerrado     = true;
                        modelPadre.fechacierre = model.Fecharesolucion;
                        modelPadre.fkreaccion  = model.Fkreaccion;
                        estadoFinalizado       = _db.Estados.Where(f => f.documento == (int)DocumentoEstado.Campañas && f.tipoestado == (int)TipoEstado.Finalizado).SingleOrDefault()
                                                 ?? _db.Estados.Where(f => f.documento == (int)DocumentoEstado.Todos && f.tipoestado == (int)TipoEstado.Finalizado).SingleOrDefault();
                    }

                    modelPadre.fketapa = model.Fketapa;
                    modelPadre.fechaultimoseguimiento = model.Fechadocumento;
                    if (model.Fechaproximoseguimiento != null)
                    {
                        modelPadre.fechaproximoseguimiento = model.Fechaproximoseguimiento;
                    }

                    //Rai
                    //Se van totalizando los costes imputados de los seguimientos
                    modelPadre.coste += model.Coste;

                    var converterModel = FConverterModel.Instance.CreateConverterModelService <CampañasModel, Campañas>(_context, _db, Empresa);
                    var modelview      = converterModel.GetModelView(modelPadre);

                    var service = FService.Instance.GetService(typeof(CampañasModel), _context);
                    service.edit(modelview);
                }
                else if (model.Tipo == (int)DocumentoEstado.Incidencias)
                {
                    var modelPadre = _db.IncidenciasCRM.Where(f => f.empresa == Empresa && f.referencia == model.Origen).FirstOrDefault();

                    if (model.Cerrado)
                    {
                        modelPadre.cerrado     = true;
                        modelPadre.fechacierre = model.Fecharesolucion;
                        modelPadre.fkreaccion  = model.Fkreaccion;
                        estadoFinalizado       = _db.Estados.Where(f => f.documento == (int)DocumentoEstado.Incidencias && f.tipoestado == (int)TipoEstado.Finalizado).SingleOrDefault()
                                                 ?? _db.Estados.Where(f => f.documento == (int)DocumentoEstado.Todos && f.tipoestado == (int)TipoEstado.Finalizado).SingleOrDefault();
                    }

                    modelPadre.fketapa = model.Fketapa;
                    modelPadre.fechaultimoseguimiento = model.Fechadocumento;
                    if (model.Fechaproximoseguimiento != null)
                    {
                        modelPadre.fechaproximoseguimiento = model.Fechaproximoseguimiento;
                    }

                    //Rai
                    //Se van totalizando los costes imputados de los seguimientos
                    modelPadre.coste += model.Coste;

                    var converterModel = FConverterModel.Instance.CreateConverterModelService <IncidenciasCRMModel, IncidenciasCRM>(_context, _db, Empresa);
                    var modelview      = converterModel.GetModelView(modelPadre);

                    var service = FService.Instance.GetService(typeof(IncidenciasCRMModel), _context);
                    service.edit(modelview);
                }

                var etapaAnterior  = _db.Seguimientos.Where(f => f.empresa == model.Empresa && f.id == model.Id).Select(f => f.fketapa).SingleOrDefault();
                var estadoAnterior = 0;
                if (etapaAnterior != null)
                {
                    var s         = etapaAnterior.Split('-');
                    var documento = Funciones.Qint(s[0]);
                    var id        = s[1];
                    estadoAnterior = _db.Estados.Where(f => f.documento == documento && f.id == id).Select(f => f.tipoestado).SingleOrDefault() ?? 0;
                }

                if (model.Cerrado && (estadoAnterior != (int)TipoEstado.Finalizado && estadoAnterior != (int)TipoEstado.Caducado && estadoAnterior != (int)TipoEstado.Anulado))
                {
                    model.Fketapa = estadoFinalizado.documento + "-" + estadoFinalizado.id;
                    currentValidationService.CambiarEstado = true;
                }

                foreach (var linea in model.Correos)
                {
                    linea.Empresa        = model.Empresa;
                    linea.Context        = model.Context;
                    linea.Fkseguimientos = model.Id;
                    linea.Fkorigen       = model.Origen;
                }

                base.create(obj);

                _db.SaveChanges();
                tran.Complete();
            }
        }
        protected override IEnumerable <IToolbaritem> EditToolbar(IGestionService service, IModelView model)
        {
            var objModel = model as IncidenciasCRMModel;
            var result   = base.EditToolbar(service, model).ToList();

            result.Add(new ToolbarSeparatorModel());

            if (!objModel.Cerrado)
            {
                result.Add(new ToolbarActionModel()
                {
                    Icono = "fa fa-gear",
                    Texto = General.LblGenerarSeguimiento,
                    Url   = Url.Action("Generar", "Seguimientos", new
                    {
                        id            = objModel.Id,
                        referencia    = objModel.Referencia,
                        tipodocumento = DocumentoEstado.Incidencias,
                        fkempresa     = objModel.Fkempresa,
                        fketapa       = objModel.Fketapa
                    })
                });

                result.Add(new ToolbarSeparatorModel());
            }

            return(result);
        }
Example #10
0
 void MergeObjectViewValueInfos(IModelMergedDifferenceStrategy differenceStrategy, IModelView sourceObjectView, IModelObjectView targetObjectView)
 {
     foreach (var valueInfo in GetValuesInfos(sourceObjectView, differenceStrategy.MergedViewValueInfos))
     {
         var sourceValue = sourceObjectView.GetValue(valueInfo.Name, valueInfo.PropertyType);
         var targetValue = targetObjectView.GetValue(valueInfo.Name, valueInfo.PropertyType);
         if (sourceValue != targetValue)
         {
             targetObjectView.SetValue(valueInfo.Name, valueInfo.PropertyType, sourceValue);
         }
     }
 }
 public static IEnumerable <IModelMemberViewItem> MemberViewItems(this IModelView modelObjectView, Type propertyEditorType = null)
 => !(modelObjectView is IModelObjectView) ? Enumerable.Empty <IModelMemberViewItem>()
         : (modelObjectView is IModelListView modelListView ? modelListView.Columns : ((IModelDetailView)modelObjectView).Items.OfType <IModelMemberViewItem>())
        public override DivisionLotes CreatePersitance(IModelView obj)
        {
            var viewmodel = obj as DivisionLotesModel;
            var result    = _db.Set <DivisionLotes>().Create();

            foreach (var item in result.GetType().GetProperties())
            {
                if ((obj.GetType().GetProperty(item.Name.FirstToUpper())?.PropertyType.IsGenericType ?? false) &&
                    (obj.GetType().GetProperty(item.Name.FirstToUpper())?.PropertyType.GetGenericTypeDefinition() !=
                     typeof(ICollection <>)))
                {
                    item.SetValue(result, obj.GetType().GetProperty(item.Name.FirstToUpper())?.GetValue(obj, null));
                }
                else if (obj.GetType().GetProperty(item.Name.FirstToUpper())?.PropertyType.IsEnum ?? false)
                {
                    item.SetValue(result, (int)obj.GetType().GetProperty(item.Name.FirstToUpper())?.GetValue(obj, null));
                }
                else if (!obj.GetType().GetProperty(item.Name.FirstToUpper())?.PropertyType.IsGenericType ?? false)
                {
                    item.SetValue(result, obj.GetType().GetProperty(item.Name.FirstToUpper())?.GetValue(obj, null));
                }
            }

            result.fechaalta             = DateTime.Now;
            result.fechamodificacion     = result.fechaalta;
            result.fkusuarioalta         = Context.Id;
            result.fkusuariomodificacion = Context.Id;
            result.empresa         = Empresa;
            result.tipoalmacenlote = (int?)viewmodel.Tipodealmacenlote;

            foreach (var item in viewmodel.LineasEntrada)
            {
                var newItem = _db.Set <DivisionLotesentradalin>().Create();
                newItem.empresa                = Empresa;
                newItem.id                     = item.Id;
                newItem.fkarticulos            = item.Fkarticulos;
                newItem.descripcion            = item.Descripcion;
                newItem.lote                   = item.Lote;
                newItem.tabla                  = item.Tabla;
                newItem.cantidad               = item.Cantidad;
                newItem.largo                  = item.Largo;
                newItem.ancho                  = item.Ancho;
                newItem.grueso                 = item.Grueso;
                newItem.fkunidades             = item.Fkunidades;
                newItem.metros                 = item.Metros;
                newItem.notas                  = item.Notas;
                newItem.canal                  = item.Canal;
                newItem.revision               = item.Revision;
                newItem.decimalesmonedas       = item.Decimalesmonedas;
                newItem.decimalesmedidas       = item.Decimalesmedidas;
                newItem.orden                  = item.Orden ?? item.Id;
                newItem.costeadicionalvariable = item.Costeadicionalvariable;
                newItem.costeadicionalmaterial = item.Costeadicionalmaterial;
                newItem.costeadicionalotro     = item.Costeadicionalotro;
                newItem.costeadicionalportes   = item.Costeadicionalportes;
                newItem.precio                 = item.Precio;
                newItem.precio                 = item.Precio;
                newItem.loteautomaticoid       = item.Loteautomaticoid;
                newItem.flagidentifier         = Guid.NewGuid();

                result.DivisionLotesentradalin.Add(newItem);
            }

            foreach (var item in viewmodel.LineasSalida)
            {
                var newItem = _db.Set <DivisionLotessalidalin>().Create();
                newItem.empresa          = Empresa;
                newItem.id               = item.Id;
                newItem.fkarticulos      = item.Fkarticulos;
                newItem.descripcion      = item.Descripcion;
                newItem.lote             = item.Lote;
                newItem.tabla            = item.Tabla;
                newItem.cantidad         = item.Cantidad;
                newItem.largo            = item.Largo;
                newItem.ancho            = item.Ancho;
                newItem.grueso           = item.Grueso;
                newItem.fkunidades       = item.Fkunidades;
                newItem.metros           = item.Metros;
                newItem.notas            = item.Notas;
                newItem.canal            = item.Canal;
                newItem.revision         = item.Revision;
                newItem.decimalesmonedas = item.Decimalesmonedas;
                newItem.decimalesmedidas = item.Decimalesmedidas;
                newItem.orden            = item.Orden ?? item.Id;
                newItem.precio           = item.Precio;
                newItem.flagidentifier   = Guid.NewGuid();
                result.DivisionLotessalidalin.Add(newItem);
            }


            foreach (var item in viewmodel.Costes)
            {
                var newItem = _db.Set <DivisionLotescostesadicionales>().Create();
                newItem.empresa         = Empresa;
                newItem.fkdivisionlotes = result.id;
                newItem.id                  = item.Id;
                newItem.tipodocumento       = (int)item.Tipodocumento;
                newItem.referenciadocumento = item.Referenciadocumento;
                newItem.importe             = item.Importe;
                newItem.porcentaje          = item.Porcentaje;
                newItem.total               = item.Total;
                newItem.tipocoste           = (int)item.Tipocoste;
                newItem.tiporeparto         = (int)item.Tiporeparto;
                newItem.notas               = item.Notas;
                result.DivisionLotescostesadicionales.Add(newItem);
            }

            return(result);
        }
Example #13
0
        //method for updating the solid cam view
        private void SolidFrameT(object myObject)//Vector3D a, Double theta)
        {
            Stopwatch stopWatch = new Stopwatch();

            double[] times = new double[8];
            stopWatch.Start();

            if (solidFrameMutex.WaitOne(0))
            {
                //no update over "noise", no update during calibration
                solidMovement = MovementFilter();
                if (!solidMovement || !mpuStable)
                {
                    solidFrameMutex.ReleaseMutex();
                    return;
                }

                lastLockedQuat = quat;
                Quaternion tempQuat = GetCorrectedQuat();
                Vector3D   a        = tempQuat.Axis;
                double     theta    = tempQuat.Angle;
                theta *= Math.PI / 180;
                //move object instead of the camera
                theta = -theta;

                //0 ms
                times[0] = stopWatch.ElapsedMilliseconds;
                try
                {
                    if (!solidDoc)
                    {
                        //5-19 ms
                        if (_swApp.ActiveDoc != null)
                        {
                            solidDoc = true;
                        }
                    }
                    //avoiding exceptions if possible
                    if (solidDoc)
                    {
                        times[1] = stopWatch.ElapsedMilliseconds;
                        //5-14 ms
                        IModelDoc doc = _swApp.ActiveDoc;
                        try
                        {
                            times[2] = stopWatch.ElapsedMilliseconds;
                            //4-6 ms somehow solid won't allow this to happen at once
                            IModelView view = doc.ActiveView;
                            times[3] = stopWatch.ElapsedMilliseconds;
                            tempQuat.Invert();
                            double[,] rotation = QuatToRotation(tempQuat);
                            //TODO: translate :(
                            //15-23 ms no need to translate just yet!
                            //MathTransform translate = view.Translation3;
                            //TODO: rescale :(
                            //no need to rescale yet either
                            //double scale = view.Scale2;
                            times[4] = stopWatch.ElapsedMilliseconds;
                            double[] tempArr = new double[16];
                            //new X axis
                            tempArr[0] = rotation[0, 0];
                            tempArr[1] = rotation[1, 0];
                            tempArr[2] = rotation[2, 0];
                            //new Y axis
                            tempArr[3] = rotation[0, 1];
                            tempArr[4] = rotation[1, 1];
                            tempArr[5] = rotation[2, 1];
                            //new Z axis
                            tempArr[6] = rotation[0, 2];
                            tempArr[7] = rotation[1, 2];
                            tempArr[8] = rotation[2, 2];
                            //translation - doesn't mater for orientation!
                            tempArr[9]  = 0;
                            tempArr[10] = 0;
                            tempArr[11] = 0;
                            //scale - doesn't mater for orientation!
                            tempArr[12] = 1;
                            //?
                            tempArr[13] = 0;
                            tempArr[14] = 0;
                            tempArr[15] = 0;
                            //? ms
                            orientation.ArrayData = tempArr;
                            times[5] = stopWatch.ElapsedMilliseconds;
                            //? ms
                            view.Orientation3 = orientation;
                            times[6]          = stopWatch.ElapsedMilliseconds;
                            //? ms
                            view.RotateAboutCenter(1, 1);
                            //view.GraphicsRedraw(new int[] { });
                            times[7] = stopWatch.ElapsedMilliseconds;
                        }
                        //no active view
                        catch (Exception ex)
                        {
                            solidDoc = false;
                            //MessageBox.Show("Unable to rotate Solid Camera!\n" + ex.ToString());
                        }
                    }
                }
                //no _swApp
                catch (Exception ex)
                {
                    solidRunning = false;
                    MessageBox.Show("Oh no! Something went wrong with Solid!\n" + ex.ToString());
                }
                solidFrameMutex.ReleaseMutex();
                stopWatch.Stop();
            }
        }
        public override Albaranes EditPersitance(IModelView obj)
        {
            var viewmodel = obj as AlbaranesModel;
            var result    = _db.Albaranes.Where(f => f.empresa == viewmodel.Empresa && f.id == viewmodel.Id).Include(b => b.AlbaranesLin).Include(b => b.AlbaranesTotales).ToList().Single();

            //todo asignar
            foreach (var item in result.GetType().GetProperties())
            {
                if ((obj.GetType().GetProperty(item.Name.FirstToUpper())?.PropertyType.IsGenericType ?? false) &&
                    (obj.GetType().GetProperty(item.Name.FirstToUpper())?.PropertyType.GetGenericTypeDefinition() !=
                     typeof(ICollection <>)))
                {
                    item.SetValue(result, obj.GetType().GetProperty(item.Name.FirstToUpper())?.GetValue(obj, null));
                }
                else if (obj.GetType().GetProperty(item.Name.FirstToUpper())?.PropertyType.IsEnum ?? false)
                {
                    item.SetValue(result, (int)obj.GetType().GetProperty(item.Name.FirstToUpper())?.GetValue(obj, null));
                }
                else if (!obj.GetType().GetProperty(item.Name.FirstToUpper())?.PropertyType.IsGenericType ?? false)
                {
                    item.SetValue(result, obj.GetType().GetProperty(item.Name.FirstToUpper())?.GetValue(obj, null));
                }
            }
            //todo asignar contador y referencia
            result.fechamodificacion     = DateTime.Now;
            result.fkusuariomodificacion = Context.Id;
            result.fkpuertosfkpaises     = viewmodel.Fkpuertos.Fkpaises;
            result.fkpuertosid           = viewmodel.Fkpuertos.Id;
            result.tipoportes            = (int?)viewmodel.Tipodeportes;
            result.tipoalmacenlote       = (int?)viewmodel.Tipodealmacenlote;
            result.AlbaranesLin.Clear();
            foreach (var item in viewmodel.Lineas)
            {
                var newItem = _db.Set <AlbaranesLin>().Create();
                newItem.empresa                       = result.empresa;
                newItem.fkalbaranes                   = result.id;
                newItem.id                            = item.Id;
                newItem.fkarticulos                   = item.Fkarticulos;
                newItem.descripcion                   = item.Descripcion;
                newItem.lote                          = item.Lote;
                newItem.tabla                         = item.Tabla;
                newItem.cantidad                      = item.Cantidad;
                newItem.cantidadpedida                = item.Cantidadpedida;
                newItem.largo                         = item.Largo;
                newItem.ancho                         = item.Ancho;
                newItem.grueso                        = item.Grueso;
                newItem.fkunidades                    = item.Fkunidades;
                newItem.metros                        = item.Metros;
                newItem.precio                        = item.Precio;
                newItem.porcentajedescuento           = item.Porcentajedescuento;
                newItem.importedescuento              = item.Importedescuento;
                newItem.fktiposiva                    = item.Fktiposiva;
                newItem.porcentajeiva                 = item.Porcentajeiva;
                newItem.cuotaiva                      = item.Cuotaiva;
                newItem.porcentajerecargoequivalencia = item.Porcentajerecargoequivalencia ?? 0;
                newItem.cuotarecargoequivalencia      = item.Cuotarecargoequivalencia;
                newItem.importe                       = item.Importe;
                newItem.notas                         = item.Notas;
                newItem.documentoorigen               = item.Documentoorigen;
                newItem.canal                         = item.Canal;
                newItem.precioanterior                = item.Precioanterior;
                newItem.revision                      = item.Revision;
                newItem.decimalesmonedas              = item.Decimalesmonedas;
                newItem.decimalesmedidas              = item.Decimalesmedidas;
                newItem.fkpedidos                     = item.Fkpedidos;
                newItem.fkpedidosid                   = item.Fkpedidosid;
                newItem.fkpedidosreferencia           = item.Fkpedidosreferencia;
                newItem.bundle                        = item.Bundle?.ToUpper();
                newItem.tblnum                        = item.Tblnum;
                newItem.contenedor                    = item.Contenedor;
                newItem.sello                         = item.Sello;
                newItem.caja                          = item.Caja;
                newItem.pesoneto                      = item.Pesoneto;
                newItem.pesobruto                     = item.Pesobruto;
                newItem.seccion                       = item.Seccion;
                newItem.costeadicionalportes          = item.Costeadicionalportes;
                newItem.costeacicionalvariable        = item.Costeadicionalvariable;
                newItem.costeadicionalmaterial        = item.Costeadicionalmaterial;
                newItem.costeadicionalotro            = item.Costeadicionalotro;
                newItem.orden                         = item.Orden;
                newItem.flagidentifier                = item.Flagidentifier;
                newItem.fkreclamado                   = item.Fkreclamado;
                newItem.fkreclamadoreferencia         = item.Fkreclamadoreferencia;

                newItem.tipoalmacenlote = (int?)item.Tipodealmacenlote;

                result.AlbaranesLin.Add(newItem);
            }

            result.AlbaranesTotales.Clear();
            foreach (var item in viewmodel.Totales)
            {
                var newItem = _db.Set <AlbaranesTotales>().Create();
                newItem.empresa       = result.empresa;
                newItem.fkalbaranes   = result.id;
                newItem.fktiposiva    = item.Fktiposiva;
                newItem.porcentajeiva = item.Porcentajeiva;
                newItem.basetotal     = item.Baseimponible;
                newItem.brutototal    = item.Brutototal;
                newItem.cuotaiva      = item.Cuotaiva;
                newItem.porcentajerecargoequivalencia = item.Porcentajerecargoequivalencia;
                newItem.importerecargoequivalencia    = item.Importerecargoequivalencia;
                newItem.porcentajedescuentoprontopago = item.Porcentajedescuentoprontopago;
                newItem.importedescuentoprontopago    = item.Importedescuentoprontopago;
                newItem.porcentajedescuentocomercial  = item.Porcentajedescuentocomercial;
                newItem.importedescuentocomercial     = item.Importedescuentocomercial;
                newItem.subtotal         = item.Subtotal;
                newItem.decimalesmonedas = item.Decimalesmonedas;
                result.AlbaranesTotales.Add(newItem);
            }
            return(result);
        }
        void showDV(object sender, CustomProcessListViewSelectedItemEventArgs e)
        {
            Frame frame = Frame;
            View  view  = View;

            DevExpress.ExpressApp.ListView        listView = view as DevExpress.ExpressApp.ListView;
            IEnumerable <MiniNavigationAttribute> mAttr    = null;
            bool AttrExists = false;

            object currentObject = (object)view.CurrentObject;

            if (currentObject == null)
            {
                return;
            }

            Type objType = typeof(object);
            //string DetailViewID = "";
            TargetWindow openMode = TargetWindow.Default;
            IObjectSpace objectSpace;

            Type NavigationChoiceType = (System.Type)(view.CurrentObject.GetType());   //.UnderlyingSystemType;   //typeof(object);


            // Вставка механизма проверки модели на предмет умолчательного view для показа по 2-клик или Ввод
            {
                string path = "";
                //string caption = "";
                //TargetWindow openMode = TargetWindow.Default;
                IModelView modelView = null;
                bool       IsMiniNavigationDefined = false;

                // Узел в модели
                IModelView node = null;
                node = View.Model.Application.Views[listView.Id];
                //IModelListView node  = View.Model.Application.Views.GetNode<IModelListView>(listView.Id);
                if (node != null)
                {
                    // Перебираем все подузлы
                    // node.GetNode(1)	{ModelListViewFilters}	DevExpress.ExpressApp.Model.IModelNode {ModelListViewFilters}
                    for (int i = 0; i < node.NodeCount; i++)
                    {
                        IModelMiniNavigations miniNavigationNode = node.GetNode(i) as IModelMiniNavigations;
                        if (miniNavigationNode != null)
                        {
                            // Сначала заполняем тот, что прописан по умолчанию
                            IModelMiniNavigationItem miniNavigationDefaultItem = miniNavigationNode.DefaultMiniNavigationNode;
                            if (miniNavigationDefaultItem != null)
                            {
                                path = miniNavigationDefaultItem.NavigationPath;
                                //caption = miniNavigationDefaultItem.NavigationCaption;
                                openMode  = miniNavigationDefaultItem.TargetWindow;
                                modelView = miniNavigationDefaultItem.View;

                                IsMiniNavigationDefined = true;
                            }

                            //if (modelView == null) {
                            if (!IsMiniNavigationDefined)
                            {
                                foreach (IModelMiniNavigationItem miniNavigationItem in miniNavigationNode.GetNodes <IModelMiniNavigationItem>())
                                {
                                    if (miniNavigationItem != miniNavigationDefaultItem)
                                    {
                                        path = miniNavigationItem.NavigationPath;
                                        //caption = miniNavigationItem.NavigationCaption;
                                        openMode  = miniNavigationItem.TargetWindow;
                                        modelView = miniNavigationItem.View;

                                        IsMiniNavigationDefined = true;
                                        break; // Берём первый по расположению
                                    }
                                }
                            }
                            break;
                        }
                    }

                    // Если в модели ничего не найдено, то читаем атрибуты.
                    if (!IsMiniNavigationDefined)
                    {
                        DevExpress.ExpressApp.DC.ITypeInfo objectTypeInfo = null;
                        objectTypeInfo = listView.CollectionSource.ObjectTypeInfo;
                        //typeObjectOfListView = objectTypeInfo.Type;

                        mAttr = objectTypeInfo.FindAttributes <MiniNavigationAttribute>();

                        // Если ничего нет, то покидаем
                        if (mAttr == null & !IsMiniNavigationDefined)
                        {
                            return;
                        }

                        SortedDictionary <int, MiniNavigationAttribute> sd = new SortedDictionary <int, MiniNavigationAttribute>();

                        IEnumerator <MiniNavigationAttribute> _enum = mAttr.GetEnumerator();
                        while (_enum.MoveNext())
                        {
                            MiniNavigationAttribute attr = ((MiniNavigationAttribute)(_enum.Current));
                            sd.Add(attr.Order, attr);
                        }

                        foreach (KeyValuePair <int, MiniNavigationAttribute> kvp in sd)
                        {
                            AttrExists = true;
                            MiniNavigationAttribute attr = kvp.Value;
                            path = attr.NavigationPath;
                            //caption = attr.NavigationCaptin;
                            openMode = attr.TargetWindow;
                            break;  // Берём первый по порядку Order (он же и тот, что по умолчанию)
                        }
                    }

                    if (AttrExists || IsMiniNavigationDefined)
                    {
                        // Получаем объект obj для показа
                        BaseObject obj = GetObjectOnPathEnd(path, currentObject as BaseObject);

                        if (obj == null)
                        {
                            DevExpress.XtraEditors.XtraMessageBox.Show(
                                CommonMethods.GetMessage(MiniNavigatorControllerMessages.SHOWING_OBJECT_NOT_DEFINED),
                                messageCaption,
                                System.Windows.Forms.MessageBoxButtons.OK,
                                System.Windows.Forms.MessageBoxIcon.Exclamation);
                            return;
                        }

                        Type   ChoiceType = (System.Type)(obj.GetType());             //.UnderlyingSystemType;   //typeof(object);
                        string ViewID     = Application.FindDetailViewId(ChoiceType); // По умолчанию - DetailView

                        Frame resultFrame = frame;                                    // Application.CreateFrame("new");
                        //TargetWindow openMode = (TargetWindow)e.SelectedChoiceActionItem.Data;

                        // Небольшая разборка с сочетанием значений openMode в целях определения фрейма, в который грузить
                        if (MasterDetailViewFrame != null && (openMode == TargetWindow.Current & ((frame as NestedFrame) != null | !view.IsRoot)))
                        {
                            // Тогда Current трактуем как корневое окно
                            resultFrame = MasterDetailViewFrame;
                            {
                                objectSpace = resultFrame.Application.CreateObjectSpace();   //.View.ObjectSpace;
                                object representativeObj = objectSpace.GetObject(obj);

                                View dv = null;

                                if (modelView != null)
                                {
                                    if ((modelView as IModelDetailView) != null)
                                    {
                                        ViewID = (modelView as IModelDetailView).Id;
                                        dv     = resultFrame.Application.CreateDetailView(objectSpace, ViewID, true, representativeObj) as DetailView;
                                    }
                                    else if ((modelView as IModelListView) != null)
                                    {
                                        ViewID = (modelView as IModelListView).Id;
                                        //ListView dv = resultFrame.Application.CreateListView(objectSpace, ChoiceType, true);
                                        CollectionSource colSource = new CollectionSource(objectSpace, ChoiceType);
                                        if (!colSource.IsLoaded)
                                        {
                                            colSource.Reload();
                                        }
                                        dv = resultFrame.Application.CreateListView((modelView as IModelListView), colSource, true) as ListView;
                                    }
                                }
                                else
                                {
                                    // Если навигация орпделена в модели, а view не определено, то образуем DetailView по умолчанию
                                    ViewID = Application.FindDetailViewId(ChoiceType);
                                    dv     = resultFrame.Application.CreateDetailView(objectSpace, ViewID, true, representativeObj) as DetailView;
                                }

                                resultFrame.SetView(dv, true, resultFrame);
                            }
                            return;
                        }

                        // Общий алгоритм
                        {
                            objectSpace = resultFrame.Application.CreateObjectSpace();
                            object representativeObj = objectSpace.GetObject(obj);

                            View dv = null;

                            if (modelView != null)
                            {
                                if ((modelView as IModelDetailView) != null)
                                {
                                    ViewID = (modelView as IModelDetailView).Id;
                                    dv     = resultFrame.Application.CreateDetailView(objectSpace, ViewID, true, representativeObj) as DetailView;
                                }
                                else if ((modelView as IModelListView) != null)
                                {
                                    ViewID = (modelView as IModelListView).Id;
                                    //ListView dv = resultFrame.Application.CreateListView(objectSpace, ChoiceType, true);
                                    //objectSpace = resultFrame.Application.CreateObjectSpace();
                                    CollectionSource colSource = new CollectionSource(objectSpace, ChoiceType);
                                    if (!colSource.IsLoaded)
                                    {
                                        colSource.Reload();
                                    }
                                    dv = resultFrame.Application.CreateListView((modelView as IModelListView), colSource, true) as ListView;
                                }
                            }
                            else
                            {
                                // Если навигация определена в модели, а view не определено, то образуем DetailView по умолчанию
                                ViewID = Application.FindDetailViewId(ChoiceType);
                                dv     = resultFrame.Application.CreateDetailView(objectSpace, ViewID, true, representativeObj) as DetailView;
                            }

                            ShowViewParameters svp = new ShowViewParameters();
                            svp.CreatedView          = dv;
                            svp.TargetWindow         = openMode;
                            svp.Context              = TemplateContext.View;
                            svp.CreateAllControllers = true;

                            e.InnerArgs.ShowViewParameters.Assign(svp);
                            return;
                        }
                    }
                }
            }


            // ПРОЧИЕ LISTVIEW
            // Грузим в отдельном окне

            e.Handled = false;
            openMode  = TargetWindow.NewWindow;
            if (Frame as NestedFrame != null | !View.IsRoot)
            {
                openMode = TargetWindow.NewModalWindow;
            }
            e.InnerArgs.ShowViewParameters.TargetWindow = openMode;
        }
        private void MiniNavigationAction_Execute(object sender, SingleChoiceActionExecuteEventArgs e)
        {
            if (e.CurrentObject == null)
            {
                return;
            }

            if (MiniNavigationAction.SelectedItem == null)
            {
                return;
            }

            object currentObj = e.CurrentObject;

            Frame  frame = Frame;
            View   view  = View;
            string path  = e.SelectedChoiceActionItem.Id;
            //if (selId == path) return;
            String selId = path;

            if ((view as DetailView) != null & selId == "This")
            {
                return;
            }

            BaseObject obj = GetObjectOnPathEnd(path, (BaseObject)currentObj);

            if (obj == null)
            {
                DevExpress.XtraEditors.XtraMessageBox.Show(
                    CommonMethods.GetMessage(MiniNavigatorControllerMessages.SHOWING_OBJECT_NOT_DEFINED),
                    messageCaption,
                    System.Windows.Forms.MessageBoxButtons.OK,
                    System.Windows.Forms.MessageBoxIcon.Exclamation);
                return;
            }

            Type   ChoiceType = (System.Type)(obj.GetType());             //.UnderlyingSystemType;   //typeof(object);
            string ViewID     = Application.FindDetailViewId(ChoiceType); // По умолчанию - DetailView

            // Считывание из модели view, через которое надо показать объект и оно задано
            IModelView modelView = null;

            DevExpress.ExpressApp.ListView   listView   = view as DevExpress.ExpressApp.ListView;
            DevExpress.ExpressApp.DetailView detailView = view as DevExpress.ExpressApp.DetailView;

            //if (IsMiniNavigationDefined) {
            //    // Узел в модели
            //    IModelView node = null;
            //    node = View.Model.Application.Views[((listView != null) ? listView.Id : "") + ((detailView != null) ? detailView.Id : "")];
            //    if (node != null) {
            //        // Перебираем все подузлы
            //        // node.GetNode(1)	{ModelListViewFilters}	DevExpress.ExpressApp.Model.IModelNode {ModelListViewFilters}
            //        for (int i = 0; i < node.NodeCount; i++) {
            //IModelMiniNavigations miniNavigationNode = node.GetNode(i) as IModelMiniNavigations;
            IModelMiniNavigations miniNavigationNode = FindMiniNavigationModel(View);

            if (miniNavigationNode != null)
            {
                foreach (IModelMiniNavigationItem miniNavigationItem in miniNavigationNode.GetNodes <IModelMiniNavigationItem>())
                {
                    if (miniNavigationItem.NavigationPath == selId)
                    {
                        modelView = miniNavigationItem.View;
                        break;
                    }
                }
                //break;
            }
            //        }
            //    }
            //}


            Frame        resultFrame = frame; // Application.CreateFrame("new");
            TargetWindow openMode    = (TargetWindow)e.SelectedChoiceActionItem.Data;

            // Сбрасываем состояние списка
            MiniNavigationAction.SelectedItem  = null;
            MiniNavigationAction.SelectedIndex = 0;

            // Небольшая разборка с сочетанием значений openMode и типа текущего View - List или Detail - в целях
            // определения фрейма, в который грузить
            if (MasterDetailViewFrame != null && (openMode == TargetWindow.Current & (view as ListView) != null & ((frame as NestedFrame) != null | !view.IsRoot)))
            {
                // Тогда Current трактуем как корневое окно
                resultFrame = MasterDetailViewFrame;
                {
                    //IObjectSpace objectSpace = resultFrame.View.ObjectSpace;
                    IObjectSpace objectSpace       = resultFrame.Application.CreateObjectSpace(); // Всё равно предыдущий ObjectSpace теряется в этом случае
                    object       representativeObj = objectSpace.GetObject(obj);

                    View dv = null;

                    if (modelView != null)
                    {
                        if ((modelView as IModelDetailView) != null)
                        {
                            ViewID = (modelView as IModelDetailView).Id;
                            dv     = resultFrame.Application.CreateDetailView(objectSpace, ViewID, true, representativeObj) as DetailView;
                        }
                        else if ((modelView as IModelListView) != null)
                        {
                            ViewID = (modelView as IModelListView).Id;
                            //ListView dv = resultFrame.Application.CreateListView(objectSpace, ChoiceType, true);
                            CollectionSource colSource = new CollectionSource(objectSpace, ChoiceType);
                            if (!colSource.IsLoaded)
                            {
                                colSource.Reload();
                            }
                            dv = resultFrame.Application.CreateListView((modelView as IModelListView), colSource, true) as ListView;
                        }
                    }
                    else
                    {
                        ViewID = Application.FindDetailViewId(ChoiceType);
                        dv     = resultFrame.Application.CreateDetailView(objectSpace, ViewID, true, representativeObj) as DetailView;
                    }

                    resultFrame.SetView(dv, true, resultFrame);
                }
                return;
            }

            // Общий алгоритм
            {
                IObjectSpace objectSpace = null;

                // Анализ того, какой ObjectSpace нужен
                if ((frame as NestedFrame) != null | !view.IsRoot)
                {
                    objectSpace = resultFrame.View.ObjectSpace.CreateNestedObjectSpace();
                }
                //objectSpace = resultFrame.View.ObjectSpace.CreateNestedObjectSpace();
                if (objectSpace == null)
                {
                    objectSpace = resultFrame.Application.CreateObjectSpace();
                }

                object representativeObj = objectSpace.GetObject(obj);

                //ViewID = Application.FindDetailViewId(ChoiceType);
                //DetailView dv = frame.Application.CreateDetailView(objectSpace, ViewID, true, representativeObj);

                View dv = null;

                if (modelView != null)
                {
                    if ((modelView as IModelDetailView) != null)
                    {
                        ViewID = (modelView as IModelDetailView).Id;
                        dv     = resultFrame.Application.CreateDetailView(objectSpace, ViewID, true, representativeObj) as DetailView;
                    }
                    else if ((modelView as IModelListView) != null)
                    {
                        ViewID = (modelView as IModelListView).Id;
                        //ListView dv = resultFrame.Application.CreateListView(objectSpace, ChoiceType, true);
                        //objectSpace = resultFrame.Application.CreateObjectSpace();
                        CollectionSource colSource = new CollectionSource(objectSpace, ChoiceType);
                        if (!colSource.IsLoaded)
                        {
                            colSource.Reload();
                        }
                        dv = resultFrame.Application.CreateListView((modelView as IModelListView), colSource, true) as ListView;
                    }
                }
                else
                {
                    ViewID = Application.FindDetailViewId(ChoiceType);
                    dv     = resultFrame.Application.CreateDetailView(objectSpace, ViewID, true, representativeObj) as DetailView;
                }

                ShowViewParameters svp = new ShowViewParameters();
                svp.CreatedView          = dv;
                svp.TargetWindow         = openMode;
                svp.Context              = TemplateContext.View;
                svp.CreateAllControllers = true;

                e.ShowViewParameters.Assign(svp);
            }
        }
 void CustomizeShowViewParameters(LogicRuleInfo info, IObjectViewRule objectViewRule) {
     var customizeShowViewParametersEventArgs = ((CustomizeShowViewParametersEventArgs) info.EventArgs);
     var createdView = customizeShowViewParametersEventArgs.ShowViewParameters.CreatedView;
     if (createdView is DetailView) {
         _defaultObjectView = createdView.Model;
         customizeShowViewParametersEventArgs.ShowViewParameters.Controllers.Add(new InfoController(true){
             Model = _defaultObjectView
         });
         createdView.SetModel(objectViewRule.ObjectView);
     }
 }
Example #18
0
 internal SwNamedView(IModelDoc2 model, IModelView view, IMathUtility mathUtils, string name)
     : base(model, view, mathUtils)
 {
     Name = name;
 }
 public static View CreateView(this XafApplication application, IModelView viewModel)
 {
     return((View)application.CallMethod("CreateView", viewModel));
 }
Example #20
0
        public override PedidosCompras CreatePersitance(IModelView obj)
        {
            var viewmodel = obj as PedidosComprasModel;
            var result    = _db.Set <PedidosCompras>().Create();

            foreach (var item in result.GetType().GetProperties())
            {
                if ((obj.GetType().GetProperty(item.Name.FirstToUpper())?.PropertyType.IsGenericType ?? false) &&
                    (obj.GetType().GetProperty(item.Name.FirstToUpper())?.PropertyType.GetGenericTypeDefinition() !=
                     typeof(ICollection <>)))
                {
                    item.SetValue(result, obj.GetType().GetProperty(item.Name.FirstToUpper())?.GetValue(obj, null));
                }
                else if (obj.GetType().GetProperty(item.Name.FirstToUpper())?.PropertyType.IsEnum ?? false)
                {
                    item.SetValue(result, (int)obj.GetType().GetProperty(item.Name.FirstToUpper())?.GetValue(obj, null));
                }
                else if (!obj.GetType().GetProperty(item.Name.FirstToUpper())?.PropertyType.IsGenericType ?? false)
                {
                    item.SetValue(result, obj.GetType().GetProperty(item.Name.FirstToUpper())?.GetValue(obj, null));
                }
            }

            result.fechaalta             = DateTime.Now;
            result.fechamodificacion     = result.fechaalta;
            result.fkusuarioalta         = Context.Id;
            result.fkusuariomodificacion = Context.Id;
            result.fkpuertosfkpaises     = viewmodel.Fkpuertos.Fkpaises;
            result.fkpuertosid           = viewmodel.Fkpuertos.Id;

            result.empresa = Empresa;
            foreach (var item in viewmodel.Lineas)
            {
                var newItem = _db.Set <PedidosComprasLin>().Create();
                newItem.empresa          = Empresa;
                newItem.fkpedidoscompras = result.id;
                newItem.id                            = item.Id;
                newItem.fkarticulos                   = item.Fkarticulos;
                newItem.descripcion                   = item.Descripcion;
                newItem.lote                          = item.Lote;
                newItem.tabla                         = item.Tabla;
                newItem.cantidad                      = item.Cantidad;
                newItem.cantidadpedida                = item.Cantidadpedida;
                newItem.largo                         = item.Largo;
                newItem.ancho                         = item.Ancho;
                newItem.grueso                        = item.Grueso;
                newItem.fkunidades                    = item.Fkunidades;
                newItem.metros                        = item.Metros;
                newItem.precio                        = item.Precio;
                newItem.porcentajedescuento           = item.Porcentajedescuento;
                newItem.importedescuento              = item.Importedescuento;
                newItem.fktiposiva                    = item.Fktiposiva;
                newItem.porcentajeiva                 = item.Porcentajeiva;
                newItem.cuotaiva                      = item.Cuotaiva;
                newItem.porcentajerecargoequivalencia = item.Porcentajerecargoequivalencia ?? 0;
                newItem.cuotarecargoequivalencia      = item.Cuotarecargoequivalencia;
                newItem.importe                       = item.Importe;
                newItem.notas                         = item.Notas;
                newItem.canal                         = item.Canal;
                newItem.precioanterior                = item.Precioanterior;
                newItem.revision                      = item.Revision;
                newItem.decimalesmonedas              = item.Decimalesmonedas;
                newItem.decimalesmedidas              = item.Decimalesmedidas;
                newItem.fkpresupuestos                = item.Fkpresupuestos;
                newItem.fkpresupuestosid              = item.Fkpresupuestosid;
                newItem.fkpresupuestosreferencia      = item.Fkpresupuestosreferencia;
                newItem.orden                         = item.Orden;
                newItem.fkpedidosventas               = item.Fkpedidosventas;
                newItem.fkpedidosventasreferencia     = item.Fkpedidosventasreferencia;
                result.PedidosComprasLin.Add(newItem);
            }


            foreach (var item in viewmodel.Totales)
            {
                var newItem = _db.Set <PedidosComprasTotales>().Create();
                newItem.empresa          = Empresa;
                newItem.fkpedidoscompras = result.id;
                newItem.fktiposiva       = item.Fktiposiva;
                newItem.porcentajeiva    = item.Porcentajeiva;
                newItem.basetotal        = item.Baseimponible;
                newItem.brutototal       = item.Brutototal;
                newItem.cuotaiva         = item.Cuotaiva;
                newItem.porcentajerecargoequivalencia = item.Porcentajerecargoequivalencia;
                newItem.importerecargoequivalencia    = item.Importerecargoequivalencia;
                newItem.porcentajedescuentoprontopago = item.Porcentajedescuentoprontopago;
                newItem.importedescuentoprontopago    = item.Importedescuentoprontopago;
                newItem.porcentajedescuentocomercial  = item.Porcentajedescuentocomercial;
                newItem.importedescuentocomercial     = item.Importedescuentocomercial;
                newItem.subtotal         = item.Subtotal;
                newItem.decimalesmonedas = item.Decimalesmonedas;

                result.PedidosComprasTotales.Add(newItem);
            }

            return(result);
        }
Example #21
0
        protected override IEnumerable <IToolbaritem> EditToolbar(IGestionService service, IModelView model)
        {
            var result    = base.EditToolbar(service, model).ToList();
            var viewmodel = model as BundleModel;

            result.Add(new ToolbarSeparatorModel());
            result.Add(CreateComboImprimir(viewmodel));
            return(result);
        }
        public override void edit(IModelView obj)
        {
            using (var tran = TransactionScopeBuilder.CreateTransactionObject())
            {
                var model = obj as SeguimientosModel;
                var currentValidationService = _validationService as SeguimientosValidation;
                var estadoFinalizado         = new Estados();

                if (model.Tipo == (int)DocumentoEstado.Oportunidades)
                {
                    var modelPadre = _db.Oportunidades.Where(f => f.empresa == Empresa && f.referencia == model.Origen).FirstOrDefault();

                    if (model.Cerrado)
                    {
                        modelPadre.cerrado     = true;
                        modelPadre.fechacierre = model.Fecharesolucion;
                        modelPadre.fkreaccion  = model.Fkreaccion;
                        estadoFinalizado       = _db.Estados.Where(f => f.documento == (int)DocumentoEstado.Oportunidades && f.tipoestado == (int)TipoEstado.Finalizado).SingleOrDefault()
                                                 ?? _db.Estados.Where(f => f.documento == (int)DocumentoEstado.Todos && f.tipoestado == (int)TipoEstado.Finalizado).SingleOrDefault();
                    }

                    modelPadre.fketapa = model.Fketapa;
                    modelPadre.fechaultimoseguimiento = model.Fechadocumento;
                    if (model.Fechaproximoseguimiento != null)
                    {
                        modelPadre.fechaproximoseguimiento = model.Fechaproximoseguimiento;
                    }

                    var converterModel = FConverterModel.Instance.CreateConverterModelService <OportunidadesModel, Oportunidades>(_context, _db, Empresa);
                    var modelview      = converterModel.GetModelView(modelPadre);

                    //Rai
                    //Hay que tener en cuenta que si se edita un seguimiento, podrían cambiarle el coste,
                    //luego al grabar hay que restar el coste que tenga y sumar el que haya al grabarlo.
                    var antiguocosteSeguimiento = _db.Seguimientos.Where(f => f.empresa == Empresa && f.origen == model.Origen && f.id == model.Id).Select(f => f.coste).FirstOrDefault();
                    modelPadre.coste -= antiguocosteSeguimiento;
                    modelPadre.coste += model.Coste;

                    var service = FService.Instance.GetService(typeof(OportunidadesModel), _context);
                    service.edit(modelview);
                }
                else if (model.Tipo == (int)DocumentoEstado.Proyectos)
                {
                    var modelPadre = _db.Proyectos.Where(f => f.empresa == Empresa && f.referencia == model.Origen).FirstOrDefault();

                    if (model.Cerrado)
                    {
                        modelPadre.cerrado     = true;
                        modelPadre.fechacierre = model.Fecharesolucion;
                        modelPadre.fkreaccion  = model.Fkreaccion;
                        estadoFinalizado       = _db.Estados.Where(f => f.documento == (int)DocumentoEstado.Proyectos && f.tipoestado == (int)TipoEstado.Finalizado).SingleOrDefault()
                                                 ?? _db.Estados.Where(f => f.documento == (int)DocumentoEstado.Todos && f.tipoestado == (int)TipoEstado.Finalizado).SingleOrDefault();
                    }

                    modelPadre.fketapa = model.Fketapa;
                    modelPadre.fechaultimoseguimiento = model.Fechadocumento;
                    if (model.Fechaproximoseguimiento != null)
                    {
                        modelPadre.fechaproximoseguimiento = model.Fechaproximoseguimiento;
                    }

                    var converterModel = FConverterModel.Instance.CreateConverterModelService <ProyectosModel, Proyectos>(_context, _db, Empresa);
                    var modelview      = converterModel.GetModelView(modelPadre);

                    //Rai
                    //Hay que tener en cuenta que si se edita un seguimiento, podrían cambiarle el coste,
                    //luego al grabar hay que restar el coste que tenga y sumar el que haya al grabarlo.
                    var antiguocosteSeguimiento = _db.Seguimientos.Where(f => f.empresa == Empresa && f.origen == model.Origen && f.id == model.Id).Select(f => f.coste).FirstOrDefault();
                    modelPadre.coste -= antiguocosteSeguimiento;
                    modelPadre.coste += model.Coste;

                    var service = FService.Instance.GetService(typeof(ProyectosModel), _context);
                    service.edit(modelview);
                }
                else if (model.Tipo == (int)DocumentoEstado.Campañas)
                {
                    var modelPadre = _db.Campañas.Where(f => f.empresa == Empresa && f.referencia == model.Origen).FirstOrDefault();

                    if (model.Cerrado)
                    {
                        modelPadre.cerrado     = true;
                        modelPadre.fechacierre = model.Fecharesolucion;
                        modelPadre.fkreaccion  = model.Fkreaccion;
                        estadoFinalizado       = _db.Estados.Where(f => f.documento == (int)DocumentoEstado.Campañas && f.tipoestado == (int)TipoEstado.Finalizado).SingleOrDefault()
                                                 ?? _db.Estados.Where(f => f.documento == (int)DocumentoEstado.Todos && f.tipoestado == (int)TipoEstado.Finalizado).SingleOrDefault();
                    }

                    modelPadre.fketapa = model.Fketapa;
                    modelPadre.fechaultimoseguimiento = model.Fechadocumento;
                    if (model.Fechaproximoseguimiento != null)
                    {
                        modelPadre.fechaproximoseguimiento = model.Fechaproximoseguimiento;
                    }

                    var converterModel = FConverterModel.Instance.CreateConverterModelService <CampañasModel, Campañas>(_context, _db, Empresa);
                    var modelview      = converterModel.GetModelView(modelPadre);

                    //Rai
                    //Hay que tener en cuenta que si se edita un seguimiento, podrían cambiarle el coste,
                    //luego al grabar hay que restar el coste que tenga y sumar el que haya al grabarlo.
                    var antiguocosteSeguimiento = _db.Seguimientos.Where(f => f.empresa == Empresa && f.origen == model.Origen && f.id == model.Id).Select(f => f.coste).FirstOrDefault();
                    modelPadre.coste -= antiguocosteSeguimiento;
                    modelPadre.coste += model.Coste;

                    var service = FService.Instance.GetService(typeof(CampañasModel), _context);
                    service.edit(modelview);
                }
                else if (model.Tipo == (int)DocumentoEstado.Incidencias)
                {
                    var modelPadre = _db.IncidenciasCRM.Where(f => f.empresa == Empresa && f.referencia == model.Origen).FirstOrDefault();

                    if (model.Cerrado)
                    {
                        modelPadre.cerrado     = true;
                        modelPadre.fechacierre = model.Fecharesolucion;
                        modelPadre.fkreaccion  = model.Fkreaccion;
                        estadoFinalizado       = _db.Estados.Where(f => f.documento == (int)DocumentoEstado.Incidencias && f.tipoestado == (int)TipoEstado.Finalizado).SingleOrDefault()
                                                 ?? _db.Estados.Where(f => f.documento == (int)DocumentoEstado.Todos && f.tipoestado == (int)TipoEstado.Finalizado).SingleOrDefault();
                    }

                    modelPadre.fketapa = model.Fketapa;
                    modelPadre.fechaultimoseguimiento = model.Fechadocumento;
                    if (model.Fechaproximoseguimiento != null)
                    {
                        modelPadre.fechaproximoseguimiento = model.Fechaproximoseguimiento;
                    }

                    var converterModel = FConverterModel.Instance.CreateConverterModelService <IncidenciasCRMModel, IncidenciasCRM>(_context, _db, Empresa);
                    var modelview      = converterModel.GetModelView(modelPadre);

                    //Rai
                    //Hay que tener en cuenta que si se edita un seguimiento, podrían cambiarle el coste,
                    //luego al grabar hay que restar el coste que tenga y sumar el que haya al grabarlo.
                    var antiguocosteSeguimiento = _db.Seguimientos.Where(f => f.empresa == Empresa && f.origen == model.Origen && f.id == model.Id).Select(f => f.coste).FirstOrDefault();
                    modelPadre.coste -= antiguocosteSeguimiento;
                    modelPadre.coste += model.Coste;

                    var service = FService.Instance.GetService(typeof(IncidenciasCRMModel), _context);
                    service.edit(modelview);
                }

                var etapaAnterior  = _db.Seguimientos.Where(f => f.empresa == model.Empresa && f.id == model.Id).Select(f => f.fketapa).SingleOrDefault();
                var s              = etapaAnterior.Split('-');
                var documento      = Funciones.Qint(s[0]);
                var id             = s[1];
                var estadoAnterior = _db.Estados.Where(f => f.documento == documento && f.id == id).Select(f => f.tipoestado).SingleOrDefault();

                if (model.Cerrado && (estadoAnterior != (int)TipoEstado.Finalizado && estadoAnterior != (int)TipoEstado.Caducado && estadoAnterior != (int)TipoEstado.Anulado))
                {
                    model.Fketapa = estadoFinalizado.documento + "-" + estadoFinalizado.id;
                    currentValidationService.CambiarEstado = true;
                }

                base.edit(obj);

                _db.SaveChanges();
                tran.Complete();
            }
        }
 public IModelViewObject(IModelView IModelViewinstance)
 {
     IModelViewInstance = IModelViewinstance;
 }
Example #24
0
        public override Presupuestos EditPersitance(IModelView obj)
        {
            var viewmodel = obj as PresupuestosModel;
            var result    = _db.Set <Presupuestos>().Where(f => f.empresa == Empresa && f.id == viewmodel.Id).Include(f => f.PresupuestosLin).Include(f => f.PresupuestosTotales).Single();

            //todo asignar
            foreach (var item in result.GetType().GetProperties())
            {
                if ((obj.GetType().GetProperty(item.Name.FirstToUpper())?.PropertyType.IsGenericType ?? false) &&
                    (obj.GetType().GetProperty(item.Name.FirstToUpper())?.PropertyType.GetGenericTypeDefinition() !=
                     typeof(ICollection <>)))
                {
                    item.SetValue(result, obj.GetType().GetProperty(item.Name.FirstToUpper())?.GetValue(obj, null));
                }
                else if (obj.GetType().GetProperty(item.Name.FirstToUpper())?.PropertyType.IsEnum ?? false)
                {
                    item.SetValue(result, (int)obj.GetType().GetProperty(item.Name.FirstToUpper())?.GetValue(obj, null));
                }
                else if (!obj.GetType().GetProperty(item.Name.FirstToUpper())?.PropertyType.IsGenericType ?? false)
                {
                    item.SetValue(result, obj.GetType().GetProperty(item.Name.FirstToUpper())?.GetValue(obj, null));
                }
            }
            //todo asignar contador y referencia
            result.fechamodificacion     = DateTime.Now;
            result.fkusuariomodificacion = Context.Id;
            result.fkpuertosfkpaises     = viewmodel.Fkpuertos.Fkpaises;
            result.fkpuertosid           = viewmodel.Fkpuertos.Id;

            result.PresupuestosLin.Clear();
            foreach (var item in viewmodel.Lineas)
            {
                var newItem = _db.Set <PresupuestosLin>().Create();
                newItem.empresa                       = result.empresa;
                newItem.fkpresupuestos                = result.id;
                newItem.id                            = item.Id;
                newItem.fkarticulos                   = item.Fkarticulos;
                newItem.descripcion                   = item.Descripcion;
                newItem.lote                          = item.Lote;
                newItem.tabla                         = item.Tabla;
                newItem.cantidad                      = item.Cantidad;
                newItem.cantidadpedida                = item.Cantidadpedida;
                newItem.largo                         = item.Largo;
                newItem.ancho                         = item.Ancho;
                newItem.grueso                        = item.Grueso;
                newItem.fkunidades                    = item.Fkunidades;
                newItem.metros                        = item.Metros;
                newItem.precio                        = item.Precio;
                newItem.porcentajedescuento           = item.Porcentajedescuento;
                newItem.importedescuento              = item.Importedescuento;
                newItem.fktiposiva                    = item.Fktiposiva;
                newItem.porcentajeiva                 = item.Porcentajeiva;
                newItem.cuotaiva                      = item.Cuotaiva;
                newItem.porcentajerecargoequivalencia = item.Porcentajerecargoequivalencia ?? 0;
                newItem.cuotarecargoequivalencia      = item.Cuotarecargoequivalencia;
                newItem.importe                       = item.Importe;
                newItem.notas                         = item.Notas;
                newItem.canal                         = item.Canal;
                newItem.precioanterior                = item.Precioanterior;
                newItem.revision                      = item.Revision;
                newItem.decimalesmonedas              = item.Decimalesmonedas;
                newItem.decimalesmedidas              = item.Decimalesmedidas;
                newItem.orden                         = item.Orden;
                newItem.integridadreferenciaflag      = item.Integridadreferenciaflag;
                newItem.intaux                        = item.Intaux;
                result.PresupuestosLin.Add(newItem);
            }

            result.PresupuestosTotales.Clear();
            foreach (var item in viewmodel.Totales)
            {
                var newItem = _db.Set <PresupuestosTotales>().Create();
                newItem.empresa        = result.empresa;
                newItem.fkpresupuestos = result.id;
                newItem.fktiposiva     = item.Fktiposiva;
                newItem.porcentajeiva  = item.Porcentajeiva;
                newItem.basetotal      = item.Baseimponible;
                newItem.brutototal     = item.Brutototal;
                newItem.cuotaiva       = item.Cuotaiva;
                newItem.porcentajerecargoequivalencia = item.Porcentajerecargoequivalencia;
                newItem.importerecargoequivalencia    = item.Importerecargoequivalencia;
                newItem.porcentajedescuentoprontopago = item.Porcentajedescuentoprontopago;
                newItem.importedescuentoprontopago    = item.Importedescuentoprontopago;
                newItem.porcentajedescuentocomercial  = item.Porcentajedescuentocomercial;
                newItem.importedescuentocomercial     = item.Importedescuentocomercial;
                newItem.subtotal         = item.Subtotal;
                newItem.decimalesmonedas = item.Decimalesmonedas;
                result.PresupuestosTotales.Add(newItem);
            }

            result.PresupuestosComponentesLin.Clear();
            foreach (var item in viewmodel.Componentes)
            {
                var newItem = _db.Set <PresupuestosComponentesLin>().Create();
                newItem.empresa                  = Empresa;
                newItem.fkpresupuestos           = result.id;
                newItem.id                       = item.Id;
                newItem.idcomponente             = item.IdComponente;
                newItem.integridadreferenciaflag = item.Integridadreferenciaflag;
                newItem.descripcioncomponente    = item.Descripcioncomponente; newItem.piezas = item.Piezas;
                newItem.piezas                   = item.Piezas;
                newItem.largo                    = item.Largo;
                newItem.ancho                    = item.Ancho;
                newItem.grueso                   = item.Grueso;
                newItem.merma                    = item.Merma;
                newItem.precio                   = item.Precio;
                newItem.precioinicial            = item.PrecioInicial;
                newItem.idlineaarticulo          = item.Idlineaarticulo.Value;
                result.PresupuestosComponentesLin.Add(newItem);
            }
            return(result);
        }
        protected override INotifyPropertyChanged GetItemCopy(IModelView view, INotifyPropertyChanged item)
        {
            ICondition condCopy = ((ICondition)item).InstallInView(view);

            return(condCopy);
        }
Example #26
0
 public EditPlanningSettingsUseCase(IModelView <EditPlanningSettingsViewModel> view, ICalculationDataProvider dataProvider)
 {
     this.view         = view;
     this.dataProvider = dataProvider;
 }
Example #27
0
 internal SwModelView(IModelDoc2 model, IModelView view, IMathUtility mathUtils)
 {
     View        = view;
     m_Model     = model;
     m_MathUtils = mathUtils;
 }
        protected override IEnumerable <IToolbaritem> EditToolbar(IGestionService service, IModelView model)
        {
            var objModel = model as AlbaranesModel;
            var result   = base.EditToolbar(service, model).ToList();

            result.Add(new ToolbarSeparatorModel());

            result.Add(new ToolbarActionModel()
            {
                Icono = "fa fa-copy",
                Texto = General.LblClonar,
                Url   = Url.Action("Clonar", new { id = objModel.Id })
            });

            if (objModel.Tipoalbaran < (int)TipoAlbaran.Devolucion)
            {
                result.Add(new ToolbarActionModel()
                {
                    Icono = "fa fa-share",
                    Texto = Albaranes.LblGestionDevoluciones,
                    Url   = "javascript:CallGenerarDevolucion();"
                });
            }

            result.Add(new ToolbarSeparatorModel());

            if (objModel.Tipoalbaran < (int)TipoAlbaran.Reclamacion)
            {
                result.Add(new ToolbarActionModel()
                {
                    Icono = "fa fa-archive",
                    Texto = RAlbaranes.LblGestionContenedores,
                    Url   = "javascript:CallGenerarContenedores();"
                });

                result.Add(new ToolbarSeparatorModel());
            }


            if (!string.IsNullOrEmpty(objModel.Fkseriefactura) && objModel.Estado?.Tipoestado < TipoEstado.Finalizado)
            {
                result.Add(new ToolbarActionModel()
                {
                    Icono = "fa fa-gear",
                    Texto = General.LblFacturar,
                    Url   = "javascript:CallFacturarAlbaran()"
                });
            }

            result.Add(new ToolbarSeparatorModel());
            result.Add(CreateComboImprimir(objModel));
            result.Add(new ToolbarActionModel()
            {
                Icono = "fa fa-envelope-o",
                OcultarTextoSiempre = true,
                Texto = General.LblEnviaremail,
                Url   = "javascript:eventAggregator.Publish('Enviaralbaran',\'\')"
            });
            result.Add(new ToolbarSeparatorModel());
            result.Add(CreateComboEstados(objModel));
            return(result);
        }
Example #29
0
        public override void create(IModelView obj)
        {
            using (var tran = Marfil.Inf.Genericos.Helper.TransactionScopeBuilder.CreateTransactionObject())
            {
                var model      = obj as AlbaranesModel;
                var validation = _validationService as AlbaranesValidation;
                validation.EjercicioId = EjercicioId;

                //Calculo ID
                var contador = ServiceHelper.GetNextId <Albaranes>(_db, Empresa, model.Fkseries);
                var identificadorsegmento = "";
                model.Referencia            = ServiceHelper.GetReference <Albaranes>(_db, model.Empresa, model.Fkseries, contador, model.Fechadocumento.Value, out identificadorsegmento);
                model.Identificadorsegmento = identificadorsegmento;

                DocumentosHelpers.GenerarCarpetaAsociada(model, TipoDocumentos.AlbaranesVentas, _context, _db);

                //Actualizar precios si estos son = 0
                ApplicationHelper app = new ApplicationHelper(_context);

                if (app.GetListTiposAlbaranes().Where(f => f.EnumInterno == model.Tipoalbaran).Select(f => f.CosteAdq).SingleOrDefault())
                {
                    foreach (var l in model.Lineas)
                    {
                        if (l.Importe == null || l.Importe == 0)
                        {
                            var lotesService = new LotesService(_context);
                            l.Precio = Math.Round((double)_db.Stockhistorico.Where(f => f.empresa == _context.Empresa && f.lote == l.Lote && f.loteid == l.Tabla.ToString() && f.fkarticulos == l.Fkarticulos)
                                                  .Select(f => f.preciovaloracion + f.costeacicionalvariable / f.metrosentrada + f.costeadicionalmaterial / f.metrosentrada
                                                          + f.costeadicionalotro / f.metrosentrada + f.costeadicionalportes / f.metrosentrada).SingleOrDefault(), 2);
                            l.Importe = Math.Round((double)((decimal)l.Precio * (decimal)l.Metros), l.Decimalesmonedas ?? 2);
                        }
                    }
                }

                if (!string.IsNullOrWhiteSpace(model.Fkpedidos))
                {
                    foreach (var lineaAlbaran in model.Lineas)
                    {
                        if (lineaAlbaran.Precio == 0)
                        {
                            var idPedido     = _db.Pedidos.Where(f => f.empresa == model.Empresa && f.referencia == model.Fkpedidos).Select(f => f.id).SingleOrDefault();
                            var lineasPedido = _db.PedidosLin.Where(f => f.empresa == model.Empresa && f.fkpedidos == idPedido);

                            foreach (var lineaPedido in lineasPedido)
                            {
                                if (lineaAlbaran.Fkarticulos == lineaPedido.fkarticulos)
                                {
                                    lineaAlbaran.Precio  = lineaPedido.precio;
                                    lineaAlbaran.Importe = Math.Round((double)((lineaAlbaran.Metros * lineaAlbaran.Precio) - (lineaAlbaran.Metros * lineaAlbaran.Precio *
                                                                                                                              (lineaAlbaran.Porcentajedescuento / 100))), 2);
                                }
                            }
                        }
                    }
                }
                //fin actualizar precios

                base.create(obj);

                ModificarCantidadesPedidasPedidos(obj as AlbaranesModel);
                ModificarMovimientosArticulos(obj as AlbaranesModel);

                _db.SaveChanges();
                tran.Complete();
            }
        }
Example #30
0
        protected override IEnumerable <IToolbaritem> EditToolbar(IGestionService service, IModelView model)
        {
            var objModel = model as PedidosModel;
            var result   = base.EditToolbar(service, model).ToList();

            result.Add(new ToolbarSeparatorModel());
            if (objModel.Estado?.Tipoestado < TipoEstado.Finalizado)
            {
                result.Add(new ToolbarActionModel()
                {
                    Icono = "fa fa-gear",
                    Texto = General.LblGenerarAlbaran,
                    Url   = Url.Action("Importar", "Albaranes", new { id = objModel.Id, returnUrl = Url.Action("Edit", new { id = objModel.Id }) })
                });

                result.Add(new ToolbarActionModel()
                {
                    Icono = "fa fa-gear",
                    Texto = General.LblGenerarEntrega,
                    Url   = Url.Action("Importar", "EntregasStock", new { id = objModel.Id, returnUrl = Url.Action("Edit", new { id = objModel.Id }) })
                });
            }

            result.Add(new ToolbarActionModel()
            {
                Icono = "fa fa-gear",
                Texto = PedidosCompras.Generarpedidoscompras,
                Url   = Url.Action("GenerarPedidosCompra", "Pedidos", new { pedido = objModel.Referencia })
            });

            result.Add(new ToolbarActionModel()
            {
                Icono = "fa fa-gear",
                Texto = General.LblGenerarImputacionMateriales,
                Url   = Url.Action("ImputacionMateriales", "EntregasStock", new { id = objModel.Id, returnUrl = Url.Action("Edit", new { id = objModel.Id }) })
            });

            result.Add(new ToolbarActionModel()
            {
                Icono = "fa fa-copy",
                Texto = General.LblClonar,
                Url   = Url.Action("Clonar", new { id = objModel.Id })
            });

            result.Add(new ToolbarSeparatorModel());
            result.Add(CreateComboImprimir(objModel));
            result.Add(new ToolbarActionModel()
            {
                Icono = "fa fa-envelope-o",
                OcultarTextoSiempre = true,
                Texto = General.LblEnviaremail,
                Url   = "javascript:eventAggregator.Publish('Enviarpedido',\'\')"
            });
            result.Add(new ToolbarSeparatorModel());
            result.Add(CreateComboEstados(objModel));
            return(result);
        }
Example #31
0
        public override Transformaciones EditPersitance(IModelView obj)
        {
            var viewmodel = obj as TransformacionesModel;
            var result    = _db.Transformaciones.Where(f => f.empresa == viewmodel.Empresa && f.id == viewmodel.Id).Include(b => b.Transformacionesentradalin).Include(b => b.Transformacionessalidalin).Include(b => b.Transformacionescostesadicionales).ToList().Single();

            //todo asignar
            foreach (var item in result.GetType().GetProperties())
            {
                if ((obj.GetType().GetProperty(item.Name.FirstToUpper())?.PropertyType.IsGenericType ?? false) &&
                    (obj.GetType().GetProperty(item.Name.FirstToUpper())?.PropertyType.GetGenericTypeDefinition() !=
                     typeof(ICollection <>)))
                {
                    item.SetValue(result, obj.GetType().GetProperty(item.Name.FirstToUpper())?.GetValue(obj, null));
                }
                else if (obj.GetType().GetProperty(item.Name.FirstToUpper())?.PropertyType.IsEnum ?? false)
                {
                    item.SetValue(result, (int)obj.GetType().GetProperty(item.Name.FirstToUpper())?.GetValue(obj, null));
                }
                else if (!obj.GetType().GetProperty(item.Name.FirstToUpper())?.PropertyType.IsGenericType ?? false)
                {
                    item.SetValue(result, obj.GetType().GetProperty(item.Name.FirstToUpper())?.GetValue(obj, null));
                }
            }
            //todo asignar contador y referencia

            result.fechamodificacion     = DateTime.Now;
            result.fkusuariomodificacion = Context.Id;
            result.tipoalmacenlote       = (int?)viewmodel.Tipodealmacenlote;

            result.Transformacionesentradalin.Clear();

            foreach (var item in viewmodel.Lineasentrada)
            {
                var newItem = _db.Set <Transformacionesentradalin>().Create();
                newItem.id                     = item.Id;
                newItem.fkarticulos            = item.Fkarticulos;
                newItem.descripcion            = item.Descripcion;
                newItem.lote                   = item.Lote;
                newItem.tabla                  = item.Tabla;
                newItem.cantidad               = item.Cantidad;
                newItem.largo                  = item.Largo;
                newItem.ancho                  = item.Ancho;
                newItem.grueso                 = item.Grueso;
                newItem.fkunidades             = item.Fkunidades;
                newItem.metros                 = item.Metros;
                newItem.notas                  = item.Notas;
                newItem.canal                  = item.Canal;
                newItem.revision               = item.Revision;
                newItem.decimalesmonedas       = item.Decimalesmonedas;
                newItem.decimalesmedidas       = item.Decimalesmedidas;
                newItem.orden                  = item.Orden ?? item.Id;
                newItem.costeacicionalvariable = item.Costeadicionalvariable;
                newItem.costeadicionalmaterial = item.Costeadicionalmaterial;
                newItem.costeadicionalotro     = item.Costeadicionalotro;
                newItem.costeadicionalportes   = item.Costeadicionalportes;
                newItem.precio                 = item.Precio;
                newItem.flagidentifier         = item.Flagidentifier;
                newItem.loteautomaticoid       = item.Loteautomaticoid;
                newItem.lotenuevocontador      = item.Lotenuevocontador;
                newItem.nuevo                  = item.Nueva;
                result.Transformacionesentradalin.Add(newItem);
            }

            result.Transformacionessalidalin.Clear();
            foreach (var item in viewmodel.Lineassalida)
            {
                var newItem = _db.Set <Transformacionessalidalin>().Create();
                newItem.id               = item.Id;
                newItem.fkarticulos      = item.Fkarticulos;
                newItem.descripcion      = item.Descripcion;
                newItem.lote             = item.Lote;
                newItem.tabla            = item.Tabla;
                newItem.cantidad         = item.Cantidad;
                newItem.largo            = item.Largo;
                newItem.ancho            = item.Ancho;
                newItem.grueso           = item.Grueso;
                newItem.fkunidades       = item.Fkunidades;
                newItem.metros           = item.Metros;
                newItem.notas            = item.Notas;
                newItem.canal            = item.Canal;
                newItem.revision         = item.Revision;
                newItem.decimalesmonedas = item.Decimalesmonedas;
                newItem.decimalesmedidas = item.Decimalesmedidas;
                newItem.orden            = item.Orden ?? item.Id;
                newItem.precio           = item.Precio;
                newItem.flagidentifier   = item.Flagidentifier;
                result.Transformacionessalidalin.Add(newItem);
            }
            result.Transformacionescostesadicionales.Clear();
            foreach (var item in viewmodel.Costes)
            {
                var newItem = _db.Set <Transformacionescostesadicionales>().Create();
                newItem.empresa            = Empresa;
                newItem.fktransformaciones = result.id;
                newItem.id                  = item.Id;
                newItem.tipodocumento       = (int)item.Tipodocumento;
                newItem.referenciadocumento = item.Referenciadocumento;
                newItem.importe             = item.Importe;
                newItem.porcentaje          = item.Porcentaje;
                newItem.total               = item.Total;
                newItem.tipocoste           = (int)item.Tipocoste;
                newItem.tiporeparto         = (int)item.Tiporeparto;
                newItem.notas               = item.Notas;
                result.Transformacionescostesadicionales.Add(newItem);
            }
            return(result);
        }
Example #32
0
 public void RenderView(IModelView<IRenderableModelState> modelView)
 {
     modelView.Set(_modelState);
 }
 public DocView(SwAddin addin, IModelView mv, DocumentEventHandler doc)
 {
     userAddin = addin;
     mView = (ModelView)mv;
     iSwApp = (ISldWorks)userAddin.SwApp;
     parent = doc;
 }
Example #34
0
 public static CompositeView NewView(this DevExpress.ExpressApp.XafApplication application, IModelView modelView)
 {
     return((CompositeView)application.CallMethod("CreateView", modelView));
 }
Example #35
0
 internal SwModelView(IModelDoc2 model, IModelView view, IMathUtility mathUtils) : base(view)
 {
     View        = view;
     Owner       = model;
     m_MathUtils = mathUtils;
 }
        protected override IEnumerable <IToolbaritem> EditToolbar(IGestionService service, IModelView model)
        {
            var objModel = model as FacturasComprasModel;
            var result   = base.EditToolbar(service, model).ToList();

            result.Add(new ToolbarSeparatorModel());
            if (objModel.Estado.Tipoestado < TipoEstado.Finalizado)
            {
                result.Add(new ToolbarActionModel()
                {
                    Icono = "fa fa-gear",
                    Texto = General.LblContabilizar,
                    Url   = Url.Action("Contabilizar", "Movs", new { IdFactura = objModel.Id, NombreTipo = typeof(FacturasComprasModel).ToString(), returnUrl = Url.Action("Edit", new { id = objModel.Id }) })
                });
                result.Add(new ToolbarSeparatorModel());
            }
            result.Add(CreateComboImprimir(objModel));
            result.Add(new ToolbarActionModel()
            {
                Icono = "fa fa-envelope-o",
                OcultarTextoSiempre = true,
                Texto = General.LblEnviaremail,
                Url   = "javascript:eventAggregator.Publish('Enviarfactura',\'\')"
            });
            if (objModel.Estado.Tipoestado < TipoEstado.Finalizado)
            {
                result.Add(new ToolbarSeparatorModel());
                result.Add(CreateComboEstados(objModel));
            }
            return(result);
        }
Example #37
0
 public override void delete(IModelView obj)
 {
     using (var tran = TransactionScopeBuilder.CreateTransactionObject())
     {
     }
 }
 public MouseEventHandler(SwAddin addin, IModelView mv, DocumentEventHandler doc)
 {
     userAddin = addin;
     mView = (ModelView)mv;
     mMouse = mView.GetMouse();
     iSwApp = (ISldWorks)userAddin.SwApp;
     parent = doc;
 }
        protected override IEnumerable <IToolbaritem> EditToolbar(IGestionService service, IModelView model)
        {
            var list           = base.EditToolbar(service, model).ToList();
            var nuevoregistro  = list.OfType <IToolbarActionModel>().Single(f => f.Texto == General.BtnNuevoRegistro);
            var borrarregistro = list.OfType <IToolbarActionModel>().Single(f => f.Texto == General.LblBorrar);

            list.Remove(nuevoregistro);
            list.Remove(borrarregistro);
            return(list);
        }