Exemple #1
0
        private void LoadChooseFromList(string id, string code, Dictionary <string, string> conditions, EditText txt)
        {
            ChooseFromList oCFLFolio = SAPChooseFromList.Init(false, code, id, this);

            if (!Object.ReferenceEquals(conditions, null) && conditions.Count > 0)
            {
                SAPChooseFromList.AddConditions(oCFLFolio, conditions);
            }
            //bind choose from list to editText
            SAPChooseFromList.Bind(id, txt);
        }
Exemple #2
0
        private void chkStatus_ClickAfter(object sboObject, SBOItemEventArg pVal)
        {
            try {
                var checkBox = (CheckBox)sboObject;

                //FOOD PLANT ----------------------------------------------------------------------------------------
                if (user.IsFoodPlant)
                {
                    if (!checkBox.Checked)
                    {
                        SAPChooseFromList.AddConditionValues(this.UIAPIRawForm.ChooseFromLists.Item("CFL_PO"), "DocNum", foodTransferDAO.GetCancelledOrders(user.WhsCode));
                    }
                    else
                    {
                        SAPChooseFromList.AddConditions(this.UIAPIRawForm.ChooseFromLists.Item("CFL_PO"), new Dictionary <string, string>()
                        {
                            { "Type", "S" }, { "Status", "R" }, { "Warehouse", "PLHE" }
                        });
                    }
                }
                //QUARANTINE ----------------------------------------------------------------------------------------
                else
                {
                    txtBags.Active = true;
                    //Stock Entry's
                    if (!checkBox.Checked)
                    {
                        txtFolio.Item.Enabled = true;
                        txtItem.Item.Enabled  = false;

                        if (this.UIAPIRawForm.ChooseFromLists.Count < 3)
                        {
                            LoadChooseFromList2("CFL_SE", "59", new Dictionary <string, string>()
                            {
                                { "Series", foodTransferDAO.GetSeries(user.WhsCode, "59", "Series").ToString() }, { "U_GLO_InMo", "E-PROD" }, { "U_GLO_Status", "O" }
                            }, txtFolio);
                        }
                        else
                        {
                            SAPChooseFromList.Bind("CFL_SE", txtFolio);
                        }
                        txtFolio.Active        = true;
                        btnCreate.Item.Enabled = false;
                    }
                    //Material List's
                    else
                    {
                        txtFolio.Item.Enabled = false;
                        txtItem.Item.Enabled  = true;
                        SAPChooseFromList.Bind("CFL_ML", txtItem);
                        txtItem.Active = true;
                    }
                }
                //--------------------------------------------------------------------------------------------------
                txtFolio.Active = true;
                mtx0.Columns.Item("C_Consumed").Visible = !checkBox.Checked ? true : false;
                mtx0.Columns.Item("C_Qty").Visible      = !checkBox.Checked ? false : true;
                mtx0.Columns.Item("C_Bags").Editable    = !checkBox.Checked ? false : true;
                ClearMatrix();

                if (!user.IsFoodPlant && checkBox.Checked)
                {
                    txtFolio.Value = foodTransferDAO.GetSeries(user.WhsCode, "59", "NextNumber").ToString();
                }
            }
            catch (Exception ex) {
                SAPException.Handle(ex, "chkStatus_ClickAfter");
            }
        }
Exemple #3
0
        private void CreateDocuments(bool cancellation)
        {
            try {
                //Validations
                if (!ValidateColumn("Existence") || !ValidateColumn("Emision"))
                {
                    return;
                }

                if (!cancellation && !ValidateColumn("BagBales"))
                {
                    return;
                }

                //Setting the Bags/Bales values and Real Quantity
                SetBagsBalesAndRealQuantity();

                //Transaction
                BeginTransaction();

                LogService.WriteInfo("Begin " + (cancellation ? "cancellation" : "Production") + " Process");

                //Invetory Exit
                var task = Task.Factory.StartNew(() => {
                    var exit   = new DocumentProduction();
                    exit.Lines = !cancellation ? components : new Component[1] {
                        productionLine
                    };
                    exit.DocEntry = docEntry;
                    exit.DocNum   = txtFolio.Value;
                    return(StockExitDI.CreateDocument(exit, user, cancellation));
                });
                task.Wait();

                if (!user.IsFoodPlant && !cancellation)
                {
                    productionLine.LineTotal = task.Result.DocTotal;
                }

                //Inventory Entry
                var task2 = Task.Factory.StartNew(() => {
                    if (!cancellation)
                    {
                        productionLine.Qty = components.Where(c => c.Prod.Equals(0)).Sum(s => s.Qty);
                    }
                    var entry   = new DocumentProduction();
                    entry.Lines = !cancellation ? new Component[1] {
                        productionLine
                    } : components;
                    entry.DocEntry = docEntry;
                    entry.DocNum   = txtFolio.Value;
                    return(StockEntryDI.CreateDocument(entry, user, cancellation));
                });

                var task3 = Task.Factory.ContinueWhenAll(new[] { task, task2 }, _ => {
                    var resultMessage = (!cancellation) ? new StringBuilder()
                                        .Append("Entrada de Producto Terminado: ").AppendLine(task2.Result.Message)
                                        .Append("Salida de Componentes: ").AppendLine(task.Result.Message)
                                                         : new StringBuilder()
                                        .Append("Salida de Producto Terminado: ").AppendLine(task.Result.Message)
                                        .Append("Entrada de Componentes: ").AppendLine(task2.Result.Message);

                    if (task.Result.Success && task2.Result.Success)
                    {
                        if (user.IsFoodPlant && !cancellation)
                        {
                            //Update Status to Closed for Production Order Document
                            var result = ProductionOrderDI.CancelDocument(docEntry, task2.Result.DocEntry, task.Result.DocEntry);
                            resultMessage.Append("Orden de Fabricación: ").AppendLine(result.Message);
                        }

                        if (cancellation)
                        {
                            var result = InventoryRevaluationDI.CreateDocument(productionLine, user, task.Result.DocEntry, docEntry);
                            if (result.Success)
                            {
                                resultMessage.Append("Revalorización de Inventario: ").AppendLine(result.Message);
                            }
                        }
                        if (StockEntryDI.UpdateDocument(task2.Result.DocEntry, task.Result.DocEntry, cancellation))
                        {
                            Commit();
                        }
                        else
                        {
                            RollBack(resultMessage.ToString());
                        }
                    }
                    else
                    {
                        RollBack(resultMessage.ToString());
                    }

                    UIApplication.ShowMessageBox(resultMessage.ToString());
                    ClearMatrix();

                    if (user.IsFoodPlant && cancellation)
                    {
                        SAPChooseFromList.AddConditionValues(this.UIAPIRawForm.ChooseFromLists.Item("CFL_PO"), "DocNum", foodTransferDAO.GetCancelledOrders(user.WhsCode));
                    }
                    else if (!user.IsFoodPlant && !cancellation)
                    {
                        txtFolio.Value = foodTransferDAO.GetSeries(user.WhsCode, "59", "NextNumber").ToString(); //OIGN
                    }
                });

                LogService.WriteInfo("Begin " + (cancellation ? "cancellation" : "Production") + " Process");
            }
            catch (Exception ex) {
                SAPException.Handle(ex, "CreateDocuments");
            }
        }
