private void CarregarValores() { try { DataTable dt = new DataTable(); dt = c_ftpconfig.CarregarFtpConfig("select localsetuparquivo,remotosetup,remotoversao,usuarioftp,senhaftp from ftpconfig where idftpconfig = 1;"); localSetupFile = dt.Rows[0][@"localsetuparquivo"].ToString(); remoteSetupFile = dt.Rows[0][@"remotosetup"].ToString(); remoteVersionFile = dt.Rows[0][@"remotoversao"].ToString(); usuarioftp = dt.Rows[0]["usuarioftp"].ToString(); senhaftp = dt.Rows[0]["senhaftp"].ToString(); } catch (System.IndexOutOfRangeException exOut) { MessageBox.Show("Não existe configuração de FTP, por favor configure o FTP antes de verificar se á atualizações!\nERROR: " + exOut.Message, "SGS", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); } }
private void Funcao(string funcao) { switch (funcao) { case "salvar": m_ftpConfig.idftpconfig = 1; m_ftpConfig.localsetuparquivo = txtDiretorioSalvarSetup.Text; m_ftpConfig.remotosetup = txtDiretorioSetupUpdate.Text; m_ftpConfig.remotoversao = txtDiretorioVersaoUpdate.Text; m_ftpConfig.usuarioftp = txtUsuarioFTP.Text; m_ftpConfig.senhaftp = txtSenhaFTP.Text; if (VerificarFTPConfig()) { if (MessageBox.Show("Deseja salvar as configurações de FTP?", "SGS", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { c_ftpConfig.NovoFtpConfig(m_ftpConfig); MessageBox.Show("Salvo com sucesso!", "SGS", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } } else { if (MessageBox.Show("Deseja alterar as configurações de FTP?", "SGS", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { c_ftpConfig.AlterarFtpConfig(m_ftpConfig); MessageBox.Show("Atualizado com sucesso!", "SGS", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } } break; case "get": if (VerificarFTPConfig() == true) { this.Text = "Configurações servidor FTP"; btnSalvar.Text = "Salvar"; txtUsuarioFTP.Text = string.Empty; txtSenhaFTP.Text = string.Empty; txtDiretorioVersaoUpdate.Text = string.Empty; txtDiretorioSetupUpdate.Text = string.Empty; txtDiretorioSalvarSetup.Text = string.Empty; } else if (VerificarFTPConfig() == false) { this.Text = "Alterar configurações servidor FTP"; btnSalvar.Text = "Alterar"; DataTable dt = new DataTable(); dt = c_ftpConfig.CarregarFtpConfig("select * from ftpconfig where idftpconfig = 1;"); txtUsuarioFTP.Text = dt.Rows[0]["usuarioftp"].ToString(); txtSenhaFTP.Text = dt.Rows[0]["senhaftp"].ToString(); txtDiretorioSalvarSetup.Text = dt.Rows[0]["localsetuparquivo"].ToString(); txtDiretorioSetupUpdate.Text = dt.Rows[0]["remotosetup"].ToString(); txtDiretorioVersaoUpdate.Text = dt.Rows[0]["remotoversao"].ToString(); } break; default: break; } }