none
What is the best way of storing properties value of different classes to a database? RRS feed

  • Question

  • I have got a wpf app which I am trying to convert to asp mvc. In wpf I use a text file to store all the values of textboxes, radio etc, however, in the asp mvc I got to use a database. 

    In the wpf I do as follow:

            private void save()
            {
    
                //StringBuilder sb = new StringBuilder();
                List<List<string>> inputsAll = new List<List<string>>();
                List<string> inputs = new List<string>();
                inputs.Add(nozzleAllUC.NozzlesOnBottomDishTabControl.Items.Count.ToString());
                inputs.Add(nozzleAllUC.NozzlesOnTopDishTabControl.Items.Count.ToString());
                inputs.Add(nozzleAllUC.NozzlesOnShellTabControl.Items.Count.ToString());
                //inputs.Add(nShells.Count().ToString());
                inputsAll.Add(inputs);
                Window window = this;
                inputsAll.Add(util.SaveContent(window));
    
                List<string> inputsNozzle= util.SaveContent(nozzleAllUC);
                if (saveFileName.Contains(".bs"))
                {
                    File.WriteAllLines(saveFileName.Replace(".bs", ".nozzle"), inputsNozzle);
                    for (int i = 0; i < inputsAll.Count; i++)
                    {
                        if (i == 0)
                        {
                            File.WriteAllLines(saveFileName, inputsAll[0]);         
                        }
                        else
                        {
                            File.AppendAllLines(saveFileName, inputsAll[i]);
                        }
                    }
                }
                else
                {
                    string saveFileNameNozzle = saveFileName + ".nozzle";
                    File.WriteAllLines(saveFileNameNozzle, inputsNozzle);
                    saveFileName = saveFileName + ".bs";
                    for (int i = 0; i < inputsAll.Count; i++)
                    {
                        
                        if (i == 0)
                        {
    
                            File.WriteAllLines(saveFileName, inputsAll[0]);
                        }
                        else
                        {
    
                            File.AppendAllLines(saveFileName, inputsAll[i]);
                        }
                    }
    
                }
                informationStutusBarTB.Text = "Job saved successfully at " + DateTime.Now + " Save file Name: " + saveFileName;
            }

    Friday, July 17, 2015 2:34 PM