Esempio n. 1
0
 private void StockHoldDelegate(StockHoldEntity SHE)
 {
     foreach (UIStockHold x in StockHoldDelegateList)
     {
         //x.Invoke(SHE);
         x(SHE);
     }
 }
Esempio n. 2
0
 //更新数据
 public void Update(StockHoldEntity SHE)
 {
     SQLiteCommand cmd = conn.CreateCommand();
     cmd.CommandText = "update '" + user + "_StockHold' set hold=@hold,money=@money where id=@id";
     cmd.Parameters.Add(new SQLiteParameter("id", SHE.id));
     cmd.Parameters.Add(new SQLiteParameter("hold", SHE.hold));
     cmd.Parameters.Add(new SQLiteParameter("money", SHE.money));
     cmd.ExecuteNonQuery();
 }
Esempio n. 3
0
        //更新数据
        public void Update(StockHoldEntity SHE)
        {
            SQLiteCommand cmd = conn.CreateCommand();

            cmd.CommandText = "update '" + user + "_StockHold' set hold=@hold,money=@money where id=@id";
            cmd.Parameters.Add(new SQLiteParameter("id", SHE.id));
            cmd.Parameters.Add(new SQLiteParameter("hold", SHE.hold));
            cmd.Parameters.Add(new SQLiteParameter("money", SHE.money));
            cmd.ExecuteNonQuery();
        }
Esempio n. 4
0
 //插入数据
 public void Insert(StockHoldEntity SHE)
 {
     SQLiteCommand cmd = conn.CreateCommand();
     cmd.CommandText = "insert into '" + user + "_StockHold' values(@id,@name,@hold,@money)";
     cmd.Parameters.Add(new SQLiteParameter("id", SHE.id));
     cmd.Parameters.Add(new SQLiteParameter("name", SHE.name));
     cmd.Parameters.Add(new SQLiteParameter("hold", SHE.hold));
     cmd.Parameters.Add(new SQLiteParameter("money", SHE.money));
     cmd.ExecuteNonQuery();
 }
Esempio n. 5
0
        //插入数据
        public void Insert(StockHoldEntity SHE)
        {
            SQLiteCommand cmd = conn.CreateCommand();

            cmd.CommandText = "insert into '" + user + "_StockHold' values(@id,@name,@hold,@money)";
            cmd.Parameters.Add(new SQLiteParameter("id", SHE.id));
            cmd.Parameters.Add(new SQLiteParameter("name", SHE.name));
            cmd.Parameters.Add(new SQLiteParameter("hold", SHE.hold));
            cmd.Parameters.Add(new SQLiteParameter("money", SHE.money));
            cmd.ExecuteNonQuery();
        }
Esempio n. 6
0
 //读取数据
 public void Select(ref StockHoldEntity SHE)
 {
     SQLiteCommand cmd = new SQLiteCommand(conn);
     cmd.CommandText = "select name,hold,money from '" + user + "_StockHold' where id=@id";
     cmd.Parameters.Add(new SQLiteParameter("id", SHE.id));
     SQLiteDataReader reader = cmd.ExecuteReader();
     if (reader.HasRows)
     {
         if (reader.Read())
         {
             SHE.name = reader.GetValue(0).ToString();
             SHE.hold = Convert.ToInt32(reader.GetValue(1));
             SHE.money = Convert.ToDouble(reader.GetValue(2));
         }
     }
 }
Esempio n. 7
0
        //读取数据
        public void Select(ref StockHoldEntity SHE)
        {
            SQLiteCommand cmd = new SQLiteCommand(conn);

            cmd.CommandText = "select name,hold,money from '" + user + "_StockHold' where id=@id";
            cmd.Parameters.Add(new SQLiteParameter("id", SHE.id));
            SQLiteDataReader reader = cmd.ExecuteReader();

            if (reader.HasRows)
            {
                if (reader.Read())
                {
                    SHE.name  = reader.GetValue(0).ToString();
                    SHE.hold  = Convert.ToInt32(reader.GetValue(1));
                    SHE.money = Convert.ToDouble(reader.GetValue(2));
                }
            }
        }
