public static string Excluir(TRegistro_CadHistorico val, BancoDados.TObjetoBanco banco) { bool st_transacao = false; TCD_CadHistorico qtb_hist = new TCD_CadHistorico(); try { if (banco == null) { st_transacao = qtb_hist.CriarBanco_Dados(true); } else { qtb_hist.Banco_Dados = banco; } val.St_registro = "C"; qtb_hist.Gravar(val); if (st_transacao) { qtb_hist.Banco_Dados.Commit_Tran(); } return(val.Cd_historico); } catch (Exception ex) { if (st_transacao) { qtb_hist.Banco_Dados.RollBack_Tran(); } throw new Exception("Erro excluir historico: " + ex.Message.Trim()); } finally { if (st_transacao) { qtb_hist.deletarBanco_Dados(); } } }
public static string Gravar(TRegistro_CadHistorico val, BancoDados.TObjetoBanco banco) { bool st_transacao = false; TCD_CadHistorico qtb_hist = new TCD_CadHistorico(); try { if (banco == null) { st_transacao = qtb_hist.CriarBanco_Dados(true); } else { qtb_hist.Banco_Dados = banco; } val.Cd_historico = CamadaDados.TDataQuery.getPubVariavel(qtb_hist.Gravar(val), "@P_CD_HISTORICO"); if (st_transacao) { qtb_hist.Banco_Dados.Commit_Tran(); } return(val.Cd_historico); } catch (Exception ex) { if (st_transacao) { qtb_hist.Banco_Dados.RollBack_Tran(); } throw new Exception("Erro gravar historico: " + ex.Message.Trim()); } finally { if (st_transacao) { qtb_hist.deletarBanco_Dados(); } } }
private void BB_Novo_Click(object sender, EventArgs e) { using (TFLanCaixa FLanCaixa = new TFLanCaixa()) { FLanCaixa.dsLanCaixa.DataSource = bindingSourceCaixa; FLanCaixa.dsLanCaixa.AddNew(); (FLanCaixa.dsLanCaixa.Current as TRegistro_LanCaixa).Vl_Anterior = VL_DifCX.Value; (FLanCaixa.dsLanCaixa.Current as TRegistro_LanCaixa).Cd_ContaGer = cbContaGer.SelectedItem != null?cbContaGer.SelectedValue.ToString() : string.Empty; if (FLanCaixa.ShowDialog() == DialogResult.OK) { //Lancar Centro Resultado if (CamadaNegocio.ConfigGer.TCN_CadParamGer.BuscaVL_Bool("CRESULTADO_EMPRESA", (FLanCaixa.dsLanCaixa.Current as TRegistro_LanCaixa).Cd_Empresa, null).Trim().ToUpper().Equals("S")) { //Verificar se historico possui centro resultado cadastrado object obj = new TCD_CadHistorico().BuscarEscalar( new TpBusca[] { new TpBusca() { vNM_Campo = "a.cd_historico", vOperador = "=", vVL_Busca = "'" + (FLanCaixa.dsLanCaixa.Current as TRegistro_LanCaixa).Cd_Historico.Trim() + "'" } }, "a.cd_centroresult"); if (obj == null ? false : !string.IsNullOrEmpty(obj.ToString())) { (bindingSourceCaixa.Current as TRegistro_LanCaixa).lCustoLancto.Add( new CamadaDados.Financeiro.CCustoLan.TRegistro_LanCCustoLancto() { Cd_empresa = (bindingSourceCaixa.Current as TRegistro_LanCaixa).Cd_Empresa, Cd_centroresult = obj.ToString(), Vl_lancto = (bindingSourceCaixa.Current as TRegistro_LanCaixa).Vl_PAGAR > decimal.Zero ? (bindingSourceCaixa.Current as TRegistro_LanCaixa).Vl_PAGAR : (bindingSourceCaixa.Current as TRegistro_LanCaixa).Vl_RECEBER, Dt_lancto = (bindingSourceCaixa.Current as TRegistro_LanCaixa).Dt_lancto, Tp_registro = "A" }); } else { using (TFRateioCResultado fRateio = new TFRateioCResultado()) { fRateio.vVl_Documento = (FLanCaixa.dsLanCaixa.Current as TRegistro_LanCaixa).Vl_PAGAR > decimal.Zero ? (FLanCaixa.dsLanCaixa.Current as TRegistro_LanCaixa).Vl_PAGAR : (FLanCaixa.dsLanCaixa.Current as TRegistro_LanCaixa).Vl_RECEBER; fRateio.Tp_mov = (FLanCaixa.dsLanCaixa.Current as TRegistro_LanCaixa).Vl_PAGAR > decimal.Zero ? "P" : "R"; fRateio.Dt_movimento = (FLanCaixa.dsLanCaixa.Current as TRegistro_LanCaixa).Dt_lancto; fRateio.ShowDialog(); (FLanCaixa.dsLanCaixa.Current as TRegistro_LanCaixa).lCustoLancto = fRateio.lCResultado; (FLanCaixa.dsLanCaixa.Current as TRegistro_LanCaixa).lCustoLanDel = fRateio.lCResultadoDel; } } } try { //Setar como lancamento caixa avulso (FLanCaixa.dsLanCaixa.Current as TRegistro_LanCaixa).St_avulso = "S"; TCN_LanCaixa.GravaLanCaixa((bindingSourceCaixa.Current as TRegistro_LanCaixa), null); afterBusca(); } catch (Exception ex) { MessageBox.Show(ex.Message.Trim(), "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); FLanCaixa.dsLanCaixa.CancelEdit(); } } else { FLanCaixa.dsLanCaixa.CancelEdit(); } } }