Exemple #1
0
 public Structure()
 {
     InitializeComponent();
     this.StockList.ItemsSource = list;
     name         = UserPanelController.Handler().name;
     user.Content = "(" + name + ")";
 }
Exemple #2
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            DrawDataController DDC = new DrawDataController((int)(hold.Width), (int)(hold.Height));

            hold.Source = Adapter.ImageAdapter.ImageConvert(DDC.GetImage());
            List <StockHoldEntity> SHEL;

            UserPanelController.Handler().DBControllerByName(name).StockHoldReadAll(out SHEL);
            List <string> idl = SHEL.Select(s => s.id).ToList();

            NetState.IdConvert(ref idl);
            List <DrawPieEntity> DPEL = new List <DrawPieEntity>();
            DrawPieEntity        DPE  = new DrawPieEntity();

            foreach (StockHoldEntity SHE in SHEL)
            {
                string id = idl.Where(s => s.Substring(1) == SHE.id).First();
                if (id == null)
                {
                    continue;
                }
                StockView sv = new StockView(SHE.name, id);
                list.Add(sv);
                stockcolor.Add(sv.StockID, sv.brush.Color);
                DPE.name  = SHE.name;
                DPE.money = SHE.hold * NetState.PriceGet(sv.StockID);
                DPE.color = Adapter.ImageAdapter.ColorConvert(sv.brush.Color);
                DPEL.Add(DPE);
            }
            DDC = new DrawDataController((int)(pie.Width), (int)(pie.Height));
            DDC.DrawPieChart(DPEL);
            pie.Source = Adapter.ImageAdapter.ImageConvert(DDC.GetImage());
            this.StockList.Items.Refresh();
        }
Exemple #3
0
        public AddDealList(string user, int deal)
        {
            InitializeComponent();
            this.titlename.Text = "修改交易";
            add.Visibility      = Visibility.Hidden;
            ComboBoxItem cbi = new ComboBoxItem();

            cbi.Content = user;
            this.user.Items.Add(cbi);
            this.user.SelectedIndex = 0;
            this.user.IsEnabled     = false;
            DealListEntity DLE = UserPanelController.Handler().DBControllerByName(user).DealListReadByDeal(deal);

            this.deal       = DLE.deal;
            name.Text       = DLE.name;
            id.Text         = DLE.id;
            date.Text       = DLE.date.ToString();
            type.Text       = DLE.type;
            money.Text      = DLE.money.ToString();
            number.Text     = DLE.number.ToString();
            taxrate.Text    = DLE.taxrate.ToString() + "‰";
            commission.Text = DLE.commission.ToString() + "‰";
            explain.Text    = DLE.explain;
            remark.Text     = DLE.remark;
        }
Exemple #4
0
        private void MenuItem_Click(object sender, RoutedEventArgs e)
        {
            InputMoney im = new InputMoney();

            im.name.Text      = this.name.Content.ToString();
            im.name.IsEnabled = false;
            string u   = name.Content.ToString();
            double pri = UserPanelController.Handler().DBControllerByName(u).PrincipalRead();

            im.money.Text = pri.ToString();
            im.ShowDialog();
            double now = UserPanelController.Handler().DBControllerByName(u).NowMoneyRead();

            if (im.m == 0)
            {
                return;
            }
            if (pri - im.m > now)
            {
                MessageBox.Show("最低本金设置为:" + (pri - now).ToString());
                return;
            }
            this.pri.Content = "本金:" + im.m;
            UserPanelController.Handler().DBControllerByName(u).PrincipalChange(im.m - pri);
            MainWindow.ShowNotifyMessage("成功修改本金\n账户名:" + u + "本金:" + im.m);
        }
Exemple #5
0
        public AddDealList()
        {
            InitializeComponent();
            List <string> user  = UserPanelController.Handler().GetUserList();
            int           index = -1;
            string        u     = DBSyncController.Handler().GetUserName();

            foreach (string s in user)
            {
                index++;
                if (s == u)
                {
                    this.user.SelectedIndex = index;
                }
                ComboBoxItem cbi = new ComboBoxItem();
                cbi.Content = s;
                this.user.Items.Add(cbi);
            }
            //List<string> user = UserPanelController.Handler().GetUserList();
            //foreach(string s in user)
            //{
            //    ComboBoxItem cbi = new ComboBoxItem();
            //    cbi.Content = s;
            //    this.user.Items.Add(cbi);
            //}
            change.Visibility = Visibility.Hidden;
            delete.Visibility = Visibility.Hidden;
        }
Exemple #6
0
        private void Remove_Click(object sender, RoutedEventArgs e)
        {
            MessageBoxResult res = MessageBox.Show("是否删除账户:" + name.Content.ToString(), "删除账户", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.No);

            if (res == MessageBoxResult.Yes)
            {
                UserPanelController.Handler().DelUser(name.Content.ToString());
                MainWindow.ShowNotifyMessage("成功删除用户\n账户名:" + name.Content.ToString());
            }
        }
Exemple #7
0
        private void user_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            string u = ((ComboBoxItem)(((ComboBox)sender).SelectedItem)).Content.ToString();

            if (id == null)
            {
                UserPanelController.Handler().DBControllerByName(u).DealListReadAll(out DLEL);
                DealListShow();
            }
            else
            {
                UserPanelController.Handler().DBControllerByName(u).DealListReadById(id, out DLEL);
                DealListShow();
            }
        }
