예제 #1
0
        private void BtnAdd_Click(object sender, RoutedEventArgs e)
        {
            switch (Manager.Instance.ActiveTable)
            {
            case Active.Stores:
            {
                WNewStore newStore = new WNewStore();
                newStore.ShowDialog();
                BtnStores_Click(new object(), new RoutedEventArgs());
            }
            break;

            case Active.Bikes:
            {
                WNewBike addBike = new WNewBike();
                addBike.ShowDialog();
                BtnBikes_Click(new object(), new RoutedEventArgs());
            }
            break;

            case Active.Models:
            {
                WNewModel wNewModel = new WNewModel();
                wNewModel.ShowDialog();
                BtnModels_Click(new object(), new RoutedEventArgs());
            }
            break;

            case Active.Users:
            {
                WNewUser newUser = new WNewUser();
                newUser.ShowDialog();
                BtnUser_Click(new object(), new RoutedEventArgs());
            }
            break;

            case Active.Orders:
            {
                WNewOrder newOrder = new WNewOrder(0);
                newOrder.ShowDialog();
                BtnOrders_Click(new object(), new RoutedEventArgs());
            }
            break;

            default:
                break;
            }
        }
예제 #2
0
        private void BtnEdit_Click(object sender, RoutedEventArgs e)
        {
            int id = Convert.ToInt16(((DataRowView)DBGrid.SelectedItems[0]).Row["Id"].ToString());

            switch (Manager.Instance.ActiveTable)
            {
            case Active.Stores:
            {
                WNewStore editStore = new WNewStore(id);
                editStore.txtName.Text    = ((DataRowView)DBGrid.SelectedItems[0]).Row["Name"].ToString();
                editStore.txtAddress.Text = ((DataRowView)DBGrid.SelectedItems[0]).Row["Address"].ToString();
                editStore.txtPhone.Text   = ((DataRowView)DBGrid.SelectedItems[0]).Row["Phone"].ToString();
                editStore.ShowDialog();
                BtnStores_Click(new object(), new RoutedEventArgs());
            }
            break;

            case Active.Bikes:
            {
                WNewBike editBike = new WNewBike(id);
                //editBike.BikeName.Text = ((DataRowView)DBGrid.SelectedItems[0]).Row["Name"].ToString();
                editBike.Price.Text = ((DataRowView)DBGrid.SelectedItems[0]).Row["Price"].ToString();
                //editBike.Stores.SelectedValue = ((DataRowView)DBGrid.SelectedItems[0]).Row["Store"].ToString() as object;
                editBike.Description.Text = ((DataRowView)DBGrid.SelectedItems[0]).Row["Status"].ToString();
                editBike.ShowDialog();
                BtnBikes_Click(new object(), new RoutedEventArgs());
            }
            break;

            case Active.Models:
            {
                WNewModel editModel = new WNewModel(id);
                editModel.txtName.Text        = ((DataRowView)DBGrid.SelectedItems[0]).Row["Name"].ToString();
                editModel.txtDescription.Text = ((DataRowView)DBGrid.SelectedItems[0]).Row["Desc"].ToString();
                editModel.ShowDialog();
                BtnModels_Click(new object(), new RoutedEventArgs());
            }
            break;

            case Active.Users:
            {
                WNewUser editUser = new WNewUser(id);
                editUser.txtName.Text  = ((DataRowView)DBGrid.SelectedItems[0]).Row["Name"].ToString();
                editUser.txtPhone.Text = ((DataRowView)DBGrid.SelectedItems[0]).Row["Phone"].ToString();
                editUser.ShowDialog();
                BtnUser_Click(new object(), new RoutedEventArgs());
            }
            break;

            case Active.Orders:
            {
                //int id  = Convert.ToInt16(((DataRowView)DBGrid.SelectedItems[0]).Row["Id"].ToString());
                WNewOrder newOrder = new WNewOrder(id)
                {
                    ClientId = Convert.ToInt16(((DataRowView)DBGrid.SelectedItems[0]).Row["UserId"].ToString()),
                    DateTime = Convert.ToDateTime(((DataRowView)DBGrid.SelectedItems[0]).Row["Date"])
                };
                newOrder.ShowDialog();
            }
            break;

            default:
                break;
            }
        }