示例#1
0
        void View_CreateNewTask(object sender, EventArgs e)
        {
            //Create the new Count Task y la Selecciona. Igual que create Empty document

            ProcessWindow pw = new ProcessWindow("Creating New Counting Task ...");

            try
            {
                Document document = new Document
                {
                    DocType      = docType,
                    CrossDocking = false,
                    IsFromErp    = false,
                    Location     = App.curLocation,
                    Company      = App.curCompany,
                    Date1        = DateTime.Today,
                    CreatedBy    = App.curUser.UserName
                };

                document = service.CreateNewDocument(document, true);

                View.Model.DocumentList.Add(document);

                View.DgDocument.Items.Refresh();

                pw.Close();
                Util.ShowMessage("Task Document " + document.DocNumber + " created.");


                View.ExpSetup.IsExpanded = true;

                //LoadDetails(document);
                View.CboToDo.IsEnabled     = true;
                View.CboToDo.SelectedIndex = -1;
                View.Model.Document        = document;
            }
            catch (Exception ex)
            {
                pw.Close();
                Util.ShowError("Document could not be created. \n" + ex.Message);
            }
        }
示例#2
0
        private void NewTask()
        {
            WMSServiceClient serv = new WMSServiceClient();

            DocumentType docType = new DocumentType {
                DocClass = new DocumentClass {
                    DocClassID = SDocClass.Task
                }
            };

            docType.DocTypeID = SDocType.CountTask;

            // CAA [2010/05/05] Valida que se incluyan las columnas necesarias en el reporte
            // Indica si utiliza Product para la programacion del conteo.
            bool useProduct = true;

            if (cboToDo.SelectedIndex == 0) //Only BIN
            {
                useProduct = false;
                if (!products.Columns.Contains("BinCode"))
                {
                    Util.ShowError("BinCode column missing.");
                    return;
                }
            }
            else
            if (cboToDo.SelectedIndex == 1)     // BIN & PRODUCT
            {
                if (!products.Columns.Contains("BinCode") || !products.Columns.Contains("Product"))
                {
                    Util.ShowError("BinCode and/or Product columns are missing.");
                    return;
                }
            }

            Document document = new Document
            {
                DocType      = docType,
                CrossDocking = false,
                IsFromErp    = false,
                Location     = App.curLocation,
                Company      = App.curCompany,
                Date1        = DateTime.Today,
                CreationDate = DateTime.Now,
                CreatedBy    = App.curUser.UserName,
                Notes        = cboToDo.SelectedIndex.ToString()
            };

            document = serv.CreateNewDocument(document, true); // SaveDocument(document);


            // Details
            foreach (DataRow row in products.Rows)
            {
                //  ojo...  siempre deben enviar los alias "producto" "binCode" en el reporte !!!
                Product prod = null;
                try
                {
                    if (!string.IsNullOrEmpty(row["Product"].ToString()) && useProduct)
                    {
                        prod = serv.GetProduct(new Product {
                            ProductCode = row["Product"].ToString()
                        })[0];
                    }
                }
                catch { }

                Bin bin = null;
                try
                {
                    if (!string.IsNullOrEmpty(row["BinCode"].ToString()))
                    {
                        bin = serv.GetBin(new Bin {
                            BinCode = row["BinCode"].ToString()
                        })[0];
                    }
                }
                catch { }

                //Crea el BinTask en el server
                BinByTask binByTask = new BinByTask
                {
                    CreatedBy    = App.curUser.UserName,
                    CreationDate = DateTime.Now,
                    Bin          = bin,
                    Product      = prod,
                    TaskDocument = document,
                    Status       = new Status {
                        StatusID = DocStatus.New
                    }
                };

                try { serv.SaveBinByTask(binByTask); }
                catch  { continue; }
            }

            Util.ShowMessage("Counting Task " + document.DocNumber + " was created.");
            ClosePopup();
        }
