Ejemplo n.º 1
0
        public List <ModelViewInventory> GetInventory(ModelViewUserG Data)
        {
            var NegocioUsuario  = new BusinessUsers();
            var NegocioEmpleado = new BusinessEmployee();
            var NegocioModulo   = new BusinessModuleService();
            var NegocioRecf     = new BusinessREFACCIONES();
            var dataUsuario     = NegocioUsuario.GetUserByToken(Data.TokenUser);
            var empleado        = NegocioEmpleado.GetByUserID(dataUsuario.UserID);

            if (Data.TokenApp != GlobalConfiguration.TokenWEB)
            {
                if (Data.TokenApp != GlobalConfiguration.TokenMobile)
                {
                    throw new Exception("TokenInvalid");
                }
            }
            if (dataUsuario == null)
            {
                throw new Exception("UserPasswordInvalid");
            }

            var modulo = NegocioModulo.GetAll().Where(a => empleado.Select(p => p.FK_ModuleID).ToList().Contains(a.ModuleID));

            var lt = NegocioRecf.GetAllRefc(DateTime.Now.Date, modulo.Select(p => p.ID).ToList(), empleado.Select(p => p.StoreProp).ToList()).Select(p => new ModelViewInventory()
            {
                RefManID = p.ID_REF,
                Quantity = p.TOTDISP.Value
            }).ToList();

            if (lt.Count == 0)
            {
                ModelViewInventory model = new ModelViewInventory();
                lt.Add(model);
            }
            return(lt);
        }
Ejemplo n.º 2
0
        public List <ModelViewGuarantyBOM> GetLisValidationBOM(ModelViewUserG objCred)
        {
            var NegocioUsuario  = new BusinessUsers();
            var NegocioEmpleado = new BusinessEmployee();
            var dataUsuario     = NegocioUsuario.GetUserByToken(objCred.TokenUser);
            var empleado        = NegocioEmpleado.GetByUserID(dataUsuario.UserID);

            if (objCred.TokenApp != GlobalConfiguration.TokenWEB)
            {
                if (objCred.TokenApp != GlobalConfiguration.TokenMobile)
                {
                    throw new Exception("TokenInvalid");
                }
            }
            if (dataUsuario == null)
            {
                throw new Exception("UserPasswordInvalid");
            }

            //var lista = new List<EntityValidationGuarantyBOM>();

            var lt = new List <EntityValidationGuarantyBOM>();

            if (objCred.Date == null)
            {
                lt = GetAll();
            }
            else
            {
                lt = GetAll().Where(p => p.ModifyDate >= objCred.Date).ToList();
            }
            return(lt.Select(p => new ModelViewGuarantyBOM()
            {
                ValidationGuarantySparePartID = p.PK_ValidationGuarantySparePartID,
                ProductID = p.FK_ProducID.HasValue ? p.FK_ProducID.Value : 0,
                BuildOfMaterialsID = p.FK_BuildOfMaterialsID.HasValue ? p.FK_BuildOfMaterialsID.Value : 0,
                SalesOrganization = p.SalesOrganization,
                SparePartsID = p.SparePartsID,
                Model = p.Model,
                ClientID = p.ClientID,
                Months = p.Months,
                ValidFrom = p.ValidFrom.Value.ToString("yyyy-MM-dd"),
                ValidTo = p.ValidTo.Value.ToString("yyyy-MM-dd"),
            }).ToList <ModelViewGuarantyBOM>());


            //var NegocioOrdenes = new BusinessOrder();
            //var NegocioBase = new BusinessInstalledBase();
            //var ordenes = NegocioOrdenes.GetAll().Where(p => empleado.Select(q => q.PK_EmployeeID).ToArray<int>().Contains(p.FK_EmployeeID.Value) && p.OrderExecuteDate >= objCred.Date.Value.Date);
            //var prod = NegocioBase.GetAll();
            //var modelos = (from c in ordenes
            //               join p in prod on c.FK_InstalledBaseID equals p.PK_InstalledBaseID
            //               select p.FK_ProductID).Distinct();
            //var lista = GetAll();
            //return (from d in lista
            //        join e in modelos on d.FK_ProducID equals e
            //        select new ModelViewGuarantyBOM()
            //        {
            //            ValidationGuarantySparePartID = d.PK_ValidationGuarantySparePartID,
            //            ProductID = d.FK_ProducID.HasValue ? d.FK_ProducID.Value : 0,
            //            BuildOfMaterialsID = d.FK_BuildOfMaterialsID.HasValue ? d.FK_BuildOfMaterialsID.Value : 0,
            //            SalesOrganization = d.SalesOrganization,
            //            SparePartsID = d.SparePartsID,
            //            Model = d.Model,
            //            ClientID = d.ClientID,
            //            Months = d.Months,
            //            ValidFrom = d.ValidFrom.Value.ToString("yyyy-MM-dd"),
            //            ValidTo = d.ValidTo.Value.ToString("yyyy-MM-dd"),
            //        }).ToList<ModelViewGuarantyBOM>();
        }
Ejemplo n.º 3
0
        public List <ModelViewFolios> GetLastFolio(ModelViewUserG objCred)
        {
            var NegocioPoliza   = new BusinessPolicy();
            var NegocioRef      = new BusinessRefsell();
            var NegocioOrden    = new BusinessOrder();
            var NegocioUsuario  = new BusinessUsers();
            var NegocioEmpleado = new BusinessEmployee();
            var dataUsuario     = NegocioUsuario.GetUserByToken(objCred.TokenUser);

            if (objCred.TokenApp != GlobalConfiguration.TokenWEB)
            {
                if (objCred.TokenApp != GlobalConfiguration.TokenMobile)
                {
                    throw new Exception("TokenInvalid");
                }
            }
            if (dataUsuario == null)
            {
                throw new Exception("UserPasswordInvalid");
            }


            DateTime date = objCred.Date.Value;


            List <ModelViewFolios> x = new List <ModelViewFolios>();

            var Empleado2 = NegocioEmpleado.GetEmployeUser(dataUsuario.UserID);
            var Empleado  = Empleado2[0];

            int Conteo;
            List <EntityQuotation> Cotizaciones;
            List <EntityPolicy>    Polizas;
            List <EntityRefSell>   Refacciones;

            string Tipo;
            int    count = 1;

            while (count < 4)
            {
                switch (count)
                {
                case 1:

                    Tipo         = "Cotizacion";
                    Conteo       = GetByEmpoyeeDate(Empleado.PK_EmployeeID, date).Count;
                    Cotizaciones = GetByEmpoyeeDate(Empleado.PK_EmployeeID, date);

                    var LastFolio = Cotizaciones.Count is 0 ? "": Cotizaciones[0].Folio;

                    x.Add(new ModelViewFolios(Tipo, Conteo, LastFolio));
                    count++;

                    break;

                case 2:
                    Tipo    = "Polizas";
                    Conteo  = NegocioPoliza.GetByEmpoyeeDate(Empleado.PK_EmployeeID, date).Count;
                    Polizas = NegocioPoliza.GetByEmpoyeeDate(Empleado.PK_EmployeeID, date);

                    LastFolio = Polizas.Count is 0 ? "" : Polizas[0].IDPolicy;

                    x.Add(new ModelViewFolios(Tipo, Conteo, LastFolio));
                    count++;
                    break;

                case 3:
                    Tipo        = "Refacciones";
                    Conteo      = NegocioRef.GetByEmpoyeeDate(Empleado.PK_EmployeeID, date).Count;
                    Refacciones = NegocioRef.GetByEmpoyeeDate(Empleado.PK_EmployeeID, date);
                    LastFolio   = Refacciones.Count is 0 ? "" : Refacciones[0].IDRefSell;

                    x.Add(new ModelViewFolios(Tipo, Conteo, LastFolio));
                    count++;
                    break;

                default:

                    count++;
                    break;
                }
            }



            return(x);
        }
        public List <ModelViewFailures> GetListCodeFailure(ModelViewUserG objCred)
        {
            var NegocioUsuario = new BusinessUsers();
            var dataUsuario    = NegocioUsuario.GetUserByToken(objCred.TokenUser);

            if (objCred.TokenApp != GlobalConfiguration.TokenWEB)
            {
                if (objCred.TokenApp != GlobalConfiguration.TokenMobile)
                {
                    throw new Exception("TokenInvalid");
                }
            }

            if (dataUsuario == null)
            {
                throw new Exception("UserPasswordInvalid");
            }
            var NegocioOrdenes     = new BusinessOrder();
            var NegocioEmpleado    = new BusinessEmployee();
            var NegocioCodigoFalla = new BusinessCodeFailure();
            var NegocioBase        = new BusinessInstalledBase();
            var codefailure        = NegocioCodigoFalla.GetAll();
            var empleado           = NegocioEmpleado.GetByUserID(dataUsuario.UserID);

            if (objCred.ProductID == 0)
            {
                //var ordenes = NegocioOrdenes.GetAll().Where(p => empleado.Select(q => q.PK_EmployeeID).ToArray<int>().Contains(p.FK_EmployeeID.Value) && p.OrderExecuteDate >= objCred.Date.Value.Date);
                //var prod = NegocioBase.GetAll();
                //var modelos = (from c in ordenes
                //               join p in prod on c.FK_InstalledBaseID equals p.PK_InstalledBaseID
                //               select p.FK_ProductID).Distinct().ToList();
                //modelos = modelos.Where(x => x != null).ToList();
                var        ordenes       = NegocioOrdenes.GetAll(empleado.Select(q => q.PK_EmployeeID).ToList(), objCred.Date.Value, false);
                List <int> baseInstalada = ordenes.Select(p => p.FK_InstalledBaseID).ToList();
                var        modelos       = NegocioBase.GetAllByBI(baseInstalada).Select(p => p.FK_ProductID).Distinct();
                modelos = modelos.Where(x => x != null).ToList();
                List <int> modelo    = modelos.Where(x => x != null).Cast <int>().ToList();
                var        codfallas = new List <ModelViewFailures>();
                foreach (var item in modelos)
                {
                    var x = (from c in GetByProductID(item.Value)
                             join p in codefailure on c.FK_CodeFailureID equals p.PK_CodeFailureID
                             select new ModelViewFailures()
                    {
                        CodeFailureID = p.PK_CodeFailureID,
                        ProductID = c.FK_ProductID,
                        CodeFailure = p.CodeFailure1,
                        Failure = p.Failure,
                        Complexity = c.Complexity.GetValueOrDefault(),
                        Status = c.Status
                    }).ToList();

                    codfallas.AddRange(x);
                }
                return(codfallas);
                //return (from c in modelos
                //        join p in GetAll() on c equals p.FK_ProductID
                //        join d in  codefailure on p.FK_CodeFailureID equals d.PK_CodeFailureID
                //        select new ModelViewFailures()
                //        {
                //            CodeFailureID = p.FK_CodeFailureID,
                //            ProductID = p.FK_ProductID,
                //            CodeFailure = d.CodeFailure1,
                //            Failure = d.Failure,
                //            Complexity = p.Complexity.GetValueOrDefault(),
                //            Status = p.Status
                //        }).ToList();
            }
            else
            {
                return((from c in GetByProductID(objCred.ProductID)
                        join p in codefailure on c.FK_CodeFailureID equals p.PK_CodeFailureID
                        select new ModelViewFailures()
                {
                    CodeFailureID = p.PK_CodeFailureID,
                    ProductID = c.FK_ProductID,
                    CodeFailure = p.CodeFailure1,
                    Failure = p.Failure,
                    Complexity = c.Complexity.GetValueOrDefault(),
                    Status = c.Status
                }).ToList());
            }
        }
