Exemple #1
0
        /// <summary>
        ///    Insere ou Altera os dados da Legenda de Anomalia no Banco
        /// </summary>
        /// <param name="leg">Legenda de Anomalia</param>
        /// <param name="usu_id">Id do Usuário Logado</param>
        /// <param name="ip">IP do Usuário Logado</param>
        /// <returns>int</returns>
        public int AnomLegenda_Salvar(AnomLegenda leg, int usu_id, string ip)
        {
            try
            {
                using (SqlConnection con = new SqlConnection(strConn))
                {
                    con.Open();
                    SqlCommand com = new SqlCommand();
                    if (leg.leg_id > 0)
                    {
                        com.CommandText = "STP_UPD_ANOM_LEGENDA";
                    }
                    else
                    {
                        com.CommandText = "STP_INS_ANOM_LEGENDA";
                    }

                    com.Connection  = con;
                    com.CommandType = CommandType.StoredProcedure;
                    com.Parameters.Clear();

                    System.Data.SqlClient.SqlParameter p_return = new System.Data.SqlClient.SqlParameter();
                    p_return.Direction = System.Data.ParameterDirection.ReturnValue;
                    com.Parameters.Add(p_return);
                    com.Parameters[0].Size = 32000;

                    if (leg.leg_id > 0)
                    {
                        com.Parameters.AddWithValue("@leg_id", leg.leg_id);
                    }

                    com.Parameters.AddWithValue("@leg_codigo", leg.leg_codigo);
                    com.Parameters.AddWithValue("@leg_descricao", leg.leg_descricao);
                    com.Parameters.AddWithValue("@leg_ativo", leg.leg_ativo);
                    com.Parameters.AddWithValue("@usu_id", usu_id);
                    com.Parameters.AddWithValue("@ip", ip);

                    com.ExecuteScalar();
                    return(Convert.ToInt32(p_return.Value));
                }
            }
            catch (Exception ex)
            {
                int id = 0;
                new LogSistemaDAO().InserirLogErro(new LogErro(ex, this.GetType().Name, new StackTrace().GetFrame(0).GetMethod().Name), out id);
                throw new Exception(ex.Message);
            }
        }
Exemple #2
0
        /// <summary>
        ///  Insere ou Altera os dados da Legenda
        /// </summary>
        /// <param name="leg">Dados da Legenda</param>
        /// <returns>int</returns>
        public int AnomLegenda_Salvar(AnomLegenda leg)
        {
            Usuario paramUsuario = (Usuario)System.Web.HttpContext.Current.Session["Usuario"];

            return(new AnomaliaDAO().AnomLegenda_Salvar(leg, paramUsuario.usu_id, paramUsuario.usu_ip));
        }
 /// <summary>
 ///  Insere ou Altera os dados da Legenda
 /// </summary>
 /// <param name="leg">Dados da Legenda</param>
 /// <returns>JsonResult</returns>
 public JsonResult AnomLegenda_Salvar(AnomLegenda leg)
 {
     return(Json(new AnomaliaBLL().AnomLegenda_Salvar(leg), JsonRequestBehavior.AllowGet));
 }