public ctrlSolicitacao getDadosSolicitacaoEdicao(string idProcesso) { ctrlSolicitacao sol = new ctrlSolicitacao(); FbConnection conn = AcessoDados.AcessoDados.getConn(); FbCommand comando = new FbCommand("SP_FLUXUS_GETSOLICITACAOEDICAO", conn); comando.CommandType = CommandType.StoredProcedure; comando.Parameters.Add("@IDPROCESSO", FbDbType.Integer).Value = Convert.ToInt16(idProcesso); comando.Parameters.Add("@IDSOL", FbDbType.Integer).Direction = System.Data.ParameterDirection.Output; comando.Parameters.Add("@SOLIDPROCESSO", FbDbType.Integer).Direction = System.Data.ParameterDirection.Output; comando.Parameters.Add("@IDCLASSIFICACAO", FbDbType.Integer).Direction = System.Data.ParameterDirection.Output; comando.Parameters.Add("@CLASSIFICACAO", FbDbType.VarChar).Direction = System.Data.ParameterDirection.Output; comando.Parameters.Add("@IDSOLICITANTE", FbDbType.Integer).Direction = System.Data.ParameterDirection.Output; comando.Parameters.Add("@SOLICITANTE", FbDbType.VarChar).Direction = System.Data.ParameterDirection.Output; comando.Parameters.Add("@IDFONTERECURSO", FbDbType.VarChar).Direction = System.Data.ParameterDirection.Output; comando.Parameters.Add("@FONTERECURSO", FbDbType.VarChar).Direction = System.Data.ParameterDirection.Output; comando.Parameters.Add("@FLAG_COTACAO", FbDbType.Integer).Direction = System.Data.ParameterDirection.Output; comando.Parameters.Add("@DATA", FbDbType.VarChar).Direction = System.Data.ParameterDirection.Output; comando.Parameters.Add("@FLAG_ATAREGISTRO", FbDbType.Integer).Direction = System.Data.ParameterDirection.Output; comando.Parameters.Add("@OBJETO", FbDbType.VarChar).Direction = System.Data.ParameterDirection.Output; comando.Parameters.Add("@JUTIFICATIVA", FbDbType.VarChar).Direction = System.Data.ParameterDirection.Output; comando.Parameters.Add("@UNDUNIFICADO", FbDbType.Char).Direction = System.Data.ParameterDirection.Output; comando.Parameters.Add("@UNDNOME", FbDbType.VarChar).Direction = System.Data.ParameterDirection.Output; try { conn.Open(); comando.ExecuteNonQuery(); sol.solId = Convert.ToInt16(comando.Parameters[1].Value); sol._IDPROC = Convert.ToInt16(comando.Parameters[2].Value); sol.solIDClassificacao = Convert.ToInt16(comando.Parameters[3].Value); sol.solClassificacao = comando.Parameters[4].Value.ToString(); sol.solIdSolicitante = Convert.ToInt16(comando.Parameters[5].Value); sol.solSolicitante = comando.Parameters[6].Value.ToString(); sol.solIdFonteRecurso = comando.Parameters[7].Value.ToString(); sol.solFonteRecurso = comando.Parameters[8].Value.ToString(); sol.solSemCotacao = Convert.ToInt16(comando.Parameters[9].Value); sol.solData = Convert.ToDateTime(comando.Parameters[10].Value); sol.solAtaRegsitroPreco = Convert.ToInt16(comando.Parameters[11].Value); sol.solObjeto = comando.Parameters[12].Value.ToString(); sol.solJustificativa = comando.Parameters[13].Value.ToString(); sol.solUndUnificado = comando.Parameters[14].Value.ToString(); sol.solUndNome = comando.Parameters[15].Value.ToString(); } catch (Exception ex) { sol.solMensagemErro = ex.Message; } finally { conn.Close(); } return sol; }
public string Grava(ctrlSolicitacao sol, string op, string origem) { string retorno = string.Empty; string procID = string.Empty; string ERRO = string.Empty; string mensagemErro = string.Empty; string idSolicitacao = string.Empty; string procNumero = string.Empty; if (origem.Equals("btnSalvarSolicitacao") && op.Equals("edt")) { op = "new"; } FbConnection conn = AcessoDados.AcessoDados.getConn(); FbCommand comando = new FbCommand("SP_FLUXUS_GRAVASOLICITACAO", conn); comando.CommandType = System.Data.CommandType.StoredProcedure; comando.Parameters.Add("@USUARIO", FbDbType.Integer).Value = Convert.ToInt16(sol.solUsuarioID); comando.Parameters.Add("@UNDFUNCIONAL", FbDbType.Integer).Value = Convert.ToInt16(sol.solUnidadeFuncional); comando.Parameters.Add("@DATA", FbDbType.VarChar).Value = DateTime.Parse(sol.solData.ToString()).ToShortDateString().Replace("/", "."); comando.Parameters.Add("@CLASSIFICACAO", FbDbType.Integer).Value = sol.solIDClassificacao; comando.Parameters.Add("@SEMCOTACAO", FbDbType.Integer).Value = Convert.ToInt16(sol.solSemCotacao); comando.Parameters.Add("@ATAREGISTRO", FbDbType.Integer).Value = Convert.ToInt16(sol.solAtaRegsitroPreco); comando.Parameters.Add("@UNDUNIFICADO", FbDbType.VarChar).Value = sol.solUndUnificado; comando.Parameters.Add("@SOLICITANTE", FbDbType.Integer).Value = Convert.ToInt16(sol.solIdSolicitante); comando.Parameters.Add("@OBJETO", FbDbType.VarChar).Value = sol.solObjeto; comando.Parameters.Add("@JUSTIFICATIVA", FbDbType.VarChar).Value = sol.solJustificativa; if (sol.solIdFonteRecurso == null) { sol.solIdFonteRecurso = string.Empty; } comando.Parameters.Add("@FONTERECURSOID", FbDbType.VarChar).Value = sol.solIdFonteRecurso; comando.Parameters.Add("@RESPONSAVEL", FbDbType.VarChar).Value = sol._RESPONSAVEL; comando.Parameters.Add("@OPERACAO", FbDbType.VarChar).Value = op; comando.Parameters.Add("@IDPROCESSO", FbDbType.VarChar).Value = sol._IDPROC; comando.Parameters.Add("@RETORNO", FbDbType.Integer).Direction = System.Data.ParameterDirection.Output; comando.Parameters.Add("@MENSAGEM", FbDbType.VarChar).Direction = System.Data.ParameterDirection.Output; comando.Parameters.Add("@ERRO", FbDbType.Integer).Direction = System.Data.ParameterDirection.Output; comando.Parameters.Add("@IDSOLICITACAO", FbDbType.Integer).Direction = System.Data.ParameterDirection.Output; comando.Parameters.Add("@PROCNUMERO", FbDbType.VarChar).Direction = System.Data.ParameterDirection.Output; try { conn.Open(); comando.ExecuteNonQuery(); mensagemErro = comando.Parameters[17].Value.ToString(); ERRO = comando.Parameters[15].Value.ToString(); procID = comando.Parameters[16].Value.ToString(); idSolicitacao = comando.Parameters[18].Value.ToString(); procNumero = comando.Parameters[14].Value.ToString(); if (op.Equals("cabecaSolicitacao") || origem.Equals("btnSalvarSolicitacaoCabeca")) { retorno = procNumero; } else { retorno = mensagemErro; } } catch (FbException ex) { retorno = ex.Message; } finally { conn.Close(); comando.Dispose(); } try { conn.Open(); comando = new FbCommand("delete from SCI_SOLICITACAO_DOTACAO where SOL_ISN = " + idSolicitacao, conn); comando.ExecuteNonQuery(); foreach (DataRow dr in solDotacoes.Rows) { string sql = "INSERT INTO SCI_SOLICITACAO_DOTACAO(SOL_ISN,DOTREDUZIDO,SDO_VALOR,PLCCOD,FONCOD) VALUES (@SOLITACAO,@DOTRED,@VALOR,999999,@FONCOD)"; comando = new FbCommand(sql, conn); comando.Parameters.Add("@SOLITACAO", FbDbType.Integer).Value = int.Parse(idSolicitacao); comando.Parameters.Add("@DOTRED", FbDbType.Integer).Value = Convert.ToInt16(dr["DOTREDUZIDO"]); comando.Parameters.Add("@VALOR", FbDbType.Numeric).Value = 0; comando.Parameters.Add("@FONCOD", FbDbType.VarChar).Value = sol.solIdFonteRecurso; comando.ExecuteNonQuery(); } } catch (Exception ex) { retorno = ex.Message; } finally { conn.Close(); } return retorno; }
public string GravaSolicitacao(string op) { string origem = string.Empty; ctrlSolicitacao obj = new ctrlSolicitacao(); ctrlSolicitacao.Dados dados = new ctrlSolicitacao.Dados(); Model.Usuarios usu = new Model.Usuarios(); usu.UsuarioID = int.Parse(hdfDadosUsuario["IDUSUARIO"].ToString()); obj._RESPONSAVEL = UsuariosControle.GetUsuarioById(usu).Nome; obj.solData = DateTime.Parse(dtSolicitacao.Date.ToString()); obj.solIDClassificacao = Convert.ToInt16(ASPxComboBox1.Value); if (Convert.ToBoolean(chbSemCotacao.Checked)) { obj.solSemCotacao = 1; } else { obj.solSemCotacao = 0; } if (Convert.ToBoolean(chbAtaRegistroPreco.Checked)) { obj.solAtaRegsitroPreco = 1; } else { obj.solAtaRegsitroPreco = 0; } obj.solUndUnificado = cbbUndOrcamentaria.SelectedItem.Value.ToString(); obj.solIdSolicitante = Convert.ToInt16(cbbSolicitante.Value); obj.solObjeto = txtObjeto.Text.ToString(); obj.solJustificativa = txtJustificativa.Text.ToString(); if (!chbAtaRegistroPreco.Checked) { obj.solIdFonteRecurso = cbbFonteRecurso.Value.ToString().Trim(); } obj.Dotacoes1 = (DataTable)Session["dsGridDotacoes"]; obj.Itens1 = (DataTable)Session["dsItensSolicitacao"]; obj.solUnidadeFuncional = hdfDadosUsuario["UNDFUNCIONAL"].ToString(); obj.solUsuarioID = hdfDadosUsuario["IDUSUARIO"].ToString(); if (op == "edt") { obj._IDPROC = Convert.ToInt16(Request.QueryString["id"]); origem = "btnSalvarSolicitacao"; } else { if (op == "cabecaSolicitacao") { if (txtNumeroProcesso.Text != string.Empty) { obj._IDPROC = Convert.ToInt16(Request.QueryString["id"]); op = "edt"; } origem = "btnSalvarSolicitacaoCabeca"; } else { obj._IDPROC = int.Parse(ProcessoCtrl.getIDbyNumeroProcesso(txtNumeroProcesso.Text)); origem = "btnSalvarSolicitacao"; } } string retorno = dados.Grava(obj,op, origem); return retorno; }