Exemple #1
0
        internal int Delete(stockremain formdata)
        {
            stockremain result = db.stockremain.Where(m => m.證券代號 == formdata.證券代號 && m.account == formdata.account).FirstOrDefault();

            db.stockremain.Remove(result);

            return(db.SaveChanges());
        }
Exemple #2
0
        internal int Updatestockremain(stockremain formdata, int Number)
        {
            var stockremain = db.stockremain.Where(s => s.證券代號 == formdata.證券代號 && s.account == formdata.account).FirstOrDefault();

            stockremain.張數    = (int.Parse(stockremain.張數) - Number).ToString();
            stockremain.持有成本  = ((int.Parse(stockremain.張數) * double.Parse(stockremain.成交均價)) * number).ToString();
            stockremain.現值    = (double.Parse(formdata.現價) * double.Parse(stockremain.張數.ToString()) * number).ToString();
            stockremain.預估收入  = ((int.Parse(stockremain.張數) * double.Parse(stockremain.現價)) * number).ToString();
            stockremain.預估損益  = (double.Parse(stockremain.預估收入) - double.Parse(stockremain.持有成本)).ToString();
            stockremain.預估獲利率 = ((double.Parse(stockremain.預估損益) / double.Parse(stockremain.持有成本)) * 100).ToString("f2") + "%";
            db.SaveChanges();
            return(db.SaveChanges());
        }