Ejemplo n.º 1
0
        /// <summary>
        /// Eventos de la forma activa
        /// </summary>
        /// <param name="FormUID">Id de la forma</param>
        /// <param name="pVal">Propiedades de la forma</param>
        /// <param name="BubbleEvent">Evento true/false</param>
        public override void eventos(string FormUID, ref SAPbouiCOM.ItemEvent pVal, out bool bubbleEvent)
        {
            bubbleEvent = true;
            try
            {
                if (pVal.BeforeAction == false && pVal.FormType == FRM_TRANSFERENCIA_DE_STOCK)
                {
                    if (pVal.EventType == BoEventTypes.et_FORM_RESIZE)
                    {
                        _oForm = _Application.Forms.GetFormByTypeAndCount(pVal.FormType, pVal.FormTypeCount);
                        OcultarControlesVentana(_oForm);
                        CrearCamposDeUsuario(_oForm);
                    }

                    if (pVal.EventType == BoEventTypes.et_FORM_CLOSE)
                    {
                        if (_oContadorFormas == 1)
                        {
                            _Application.ItemEvent      -= new _IApplicationEvents_ItemEventEventHandler(SBO_Application_ItemEvent);
                            _Application.StatusBarEvent -= new SAPbouiCOM._IApplicationEvents_StatusBarEventEventHandler(SBO_Application_StatusBarEvent);
                            Dispose();
                            application            = null;
                            company                = null;
                            _oTransferenciaDeStock = false;
                            Addon.typeList.RemoveAll(p => p._forma == formID);
                            return;
                        }
                        else
                        {
                            _oContadorFormas -= 1;
                        }
                    }

                    if (pVal.EventType == BoEventTypes.et_FORM_ACTIVATE)
                    {
                        _oForm = _Application.Forms.GetFormByTypeAndCount(pVal.FormType, pVal.FormTypeCount);
                        CrearCamposDeUsuario(_oForm);
                    }
                }

                if (pVal.BeforeAction == true && pVal.FormType == FRM_TRANSFERENCIA_DE_STOCK)
                {
                    if (pVal.ItemUID == TXT_SERIE && pVal.CharPressed == CHAR_PRESS_ENTER && pVal.EventType == BoEventTypes.et_KEY_DOWN)
                    {
                        _oForm          = _Application.Forms.GetFormByTypeAndCount(pVal.FormType, pVal.FormTypeCount);
                        _oTxtSerie      = _oForm.Items.Item(TXT_SERIE).Specific;
                        _oAlmacenOrigen = _oForm.Items.Item(TXT_ALMACEN_ORIGEN).Specific;
                        _oForm.Select();
                        if (!string.IsNullOrEmpty(_oTxtSerie.Value.ToString()))
                        {
                            _oForm.Select();
                            AgregarArticulo(_oForm, _oTxtSerie.Value.ToString(), _oAlmacenOrigen.Value.ToString());
                            _oForm.Select();
                        }
                        else
                        {
                            _Application.MessageBox("Capture el número de serie");
                        }
                        bubbleEvent = false;
                        return;
                    }

                    if (pVal.EventType == BoEventTypes.et_KEY_DOWN && pVal.ItemUID == GRID_ARTICULOS && pVal.ColUID == COLUMNA_SERIE_INICIO && pVal.CharPressed == CHAR_PRESS_ENTER)
                    {
                        bubbleEvent = false;
                        return;
                    }
                    if (pVal.EventType == BoEventTypes.et_KEY_DOWN && pVal.ItemUID == GRID_ARTICULOS && pVal.ColUID == COLUMNA_SERIE_FIN && pVal.CharPressed == CHAR_PRESS_ENTER)
                    {
                        bubbleEvent = false;
                        return;
                    }

                    if (pVal.EventType == BoEventTypes.et_KEY_DOWN && pVal.ItemUID == GRID_ARTICULOS && pVal.ColUID == COLUMNA_SERIE && pVal.CharPressed == CHAR_PRESS_ENTER)
                    {
                        bubbleEvent = false;
                        return;
                    }

                    if (pVal.EventType == BoEventTypes.et_ITEM_PRESSED && pVal.ItemUID == BTN_CREAR && pVal.InnerEvent == true)
                    {
                        bubbleEvent = false;
                        return;
                    }

                    if (pVal.EventType == BoEventTypes.et_ITEM_PRESSED && pVal.ItemUID == BTN_CREAR && pVal.InnerEvent == false)
                    {
                        _oForm       = _Application.Forms.GetFormByTypeAndCount(pVal.FormType, pVal.FormTypeCount);
                        oBtnCrearSAP = _oForm.Items.Item(BTN_CREAR).Specific;

                        if (oBtnCrearSAP.Caption == "Crear")
                        {
                            string msgError = ValidarStatusSolicitudGrid(_oForm);

                            if (!string.IsNullOrEmpty(msgError))
                            {
                                _Application.MessageBox(msgError);
                                bubbleEvent = false;
                                bubbleEvent = false;
                                return;
                            }
                        }
                    }
                }

                if (pVal.BeforeAction == true && pVal.FormType == -FRM_TRANSFERENCIA_DE_STOCK)
                {
                    if (pVal.EventType == BoEventTypes.et_COMBO_SELECT && pVal.ItemUID == TIPO_MOVIMIENTO)
                    {
                        _oForm = _Application.Forms.GetFormByTypeAndCount(pVal.FormType, pVal.FormTypeCount);
                        _oCmbTipoMovimiento = _oForm.Items.Item(TIPO_MOVIMIENTO).Specific;

                        if (!string.IsNullOrEmpty(_oCmbTipoMovimiento.Value.ToString()))
                        {
                            if (_oForm.Mode == BoFormMode.fm_ADD_MODE)
                            {
                                if (_Application.MessageBox("Estas seguro de cambiar el tipo de movimiento sin crear." + Environment.NewLine + "¿Desea continuar?", 2, "Si", "No") == 1)
                                {
                                    try
                                    {
                                        _oTxtPromotor.Value = "";
                                    }
                                    catch (Exception)
                                    {
                                    }
                                }
                                else
                                {
                                    bubbleEvent = false;
                                }
                            }
                        }
                    }
                }



                if (pVal.BeforeAction == false && pVal.FormType == -FRM_TRANSFERENCIA_DE_STOCK)
                {
                    if (pVal.EventType == BoEventTypes.et_COMBO_SELECT && pVal.ItemUID == TIPO_MOVIMIENTO)
                    {
                        _oForm = _Application.Forms.GetFormByTypeAndCount(pVal.FormType, pVal.FormTypeCount);
                        _oForm.Freeze(true);
                        SAPbouiCOM.Form F1 = _Application.Forms.GetFormByTypeAndCount(Convert.ToInt32(_oForm.TypeEx.TrimStart('-')), _oForm.TypeCount);
                        F1.Freeze(true);
                        _oTxtPromotor       = F1.Items.Item(TXT_PROMOTOR).Specific;
                        _oTxtNombrePromotor = F1.Items.Item(TXT_NOMBRE_PROMOTOR).Specific;
                        _oTxtSerie          = F1.Items.Item(TXT_SERIE).Specific;
                        _oCmbTipoMovimiento = _oForm.Items.Item(TIPO_MOVIMIENTO).Specific;


                        if (!string.IsNullOrEmpty(_oCmbTipoMovimiento.Value.ToString()))
                        {
                            F1.Items.Item(TXT_SERIE).Enabled = true;
                            TipoMovimiento            = _oCmbTipoMovimiento.Value.ToString().TrimEnd(' ');
                            _oTxtFechaContabilizacion = F1.Items.Item(TXT_FECHA_CONTABILIZACION).Specific;
                            _oTxtFechaDocumento       = F1.Items.Item(TXT_FECHA_DOCUMENTO).Specific;

                            if (TipoMovimiento != "PROMOTORES - OFICINAS" && TipoMovimiento != "OFICINAS - PROMOTORES")
                            {
                                if (_oForm.Mode == BoFormMode.fm_ADD_MODE)
                                {
                                    _oTxtPromotor.Value       = Extensor.ObtenerSecretaria(_Company, "U_codigo_secretaria");
                                    _oTxtNombrePromotor.Value = Extensor.ObtenerSecretaria(_Company, "T0.U_nombre_secretaria");
                                }
                            }
                            else
                            {
                                if (_oForm.Mode == BoFormMode.fm_ADD_MODE)
                                {
                                    _oTxtPromotor.Value       = "";
                                    _oTxtNombrePromotor.Value = "";
                                }
                            }

                            if (TipoMovimiento == "PROMOTORES - OFICINAS" || TipoMovimiento == "OFICINAS - PROMOTORES")
                            {
                                if (_oForm.Mode == BoFormMode.fm_ADD_MODE)
                                {
                                    //if (Extensor.ValidarImpresionCorteSolicitudes(_Company))
                                    //{
                                    if (F1.Items.Item(TXT_FECHA_DOCUMENTO).Enabled == true)
                                    {
                                        _oTxtFechaContabilizacion.Value = DateTime.Now.ToString("yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture);
                                        _oTxtFechaDocumento.Value       = DateTime.Now.ToString("yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture);
                                        F1.Items.Item(TXT_FECHA_CONTABILIZACION).Enabled = false;
                                        F1.Items.Item(TXT_PROMOTOR).Click();
                                        F1.Items.Item(TXT_FECHA_DOCUMENTO).Enabled = false;
                                    }
                                    //}
                                    //else
                                    //{
                                    //    if (F1.Items.Item(TXT_FECHA_DOCUMENTO).Enabled == true)
                                    //    {
                                    //        DateTime hoy = DateTime.Now;
                                    //        DateTime mañana = hoy.AddDays(1);
                                    //        _oTxtFechaContabilizacion.Value = hoy.ToString("yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture).ToString();
                                    //        _oTxtFechaDocumento.Value = mañana.ToString("yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture).ToString();
                                    //        F1.Items.Item(TXT_FECHA_CONTABILIZACION).Enabled = false;
                                    //        F1.Items.Item(TXT_PROMOTOR).Click();
                                    //        F1.Items.Item(TXT_FECHA_DOCUMENTO).Enabled = false;
                                    //    }
                                    //}
                                }
                            }
                            else
                            {
                                if (_oForm.Mode == BoFormMode.fm_ADD_MODE)
                                {
                                    F1.Items.Item(TXT_PROMOTOR).Click();
                                    F1.Items.Item(TXT_FECHA_CONTABILIZACION).Enabled = true;
                                    _oTxtFechaContabilizacion.Value = DateTime.Now.ToString("yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture);
                                    F1.Items.Item(TXT_PROMOTOR).Click();
                                    F1.Items.Item(TXT_FECHA_DOCUMENTO).Enabled = true;
                                    _oTxtFechaDocumento.Value = DateTime.Now.ToString("yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture);
                                }
                            }
                        }

                        _oForm.Freeze(false);
                        F1.Freeze(false);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Error en método 'eventos' *clsTransferenciaDeStock* : " + ex.Message);
            }
        }