Exemple #8
0
        private void SetUserList()
        {
            List <string> user  = UserPanelController.Handler().GetUserList();
            int           index = -1;
            string        u     = DBSyncController.Handler().GetUserName();

            foreach (string s in user)
            {
                index++;
                if (s == u)
                {
                    this.user.SelectedIndex = index;
                }
                ComboBoxItem cbi = new ComboBoxItem();
                cbi.Content = s;
                this.user.Items.Add(cbi);
            }
        }
Exemple #9
0
        private void DList_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            object o = DList.SelectedItem;

            if (o == null)
            {
                return;
            }
            ItemData    item = o as ItemData;
            AddDealList adl  = new AddDealList(user.Text, item.deal);

            adl.ShowDialog();
            DealListEntity DLE   = UserPanelController.Handler().DBControllerByName(user.Text).DealListReadByDeal(item.deal);
            int            index = DList.SelectedIndex;

            DList.Items.Remove(item);
            if (DLE.id == item.id)
            {
                item = new ItemData(DLE.deal, DLE.name, DLE.id, DLE.date.ToString("yyyy/MM/dd"), DLE.type, DLE.money.ToString(), DLE.number.ToString(), DLE.taxrate.ToString(), DLE.commission.ToString(), DLE.explain, DLE.remark);
                DList.Items.Insert(index, item);
            }
            DList.UpdateLayout();
            //MessageBox.Show("暂时未提供修改功能!");
        }
Exemple #10
0
        private void ShowImage(object sender, RoutedEventArgs e)
        {
            if (user.Content.ToString() != "(" + UserPanelController.Handler().DBControllerByName(name).GetUserName() + ")")
            {
                MessageBox.Show("用户已改变!");
                this.Close();
                return;
            }
            if (select.Count == 0)
            {
                MessageBox.Show("请选择股票");
                return;
            }
            DateTime date;
            int      days;

            try
            {
                date = Convert.ToDateTime(StartDate.Text);
                days = Convert.ToInt32(DateLong.Text);
            }
            catch (Exception)
            {
                MessageBox.Show("请输入正确的日期");
                return;
            }
            Dictionary <DateTime, double> money;
            List <HistoryStockHoldEntity> HSHEL;
            DrawDataController            DDC = new DrawDataController((int)(hold.Width), (int)(hold.Height));
            Dictionary <System.Drawing.Color, List <DrawDataEntity> > dict = new Dictionary <System.Drawing.Color, List <DrawDataEntity> >();
            double max = 0;

            foreach (string id in select)
            {
                DrawDataEntity        DDE  = new DrawDataEntity();
                List <DrawDataEntity> DDEL = new List <DrawDataEntity>();
                UserPanelController.Handler().DBControllerByName(name).HistoryStockHoldReadByRange(id.Substring(1), date, days, out HSHEL);
                if (HSHEL.Count == 0)
                {
                    continue;
                }
                NetDataController.HistoryMoney(id, date, days, out money);
                int      index  = 0;
                DateTime usable = DateTime.Parse("1970-01-01");
                for (int i = 0; i < days; i++)
                {
                    DateTime dt = date.AddDays(i);
                    DDE.date = dt;
                    if (dt > DateTime.Now)
                    {
                        break;
                    }
                    if (money.ContainsKey(dt))
                    {
                        usable = dt;
                    }
                    else
                    {
                        if (usable == DateTime.Parse("1970-01-01"))
                        {
                            continue;
                        }
                    }
                    if (dt < HSHEL[index].date)
                    {
                        DDE.money = HSHEL[index].number * money[usable];
                    }
                    else
                    {
                        if (index >= HSHEL.Count - 1)
                        {
                            DDE.money = (HSHEL[index].number + HSHEL[index].change) * money[usable];
                        }
                        else
                        {
                            while (index + 1 < HSHEL.Count && HSHEL[index].date == HSHEL[index + 1].date)
                            {
                                index++;
                            }
                            if (index < HSHEL.Count - 1)
                            {
                                index++;
                            }
                            DDE.money = HSHEL[index].number * money[usable];
                        }
                    }
                    if (max < DDE.money)
                    {
                        max = DDE.money;
                    }
                    DDEL.Add(DDE);
                }
                dict.Add(Adapter.ImageAdapter.ColorConvert(stockcolor[id]), DDEL);
            }
            DDC.DrawData(dict, max);
            hold.Source = Adapter.ImageAdapter.ImageConvert(DDC.GetImage());
        }
Exemple #11
0
        private void CButton_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 (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;
            string t = ((Button)sender).Content.ToString();

            if (t == "删除")
            {
                DBDataThreadController.DBDataThreadControllerHandler(UserPanelController.Handler().DBControllerByName(u)).DealListDelete(DLE);
                //UserPanelController.Handler().DBControllerByName(u).DealListDelete(DLE);
                MainWindow.ShowNotifyMessage("交易记录已删除\n股票:" + DLE.name + "!");
            }
            else if (t == "修改")
            {
                DBDataThreadController.DBDataThreadControllerHandler(UserPanelController.Handler().DBControllerByName(u)).DealListUpdate(DLE);
                //UserPanelController.Handler().DBControllerByName(u).DealListUpdate(DLE);
                MainWindow.ShowNotifyMessage("交易记录已修改\n股票:" + DLE.name + "以" + DLE.money + "元" + DLE.type + DLE.number + "股!");
            }
            this.Close();
        }
Exemple #12
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();
        }
Exemple #13
0
        private void user_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            string u = ((ComboBoxItem)(((ComboBox)sender).SelectedItem)).Content.ToString();

            DBC = UserPanelController.Handler().DBControllerByName(u);
        }