Ejemplo n.º 5
0
        public List <ModelViewSerialNumber> GetListModel(ModelViewUserG objCred)
        {
            var NegocioBase         = new BusinessInstalledBase();
            var NegocioUsuario      = new BusinessUsers();
            var NegocioOrdenes      = new BusinessOrder();
            var NegocioValidacionSN = new BusinessValidationsSerialNumber();
            var NegocioEmpleado     = new BusinessEmployee();
            var user         = NegocioUsuario.GetUserByToken(objCred.TokenUser);
            var empleado     = NegocioEmpleado.GetByUserID(user.UserID);
            var ordenes      = NegocioOrdenes.GetAll().Where(p => empleado.Select(q => q.PK_EmployeeID).ToList <int>().Contains(p.FK_EmployeeID.Value) && p.OrderExecuteDate >= objCred.Date);
            var prod         = NegocioBase.GetAll();
            var SerialNumber = GetAll();
            var Validation   = NegocioValidacionSN.GetAll();

            if (objCred.ProductID == 0)
            {
                var modelos = (from c in ordenes
                               join p in prod on c.FK_InstalledBaseID equals p.PK_InstalledBaseID
                               select p.FK_ProductID).Distinct().ToList();
                modelos = modelos.Where(x => x != null).ToList();
                var lt = (from c in SerialNumber
                          join p in Validation on c.PK_ModelSerialNumberID equals p.FK_ModelSerialNumberID
                          select new ModelViewSerialNumber()
                {
                    ModelSerialNumberID = c.PK_ModelSerialNumberID,
                    ProductID = c.FK_ProducID,
                    Model = c.Model,
                    ValidationFormatID = c.ValidationFormatID,
                    ValidDate = c.ValidDate,
                    InitialDate = c.InitialDate != null ? c.InitialDate.Value.ToString("yyyy-MM-dd") : "",
                    EndDate = c.EndDate != null ? c.EndDate.Value.ToString("yyyy-MM-dd") : "",
                    ValidationsSerialNumberID = p.PK_ValidationsSerialNumberID,
                    ValidationName = p.ValidationName,
                    InitialPosition = p.InitialPosition,
                    FinalPosition = p.FinalPosition,
                    Allowed = p.Allowed,
                    RankID = p.RankID
                }).ToList();


                return((from c in modelos
                        join p in lt on c equals p.ProductID
                        select p).ToList());
            }
            else
            {
                return((from c in SerialNumber.Where(p => p.FK_ProducID == objCred.ProductID)
                        join p in Validation on c.PK_ModelSerialNumberID equals p.FK_ModelSerialNumberID
                        select new ModelViewSerialNumber()
                {
                    ModelSerialNumberID = c.PK_ModelSerialNumberID,
                    ProductID = c.FK_ProducID,
                    Model = c.Model,
                    ValidationFormatID = c.ValidationFormatID,
                    ValidDate = c.ValidDate,
                    InitialDate = c.InitialDate != null ? c.InitialDate.Value.ToString("yyyy-MM-dd") : "",
                    EndDate = c.EndDate != null ? c.EndDate.Value.ToString("yyyy-MM-dd") : "",
                    ValidationsSerialNumberID = p.PK_ValidationsSerialNumberID,
                    ValidationName = p.ValidationName,
                    InitialPosition = p.InitialPosition,
                    FinalPosition = p.FinalPosition,
                    Allowed = p.Allowed,
                    RankID = p.RankID
                }).ToList());
            }



            //return lt;
        }
