コード例 #1
0
        public OrderFormViewModel()
        {
            OrderDataSet dataset = new OrderDataSet();

            OrderDataSetTableAdapters.OrdersTableAdapter     Order     = new OrderDataSetTableAdapters.OrdersTableAdapter();
            OrderDataSetTableAdapters.Orders_ObsTableAdapter Order_obs = new OrderDataSetTableAdapters.Orders_ObsTableAdapter();

            _row     = dataset.Orders.NewOrdersRow();
            _row_obs = dataset.Orders_Obs.NewOrders_ObsRow();

            //Order
            _row.Reference       = "";
            _row.OperatorId      = 0;
            _row.ClientId        = 0;
            _row.StartDate       = DateTime.Now;
            _row.FinalDate       = DateTime.MinValue;
            _row.Address         = "";
            _row.City            = "";
            _row.PostCode        = "";
            _row.FactoryId       = 0;
            _row.ProductId       = 0;
            _row.VehicleSize     = 1;
            _row.RequestedAmount = 0;
            _row.Status          = 1;

            _row.CreatedDate  = DateTime.Now;
            _row.ModifiedDate = DateTime.Now;

            //observaciones pedido
            _row_obs.Observations = "";
            _row_obs.Description  = "";

            SaveCommand = new RelayCommand(Save, CanSave);
        }
コード例 #2
0
        public void Load(long IdOrder)
        {
            try
            {
                OrderDataSet dataset = new OrderDataSet();
                OrderDataSetTableAdapters.OrdersTableAdapter TableOrder = new OrderDataSetTableAdapters.OrdersTableAdapter();
                OrderDataSet.OrdersDataTable dataTable = TableOrder.GetDataOrderById(IdOrder);

                if (dataTable.Rows.Count > 0)
                {
                    OrderDataSetTableAdapters.Orders_ObsTableAdapter order_obs = new OrderDataSetTableAdapters.Orders_ObsTableAdapter();
                    OrderDataSet.Orders_ObsDataTable dataTable_Obs             = order_obs.GetDataOrder_ObsById(IdOrder);

                    _row = (OrderDataSet.OrdersRow)dataTable.Rows[0];

                    RaisePropertyChanged(nameof(Reference));
                    RaisePropertyChanged(nameof(OperatorCode));
                    RaisePropertyChanged(nameof(ClientCode));
                    RaisePropertyChanged(nameof(ProductCode));
                    RaisePropertyChanged(nameof(FactoryCode));
                    RaisePropertyChanged(nameof(ClientId));
                    RaisePropertyChanged(nameof(Address));
                    RaisePropertyChanged(nameof(City));
                    RaisePropertyChanged(nameof(PostCode));
                    RaisePropertyChanged(nameof(FromDate));
                    RaisePropertyChanged(nameof(ToDate));
                    RaisePropertyChanged(nameof(ProductId));
                    RaisePropertyChanged(nameof(VehicleSize));
                    RaisePropertyChanged(nameof(RequestedAmount));
                    RaisePropertyChanged(nameof(Status));

                    //Cargamos datos
                    LoadDatasInterface(_row.ProductId, _row.OperatorId, _row.ClientId, _row.FactoryId);

                    _row_obs = (OrderDataSet.Orders_ObsRow)dataTable_Obs.Rows[0];
                    RaisePropertyChanged(nameof(Description));
                    RaisePropertyChanged(nameof(Observation));
                }
                FormLoadFinished?.Invoke();
            }
            catch (Exception e)
            {
                FormLoadError?.Invoke(e);
            }
        }