public void Destroy(Shipping_RecordsViewModel Record)
        {
            if (!UpdateDatabase)
            {
                var target = Read().FirstOrDefault(e => e.RecordID == Record.RecordID);
                if (target != null)
                {
                    GetAll().Remove(target);
                }
            }
            else
            {
                var entity = new Shipping_Records
                {
                    RecordID = Record.RecordID
                };
                Entities.Shipping_Records.Attach(entity);
                Entities.Shipping_Records.Remove(entity);

                var record = Entities.Shipping_Records.Where(s => s.RecordID == entity.RecordID);

                foreach (var e in record)
                {
                    Entities.Shipping_Records.Remove(e);
                }
                Entities.SaveChanges();
            }
        }
        public ActionResult Destroy([DataSourceRequest] DataSourceRequest request, Shipping_RecordsViewModel Datos)
        {
            RouteValueDictionary routeValues;

            _SumarioEmbarquesService.Destroy(Datos);

            routeValues = this.GridRouteValues();

            return(Json(new[] { Datos }.ToDataSourceResult(request, ModelState)));
        }
        public Shipping_RecordsViewModel TakeLast()
        {
            var ultimo = GetAll().OrderByDescending(des => des.RecordID).Select(sel => new Shipping_RecordsViewModel
            {
                RecordControlBoxNo  = sel.RecordControlBoxNo,
                RecordFedexTracking = sel.RecordFedexTracking,
                RecordPieceBoxNo    = sel.RecordPieceBoxNo,
                ClientID            = sel.ClientID,
                Clients             = new ClientesViewModel()
                {
                    ClientName    = sel.Clients.ClientName,
                    ClientCompany = sel.Clients.ClientCompany
                },
                ShipmentTypeID      = sel.ShipmentTypeID,
                CatalogShipmentType = new CatalogShipmentTypeViewModel()
                {
                    ShipmentType = sel.CatalogShipmentType.ShipmentType
                },
                RecordServiceType   = sel.RecordServiceType,
                RecordTransfer      = sel.RecordTransfer,
                RecordSeguritySeal1 = sel.RecordSeguritySeal1
            }).FirstOrDefault();

            if (ultimo == null)
            {
                ultimo = new Shipping_RecordsViewModel
                {
                    RecordTransfer      = "",
                    ClientID            = 0,
                    ProductID           = 0,
                    RecordQuantity      = 0,
                    RecordDate          = DateTime.Now,
                    RecordFedexTracking = 0,
                    RecordControlBoxNo  = 0,
                    RecordPieceBoxNo    = 0,
                    ShipmentTypeID      = 0,
                    RecordServiceType   = "",
                    RecordComment       = "",
                    RecordWorkOrder     = 0,
                    RecordSerialNo      = "",
                    RecordTrackingId    = 0,
                    RecordRework        = false,
                    RecordComment1      = "",
                    RecordComment2      = "",
                    RecordFAI           = false,
                    RecordSeguritySeal1 = "",
                    RecordSeguritySeal2 = "",
                    RecordSeguritySeal3 = "",
                    RecordSeguritySeal4 = ""
                };
            }
            return(ultimo);
        }
 public ActionResult Update([DataSourceRequest] DataSourceRequest request, Shipping_RecordsViewModel Datos)
 {
     try
     {
         _SumarioEmbarquesService.Update(Datos);
         return(RedirectToAction("Index"));
     }
     catch (DbEntityValidationException ex)
     {
         Debug.WriteLine("ErrorMessage: " + ex.EntityValidationErrors);
         return(RedirectToAction("Index"));
     }
 }
