Example #1
0
 private void btnSaveProductXml_Click(object sender, EventArgs e)
 {
     if (tabProduct.Visible == false || isexist == false)
     {
         MessageBox.Show("数据不存在!", "错误");
         return;
     }
     else
     {
         if (openPath != "")
         {
             if (!System.IO.File.Exists(openPath))
             {
                 MessageBox.Show(openPath + " 该路径下的打开文件不存在!", "错误");
                 return;
             }
             else
             {
                 SaveDialog sd = new SaveDialog();
                 sd.ShowDialog();
                 if (sd.DialogResult == DialogResult.OK)
                 {
                     savePath = openPath;
                 }
                 else if (sd.DialogResult == DialogResult.Cancel)
                 {
                     return;
                 }
                 else if (sd.DialogResult == DialogResult.Abort)
                 {
                     SaveFileDialog saveDialog = new SaveFileDialog();
                     saveDialog.Title            = "";
                     saveDialog.InitialDirectory = Application.StartupPath + "\\resources\\product";
                     saveDialog.Filter           = "xml files (*.xml)|*.xml";
                     saveDialog.FileName         = cmbProductName.Text;
                     saveDialog.RestoreDirectory = false;
                     if (saveDialog.ShowDialog() == DialogResult.OK)
                     {
                         //System.IO.FileStream fs = (System.IO.FileStream)saveDialog.OpenFile();
                         //fs.Close();
                         savePath = saveDialog.FileName.ToString();
                         openPath = savePath;
                     }
                     else
                     {
                         return;
                     }
                 }
             }
         }
         else
         {
             SaveFileDialog saveDialog = new SaveFileDialog();
             saveDialog.Title            = "";
             saveDialog.InitialDirectory = Application.StartupPath + "\\resources\\product";
             saveDialog.Filter           = "xml files (*.xml)|*.xml";
             saveDialog.FileName         = cmbProductName.Text;
             saveDialog.RestoreDirectory = false;
             if (saveDialog.ShowDialog() == DialogResult.OK)
             {
                 //System.IO.FileStream fs = (System.IO.FileStream)saveDialog.OpenFile();
                 //fs.Close();
                 savePath = saveDialog.FileName.ToString();
                 openPath = savePath;
             }
             else
             {
                 return;
             }
         }
         //
         if (EnsurePara())
         {
             //Serialize
             SystemConfig.SerializeToXml(savePath, product);
         }
     }
 }
Example #2
0
        private void btnSaveXml_Click(object sender, EventArgs e)
        {
            if (tabControl1.Visible == false)
            {
                MessageBox.Show("数据不存在!", "错误");
            }
            else
            {
                if (openPath != "")
                {
                    if (!System.IO.File.Exists(openPath))
                    {
                        MessageBox.Show(openPath + " 该路径下的打开文件不存在!", "错误");
                        return;
                    }
                    else
                    {
                        SaveDialog sd = new SaveDialog();
                        sd.ShowDialog();
                        if (sd.DialogResult == DialogResult.OK)
                        {
                            savePath = openPath;
                        }
                        else if (sd.DialogResult == DialogResult.Cancel)
                        {
                            return;
                        }
                        else if (sd.DialogResult == DialogResult.Abort)
                        {
                            SaveFileDialog saveDialog = new SaveFileDialog();
                            saveDialog.Title            = "";
                            saveDialog.InitialDirectory = Application.StartupPath + "\\resources\\wedge";
                            saveDialog.Filter           = "xml files (*.xml)|*.xml";
                            saveDialog.FileName         = cmbName.Text;
                            saveDialog.RestoreDirectory = false;
                            if (saveDialog.ShowDialog() == DialogResult.OK)
                            {
                                //System.IO.FileStream fs = (System.IO.FileStream)saveDialog.OpenFile();
                                //fs.Close();
                                savePath = saveDialog.FileName.ToString();
                                openPath = savePath;
                            }
                            else
                            {
                                return;
                            }
                        }
                    }
                }
                else
                {
                    SaveFileDialog saveDialog = new SaveFileDialog();
                    saveDialog.Title            = "";
                    saveDialog.InitialDirectory = Application.StartupPath + "\\resources\\wedge";
                    saveDialog.Filter           = "xml files (*.xml)|*.xml";
                    saveDialog.FileName         = cmbName.Text;
                    saveDialog.RestoreDirectory = false;
                    if (saveDialog.ShowDialog() == DialogResult.OK)
                    {
                        //System.IO.FileStream fs = (System.IO.FileStream)saveDialog.OpenFile();
                        //fs.Close();
                        savePath = saveDialog.FileName.ToString();
                        openPath = savePath;
                    }
                    else
                    {
                        return;
                    }
                }

                if (EnsurePrm())
                {
                    //SerializeToXml(savePath, wedge);
                    SystemConfig.WriteBase64Data(savePath, "WEDGE", wedge);
                    SystemConfig.WriteBase64Data(savePath, "POSITION", positions);
                }
            }
        }