private void btnServidor_Click(object sender, EventArgs e)
 {
     //De esta forma se controla que solo un servidor este iniciado
     //Se implemento de esta forma debido a una pregunta de un estudiante en la tercer sesion de dudas
     //Para mas detalle, ver el video de la tercer sesion de dudas del 17/11/2020 Tutor Henry Mendez
     if (frmServidor.IndicarFormularioServidorIniciado)
     {
         MessageBox.Show("Servidor ya se encuentra iniciado");
     }
     else
     {
         frmServidor.IndicarFormularioServidorIniciado = true;
         servidor = new frmServidor();
         servidor.Show();
     }
 }
Beispiel #2
0
 private void btnEntrar_Click(object sender, EventArgs e)
 {
     Cursor.Current = Cursors.WaitCursor;
     try
     {
         if (
             (string.IsNullOrEmpty(txtServerDataSource.Text)) ||
             (string.IsNullOrWhiteSpace(txtServerDataSource.Text)) ||
             (string.IsNullOrEmpty(txtServerInitialCatalog.Text)) ||
             (string.IsNullOrWhiteSpace(txtServerInitialCatalog.Text))
             )
         {
             lblResultado.Text = "Valores en formato incorrecto o nulos";
         }
         else
         {
             DataLayer datalayer = new DataLayer(txtServerDataSource.Text.Trim(), txtServerInitialCatalog.Text.Trim());
             if (!datalayer.testData())
             {
                 lblResultado.Text = datalayer._LatestError;
             }
             else
             {
                 this.Hide();
                 frmServidor mainForm = new frmServidor();
                 mainForm.Show();
             }
         }
     }
     catch (Exception ex)
     {
         lblResultado.Text = ex.Message;
         throw;
     }
     Cursor.Current = Cursors.Default;
 }
        private void frmMdi_Load(object sender, EventArgs e)
        {
            RegistryKey equipoLocal = Registry.CurrentUser;

            equipoLocal = equipoLocal.OpenSubKey(@"Software\\VeoSystem", true);
            string Licencia = string.Empty;

            if (equipoLocal == null)
            {
                this.Hide();

                equipoLocal = Registry.CurrentUser;
                equipoLocal = equipoLocal.OpenSubKey(@"Software", true);

                RegistryKey VeoSystem = equipoLocal.CreateSubKey("VeoSystem");

                VeoSystem.SetValue("Caja", 0, RegistryValueKind.String);
                VeoSystem.SetValue("Licencia", "", RegistryValueKind.String);
                VeoSystem.SetValue("FechaInst", "", RegistryValueKind.String);
                VeoSystem.SetValue("Servidor", "", RegistryValueKind.String);
                VeoSystem.SetValue("Empresa", "", RegistryValueKind.String);
                VeoSystem.SetValue("Tipo", "", RegistryValueKind.String);
                VeoSystem.SetValue("Version", "", RegistryValueKind.String);

                Sistema_Cls.GblStrLicencia = VeoSystem.GetValue("Licencia").ToString();

                if (Sistema_Cls.GblStrLicencia == "")
                {
                    frmLicencia frmlicencias = new frmLicencia();
                    if (frmlicencias.ShowDialog() == DialogResult.OK)
                    {
                        frmServidor frmservidor = new frmServidor();
                        if (frmservidor.ShowDialog() == DialogResult.OK)
                        {
                            Empresa_Ctl objEmpresa = new Empresa_Ctl();

                            Licencia = Sistema_Cls.DesEncripta(Sistema_Cls.GblStrLicencia = VeoSystem.GetValue("Licencia").ToString());

                            BindingSource dbEmpresa = new BindingSource();
                            dbEmpresa.DataSource = objEmpresa.DatosEmpresa(Licencia);

                            frmEmpresa frmempresa = new frmEmpresa(dbEmpresa);
                            if (frmempresa.ShowDialog() == DialogResult.OK)
                            {
                                frmInicioSesion frminiciosesion = new frmInicioSesion();
                                if (frminiciosesion.ShowDialog() == DialogResult.OK)
                                {
                                    this.Show();
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                equipoLocal = Registry.CurrentUser;
                equipoLocal = equipoLocal.OpenSubKey(@"Software", true);

                RegistryKey VeoSystem = equipoLocal.CreateSubKey("VeoSystem");

                Sistema_Cls.GblStrLicencia = VeoSystem.GetValue("Licencia").ToString();
                Sistema_Cls.GblStrServidor = VeoSystem.GetValue("Servidor").ToString();
                Sistema_Cls.GblStrEmpresa  = VeoSystem.GetValue("Empresa").ToString();

                this.Hide();

                if (Sistema_Cls.GblStrLicencia == "")
                {
                    frmLicencia frmlicencias = new frmLicencia();
                    if (frmlicencias.ShowDialog() == DialogResult.OK)
                    {
                        frmServidor frmservidor = new frmServidor();
                        if (frmservidor.ShowDialog() == DialogResult.OK)
                        {
                            Empresa_Ctl objEmpresa = new Empresa_Ctl();

                            Licencia = Sistema_Cls.DesEncripta(Sistema_Cls.GblStrLicencia = VeoSystem.GetValue("Licencia").ToString());

                            BindingSource dbEmpresa = new BindingSource();
                            dbEmpresa.DataSource = objEmpresa.DatosEmpresa(Licencia);

                            frmEmpresa frmempresa = new frmEmpresa(dbEmpresa);
                            if (frmempresa.ShowDialog() == DialogResult.OK)
                            {
                                frmInicioSesion frminiciosesion = new frmInicioSesion();
                                if (frminiciosesion.ShowDialog() == DialogResult.OK)
                                {
                                    this.Show();
                                }
                            }
                            else
                            {
                                this.Close();
                            }
                        }
                        else
                        {
                            this.Close();
                        }
                    }
                    else
                    {
                        this.Close();
                    }
                }
                else
                {
                    if (Sistema_Cls.GblStrServidor == "")
                    {
                        frmServidor frmservidor = new frmServidor();
                        if (frmservidor.ShowDialog() == DialogResult.OK)
                        {
                            Empresa_Ctl objEmpresa = new Empresa_Ctl();

                            Licencia = Sistema_Cls.DesEncripta(Sistema_Cls.GblStrLicencia = VeoSystem.GetValue("Licencia").ToString());

                            BindingSource dbEmpresa = new BindingSource();
                            dbEmpresa.DataSource = objEmpresa.DatosEmpresa(Licencia);

                            frmEmpresa frmempresa = new frmEmpresa(dbEmpresa);
                            if (frmempresa.ShowDialog() == DialogResult.OK)
                            {
                                frmInicioSesion frminiciosesion = new frmInicioSesion();
                                if (frminiciosesion.ShowDialog() == DialogResult.OK)
                                {
                                    this.Show();
                                }
                            }
                            else
                            {
                                this.Close();
                            }
                        }
                        else
                        {
                            this.Close();
                        }
                    }
                    else
                    {
                        if (Sistema_Cls.GblStrEmpresa == "")
                        {
                            Empresa_Ctl objEmpresa = new Empresa_Ctl();

                            Licencia = Sistema_Cls.DesEncripta(Sistema_Cls.GblStrLicencia = VeoSystem.GetValue("Licencia").ToString());

                            BindingSource dbEmpresa = new BindingSource();
                            dbEmpresa.DataSource = objEmpresa.DatosEmpresa(Licencia);

                            frmEmpresa frmempresa = new frmEmpresa(dbEmpresa);
                            if (frmempresa.ShowDialog() == DialogResult.OK)
                            {
                                frmInicioSesion frminiciosesion = new frmInicioSesion();
                                if (frminiciosesion.ShowDialog() == DialogResult.OK)
                                {
                                    this.Show();
                                }
                            }
                            else
                            {
                                this.Close();
                            }
                        }
                        else
                        {
                            frmInicioSesion frminiciosesion = new frmInicioSesion();
                            if (frminiciosesion.ShowDialog() == DialogResult.OK)
                            {
                                this.Show();
                            }
                            else
                            {
                                this.Close();
                            }
                        }
                    }
                }
            }
        }