示例#3
0
        private void OnExecute(object sender, DataEventArgs <DocumentConcept> e)
        {
            //if (string.IsNullOrEmpty(View.TxtComment.Text.Trim()))
            //{
            //    Util.ShowError("Please enter the adjustment cause or observation.");
            //    return;
            //}

            if (e.Value == null)
            {
                Util.ShowError("Please select the adjustment cause.");
                return;
            }



            int count = 1;
            int step  = 0;

            Document curDocument = new Document
            {
                DocType = new DocumentType {
                    DocTypeID = SDocType.InventoryAdjustment
                },
                DocConcept   = e.Value,
                CreatedBy    = App.curUser.UserName,
                Location     = App.curLocation,
                Company      = App.curCompany,
                IsFromErp    = false,
                CrossDocking = false,
                Comment      = View.TxtComment.Text.Trim(),
                Date1        = DateTime.Now
            };

            if (Util.GetConfigOption("REASON2ERP").Equals("T"))
            {
                curDocument.Notes = curDocument.DocConcept.Name.ToUpper();
            }


            ProcessWindow pw = new ProcessWindow("Processing the Adjustment ... ");

            try
            {
                //Header del Documento de Ajuste
                curDocument = service.CreateNewDocument(curDocument, true);
                step        = 1; //Creo el header del documento

                DocumentLine curLine;
                foreach (DocumentLine docLine in View.Model.LinesToProcess)
                {
                    docLine.Document   = curDocument;
                    docLine.Location   = App.curLocation;
                    docLine.LineNumber = count++;

                    //LAbel Origen de la transaccion, guardada en lao notes de la linea
                    WpfFront.WMSBusinessService.Label source = service.GetLabel(new WpfFront.WMSBusinessService.Label {
                        LabelID = long.Parse(docLine.LinkDocNumber)
                    }).First();

                    curLine = service.SaveAdjustmentTransaction(docLine, source);
                    if (curLine.Note != "Adjust OK.")
                    {
                        throw new Exception(curLine.Note);
                    }
                }

                step = 2; //Creo las lineas

                service.CreateInventoryAdjustment(curDocument);


                View.BtnExecute.IsEnabled = false;
                ClearForms();
                LoadHistAdjustments();

                pw.Close();
                Util.ShowMessage("Adjustment document " + curDocument.DocNumber + " was created.");
            }
            catch (Exception ex)
            {
                pw.Close();

                if (step > 0)
                {
                    curDocument.DocStatus = new Status {
                        StatusID = DocStatus.Cancelled
                    };
                    curDocument.Comment = "Cancelled: " + ex.Message;
                    service.UpdateDocument(curDocument);
                }

                Util.ShowError("Adjustment document could not be created.\n" + ex.Message);
            }
        }
        private void OnConfirmBasicData(object sender, EventArgs e)
        {
            Object         ChildrenValue, ChildrenLabel;
            ShowData       HeaderDataSave;
            string         XmlData;
            string         CodigoCampo;
            DataDefinition IsRequiredField;
            bool           ControlIsRequired;

            //Inicializo la lista de los datos a convertir en Xml
            View.Model.ListHeaderDataSave = new List <ShowData>();
            //Obtengo los datos de los campos
            foreach (UIElement UIElement in View.GetStackPanelHeader.Children)
            {
                try
                {
                    //Obtengo el label y el valor digitado
                    ChildrenLabel = UIElement.GetType().GetProperty("UcLabel").GetValue(UIElement, null);
                    ChildrenValue = UIElement.GetType().GetProperty("UcValue").GetValue(UIElement, null);
                    //Obtengo el codigo del campo
                    CodigoCampo = UIElement.GetType().GetProperty("Name").GetValue(UIElement, null).ToString();
                    CodigoCampo = CodigoCampo.Replace("f_", "");
                    //Traigo sus datos de creacion
                    IsRequiredField = service.GetDataDefinition(new DataDefinition {
                        Code = CodigoCampo
                    }).First();
                    //Evaluo si el campo es obligatorio
                    if (IsRequiredField.IsRequired == true && String.IsNullOrEmpty(ChildrenValue == null ? "" : 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 CodigoCampo y ChildrenValue
                        HeaderDataSave = new ShowData
                        {
                            DataKey   = CodigoCampo.ToString(),
                            DataValue = ChildrenValue == null ? "" : ChildrenValue.ToString()
                        };
                        //Adiciono el ShowData al listado para crear el Xml
                        View.Model.ListHeaderDataSave.Add(HeaderDataSave);
                    }
                    else
                    {
                        Util.ShowError("El campo " + ChildrenLabel.ToString() + " no puede ser vacio.");
                        return;
                    }
                }
                catch { continue; }
            }
            try
            {
                //Convierto el listado de datos a un Xml
                XmlData = Util.XmlSerializerWF(View.Model.ListHeaderDataSave);
                //Asigno los datos del documento para guardar
                View.Model.HeaderDocument.Location = LocationDespachos;
                View.Model.HeaderDocument.DocType  = new DocumentType {
                    DocTypeID = SDocType.SalesOrder
                };
                View.Model.HeaderDocument.IsFromErp    = false;
                View.Model.HeaderDocument.CrossDocking = false;
                View.Model.HeaderDocument.Vendor       = service.GetAccount(new Account {
                    AccountCode = WmsSetupValues.DEFAULT
                }).First();
                View.Model.HeaderDocument.Customer = service.GetAccount(new Account {
                    AccountCode = WmsSetupValues.DEFAULT
                }).First();
                View.Model.HeaderDocument.Date1     = DateTime.Now;
                View.Model.HeaderDocument.CreatedBy = App.curUser.UserName;
                View.Model.HeaderDocument.Company   = new Company {
                    CompanyID = App.curCompany.CompanyID
                };
                //Guardo el Documento
                View.Model.HeaderDocument = service.CreateNewDocument(View.Model.HeaderDocument, true);
                //Creo el DataInformation del Header para el Xml
                View.Model.DataInformationHeader = new DataInformation
                {
                    Entity = new ClassEntity {
                        ClassEntityID = 6
                    },
                    EntityRowID  = View.Model.HeaderDocument.DocID,
                    XmlData      = XmlData,
                    CreationDate = DateTime.Now,
                    CreatedBy    = App.curUser.UserName
                };
                //Guardo el Xml en la tabla DataInformation
                View.Model.DataInformationHeader = service.SaveDataInformation(View.Model.DataInformationHeader);
                //Inhabilito el boton de Guardar, muestro Cancelar y oculto Nuevo
                View.GetButtonConfirmar.IsEnabled = false;
                View.GetButtonNuevo.Visibility    = Visibility.Collapsed;
                View.GetButtonCancelar.Visibility = Visibility.Visible;
                //Inhabilito el combobox de bin de ingreso
                View.GetListBinInicio.IsEnabled = false;
                //Muestro el boton para mostrar los datos del header y oculto header
                View.GetTextHideShowHeader.Visibility = Visibility.Visible;
                View.GetBorderHeader.Visibility       = Visibility.Collapsed;
                //Cargo los datos para el detalle, los seriales y muestro
                CargarSeriales();
                CargarDatosDetails();
                View.BorderDetails.Visibility = Visibility.Visible;
                //Muestro el mensaje de confirmacion
                Util.ShowMessage("El documento se guardo satisfactoriamente");
            }
            catch (Exception Ex) { Util.ShowError("Hubo un error durante el proceso: " + Ex.Message); }
        }