Beispiel #1
0
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    public bool UpdateTemplate(ReportPro pro)
    {
        SqlCommand sqlCommand = new SqlCommand("dbo.[Report_UpdateTemplate]", MainConnection);

        sqlCommand.CommandType = CommandType.StoredProcedure;

        try
        {
            sqlCommand.Parameters.Add(new SqlParameter("@RepID", SqlDbType.VarChar, 10, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, pro.RepID));
            sqlCommand.Parameters.Add(new SqlParameter("@RepTemp", SqlDbType.VarChar, 50000, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, pro.RepTemp));
            sqlCommand.Parameters.Add(new SqlParameter("@Lang", SqlDbType.VarChar, 500, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, pro.Lang));
            sqlCommand.Parameters.Add(new SqlParameter("@ModifiedBy", SqlDbType.VarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, pro.ModifiedBy));
            //sqlCommand.Parameters.Add(new SqlParameter("@ModifiedDate", SqlDbType.DateTime, 14, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, pro.ModifiedDate));

            MainConnection.Open();

            sqlCommand.ExecuteNonQuery();
            return(true);
        }
        catch (Exception ex)
        {
            throw new Exception(ex.Message, ex);
        }
        finally
        {
            MainConnection.Close();
            sqlCommand.Dispose();
        }
    }
        public ActionResult getDataChart(int y = 2016)
        {
            List <ReportPro> p       = new List <ReportPro>();
            int        s             = 0;
            string     tt            = "";
            List <int> quantityofRes = new List <int>();
            List <int> QuanOder      = new List <int>();

            using (var db = new QLBHEntities())
            {
                var c = db.Categories.OrderBy(it => it.CatID).ToList();
                foreach (var item in c)
                {
                    ReportPro t = new ReportPro()
                    {
                        CatName = item.CatName
                    };
                    var pro = db.OrderDetails.Include("Product")
                              .Where(it => it.Order.OrderDate.Year == y && it.Product.CatID == item.CatID)
                              .OrderBy(it => it.Order.OrderDate.Month)
                              .ToList();
                    var st = 0;
                    foreach (var it in new List <int>()
                    {
                        1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12
                    })
                    {
                        t.Month.Add(it);
                        var tm = pro.Where(itm => itm.Order.OrderDate.Month == it).Count();
                        st += tm;
                        t.QuanTity.Add(tm);
                    }
                    //s = st > s ? st : s;
                    if (st > s)
                    {
                        s  = st;
                        tt = item.CatName;
                    }
                    p.Add(t);
                }

                foreach (var item in new List <int>()
                {
                    1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12
                })
                {
                    var qr = db.Users.Where(u => u.f_Day_Rerister.Value.Month == item).Count();
                    quantityofRes.Add(qr);
                    var qqo = db.Orders.Where(od => od.OrderDate.Day == item).Count();
                    QuanOder.Add(qqo);
                }
            }

            return(Json(new { lbl = p.Select(i => i.CatName).ToList(), sre =
                                  p.Select(i => i.QuanTity).ToList(), ma = s, pn = tt,
                              us_q = new List <List <int> > {
                                  quantityofRes, QuanOder
                              } }));
        }