Ejemplo n.º 6
0
        public string SetRefQuotation(ModelViewUserG objCred, ModelViewBilling obj)
        {
            var objRepository            = new RepositoryOrder();
            var NegocioOrden             = new BusinessOrder();
            var objAlerta                = new BusinessNotification();
            var NegocioUsuario           = new BusinessUsers();
            var NegocioCliente           = new BusinessClient();
            var NegocioBase              = new BusinessInstalledBase();
            var NegocioProducto          = new BusinessProduct();
            var NegocioFallas            = new BusinessCodeFailure();
            var NegocioBOM               = new BusinessBuildOfMaterial();
            var NegocioCotizacion        = new BusinessQuotation();
            var NegocioCotizacionDetalle = new BusinessRefsellDetail();
            var NegocioCFP               = new BusinessCodeFailureByProduct();
            var NegocioCF                = new BusinessCodeFailure();
            var NegocioLugarCompra       = new BusinessShopPlace();
            var NegocioEmpleado          = new BusinessEmployee();
            var NegocioMonitor           = new BusinessVisit();
            var NegocioHistorico         = new BusinessHistory();
            var NegocioGarantia          = new BusinessGuaranty();
            var NegocioPayment           = new BusinessPayment();
            var NegocioInvoice           = new BusinessInvoice();
            var NegocioRefsell           = new BusinessRefsell();
            var dataUsuario              = NegocioUsuario.GetUserByToken(objCred.TokenUser);

            if (objCred.TokenApp != GlobalConfiguration.TokenWEB)
            {
                if (objCred.TokenApp != GlobalConfiguration.TokenMobile)
                {
                    throw new Exception("TokenInvalid");
                }
            }
            if (dataUsuario == null)
            {
                throw new Exception("UserPasswordInvalid");
            }

            var empleado = NegocioEmpleado.GetByUserID(dataUsuario.UserID);
            var orden    = NegocioOrden.GetByOrderID(obj.ODS);


            var cliente = NegocioCliente.GetByID(orden.FK_ClientID);

            var lugarcompra = NegocioLugarCompra.GetByShopPlaceID(obj.FK_ShopPlaceID.Value);
            var pro         = NegocioProducto.GetByID(obj.FK_ProductID.Value);

            SpreadsheetInfo.SetLicense("EQU2-3K5L-UZDC-SDYN");
            string         Origin = GlobalConfiguration.MabeAttachmentsLocal + "FormatoVentaRefacciones.xlsx";
            List <string>  result = obj.EMails.Split(new char[] { ';' }).ToList();
            ExcelFile      ef     = ExcelFile.Load(Origin);
            ExcelWorksheet ws     = ef.Worksheets[0];
            string         Folio  = "";

            ws.Cells["L7"].Value  = obj.ODS;
            ws.Cells["L9"].Value  = cliente.ClientID;
            ws.Cells["L11"].Value = cliente.FirstName.ToUpper() + " " + cliente.LastName.ToUpper();
            ws.Cells["L13"].Value = pro.Model + " / " + pro.ProductName.ToUpper();
            ws.Cells["U13"].Value = DateTime.Today.ToString("dd-MM-yyyy");

            ws.Cells["L80"].Value = obj.ODS;
            int cantidad  = 30;
            int cantidad1 = 31;

            foreach (var jko in obj.BillingDetails)
            {
                if (jko.SparePartsDescription.EndsWith("-R"))
                {
                    Folio = jko.SparePartsDescription;
                    ws.Cells["L6"].Value  = Folio;
                    ws.Cells["L79"].Value = Folio;
                }
                else
                {
                    if (cantidad == 60)
                    {
                        cantidad  = 85;
                        cantidad1 = 86;
                    }
                    var bom = NegocioBOM.GetByID(jko.ProductID);
                    if (bom != null)
                    {
                        ws.Cells["L" + cantidad1.ToString()].Value = bom.SparePartsID;
                        ws.Cells["L" + cantidad.ToString()].Value  = bom.SparePartDescription;
                    }
                    else
                    {
                        ws.Cells["L" + cantidad1.ToString()].Value = jko.RefManID;
                        ws.Cells["L" + cantidad.ToString()].Value  = jko.SparePartsDescription;
                    }
                    ws.Cells["J" + cantidad.ToString()].Value = jko.Quantity;
                    ws.Cells["T" + cantidad.ToString()].Value = Convert.ToDouble(jko.Price);
                    ws.Cells["V" + cantidad.ToString()].Value = Convert.ToDouble(jko.Totals);
                    cantidad  = cantidad + 3;
                    cantidad1 = cantidad1 + 3;
                }
            }

            double subtotal    = Convert.ToDouble(obj.SubTotal.Substring(1));
            double iva         = Convert.ToDouble(obj.IVA.Substring(1));
            double total       = Convert.ToDouble(obj.Total.Substring(1));
            double subtotalref = subtotal;
            string totalletras = NegocioOrden.enletras(total.ToString());

            ws.Cells["M16"].Value = subtotalref;
            ws.Cells["M17"].Value = subtotal;
            ws.Cells["M18"].Value = iva;
            ws.Cells["U17"].Value = total;
            ws.Cells["M19"].Value = totalletras;
            string file    = "Cotización_" + Folio + ".pdf";
            string quotion = "CotizacionesRefaccion_" + DateTime.Today.ToString("yyyyMMdd");
            string Destiny = GlobalConfiguration.MabeAttachmentsLocal + quotion + "/" + file;

            if (obj.BillingDetails.Count < 11)
            {
                ws.NamedRanges.SetPrintArea(ws.Cells.GetSubrange("J1", "W74"));
            }
            string Cotizaciones = new DirectoryInfo(GlobalConfiguration.MabeAttachmentsLocal).ToString() + quotion;

            if (!(Directory.Exists(Cotizaciones)))
            {
                Directory.CreateDirectory(Cotizaciones);
            }
            ef.Save(Destiny);
            string URL        = GlobalConfiguration.urlRequest + "Content/Attachments/" + quotion + "/" + file;
            var    cotizacion = NegocioCotizacion.GetByOrderFolio(orden.PK_OrderID, Folio);
            var    Payment    = NegocioPayment.GetPolicyPayment(orden.PK_OrderID, Folio);
            var    Invoice    = NegocioInvoice.GetPolicyInvoice(orden.PK_OrderID, Folio);


            var LsVenta = NegocioRefsell.GetByFolio(orden.PK_OrderID, Folio);

            if (obj.EMails != "")
            {
                if (cotizacion == null)
                {
                    cotizacion = NegocioCotizacion.Insert(orden.PK_OrderID, subtotal.ToString(), iva.ToString(), total.ToString(), Folio, URL, obj.EstimatedTipe, empleado[0].PK_EmployeeID);
                }
                else
                {
                    cotizacion.Folio         = Folio;
                    cotizacion.IVA           = iva.ToString();
                    cotizacion.SubTotal      = subtotal.ToString();
                    cotizacion.Total         = total.ToString();
                    cotizacion.URL           = URL;
                    cotizacion.ModifyDate    = DateTime.UtcNow;
                    cotizacion.TypeQuotation = obj.EstimatedTipe;
                    cotizacion.FK_EmployeeID = empleado[0].PK_EmployeeID;
                    NegocioCotizacion.Update(cotizacion);
                }

                string sb     = File.ReadAllText(GlobalConfiguration.LocateBodyMail + "NotificationCotizacion.txt");
                string lugCom = obj.ShopDate != null ? obj.ShopDate : "";
                sb = sb.Replace("#%Nombre%#", cliente.FirstName + " " + cliente.LastName);
                sb = sb.Replace("#%OrderID%#", obj.ODS);
                sb = sb.Replace("#%Folio%#", Folio);
                sb = sb.Replace("#%Modelo%#", pro.Model);
                sb = sb.Replace("#%Descripcion%#", pro.ProductName.ToUpper());
                sb = sb.Replace("#%Serie%#", obj.SerialNumber);
                sb = sb.Replace("#%Fecha%#", lugCom);
                sb = sb.Replace("#%Lugar%#", lugarcompra.ShopPlace1);
                //objAlerta.SendMails(result, "Cotización ServiPlus", sb.ToString(), Destiny);
                objAlerta.SendMailExchange(GlobalConfiguration.exchangeUserCotiza, GlobalConfiguration.exchangePwdCotiza, result, "Cotización ServiPlus", sb.ToString(), Destiny);
            }
            else
            {
                if (LsVenta.PK_RefSellID == 0)
                {
                    if (cotizacion == null)
                    {
                        cotizacion = NegocioCotizacion.Insert(orden.PK_OrderID, subtotal.ToString(), iva.ToString(), total.ToString(), Folio, URL, obj.EstimatedTipe, empleado[0].PK_EmployeeID);
                    }
                    else
                    {
                        cotizacion.Folio         = Folio;
                        cotizacion.IVA           = iva.ToString();
                        cotizacion.SubTotal      = subtotal.ToString();
                        cotizacion.Total         = total.ToString();
                        cotizacion.URL           = URL;
                        cotizacion.ModifyDate    = DateTime.UtcNow;
                        cotizacion.TypeQuotation = obj.EstimatedTipe;
                        cotizacion.FK_EmployeeID = empleado[0].PK_EmployeeID;
                        NegocioCotizacion.Update(cotizacion);
                    }
                    var NewRefSell = new EntityRefSell();
                    var NuevaVenta = new EntityRefSell();

                    NewRefSell.FK_OrderID     = orden.PK_OrderID;
                    NewRefSell.FK_ClientID    = cliente.PK_ClientID;
                    NewRefSell.FK_EmployeeID  = empleado[0].PK_EmployeeID;
                    NewRefSell.FK_PaymentID   = Payment.PK_PaymentID;
                    NewRefSell.FK_Invoice_ID  = Invoice.InvoicingID;
                    NewRefSell.FK_ProductID   = obj.FK_ProductID.Value;
                    NewRefSell.FK_ShopPlace   = obj.FK_ShopPlaceID.Value;
                    NewRefSell.FK_QuotationID = cotizacion.PK_QuotationID;
                    NewRefSell.IDRefSell      = Folio;
                    NuevaVenta = NegocioRefsell.Insert(NewRefSell);
                }
                else
                {
                    LsVenta.FK_OrderID     = orden.PK_OrderID;
                    LsVenta.FK_ClientID    = cliente.PK_ClientID;
                    LsVenta.FK_EmployeeID  = empleado[0].PK_EmployeeID;
                    LsVenta.FK_PaymentID   = Payment.PK_PaymentID;
                    LsVenta.FK_Invoice_ID  = Invoice.InvoicingID;
                    LsVenta.FK_QuotationID = LsVenta.FK_QuotationID;
                    LsVenta.FK_ProductID   = obj.FK_ProductID.Value;
                    LsVenta.FK_ShopPlace   = obj.FK_ShopPlaceID.Value;

                    NegocioRefsell.Update(LsVenta);

                    if (cotizacion == null)
                    {
                        cotizacion = NegocioCotizacion.Insert(orden.PK_OrderID, subtotal.ToString(), iva.ToString(), total.ToString(), Folio, URL, obj.EstimatedTipe, empleado[0].PK_EmployeeID);
                    }
                    else
                    {
                        cotizacion.Folio         = Folio;
                        cotizacion.IVA           = iva.ToString();
                        cotizacion.SubTotal      = subtotal.ToString();
                        cotizacion.Total         = total.ToString();
                        cotizacion.URL           = URL;
                        cotizacion.ModifyDate    = DateTime.UtcNow;
                        cotizacion.TypeQuotation = obj.EstimatedTipe;
                        cotizacion.FK_EmployeeID = empleado[0].PK_EmployeeID;
                        NegocioCotizacion.Update(cotizacion);
                    }
                }
                string[] lstADR = { "T002", "T012", "T024" };

                foreach (var jko in obj.BillingDetails)
                {
                    string ADRAnt   = "";
                    int    ADRCount = 0;
                    bool   AddFlete = false;

                    if (jko.SparePartsDescription != Folio)
                    {
                        switch (jko.SparePartsDescription)
                        {
                        case "Fletes":
                        {
                            var DetailCotation2 = NegocioCotizacionDetalle.GetList(cotizacion.PK_QuotationID);

                            foreach (var items in DetailCotation2)
                            {
                                if (lstADR.Contains(items.Origen))
                                {
                                    if (ADRAnt != items.Origen)
                                    {
                                        ADRAnt = items.Origen;
                                        ADRCount++;
                                        if (ADRCount < 3)
                                        {
                                            AddFlete = true;
                                        }
                                        else
                                        {
                                            AddFlete = false;
                                        }
                                    }
                                    if (AddFlete)
                                    {
                                        items.Flete      = true;
                                        items.CostoFlete = jko.Price;
                                        NegocioCotizacionDetalle.Update(items);
                                        AddFlete = false;
                                    }
                                }
                            }
                        }

                        break;

                        default:
                            var newDetailquotion = NegocioCotizacionDetalle.GetDetail(cotizacion.PK_QuotationID, jko.ProductID);

                            if (newDetailquotion == null)
                            {
                                NegocioCotizacionDetalle.Insert(cotizacion.PK_QuotationID, jko.ProductID, jko.Quantity.ToString(), jko.RefManID, jko.Origins, jko.Price);
                            }
                            break;
                        }
                    }
                }


                var Refacciones = new BusinessMabe().Orden_Venta(obj.ODS, obj.ServiceTypes, Folio);
            }
            return(obj.ODS);
        }
        //public List<ModelViewSpareParts> GetListSparePartsComplete(ModelViewUserG objCred)
        //{
        //    return new RepositoryBuildOfMaterial().GetList(objCred);
        //}


        public List <ModelViewSpareParts> GetListSpareParts(ModelViewUserG objCred)
        {
            var NegocioBase     = new BusinessInstalledBase();
            var NegocioUsuario  = new BusinessUsers();
            var NegocioOrdenes  = new BusinessOrder();
            var NegocioEmpleado = new BusinessEmployee();
            var NegocioManoObra = new BusinessWorkforce();
            var user            = NegocioUsuario.GetUserByToken(objCred.TokenUser);
            var empleado        = NegocioEmpleado.GetByUserID(user.UserID);


            var lista = new List <ModelViewSpareParts>();

            if (objCred.ProductID == 0)
            {
                //var ordenes1 = NegocioOrdenes.GetAll().Where(p => empleado.Select(q => q.PK_EmployeeID).ToArray<int>().Contains(p.FK_EmployeeID.Value) && p.OrderExecuteDate >= objCred.Date);
                var        ordenes       = NegocioOrdenes.GetAll(empleado.Select(q => q.PK_EmployeeID).ToList(), objCred.Date.Value, false);
                List <int> baseInstalada = ordenes.Select(p => p.FK_InstalledBaseID).ToList();
                //var prod = NegocioBase.GetAll();
                //var modelos = (from c in ordenes
                //               join p in prod on c.FK_InstalledBaseID equals p.PK_InstalledBaseID
                //               select p.FK_ProductID).Distinct();
                var modelos = NegocioBase.GetAllByBI(baseInstalada).Select(p => p.FK_ProductID).Distinct();
                modelos = modelos.Where(x => x != null).ToList();
                List <int> modelo = modelos.Where(x => x != null).Cast <int>().ToList();
                lista = GetListSparePartsByModel(modelo);
                //lista = (from c in modelos
                //         join p in GetAll() on c equals p.FK_ProductID
                //         select new ModelViewSpareParts()
                //         {
                //             BuildOfMaterialsID = p.PK_BuildOfMaterialsID,
                //             ProductID = p.FK_ProductID,
                //             Model = p.Model,
                //             SparePartsID = p.SparePartsID,
                //             Quantity = p.Quantity,
                //             SpartePartDescription = p.SparePartDescription,
                //             StatusBOM = p.StatusBOM,
                //             Status = p.Status
                //         }).ToList<ModelViewSpareParts>();
            }
            else
            {
                lista = GetAll().Where(p => p.FK_ProductID == objCred.ProductID).Select(p => new ModelViewSpareParts()
                {
                    BuildOfMaterialsID = p.PK_BuildOfMaterialsID,
                    ProductID          = p.FK_ProductID,
                    Model                 = p.Model,
                    SparePartsID          = p.SparePartsID,
                    Quantity              = p.Quantity,
                    SpartePartDescription = p.SparePartDescription,
                    StatusBOM             = p.StatusBOM,
                    Status                = p.Status
                }).ToList <ModelViewSpareParts>();
            }
            var demo2 = NegocioManoObra.GetAll().Where(p => p.WorkforceID == "8011161600000031").Select(p => new ModelViewSpareParts
            {
                BuildOfMaterialsID = 0,
                ProductID          = 0,
                Model                 = "",
                SparePartsID          = p.WorkforceID,
                Quantity              = 1,
                SpartePartDescription = p.Description,
                StatusBOM             = "",
                Status                = p.Status,
            }).First();

            var demo3 = NegocioManoObra.GetAll().Where(p => p.WorkforceID == "8011161600000032").Select(p => new ModelViewSpareParts
            {
                BuildOfMaterialsID = 0,
                ProductID          = 0,
                Model                 = "",
                SparePartsID          = p.WorkforceID,
                Quantity              = 1,
                SpartePartDescription = p.Description,
                StatusBOM             = "",
                Status                = p.Status,
            }).First();

            lista.Add(demo2);
            lista.Add(demo3);

            return(lista);
        }
