Esempio n. 1
0
        public Select.Promocion_Sistema selectById_Sistema_Promocion(int id)
        {
            try
            {
                Select.Promocion_Sistema p =  new Select.Promocion_Sistema();

                DataTable dt = new DataTable();
                SqlDataAdapter sda = new SqlDataAdapter();
                string ConnString = ConfigurationManager.ConnectionStrings["barabaresConnectionString"].ConnectionString;
                using (SqlConnection SqlConn = new SqlConnection(ConnString))
                {
                    try
                    {
                        SqlConn.Open();
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine(ex.ToString());
                        return p;
                    }

                    SqlCommand sqlCmd = new SqlCommand("PROMOCION_SELECT_BY_ID_SISTEMA", SqlConn);
                    sqlCmd.CommandType = CommandType.StoredProcedure;

                    sqlCmd.Parameters.Add("@ipnIdPromocion", SqlDbType.Int).Value = id;

                    sqlCmd.Parameters.Add("@ipsAccion", SqlDbType.VarChar).Value = Constantes.LOG_LISTAR;
                    sqlCmd.Parameters.Add("@ipsClase", SqlDbType.VarChar).Value = p.GetType().Name;
                    sqlCmd.Parameters.Add("@ipnIdUsuarioLog", SqlDbType.Int).Value = 1;

                    sda.SelectCommand = sqlCmd;
                    sda.Fill(dt);
                    SqlConn.Close();
                    sqlCmd.Dispose();
                    sda.Dispose();
                }

                DataRow[] rows = dt.Select();

                for (int i = 0; i < rows.Length; i++)
                {
                    p = Utils.promocion_sistema_parse(rows[i]);
                }

                return p;

            }
            catch (Exception ex)
            {
                Select.Promocion d = new Select.Promocion();

                LogBarabares b = new LogBarabares()
                {
                    Accion = Constantes.LOG_LISTAR,
                    Servicio = Constantes.SelectById_Sistema_Promocion,
                    Input = JsonSerializer.selectById(id),
                    Descripcion = ex.ToString(),
                    Clase = d.GetType().Name,
                    Aplicacion = Constantes.ENTORNO_SERVICIOS,
                    Estado = Constantes.FALLA,
                    Ip = "",
                    IdUsuario = 1 //TODO: obtener usuario de la sesión

                };

                Utils.add_LogBarabares(b);

                return new Select.Promocion_Sistema();
            }
        }
Esempio n. 2
0
        public List<Select.Promocion> search_Promocion(Search.Promocion pro)
        {
            try
            {
                List<Select.Promocion> promociones = new List<Select.Promocion>();
                Select.Promocion p = new Select.Promocion();

                DataTable dt = new DataTable();
                SqlDataAdapter sda = new SqlDataAdapter();
                string ConnString = ConfigurationManager.ConnectionStrings["barabaresConnectionString"].ConnectionString;
                using (SqlConnection SqlConn = new SqlConnection(ConnString))
                {
                    try
                    {
                        SqlConn.Open();
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine(ex.ToString());
                        return promociones;
                    }

                    SqlCommand sqlCmd = new SqlCommand("PROMOCION_SEARCH", SqlConn);
                    sqlCmd.CommandType = CommandType.StoredProcedure;

                    sqlCmd.Parameters.Add("@ipsNombre", SqlDbType.VarChar).Value = pro.Nombre;
                    sqlCmd.Parameters.Add("@ipnMinimo", SqlDbType.Real).Value = pro.Minimo;
                    sqlCmd.Parameters.Add("@ipnMaximo", SqlDbType.Real).Value = pro.Maximo;
                    sqlCmd.Parameters.Add("@ipbSemana", SqlDbType.Bit).Value = pro.Semana;
                    sqlCmd.Parameters.Add("@ipdDesde", SqlDbType.DateTime).Value = pro.Desde;
                    sqlCmd.Parameters.Add("@ipdHasta", SqlDbType.DateTime).Value = pro.Hasta;

                    sqlCmd.Parameters.Add("@ipsAccion", SqlDbType.VarChar).Value = Constantes.LOG_BUSCAR;
                    sqlCmd.Parameters.Add("@ipsClase", SqlDbType.VarChar).Value = p.GetType().Name;
                    sqlCmd.Parameters.Add("@ipnIdUsuario", SqlDbType.Int).Value = 1;

                    sda.SelectCommand = sqlCmd;
                    sda.Fill(dt);
                    SqlConn.Close();
                    sqlCmd.Dispose();
                    sda.Dispose();
                }

                DataRow[] rows = dt.Select();

                for (int i = 0; i < rows.Length; i++)
                {
                    p = Utils.select_promocion_parse(rows[i]);
                    promociones.Add(p);
                }

                return promociones;

            }
            catch (Exception ex)
            {
                Select.Promocion d = new Select.Promocion();

                LogBarabares b = new LogBarabares()
                {
                    Accion = Constantes.LOG_BUSCAR,
                    Servicio = Constantes.Search_Promocion,
                    Input = JsonSerializer.search_Promocion(pro),
                    Descripcion = ex.ToString(),
                    Clase = d.GetType().Name,
                    Aplicacion = Constantes.ENTORNO_SERVICIOS,
                    Estado = Constantes.FALLA,
                    Ip = "",
                    IdUsuario = 1 //TODO: obtener usuario de la sesión

                };

                Utils.add_LogBarabares(b);

                return new List<Select.Promocion>();
            }
        }
