Ejemplo n.º 1
0
        private void OrdersGrid_BeginningEdit(object sender, DataGridBeginningEditEventArgs e)
        {
            if ((string)e.Column.Header == "Trade")
            {
                //make sure the popup isn't too big, otherwise items can be hidden in small resolutions
                OrdersGridTradePickerPopup.Height = Math.Min(600, OrdersGrid.ActualHeight - 100);

                var order = (Order)OrdersGrid.SelectedItem;
                //if this order belongs to a closed trade, disallow editing
                if (order.Trade != null && order.Trade.Open == false)
                {
                    e.Cancel = true;
                    return;
                }

                //Fill it
                TradePickerListBox.ItemsSource = Context
                                                 .Trades
                                                 .Where(x => x.Open)
                                                 .OrderBy(x => x.Name)
                                                 .ToList()
                                                 .Select(
                    x => new CheckListItem <Trade>(x))
                                                 .ToList();

                //make sure the currently selected trade is checked
                if (order.Trade != null)
                {
                    foreach (CheckListItem <Trade> item in TradePickerListBox.Items)
                    {
                        item.IsChecked = order.Trade.ID == item.Item.ID;
                    }
                }

                //and open it at the right position
                OrdersGridTradePickerPopup.PlacementTarget = OrdersGrid.GetCell(e.Row.GetIndex(), e.Column.DisplayIndex);
                OrdersGridTradePickerPopup.IsOpen          = true;
            }
        }
Ejemplo n.º 2
0
        private async void TradePickerNewTradeTextBox_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Enter && !String.IsNullOrEmpty(TradePickerNewTradeTextBox.Text))
            {
                var selectedOrder = (Order)OrdersGrid.SelectedItem;
                var newTrade      = new Trade {
                    Name = TradePickerNewTradeTextBox.Text, Open = true
                };
                Context.Trades.Add(newTrade);
                newTrade.Tags = new List <Tag>();

                await Task.Run(async() =>
                {
                    await TradesRepository.AddOrder(newTrade, selectedOrder).ConfigureAwait(true);
                    await TradesRepository.Save().ConfigureAwait(true);
                }).ConfigureAwait(true);

                TradePickerNewTradeTextBox.Text   = "";
                OrdersGridTradePickerPopup.IsOpen = false;
                OrdersGrid.CommitEdit();
            }
        }
Ejemplo n.º 3
0
        public MainWindow(DataContainer data, IAppSettings settings, DbContextFactory contextFactory, IDataSourcer dataSourcer)
        {
            /////////////////////////////////////////////////////////
            InitializeComponent();
            /////////////////////////////////////////////////////////

            Settings       = settings;
            ContextFactory = contextFactory;
            DataSourcer    = dataSourcer;

            ViewModel        = new MainViewModel(ContextFactory, DataSourcer, DialogCoordinator.Instance, Settings, data);
            this.DataContext = ViewModel;

            PopulateStatementMenus();

            //Restore column ordering, widths, and sorting
            LoadDataGridLayouts();

            //A hack to force the heavy stuff to load,
            //providing snappier navigation at the expense of longer startup time
#if !DEBUG
            TradesGrid.Measure(new Size(500, 500));

            OrdersGrid.Measure(new Size(500, 500));

            CashTransactionsGrid.Measure(new Size(500, 500)); //todo: remove this stuff?
#endif
            //hiding the tab headers
            Style s = new Style();
            s.Setters.Add(new Setter(VisibilityProperty, Visibility.Collapsed));
            MainTabCtl.ItemContainerStyle = s;

            //close the slash screen
            //App.Splash.LoadComplete();

            this.Show();

            ShowChangelog();
        }
Ejemplo n.º 4
0
        public async Task<ActionResult> Orders()
        {
            var userId = User.Identity.GetUserId();

            var orders = await _orderService.Query(x => x.Status != (int)Enum_OrderStatus.Created && (x.UserProvider == userId || x.UserReceiver == userId))
                .Include(x => x.Listing).SelectAsync();

            var grid = new OrdersGrid(orders.AsQueryable().OrderByDescending(x => x.Created));

            var model = new OrderModel()
            {
                Grid = grid
            };

            return View(model);
        }
        public async Task<ActionResult> Order()
        {
            var userId = User.Identity.GetUserId();

            var orders = await _orderService.Query(x => x.Status != (int)Enum_OrderStatus.Created)
                .Include(x => x.Item).Include(x => x.AspNetUser).Include(x => x.AspNetUser1).SelectAsync();

            var grid = new OrdersGrid(orders.AsQueryable().OrderByDescending(x => x.Created));

            var model = new OrderModel()
            {
                Grid = grid
            };

            return View(model);
        }
Ejemplo n.º 6
0
 private void UserOrders_Shown(object sender, EventArgs e)
 {
     OrdersGrid.ClearSelection();
 }
