public override string ToString()
        {
            var outflow = Outflow.ToString("F2", CultureInfo.InvariantCulture);
            var inflow  = Inflow.ToString("F2", CultureInfo.InvariantCulture);

            return($"{Date.ToString("dd'/'MM'/'yyyy")},\"{Payee}\",\"{Category}\",\"{Memo.Replace(',',' ')}\",{outflow},{inflow}");
        }
Exemplo n.º 2
0
        public void OnGet()
        {
            var currentMonth = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1).AddMonths(1);

            ViewData["Title"] = $"Overview > Funding > {currentMonth.ToString("MMMM yyyy")}";

            Forecast forecast    = null;
            var      accessToken = HttpContext.GetTokenAsync("access_token").Result;
            var      userId      = User.FindFirst(ClaimTypes.NameIdentifier).Value;

            _cache.TryGetValue(userId, out forecast);
            if (forecast == null)
            {
                forecast = Cache.GetForecast(accessToken, userId);
                _cache.Set(userId, forecast);
            }

            ViewData["LastUpdated"] = forecast.LastModifiedOn;

            var expenses = forecast.MonthFundStatus[currentMonth.AddMonths(-1).ToShortDateString()]
                           .Where(e => e.Date.Year == currentMonth.Year && e.Date.Month == currentMonth.Month)
                           .OrderBy(e => e.Date)
                           .ThenBy(e => e.Amount);

            foreach (var outflow in expenses)
            {
                var of = new OutflowModel
                {
                    Amount   = outflow.Amount.ToDisplay(),
                    Category = outflow.CategoryName,
                    Date     = outflow.Date.ToShortDateString(),
                    Funded   = outflow.Funded.ToDisplay(),
                    Payee    = outflow.PayeeName,
                    Percent  = "N/A"
                };
                if (outflow.Amount != 0)
                {
                    of.Percent = Math.Abs(Decimal.Divide(outflow.Funded, outflow.Amount) * 100M).ToString("N2");
                }

                Outflow.Add(of);
            }
            var funded = expenses.Sum(e => e.Funded);

            Funded = funded.ToDisplay();

            var needed = expenses.Sum(e => e.Amount);

            Needed = needed.ToDisplay();

            if (needed != 0)
            {
                Percent = Math.Abs(Decimal.Divide(funded, needed) * 100M).ToString("N2");
            }
            else
            {
                Percent = "N/A";
            }
        }
