private void OnBuscarSeriales(object sender, EventArgs e)
        {
            //Variables auxiliares.
            WMSBusinessService.Location Cliente;
            string   NumeroDelDocumento = "";
            DateTime?FechaUno;
            DateTime?FechaDos;

            WMSBusinessService.Document Documento = null;

            //Evaluo si fue seleccionado un Cliente para busqueda
            if (View.comboCliente.SelectedIndex != -1)
            {
                Cliente = (WMSBusinessService.Location)View.comboCliente.SelectedItem;
            }
            else
            {
                //Cliente = null;
                Util.ShowError("Debe seleccionar el cliente.");
                return;
            }

            //Evaluo si hay un numero de documento ingresado.
            if (View.NumeroDocumento.Text != "")
            {
                NumeroDelDocumento = View.NumeroDocumento.Text;
                try
                {
                    Documento = service.GetDocument(new WMSBusinessService.Document()
                    {
                        DocNumber = NumeroDelDocumento
                    }).First();
                }
                catch (Exception)// ex)
                {
                    //Util.ShowError("Hubo un error al cargar el tipo de documento");
                    //return;
                    Documento = null;
                }
            }
            else
            {
                NumeroDelDocumento = null;
            }

            //Evaluar fecha 1
            if (View._FechaDesde.SelectedDate != null)
            {
                FechaUno = View._FechaDesde.SelectedDate;
            }
            else
            {
                FechaUno = null;
            }

            //Evaluar fecha 2
            if (View._FechaHasta.SelectedDate != null)
            {
                FechaDos = View._FechaHasta.SelectedDate;
            }
            else
            {
                FechaDos = null;
            }

            //La lista con los resultados.
            View.Model.ListaSerialesNoCargados = service.GetLabel(new WMSBusinessService.Label
            {
                CreTerminal = Cliente.LocationID.ToString(),
                Node        = new Node {
                    NodeID = NodeType.PreLabeled
                },
                ReceivingDocument = Documento
            }).Where(f => f.Node.NodeID == 1 && f.CreTerminal == Cliente.LocationID.ToString()).ToList();
            //&& f.CreationDate == FechaUno && f.CreationDate <= FechaDos
        }
        private void OnSaveDetails(object sender, EventArgs e)
        {
            //Validacion si no existen datos para guardar
            if (View.Model.ListRecords.Rows.Count == 0)
                return;

            //Variables Auxiliares
            DataInformation DataInformationSerial;
            DataDefinitionByBin DataDefinitionControlIsRequired;
            Object ChildrenValue, ChildrenLabel;
            ShowData DetailDataSave;
            string XmlData;
            bool ControlIsRequired;

            try
            {
                try
                {
                    foreach (DataRow DataRow in View.Model.ListRecords.Rows)
                    {
                        //Inicializo la lista de los datos a convertir en Xml
                        View.Model.ListDetailsDataSave = new List<ShowData>();
                        //Obtengo los datos de cada campo con su nombre
                        foreach (DataColumn c in View.Model.ListRecords.Columns)
                        {
                            //Obtengo el label y el valor digitado
                            ChildrenLabel = c.ColumnName;
                            ChildrenValue = DataRow[c.ColumnName].ToString();

                            //Evaluo si el campo es obligatorio
                            ControlIsRequired = true;
                            DataDefinitionControlIsRequired = (View.Model.CamposDetails.Where(f => f.DataDefinition.Code == ChildrenLabel).Count() > 0) ? View.Model.CamposDetails.Where(f => f.DataDefinition.Code == ChildrenLabel).First() : null;
                            if (DataDefinitionControlIsRequired != null)
                            {
                                if (DataDefinitionControlIsRequired.DataDefinition.IsRequired == true && String.IsNullOrEmpty(ChildrenValue.ToString()))
                                    ControlIsRequired = false;
                                else
                                    ControlIsRequired = true;
                            }
                            //Evaluo si puedo continuar dependiendo de si el dato era requerido y fue digitado o no
                            if (ControlIsRequired)
                            {
                                //Creo el ShowData con los datos de ChildrenLabel y ChildrenValue
                                DetailDataSave = new ShowData
                                {
                                    DataKey = ChildrenLabel.ToString(),
                                    DataValue = ChildrenValue.ToString()
                                };
                                //Adiciono cada dato a la lista
                                View.Model.ListDetailsDataSave.Add(DetailDataSave);
                            }
                            else
                            {
                                Util.ShowError("El campo " + ChildrenLabel.ToString() + " no puede ser vacio.");
                                return;
                            }

                            //Cargo el dato para la variable de ultimos procesados
                            View.Model.UltimosProcesados = View.Model.UltimosProcesados + ChildrenValue.ToString() + " \t ";

                        }
                        //Convierto el listado de datos a un Xml
                        XmlData = Util.XmlSerializerWF(View.Model.ListDetailsDataSave);
                        //Creo el DataInformation del Serial para el Xml
                        DataInformationSerial = new DataInformation
                        {
                            Entity = new ClassEntity { ClassEntityID = 20 },
                            EntityRowID = Int32.Parse(DataRow[0].ToString()),
                            XmlData = XmlData,
                            CreationDate = DateTime.Now,
                            CreatedBy = App.curUser.UserName,
                            ModDate = DateTime.Now
                        };
                        //Guardo el Xml en la tabla DataInformation
                        DataInformationSerial = service.SaveDataInformation(DataInformationSerial);

                        //Ejecuto el proceso para cargar los datos a las tablas
                        CargarDatosXML(DataInformationSerial);

                        View.Model.UltimosProcesados = View.Model.UltimosProcesados + "\n";
                    }
                }
                catch (Exception ex)
                { Util.ShowError(ex.Message); }


                //COMPLETAR DOCUMENTO
                service.CreatePurchaseReceipt(View.Model.HeaderDocument);

                WindowInfo confirm = new WindowInfo();
                confirm.Txt_Mensaje.Text = View.Model.UltimosProcesados;
                confirm.ShowDialog();

                //Mensaje de confirmacion
                Util.ShowMessage("Datos Guardados exitosamente.");

                #region Nuevo Codigo

                DocumentoConsultado = service.GetDocument(new Document { DocNumber = View.NumeroDelDocumento.Text }).Where(f => f.DocNumber == View.NumeroDelDocumento.Text).ToList().First();
                View.Model.ListaSerialesNoCargados = service.GetLabel(new WMSBusinessService.Label
                {
                    Node = new Node { NodeID = NodeType.PreLabeled },
                    CreTerminal = View.Model.RecordCliente.LocationID.ToString(),
                    ReceivingDocument = DocumentoConsultado
                }).Where(f => f.Node.NodeID == 1 && f.ReceivingDocument == DocumentoConsultado).ToList();

                Util.ShowMessage("Los equipos cargados fueron guardados satisfactoriamente. \n"
                    + "Equipos cargados: " + View.Model.ListRecords.Rows.Count + " \n"
                    + "Equipos No cargador por error en la comunicacion con el servidor principal: " + View.Model.ListaSerialesNoCargados.Count);

                #endregion
                //Inicializo los campos de ingreso
                LimpiarDatosIngresoSeriales();
            }
            catch (Exception Ex) { Util.ShowError("Hubo un error guardando los datos, por favor vuelva a intentarlo: " + Ex.Message); }
        }