Esempio n. 3
0
        public List<Select.Promocion> selectAll_Promocion()
        {
            try
            {
                List<Select.Promocion> promociones = new List<Select.Promocion>();
                Select.Promocion p;

                DataTable dt = new DataTable();
                SqlDataAdapter sda = new SqlDataAdapter();
                string ConnString = ConfigurationManager.ConnectionStrings["barabaresConnectionString"].ConnectionString;
                using (SqlConnection SqlConn = new SqlConnection(ConnString))
                {
                    try
                    {
                        SqlConn.Open();
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine(ex.ToString());
                        return promociones;
                    }

                    SqlCommand sqlCmd = new SqlCommand("PROMOCION_SELECT_ALL", SqlConn);
                    sqlCmd.CommandType = CommandType.StoredProcedure;
                    sda.SelectCommand = sqlCmd;
                    sda.Fill(dt);
                    SqlConn.Close();
                    sqlCmd.Dispose();
                    sda.Dispose();
                }

                DataRow[] rows = dt.Select();

                for (int i = 0; i < rows.Length; i++)
                {
                    p = Utils.select_promocion_parse(rows[i]);
                    promociones.Add(p);
                }

                return promociones;

            }
            catch (Exception ex)
            {
                Select.Promocion d = new Select.Promocion();

                LogBarabares b = new LogBarabares()
                {
                    Accion = Constantes.LOG_LISTAR,
                    Servicio = Constantes.SelectAll_Promocion,
                    Input = "",
                    Descripcion = ex.ToString(),
                    Clase = d.GetType().Name,
                    Aplicacion = Constantes.ENTORNO_SERVICIOS,
                    Estado = Constantes.FALLA,
                    Ip = "",
                    IdUsuario = 1 //TODO: obtener usuario de la sesión

                };

                Utils.add_LogBarabares(b);

                return new List<Select.Promocion>();
            }
        }
Esempio n. 4
0
        public static Select.Promocion select_promocion_parse(DataRow r)
        {
            Select.Promocion p = new Select.Promocion();
            p.IdPromocion = Int32.Parse(r["idPromocion"].ToString());
            p.Nombre = r["nombre"].ToString();
            p.Descripcion = r["descripcion"].ToString();
            p.FechaInicio = DateTime.ParseExact(r["fechaInicio"].ToString(), "M/d/yyyy h:mm:ss ttt", null);
            p.FechaFin = DateTime.ParseExact(r["fechaFin"].ToString(), "M/d/yyyy h:mm:ss ttt", null);
            p.Precio = r["precioUnitario"].ToString();
            p.Semana = Boolean.Parse(r["semana"].ToString());

            return p;
        }