Exemplo n.º 3
0
        //出库
        static public bool OutWarehouse(int indetailId, int outNum, string userNum, out string msg)
        {
            List <string> list     = new List <string>();
            Indetail      indetail = IndetailDAL.QueryById(indetailId, out msg);

            if (indetail == null)
            {
                msg = "单品记录查询失败";
                return(false);
            }
            if (indetail.quantity < outNum)
            {
                msg = "数量不足";
                return(false);
            }
            indetail.quantity -= outNum;
            int   stockId = indetail.stockID;
            Stock stock   = StockDAL.QueryById(stockId, out msg);

            if (stock == null)
            {
                msg = "库存查询失败";
                return(false);
            }
            stock.quantity -= outNum;
            stock.money     = stock.money - outNum * indetail.price;
            if (stock.money < 0)
            {
                msg = "金额出错";
                return(false);
            }
            string  date    = DateTime.Now.ToString("yyyy-MM-dd");
            Outflow outflow = new Outflow(stock.cagNum, stock.storeID, date, userNum, outNum, indetail.price, indetail.batchNum, indetail.batchNum2, indetail.suppliers, "正常出库");

            if (indetail.quantity == 0)
            {
                list.Add(string.Format(" delete from Indetail where id ={0}", indetailId));
                list.Add(string.Format("update Stock set cagNum = '{0}', storeID = {1}, quantity = {2}, money = {3} where id = {4} ", stock.cagNum, stock.storeID, stock.quantity, stock.money, stock.id));
                list.Add(string.Format("insert into Outflow (cagNum,storeID,date,userNum,quantity,price,batchNum,batchNum2,suppliers,state) values('{0}',{1},'{2}','{3}',{4},{5},'{6}','{7}','{8}','{9}')", outflow.cagNum, outflow.storeID, outflow.date, outflow.userNum, outflow.quantity, outflow.price, outflow.batchNum, outflow.batchNum2, outflow.suppliers, outflow.state));
            }
            else
            {
                list.Add(string.Format("update Indetail set stockID = {0},batchNum = '{1}',date = '{2}',quantity = {3},price = {4},batchNum2 = '{5}',suppliers = '{6}',note = '{7}'  where id = {8}", indetail.stockID, indetail.batchNum, indetail.date, indetail.quantity, indetail.price, indetail.batchNum2, indetail.suppliers, indetail.note, indetail.id));
                list.Add(string.Format("update Stock set cagNum = '{0}', storeID = {1}, quantity = {2}, money = {3} where id = {4} ", stock.cagNum, stock.storeID, stock.quantity, stock.money, stock.id));
                list.Add(string.Format("insert into Outflow (cagNum,storeID,date,userNum,quantity,price,batchNum,batchNum2,suppliers,state) values('{0}',{1},'{2}','{3}',{4},{5},'{6}','{7}','{8}','{9}')", outflow.cagNum, outflow.storeID, outflow.date, outflow.userNum, outflow.quantity, outflow.price, outflow.batchNum, outflow.batchNum2, outflow.suppliers, outflow.state));
            }
            bool bol = SQL.ExecuteTransaction(list, out msg);

            if (bol)
            {
                msg = "出库成功";
            }
            else
            {
                return(false);
            }
            return(true);
        }
        static public bool Destory(List <Indetail> indetails, string userNum, out string msg)
        {
            List <string> list = new List <string>();

            if (indetails == null || indetails.Count == 0)
            {
                msg = "没有记录需要销毁";
                return(false);
            }
            for (int i = 0; i < indetails.Count; i++)
            {
                int outNum = indetails[i].quantity;
                indetails[i].quantity = 0;
                int   stockId = indetails[i].stockID;
                Stock stock   = StockDAL.QueryById(stockId, out msg);
                if (stock == null)
                {
                    msg = "库存查询失败";
                    return(false);
                }
                stock.quantity -= outNum;
                stock.money     = stock.money - outNum * indetails[i].price;
                if (stock.money < 0)
                {
                    msg = "金额出错";
                    return(false);
                }
                string  date    = DateTime.Now.ToString("yyyy-MM-dd");
                Outflow outflow = new Outflow(stock.cagNum, stock.storeID, date, userNum, outNum, indetails[i].price, indetails[i].batchNum, indetails[i].batchNum2, indetails[i].suppliers, "过期作废");
                if (indetails[i].quantity == 0)
                {
                    list.Add(string.Format(" delete from Indetail where id ={0}", indetails[i].id));
                    list.Add(string.Format("update Stock set cagNum = '{0}', storeID = {1}, quantity = {2}, money = {3} where id = {4} ", stock.cagNum, stock.storeID, stock.quantity, stock.money, stock.id));
                    list.Add(string.Format("insert into Outflow (cagNum,storeID,date,userNum,quantity,price,batchNum,batchNum2,suppliers,state) values('{0}',{1},'{2}','{3}',{4},{5},'{6}','{7}','{8}','{9}')", outflow.cagNum, outflow.storeID, outflow.date, outflow.userNum, outflow.quantity, outflow.price, outflow.batchNum, outflow.batchNum2, outflow.suppliers, outflow.state));
                }
                else
                {
                    list.Add(string.Format("update Indetail set stockID = {0},batchNum = '{1}',date = '{2}',quantity = {3},price = {4},batchNum2 = '{5}',suppliers = '{6}',note = '{7}'  where id = {8}", indetails[i].stockID, indetails[i].batchNum, indetails[i].date, indetails[i].quantity, indetails[i].price, indetails[i].batchNum2, indetails[i].suppliers, indetails[i].note, indetails[i].id));
                    list.Add(string.Format("update Stock set cagNum = '{0}', storeID = {1}, quantity = {2}, money = {3} where id = {4} ", stock.cagNum, stock.storeID, stock.quantity, stock.money, stock.id));
                    list.Add(string.Format("insert into Outflow (cagNum,storeID,date,userNum,quantity,price,batchNum,batchNum2,suppliers,state) values('{0}',{1},'{2}','{3}',{4},{5},'{6}','{7}','{8}','{9}')", outflow.cagNum, outflow.storeID, outflow.date, outflow.userNum, outflow.quantity, outflow.price, outflow.batchNum, outflow.batchNum2, outflow.suppliers, outflow.state));
                }
            }

            bool bol = SQL.ExecuteTransaction(list, out msg);

            if (bol)
            {
                msg = "销毁成功";
            }
            else
            {
                return(false);
            }
            msg = null;
            return(true);
        }
    public override void PrepareToSim()
    {
        Outflow outflow = schemeObject.boardObject.GetComponent <Outflow>();

        if (!DataClass.objectManager.wasSimulation)
        {
            outflow.enabled = true;
            DataClass.objectManager.wasSimulation = true;
        }
        else
        {
            outflow.Start();
        }
    }
        static public bool Add(Outflow outflow, out string msg)
        {
            string command = $"insert into Outflow (cagNum,storeID,date,userNum,quantity,price,batchNum,batchNum2,suppliers,state) values ('{outflow.cagNum}','{outflow.storeID}','{outflow.date}','{outflow.userNum}','{outflow.quantity}','{outflow.price}','{outflow.batchNum}','{outflow.batchNum2}','{outflow.suppliers}','{outflow.state}')";

            try
            {
                msg = null;
                return(SQL.Excute(command));
            }
            catch (Exception ex)
            {
                msg = ex.Message;
                return(false);
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Gets the average storage time for the time period. Calculated as mean volume divide by mean (sinks + outflow + evaporation)
        /// </summary>
        /// <param name="Start"></param>
        /// <param name="End"></param>
        /// <returns></returns>
        public TimeSpan GetStorageTime(DateTime Start, DateTime End)
        {
            if (!IsEmpty)
            {
                if (EndTime < End || StartTime > Start)
                {
                    throw new Exception("Cannot calculate storage time outside of the simulated period");
                }

                //Find the total outflow
                double d = Sinks.GetSiValue(Start, End);
                d += Outflow.GetSiValue(Start, End);
                //Evaporation is negative
                d += Evaporation.GetSiValue(Start, End);
                d += GroundwaterOutflow.GetSiValue(Start, End);

                return(TimeSpan.FromSeconds(StoredVolume.GetSiValue(Start, End) / d));
            }
            return(TimeSpan.Zero);
        }
 public NewOutflowRecorded(Guid fromAccountId, Guid toAccountId, Outflow outflow)
 {
     FromAccountId = fromAccountId;
     ToAccountId   = toAccountId;
     Outflow       = outflow;
 }
 private void Start()
 {
     subject = parent.boardObject.GetComponent <Outflow>();
     inputs  = new List <MonitorInput>();
 }
Exemplo n.º 10
0
    public override void PrepareToStop()
    {
        Outflow outflow = schemeObject.boardObject.GetComponent <Outflow>();

        outflow.StopSim();
    }
Exemplo n.º 11
0
 void Awake()
 {
     instance = this;
 }