Ejemplo n.º 7
0
        public MainWindow()
        {
            //make sure we have a database connection and stuff, otherwise show the dialog to set db settings
            try
            {
                DBUtils.CheckDBConnection();
            }
            catch
            {
                App.Splash.LoadComplete();
                var dbDetailsWindow = new DBPicker();
                dbDetailsWindow.ShowDialog();
            }

            //initialize logging
            InitializeLogging();

            //Log unhandled exceptions
            AppDomain.CurrentDomain.UnhandledException += AppDomain_CurrentDomain_UnhandledException;

            //set the connection string
            DBUtils.SetConnectionString();

            Context = new DBContext();

            //create db if it doesn't exist
            Context.Database.Initialize(false);

            //check for any currencies, seed the db with initial values if nothing is found
            if (!Context.Currencies.Any())
            {
                Seed.DoSeed();
            }

            //check for empty account fields
            if (Context.EquitySummaries.Any(x => x.AccountID == null))
            {
                App.Splash.LoadComplete();
                var accountMigrationWindow = new AccountMigrationWindow();
                accountMigrationWindow.ShowDialog();
            }

            var qdmsSource = new ExternalDataSources.QDMS();

            Datasourcer = new DataSourcer(Context, qdmsSource);

            TradesRepository = new TradesRepository(Context, Datasourcer);

            IDialogService dialogService = new DialogService(this);

            ViewModel = new MainViewModel(Context, Datasourcer, dialogService);

            /////////////////////////////////////////////////////////
            InitializeComponent();
            /////////////////////////////////////////////////////////

            DataContext = ViewModel;

            //Create the load statement menus using the loaded plugins
            PopulateStatementMenus();

            //Restore column ordering, widths, and sorting
            LoadDataGridLayouts();

            //A hack to force the heavy stuff to load,
            //providing snappier navigation at the expense of longer startup time
#if !DEBUG
            ViewModel.TradesPageViewModel.Refresh();
            TradesGrid.Measure(new Size(500, 500));

            ViewModel.OrdersPageViewModel.Refresh();
            OrdersGrid.Measure(new Size(500, 500));

            ViewModel.CashTransactionsPageViewModel.Refresh();
            CashTransactionsGrid.Measure(new Size(500, 500));
#endif
            //hiding the tab headers
            Style s = new Style();
            s.Setters.Add(new Setter(VisibilityProperty, Visibility.Collapsed));
            MainTabCtl.ItemContainerStyle = s;

            //load the open positions page data
            ViewModel.RefreshCurrentPage();

            //close the slash screen
            App.Splash.LoadComplete();

            ShowChangelog();
        }
Ejemplo n.º 8
0
 protected void dataBind()
 {
     OrdersGrid.DataSource = (DataTable)Session["SqlDataSource"];
     OrdersGrid.DataBind();
 }
Ejemplo n.º 9
0
 protected void OrdersGrid_CustomCallback(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewCustomCallbackEventArgs e)
 {
     OrdersGrid.DataBind();
 }
Ejemplo n.º 10
0
 public ActionResult Grid()
 {
     var repository = new OrdersRepository();
     var grid = new OrdersGrid(repository.GetAll());
     return PartialView("_OrdersGrid", grid);
 }
        protected void SearchOrders_Click(object sender, EventArgs e)
        {
            String timeperiod = RadioButtonList1.SelectedValue.ToString();
            String status     = RadioButtonList3.SelectedValue.ToString();
            String sql        = "";
            String sql2       = "";

            conn = new MySqlConnection(GetConnectionString());
            if (timeperiod.Equals("By Day"))
            {
                String temp = DropDownList3.SelectedValue.ToString();
                sql = "Select Order_ID,Amount,Quantity,Date_Time,Order_Received from Order_Detail_Store where DATE_FORMAT(Date_Time,'%d-%M-%Y') like '" + temp + "'";
            }
            if (timeperiod.Equals("By Week"))
            {
                String temp = DropDownList1.SelectedValue.ToString();
                sql = "Select Order_ID,Amount,Quantity,Date_Time,Order_Received from Order_Detail_Store where WEEK(Date_Time) = " + temp + "";
            }
            if (timeperiod.Equals("By Month"))
            {
                String temp = DropDownList2.SelectedValue.ToString();
                sql = "Select Order_ID,Amount,Quantity,Date_Time,Order_Received from Order_Detail_Store where MONTHNAME(Date_Time) = '" + temp + "'";
            }
            if (timeperiod.Equals("By Quarter"))
            {
                String temp = DropDownList4.SelectedValue.ToString();
                sql = "Select Order_ID,Amount,Quantity,Date_Time,Order_Received from Order_Detail_Store where QUARTER(Date_Time) = " + temp + "";
            }

            if (timeperiod.Equals("Custom Date"))
            {
                String date1 = TextBox5.Text;
                String date2 = TextBox6.Text;
                sql = "Select Order_ID,Amount,Quantity,Date_Time,Order_Received from Order_Detail_Store where DATE(Date_Time) BETWEEN '" + date1 + "' AND '" + date2 + "'";
            }

            if (status.Equals("") || status.Equals("All"))
            {
                sql2 = "";
            }
            if (status.Equals("Received"))
            {
                sql2 = " and Order_Received='Completed'";
            }
            if (status.Equals("Pending"))
            {
                sql2 = " and Order_Received='Pending'";
            }

            Response.Write(sql + sql2);

            try
            {
                conn.Open();
                MySqlCommand    comm = new MySqlCommand(sql + sql2, conn);
                MySqlDataReader dr1  = comm.ExecuteReader();
                OrdersGrid.DataSource = dr1;
                OrdersGrid.DataBind();
                dr1.Close();
            }
            catch (Exception ex)
            { Response.Write(ex.Message); }
            finally { conn.Close(); }
        }