Esempio n. 1
0
        protected virtual void AddCentroDeCostos(string id, string style, bool obligatorio)
        {
            var cbCentroDeCostos = new DropDownList {
                ID = id, Width = Unit.Pixel(200)
            };

            cbCentroDeCostos.Style.Value = style;

            var cbEmpresa = GetControlFromView(TipoDocumentoHelper.CONTROL_NAME_PARENTI01) as DropDownList;
            var cbLinea   = GetControlFromView(TipoDocumentoHelper.CONTROL_NAME_PARENTI02) as DropDownList;

            var cbCentroDeCostosWrapper = new CentroDeCostoDropDownListWrapper(cbCentroDeCostos, !obligatorio);

            cbCentroDeCostosWrapper.AddParent <Empresa>(cbEmpresa);
            cbCentroDeCostosWrapper.AddParent <Linea>(cbLinea);

            BindingManager.BindCentroDeCostos(cbCentroDeCostosWrapper);

            cbCentroDeCostos.Attributes.Add("AddAllItem", !obligatorio ? "1" : "0");

            if (cbEmpresa != null)
            {
                cbEmpresa.SelectedIndexChanged += cbEmpresa_SelectedIndexChanged;
                cbEmpresa.AutoPostBack          = true;

                AddChildrenToControl(cbEmpresa.ID, id, BINDCENTRODECOSTO);
            }

            if (cbLinea != null)
            {
                cbLinea.SelectedIndexChanged += cbLinea_SelectedIndexChanged;
                cbLinea.AutoPostBack          = true;

                AddChildrenToControl(cbLinea.ID, id, BINDCENTRODECOSTO);
            }
            AddControlToView(cbCentroDeCostos);
        }
Esempio n. 2
0
        protected virtual void cbEmpresa_SelectedIndexChanged(object sender, EventArgs e)
        {
            var cbEmpresa = sender as DropDownList;

            if (cbEmpresa == null)
            {
                return;
            }

            var childs = GetChildrenForControl(cbEmpresa.ID);

            foreach (var child in childs)
            {
                if (child.StartsWith(BINDCOCHE))
                {
                    var id         = child.Substring(BINDCOCHE.Length);
                    var cbVehiculo = GetControlFromView(id) as DropDownList;
                    var all        = cbVehiculo.Attributes["AddAll"] == "1";

                    var cbLinea         = GetControlFromView(id) as DropDownList;
                    var cbTransportista = GetControlFromView(TipoDocumentoHelper.CONTROL_NAME_PARENTI07) as DropDownList;

                    var cbVehiculoWrapper = new MovilDropDownListWrapper(cbVehiculo, false);
                    cbVehiculoWrapper.AddParent <Empresa>(cbEmpresa);
                    cbVehiculoWrapper.AddParent <Linea>(cbLinea);
                    if (cbTransportista != null)
                    {
                        cbVehiculoWrapper.AddParent <Transportista>(cbTransportista);
                    }
                    cbVehiculoWrapper.AddAllItem = all;

                    BindingManager.BindMovil(cbVehiculoWrapper);
                }
                else if (child.StartsWith(BINDLINEA))
                {
                    var id      = child.Substring(BINDLINEA.Length);
                    var cbLinea = GetControlFromView(id) as DropDownList;

                    var ddlLinea = new DropDownListBaseWrapper <Linea>(cbLinea, TipoDocumento.Linea == null);
                    ddlLinea.AddParent <Empresa>(cbEmpresa);

                    if (TipoDocumento.Linea != null)
                    {
                        BindingManager.BindPlanta(ddlLinea, TipoDocumento.Linea.Id);
                    }
                    else
                    {
                        BindingManager.BindPlanta(ddlLinea);
                    }
                }
                else if (child.StartsWith(BINDTRANSPORTISTA))
                {
                    var id      = child.Substring(BINDTRANSPORTISTA.Length);
                    var cbTrans = GetControlFromView(id) as DropDownList;
                    var cbLinea = GetControlFromView(TipoDocumentoHelper.CONTROL_NAME_PARENTI02) as DropDownList;
                    var all     = cbTrans.Attributes["AddAllItem"] == "1";

                    var ddlTransportista = new TransportistaDropDownListWrapper(cbTrans, all);
                    ddlTransportista.AddParent <Linea>(cbLinea);

                    BindingManager.BindTransportista(ddlTransportista);
                }
                else if (child.StartsWith(BINDEQUIPO))
                {
                    var id = child.Substring(BINDEQUIPO.Length);

                    var cbLinea  = GetControlFromView(TipoDocumentoHelper.CONTROL_NAME_PARENTI02) as DropDownList;
                    var cbEquipo = GetControlFromView(id) as DropDownList;

                    var ddlEquipo = new EquipoDropDownListWrapper(cbEquipo);
                    ddlEquipo.AddParent <Empresa>(cbEmpresa);
                    ddlEquipo.AddParent <Linea>(cbLinea);

                    BindingManager.BindEquipo(ddlEquipo);
                }
                else if (child.StartsWith(BINDEMPLEADO))
                {
                    var id = child.Substring(BINDEMPLEADO.Length);

                    var cbEmpleado = GetControlFromView(id) as DropDownList;
                    var cbLinea    = GetControlFromView(TipoDocumentoHelper.CONTROL_NAME_PARENTI02) as DropDownList;

                    var all = cbEmpleado.Attributes["AddSinEmpleado"] == "1";

                    var cbEmpleadoWrapper = new EmpleadoDropDownListWrapper(cbEmpleado, false, all);
                    cbEmpleadoWrapper.AddParent <Empresa>(cbEmpresa);
                    cbEmpleadoWrapper.AddParent <Linea>(cbLinea);

                    BindingManager.BindEmpleados(cbEmpleadoWrapper);
                }
                else if (child.StartsWith(BINDCLIENTE))
                {
                    var id               = child.Substring(BINDCLIENTE.Length);
                    var cbCliente        = GetControlFromView(id) as DropDownList;
                    var cbLinea          = GetControlFromView(TipoDocumentoHelper.CONTROL_NAME_PARENTI02) as DropDownList;
                    var all              = cbCliente.Attributes["AddAllItem"] == "1";
                    var cbClienteWrapper = new ClienteDropDownListWrapper(cbCliente, all);
                    cbClienteWrapper.AddParent <Empresa>(cbEmpresa);
                    cbClienteWrapper.AddParent <Linea>(cbLinea);
                    BindingManager.BindCliente(cbClienteWrapper);
                }
                else if (child.StartsWith(BINDCENTRODECOSTO))
                {
                    var id = child.Substring(BINDCENTRODECOSTO.Length);
                    var cbCentroDeCosto        = GetControlFromView(id) as DropDownList;
                    var cbLinea                = GetControlFromView(TipoDocumentoHelper.CONTROL_NAME_PARENTI02) as DropDownList;
                    var all                    = cbCentroDeCosto.Attributes["AddAllItem"] == "1";
                    var cbCentroDeCostoWrapper = new CentroDeCostoDropDownListWrapper(cbCentroDeCosto, all);
                    cbCentroDeCostoWrapper.AddParent <Empresa>(cbEmpresa);
                    cbCentroDeCostoWrapper.AddParent <Linea>(cbLinea);
                    BindingManager.BindCentroDeCostos(cbCentroDeCostoWrapper);
                }
                else if (child.StartsWith(BINDTANQUE))
                {
                    var id              = child.Substring(BINDTANQUE.Length);
                    var cbTanque        = GetControlFromView(id) as DropDownList;
                    var cbEquipo        = GetControlFromView(TipoDocumentoHelper.CONTROL_NAME_PARENTI19) as DropDownList;
                    var cbLinea         = GetControlFromView(TipoDocumentoHelper.CONTROL_NAME_PARENTI02) as DropDownList;
                    var all             = cbTanque.Attributes["AddAllItem"] == "1";
                    var cbTanqueWrapper = new TanqueDropDownListWrapper(cbTanque, all);
                    cbTanqueWrapper.AddParent <Empresa>(cbEmpresa);
                    cbTanqueWrapper.AddParent <Linea>(cbLinea);
                    cbTanqueWrapper.AddParent <Equipo>(cbEquipo);
                    BindingManager.BindTanque(cbTanqueWrapper);
                }
            }
        }