Esempio n. 1
0
        public Select.Promocion_Web semana_WEB_Promocion()
        {
            try
            {
                Select.Promocion_Web promocion = new Select.Promocion_Web();

                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 promocion;
                    }

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

                DataRow[] rows = dt.Select();
                DataRow[] rows2;

                //rows.Length = 1
                if (rows.Length > 0)
                {
                    promocion = Utils.promocion_web_parse(rows[0]);

                    Select.DetallePromocion_Web dpw;

                    dt = null;
                    sda = null;
                    dt = new DataTable();
                    sda = new SqlDataAdapter();

                    using (SqlConnection SqlConn = new SqlConnection(ConnString))
                    {
                        SqlConn.Open();
                        SqlCommand sqlCmd = new SqlCommand("PROMOCION_DETALLE_LIST_WEB", SqlConn);
                        sqlCmd.CommandType = CommandType.StoredProcedure;

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

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

                    rows2 = null;
                    rows2 = dt.Select();

                    for (int j = 0; j < rows2.Length; j++)
                    {
                        dpw = Utils.detallePromocion_Web_parse(rows2[j]);
                        promocion.Detalle.Add(dpw);
                    }

                }

                return promocion;
            }
            catch (Exception ex)
            {
                Select.Promocion_Web d = new Select.Promocion_Web();

                LogBarabares b = new LogBarabares()
                {
                    Accion = Constantes.LOG_LISTAR,
                    Servicio = Constantes.List_web_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 Select.Promocion_Web();
            }
        }
Esempio n. 2
0
        public static Select.Promocion_Web promocion_web_parse(DataRow r)
        {
            Select.Promocion_Web p = new Select.Promocion_Web();
            p.IdPromocion = Int32.Parse(r["idPromocion"].ToString());
            p.Nombre = r["nombre"].ToString();
            p.Imagen = r["imagen"].ToString();
            p.Precio = Double.Parse(r["precioUnitario"].ToString());
            p.Semana = Boolean.Parse(r["semana"].ToString());
            p.Detalle = new List<Select.DetallePromocion_Web>();

            return p;
        }