Ejemplo n.º 8
0
        public string CreateReceipt(ModelViewUserG objCred, ModelViewReceiptRef obj)
        {
            var objRepository   = new RepositoryOrder();
            var NegocioOrden    = new BusinessOrder();
            var objAlerta       = new BusinessNotification();
            var NegocioUsuario  = new BusinessUsers();
            var NegocioCliente  = new BusinessClient();
            var NegocioContrato = new BusinessContrat();
            var NegocioEmpleado = new BusinessEmployee();
            var NegocioBOM      = new BusinessBuildOfMaterial();

            var dataUsuario = NegocioUsuario.GetUserByToken(objCred.TokenUser);

            if (objCred.TokenApp != GlobalConfiguration.TokenWEB)
            {
                if (objCred.TokenApp != GlobalConfiguration.TokenMobile)
                {
                    throw new Exception("TokenInvalid");
                }
            }
            if (dataUsuario == null)
            {
                throw new Exception("UserPasswordInvalid");
            }


            var empleado = NegocioEmpleado.GetByUserID(dataUsuario.UserID);
            var orden    = NegocioOrden.GetByOrderID(obj.FK_OrderID);
            var cliente  = NegocioCliente.GetByID(orden.FK_ClientID);


            SpreadsheetInfo.SetLicense("EQU2-3K5L-UZDC-SDYN");
            string         Origin = GlobalConfiguration.MabeAttachmentsLocal + "FormatoReciboRef.xlsx";
            List <string>  result = obj.EMails.Split(new char[] { ';' }).ToList();
            ExcelFile      ef     = ExcelFile.Load(Origin);
            ExcelWorksheet ws     = ef.Worksheets[0];


            ws.Cells["W9"].Value  = obj.Folio;
            ws.Cells["W12"].Value = DateTime.Today.ToString("dd-MM-yyyy");
            ws.Cells["L18"].Value = cliente.FirstName.ToUpper();
            ws.Cells["P18"].Value = cliente.LastName.ToUpper();
            ws.Cells["L21"].Value = cliente.PhoneNumber1;
            ws.Cells["T21"].Value = cliente.PhoneNumber2;
            ws.Cells["M23"].Value = cliente.Email;


            int cantidad = 29;


            foreach (var jko in obj.SpareParts)
            {
                if (cantidad == 60)
                {
                    cantidad = 85;
                }
                ////var bom = NegocioBOM.GetByID(jko.ProductID);
                //if (bom != null)
                //{
                //    ws.Cells["L" + cantidad1.ToString()].Value = bom.SparePartsID;
                //    ws.Cells["L" + cantidad.ToString()].Value = bom.SparePartDescription;
                //}
                else
                {
                    ws.Cells["K" + cantidad.ToString()].Value = jko.RefManID;
                    ws.Cells["M" + cantidad.ToString()].Value = jko.SparePartsDescription;
                }
                ws.Cells["R" + cantidad.ToString()].Value = jko.Quantity;
                ws.Cells["U" + cantidad.ToString()].Value = Convert.ToDouble(jko.Price);
                ws.Cells["W" + cantidad.ToString()].Value = Convert.ToDouble(jko.Totals);
                cantidad = cantidad + 1;
            }

            double subtotal    = Convert.ToDouble(obj.SubTotal);
            double iva         = Convert.ToDouble(obj.IVA);
            double total       = Convert.ToDouble(obj.Total);
            double subtotalref = subtotal;
            string totalletras = NegocioOrden.enletras(total.ToString());

            ws.Cells["W41"].Value = subtotalref;

            ws.Cells["W42"].Value = iva;
            ws.Cells["W43"].Value = total;

            string file    = "ReciboRef" + obj.Folio + ".pdf";
            string quotion = "RecibosRefaccion_" + DateTime.Today.ToString("yyyyMMdd");
            string Destiny = GlobalConfiguration.MabeAttachmentsLocal + quotion + "/" + file;

            if (obj.SpareParts.Count < 11)
            {
                ws.NamedRanges.SetPrintArea(ws.Cells.GetSubrange("J1", "X54"));
            }
            string Cotizaciones = new DirectoryInfo(GlobalConfiguration.MabeAttachmentsLocal).ToString() + quotion;

            if (!(Directory.Exists(Cotizaciones)))
            {
                Directory.CreateDirectory(Cotizaciones);
            }
            ef.Save(Destiny);
            string URL    = GlobalConfiguration.urlRequest + "Content/Attachments/" + quotion + "/" + file;
            var    Recibo = NegocioContrato.GetByOrderFolio(orden.PK_OrderID, obj.Folio);



            if (obj.EMails != "")
            {
                if (Recibo == null)
                {
                    Recibo = NegocioContrato.Insert(orden.PK_OrderID, obj.Folio, URL);
                }
                else
                {
                    Recibo.Fk_OrderID = orden.PK_OrderID;
                    Recibo.Folio      = obj.Folio;
                    Recibo.Ruta       = URL;
                    NegocioContrato.Update(Recibo);
                }

                string sb = File.ReadAllText(GlobalConfiguration.LocateBodyMail + "MaiReciboRef.txt");
                sb = sb.Replace("#%Nombre%#", cliente.FirstName + " " + cliente.LastName);
                sb = sb.Replace("#%Folio%#", obj.Folio);

                objAlerta.SendMailExchange(GlobalConfiguration.exchangeUserCotiza, GlobalConfiguration.exchangePwdCotiza, result, "Recibo Refacciones", sb.ToString(), Destiny);
                return(URL);
            }
            else
            {
                string Tipo     = "Recibo";
                var    EnvioSMS = SendNotification(obj.PhoneNumber, Tipo, URL);

                return(EnvioSMS);
            }
        }
