コード例 #1
0
        public string GetallDetalles(String fecha)
        {
            if (Session["Usuario"] != null && Session["Usuario"].ToString().Equals("SI"))
            {
                string expFecha = @"^\d{4}[\-\/\s]?((((0[13578])|(1[02]))[\-\/\s]?(([0-2][0-9])|(3[01])))|(((0[469])|(11))[\-\/\s]?(([0-2][0-9])|(30)))|(02[\-\/\s]?[0-2][0-9]))$";
                if (Regex.IsMatch(fecha, expFecha))
                {
                    List <MReporte>  lista2 = new List <MReporte>();
                    List <MDetalles> lista1 = DAO.GetallDetalles();
                    MReporte         rep    = new MReporte();

                    foreach (var item in DAO.GetAll())
                    {
                        foreach (var item2 in lista1)
                        {
                            if (item.fecha.Equals(fecha) && item.id.Equals(item2.idVenta))
                            {
                                rep          = new MReporte();
                                rep.Tipo     = item2.Tipo;
                                rep.Cantidad = item2.cantidad;
                                rep.Total    = item2.total;
                                rep.Nombre   = new ArticuloDAO().Getbyid(item2.producto).nombre;
                                if (lista2.Contains(rep))
                                {
                                    lista2.ElementAt(lista2.IndexOf(rep)).Total    += rep.Total;
                                    lista2.ElementAt(lista2.IndexOf(rep)).Cantidad += rep.Cantidad;
                                }
                                else
                                {
                                    lista2.Add(rep);
                                }
                            }
                        }
                    }
                    JavaScriptSerializer jss = new JavaScriptSerializer();
                    return(jss.Serialize(lista2));
                }
                throw new SystemException("La fecha ingresada no es valida");
            }
            else
            {
                return(null);
            }
        }
コード例 #2
0
        public string GetallDetalles(String fecha)
        {
            if (Session["Usuario"] != null && Session["Usuario"].ToString().Equals("SI"))
            {
                List <MReporte>  lista2 = new List <MReporte>();
                List <MDetalles> lista1 = DAO.GetallDetalles();
                MReporte         rep    = new MReporte();

                foreach (var item in DAO.GetAll())
                {
                    foreach (var item2 in lista1)
                    {
                        if (item.fecha.Equals(fecha) && item.id.Equals(item2.idVenta))
                        {
                            rep          = new MReporte();
                            rep.Tipo     = item2.Tipo;
                            rep.Cantidad = item2.cantidad;
                            rep.Total    = item2.total;
                            rep.Nombre   = new ArticuloDAO().Getbyid(item2.producto).nombre;
                            if (lista2.Contains(rep))
                            {
                                lista2.ElementAt(lista2.IndexOf(rep)).Total    += rep.Total;
                                lista2.ElementAt(lista2.IndexOf(rep)).Cantidad += rep.Cantidad;
                            }
                            else
                            {
                                lista2.Add(rep);
                            }
                        }
                    }
                }
                JavaScriptSerializer jss = new JavaScriptSerializer();
                return(jss.Serialize(lista2));
            }
            else
            {
                return(null);
            }
        }