Exemple #4
0
        private void SBO_Application_ItemEvent(string FormUID, ref ItemEvent pVal, out bool BubbleEvent)
        {
            BubbleEvent = true;
            try {
                if (FormUID.Equals(this.UIAPIRawForm.UniqueID))
                {
                    if (!pVal.BeforeAction)
                    {
                        switch (pVal.EventType)
                        {
                        case BoEventTypes.et_CHOOSE_FROM_LIST:
                            try {
                                if (String.IsNullOrEmpty(SAPChooseFromList.GetValue(pVal, 0)))
                                {
                                    return;
                                }

                                txtBags.Item.Enabled = chkStatus.Checked ? false : true;
                                if (user.IsFoodPlant)
                                {
                                    //FOOD PLANT----------------------------
                                    btnCreate.Item.Enabled = !chkStatus.Checked ? true : false;
                                    btnCancel.Item.Enabled = chkStatus.Checked ? true : false;

                                    docEntry      = int.Parse(SAPChooseFromList.GetValue(pVal, 0));
                                    txtItem.Value = SAPChooseFromList.GetValue(pVal, 48);
                                    txtDate.Value = SAPDate.ParseDate(SAPChooseFromList.GetValue(pVal, 9).Substring(0, 10)).ToString("yyyyMMdd");
                                    this.UIAPIRawForm.DataSources.UserDataSources.Item("CFL_PO").ValueEx = SAPChooseFromList.GetValue(pVal, 1);
                                    SetProductionItem(SAPChooseFromList.GetValue(pVal, 3), txtItem.Value, Double.Parse(SAPChooseFromList.GetValue(pVal, 7)), !chkStatus.Checked ? 0 : foodTransferDAO.GetProdItemBags(docEntry));
                                    components     = foodTransferDAO.GetComponents(SAPChooseFromList.GetValue(pVal, 0), user.WhsCode, false);
                                    plannedQty     = GetPlannedQty(docEntry);
                                    txtQPlan.Value = plannedQty.ToString();

                                    if (chkStatus.Checked && productionLine.Bags > 0)
                                    {
                                        txtBags.Value = productionLine.Bags.ToString("#.####");
                                    }
                                    else if (chkStatus.Checked && productionLine.Bags <= 0)
                                    {
                                        txtBags.Value = "0.0000";
                                    }

                                    Task.Run(() => {
                                        FillMatrix();
                                        CalculateQuantities(components, plannedQty);
                                    });
                                }
                                else  //QUARANTINE--------------------------
                                      //Material List
                                {
                                    if (pVal.ItemUID == "txtItem")
                                    {
                                        btnCreate.Item.Enabled = true;
                                        this.UIAPIRawForm.DataSources.UserDataSources.Item("CFL_ML").ValueEx = SAPChooseFromList.GetValue(pVal, 24);
                                        SetProductionItem(SAPChooseFromList.GetValue(pVal, 0), txtItem.Value, Double.Parse(SAPChooseFromList.GetValue(pVal, 3)), 0);
                                        components = foodTransferDAO.GetComponents(SAPChooseFromList.GetValue(pVal, 0), user.WhsCode, chkStatus.Checked);
                                    }
                                    //Stock Entry
                                    else if (pVal.ItemUID == "txtFolio")
                                    {
                                        btnCancel.Item.Enabled = true;
                                        docEntry      = int.Parse(SAPChooseFromList.GetValue(pVal, 0));
                                        txtDate.Value = SAPDate.ParseDate(SAPChooseFromList.GetValue(pVal, 10).Substring(0, 10)).ToString("yyyyMMdd");
                                        this.UIAPIRawForm.DataSources.UserDataSources.Item("CFL_SE").ValueEx = SAPChooseFromList.GetValue(pVal, 1);
                                        productionLine = foodTransferDAO.GetProductionItem(docEntry, user.WhsCode);
                                        txtItem.Value  = productionLine.Desc;
                                        components     = foodTransferDAO.GetComponents(SAPChooseFromList.GetValue(pVal, 458), user.WhsCode, chkStatus.Checked);
                                    }

                                    Task.Run(() => {
                                        FillMatrix();
                                        txtQReal.Value = !chkStatus.Checked ? SAPMatrix.SumColumnQuantities(mtx0, "C_Qty", components).ToString() : productionLine.Qty.ToString();
                                    });
                                }
                            }
                            catch (Exception ex) {
                                SAPException.Handle(ex, "SBO_Application_ItemEvent");
                            }
                            break;

                        case SAPbouiCOM.BoEventTypes.et_LOST_FOCUS:
                            if (pVal.ColUID == "C_Qty")
                            {
                                if (user.IsFoodPlant)
                                {
                                    CalculateQuantities(components, plannedQty);
                                }
                                else
                                {
                                    txtQReal.Value = SAPMatrix.SumColumnQuantities(mtx0, pVal.ColUID, components).ToString();
                                }
                            }
                            break;
                        }
                    }
                }//Event for date picker
                else if (String.IsNullOrEmpty(pVal.ItemUID) && pVal.FormType == 10000075 && !user.IsFoodPlant)
                {
                    if (this.UIAPIRawForm.Selected)
                    {
                        switch (pVal.EventType)
                        {
                        case SAPbouiCOM.BoEventTypes.et_FORM_CLOSE:
                            if (pVal.ActionSuccess)
                            {
                                SAPDate.ValidateDate(txtDate, 3);
                            }
                            break;
                        }
                    }
                }
            }
            catch (Exception ex) {
                SAPException.Handle(ex, "SBO_Application_ItemEvent");
            }
        }