Exemplo n.º 5
0
        public ActionResult Create([Bind(Include = "RecordID,ClientID,ProductID,RecordQuantity,RecordDate,RecordFedexTracking,RecordControlBoxNo,RecordPieceBoxNo,ShipmentTypeID,RecordServiceType,RecordComment,RecordWorkOrder,RecordSerialNo,RecordTrackingId,RecordRework,RecordComment1,RecordComment2,RecordFAI,RecordTransfer,RecordSeguritySeal1,")] Shipping_RecordsViewModel Perro)
        {
            bool va1 = false;
            bool va2 = false;

            if (Perro != null && ModelState.IsValid)
            {
                if (Perro.RecordWorkOrder != null && !_ServiceSR.WOrderUnik((int)Perro.RecordWorkOrder))
                {                       /*Si es diferente de nulo y no esta repetido en la BD*/
                    ViewBag.showMs = 3; //WorkOrder
                    return(View("Create", Perro));
                }
                else
                {
                    va1 = true;
                }

                if (Perro.RecordTrackingId != null && !_ServiceSR.TID((int)Perro.RecordTrackingId))
                {
                    /*Si es diferente de nulo y no esta repetido en la BD*/
                    ViewBag.showMs = 4;
                    return(View("Create", Perro));
                }
                else
                {
                    va2 = true;
                }

                if (va1 && va2)
                {
                    ViewBag.showMs = 1;
                    _ServiceSR.Create(Perro);
                    ModelState.Clear();
                    Perro = _ServiceSR.TakeLast();
                    return(View("Create", Perro));
                }
                else
                {
                    return(View("Create", Perro));
                }
            }
            else
            {
                ViewBag.showMs = 2;
                return(View("Create", Perro));
            }
        }
        public void Update(Shipping_RecordsViewModel Record)
        {
            //Record.Shipping_Catalog_Products = null;
            if (!UpdateDatabase)
            {
                var target = One(e => e.RecordID == Record.RecordID);

                if (target != null)
                {
                    target.RecordTransfer = Record.RecordTransfer;
                }
            }
            else
            {
                var entity = new Shipping_Records
                {
                    RecordID            = Record.RecordID,
                    RecordTransfer      = Record.RecordTransfer,
                    ClientID            = Record.ClientID,
                    ProductID           = Record.ProductID,
                    RecordQuantity      = Record.RecordQuantity,
                    RecordDate          = Record.RecordDate,
                    RecordFedexTracking = Record.RecordFedexTracking,
                    RecordControlBoxNo  = Record.RecordControlBoxNo,
                    RecordPieceBoxNo    = Record.RecordPieceBoxNo,
                    ShipmentTypeID      = Record.ShipmentTypeID,
                    RecordServiceType   = Record.RecordServiceType,
                    RecordComment       = Record.RecordComment,
                    RecordWorkOrder     = Record.RecordWorkOrder,
                    RecordSerialNo      = Record.RecordSerialNo,
                    RecordTrackingId    = Record.RecordTrackingId,
                    RecordRework        = Record.RecordRework,
                    RecordComment1      = Record.RecordComment1,
                    RecordComment2      = Record.RecordComment2,
                    RecordFAI           = Record.RecordFAI,
                    RecordSeguritySeal1 = Record.RecordSeguritySeal1,
                    RecordSeguritySeal2 = Record.RecordSeguritySeal2,
                    RecordSeguritySeal3 = Record.RecordSeguritySeal3,
                    RecordSeguritySeal4 = Record.RecordSeguritySeal4
                };
                Entities.Shipping_Records.Add(entity);
                Entities.Entry(entity).State = EntityState.Modified;
                Entities.SaveChanges();
            }
        }
 public void Create(Shipping_RecordsViewModel Record)
 {
     if (!UpdateDatabase)
     {
         var firts = Read().OrderByDescending(e => e.RecordID).FirstOrDefault();
         var id    = (firts != null) ? firts.RecordID : 0;
         Record.RecordID = id + 1;
         GetAll().Insert(0, Record);
     }
     else
     {
         var entity = new Shipping_Records
         {
             ClientID            = Record.ClientID,
             ProductID           = Record.ProductID,
             RecordQuantity      = Record.RecordQuantity,
             RecordDate          = Record.RecordDate,
             RecordFedexTracking = Record.RecordFedexTracking,
             RecordControlBoxNo  = Record.RecordControlBoxNo,
             RecordPieceBoxNo    = Record.RecordPieceBoxNo,
             ShipmentTypeID      = Record.ShipmentTypeID,
             RecordServiceType   = Record.RecordServiceType,
             RecordComment       = Record.RecordComment,
             RecordWorkOrder     = Record.RecordWorkOrder,
             RecordSerialNo      = Record.RecordSerialNo,
             RecordTrackingId    = Record.RecordTrackingId,
             RecordRework        = Record.RecordRework,
             RecordComment1      = Record.RecordComment1,
             RecordComment2      = Record.RecordComment2,
             RecordFAI           = Record.RecordFAI,
             RecordTransfer      = Record.RecordTransfer,
             RecordSeguritySeal1 = Record.RecordSeguritySeal1
         };
         Entities.Shipping_Records.Add(entity);
         Entities.SaveChanges();
         Record.RecordID = entity.RecordID;
     }
 }
Exemplo n.º 8
0
        public ActionResult Create()
        {
            Shipping_RecordsViewModel Perro = _ServiceSR.TakeLast();

            return(View(Perro));
        }