Ejemplo n.º 9
0
        public string SetPolicyQuotation(ModelViewUserG objCred, ModelViewBilling obj)
        {
            var NegocioOrders = new BusinessOrder();

            var objAlerta         = new BusinessNotification();
            var NegocioUsuario    = new BusinessUsers();
            var NegocioCliente    = new BusinessClient();
            var NegocioProducto   = new BusinessProduct();
            var NegocioCotizacion = new BusinessQuotation();
            var NegocioEmpleado   = new BusinessEmployee();
            var NegocioMonitor    = new BusinessVisit();
            var NegocioPayment    = new BusinessPayment();
            var NegocioInvoice    = new BusinessInvoice();

            var dataUsuario = NegocioUsuario.GetUserByToken(objCred.TokenUser);

            if (objCred.TokenApp != GlobalConfiguration.TokenWEB)
            {
                if (objCred.TokenApp != GlobalConfiguration.TokenMobile)
                {
                    throw new Exception("TokenInvalid");
                }
            }
            if (dataUsuario == null)
            {
                throw new Exception("UserPasswordInvalid");
            }

            var    empleado   = NegocioEmpleado.GetByUserID(dataUsuario.UserID);
            var    orden      = NegocioOrders.GetByOrderID(obj.ODS);
            var    cliente    = NegocioCliente.GetByID(orden.FK_ClientID);
            var    pro        = NegocioProducto.GetByID(obj.FK_ProductID.Value);
            string Folio      = obj.Policies.Folio;
            var    cotizacion = NegocioCotizacion.GetByOrderFolio(orden.PK_OrderID, Folio);
            var    Payment    = NegocioPayment.GetPolicyPayment(orden.PK_OrderID, Folio);
            var    Invoice    = NegocioInvoice.GetPolicyInvoice(orden.PK_OrderID, Folio);
            var    LsPolicy   = GetByFolio(orden.PK_OrderID, Folio);

            SpreadsheetInfo.SetLicense("EQU2-3K5L-UZDC-SDYN");
            string         Origin = GlobalConfiguration.MabeAttachmentsLocal + "FormatoPolizas.xlsx";
            List <string>  result = obj.EMails.Split(new char[] { ';' }).ToList();
            ExcelFile      ef     = ExcelFile.Load(Origin);
            ExcelWorksheet ws     = ef.Worksheets[0];

            ws.Cells["L6"].Value = Folio;
            //ws.Cells["L7"].Value = obj.ODS;
            ws.Cells["L9"].Value  = cliente.ClientID;
            ws.Cells["L11"].Value = cliente.FirstName.ToUpper() + " " + cliente.LastName.ToUpper();
            ws.Cells["L13"].Value = pro.Model + " / " + pro.ProductName.ToUpper();
            ws.Cells["U13"].Value = DateTime.Today.ToString("dd-MM-yyyy");
            ws.Cells["L79"].Value = Folio;
            //ws.Cells["L80"].Value = obj.ODS;

            int cantidad  = 30;
            int cantidad1 = 31;

            ws.Cells["L" + cantidad1.ToString()].Value = obj.Policies.PolicyDescription;
            ws.Cells["L" + cantidad.ToString()].Value  = "Venta de Poliza";
            ws.Cells["J" + cantidad.ToString()].Value  = 1;
            ws.Cells["V" + cantidad.ToString()].Value  = Convert.ToDouble(obj.SubTotal);

            double subtotal    = Convert.ToDouble(obj.SubTotal.Substring(0));
            double iva         = Convert.ToDouble(obj.IVA.Substring(0));
            double total       = Convert.ToDouble(obj.Total.Substring(0));
            double subtotalref = subtotal;
            string totalletras = NegocioOrders.enletras(total.ToString());

            ws.Cells["M17"].Value = subtotal;
            ws.Cells["M18"].Value = iva;
            ws.Cells["U16"].Value = total;
            ws.Cells["M19"].Value = totalletras;
            string file    = "CotizaciónPoliza_" + Folio + ".pdf";
            string quotion = "CotizacionesPoliza_" + DateTime.Today.ToString("yyyyMMdd");
            string Destiny = GlobalConfiguration.MabeAttachmentsLocal + quotion + "/" + file;

            if (obj.BillingDetails.Count < 11)
            {
                ws.NamedRanges.SetPrintArea(ws.Cells.GetSubrange("J1", "W74"));
            }
            string Cotizaciones = new DirectoryInfo(GlobalConfiguration.MabeAttachmentsLocal).ToString() + quotion;

            if (!(Directory.Exists(Cotizaciones)))
            {
                Directory.CreateDirectory(Cotizaciones);
            }
            ef.Save(Destiny);
            string URL = GlobalConfiguration.urlRequest + "Content/Attachments/" + quotion + "/" + file;

            if (obj.EMails != "")
            {
                if (cotizacion == null)
                {
                    cotizacion = NegocioCotizacion.Insert(orden.PK_OrderID, subtotal.ToString(), iva.ToString(), total.ToString(), Folio, URL, obj.EstimatedTipe, empleado[0].PK_EmployeeID);
                }
                else
                {
                    cotizacion.Folio         = Folio;
                    cotizacion.IVA           = iva.ToString();
                    cotizacion.SubTotal      = subtotal.ToString();
                    cotizacion.Total         = total.ToString();
                    cotizacion.URL           = URL;
                    cotizacion.ModifyDate    = DateTime.UtcNow;
                    cotizacion.TypeQuotation = obj.EstimatedTipe;
                    cotizacion.FK_EmployeeID = empleado[0].PK_EmployeeID;
                    NegocioCotizacion.Update(cotizacion);
                }
                string sb     = File.ReadAllText(GlobalConfiguration.LocateBodyMail + "NotificationPoliza.txt");
                string lugCom = obj.ShopDate != null ? obj.ShopDate : "";
                sb = sb.Replace("#%Nombre%#", cliente.FirstName + " " + cliente.LastName);
                sb = sb.Replace("#%OrderID%#", obj.ODS);
                sb = sb.Replace("#%Folio%#", Folio);
                sb = sb.Replace("#%Modelo%#", pro.Model);
                sb = sb.Replace("#%Descripcion%#", pro.ProductName.ToUpper());
                sb = sb.Replace("#%Fecha%#", obj.Policies.PolicyDate);
                sb = sb.Replace("#%Vigencia1%#", obj.Policies.PolicyDescription);
                sb = sb.Replace("#%Precio%#", obj.Total);
                objAlerta.SendMailExchange(GlobalConfiguration.exchangeUserCotiza, GlobalConfiguration.exchangePwdCotiza, result, "Cotización ServiPlus", sb.ToString(), Destiny);
            }
            else
            {
                if (LsPolicy.PK_PolicyID == 0)
                {
                    if (cotizacion == null)
                    {
                        cotizacion = NegocioCotizacion.Insert(orden.PK_OrderID, subtotal.ToString(), iva.ToString(), total.ToString(), Folio, URL, obj.EstimatedTipe, empleado[0].PK_EmployeeID);
                    }
                    else
                    {
                        cotizacion.Folio         = Folio;
                        cotizacion.IVA           = iva.ToString();
                        cotizacion.SubTotal      = subtotal.ToString();
                        cotizacion.Total         = total.ToString();
                        cotizacion.URL           = URL;
                        cotizacion.ModifyDate    = DateTime.UtcNow;
                        cotizacion.TypeQuotation = obj.EstimatedTipe;
                        cotizacion.FK_EmployeeID = empleado[0].PK_EmployeeID;
                        NegocioCotizacion.Update(cotizacion);
                    }
                    var NewPolicy   = new EntityPolicy();
                    var NuevaPoliza = new EntityPolicy();

                    NewPolicy.FK_OrderID     = orden.PK_OrderID;
                    NewPolicy.FK_ClientID    = cliente.PK_ClientID;
                    NewPolicy.FK_EmployeeID  = empleado[0].PK_EmployeeID;
                    NewPolicy.FK_PaymentID   = Payment.PK_PaymentID;
                    NewPolicy.FK_Invoice_ID  = Invoice.InvoicingID;
                    NewPolicy.FK_QuotationID = cotizacion.PK_QuotationID;
                    NewPolicy.FK_ProductID   = pro.PK_ProductID;
                    NewPolicy.FK_ShopPlace   = obj.FK_ShopPlaceID.Value;
                    NewPolicy.IDPolicy       = obj.Policies.Folio;
                    NewPolicy.SerialNumber   = obj.SerialNumber;
                    NewPolicy.PriceList      = obj.Policies.PriceList;
                    NewPolicy.PolicyPrice    = obj.Policies.PolicyPrice;
                    NewPolicy.Coin           = obj.Policies.Coin;
                    NewPolicy.SalesOrg       = obj.Policies.SalesOrg;
                    NewPolicy.ccGroup        = obj.Policies.ccGroup;
                    NewPolicy.MaterialGroup4 = obj.Policies.MaterialGroup4;
                    NewPolicy.GuarantyStart  = Convert.ToDateTime(obj.Policies.GuarantyStart);
                    NewPolicy.GuarantyEnd    = Convert.ToDateTime(obj.Policies.GuarantyEnd);
                    NewPolicy.PolicyDate     = obj.Policies.PolicyDate;

                    NuevaPoliza = Insert(NewPolicy);
                }
                else
                {
                    LsPolicy.FK_OrderID     = orden.PK_OrderID;
                    LsPolicy.FK_ClientID    = cliente.PK_ClientID;
                    LsPolicy.FK_EmployeeID  = empleado[0].PK_EmployeeID;
                    LsPolicy.FK_PaymentID   = Payment.PK_PaymentID;
                    LsPolicy.FK_Invoice_ID  = Invoice.InvoicingID;
                    LsPolicy.FK_QuotationID = LsPolicy.FK_QuotationID;
                    LsPolicy.FK_ProductID   = obj.Policies.ProductID;
                    LsPolicy.FK_ShopPlace   = obj.FK_ShopPlaceID.Value;
                    LsPolicy.IDPolicy       = obj.Policies.Folio;
                    LsPolicy.PolicyPrice    = obj.Policies.PolicyPrice;
                    LsPolicy.Coin           = obj.Policies.Coin;
                    LsPolicy.SalesOrg       = obj.Policies.SalesOrg;
                    LsPolicy.PriceList      = obj.Policies.PriceList;
                    LsPolicy.SerialNumber   = obj.SerialNumber;
                    LsPolicy.ccGroup        = obj.Policies.ccGroup;
                    LsPolicy.MaterialGroup4 = obj.Policies.MaterialGroup4;
                    LsPolicy.GuarantyEnd    = Convert.ToDateTime(obj.Policies.GuarantyEnd);
                    LsPolicy.GuarantyStart  = Convert.ToDateTime(obj.Policies.GuarantyStart);
                    LsPolicy.PolicyDate     = obj.Policies.PolicyDate;

                    Update(LsPolicy);
                    if (cotizacion == null)
                    {
                        cotizacion = NegocioCotizacion.Insert(orden.PK_OrderID, subtotal.ToString(), iva.ToString(), total.ToString(), Folio, URL, obj.EstimatedTipe, empleado[0].PK_EmployeeID);
                    }
                    else
                    {
                        cotizacion.Folio         = Folio;
                        cotizacion.IVA           = iva.ToString();
                        cotizacion.SubTotal      = subtotal.ToString();
                        cotizacion.Total         = total.ToString();
                        cotizacion.URL           = URL;
                        cotizacion.ModifyDate    = DateTime.UtcNow;
                        cotizacion.TypeQuotation = obj.EstimatedTipe;
                        cotizacion.FK_EmployeeID = empleado[0].PK_EmployeeID;
                        NegocioCotizacion.Update(cotizacion);
                    }
                }
                var Refacciones = new BusinessMabe().Orden_Venta(obj.ODS, obj.ServiceTypes, Folio);
            }



            return(obj.ODS);
        }
