Beispiel #1
0
        public void UpdateAllSaleCounts()
        {
            char store = userStoreDic[Context.ConnectionId];
            SqlStoredProcedures sqlSP = new SqlStoredProcedures();
            List <Sale>         sales = sqlSP.StoreSelectSales(store);

            foreach (Sale sale in sales)
            {
                Clients.Client(Context.ConnectionId).UpdateSaleCount(sale.GetProductID(), sale.GetCount(), sale.GetEmployeeCount());
            }
            decimal total = sqlSP.StoreGetSaleTotal(store);

            Clients.Client(Context.ConnectionId).UpdateTotal(Convert.ToDouble(total).ToString("N2"));
        }
Beispiel #2
0
        private ActionResult CPDownloadSales()
        {
            if (user.HasPolicy("Store.Sales.Download"))
            {
                SqlStoredProcedures sqlSP = new SqlStoredProcedures();

                DateTime startDate = Convert.ToDateTime(postData["startDate"]);
                DateTime endDate   = Convert.ToDateTime(postData["endDate"]);

                List <Sale>   saleCounts = sqlSP.StoreSelectSales(startDate, endDate);
                StringBuilder sb         = new StringBuilder();
                DateTime      date       = DateTime.Now;

                sb.AppendLine("\"Date\",\"Store\",\"Product Name\",\"Count\",\"Employee Count\"");
                foreach (Sale sale in saleCounts)
                {
                    if (date != null && date != sale.GetDate())
                    {
                        sb.AppendLine();
                    }
                    date = sale.GetDate();
                    sb.Append("\"" + CSV.Escape(sale.GetDate().ToShortDateString()) + "\"" + ",");
                    sb.Append("\"" + CSV.Escape(Convert.ToString(sale.GetStore())) + "\"" + ",");
                    sb.Append("\"" + CSV.Escape(Convert.ToString(sale.GetProductName())) + "\"" + ",");
                    sb.Append("\"" + CSV.Escape(Convert.ToString(sale.GetCount())) + "\"" + ",");
                    sb.Append("\"" + CSV.Escape(Convert.ToString(sale.GetEmployeeCount())) + "\"");
                    sb.Append("\n");
                }

                byte[] fileBytes = System.Text.Encoding.UTF8.GetBytes(sb.ToString());
                return(File(fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet, postData["startDate"] + "-" + postData["endDate"] + ".csv"));
            }
            else
            {
                throw new NoPermissionException();
            }
        }