Exemplo n.º 1
0
        private void btnImport_ItemClick(object sender, DevExpress.Xpf.Bars.ItemClickEventArgs e)
        {
            try
            {
                System.Windows.Forms.OpenFileDialog OFD = new System.Windows.Forms.OpenFileDialog();
                OFD.Filter = "XML files (*.xml)|*.xml|STA files (*.sta)|*.sta|XLS files (*.xls)|*.xls|XLSX files (*.xlsx)|*.xlsx|All files (*.*)|*.*";
                if (OFD.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    XYTestLimit lstLimitLine = new XYTestLimit();
                    if (OFD.FilterIndex == 3 || OFD.FilterIndex == 4)
                    {
                        lstLimitLine = TestTraceVM.ExcelToTable(OFD.FileName);
                    }
                    else
                    {
                        lstLimitLine = (XYTestLimit)CommUtils.DeserializerData(typeof(XYTestLimit), OFD.FileName);
                    }

                    (this.DataContext as TestTraceVM).TestLimit = lstLimitLine;
                    //MessageBox.Show("导入成功!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Exemplo n.º 2
0
 private void btnExport_ItemClick(object sender, DevExpress.Xpf.Bars.ItemClickEventArgs e)
 {
     try
     {
         System.Windows.Forms.SaveFileDialog SFD = new System.Windows.Forms.SaveFileDialog();
         SFD.Filter = "XML files (*.xml)|*.xml|STA files (*.sta)|*.sta|XLS files (*.xls)|*.xls|XLSX files (*.xlsx)|*.xlsx|All files (*.*)|*.*";
         if (SFD.ShowDialog() == System.Windows.Forms.DialogResult.OK)
         {
             XYTestLimit lstLimitLine = (this.DataContext as TestTraceVM).TestLimit;
             if (SFD.FilterIndex == 3 || SFD.FilterIndex == 4)
             {
                 TestTraceVM.TableToExcel(lstLimitLine, SFD.FileName);
             }
             else
             {
                 CommUtils.SerializeData(lstLimitLine.GetType(), lstLimitLine, SFD.FileName);
             }
             MessageBox.Show("导出成功!");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }