private bool SalvouArquivo() { string NomeArquivo = ""; try { if (this.TemArquivoCarregado) { NomeArquivo = _NomeArquivo; this.AtualizarDadosLista(); _ListaCheckItens.SalvarArquivo(NomeArquivo); _ArquivoEstaSalvo = true; return(true); } else { SaveFileDialog dlgSalvar = new SaveFileDialog(); DialogResult Resp; dlgSalvar.Title = "Escolha o nome do modelo de Check List para salvar"; dlgSalvar.Filter = "Check List Preenchido (*.chkl)|*.chkl"; Resp = dlgSalvar.ShowDialog(); if (Resp == System.Windows.Forms.DialogResult.OK) { NomeArquivo = dlgSalvar.FileName; this.AtualizarDadosLista(); _ListaCheckItens.SalvarArquivo(NomeArquivo); _NomeArquivo = NomeArquivo; this.Text = "Check List - Editor de Check List - " + csUtil.ParteNomeArquivo(_NomeArquivo, csUtil.enuParteNomeArquivo.NomeExtencao); _ArquivoEstaSalvo = true; return(true); } else { return(false); } } } catch (Exception _Exception) { MessageBox.Show("Erro ao salvar o arquivo\n" + NomeArquivo + "\n" + _Exception.ToString(), "Salvar Modelo de Check List", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } }
private bool SalvouArquivo() { //if ((_ArquivoEstaSalvo) && (this.TemArquivoCarregado)) //{ // return false; //} if (this.VerificarReutilizacao()) { MessageBox.Show("Este CheckList parece estar sendo reutilizado.\nUm CheckList não deve ser reutilizado, crie um novo CheckList a partir do modelo.\nSuas alterações não serão salvas!", "CheckList sendo reutilizado", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } else { string NomeArquivo = ""; try { if (this.TemArquivoCarregado) { NomeArquivo = _NomeArquivo; _ListaCheckItens.SalvarArquivo(NomeArquivo); this.Atualizar(); _ArquivoEstaSalvo = true; return(true); } else { SaveFileDialog dlgSalvar = new SaveFileDialog(); DialogResult Resp; AppSettingsReader AppConfig = new AppSettingsReader(); string SugestaoNomeArquivo = ""; string PastaPadrao = ""; dlgSalvar.Title = "Escolha o nome do Check List para salvar"; dlgSalvar.Filter = "Check List Preenchido (*.chklp)|*.chklp"; try { PastaPadrao = AppConfig.GetValue("PastaPadrao", typeof(string)).ToString(); dlgSalvar.InitialDirectory = PastaPadrao; } catch (Exception e) { MessageBox.Show(e.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); } SugestaoNomeArquivo = _ListaCheckItens.TextoItemIdentificador; if (SugestaoNomeArquivo.Trim().Length > 0) { dlgSalvar.FileName = SugestaoNomeArquivo.Trim(); } else { dlgSalvar.FileName = _ListaCheckItens.Nome; } Resp = dlgSalvar.ShowDialog(); if (Resp == System.Windows.Forms.DialogResult.OK) { NomeArquivo = dlgSalvar.FileName; _ListaCheckItens.SalvarArquivo(NomeArquivo); this.Atualizar(); _NomeArquivo = NomeArquivo; this.Text = "Check List - " + _ListaCheckItens.Nome + " (" + _NomeArquivo + ")"; _ArquivoEstaSalvo = true; return(true); } else { return(false); } } } catch (Exception _Exception) { MessageBox.Show("Erro ao salvar o arquivo\n" + NomeArquivo + "\n" + _Exception.ToString(), "Salvar Modelo de Check List", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } } }