示例#1
0
        public TransactionTO GetData(String token)
        {
            if (!mFilterManager.checkFilters(token))
            {
                return(null);
            }

            var random      = new Random();
            var amount      = random.Next() % 1001;
            var transaction = new TransactionTO(100.0f, amount, 1);

            return(transaction);
        }
示例#2
0
        public void RegistryNewTransaction(TransactionTO t)
        {
            Stats.TotalAmount += t.Amount;

            //
            if (Stats.TotalAmount > 500)
            {
                State = new BuyState();
            }
            else if (Stats.TotalAmount > 1000)
            {
                State = new SellState();
            }

            Notify();
        }
示例#3
0
        private void ListChanged(object sender, ListChangedEventArgs e)
        {
            //Console.WriteLine(e.ToString());

            if (e.ListChangedType.Equals(System.ComponentModel.ListChangedType.ItemAdded))
            {
                Console.WriteLine("zarejestrowanie nowej transakcji");
                if (bindingSource1.List[e.NewIndex].GetType().Equals(typeof(TransactionTO)))
                {
                    TransactionTO t = (TransactionTO)bindingSource1.List[e.NewIndex];
                    gui.RegistryNewTransaction(t);
                }
            }
            else if (e.ListChangedType.Equals(System.ComponentModel.ListChangedType.ItemChanged))
            {
                //// wyslanie zmodyfikowanego obiektu na serwer
                //Console.WriteLine("wyslanie zmodyfikowanego obiektu na serwer");
                //TransactionTO t = (TransactionTO)bindingSource1.List[e.NewIndex];

                //var sClient = new ServiceReference1.Service1Client();
                //sClient.Open();
                //bool result = sClient.Save(t);
                //sClient.Close();

                //if (result)
                //{
                //    MessageBox.Show("Zapisano zmiany");
                //}
                //else
                //{
                //    MessageBox.Show("Nie udało się zapisać zmian");
                //}

                //// dla celów dev, wyświetlenie obiektu w postaci json
                //MemoryStream stream1 = new MemoryStream();
                //DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(TransactionTO));
                //ser.WriteObject(stream1, t);
                //stream1.Position = 0;
                //StreamReader sr = new StreamReader(stream1);
                //Console.Write("JSON of TransactionTO object: ");
                //Console.WriteLine(sr.ReadToEnd());
            }
        }
示例#4
0
        public int UpdateOrInsert(TransactionTO t)
        {
            var existingT = GetSingle(t.ID);

            if (null == existingT)
            {
                // nowy rekord
                int newId = mData.Last().ID + 1;
                var newT  = new Transaction(t.Price, t.Amount, newId);
                mData.Add(newT);

                return(newId);
            }
            else
            {
                // aktualizacja rekordu
                existingT.Amount = t.Amount;
                existingT.Price  = t.Price;

                return(existingT.ID);
            }
        }
示例#5
0
        public void Update()
        {
            TransactionTO t = Gui.LastTransaction;

            Robot.RegistryNewTransaction(t);
        }
示例#6
0
        public TransactionTO GetLatestTransaction()
        {
            var trans = new TransactionTO(207.9f, 10000, 999);

            return(trans);
        }
示例#7
0
文件: GUI.cs 项目: rzymek01/pai-lab10
 public void RegistryNewTransaction(TransactionTO t)
 {
     LastTransaction = t;
     Notify();
 }
示例#8
0
        protected TransactionTO createTransferObject(Transaction src)
        {
            var dst = new TransactionTO(src.Price, src.Amount, src.ID);

            return(dst);
        }
示例#9
0
        public int Insert(TransactionTO t)
        {
            var newId = mMP.UpdateOrInsert(t);

            return(newId);
        }
示例#10
0
 public bool Delete(TransactionTO t)
 {
     throw new NotImplementedException();
 }
示例#11
0
 public bool Update(TransactionTO t)
 {
     mMP.UpdateOrInsert(t);
     return(true);
 }
示例#12
0
 public bool Save(TransactionTO t)
 {
     return(mDAO.Update(t));
 }