Ejemplo n.º 10
0
        public List <ModelViewEvidence> GetLisEvidencetAll(string StatusVisitID, string ModuleID, string PriorityID, string StatusOrderID, string ServiceID, string OrderID, string Employee, string StartDate, string EndDate, string User)
        {
            var NegocioUser         = new BusinessUsers();
            var NegocioEmpleado     = new BusinessEmployee();
            var NegocioOrdenes      = new BusinessOrder();
            var NegocioEstatusOrden = new BusinessStatusCauseOrder();
            var NegocioGarantia     = new BusinessGuaranty();
            var NegocioModulosMabe  = new BusinessModuleService();
            var NegocioEvidencia    = new BusinessOrderEvidence();
            //var visitas = GetAll();
            var user         = new List <ModelViewUserList>();
            var estatusorden = NegocioEstatusOrden.GetAll();
            int profileuser  = NegocioUser.GetProfileByToken(User).ProfileID;
            var ordenes      = new List <EntityOrder>();
            var garantia     = new List <EntityGuaranty>();
            var modulos      = new List <EntityModuleService>();
            var estatus      = new List <EntityStatusOrder>();
            var empleado     = new List <EntityEmployee>();
            var visitas      = new List <ModelViewMonitorOrder>();

            user = NegocioUser.GetAll();

            if (StartDate != "" && EndDate != "")
            {
                DateTime inicio = DateTime.ParseExact(StartDate, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                DateTime fin    = DateTime.ParseExact(EndDate, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                //ordenes = NegocioOrdenes.GetAll().Where(p => p.OrderExecuteDate >= inicio && p.OrderExecuteDate <= fin && p.FK_StatusSchemeID != 44).ToList();
                ordenes = NegocioOrdenes.GetByRange(inicio, fin).Where(p => p.FK_StatusSchemeID != 44).ToList();
                if (OrderID != "")
                {
                    ordenes = NegocioOrdenes.GetAll().Where(p => p.OrderID.Contains(OrderID)).ToList();
                }
                if (profileuser == 7)
                {
                    ordenes = (from a in ordenes
                               join b in user on a.FK_ModuleID equals b.FK_ModuleID
                               where b.ProfileID == profileuser
                               select a).ToList();
                }
            }
            else
            {
                ordenes = NegocioOrdenes.GetAll();
            }

            if (StatusVisitID != "")
            {
                int[] nums = StatusVisitID.Split(',').Select(int.Parse).ToArray();
                visitas = GetAll().Where(p => nums.Contains(p.StatusVisitID.Value)).ToList();
            }
            else
            {
                visitas = GeListByOrder(ordenes.Select(p => p.PK_OrderID).ToList());
            }



            if (Employee != "")
            {
                empleado = NegocioEmpleado.GetAll().Where(p => p.FirstName.ToLower().Contains(Employee.ToLower()) || p.LastName.ToLower().Contains(Employee.ToLower())).ToList();
            }
            else
            {
                empleado = NegocioEmpleado.GetAll();
            }


            if (ServiceID != "")
            {
                int[] nums = ServiceID.Split(',').Select(int.Parse).ToArray();
                garantia = NegocioGarantia.GetAll().Where(p => nums.Contains(p.PK_GuarantyID)).ToList();
            }
            else
            {
                garantia = NegocioGarantia.GetAll();
            }

            if (ModuleID != "")
            {
                int[] nums = ModuleID.Split(',').Select(int.Parse).ToArray();
                modulos = NegocioModulosMabe.GetAll().Where(p => nums.Contains(p.ModuleID)).ToList();
            }
            else
            {
                modulos = NegocioModulosMabe.GetAll();
            }
            if (StatusOrderID != "")
            {
                int[] nums = StatusOrderID.Split(',').Select(int.Parse).ToArray();
                estatus = NegocioEstatusOrden.GetAll().Where(p => nums.Contains(p.PK_StatusOrderID)).ToList();
            }
            else
            {
                estatus = NegocioEstatusOrden.GetAll();
            }


            var lt = (from a in visitas
                      join b in estatus on a.StatusOrderID equals b.PK_StatusOrderID
                      join c in ordenes on a.OrderID equals c.PK_OrderID
                      join d in empleado on c.TechnicalID equals d.EmployeeID
                      join e in garantia on c.FK_GuarantyID equals e.PK_GuarantyID
                      join f in modulos on c.FK_ModuleID equals f.ModuleID
                      select new ModelViewEvidence()
            {
                OrderID = c.OrderID,
                EmployeeName = d.FirstName + " " + d.LastName,
                Date = c.OrderExecuteDate.ToString("dd/MM/yyyy"),
                EvidenceBadUse = NegocioEvidencia.GetEvidence(a.VisitID, "BadUse").Select(p => new EvidenceOrder {
                    TypeEvidence = p.TypeEvidence, URLEvidence = GlobalConfiguration.urlRequest + p.URLEvidence.Substring(2)
                }).ToList(),
                EvidenceFinish = NegocioEvidencia.GetEvidence(a.VisitID, "Finish").Select(p => new EvidenceOrder {
                    TypeEvidence = p.TypeEvidence, URLEvidence = GlobalConfiguration.urlRequest + p.URLEvidence.Substring(2)
                }).ToList(),
                EvidenceNoSeriesNumber = NegocioEvidencia.GetEvidence(a.VisitID, "NoSeriesNumber").Select(p => new EvidenceOrder {
                    TypeEvidence = p.TypeEvidence, URLEvidence = GlobalConfiguration.urlRequest + p.URLEvidence.Substring(2)
                }).ToList(),
                EvidencePurchaseNote = NegocioEvidencia.GetEvidence(a.VisitID, "PurchaseNote").Select(p => new EvidenceOrder {
                    TypeEvidence = p.TypeEvidence, URLEvidence = GlobalConfiguration.urlRequest + p.URLEvidence.Substring(2)
                }).ToList(),
                EvidenceStartODS = NegocioEvidencia.GetEvidence(a.VisitID, "StartODS").Select(p => new EvidenceOrder {
                    TypeEvidence = p.TypeEvidence, URLEvidence = GlobalConfiguration.urlRequest + p.URLEvidence.Substring(2)
                }).Take(3).ToList(),
                EvidenceSummary = NegocioEvidencia.GetEvidence(a.VisitID, "Summary").Select(p => new EvidenceOrder {
                    TypeEvidence = p.TypeEvidence, URLEvidence = GlobalConfiguration.urlRequest + p.URLEvidence.Substring(2)
                }).ToList()
                                  // NegocioEvidencia.GetEvidence
                                  //EvidenceBadUse = NegocioEvidencia.GetAll().Where(p => p.MonitorOrdersID == a.VisitID && p.TypeEvidence == "BadUse").Select(p => new EvidenceOrder { TypeEvidence = p.TypeEvidence, URLEvidence = GlobalConfiguration.urlRequest + p.URLEvidence.Substring(2) }).ToList(),
                                  //EvidenceFinish = NegocioEvidencia.GetAll().Where(p => p.MonitorOrdersID == a.VisitID && p.TypeEvidence == "Finish").Select(p => new EvidenceOrder { TypeEvidence = p.TypeEvidence, URLEvidence = GlobalConfiguration.urlRequest + p.URLEvidence.Substring(2) }).ToList(),
                                  //EvidenceNoSeriesNumber = NegocioEvidencia.GetAll().Where(p => p.MonitorOrdersID == a.VisitID && p.TypeEvidence == "NoSeriesNumber").Select(p => new EvidenceOrder { TypeEvidence = p.TypeEvidence, URLEvidence = GlobalConfiguration.urlRequest + p.URLEvidence.Substring(2) }).ToList(),
                                  //EvidencePurchaseNote = NegocioEvidencia.GetAll().Where(p => p.MonitorOrdersID == a.VisitID && p.TypeEvidence == "PurchaseNote").Select(p => new EvidenceOrder { TypeEvidence = p.TypeEvidence, URLEvidence = GlobalConfiguration.urlRequest + p.URLEvidence.Substring(2) }).ToList(),
                                  //EvidenceStartODS = NegocioEvidencia.GetAll().Where(p => p.MonitorOrdersID == a.VisitID && p.TypeEvidence == "StartODS").Select(p => new EvidenceOrder { TypeEvidence = p.TypeEvidence, URLEvidence = GlobalConfiguration.urlRequest + p.URLEvidence.Substring(2) }).Take(3).ToList(),
                                  //EvidenceSummary = NegocioEvidencia.GetAll().Where(p => p.MonitorOrdersID == a.VisitID && p.TypeEvidence == "Summary").Select(p => new EvidenceOrder { TypeEvidence = p.TypeEvidence, URLEvidence = GlobalConfiguration.urlRequest + p.URLEvidence.Substring(2) }).ToList()
            }).ToList();


            return(lt);
        }
Ejemplo n.º 11
0
        public List <ModelViewQuotation> GetListAllQuotation(string StatusVisitID, string ModuleID, string PriorityID, string StatusOrderID, string ServiceID, string OrderID, string Employee, string StartDate, string EndDate, string User, string TypeQuotation)
        {
            var NegocioUser          = new BusinessUsers();
            var NegocioCiente        = new BusinessClient();
            var NegocioCotizacion    = new BusinessQuotation();
            var cotiza               = new BusinessQuotation();
            var NegocioPolizas       = new BusinessPolicy().GetAll();
            var NegocioEmpleado      = new BusinessEmployee();
            var NegocioMonitor       = new BusinessMonitor();
            var NegocioOrdenes       = new BusinessOrder();
            var NegocioEstatusOrden  = new BusinessStatusCauseOrder();
            var NegocioGarantia      = new BusinessGuaranty();
            var NegocioModulosMabe   = new BusinessModuleService();
            var NegocioCauseOrder    = new BusinessCauseOrder();
            var NegocioTypeQuotation = new BusinessTypeQuotation();
            var NegocioContrat       = new BusinessContrat();
            var estatusorden         = NegocioEstatusOrden.GetAll();
            int profileuser          = NegocioUser.GetProfileByToken(User).ProfileID;
            var ordenes              = new List <EntityOrder>();
            var polizas              = new List <EntityPolicy>();
            var user         = new List <ModelViewUserList>();
            var garantia     = new List <EntityGuaranty>();
            var modulos      = new List <EntityModuleService>();
            var estatus      = new List <EntityStatusOrder>();
            var empleado     = new List <EntityEmployee>();
            var visitas      = new List <ModelViewMonitorOrder>();
            var tipo         = new List <EntityTypeQuotation>();
            var Cotizaciones = new List <EntityQuotation>();
            var contrat      = new List <EntityContract>();

            var ModuleUser = NegocioUser.GetProfileByToken(User).ModuleID;

            //contrat = NegocioContrat.GetAll();
            user = NegocioUser.GetAll();

            if (StartDate != "" && EndDate != "")
            {
                DateTime inicio = DateTime.ParseExact(StartDate, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                DateTime fin    = DateTime.ParseExact(EndDate, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                //ordenes = NegocioOrdenes.GetAll().Where(p => p.OrderExecuteDate >= inicio && p.OrderExecuteDate <= fin).ToList();
                ordenes = NegocioOrdenes.GetByRange(inicio, fin);
                if (OrderID != "")
                {
                    ordenes = NegocioOrdenes.GetAll().Where(p => p.OrderID.Contains(OrderID)).ToList();
                }
                if (profileuser == 7)
                {
                    ordenes = (from a in ordenes
                               where a.FK_ModuleID == ModuleUser
                               select a).ToList();
                }
            }
            else
            {
                ordenes = NegocioOrdenes.GetAll();
            }

            if (StatusVisitID != "")
            {
                int[] nums = StatusVisitID.Split(',').Select(int.Parse).ToArray();
                visitas = GetAll().Where(p => nums.Contains(p.StatusVisitID.Value)).ToList();
            }
            else
            {
                visitas = GeListByOrder(ordenes.Select(p => p.PK_OrderID).ToList());
            }

            if (Employee != "")
            {
                empleado = NegocioEmpleado.GetAll().Where(p => p.FirstName.ToLower().Contains(Employee.ToLower()) || p.LastName.ToLower().Contains(Employee.ToLower())).ToList();
            }
            else
            {
                empleado = NegocioEmpleado.GetAll();
            }

            if (ServiceID != "")
            {
                int[] nums = ServiceID.Split(',').Select(int.Parse).ToArray();
                garantia = NegocioGarantia.GetAll().Where(p => nums.Contains(p.PK_GuarantyID)).ToList();
            }
            else
            {
                garantia = NegocioGarantia.GetAll();
            }

            if (ModuleID != "")
            {
                int[] nums = ModuleID.Split(',').Select(int.Parse).ToArray();
                modulos = NegocioModulosMabe.GetAll().Where(p => nums.Contains(p.ModuleID)).ToList();
            }
            else
            {
                modulos = NegocioModulosMabe.GetAll();
            }
            if (StatusOrderID != "")
            {
                int[] nums = StatusOrderID.Split(',').Select(int.Parse).ToArray();
                estatus = NegocioEstatusOrden.GetAll().Where(p => nums.Contains(p.PK_StatusOrderID)).ToList();
            }
            else
            {
                estatus = NegocioEstatusOrden.GetAll();
            }
            if (TypeQuotation != "")
            {
                int[] nums = TypeQuotation.Split(',').Select(int.Parse).ToArray();
                tipo = NegocioTypeQuotation.GetAll().Where(p => nums.Contains(p.PK_TypeQuotation)).ToList();
            }
            else
            {
                tipo = NegocioTypeQuotation.GetAll();
            }

            Cotizaciones = NegocioCotizacion.GeListByOrder(ordenes.Select(p => p.PK_OrderID).ToList());

            //var x = NegocioCotizacion.GetAll().Select(p => p.TypeQuotation).Distinct();
            List <ModelViewQuotation> x = (from c in Cotizaciones
                                           join j in tipo on c.TypeQuotation equals j.PK_TypeQuotation
                                           join p in ordenes on c.FK_OrdenID equals p.PK_OrderID
                                           join e in NegocioCiente.GetAll() on p.FK_ClientID equals e.PK_ClientID
                                           join t in empleado on p.TechnicalID equals t.EmployeeID
                                           join m in NegocioMonitor.GetAll() on p.PK_OrderID equals m.OrderID
                                           join b in estatus on m.StatusOrderID equals b.PK_StatusOrderID
                                           join g in garantia on p.FK_GuarantyID equals g.PK_GuarantyID
                                           join f in modulos on p.FK_ModuleID equals f.ModuleID


                                           join h in NegocioCauseOrder.GetAll() on m.CauseOrderID equals h.PK_CauseOrderID



                                           select new ModelViewQuotation()
            {
                FK_OrderID = c.FK_OrdenID.Value,
                QuotationID = c.PK_QuotationID,
                TypeQuotation = j.Description,
                OrdenVenta = c.OrdenVenta,
                OrderID = p.OrderID,
                StatusQuotation = h.PK_CauseOrderID,
                Folio = c.Folio,
                ClientName = e.FirstName + " " + e.LastName,
                EmployeeName = t.FirstName + " " + t.LastName,
                Total = "$ " + c.Total,
                URL = c.URL,
            }).OrderByDescending(p => p.QuotationID).ToList();

            //var z = (from r in x
            //         join y in contrat on r.FK_OrderID equals y.Fk_OrderID
            //         into ps
            //         from sub in ps.DefaultIfEmpty()

            //         select new ModelViewQuotation()
            //         {
            //             FK_OrderID = r.FK_OrderID,
            //             QuotationID = r.QuotationID,
            //             TypeQuotation = r.TypeQuotation,
            //             OrdenVenta = r.OrdenVenta,
            //             OrderID = r.OrderID,
            //             StatusQuotation = r.StatusQuotation,
            //             Folio = r.Folio,
            //             ClientName = r.ClientName,
            //             EmployeeName = r.EmployeeName,
            //             Total = r.Total,
            //             URL = r.URL,
            //             Contract = sub?.Ruta ?? String.Empty
            //         }).GroupBy(w => new { w.FK_OrderID, w.Folio }).Select(w => w.First()).ToList();



            return(x);
            //return z;
        }
Ejemplo n.º 12
0
        public List <ModelViewODS> GetListVisitAll(string StatusVisitID, string ModuleID, string PriorityID, string StatusOrderID, string ServiceID, string OrderID, string Employee, string StartDate, string EndDate, string User)
        {
            var NegocioUser           = new BusinessUsers();
            var NegocioEmpleado       = new BusinessEmployee();
            var NegocioOrdenes        = new BusinessOrder();
            var NegocioEstatusOrden   = new BusinessStatusCauseOrder();
            var NegocioGarantia       = new BusinessGuaranty();
            var NegocioModulosMabe    = new BusinessModuleService();
            var NegocioEvidencia      = new BusinessOrderEvidence();
            var NegocioCausaOrder     = new BusinessCauseOrder();
            var NegocioEstatusEsquema = new BusinessStatusScheme();
            var estatusorden          = NegocioEstatusOrden.GetAll();
            var causaOrder            = NegocioCausaOrder.GetAll();
            int profileuser           = NegocioUser.GetProfileByToken(User).ProfileID;
            var ModuleUser            = NegocioUser.GetProfileByToken(User).ModuleID;
            var ordenes = new List <EntityOrder>();

            var user                 = new List <ModelViewUserList>();
            var garantia             = new List <EntityGuaranty>();
            var modulos              = new List <EntityModuleService>();
            var estatus              = new List <EntityStatusOrder>();
            var empleado             = new List <EntityEmployee>();
            var visitas              = new List <ModelViewMonitorOrder>();
            List <ModelViewODS> list = new List <ModelViewODS>();


            user = NegocioUser.GetAll();


            if (StartDate != "" && EndDate != "")
            {
                DateTime inicio = DateTime.ParseExact(StartDate, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                DateTime fin    = DateTime.ParseExact(EndDate, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                ordenes = NegocioOrdenes.GetByRange(inicio, fin);

                if (OrderID != "")
                {
                    ordenes = ordenes.Where(p => p.OrderID.Contains(OrderID)).ToList();
                }
                if (profileuser == 7)
                {
                    ordenes = (from a in ordenes where a.FK_ModuleID == ModuleUser
                               select a).ToList();
                }

                //ordenes = NegocioOrdenes.GetAll().Where(p => p.OrderExecuteDate >= inicio && p.OrderExecuteDate <= fin).ToList();
                //if (OrderID != "")
                //{ ordenes = ordenes.Where(p => p.OrderID.Contains(OrderID)).ToList(); }
            }

            else
            {
                ordenes = NegocioOrdenes.GetAll();
            }

            if (StatusVisitID != "")
            {
                int[] nums = StatusVisitID.Split(',').Select(int.Parse).ToArray();
                visitas = GetAll().Where(p => nums.Contains(p.StatusVisitID.Value)).ToList();
            }
            else
            {
                visitas = GeListByOrder(ordenes.Select(p => p.PK_OrderID).ToList());
            }

            var ordenesFactura = (from a in ordenes
                                  join b in new BusinessInvoice().GetAll() on a.PK_OrderID equals b.FK_OrderID into total
                                  from p in total.DefaultIfEmpty()
                                  select new { a, Invoice = p == null ? "No" : "Si" }).ToList();
            var complete = (from a in ordenes
                            join b in visitas on a.PK_OrderID equals b.OrderID
                            join c  in ordenesFactura on a.PK_OrderID equals c.a.PK_OrderID
                            select new { a, b, c.Invoice }).ToList();

            if (Employee != "")
            {
                var fullEmployee = NegocioEmpleado.GetAll().Select(p => new { PK_EmployeeID = p.PK_EmployeeID, Name = p.FirstName.ToLower() + " " + p.LastName.ToLower() }).ToList();
                var EmployeeID   = fullEmployee.Where(p => p.Name.Contains(Employee.ToLower())).ToList();
                empleado = NegocioEmpleado.GetAll().Where(p => EmployeeID.Select(a => a.PK_EmployeeID).ToList <int>().Contains(p.PK_EmployeeID) && p.FK_UserID != null).ToList();
            }
            else
            {
                empleado = NegocioEmpleado.GetAll().Where(p => p.FK_UserID != null).ToList();
            }

            var completeEmpl = (from a in complete
                                join b in empleado
                                on a.a.FK_EmployeeID equals b.PK_EmployeeID
                                select new { a, b }).ToList();

            if (ServiceID != "")
            {
                int[] nums = ServiceID.Split(',').Select(int.Parse).ToArray();
                garantia = NegocioGarantia.GetAll().Where(p => nums.Contains(p.PK_GuarantyID)).ToList();
            }
            else
            {
                garantia = NegocioGarantia.GetAll();
            }

            var completeSer = (from a in completeEmpl
                               join b in garantia
                               on a.a.a.FK_GuarantyID equals b.PK_GuarantyID
                               select new { a, b }).ToList();

            if (ModuleID != "")
            {
                int[] nums = ModuleID.Split(',').Select(int.Parse).ToArray();
                modulos = NegocioModulosMabe.GetAll().Where(p => nums.Contains(p.ModuleID)).ToList();
            }
            else
            {
                modulos = NegocioModulosMabe.GetAll();
            }

            var completeMod = (from a in completeSer
                               join b in modulos
                               on a.a.a.a.FK_ModuleID equals b.ModuleID
                               select new { a, b }).ToList();

            if (StatusOrderID != "")
            {
                int[] nums = StatusOrderID.Split(',').Select(int.Parse).ToArray();
                estatus = NegocioEstatusOrden.GetAll().Where(p => nums.Contains(p.PK_StatusOrderID)).ToList();
            }
            else
            {
                estatus = NegocioEstatusOrden.GetAll();
            }

            var completeEst = (from a in completeMod
                               join b in estatus
                               on a.a.a.a.b.StatusOrderID equals b.PK_StatusOrderID
                               select new { a, b }).ToList();

            //var ordenesemple = (from a in visitas
            //                    join b in estatus on a.StatusOrderID equals b.PK_StatusOrderID
            //                    join c in ordenes on a.OrderID equals c.PK_OrderID
            //                    join d in empleado on c.TechnicalID equals d.EmployeeID
            //                    select new
            //                    {
            //                        EmployeeID = d.PK_EmployeeID,
            //                        Status = b.StatusOrder1,
            //                        StatusID = a.StatusVisitID,
            //                        LatitudeAddress = a.LatitudeAddress ,
            //                        LogitudeAddress = a.LogitudeAddress,
            //                        LatitudeStartVisit = a.LatitudeStartVisit,
            //                        LogitudeStartVisit = a.LogitudeStartVisit,
            //                        LatitudeEndVisit = a.LatitudeEndVisit,
            //                        LogitudeEndVisit = a.LogitudeEndVisit,
            //                        OrderID = c.OrderID,
            //                        StarTime = a.StartVisitDate,
            //                        EndTime = a.EndVisitDate,
            //                        OrderExceute = c.OrderExecuteDate,
            //                        Secuence = a.SequenceVisit
            //                    });

            var completeEstEsq = (from a in completeEst
                                  join b in NegocioEstatusEsquema.GetAll()
                                  on a.a.a.a.a.a.FK_StatusSchemeID equals b.PK_StatusSchemeID
                                  select new { a, b }).ToList();


            var lt = completeEstEsq.Select(p => new ModelViewODS()
            {
                MonitorID          = p.a.a.a.a.a.b.VisitID,
                ModuleID           = p.a.a.b.ModuleID,
                StatusVisitID      = p.a.a.a.a.a.b.StatusVisitID.Value,
                Module             = p.a.a.b.ID + " - " + p.a.a.b.Base,
                StatusOrderID      = p.a.b.PK_StatusOrderID,
                StatusODS          = p.a.b.StatusOrder1,
                CauseOrder         = p.b.Description,
                OrderID            = p.a.a.a.a.a.a.PreOrder == false ? p.a.a.a.a.a.a.OrderID : "PreOrden",
                EmployeeName       = p.a.a.a.a.b.FirstName + " " + p.a.a.a.a.b.LastName,
                ServiceType        = p.a.a.a.b.GuarantyID + " " + p.a.a.a.b.Guaranty1,
                StartVisitODS      = p.a.a.a.a.a.b.StartVisitDate.ToString(),
                StartTryODS        = p.a.a.a.a.a.b.StartServiceDate.ToString(),
                StartRunODS        = p.a.a.a.a.a.b.StartOrderDate.ToString(),
                EndVisitODS        = p.a.a.a.a.a.b.EndVisitDate.ToString(),
                EndTryODS          = p.a.a.a.a.a.b.EndServiceDate.ToString(),
                EndRunODS          = p.a.a.a.a.a.b.EndOrderDate.ToString(),
                LatitudeStartVisit = p.a.a.a.a.a.b.LatitudeStartVisit.ToString(),
                LogitudeStartVisit = p.a.a.a.a.a.b.LogitudeStartVisit.ToString(),
                LatitudeEndVisit   = p.a.a.a.a.a.b.LatitudeEndVisit.ToString(),
                LogitudeEndVisit   = p.a.a.a.a.a.b.LogitudeEndVisit.ToString(),
                LatitudeStartOrder = p.a.a.a.a.a.b.LatitudeStartOrder.ToString(),
                LogitudeStartOrder = p.a.a.a.a.a.b.LogitudeStartOrder.ToString(),
                LatitudeEndOrder   = p.a.a.a.a.a.b.LatitudeEndOrder.ToString(),
                LogitudeEndOrder   = p.a.a.a.a.a.b.LogitudeEndOrder.ToString(),
                DurationVisit      = p.a.a.a.a.a.b.DurationVisit.ToString(),
                DurationExecute    = p.a.a.a.a.a.b.DurationExecute.ToString(),
                Notes            = p.a.a.a.a.a.b.NoteOrder,
                URL              = p.a.a.a.a.a.a.URLPreOrder,
                SendCRM          = p.a.a.a.a.a.a.SendCRM,
                OrderExecuteDate = p.a.a.a.a.a.a.OrderExecuteDate,
                Invoice          = p.a.a.a.a.a.Invoice,
                Evidence         = NegocioEvidencia.GetEvidence(p.a.a.a.a.a.b.VisitID, "StartODS").Select(c => new EvidenceOrder
                {
                    TypeEvidence = c.TypeEvidence, URLEvidence = GlobalConfiguration.urlRequest + c.URLEvidence.Substring(2)
                }).Take(3).ToList(),
                // Address = ordenesemple.Where(a => a.EmployeeID == p.a.a.a.a.b.PK_EmployeeID && a.OrderExceute.Date == p.a.a.a.a.a.a.OrderExecuteDate.Date).Select(b => new AddressV
                // {
                //     StatusOrderID = b.StatusID.Value,
                //     LatitudeStartVisit = b.LatitudeStartVisit,
                //     LogitudeStartVisit = b.LogitudeStartVisit,
                //     LatitudeEndVisit = b.LatitudeEndVisit,
                //     LogitudeEndVisit = b.LogitudeEndVisit,
                //     LatitudeAddress = b.LatitudeAddress,
                //     LogitudeAddress = b.LogitudeAddress,
                //     Status = b.Status,
                //     OrderID = b.OrderID,
                //     StarTime = b.StarTime.ToString(),
                //     EndTime = b.EndTime.ToString(),
                //     Secuence = b.Secuence.HasValue ? b.Secuence.Value : 0,
                //}).ToList()
            }).OrderByDescending(p => p.OrderExecuteDate).ToList();

            return(lt);
        }