Ejemplo n.º 1
0
        private static Request MaterialRequestHandler(Request req)
        {
            try
            {
                //switch based on the purpose
                switch (req.purpose)
                {
                    case Constants.Request_Material:
                        // show the input to the user
                        MessageBox.Show("A request has been made for\n " + (JsonConvert.DeserializeObject<MaterialRequest>(req.content).MaterialName) + "\n quantity " + (JsonConvert.DeserializeObject<MaterialRequest>(req.content).quantity) , "Field Request", MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK, MessageBoxOptions.None);
                        //Application.Current.Dispatcher.BeginInvoke( DispatcherPriority.Background, new Action( () => ) );
                        //Application.Current.Dispatcher.Invoke(new Action(() => FillRequests));

                        break;
                    case Constants.Remainder_Materials:
                        //show the user the request
                        MessageBox.Show("There is a remainder of \n " + (JsonConvert.DeserializeObject<MaterialRequest>(req.content).MaterialName) + "\n in " + (JsonConvert.DeserializeObject<RemainderRequest>(req.content).quantity) + "amount", "Field Request", MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK, MessageBoxOptions.None);
                        DB1 = new DBManager();
                        if (DB1.UpdateValue((JsonConvert.DeserializeObject<RemainderRequest>(req.content).quantity), (JsonConvert.DeserializeObject<MaterialRequest>(req.content).MaterialName)))
                        {
                            MessageBox.Show("stock has been updated");
                        }
                        break;
                }
            }
            catch { }

            return req;
        }