private void fill_cbolocal(string dominioid, string moduloid)
        {
            var BL = new usuariomodulolocalBL();
            var BE = new tb_usuariomodulolocal();
            BE.usuar = VariablesPublicas.Usuar.Trim();
            var dt = new DataTable();
            BE.dominioid = dominioid;
            BE.moduloid = moduloid;

            try
            {
                dt = BL.GetAll3(VariablesPublicas.EmpresaID, BE).Tables[0];
                cboLocal.DataSource = dt;
                cboLocal.ValueMember = "local";
                cboLocal.DisplayMember = "localname";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void get_dominio_modulo_local(string dominioid, string moduloid)
        {
            if (moduloid.ToString().Length == 4)
            {
                var BL = new usuariomodulolocalBL();
                var BE = new tb_usuariomodulolocal();
                var dt = new DataTable();
                BE.usuar = VariablesPublicas.Usuar.Trim();
                BE.dominioid = dominioid;
                BE.moduloid = moduloid;

                dt = BL.GetAll3(VariablesPublicas.EmpresaID, BE).Tables[0];
                if (dt.Rows.Count > 0)
                {
                    localdes.DataSource = dt;
                    localdes.ValueMember = "local";
                    localdes.DisplayMember = "localname";
                }
            }
        }
        private void get_dominio_modulo_local()
        {
            usuariomodulolocalBL BL = new usuariomodulolocalBL();
            tb_usuariomodulolocal BE = new tb_usuariomodulolocal();
            BE.usuar = VariablesPublicas.Usuar.Trim();
            DataTable dt = new DataTable();
            BE.dominioid = dominio.ToString();
            BE.moduloid = modulo.ToString();

            try
            {
                dt = BL.GetAll3(VariablesPublicas.EmpresaID, BE).Tables[0];
                cmb_local.DataSource = dt;
                cmb_local.ValueMember = "local";
                cmb_local.DisplayMember = "localname";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            //get_constantesGen(cboDominioID.SelectedValue.ToString(), cboModuloID.SelectedValue.ToString(), cboLocal.SelectedValue.ToString());
        }
        private void Metodo_VariablesStatic()
        {
            try
            {
                _dominioid = cboDominioID.SelectedValue.ToString();
                _moduloid = cboModuloID.SelectedValue.ToString();
                _local = cboLocal.SelectedValue.ToString();
                _localname = cboLocal.Text.ToString();
                _moduloname = cboModuloID.Text.ToString();
                _novalidastock = false;
                VariablesPublicas.perianio = txtPeriodo.Text.ToString().Trim();

                var BL1 = new usuariomodulolocalBL();
                var BE1 = new tb_usuariomodulolocal();
                var data = new DataTable();

                BE1.dominioid = cboDominioID.SelectedValue.ToString();
                BE1.moduloid = cboModuloID.SelectedValue.ToString();
                BE1.local = cboLocal.SelectedValue.ToString();

                data = BL1.GetAllDatos(VariablesPublicas.EmpresaID, BE1).Tables[0];
                if (data.Rows.Count > 0)
                {
                    _ctacte = data.Rows[0]["ctacte"].ToString();
                    _direcnume = data.Rows[0]["direcnume"].ToString();
                    _novalidastock = Convert.ToBoolean(data.Rows[0]["novalidastock"].ToString() == "True" ? 1 : 0);
                    _editnumdoc = Convert.ToBoolean(data.Rows[0]["editnumdoc"].ToString() == "True" ? 1 : 0);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            var xperfil = string.Empty;
            xperfil = cboDominioID.SelectedValue.ToString() + cboModuloID.SelectedValue.ToString();

            var BL = new usuariosBL();
            var BE = new tb_usuarios();
            var dt = new DataTable();

            BE.usuar = VariablesPublicas.Usuar.Trim();
            BE.idper = xperfil.Trim();
            dt = BL.GetAll_perfil(cboEmpresa.Text.Substring(0, 2), BE).Tables[0];
            if (dt.Rows.Count > 0)
            {
                _perfil = dt.Rows[0]["idper"].ToString();
            }
            else
            {
                MessageBox.Show("Asignar perfil a usuario !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (VariablesPublicas.EmpresaSigla == "WAMA" || VariablesPublicas.EmpresaSigla == "PRUEBAS")
            {
                if (_dominioid == "L0")
                {
                    if (_moduloid == "0100")
                    {
                        var frm = (DL0Logistica.MainLogistica)AbrirVentana(typeof(DL0Logistica.MainLogistica));
                        frm.perfil = _perfil;
                        frm.perianio = _perianio;
                        frm.perimes = _perimes;
                        frm.fechdigini = _fechdigini;
                        frm.fechdigfin = _fechdigfin;
                        frm.dominioid = _dominioid;
                        frm.moduloid = _moduloid;
                        frm.moduloname = _moduloname;
                        frm.local = _local;
                        frm.localname = _localname;
                        frm.ctacte = _ctacte;
                        frm.ctactename = _ctactename;
                        frm.direcnume = _direcnume;
                        frm.novalidastock = _novalidastock;
                        frm.editnumdoc = _editnumdoc;
                        frm.estabsunat = _estabsunat;
                        frm.localfeuiv = _localfeuiv;
                        frm.Show();
                    }
                }

                if (_dominioid == "70")
                {
                    if (_moduloid == "0900")
                    {
                        var frm = (D70Produccion.MainProduccion)AbrirVentana(typeof(D70Produccion.MainProduccion));
                        frm.Show();
                    }
                }

                if (_dominioid == "60")
                {
                    if (_moduloid == "0310"
                        || _moduloid == "0320"
                        || _moduloid == "0330"
                        || _moduloid == "0340"
                        || _moduloid == "0350"
                        || _moduloid == "0360"
                        || _moduloid == "0370"
                        || _moduloid == "0500"
                        || _moduloid == "0510"
                        || _moduloid == "0520"
                        || _moduloid == "0530"
                        || _moduloid == "0540")
                    {
                        var frm = (D60ALMACEN.MainAlmacen)AbrirVentana(typeof(D60ALMACEN.MainAlmacen));
                        frm.perfil = _perfil;
                        frm.perianio = _perianio;
                        frm.perimes = _perimes;
                        frm.fechdigini = _fechdigini;
                        frm.fechdigfin = _fechdigfin;
                        frm.dominioid = _dominioid;
                        frm.moduloid = _moduloid;
                        frm.moduloname = _moduloname;
                        frm.local = _local;
                        frm.localname = _localname;
                        frm.ctacte = _ctacte;
                        frm.ctactename = _ctactename;
                        frm.direcnume = _direcnume;
                        frm.novalidastock = _novalidastock;
                        frm.editnumdoc = _editnumdoc;
                        frm.estabsunat = _estabsunat;
                        frm.localfeuiv = _localfeuiv;
                        frm.Show();
                    }

                    if (_moduloid == "0100")
                    {
                        // ALMACEN DE DISTRIBUCION
                        var frm = (APT600100.MainAlmacenPT)AbrirVentana(typeof(APT600100.MainAlmacenPT));
                        frm.perfil = _perfil;
                        frm.perianio = _perianio;
                        frm.perimes = _perimes;
                        frm.fechdigini = _fechdigini;
                        frm.fechdigfin = _fechdigfin;
                        frm.dominioid = _dominioid;
                        frm.moduloid = _moduloid;
                        frm.moduloname = _moduloname;
                        frm.local = _local;
                        frm.localname = _localname;
                        frm.ctacte = _ctacte;
                        frm.ctactename = _ctactename;
                        frm.direcnume = _direcnume;
                        frm.novalidastock = _novalidastock;
                        frm.editnumdoc = _editnumdoc;
                        frm.estabsunat = _estabsunat;
                        frm.localfeuiv = _localfeuiv;
                        frm.Show();
                    }

                    if (_moduloid == "0200")
                    {
                        var frm = (D60Tienda.MainTienda)AbrirVentana(typeof(D60Tienda.MainTienda));
                        frm.toolStripTxtDomModLocal.Text = _dominioid + "-" + _moduloid + "-" + _local + "-" + _localname;
                        //frm.perfil = _perfil;
                        //frm.perianio = _perianio;
                        frm.perimes = _perimes;
                        //frm.fechdigini = _fechdigini;
                        //frm.fechdigfin = _fechdigfin;
                        frm.dominioid = _dominioid;
                        //frm.moduloid = _moduloid;
                        //frm.local = _local;
                        //frm.localname = _localname;
                        //frm.ctacte = _ctacte;
                        //frm.ctactename = _ctactename;
                        //frm.direcnume = _direcnume;
                        //frm.novalidastock = _novalidastock;
                        //frm.editnumdoc = _editnumdoc;
                        //frm.estabsunat = _estabsunat;
                        //frm.localfeuiv = _localfeuiv;
                        frm.Show();
                    }
                }
            }

            if (VariablesPublicas.EmpresaSigla == "VIALEX"
                || VariablesPublicas.EmpresaSigla == "MONTANA")
            {
                if (_dominioid == "60")
                {
                    if (_moduloid == "0100"
                        || _moduloid == "0320"
                        || _moduloid == "0330"
                        || _moduloid == "0500")
                    {
                        var frm = (MERCADERIA.MainMercaderia)AbrirVentana(typeof(MERCADERIA.MainMercaderia));
                        frm.toolStripTxtDomModLocal.Text = _dominioid + "-" + _moduloid + "-" + _local + "-" + _localname;
                        frm.Show();
                    }
                }
                if (_dominioid == "L0")
                {
                    if (_moduloid == "0100")
                    {
                        var frm = (DL0Logistica.MainLogistica)AbrirVentana(typeof(DL0Logistica.MainLogistica));
                        frm.Show();
                    }
                }
            }

            if (_dominioid == "RH")
            {
                if (_moduloid == "0100")
                {
                    var frm = (RecursosHumanos.MainRecursosHumanos)AbrirVentana(typeof(RecursosHumanos.MainRecursosHumanos));
                    frm.Show();
                }
            }

            if (_dominioid == "20")
            {
                if (_moduloid == "0130")
                {
                    var frm = (D20Comercial.MainComercial)AbrirVentana(typeof(D20Comercial.MainComercial));
                    frm.perfil = _perfil;
                    frm.perianio = _perianio;
                    frm.perimes = _perimes;
                    frm.fechdigini = _fechdigini;
                    frm.fechdigfin = _fechdigfin;
                    frm.dominioid = _dominioid;
                    frm.moduloid = _moduloid;
                    frm.local = _local;
                    frm.localname = _localname;
                    frm.ctacte = _ctacte;
                    frm.ctactename = _ctactename;
                    frm.direcnume = _direcnume;
                    frm.novalidastock = _novalidastock;
                    frm.editnumdoc = _editnumdoc;
                    frm.estabsunat = _estabsunat;
                    frm.localfeuiv = _localfeuiv;
                    frm.Show();
                }
            }

            if (_dominioid == "S0")
            {
                if (_moduloid == "0100")
                {
                    var frm = (DS0Seguridad.MainSeguridad)AbrirVentana(typeof(DS0Seguridad.MainSeguridad));
                    frm.Show();
                }
            }
        }
        private void btnOk2_Click(object sender, EventArgs e)
        {
            try
            {
                var BL1 = new usuariomodulolocalBL();
                var BE1 = new tb_usuariomodulolocal();
                var data = new DataTable();

                BE1.dominioid = cboDominioID.SelectedValue.ToString();
                BE1.moduloid = cboModuloID.SelectedValue.ToString();
                BE1.local = cboLocal.SelectedValue.ToString();

                data = BL1.GetAllDatos(VariablesPublicas.EmpresaID, BE1).Tables[0];
                if (data.Rows.Count > 0)
                {
                    VariablesPublicas.xctacte = data.Rows[0]["ctacte"].ToString();
                    VariablesPublicas.xdirecnume = data.Rows[0]["direcnume"].ToString();
                    VariablesPublicas.novalidastock = Convert.ToBoolean(data.Rows[0]["novalidastock"].ToString() == "True" ? 1 : 0);
                    VariablesPublicas.editnumdoc = Convert.ToBoolean(data.Rows[0]["editnumdoc"].ToString() == "True" ? 1 : 0);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            var xperfil = string.Empty;
            xperfil = cboDominioID.SelectedValue.ToString() + cboModuloID.SelectedValue.ToString();

            var BL = new usuariosBL();
            var BE = new tb_usuarios();
            var dt = new DataTable();

            BE.usuar = VariablesPublicas.Usuar.Trim();
            BE.idper = xperfil.Trim();
            dt = BL.GetAll_perfil(VariablesPublicas.EmpresaID, BE).Tables[0];
            if (dt.Rows.Count > 0)
            {
                VariablesPublicas.Perfil = dt.Rows[0]["idper"].ToString();
            }
            else
            {
                MessageBox.Show("Asignar perfil a usuario !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }
        private void Delete_usuariomodulolocal()
        {
            try
            {
                if (usuarl.Text.Trim().Length == 0)
                {
                    MessageBox.Show("Ingrese Usuario !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else
                {
                    if (locall.Text.Trim().Length == 0)
                    {
                        MessageBox.Show("Ingrese Local !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    else
                    {
                        var BL = new usuariomodulolocalBL();
                        var BE = new tb_usuariomodulolocal();

                        BE.usuar = usuarl.Text.Trim().ToUpper();
                        BE.dominioid = dominioid.SelectedValue.ToString().Trim();
                        BE.moduloid = moduloid.SelectedValue.ToString().Trim();
                        BE.local = locall.Text.Trim();

                        if (BL.Delete(EmpresaID, BE))
                        {
                            MessageBox.Show("Datos modificado correctamente !!!", "Confirmación", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            procesado = true;
                            NIVEL_FORMS();
                            data_Tablausuariomodulolocal();
                            limpiar_usuarioperfil();
                            form_bloqueado(false);

                            btn_nuevo.Enabled = true;
                        }
                        else
                        {
                            MessageBox.Show("Contactese con Sistemas !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void data_Tablausuariomodulolocal()
        {
            try
            {
                if (Tablausuariomodulolocal != null)
                {
                    Tablausuariomodulolocal.Rows.Clear();
                }
                var BL = new usuariomodulolocalBL();
                var BE = new tb_usuariomodulolocal();
                BE.dominioid = dominioid.SelectedValue.ToString().Trim();
                BE.moduloid = moduloid.SelectedValue.ToString().Trim();

                Tablausuariomodulolocal = BL.GetAll(EmpresaID, BE).Tables[0];
                if (Tablausuariomodulolocal.Rows.Count > 0)
                {
                    gridusuariomodulolocal.DataSource = Tablausuariomodulolocal;
                    gridusuariomodulolocal.Rows[0].Selected = false;
                    gridusuariomodulolocal.Focus();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void Insert_usuariomodulolocal()
        {
            try
            {
                if (usuarl.Text.Trim().Length == 0)
                {
                    MessageBox.Show("Ingrese Usuario !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else
                {
                    if (locall.Text.Trim().Length == 0)
                    {
                        MessageBox.Show("Ingrese Local !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    else
                    {
                        var BL = new usuariomodulolocalBL();
                        var BE = new tb_usuariomodulolocal();

                        BE.usuar = usuarl.Text.Trim().ToUpper();
                        BE.dominioid = dominioid.SelectedValue.ToString().Trim();
                        BE.moduloid = moduloid.SelectedValue.ToString().Trim();
                        BE.local = locall.Text.Trim();

                        if (BL.Insert(EmpresaID, BE))
                        {
                            MessageBox.Show("Datos grabados correctamente !!!", "Confirmación", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            procesado = true;
                            data_Tablausuariomodulolocal();
                        }
                        else
                        {
                            MessageBox.Show("Contactese con Sistemas !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }