Exemplo n.º 1
0
        private static void ButtonConformarLotes(string formUID, ref ItemEvent oItemEvent, SAPbobsCOM.Company sbo_company, ref Application sbo_application, out bool bBubbleEvent, string sessionId)
        {
            bBubbleEvent = true;

            if (oItemEvent.BeforeAction)
            {
            }

            if (!oItemEvent.BeforeAction)
            {
                var oForm = sbo_application.Forms.Item(formUID);
                if (oItemEvent.EventType == BoEventTypes.et_CLICK)
                {
                    if (oForm.Mode == BoFormMode.fm_UPDATE_MODE)
                    {
                        List <RegistroCalidad_Lotes> lotes = new List <RegistroCalidad_Lotes>();

                        XDocument doc = XDocument.Parse(oForm.DataSources.DataTables.Item(CommonForms.FormLotesCalidad.GrdLotes.dt).SerializeAsXML(BoDataTableXmlSelect.dxs_DataOnly));

                        foreach (var Row in doc.Element("DataTable").Elements("Rows").Elements())
                        {
                            var value = Row
                                        .Element("Cells")
                                        .Elements("Cell")
                                        .Single(x => x.Element("ColumnUid").Value == "Asignar")
                                        .Element("Value")
                                        .Value;

                            if (value == "Y")
                            {
                                var _lote = new RegistroCalidad_Lotes
                                {
                                    DocEntry   = null,
                                    LineId     = null,
                                    U_BatchNum = Row.Element("Cells").Elements("Cell").Single(x => x.Element("ColumnUid").Value == "Lote").Element("Value").Value,
                                    U_Kg       = Row.Element("Cells").Elements("Cell").Single(x => x.Element("ColumnUid").Value == "Kilos").Element("Value").Value.GetDoubleFromString(",")
                                };

                                lotes.Add(_lote);
                            }
                        }

                        if (lotes != null)
                        {
                            var FatherFormUID = oForm.DataSources.UserDataSources.Item(CommonForms.FormLotesCalidad.UDFather).ValueEx;
                            var FatherForm    = sbo_application.Forms.Item(FatherFormUID);
                            FatherForm.DataSources.UserDataSources.Item(pluginForm.UDLotes).ValueEx = lotes.SerializeJson();
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        private static void ButtonFumigar(string formUID, ref ItemEvent oItemEvent, SAPbobsCOM.Company sbo_company, ref Application sbo_application, out bool bBubbleEvent, string sessionId)
        {
            //throw new NotImplementedException();
            bBubbleEvent = true;
            if (oItemEvent.BeforeAction)
            {
                if (oItemEvent.EventType == BoEventTypes.et_CLICK)
                {
                    var oForm = sbo_application.Forms.Item(formUID);
                    if (oForm.Mode != BoFormMode.fm_OK_MODE)
                    {
                        bBubbleEvent = false;
                        if (oForm.Mode == BoFormMode.fm_ADD_MODE)
                        {
                            throw new Exception("Debe crear el documento antes");
                        }

                        if (oForm.Mode == BoFormMode.fm_UPDATE_MODE)
                        {
                            throw new Exception("Debe grabar los cambios antes");
                        }

                        if (oForm.Mode == BoFormMode.fm_FIND_MODE)
                        {
                            throw new Exception("Debe buscar un registro antes");
                        }
                    }
                }
            }

            if (!oItemEvent.BeforeAction)
            {
                if (oItemEvent.EventType == BoEventTypes.et_CLICK)
                {
                    var oForm = sbo_application.Forms.Item(formUID);
                    var Doc   = CommonFunctions.GET(ServiceLayer.StockTransfers, oForm.DataSources.DBDataSources.Item(pluginForm.dbCabecera).GetValue("DocEntry", 0), null, sessionId, out _).DeserializeJsonObject <StockTransfer>();

                    var lotes = new List <RegistroCalidad_Lotes>();

                    foreach (var line in Doc.StockTransferLines)
                    {
                        foreach (var lote in line.BatchNumbers)
                        {
                            var loteCalidad = new RegistroCalidad_Lotes
                            {
                                DocEntry   = null,
                                LineId     = null,
                                U_BatchNum = lote.BatchNumber,
                                U_Kg       = lote.Quantity
                            };

                            lotes.Add(loteCalidad);
                        }
                    }

                    dynamic Cabecera = new System.Dynamic.ExpandoObject();

                    Cabecera.Tipo  = "67";
                    Cabecera.Valor = Doc.DocNum;
                    Cabecera.Lote  = lotes.SerializeJson();

                    var Fruta = oForm.DataSources.DBDataSources.Item("WTR1").GetValue("Dscription", 0);

                    if (Fruta.Contains("Pasa"))
                    {
                        var oFormCalidad = SAPFunctions.LoadFormCalidad(ref sbo_application, "PASA-20016-RG-6.1.1", sessionId, Cabecera);
                    }
                    if (Fruta.Contains("Cir"))
                    {
                        var oFormCalidad = SAPFunctions.LoadFormCalidad(ref sbo_application, "CIRUELA-GRAL-RG-6.1.1", sessionId, Cabecera);
                    }
                    if (Fruta.Contains("Nue"))
                    {
                        var oFormCalidad = SAPFunctions.LoadFormCalidad(ref sbo_application, "CIRUELA-GRAL-RG-6.1.1", sessionId, Cabecera);
                    }
                }
            }
        }