private void toolStripButton1_Click(object sender, EventArgs e) { if (bsOrcamento.Current != null) { if (MessageBox.Show("Deseja reabrir Orçamento?", "Pergunta", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes) { try { using (TFTarefas ftarefa = new TFTarefas()) { ftarefa.pCd_Empresa = (bsOrcamento.Current as TRegistro_Orcamento).Cd_empresa; if (ftarefa.ShowDialog() == DialogResult.OK) { if (ftarefa.pDs_tarefa != null) { TRegistro_Tarefas rtarefa = new TRegistro_Tarefas(); rtarefa.Cd_empresa = ftarefa.pCd_Empresa; rtarefa.Ds_tarefa = ftarefa.pDs_tarefa; rtarefa.Id_orcamentostr = (bsOrcamento.Current as TRegistro_Orcamento).Id_orcamentostr; rtarefa.Nr_versaostr = (bsOrcamento.Current as TRegistro_Orcamento).Nr_versaostr; rtarefa.Login = Utils.Parametros.pubLogin; TCN_Tarefas.Gravar(rtarefa, null); } } } (bsOrcamento.Current as TRegistro_Orcamento).St_registro = "O"; TCN_Orcamento.Gravar(bsOrcamento.Current as TRegistro_Orcamento, null); MessageBox.Show("Orçamento reaberto.", "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(ex.Message.Trim(), "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
private void afterNovo() { using (TFOrcamento fOrcamento = new TFOrcamento()) { if (fOrcamento.ShowDialog() == DialogResult.OK) { if (fOrcamento.rOrcamento != null) { try { TList_CadDespesa lDespesa = TCN_CadDespesa.Busca(string.Empty, string.Empty, null); lDespesa.ForEach(p => { TRegistro_Despesas desp = new TRegistro_Despesas(); desp.Id_despesastr = p.Id_despesastr; desp.Cd_empresa = fOrcamento.rOrcamento.Cd_empresa; desp.Nr_versao = fOrcamento.rOrcamento.Nr_versao; desp.Id_orcamentostr = fOrcamento.rOrcamento.Id_orcamentostr; fOrcamento.rOrcamento.lDespesas.Add(desp); }); TCN_Orcamento.Evoluir(fOrcamento.rOrcamento, null); MessageBox.Show("Orçamento gravado com sucesso.", "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information); LimparFiltros(); cd_empresa.Text = fOrcamento.rOrcamento.Cd_empresa; id_orcamento.Text = fOrcamento.rOrcamento.Id_orcamentostr; nr_versao.Text = fOrcamento.rOrcamento.Nr_versaostr; afterBusca(); } catch (Exception ex) { MessageBox.Show(ex.Message.Trim(), "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } }
private void afterAltera() { if (bsOrcamento.Current != null) { if (!(bsOrcamento.Current as TRegistro_Orcamento).St_registro.Trim().ToUpper().Equals("A") && !(bsOrcamento.Current as TRegistro_Orcamento).St_registro.Trim().ToUpper().Equals("N")) { MessageBox.Show("Permitido alterar somente orçamento ABERTO.", "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } using (TFOrcamento fOrc = new TFOrcamento()) { fOrc.rOrcamento = bsOrcamento.Current as TRegistro_Orcamento; if (fOrc.ShowDialog() == DialogResult.OK) { try { TCN_Orcamento.Evoluir(fOrc.rOrcamento, null); MessageBox.Show("Orçamento alterado com sucesso.", "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(ex.Message.Trim(), "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); } } LimparFiltros(); cd_empresa.Text = fOrc.rOrcamento.Cd_empresa; id_orcamento.Text = fOrc.rOrcamento.Id_orcamentostr; nr_versao.Text = fOrc.rOrcamento.Nr_versaostr; afterBusca(); } } }
private void afterbusca() { bsOrcamento.DataSource = TCN_Orcamento.Buscar(vCd_Empresa, vId_Orcamento, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, null); bsOrcamento_PositionChanged(this, new EventArgs()); bsOrcamento.ResetCurrentItem(); }
private void bbbOrcamento_Click(object sender, EventArgs e) { if (bsOrcamento.Current != null) { bool flag = true; string mensagem = string.Empty; if ((bsOrcamento.Current as TRegistro_Orcamento).St_registro.Equals("A") || (bsOrcamento.Current as TRegistro_Orcamento).St_registro.Equals("O") || (bsOrcamento.Current as TRegistro_Orcamento).St_registro.Equals("T") || (bsOrcamento.Current as TRegistro_Orcamento).St_registro.Equals("J")) { if ((bsOrcamento.Current as TRegistro_Orcamento).St_registro.Equals("A") || (bsOrcamento.Current as TRegistro_Orcamento).St_registro.Equals("O")) { flag = (CamadaNegocio.Diversos.TCN_Usuario_RegraEspecial.ValidaRegra(Parametros.pubLogin, "VISAO ORCAMENTISTA", null)); mensagem = "Não tem permissão para otimizar o orcamento como orcamentista."; } if ((bsOrcamento.Current as TRegistro_Orcamento).St_registro.Equals("T") || (bsOrcamento.Current as TRegistro_Orcamento).St_registro.Equals("J")) { flag = (CamadaNegocio.Diversos.TCN_Usuario_RegraEspecial.ValidaRegra(Parametros.pubLogin, "VISAO PROJETISTA", null)); mensagem = "Não tem permissão para otimizar o orcamento como projetista."; } if (flag) { using (TFLan_EvoluirOrcamento orc = new TFLan_EvoluirOrcamento()) { orc.rOrcamento = (bsOrcamento.Current as TRegistro_Orcamento); orc.projetista = true; if (orc.ShowDialog() == DialogResult.OK) { try { if ((bsOrcamento.Current as TRegistro_Orcamento).St_registro.Equals("A") || (bsOrcamento.Current as TRegistro_Orcamento).St_registro.Equals("O")) { (bsOrcamento.Current as TRegistro_Orcamento).St_registro = "O"; } TCN_Orcamento.Evoluir(orc.rOrcamento, null); MessageBox.Show("Projeto gravado com sucesso.", "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information); afterBusca(); } catch (Exception ex) { MessageBox.Show(ex.Message.Trim(), "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } else { MessageBox.Show(mensagem, "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("Apenas Orçamento em requisição.", "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("Selecione um orcamento!", "Orçamento", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void afterBusca() { //buscar orcamento/itens bsOrcamento.DataSource = TCN_Orcamento.Buscar(cOrcamento.Cd_endereco, cOrcamento.Id_orcamentostr, cOrcamento.Nr_versaostr, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, "'H'", null); bsOrcamento_PositionChanged(this, new EventArgs()); }
private void afterBusca() { bsOrcamento.DataSource = TCN_Orcamento.Buscar(cd_empresa.Text, id_orcamento.Text, nr_versao.Text, cd_clifor.Text, string.Empty, //rbIni.Checked ? "I" : rbFin.Checked ? "F" : string.Empty, dt_ini.Text, dt_fin.Text, "= 'E'", //st_projeto.Checked ? "= 'T'" : st_finalizado.Checked ? "= 'F'" : st_aprovadorep.Checked ? "= 'R' OR isnull(a.st_registro, 'A') = 'P' " : "= 'A' OR ISNULL(a.st_registro,'A') = 'N' ", null); bsOrcamento_PositionChanged(this, new EventArgs()); bsOrcamento.ResetCurrentItem(); }
private void bb_inutilizar_Click(object sender, EventArgs e) { if (bsOrcamento.Current != null) { try { if (MessageBox.Show("Confirma Gravar Orcamento? evoluir para Em Negociação.", "Pergunta", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes) { (bsOrcamento.Current as TRegistro_Orcamento).St_registro = "N"; (bsOrcamento.Current as TRegistro_Orcamento).vl_orcamento = (bsOrcamento.Current as TRegistro_Orcamento).total_orcdesc; TList_CadCFGEmpreendimento lcfg = new TCD_CadCFGEmpreendimento().Select(null, 0, string.Empty); if (lcfg.Count.Equals(0) || lcfg[0].ValidadePropostaDias == null || lcfg[0].ValidadePropostaDias < 1) { throw new Exception("Na configuração de empreemdimento é necessário informar " + "a validade de dias para a proposta. Assim o sistema pode calcular a data de validade. " + "Não será possível finalizar a operaçao, o valor deve ser maior que zero"); } //Atribuição da data de validade do orçamento if (lcfg.Count > 0 && lcfg[0].ValidadePropostaDias != null) { (bsOrcamento.Current as TRegistro_Orcamento).Dt_validade = CamadaDados.UtilData.Data_Servidor().AddDays(Convert.ToDouble(lcfg[0].ValidadePropostaDias)); bsOrcamento.ResetCurrentItem(); } TCN_Orcamento.Evoluir(bsOrcamento.Current as TRegistro_Orcamento, null); MessageBox.Show("Orçamento gravado com sucesso.", "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information); DialogResult = DialogResult.OK; } } catch (Exception ex) { MessageBox.Show(ex.Message.Trim(), "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void afterBusca() { bsOrcamento.DataSource = TCN_Orcamento.Buscar(cd_empresa.Text, nr_orcamento.Text, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, null); bsOrcamento_PositionChanged(this, new EventArgs()); bsOrcamento.ResetCurrentItem(); }
private void toolStripLabel1_Click(object sender, EventArgs e) { if (bsOrcamento.Current == null) { return; } using (FRequisicaoCompra comp = new FRequisicaoCompra()) {//Buscar Atividades TRegistro_Orcamento orc = new TRegistro_Orcamento(); orc = (bsOrcamento.Current as TRegistro_Orcamento); orc.lOrcProjeto = TCN_OrcProjeto.Buscar((bsOrcamento.Current as TRegistro_Orcamento).Cd_empresa, (bsOrcamento.Current as TRegistro_Orcamento).Id_orcamentostr, (bsOrcamento.Current as TRegistro_Orcamento).Nr_versaostr, string.Empty, string.Empty, null); orc.lOrcProjeto.ForEach(p => { TpBusca[] filtro = new TpBusca[0]; if (!string.IsNullOrEmpty(p.Cd_empresa)) { Array.Resize(ref filtro, filtro.Length + 1); filtro[filtro.Length - 1].vNM_Campo = "a.cd_empresa"; filtro[filtro.Length - 1].vOperador = "="; filtro[filtro.Length - 1].vVL_Busca = "'" + p.Cd_empresa.Trim() + "'"; } if (!string.IsNullOrEmpty(p.Id_orcamentostr)) { Array.Resize(ref filtro, filtro.Length + 1); filtro[filtro.Length - 1].vNM_Campo = "a.id_orcamento"; filtro[filtro.Length - 1].vOperador = "="; filtro[filtro.Length - 1].vVL_Busca = p.Id_orcamentostr; } if (!string.IsNullOrEmpty(p.Nr_versaostr)) { Array.Resize(ref filtro, filtro.Length + 1); filtro[filtro.Length - 1].vNM_Campo = "a.nr_versao"; filtro[filtro.Length - 1].vOperador = "="; filtro[filtro.Length - 1].vVL_Busca = p.Nr_versaostr; } if (!string.IsNullOrEmpty(p.Id_projetostr)) { Array.Resize(ref filtro, filtro.Length + 1); filtro[filtro.Length - 1].vNM_Campo = "a.id_atividade"; filtro[filtro.Length - 1].vOperador = "="; filtro[filtro.Length - 1].vVL_Busca = p.Id_projetostr; } if (!string.IsNullOrEmpty(p.Id_registrostr)) { Array.Resize(ref filtro, filtro.Length + 1); filtro[filtro.Length - 1].vNM_Campo = "a.Id_Registro"; filtro[filtro.Length - 1].vOperador = "="; filtro[filtro.Length - 1].vVL_Busca = p.Id_registrostr; } Array.Resize(ref filtro, filtro.Length + 1); filtro[filtro.Length - 1].vOperador = "not exists "; filtro[filtro.Length - 1].vVL_Busca = " (select 1 from TB_EMP_CompraEmpreendimento x " + "where a.id_orcamento = x.id_orcamento and a.nr_versao = x.nr_versao " + "and a.ID_Atividade = x.ID_Atividade and a.ID_Ficha = x.ID_Ficha " + "and a.ID_Registro = x.ID_Registro and a.cd_empresa = x.cd_empresa) "; p.lFicha = new TCD_FichaTec().Select(filtro, 0, string.Empty); }); comp.rOrcamento = orc; if (comp.ShowDialog() == DialogResult.OK) { TList_FichaTec lficha = new TList_FichaTec(); lficha = comp.objetoItens.lFicha; //(bsOrcamento.Current as TRegistro_Orcamento).St_registro = "E"; TList_FichaTec lficha2 = new TList_FichaTec(); lficha.ForEach(p => { if (p.st_agregar) { lficha2.Add(p); } }); try { TCN_Orcamento.GravarOrcReq((bsOrcamento.Current as TRegistro_Orcamento), lficha2, null); MessageBox.Show("Requisição de compra gravada com sucesso.", "Informativo", MessageBoxButtons.OK, MessageBoxIcon.Information); LimparFiltros(); afterBusca(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
private void toolStripButton3_Click(object sender, EventArgs e) { if ((bsOrcamento.Current) != null) { if ((bsOrcamento.Current as TRegistro_Orcamento).St_registro.Equals("T")) { if (CamadaNegocio.Diversos.TCN_Usuario_RegraEspecial.ValidaRegra(Parametros.pubLogin, "VISAO PROJETISTA", null)) { if (MessageBox.Show("Orcamento está em " + (bsOrcamento.Current as TRegistro_Orcamento).Status + ", Deseja finalizar o projeto e evoluir para execução?", "Pergunta", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes) { try { bsOrcamento_PositionChanged(this, new EventArgs()); TList_FichaTec lficha = new TList_FichaTec(); //valida TList_CadCFGEmpreendimento lcfg = new TCD_CadCFGEmpreendimento().Select( new TpBusca[] { new TpBusca() { vNM_Campo = "a.cd_empresa", vOperador = "=", vVL_Busca = (bsOrcamento.Current as TRegistro_Orcamento).Cd_empresa } }, 1, string.Empty); if (string.IsNullOrEmpty(lcfg[0].tp_requisicao) || string.IsNullOrEmpty(lcfg[0].tp_requisicaodir)) { MessageBox.Show("Favor corrigir a configuração do empreendimento!\n (Tipo Requisição)", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } (bsOrcamento.Current as TRegistro_Orcamento).lOrcProjeto.ForEach(o => { o.lFicha.ForEach(p => { if (p.Tot_saldo < p.Quantidade) { p.st_agregar = true; p.quantidade_agregar = p.Quantidade; } }); }); TList_FichaTec lista_nao_cadastrados = new TList_FichaTec(); bool lista = false; (bsOrcamento.Current as TRegistro_Orcamento).lOrcProjeto.ForEach(o => { o.lFicha.ForEach(p => { if (string.IsNullOrEmpty(p.Cd_produto)) { lista_nao_cadastrados.Add(p); lista = true; } }); }); if (lista) { using (FListCadProd ls = new FListCadProd()) { ls.rLItens = lista_nao_cadastrados; if (ls.ShowDialog() == DialogResult.OK) { (bsOrcamento.Current as TRegistro_Orcamento).lOrcProjeto.ForEach(o => { o.lFicha.ForEach(p => { ls.rLItens.ForEach(i => { if (p.Ds_produto.Equals(i.Ds_produto)) { p.Cd_produto = i.Cd_produto; CamadaNegocio.Empreendimento.TCN_FichaTec.Gravar(p, null); } }); }); }); bsOrcamento.ResetCurrentItem(); } else { return; } } } using (FRequisicaoCompra comp = new FRequisicaoCompra()) {//Buscar Atividades TRegistro_Orcamento orc = new TRegistro_Orcamento(); orc = (bsOrcamento.Current as TRegistro_Orcamento); orc.lOrcProjeto = TCN_OrcProjeto.Buscar((bsOrcamento.Current as TRegistro_Orcamento).Cd_empresa, (bsOrcamento.Current as TRegistro_Orcamento).Id_orcamentostr, (bsOrcamento.Current as TRegistro_Orcamento).Nr_versaostr, string.Empty, string.Empty, null); orc.lOrcProjeto.ForEach(p => { TpBusca[] filtro = new TpBusca[0]; if (!string.IsNullOrEmpty(p.Cd_empresa)) { Array.Resize(ref filtro, filtro.Length + 1); filtro[filtro.Length - 1].vNM_Campo = "a.cd_empresa"; filtro[filtro.Length - 1].vOperador = "="; filtro[filtro.Length - 1].vVL_Busca = "'" + p.Cd_empresa.Trim() + "'"; } if (!string.IsNullOrEmpty(p.Id_orcamentostr)) { Array.Resize(ref filtro, filtro.Length + 1); filtro[filtro.Length - 1].vNM_Campo = "a.id_orcamento"; filtro[filtro.Length - 1].vOperador = "="; filtro[filtro.Length - 1].vVL_Busca = p.Id_orcamentostr; } if (!string.IsNullOrEmpty(p.Nr_versaostr)) { Array.Resize(ref filtro, filtro.Length + 1); filtro[filtro.Length - 1].vNM_Campo = "a.nr_versao"; filtro[filtro.Length - 1].vOperador = "="; filtro[filtro.Length - 1].vVL_Busca = p.Nr_versaostr; } if (!string.IsNullOrEmpty(p.Id_projetostr)) { Array.Resize(ref filtro, filtro.Length + 1); filtro[filtro.Length - 1].vNM_Campo = "a.id_atividade"; filtro[filtro.Length - 1].vOperador = "="; filtro[filtro.Length - 1].vVL_Busca = p.Id_projetostr; } if (!string.IsNullOrEmpty(p.Id_registrostr)) { Array.Resize(ref filtro, filtro.Length + 1); filtro[filtro.Length - 1].vNM_Campo = "a.Id_Registro"; filtro[filtro.Length - 1].vOperador = "="; filtro[filtro.Length - 1].vVL_Busca = p.Id_registrostr; } Array.Resize(ref filtro, filtro.Length + 1); filtro[filtro.Length - 1].vOperador = "not exists "; filtro[filtro.Length - 1].vVL_Busca = " (select 1 from TB_EMP_CompraEmpreendimento x " + "where a.id_orcamento = x.id_orcamento and a.nr_versao = x.nr_versao " + "and a.ID_Atividade = x.ID_Atividade and a.ID_Ficha = x.ID_Ficha " + "and a.ID_Registro = x.ID_Registro and a.cd_empresa = x.cd_empresa) "; p.lFicha = new TCD_FichaTec().Select(filtro, 0, string.Empty); }); comp.rOrcamento = orc; if (comp.ShowDialog() == DialogResult.OK) { lficha = comp.objetoItens.lFicha; //(bsOrcamento.Current as TRegistro_Orcamento) = comp.rOrcamento; (bsOrcamento.Current as TRegistro_Orcamento).St_registro = "E"; TList_FichaTec lficha2 = new TList_FichaTec(); lficha.ForEach(p => { if (p.st_agregar) { lficha2.Add(p); } }); TCN_Orcamento.GravarOrcReq((bsOrcamento.Current as TRegistro_Orcamento), lficha2, null); // MessageBox.Show("Orçamento gravado com sucesso.", "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information); LimparFiltros(); //cbHomologacao.Checked = true; afterBusca(); MessageBox.Show("Orçamento está aguardando em execução.", "Orçamento", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } catch (Exception ex) { MessageBox.Show(ex.Message.Trim(), "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } else { MessageBox.Show("Usuário não tem permissão de projetista para esta evolução.", "Orçamento", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } else { MessageBox.Show("Selecione um orcamento!", "Orçamento", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void OtimizarOrcamento() { if (MessageBox.Show("Deseja gerar nova versão do orçamento?", "Pergunta", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes) { if (bsOrcamento.Current != null) { if ((bsOrcamento.Current as TRegistro_Orcamento).St_registro.Trim().ToUpper().Equals("N")) { //Verificar se orçamento possui versão em Aberto if (new TCD_Orcamento().BuscarEscalar( new TpBusca[] { new TpBusca() { vNM_Campo = "a.cd_empresa", vOperador = "=", vVL_Busca = "'" + (bsOrcamento.Current as TRegistro_Orcamento).Cd_empresa.Trim() + "'" }, new TpBusca() { vNM_Campo = "a.id_orcamento", vOperador = "=", vVL_Busca = (bsOrcamento.Current as TRegistro_Orcamento).Id_orcamentostr }, new TpBusca() { vNM_Campo = "isnull(a.st_registro, 'A')", vOperador = "=", vVL_Busca = "'A'" } }, "1") != null) { MessageBox.Show("Orçamento possui versão disponivel para OTIMIZAR.", "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } string ds_tarefa = string.Empty; using (TFTarefas fTarefa = new TFTarefas()) { if (fTarefa.ShowDialog() == DialogResult.OK) { ds_tarefa = fTarefa.pDs_tarefa; } } try { TRegistro_Orcamento aux = TCN_Orcamento.GerarNovaVersao(bsOrcamento.Current as TRegistro_Orcamento, ds_tarefa, null); MessageBox.Show("Nova versão gerada com sucesso.", "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information); LimparFiltros(); cd_empresa.Text = aux.Cd_empresa; id_orcamento.Text = aux.Id_orcamentostr; nr_versao.Text = aux.Nr_versaostr; // cbAberto.Checked = true; afterBusca(); } catch (Exception ex) { MessageBox.Show(ex.Message.Trim(), "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Permitido otimizar somente orçamento que estiver em NEGOCIAÇÃO.", "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("Selecione um orcamento!", "Orçamento", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
private void afterExclui() { if (bsOrcamento.Current != null) { if (!(bsOrcamento.Current as TRegistro_Orcamento).St_registro.Trim().ToUpper().Equals("A") && !(bsOrcamento.Current as TRegistro_Orcamento).St_registro.Trim().ToUpper().Equals("N") && !(bsOrcamento.Current as TRegistro_Orcamento).St_registro.Trim().ToUpper().Equals("P")) { MessageBox.Show("Permitido alterar somente orçamento ABERTO, em NEGOCIAÇÃO ou PROCESSADO.", "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if ((bsOrcamento.Current as TRegistro_Orcamento).St_registro.Trim().ToUpper().Equals("P")) { if (new TCD_Orcamento().BuscarEscalar( new TpBusca[] { new TpBusca() { vNM_Campo = "a.cd_empresa", vOperador = "=", vVL_Busca = "'" + (bsOrcamento.Current as TRegistro_Orcamento).Cd_empresa.Trim() + "'" }, new TpBusca() { vNM_Campo = "a.id_orc", vOperador = "=", vVL_Busca = (bsOrcamento.Current as TRegistro_Orcamento).Id_orcamentostr }, new TpBusca() { vNM_Campo = "a.nr_versaoorc", vOperador = "=", vVL_Busca = (bsOrcamento.Current as TRegistro_Orcamento).Nr_versaostr }, new TpBusca() { vNM_Campo = "isnull(a.st_registro, 'A')", vOperador = "<>", vVL_Busca = "'C'" } }, "1") != null) { MessageBox.Show("Não é permitido CANCELAR orçamento PROCESSADO com PROJETO ATIVO.", "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } if (MessageBox.Show("Confirma CANCELAMENTO do orçamento corrente?", "Pergunta", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes) { try { TCN_Orcamento.Cancelar(bsOrcamento.Current as TRegistro_Orcamento, null); MessageBox.Show("Orçamento CANCELADO com sucesso.", "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information); (bsOrcamento.Current as TRegistro_Orcamento).St_registro = "C"; bsOrcamento.ResetCurrentItem(); } catch (Exception ex) { MessageBox.Show(ex.Message.Trim(), "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
private void bb_inutilizar_Click(object sender, EventArgs e) { bool flag = false, semvalor = false; try { if (bsOrcamento.Current == null) { MessageBox.Show("Selecione um projeto!", "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } else if ((bsFicha.List as List <TRegistro_FichaTec>).Where(p => p.st_agregar).ToList().FindAll(c => string.IsNullOrEmpty(c.Cd_produto)).Count > 0) { MessageBox.Show("Obrigatório informar código de produto para gerar a remessa", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } (bsFicha.List as List <TRegistro_FichaTec>).Where(p => p.st_agregar && p.quantidade_agregar > decimal.Zero).ToList().ForEach(p => { flag = true; if (vTp_Fat.Equals("Normal")) { decimal saldo = BuscarSaldoLocal(vCD_Empresa, p.Cd_produto); if (saldo.Equals(decimal.Zero)) { MessageBox.Show("Não existe saldo disponivel no estoque.\r\n" + "Produto.........: " + p.Cd_produto.Trim() + "-" + p.Ds_produto.Trim() + "\r\n" + "Local Arm.......: " + vCd_Local.Trim() + "-" + vDs_Local + "\r\n" + "Saldo Disponivel: " + saldo.ToString("N3", new System.Globalization.CultureInfo("pt-BR", true)), "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information); semvalor = true; } } }); if (!semvalor) { if (flag) { if (vTp_Fat.Equals("Normal")) { List <TRegistro_FichaTec> lficha = new List <TRegistro_FichaTec>(); (bsFicha.List as List <TRegistro_FichaTec>).Where(p => p.st_agregar && p.quantidade_agregar > decimal.Zero).ToList() .ForEach(x => lficha.Add(x)); bsCFGEmpreendimento.DataSource = TCN_CadCFGEmpreendimento.Busca((bsOrcamento.Current as TRegistro_Orcamento).Cd_empresa, string.Empty, null); bsCFGEmpreendimento.ResetCurrentItem(); TList_CadCFGEmpreendimento lcfg = TCN_CadCFGEmpreendimento.Busca(string.Empty, string.Empty, null); if (lcfg[0].tp_precoitem.Trim().Equals("0")) { lficha.ForEach(p => { p.Vl_unitario = CamadaNegocio.Estoque.TCN_LanEstoque.Valor_Medio_Est_Produto(p.Cd_empresa, p.Cd_produto, null); if (p.Vl_unitario <= decimal.Zero) { throw new Exception("Produto " + p.Cd_produto.Trim() + "-" + p.Ds_produto.Trim() + " esta com valor medio negativo no estoque."); } }); } CamadaDados.Faturamento.NotaFiscal.TRegistro_LanFaturamento rNf = Proc_Commoditties.ProcessaEmpreendimento.ProcessarEmpreendimento("N", (bsOrcamento.Current as TRegistro_Orcamento).Cd_clifor, rorcamento, lficha); TCN_Orcamento.ProcessarNFEmpreendimento(rNf, bsCFGEmpreendimento.Current as TRegistro_CadCFGEmpreendimento, bsOrcamento.Current as TRegistro_Orcamento, null); if (rNf.Tp_nota.Trim().ToUpper().Equals("P") && rNf.Cd_modelo.Trim().Equals("55")) { if (MessageBox.Show("Deseja enviar NF-e para a receita agora?", "Pergunta", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes) { //Verificar se é nota de produto ou mista object obj = new CamadaDados.Faturamento.Cadastros.TCD_CadSerieNF().BuscarEscalar( new TpBusca[] { new TpBusca() { vNM_Campo = "a.nr_serie", vOperador = "=", vVL_Busca = "'" + rNf.Nr_serie + "'" } }, "a.tp_serie"); if (obj != null) { if (obj.ToString().Trim().ToUpper().Equals("P") || obj.ToString().Trim().ToUpper().Equals("M")) { try { using (srvNFE.TFGerenciarNFe fGerNfe = new srvNFE.TFGerenciarNFe()) { fGerNfe.rNfe = CamadaNegocio.Faturamento.NotaFiscal.TCN_LanFaturamento.BuscarNF(rNf.Cd_empresa, rNf.Nr_lanctofiscalstr, null); fGerNfe.ShowDialog(); } } catch (Exception ex) { MessageBox.Show("Erro enviar NF-e: " + ex.Message.Trim(), "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else if (obj.ToString().Trim().ToUpper().Equals("S")) { try { CamadaDados.Faturamento.NotaFiscal.TRegistro_LanFaturamento rNfs = CamadaNegocio.Faturamento.NotaFiscal.TCN_LanFaturamento.BuscarNF(rNf.Cd_empresa, rNf.Nr_lanctofiscalstr, null); NFES.TGerarRPS.CriarArquivoRPS(rNfs.rCfgNfe, new List <CamadaDados.Faturamento.NotaFiscal.TRegistro_LanFaturamento>() { rNfs }); MessageBox.Show("NFS-e enviada com sucesso. Aguarde alguns segundos e consulte o status do lote.", "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show("Erro enviar NFS-e: " + ex.Message.Trim(), "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } } } DialogResult = DialogResult.OK; } else { MessageBox.Show("Para confirmar deve selecionar algum item.", "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } catch (Exception ex) { MessageBox.Show("" + ex.Message.Trim(), "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); } }