Advertisement
Guest User

Untitled

a guest
Dec 11th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.85 KB | None | 0 0
  1. public bool UpdateConfig(string codFilial, string codMina, string docEncomenda, string docReqInterna,
  2.             string docPedidoCotacao, string emailAssunto, string emailMensagem, string versaoTemplate, string templateExcel,
  3.             bool updateFornecedor, string caminhoAnexos, ref string strErros)
  4.         {
  5.             const string    SOURCE             = "UpdateConfig";
  6.             bool            resultado          = false;
  7.                                                
  8.             SqlTransaction  Cn_Transaction     = null;
  9.             bool            transacao          = false;                                
  10.            
  11.             SqlParameter p_CodFilial            =null;
  12.             SqlParameter p_CodMina              =null;
  13.             SqlParameter p_DocEncomenda         =null;
  14.             SqlParameter p_DocReqInterna        =null;
  15.             SqlParameter p_DocPedidoCotacao     =null;
  16.             SqlParameter p_EmailAssunto         =null;
  17.             SqlParameter p_EmailMensagem        =null;
  18.             SqlParameter p_VersaoTemplate       =null;
  19.             SqlParameter p_TemplateExcel        =null;
  20.             SqlParameter p_UpdateFornecedor     =null;
  21.             SqlParameter p_CaminhoAnexos        =null;
  22.  
  23.             try
  24.             {
  25.                
  26.                 if (SqlCmd == null)
  27.                 {
  28.                     SqlCmd = new SqlCommand();
  29.                 }
  30.        
  31.                 p_CodFilial             = new SqlParameter("@CodFilial"       ,SqlDbType.NVarChar, 3);
  32.                 p_CodMina               = new SqlParameter("@CodMina"         ,SqlDbType.NVarChar, 3);
  33.                 p_DocEncomenda          = new SqlParameter("@DocEncomenda"    ,SqlDbType.NVarChar, 5);
  34.                 p_DocReqInterna         = new SqlParameter("@DocReqInterna"   ,SqlDbType.NVarChar, 5);
  35.                 p_DocPedidoCotacao      = new SqlParameter("@DocPedidoCotacao",SqlDbType.NVarChar, 5);
  36.                 p_EmailAssunto          = new SqlParameter("@EmailAssunto"    ,SqlDbType.NVarChar, 1000);
  37.                 p_EmailMensagem         = new SqlParameter("@EmailMensagem"   ,SqlDbType.NVarChar, 1000);
  38.                 p_VersaoTemplate        = new SqlParameter("@VersaoTemplate"  ,SqlDbType.NVarChar, 5);
  39.                 p_TemplateExcel         = new SqlParameter("@TemplateExcel"   ,SqlDbType.NVarChar, 1000);
  40.                 p_UpdateFornecedor      = new SqlParameter("@UpdateFornecedor",SqlDbType.Bit);
  41.                 p_CaminhoAnexos         = new SqlParameter("@CaminhoAnexos"   ,SqlDbType.NVarChar, 1000);
  42.  
  43.  
  44.                 p_CodFilial.Value = codFilial;
  45.                 p_CodMina.Value = codMina;
  46.                 p_DocEncomenda.Value = docEncomenda;
  47.                 p_DocReqInterna.Value = docReqInterna;
  48.                 p_DocPedidoCotacao.Value = docPedidoCotacao;
  49.                 p_EmailAssunto.Value = emailAssunto;
  50.                 p_EmailMensagem.Value = emailMensagem;
  51.                 p_VersaoTemplate.Value = versaoTemplate;
  52.                 p_TemplateExcel.Value = templateExcel;
  53.                 p_UpdateFornecedor.Value = updateFornecedor;
  54.                 p_CaminhoAnexos.Value = caminhoAnexos;    
  55.  
  56.  
  57.                 SqlCmd.Connection = PriEngine_v9.SqlCn;
  58.                 SqlCmd.CommandType = CommandType.StoredProcedure;
  59.  
  60.                 if (PriEngine_v9.SqlCn.State == ConnectionState.Closed)
  61.                 {
  62.                     PriEngine_v9.SqlCn.Open();
  63.                 }
  64.  
  65.                 SqlCmd.CommandText = "sp_PCO_Update_Config";
  66.                
  67.                 SqlCmd.Parameters.Add(p_CodFilial);
  68.                 SqlCmd.Parameters.Add(p_CodMina);
  69.                 SqlCmd.Parameters.Add(p_DocEncomenda);
  70.                 SqlCmd.Parameters.Add(p_DocReqInterna);
  71.                 SqlCmd.Parameters.Add(p_DocPedidoCotacao);
  72.                 SqlCmd.Parameters.Add(p_EmailAssunto);
  73.                 SqlCmd.Parameters.Add(p_EmailMensagem);
  74.                 SqlCmd.Parameters.Add(p_VersaoTemplate);
  75.                 SqlCmd.Parameters.Add(p_TemplateExcel);
  76.                 SqlCmd.Parameters.Add(p_UpdateFornecedor);
  77.                 SqlCmd.Parameters.Add(p_CaminhoAnexos);
  78.  
  79.                 Cn_Transaction = PriEngine_v9.SqlCn.BeginTransaction();
  80.  
  81.                 SqlCmd.Transaction = Cn_Transaction;
  82.                 transacao = true;
  83.                 SqlCmd.ExecuteNonQuery();
  84.  
  85.                 Cn_Transaction.Commit();
  86.  
  87.                 transacao = false;
  88.  
  89.                 resultado = true;
  90.             }
  91.             catch (Exception ex)
  92.             {
  93.                 resultado = false;
  94.                 int NumLinhaErro = PriUtil_v9.Globais.fn_DaNumLinhaErro(ex);
  95.  
  96.                 strErros = SOURCE + "\r\nLinhaErro: " + NumLinhaErro.ToString() + "\r\n" + ex.Message;
  97.             }
  98.             finally
  99.             {
  100.                 SqlCmd = null;
  101.             }
  102.  
  103.             return resultado;
  104.  
  105.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement