Beispiel #1
0
        private void btnAtualizar_Click(object sender, EventArgs e)
        {
            try
            {
                if (UtilValidar.CamposValidos(uiPanelCryptocurrency))
                {
                    if (newImage)
                    {
                        int archiveId = new Archive
                        {
                            Blob = UtilImage.ImageToByte(picCriptocurrency.Image),
                        }.Gravar();

                        bool updated = new Cryptocurency
                        {
                            ArchiveId             = archiveId,
                            Name                  = uiTxtCriptocurrency.Text,
                            Base                  = uiTxtCryptocurrencyBase.Text,
                            Description           = uiTxtDescription.Text,
                            CryptocurrencyBalance = UtilConvert.ToInt(uiTxtCryptocurrencyBalance.Text),
                            CryptocurrencyUnit    = uiTxtCryptocurrencyUnit.Text
                        }.AlterarPorId();

                        if (updated)
                        {
                            new Alert(String.Format("A criptomoeda {0} foi cadastrada.", uiTxtCriptocurrency.Text), uiCSB.Toastr.Type.Info);
                            newImage = false;
                        }
                        else
                        {
                            new Alert(String.Format("A criptomoeda {0} não foi cadastrada. Tente novamente mais tarde.", uiTxtCriptocurrency.Text), uiCSB.Toastr.Type.Warning);
                            newImage = true;
                        }
                    }
                    else
                    {
                        bool response = new Cryptocurency
                        {
                            ArchiveId             = UtilConvert.ToInt(lblArchiveId.Text),
                            Name                  = uiTxtCriptocurrency.Text,
                            Base                  = uiTxtCryptocurrencyBase.Text,
                            Description           = uiTxtDescription.Text,
                            CryptocurrencyBalance = UtilConvert.ToInt(uiTxtCryptocurrencyBalance.Text),
                            CryptocurrencyUnit    = uiTxtCryptocurrencyUnit.Text
                        }.AlterarPorId();

                        new Alert(String.Format("A criptomoeda {0} foi cadastrada.", uiTxtCriptocurrency.Text), uiCSB.Toastr.Type.Info);
                    }
                }
            }
            catch (Exception ex)
            {
                new Alert(ex.Message, uiCSB.Toastr.Type.Warning);
            }
            finally
            {
                ObterCriptomoedas();
            }
        }
Beispiel #2
0
        private void btnCriar_Click(object sender, EventArgs e)
        {
            try
            {
                if (UtilValidar.CamposValidos(uiPanelCryptocurrency))
                {
                    if (newImage)
                    {
                        int archiveId = new Archive
                        {
                            Blob = UtilImage.ImageToByte(picCriptocurrency.Image),
                        }.Gravar();

                        int response = new Cryptocurency
                        {
                            ArchiveId             = archiveId,
                            Name                  = uiTxtCriptocurrency.Text,
                            Base                  = uiTxtCryptocurrencyBase.Text,
                            Description           = uiTxtDescription.Text,
                            CryptocurrencyBalance = UtilConvert.ToInt(uiTxtCryptocurrencyBalance.Text),
                            CryptocurrencyUnit    = uiTxtCryptocurrencyUnit.Text
                        }.Gravar();

                        new Alert(String.Format("A criptomoeda {0} foi cadastrada.", uiTxtCriptocurrency.Text), uiCSB.Toastr.Type.Info);
                        newImage = false;
                    }
                    else
                    {
                        int response = new Cryptocurency
                        {
                            ArchiveId             = 1,
                            Name                  = uiTxtCriptocurrency.Text,
                            Base                  = uiTxtCryptocurrencyBase.Text,
                            Description           = uiTxtDescription.Text,
                            CryptocurrencyBalance = UtilConvert.ToInt(uiTxtCryptocurrencyBalance.Text),
                            CryptocurrencyUnit    = uiTxtCryptocurrencyUnit.Text
                        }.Gravar();

                        new Alert(String.Format("A criptomoeda {0} foi cadastrada.", uiTxtCriptocurrency.Text), uiCSB.Toastr.Type.Info);
                    }
                }
            }
            catch (Exception ex)
            {
                new Alert(ex.Message, uiCSB.Toastr.Type.Warning);
            }
        }
Beispiel #3
0
 private void btnCriar_ClickAsync(object sender, EventArgs e)
 {
     try
     {
         if (UtilValidar.CamposValidos(uiPanelDados))
         {
             if (newImage)
             {
                 new Employee
                 {
                     ArchiveId = new Archive {
                         Blob = UtilImage.ImageToByte(picProfilePhoto.Image)
                     }.Gravar(),
                     Words         = UtilConvert.ToString(RandomWordsAsync(12)),
                     WordsLanguage = UtilConvert.ToString("en-US"),
                     FirstName     = UtilConvert.ToString(uiTxtPNome.Text),
                     LastName      = UtilConvert.ToString(uiTxtUNome.Text),
                     DateBirth     = UtilConvert.ToDateTime(uiTxtDataNasc.Text),
                     Gender        = UtilConvert.ToChar(uiTxtSexo.Text),
                     CPF           = uiTxtCPF.Text,
                     RG            = uiTxtRG.Text,
                     Email         = uiTxtEmail.Text,
                     StreetLine    = uiTxtLogradouro.Text,
                     //uiTxtNumero.Text,
                     //uiTxtBairro.Text,
                     Country      = uiTxtPais.Text,
                     City         = uiTxtCidade.Text,
                     Neighborhood = uiTxtBairro.Text,
                     Region       = uiTxtEstado.Text,
                     Number       = uiTxtNumero.Text,
                     PostCode     = uiTxtCep.Text,
                     MobileNumber = uiTxtTelCel.Text,
                     PhoneNumber  = uiTxtTelFixo.Text
                 }.Gravar();
             }
             else
             {
                 new Employee
                 {
                     ArchiveId     = UtilConvert.ToInt(lblArchiveId.Text),
                     Words         = UtilConvert.ToString(RandomWordsAsync(12)),
                     WordsLanguage = UtilConvert.ToString("en-US"),
                     FirstName     = UtilConvert.ToString(uiTxtPNome.Text),
                     LastName      = UtilConvert.ToString(uiTxtUNome.Text),
                     DateBirth     = UtilConvert.ToDateTime(uiTxtDataNasc.Text),
                     Gender        = UtilConvert.ToChar(uiTxtSexo.Text),
                     CPF           = uiTxtCPF.Text,
                     RG            = uiTxtRG.Text,
                     Email         = uiTxtEmail.Text,
                     StreetLine    = uiTxtLogradouro.Text,
                     //uiTxtNumero.Text,
                     //uiTxtBairro.Text,
                     Country      = uiTxtPais.Text,
                     City         = uiTxtCidade.Text,
                     Neighborhood = uiTxtBairro.Text,
                     Region       = uiTxtEstado.Text,
                     Number       = uiTxtNumero.Text,
                     PostCode     = uiTxtCep.Text,
                     MobileNumber = uiTxtTelCel.Text,
                     PhoneNumber  = uiTxtTelFixo.Text
                 }.Gravar();
             }
         }
     }
     catch (NullReferenceException)
     {
         new Alert("Preencha todos os campos antes de atualizar.", Type.Warning);
     }
     catch (Exception ex)
     {
         new Alert(ex.Message, Type.Warning);
     }
 }