コード例 #1
0
        public OrderVModel GetQueryOrderComplete(string shipment)
        {
            OrderVModel order = new OrderVModel();
            List <OrderDetailVModel> query = ApplicationDbContext.OrderDetail
                                             .Where(x => x.embarque == shipment).Select(x => new OrderDetailVModel
            {
                OrderID               = x.OrderID,
                partida               = x.partida,
                total_pallets         = x.total_pallets,
                continentalpartnumber = x.continentalpartnumber,
                customerpartnumber    = x.customerpartnumber,
                traza = x.traza,
                notas = x.notas,
                Leido = x.Leido
            }).ToList();

            //OrderVModel order = ReadsItems(x => x.ShipmentNumber == shipment).Select(x => new OrderVModel
            //{
            //    OrderID = x.OrderID,
            //    ReaderID = x.ReaderID,
            //    Number = x.Number,
            //    ShipmentNumber = x.ShipmentNumber,
            //    OnShipment = x.OnShipment,
            //    Date = x.Date,
            //    Finished = x.Finished
            //}).FirstOrDefault();

            order.ListOrderDetail = query;
            return(order);
        }
コード例 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public OrderVModel GetQueryOrderComplete(int id)
        {
            List <OrderDetailVModel> query = Context.OrderDetail
                                             .Where(x => x.OrderID == id).Select(x => new OrderDetailVModel
            {
                OrderID               = x.OrderID,
                partida               = x.partida,
                total_pallets         = x.total_pallets,
                continentalpartnumber = x.continentalpartnumber,
                customerpartnumber    = x.customerpartnumber,
                traza = x.traza,
                notas = x.notas,
                Leido = x.Leido
            }).ToList();

            OrderVModel order = ReadsItems(x => x.OrderID == id).Select(x => new OrderVModel
            {
                OrderID        = x.OrderID,
                ReaderID       = x.ReaderID,
                Number         = x.Number,
                ShipmentNumber = x.ShipmentNumber,
                OnShipment     = x.OnShipment,
                Date           = x.Date,
                Finished       = x.Finished
            }).FirstOrDefault();

            order.ListOrderDetail = query;
            return(order);
        }
コード例 #3
0
        public async Task <IActionResult> SetShipment(OrderVModel item)
        {
            MonitorVModel mntr = new MonitorVModel();

            if (item.OrderID > 0)
            {
                //Se pone el embarque activo
                OrderEModel order = _context.Order.FirstOrDefault(x => x.OrderID == item.OrderID);
                order.OnShipment = true;
                order.ReaderID   = item.ReaderID;
                var succes = await _contextOrder.UpdateItemAsync(order);

                //Obtengo el nombre de reader asignado
                ReaderEModel reader = _context.Reader.FirstOrDefault(x => x.ReaderID == item.ReaderID);
                mntr.Portal   = reader.Name;
                mntr.IdOrden  = order.OrderID;
                mntr.Embarque = order.ShipmentNumber;
                mntr.IdPortal = (int)order.ReaderID;
                return(RedirectToAction("Monitor", mntr));//Monitor = mntr
            }
            else
            {
                ViewBag.Show = false;
            }
            return(null);
        }
コード例 #4
0
        public static async Task <OrderVModel> CreateNuevaOrden(ShipmentVModel embarque)
        {
            OrderVModel orden = new OrderVModel();

            using (var unitOfWork = new UnitOfWork(new ApplicationDbContext()))
            {
                orden = await unitOfWork.OrderR.CreateShipmentV2(embarque.detalle);
            }
            return(orden);
        }
コード例 #5
0
        public static OrderVModel GetOrdenCompleta(string embarque)
        {
            OrderVModel orden = new OrderVModel();

            using (var unitOfWork = new UnitOfWork(new ApplicationDbContext()))
            {
                orden = unitOfWork.OrderR.GetQueryOrderComplete(embarque);
            }
            return(orden);
        }
コード例 #6
0
        public static OrderVModel GetOrder(string embarque)
        {
            OrderVModel orden = new OrderVModel();

            using (var unitOfWork = new UnitOfWork(new ApplicationDbContext()))
            {
                orden = unitOfWork.OrderR.GetOrderOnshipment(embarque);
            }
            return(orden);
        }
コード例 #7
0
        public OrderVModel GetOrderOnshipment(string embarque)
        {
            OrderVModel order = ReadsItems(x => x.ShipmentNumber == embarque && x.OnShipment == true).Select(x => new OrderVModel
            {
                OrderID        = x.OrderID,
                ReaderID       = x.ReaderID,
                Number         = x.Number,
                ShipmentNumber = x.ShipmentNumber,
                OnShipment     = x.OnShipment,
                Date           = x.Date,
                Finished       = x.Finished
            }).FirstOrDefault();

            return(order);
        }