Esempio n. 8
0
 //读取全部数据
 public void Select(out List<StockHoldEntity> SHEL)
 {
     SHEL = new List<StockHoldEntity>();
     SQLiteCommand cmd = new SQLiteCommand(conn);
     cmd.CommandText = "select * from '" + user + "_StockHold'";
     StockHoldEntity SHE = new StockHoldEntity();
     SQLiteDataReader reader = cmd.ExecuteReader();
     if (reader.HasRows)
     {
         while (reader.Read())
         {
             SHE.id = reader.GetValue(0).ToString();
             SHE.name = reader.GetValue(1).ToString();
             SHE.hold = Convert.ToInt32(reader.GetValue(2));
             SHE.money = Convert.ToDouble(reader.GetValue(3));
             SHEL.Add(SHE);
         }
     }
 }
Esempio n. 9
0
        //读取全部数据
        public void Select(out List <StockHoldEntity> SHEL)
        {
            SHEL = new List <StockHoldEntity>();
            SQLiteCommand cmd = new SQLiteCommand(conn);

            cmd.CommandText = "select * from '" + user + "_StockHold'";
            StockHoldEntity  SHE    = new StockHoldEntity();
            SQLiteDataReader reader = cmd.ExecuteReader();

            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    SHE.id    = reader.GetValue(0).ToString();
                    SHE.name  = reader.GetValue(1).ToString();
                    SHE.hold  = Convert.ToInt32(reader.GetValue(2));
                    SHE.money = Convert.ToDouble(reader.GetValue(3));
                    SHEL.Add(SHE);
                }
            }
        }
Esempio n. 10
0
 public void UpdateCanvas(Canvas canvas, StockHoldEntity SHE)
 {
     if (!Change(SHE.id, SHE.hold, SHE.money))
     {
         Add(SHE.id, SHE.name, SHE.hold, SHE.money);
     }
 }
Esempio n. 11
0
 //public double ExistsRemove(string id)
 //{
 //    double height = -5;
 //    foreach(StockStateBox SSB in canvas.Children)
 //    {
 //        if (SSB.stockid == id)
 //        {
 //            if (StockStateBox.pre == SSB)
 //                height = SSB.Margin.Top;
 //            canvas.Children.Remove(SSB);
 //            canvasbox.Remove(SSB);
 //            return height;
 //        }
 //    }
 //    return height;
 //}
 public void GetDelegateValues(StockHoldEntity SHE)
 {
     Action<Canvas, StockHoldEntity> updateAction = new Action<Canvas, StockHoldEntity>(UpdateCanvas);
     canvas.Dispatcher.BeginInvoke(updateAction, canvas, SHE);
     //if (!Change(SHE.id, SHE.hold, SHE.money))
     //{
     //    Add(SHE.id, SHE.name, SHE.hold, SHE.money);
     //}
 }
Esempio n. 12
0
 //按类型转换
 private StockHoldEntity DealList_Insert_StockHold(DealListEntity DLE)
 {
     if (DLE.deal >= dealid)
         dealid = DLE.deal + 1;
     StockHoldEntity SHE = new StockHoldEntity();
     SHE.id = DLE.id;
     SHE.name = DLE.name;
     double c;
     if (DLE.type == "买入")
     {
         SHE.hold = DLE.number;
         c = -(DLE.number * DLE.money);
         MoneyChangeNow(c);
     }
     else if (DLE.type == "卖出")
     {
         SHE.hold = -DLE.number;
         c = DLE.number * DLE.money;
         MoneyChangeNow(c);
     }
     else if (DLE.type == "补仓")
     {
         SHE.hold = DLE.number;
         c = -(DLE.number * DLE.money);
         MoneyChangeNow(c);
     }
     else if (DLE.type == "卖空")
     {
         SHE.hold = -DLE.number;
         c = DLE.number * DLE.money;
         MoneyChangeNow(c);
     }
     else
     {
         SHE.hold = DLE.number;
         c = -(DLE.number * DLE.money);
         MoneyChangeNow(c);
     }
     SHE.money = -c;
     StockHoldEntity SHE_=new StockHoldEntity();
     SHE_.id = SHE.id;
     stockhold.Select(ref SHE_);
     HistoryStockHoldEntity HSHE = new HistoryStockHoldEntity();
     HSHE.id = SHE.id;
     HSHE.number = SHE_.hold;
     HSHE.date = DLE.date;
     HSHE.change = SHE.hold;
     HSHE.money = DLE.money;
     historystockhold.Insert(HSHE);
     if (SHE_.name != null)
     {
         SHE.hold = SHE.hold + SHE_.hold;
         SHE.money = Convert.ToDouble(SHE.money) + Convert.ToDouble(SHE_.money);
         stockhold.Update(SHE);
     }
     else
     {
         stockhold.Insert(SHE);
     }
     return SHE;
     //StockHoldSet(SHE);
 }
