private void BtnRemover_Click(object sender, EventArgs e) { try { if (dtgDados.CurrentRow == null) { MessageBox.Show("Selecione um registro na linha", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } string Id = dtgDados.CurrentRow.Cells["Id"].Value.ToString(); if (list_fase_financeiro_dto.Exists(x => x.ID.ToString() == Id)) { ADMINISTRACAO_DTO fase_financeiro = list_fase_financeiro_dto.Find(x => x.ID.ToString() == Id); if (fase_financeiro.OPERACAO != SysDTO.Operacoes.Inclusao) { new FINANCEIRO_BLL().Excluir_FaseFinanceiro((int)fase_financeiro.ID); } list_fase_financeiro_dto.Remove(fase_financeiro); PopularGrid(); } else { MessageBox.Show("Registro não encontrado. Por favor, reinicie o programa.\nCaso o erro insista, entre em contato com o administrador do sistema.", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void BtnAdicionar_Click(object sender, EventArgs e) { try { ADMINISTRACAO_DTO fase_financeiro = new ADMINISTRACAO_DTO(); fase_financeiro.ID_FINANCEIRO = (int)financeiro_dto.ID; if (financeiro_dto.ADMINISTRACAO.Count > 0) { var orderByDescending = financeiro_dto.ADMINISTRACAO.OrderByDescending(x => x.LAYOUT_TELA); fase_financeiro.LAYOUT_TELA = orderByDescending.FirstOrDefault().LAYOUT_TELA; } else { fase_financeiro.LAYOUT_TELA = 0; } frmCad_Administracao_Fases frmCad_Financeiro_Fases = new frmCad_Administracao_Fases(fase_financeiro, financeiro_dto.ID_SERVICO); DialogResult result = frmCad_Financeiro_Fases.ShowDialog(); if (result == DialogResult.OK) { fase_financeiro = frmCad_Financeiro_Fases.administracao_dto; fase_financeiro.ID_FINANCEIRO = financeiro_dto.ID == null ? 0 : (int)financeiro_dto.ID; fase_financeiro.OPERACAO = SysDTO.Operacoes.Inclusao; list_fase_financeiro_dto.Add(fase_financeiro); PopularGrid(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
public List <ADMINISTRACAO_DTO> Listar() { using (SqlConnection cn = new SqlConnection(strConnection)) { List <ADMINISTRACAO_DTO> SYS_PERFIL = new List <ADMINISTRACAO_DTO>(); try { SqlDataReader dr = null; StringBuilder SQL_ = new StringBuilder(); SQL_.Append("SELECT "); SQL_.Append("* "); SQL_.Append("FROM "); SQL_.Append("ADMINISTRACAO "); cn.Open(); SqlCommand cmd = new SqlCommand(SQL_.ToString(), cn); dr = cmd.ExecuteReader(); while (dr.Read()) { ADMINISTRACAO_DTO DTO = new ADMINISTRACAO_DTO(); DTO.ID = Convert.ToInt32(dr["ID"]); DTO.ID_STATUS_ADMINISTRACAO_FASES = dr["ID_STATUS_ADMINISTRACAO_FASES"] == DBNull.Value ? 0 : Convert.ToInt32(dr["ID_STATUS_ADMINISTRACAO_FASES"]); DTO.FASE = Convert.ToString(dr["FASE"]); DTO.OBSERVACAO = dr["OBSERVACAO"].ToString(); DTO.DATA = dr["COR"] == DBNull.Value? (DateTime?)null : Convert.ToDateTime(dr["COR"].ToString()); SYS_PERFIL.Add(DTO); } return(SYS_PERFIL); } catch (SqlException ex) { throw new Exception(ex.ToString()); } catch (Exception ex) { throw new Exception(ex.ToString()); } finally { cn.Close(); } } }
public frmCad_Administracao_Fases(ADMINISTRACAO_DTO administracao_dto, int ID_SERVICO) { InitializeComponent(); this.ID_SERVICO = ID_SERVICO; this.administracao_dto = administracao_dto; PopularCombos(); if (this.administracao_dto.ID != null) { PopularDados(); cboFase.Enabled = false; } else { Random random = new Random(); this.administracao_dto.ID = random.Next(); tabControl1.TabPages.Remove(tabDetalhe); } }
private void BtnAlterar_Click(object sender, EventArgs e) { try { if (dtgDados.CurrentRow == null) { MessageBox.Show("Selecione um registro na linha", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } string Id = dtgDados.CurrentRow.Cells["Id"].Value.ToString(); if (list_fase_financeiro_dto.Exists(x => x.ID.ToString() == Id)) { ADMINISTRACAO_DTO administracao = list_fase_financeiro_dto.First(x => x.ID.ToString() == Id); frmCad_Administracao_Fases frmCad_Financeiro_Fases = new frmCad_Administracao_Fases(administracao, financeiro_dto.ID_SERVICO); DialogResult result = frmCad_Financeiro_Fases.ShowDialog(); if (result == DialogResult.OK) { foreach (ADMINISTRACAO_DTO fASE_FINANCEIRO in list_fase_financeiro_dto.FindAll(x => x.ID.ToString() == Id)) { fASE_FINANCEIRO.DATA = administracao.DATA; fASE_FINANCEIRO.FASE = administracao.FASE; fASE_FINANCEIRO.OBSERVACAO = fASE_FINANCEIRO.OBSERVACAO; fASE_FINANCEIRO.ID_FINANCEIRO = financeiro_dto.ID == null ? 0 : (int)financeiro_dto.ID; if (fASE_FINANCEIRO.OPERACAO != SysDTO.Operacoes.Inclusao) { fASE_FINANCEIRO.OPERACAO = SysDTO.Operacoes.Alteracao; } } PopularGrid(); } } else { MessageBox.Show("Registro não encontrado. Por favor, reinicie o programa.\nCaso o erro insista, entre em contato com o administrador do sistema.", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); } }