コード例 #8
0
        private void LlenarDgv()
        {
            OrderVModel order = new OrderVModel();

            DgvEmbarque.DataSource = null;
            var dt = LlenarTabla();

            order = BusinessOrders.GetOrdenCompleta(_embarque);
            foreach (var item in order.ListOrderDetail)
            {
                dt.Rows.Add(item.continentalpartnumber, item.traza, item.total_pallets, item.Leido);
            }

            DgvEmbarque.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
            //DgvEmbarque.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.DisplayedCells;
            DgvEmbarque.DataSource = dt;
        }
コード例 #9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="embarque"></param>
        /// <returns></returns>
        public OrderVModel GetOrderOnshipment(string embarque)
        {
            OrderVModel order = (from orders in ReadsItems(x => x.ShipmentNumber == embarque && x.OnShipment == true)
                                 join reader in ApplicationDbContext.Reader on orders.ReaderID equals reader.ReaderID
                                 select new
            {
                orders,
                reader
            }).Select(x => new OrderVModel
            {
                OrderID        = x.orders.OrderID,
                ReaderID       = x.orders.ReaderID,
                Number         = x.orders.Number,
                ShipmentNumber = x.orders.ShipmentNumber,
                OnShipment     = x.orders.OnShipment,
                Date           = x.orders.Date,
                Finished       = x.orders.Finished,
            }).FirstOrDefault();

            return(order);
        }
コード例 #10
0
        public IActionResult Index(OrderVModel item)
        {
            if (ModelState.IsValid)
            {
                #region Fill select
                ViewBag.ReaderList = new SelectList(_context.Reader.ToList(), "ReaderID", "Name");
                #endregion
                #region Get order by ID
                OrderEModel orderModel = new OrderEModel();
                orderModel = _context.Order.FirstOrDefault(x => x.ShipmentNumber == item.Number);
                if (null == orderModel)
                {
                    //Actualizar Orden
                    orderModel = new OrderEModel()
                    {
                        Date           = DateTime.Now,
                        Number         = item.Number,
                        OnShipment     = false,
                        ReaderID       = null,
                        ShipmentNumber = item.Number
                    };
                    orderModel = _context.Order.Add(orderModel).Entity;
                }
                //else
                //{
                //    orderModel = new OrderEModel()
                //    {
                //        ID = order.ID,
                //        Date = order.Date,
                //        Number = order.Number,
                //        OnShipment = order.OnShipment,
                //        ReaderID = order.ReaderID,
                //        ShipmentNumber = order.Number
                //    };

                //}
                #endregion

                #region obtener información de embarques
                //1.- Obtener el total de piezas

                List <OrderDetailVModel> embarques = new List <OrderDetailVModel> {
                    new OrderDetailVModel {
                        Traza = 100922, PartNumber = "A2C98063402", Quantity = 48
                    },
                    new OrderDetailVModel {
                        Traza = 100920, PartNumber = "A2C98062602", Quantity = 240
                    },
                    new OrderDetailVModel {
                        Traza = 100921, PartNumber = "A2C98062602", Quantity = 96
                    },
                    new OrderDetailVModel {
                        Traza = 100921, PartNumber = "A2C98062702", Quantity = 48
                    },
                };
                // 1.1.-el total de piezas convertirlo a tarimas
                foreach (OrderDetailVModel embarque in embarques)
                {
                    Console.WriteLine(embarque.PartNumber);
                    embarque.UnitID  = embarque.Quantity / 48;
                    embarque.OrderID = orderModel.OrderID;
                }
                List <OrderDetailEModel> ordersDetail = JsonConvert.DeserializeObject <List <OrderDetailEModel> >(JsonConvert.SerializeObject(embarques).ToString());
                Console.WriteLine(embarques);
                _context.OrderDetail.AddRange(ordersDetail);
                _context.SaveChanges();
                #endregion
                OrderVModel orders = JsonConvert.DeserializeObject <OrderVModel>(JsonConvert.SerializeObject(orderModel).ToString());
                orders.ListOrderDetail = embarques;
                ViewBag.OrderDetail    = embarques;
                ViewBag.Show           = true;
                return(View(orderModel));
            }
            else
            {
                ViewBag.Show = false;
            }
            return(View(item));
        }
コード例 #11
0
        /// <summary>
        /// Metodo para crear un embarque ysus detalles
        /// </summary>
        /// <param name="orderVModel"></param>
        /// <param name="orderDetailVModel"></param>
        /// <returns></returns>
        public async Task <OrderVModel> CreateShipmentV2(List <OrderDetailVModel> orderDetailVModel)
        {
            try
            {
                var                      todo            = ApplicationDbContext.Order;
                int                      pallet          = 1;
                OrderEModel              orderModel      = new OrderEModel();
                OrderVModel              order           = new OrderVModel();
                OrderDetailEModel        orderDetail     = new OrderDetailEModel();
                List <OrderDetailVModel> orderDetailList = new List <OrderDetailVModel>();

                using (var transaction = await ApplicationDbContext.Database.BeginTransactionAsync(IsolationLevel.RepeatableRead))
                {
                    // var todo = ApplicationDbContext.Order.ToList();
                    var lastItemOrder = ApplicationDbContext.Order.LastOrDefault();
                    int idOrder       = lastItemOrder == null ? 1 : lastItemOrder.OrderID + 1;
                    // Crea el modelo para insertar en la tabla Order
                    orderModel = new OrderEModel()
                    {
                        OrderID        = idOrder,
                        Date           = DateTime.Now,
                        OnShipment     = false,
                        ReaderID       = null,
                        ShipmentNumber = orderDetailVModel[0].embarque
                    };

                    ApplicationDbContext.Order.Add(orderModel);
                    ApplicationDbContext.SaveChanges();
                    order.OrderID    = orderModel.OrderID;
                    order.Date       = orderModel.Date;
                    order.OnShipment = orderModel.OnShipment;

                    //TODO: Crear los detalles del EMBARQUE para la tabla OrderDetails
                    foreach (var item in orderDetailVModel)
                    {
                        for (int i = 0; i < item.total_pallets; i++)
                        {
                            var lastItemOrderDetail = ApplicationDbContext.OrderDetail.LastOrDefault();
                            int idOrderDetail       = lastItemOrderDetail == null ? 1 : lastItemOrderDetail.OrderDetailID + 1;
                            orderDetail = new OrderDetailEModel()
                            {
                                OrderDetailID         = idOrderDetail,
                                OrderID               = orderModel.OrderID,
                                embarque              = item.embarque,
                                partida               = item.partida,
                                total_pallets         = pallet,
                                continentalpartnumber = item.continentalpartnumber,
                                customerpartnumber    = item.customerpartnumber,
                                cantidad              = item.cantidad,
                                delivery              = item.delivery,
                                traza    = item.traza,
                                shipment = item.shipment,
                                notas    = item.shipment,
                                Leido    = false
                            };
                            pallet++;
                            ApplicationDbContext.OrderDetail.Add(orderDetail);
                            ApplicationDbContext.SaveChanges();
                            var uno = JsonConvert.DeserializeObject <OrderDetailVModel>(JsonConvert.SerializeObject(orderDetail).ToString());
                            orderDetailList.Add(uno);
                        }
                    }
                    ApplicationDbContext.SaveChanges();
                    transaction.Commit();
                }

                order.ListOrderDetail = orderDetailList;
                return(order);
            }
            catch (Exception)
            {
                return(null);

                //throw new DataValidationException("Error", string.Format("No fué posible crear el embarque: {0}", ex.Message));
            }
        }
コード例 #12
0
        private void btnEnviar_Click(object sender, EventArgs e)
        {
            try
            {
                OrderVModel order     = new OrderVModel();
                int         palletBox = 0;
                if (BusinessOrders.Terminado(txbEmbarque.Text))
                {
                    //MensajeError(embarqueTerminado);
                    MessageBox.Show(embarqueTerminado);
                    //TODO: Limpiar el txt donde se escribe el embarque
                }
                else if (BusinessOrders.ExisteAsignada(txbEmbarque.Text))
                {
                    _embarque = txbEmbarque.Text;
                    order     = BusinessOrders.GetOrder(_embarque);

                    FormValidar fv = FormValidar.GetInstance(_embarque, (int)order.ReaderID);
                    if (!fv.IsDisposed)
                    {
                        this.Hide();
                        fv.Show();
                        fv.BringToFront();
                    }
                    else
                    {
                        cboxAndenes.Visible = false;
                        btnAsignar.Visible  = false;
                    }
                }
                else if (BusinessOrders.ExisteNoAsignada(txbEmbarque.Text))
                {
                    //TODO: Si esta asignado abrir la siguiente pantalla que es la de validar


                    // Obtengo los datos del embarque
                    var uno = Shipment(txbEmbarque.Text);

                    if (uno != null)
                    {
                        // Preguntas si esta cancelado
                        if (int.Parse(uno.cancelado) == 0)
                        {
                            dataGridView1.DataSource = null;
                            var dt = LlenarTabla();
                            order = BusinessOrders.GetOrdenCompleta(txbEmbarque.Text);
                            foreach (var item in order.ListOrderDetail)
                            {
                                dt.Rows.Add(item.continentalpartnumber, item.traza, item.total_pallets, item.Leido);
                            }
                            dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
                            dataGridView1.AutoSizeRowsMode    = DataGridViewAutoSizeRowsMode.AllCells;
                            dataGridView1.DataSource          = dt;
                            cboxAndenes.Visible = dt != null ? true : false;
                            btnAsignar.Visible  = dt != null ? true : false;
                        }
                    }
                    else
                    {
                        MessageBox.Show("");
                    }
                }
                else
                {
                    // Obtengo los datos del embarque
                    ShipmentVModel embarque = Shipment(txbEmbarque.Text);

                    if (embarque.detalle.Count > 0)
                    {
                        // Preguntas si esta cancelado
                        if (int.Parse(embarque.cancelado) == 0)
                        {
                            // ir a traza y obtener el numero de pallets
                            int index = 0;
                            foreach (OrderDetailVModel item in embarque.detalle)
                            {
                                if (item.continentalpartnumber.ToLower() == "varios")
                                {
                                    item.total_pallets = 1;
                                }
                                else
                                {
                                    #region Connection Traza- Se obtiene el total de piezas por tarima
                                    //string oracleConn = "Data Source= tqdb002x.tq.mx.conti.de:1521/tqtrazapdb.tq.mx.conti.de; User Id=consulta; Password= solover";
                                    //string query = $"SELECT aunitsperbox * aboxperpallet FROM ETGDL.products WHERE MLFB = '{item.continentalpartnumber}' ";
                                    //using (OracleConnection connection = new OracleConnection(oracleConn))
                                    //{
                                    //    OracleCommand command = new OracleCommand(query, connection);
                                    //    connection.Open();
                                    //    OracleDataReader reader = command.ExecuteReader();

                                    //    if (reader.Read())
                                    //    {
                                    //        palletBox = reader.GetInt32(0);
                                    //    }

                                    //    reader.Close();
                                    //}

                                    #endregion

                                    #region Dummyes para no conectar con traza
                                    palletBox = 300;
                                    #endregion

                                    if (int.Parse(item.cantidad) <= palletBox)
                                    {
                                        item.total_pallets = 1;
                                    }
                                    else
                                    {
                                        //int pallets = int.Parse(item.cantidad) / piezasPorTarima;
                                        //if (pallets == 0)
                                        //    txbEmbarque.Text = string.Empty;
                                        //item.total_pallets = pallets;
                                        int pallets = int.Parse(item.cantidad) / palletBox;
                                        item.total_pallets = pallets;
                                    }
                                }
                                index++;
                            }
                            var orderT = BusinessOrders.CreateNuevaOrden(embarque);
                            order = orderT.Result;
                            // Crear el embarque

                            dataGridView1.DataSource = null;
                            var dt = LlenarTabla();
                            order = BusinessOrders.GetOrdenCompleta(txbEmbarque.Text);
                            foreach (var item in order.ListOrderDetail)
                            {
                                dt.Rows.Add(item.continentalpartnumber, item.traza, item.total_pallets, item.Leido);
                            }
                            dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
                            dataGridView1.AutoSizeRowsMode    = DataGridViewAutoSizeRowsMode.AllCells;
                            dataGridView1.DataSource          = dt;
                            cboxAndenes.Visible = dt != null ? true : false;
                            btnAsignar.Visible  = dt != null ? true : false;
                        }
                        else
                        {
                            MessageBox.Show("El embarque no contiene tarimas para embarcar");
                        }
                    }
                }
            }
            catch (DataValidationException dex)
            {
                MessageBox.Show(dex.ErrorMessage, dex.PropertyName);
            }
        }
コード例 #13
0
        public async Task <IActionResult> Index(OrderVModel item)
        {
            OrderVModel orders     = new OrderVModel();
            OrderEModel orderModel = new OrderEModel();

            try
            {
                if (ModelState.IsValid)
                {
                    #region Fill select
                    ViewBag.ReaderList = new SelectList(_context.Reader.ToList(), "ReaderID", "Name");
                    #endregion
                    var exist = _contextOrder.GetOrderOnshipment(item.ShipmentNumber);
                    if (exist == null)
                    {
                        #region obtener información de embarques
                        //1.- Obtener el total de piezas
                        ShipmentVModel result = test(item.ShipmentNumber);
                        int            index  = 0;
                        // 1.1.-Obtener de traza el total de piezas por tarima del número de parte
                        foreach (OrderDetailVModel embarque in result.detalle)
                        {
                            Console.WriteLine(index);
                            //TODO: Conectar con traza y mediante el numero de parte obtener el total de piezas por pallet
                            int pallets = int.Parse(embarque.cantidad) / 48;
                            embarque.OrderID  = orderModel.OrderID;
                            embarque.shipment = orderModel.ShipmentNumber;
                            Console.WriteLine(embarque.continentalpartnumber);
                            embarque.total_pallets = pallets;
                            index++;
                        }


                        #endregion

                        #region CreateShipment

                        orders = await _contextOrder.CreateShipment(item, result.detalle);

                        #endregion

                        ViewBag.OrderDetail = orders.ListOrderDetail;
                        ViewBag.Show        = true;
                        return(View(orders));
                    }
                    else if (exist.OnShipment == true && exist.Finished == false && exist.ReaderID != null)
                    {
                        var mntr = GetInfoMonitor(exist.OrderID);
                        mntr.IdOrden  = exist.OrderID;
                        mntr.IdPortal = (int)exist.ReaderID;
                        mntr.Embarque = exist.ShipmentNumber;
                        return(RedirectToAction("Monitor", mntr));//Monitor = mntr
                    }
                    else if (exist.Finished == true)
                    {
                        ViewBag.shipment = "Este embarque esta terminado";
                        ViewBag.Show     = false;
                        return(View());
                    }
                    else
                    {
                        ViewBag.Show        = true;
                        orders              = _contextOrder.GetQueryOrderComplete(exist.OrderID);
                        ViewBag.OrderDetail = orders.ListOrderDetail;
                        return(View(orders));
                    }
                }
                else
                {
                    ViewBag.Show = false;
                }
            }
            catch (DataValidationException dex)
            {
                //TODO: Mostrar el mensaje en la pantala principal
                this.ModelState.AddModelError(dex.PropertyName, dex.ErrorMessage);
            }
            return(View());
        }
コード例 #14
0
        private void btnEnviar_Click(object sender, EventArgs e)
        {
            OrderVModel order = new OrderVModel();

            if (BusinessOrders.Terminado(txbEmbarque.Text))
            {
            }
            else if (BusinessOrders.ExisteAsignada(txbEmbarque.Text))
            {
                var orden = BusinessOrders.GetOrder(txbEmbarque.Text);
            }
            else if (BusinessOrders.Existe(txbEmbarque.Text))
            {
                // se llena el combobox con los andenes
                LlenarComboAnden();
                // Obtengo los datos del embarque
                var uno = Shipment(txbEmbarque.Text);
                // Preguntas si esta cancelado
                if (int.Parse(uno.cancelado) == 0)
                {
                    dataGridView1.DataSource = null;
                    var dt = new DataTable();
                    dt.Columns.Add("continentalpartnumber");
                    dt.Columns.Add("traza");
                    dt.Columns.Add("total_pallets");
                    order = BusinessOrders.GetOrdenCompleta(txbEmbarque.Text);
                    foreach (var item in order.ListOrderDetail)
                    {
                        dt.Rows.Add(item.continentalpartnumber, item.traza, item.total_pallets);
                    }
                    dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
                    dataGridView1.AutoSizeRowsMode    = DataGridViewAutoSizeRowsMode.AllCells;

                    dataGridView1.DataSource = dt;
                }
            }
            else
            {
                // se llena el combobox con los andenes
                LlenarComboAnden();
                // Obtengo los datos del embarque
                var uno = Shipment(txbEmbarque.Text);
                // Preguntas si esta cancelado
                if (int.Parse(uno.cancelado) == 0)
                {
                    dataGridView1.DataSource = null;
                    var dt = new DataTable();
                    dt.Columns.Add("continentalpartnumber");
                    dt.Columns.Add("traza");
                    dt.Columns.Add("total_pallets");
                    order = BusinessOrders.GetOrdenCompleta(txbEmbarque.Text);
                    foreach (var item in order.ListOrderDetail)
                    {
                        dt.Rows.Add(item.continentalpartnumber, item.traza, item.total_pallets);
                    }
                    dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
                    dataGridView1.AutoSizeRowsMode    = DataGridViewAutoSizeRowsMode.AllCells;

                    dataGridView1.DataSource = dt;
                }
            }
        }