Esempio n. 13
0
 //读取指定id持股
 public void StockHoldRead(ref StockHoldEntity SHE)
 {
     stockhold.Select(ref SHE);
 }
Esempio n. 14
0
 //重置id相关
 private void DealListRestore(DealListEntity DLE)
 {
     List<DealListEntity> DLEL;
     deallist.Select(DLE.id, out DLEL);
     StockHoldEntity SHE = new StockHoldEntity();
     SHE.id = DLE.id;
     stockhold.Select(ref SHE);
     MoneyChangeNow(SHE.money);
     stockhold.Delete(DLE.id);
     historystockhold.Delete(DLE.id);
     if (DLEL.Count == 0)
     {
         SHE.hold = 0;
         SHE.id = DLE.id;
         SHE.money = 0;
         SHE.name = DLE.name;
         StockHoldSet(SHE);
     }
     foreach (DealListEntity D in DLEL)
     {
         SHE = DealList_Insert_StockHold(D);
     }
     StockHoldSet(SHE);
     MoneyReadSet();
 }
Esempio n. 15
0
 //持股构成执行委托
 private void StockHoldSet(StockHoldEntity SHE)
 {
     if (stockholdDelegate != null)
         stockholdDelegate(SHE);
 }
Esempio n. 16
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            string u = user.Text;
            try
            {
                Convert.ToDouble(money.Text);
                if (number.Text == "0")
                    throw new Exception();
                if (type.Text == "买入" || type.Text == "补仓")
                {
                    int buy = Convert.ToInt32(number.Text);
                    if (buy % 100 != 0)
                        throw new Exception();
                    if (buy * Convert.ToDouble(money.Text) > UserPanelController.Handler().DBControllerByName(u).NowMoneyRead()) 
                    {
                        MessageBox.Show("现金不足!");
                        return;
                    }
                }
                else if (type.Text == "卖出")
                {
                    StockHoldEntity SHE = new StockHoldEntity();
                    SHE.id = id.Text;
                    UserPanelController.Handler().DBControllerByName(u).StockHoldRead(ref SHE);
                    if (SHE.hold < Convert.ToInt32(number.Text))
                    {
                        MessageBox.Show("卖出数目超出范围!");
                        return;
                    }
                }
                if (taxrate.Text[taxrate.Text.Length - 1] != '‰')
                    throw new Exception();
                if (commission.Text[commission.Text.Length - 1] != '‰')
                    throw new Exception();
            }
            catch (Exception)
            {
                MessageBox.Show("输入的数据有误\n请检查后输入");
                return;
            }
            DealListEntity DLE;
            DLE.deal = deal;
            DLE.name = name.Text;
            DLE.id = id.Text;
            DLE.date = Convert.ToDateTime(date.Text);
            DLE.type = type.Text;
            DLE.money = Convert.ToDouble(money.Text);
            DLE.number = Convert.ToInt32(number.Text);
            DLE.taxrate = Convert.ToDouble(taxrate.Text.Substring(0,taxrate.Text.IndexOf("‰")));
            DLE.commission = Convert.ToDouble(commission.Text.Substring(0,commission.Text.IndexOf("‰")));
            DLE.explain = explain.Text;
            DLE.remark = remark.Text;
            UserPanelController.Handler().UserChange(u);

            //UserPanelController.Handler().DBControllerByName(u).DealListAdd(DLE);
            DBDataThreadController.DBDataThreadControllerHandler(UserPanelController.Handler().DBControllerByName(u)).DealListAdd(DLE);
            MainWindow.ShowNotifyMessage("交易记录已添加\n股票:" + DLE.name + "以" + DLE.money + "元" + DLE.type + DLE.number + "股!");
            //MessageBox.Show("添加成功!");
            //StockStateBoxController.Handler().Add(id.Text, name.Text, Convert.ToInt32(number.Text), Convert.ToDouble(money.Text) * Convert.ToInt32(number.Text));
            this.Close();
        }