コード例 #1
0
 public static bool ShowDialogRegister()
 {
     using (var f = new FormRegister())
     {
         return(f.ShowDialog() == DialogResult.OK);
     }
 }
コード例 #2
0
        /// <summary>
        /// Checa se o registro do windows foi configurado e, se sim, seta a ConnectionString
        /// </summary>
        /// <param name="showDialog">Se exibe FormRegister, caso o registro não tenha sido configurado</param>
        public static bool CheckRegister(bool showDialog)
        {
            bool ret = false;

            try
            {
                using (var reg = new RegUtil(RegistrySource, AppName))
                {
                    reg.Check();

                    if (!reg.IsOk)
                    {
                        if (showDialog)
                        {
                            using (var f = new FormRegister())
                            {
                                if (f.ShowDialog() != DialogResult.OK)
                                {
                                    return(false);
                                }
                            }
                        }
                    }

                    if (!reg.IsOk)
                    {
                        throw new Exception("O sistema não foi configurado corretamente");
                    }

                    ConnectionString = Database.BuildConnectionString(ProviderType, reg.Server, reg.Database, reg.UserId, reg.Password, false, reg.Port).ConnectionString;

                    ret = true;
                }
            }
            catch (Exception ex)
            {
                if (showDialog)
                {
                    ShowError(ex);
                }
                else
                {
                    throw ex;
                }
            }
            return(ret);
        }