Exemplo n.º 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Control ctrl = (Control)Session["ctrl"];

        PrintHelper.PrintWebControl(ctrl);
    }
Exemplo n.º 2
0
        private void DoAfterCaptureJobs()
        {
            if (Info.TaskSettings.AfterCaptureJob.HasFlag(AfterCaptureTasks.AddImageEffects))
            {
                tempImage = TaskHelpers.AddImageEffects(tempImage, Info.TaskSettings);
            }

            if (Info.TaskSettings.AfterCaptureJob.HasFlag(AfterCaptureTasks.AddWatermark) && Info.TaskSettings.ImageSettings.WatermarkConfig != null)
            {
                Info.TaskSettings.ImageSettings.WatermarkConfig.Apply(tempImage);
            }

            if (Info.TaskSettings.AfterCaptureJob.HasFlag(AfterCaptureTasks.AnnotateImage))
            {
                tempImage = TaskHelpers.AnnotateImage(tempImage, Info.FileName);
            }

            if (Info.TaskSettings.AfterCaptureJob.HasFlag(AfterCaptureTasks.CopyImageToClipboard))
            {
                ClipboardHelpers.CopyImage(tempImage);
                DebugHelper.WriteLine("CopyImageToClipboard");
            }

            if (Info.TaskSettings.AfterCaptureJob.HasFlag(AfterCaptureTasks.SendImageToPrinter))
            {
                if (Program.Settings.DontShowPrintSettingsDialog)
                {
                    using (PrintHelper printHelper = new PrintHelper(tempImage))
                    {
                        printHelper.Settings = Program.Settings.PrintSettings;
                        printHelper.Print();
                    }
                }
                else
                {
                    using (PrintForm printForm = new PrintForm(tempImage, Program.Settings.PrintSettings))
                    {
                        printForm.ShowDialog();
                    }
                }
            }

            if (Info.TaskSettings.AfterCaptureJob.HasFlagAny(AfterCaptureTasks.SaveImageToFile, AfterCaptureTasks.SaveImageToFileWithDialog,
                                                             AfterCaptureTasks.UploadImageToHost))
            {
                using (tempImage)
                {
                    ImageData imageData = TaskHelpers.PrepareImage(tempImage, Info.TaskSettings);
                    Data          = imageData.ImageStream;
                    Info.FileName = Path.ChangeExtension(Info.FileName, imageData.ImageFormat.GetDescription());

                    if (Info.TaskSettings.AfterCaptureJob.HasFlag(AfterCaptureTasks.SaveImageToFile))
                    {
                        string filePath = TaskHelpers.CheckFilePath(Info.TaskSettings.CaptureFolder, Info.FileName, Info.TaskSettings);

                        if (!string.IsNullOrEmpty(filePath))
                        {
                            Info.FilePath = filePath;
                            imageData.Write(Info.FilePath);
                            DebugHelper.WriteLine("SaveImageToFile: " + Info.FilePath);
                        }
                    }

                    if (Info.TaskSettings.AfterCaptureJob.HasFlag(AfterCaptureTasks.SaveImageToFileWithDialog))
                    {
                        using (SaveFileDialog sfd = new SaveFileDialog())
                        {
                            if (string.IsNullOrEmpty(lastSaveAsFolder) || !Directory.Exists(lastSaveAsFolder))
                            {
                                lastSaveAsFolder = Info.TaskSettings.CaptureFolder;
                            }

                            sfd.InitialDirectory = lastSaveAsFolder;
                            sfd.FileName         = Info.FileName;
                            sfd.DefaultExt       = Path.GetExtension(Info.FileName).Substring(1);
                            sfd.Filter           = string.Format("*{0}|*{0}|All files (*.*)|*.*", Path.GetExtension(Info.FileName));
                            sfd.Title            = "Choose a folder to save " + Path.GetFileName(Info.FileName);

                            if (sfd.ShowDialog() == DialogResult.OK && !string.IsNullOrEmpty(sfd.FileName))
                            {
                                Info.FilePath    = sfd.FileName;
                                lastSaveAsFolder = Path.GetDirectoryName(Info.FilePath);
                                imageData.Write(Info.FilePath);
                                DebugHelper.WriteLine("SaveImageToFileWithDialog: " + Info.FilePath);
                            }
                        }
                    }

                    if (Info.TaskSettings.AfterCaptureJob.HasFlag(AfterCaptureTasks.SaveThumbnailImageToFile))
                    {
                        string thumbnailFilename, thumbnailFolder;

                        if (!string.IsNullOrEmpty(Info.FilePath))
                        {
                            thumbnailFilename = Path.GetFileName(Info.FilePath);
                            thumbnailFolder   = Path.GetDirectoryName(Info.FilePath);
                        }
                        else
                        {
                            thumbnailFilename = Info.FileName;
                            thumbnailFolder   = Info.TaskSettings.CaptureFolder;
                        }

                        Info.ThumbnailFilePath = TaskHelpers.CreateThumbnail(tempImage, thumbnailFolder, thumbnailFilename, Info.TaskSettings);

                        if (!string.IsNullOrEmpty(Info.ThumbnailFilePath))
                        {
                            DebugHelper.WriteLine("SaveThumbnailImageToFile: " + Info.ThumbnailFilePath);
                        }
                    }

                    if (Info.TaskSettings.AfterCaptureJob.HasFlag(AfterCaptureTasks.CopyFileToClipboard) && !string.IsNullOrEmpty(Info.FilePath) &&
                        File.Exists(Info.FilePath))
                    {
                        ClipboardHelpers.CopyFile(Info.FilePath);
                    }
                    else if (Info.TaskSettings.AfterCaptureJob.HasFlag(AfterCaptureTasks.CopyFilePathToClipboard) && !string.IsNullOrEmpty(Info.FilePath))
                    {
                        ClipboardHelpers.CopyText(Info.FilePath);
                    }

                    if (Info.TaskSettings.AfterCaptureJob.HasFlag(AfterCaptureTasks.PerformActions) && Info.TaskSettings.ExternalPrograms != null &&
                        !string.IsNullOrEmpty(Info.FilePath) && File.Exists(Info.FilePath))
                    {
                        var actions = Info.TaskSettings.ExternalPrograms.Where(x => x.IsActive);

                        if (actions.Count() > 0)
                        {
                            if (Data != null)
                            {
                                Data.Dispose();
                            }

                            foreach (ExternalProgram fileAction in actions)
                            {
                                fileAction.Run(Info.FilePath);
                            }

                            Data = new FileStream(Info.FilePath, FileMode.Open, FileAccess.Read, FileShare.Read);
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
        private void btIn_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show("Bạn có muốn xuất tạo file báo cáo", "Thông báo", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                var    printer = new PrintHelper();
                string x       = DateTime.Now.Year + "-" + DateTime.Now.Month + "-" + DateTime.Now.Day + "-" + DateTime.Now.Hour + "-" + DateTime.Now.Minute + "-" + DateTime.Now.Second + "";

                string tenfile = x + "ReportSachBan.pdf";
                printer.FileName   = tenfile;
                printer.FolderPath = "D://Report";
                printer.Title      = "Báo cáo Sách bán";
                var startDate = new DateTime(_startYear, _startMonth, 1);
                var endDate   = new DateTime(_endYear, _endMonth, 1);
                endDate.AddMonths(1).AddDays(-1);
                printer.printSachBan(_Sach, startDate, endDate);
                MessageBox.Show("Đã tạo file thành công , Tên file là : " + tenfile);


                //    var redListTextFont = FontFactory.RegisterDirectory(Environment.GetEnvironmentVariable("SystemRoot") + "\\fonts");
                //    var _bold = FontFactory.GetFont("Times New Roman", BaseFont.IDENTITY_H, BaseFont.EMBEDDED, 10f, iTextSharp.text.Font.BOLD, BaseColor.BLACK);
                //    var _bold1 = FontFactory.GetFont("Times New Roman", BaseFont.IDENTITY_H, BaseFont.EMBEDDED, 10f, iTextSharp.text.Font.NORMAL, BaseColor.BLACK);
                //    PdfPTable pdfTable = new PdfPTable(gdvDMSach.ColumnCount);
                //    pdfTable.DefaultCell.Padding = 3;
                //    pdfTable.WidthPercentage = 30;
                //    pdfTable.HorizontalAlignment = Element.ALIGN_CENTER;
                //    pdfTable.DefaultCell.BorderWidth = 1;
                //    pdfTable.TotalWidth = 550f;
                //    pdfTable.LockedWidth = true;
                //    float[] widths = new float[] { 70f, 120f, 120f, 120f, 120f };
                //    pdfTable.SetWidths(widths);


                //    //Adding Header row
                //    foreach (DataGridViewColumn column in gdvDMSach.Columns)
                //    {
                //        PdfPCell cell = new PdfPCell(new Phrase(column.HeaderText, _bold));
                //        cell.BackgroundColor = new iTextSharp.text.BaseColor(240, 240, 240);

                //        pdfTable.AddCell(cell);
                //    }

                //    //Adding DataRow
                //    foreach (DataGridViewRow row in gdvDMSach.Rows)
                //    {
                //        foreach (DataGridViewCell cell in row.Cells)
                //        {
                //            if (!String.IsNullOrEmpty(Convert.ToString(cell.Value)))
                //                pdfTable.AddCell(new Phrase(cell.Value.ToString(), _bold1));
                //        }
                //    }

                //    //Exporting to PDF
                //    string folderPath = @"C:\Users\huy\Desktop\Report\";
                //    string x = DateTime.Now.Year + "-" + DateTime.Now.Month + "-" + DateTime.Now.Day + "-" + DateTime.Now.Hour + "-" + DateTime.Now.Minute + "-" + DateTime.Now.Second + "";

                //    string tenfile = x + "ReportThongKeBanSach.pdf";
                //    if (!Directory.Exists(folderPath))
                //    {
                //        Directory.CreateDirectory(folderPath);
                //    }
                //    using (FileStream stream = new FileStream(folderPath + tenfile, FileMode.Create))
                //    {

                //        Document pdfDoc = new Document(PageSize.A3, 100f, 100f, 100f, 0);
                //        PdfWriter.GetInstance(pdfDoc, stream);
                //        pdfDoc.Open();
                //        var FontColour = new BaseColor(255, 0, 0);
                //        var _bold2 = FontFactory.GetFont("Times New Roman", BaseFont.IDENTITY_H, BaseFont.EMBEDDED, 20f, iTextSharp.text.Font.NORMAL, BaseColor.BLUE);
                //        Paragraph docTitle = new Paragraph("Thống kê bán sách " +"\n", _bold2);
                //        Paragraph docTitle1 = new Paragraph("Từ tháng  : " + cmbStartMonth.Text + " Năm  " + cmbStartYear.Text + "\n", _bold2);
                //        Paragraph docTitle2 = new Paragraph("đến tháng : " + cmbEndMonth.Text + " Năm  " + cmbEndYear.Text + "\n", _bold2);
                //        Paragraph docTitle3 = new Paragraph("Số lượng  : " +lbSachBanDuoc.Text+ "\n", _bold2);
                //        Paragraph docTitle4 = new Paragraph("Tổng tiền : " + lbTongTien.Text+ "\n", _bold2);
                //        docTitle.Alignment = Element.ALIGN_CENTER;
                //        docTitle1.Alignment = Element.ALIGN_LEFT;
                //        docTitle2.Alignment = Element.ALIGN_LEFT;
                //        docTitle3.Alignment = Element.ALIGN_LEFT;
                //        docTitle4.Alignment = Element.ALIGN_LEFT;

                //        pdfDoc.Add(docTitle);
                //        pdfDoc.Add(docTitle1);
                //        pdfDoc.Add(docTitle2);
                //        pdfDoc.Add(docTitle3);
                //        pdfDoc.Add(docTitle4);
                //        pdfDoc.Add(new Paragraph("\n"));
                //        pdfDoc.Add(new Paragraph("\n"));
                //        pdfDoc.Add(pdfTable);
                //        pdfDoc.Close();
                //        stream.Close();

                //        MessageBox.Show("Đã tạo file thành công , Tên file là : " + tenfile);
            }
            else if (dialogResult == DialogResult.No)
            {
                return;
            }
        }
Exemplo n.º 4
0
 public void Run()
 {
     _other();
     PrintHelper.PrintCaseSubStep(output.ToString());
 }
Exemplo n.º 5
0
 static void ThreadActionWithParameter(object obj)
 {
     PrintHelper.PrintCaseStep($"Starting by parametrized Delegate: {obj}");
 }
Exemplo n.º 6
0
        private async void SaveButton_OnClick(object sender, RoutedEventArgs e)
        {
            using (var db = new ProjectContext())
            {
                //Add
                if (flag == 0)
                {
                    var newTecnico = new Tecnicos
                    {
                        Nombre          = NombreTextBox.Text,
                        Apellido        = ApellidoTextBox.Text,
                        Dni             = DniTextBox.Text,
                        Direccion       = DireccionTextBox.Text,
                        FechaNacimiento = FechaNacimientoDatePicker.Date.LocalDateTime,
                        Email           = EmailTextBox.Text,
                        Telefono        = Int32.Parse(TelefonoTextBox.Text),
                    };
                    string apocope1 = newTecnico.Nombre;
                    string apocope2 = newTecnico.Apellido;
                    newTecnico.Apocope = apocope1.Substring(0, 1).ToUpper() + apocope2.Substring(0, 1).ToUpper();
                    db.Tecnicos.Add(newTecnico);
                    await db.SaveChangesAsync();

                    TecnicosList = await db.Tecnicos.OrderBy(x => x.Nombre).ToListAsync();

                    cvs.Source = GetGroupsByLetter();

                    InputModalDialog.IsModal    = false;
                    MasterListView.SelectedItem = newTecnico;
                    MasterListView.ScrollIntoView(newTecnico);
                }
                //Edit
                else if (flag == 1)
                {
                    var itemSelected = (Tecnicos)MasterListView.SelectedItem;

                    if (MasterListView.SelectedItem != null)
                    {
                        itemSelected.Nombre          = NombreTextBox.Text;
                        itemSelected.Apellido        = ApellidoTextBox.Text;
                        itemSelected.Dni             = DniTextBox.Text;
                        itemSelected.Direccion       = DireccionTextBox.Text;
                        itemSelected.FechaNacimiento = FechaNacimientoDatePicker.Date.LocalDateTime;
                        itemSelected.Email           = EmailTextBox.Text;
                        itemSelected.Telefono        = Int32.Parse(TelefonoTextBox.Text);

                        string apocope1 = itemSelected.Nombre;
                        string apocope2 = itemSelected.Apellido;

                        itemSelected.Apocope = apocope1.Substring(0, 1).ToUpper() + apocope2.Substring(0, 1).ToUpper();

                        db.Tecnicos.Update(itemSelected);

                        await db.SaveChangesAsync();

                        TecnicosList = await db.Tecnicos.OrderBy(x => x.Nombre).ToListAsync();

                        cvs.Source = GetGroupsByLetter();

                        InputModalDialog.IsModal    = false;
                        MasterListView.SelectedItem = itemSelected;
                        MasterListView.ScrollIntoView(itemSelected);
                    }
                }
                var query = db.Tecnicos.Count();
                if (query <= 0)
                {
                    EmptyItemsBorder.Visibility  = Visibility.Visible;
                    EmptyItemsBorder2.Visibility = Visibility.Visible;
                }
                else
                {
                    EmptyItemsBorder.Visibility = Visibility.Collapsed;
                }
            }
            if (printHelper != null)
            {
                printHelper.UnregisterForPrinting();
                // Initalize common helper class and register for printing
                printHelper = new PrintHelper(this);
                printHelper.RegisterForPrinting();

                // Initialize print content for this scenario
                printHelper.PreparePrintContent(new TecnicosReport());
            }

            //Enable
            MasterListView.IsEnabled       = true;
            ListViewCommandBar.IsEnabled   = true;
            SearchAutoSuggestBox.IsEnabled = true;
        }
Exemplo n.º 7
0
 public override void DoDish()
 {
     PrintHelper.PrintWrite("取荷叶", DishContext.PrintColor);
     PrintHelper.PrintWrite("大火闷1小时", DishContext.PrintColor);
 }
Exemplo n.º 8
0
        public void Nested_casing_issues_take_multiple_passes_to_correct()
        {
            var bicepFile = @"
resource resA 'My.Rp/resA@2020-01-01' = {
  name: 'resA'
  properties: {
    lowerCaseObj: {
      lowerCaseStr: 'test'
    }
  }
}

output myObj object = {
  lowerCaseProp: resA.properties.lowerCaseObj.lowerCaseStr
}
";

            var typeDefinition = TestTypeHelper.CreateCustomResourceType("My.Rp/resA", "2020-01-01", TypeSymbolValidationFlags.WarnOnTypeMismatch,
                                                                         new TypeProperty("lowercaseobj", new ObjectType("lowercaseobj", TypeSymbolValidationFlags.Default, new [] {
                new TypeProperty("lowercasestr", LanguageConstants.String)
            }, null)));
            var typeLoader = TestTypeHelper.CreateAzResourceTypeLoaderWithTypes(typeDefinition.AsEnumerable());

            var(_, _, compilation) = CompilationHelper.Compile(typeLoader, ("main.bicep", bicepFile));
            var rewriter = new TypeCasingFixerRewriter(compilation.GetEntrypointSemanticModel());

            var newProgramSyntax   = rewriter.Rewrite(compilation.SourceFileGrouping.EntryPoint.ProgramSyntax);
            var firstPassBicepFile = PrintHelper.PrintAndCheckForParseErrors(newProgramSyntax);

            firstPassBicepFile.Should().Be(
                @"resource resA 'My.Rp/resA@2020-01-01' = {
  name: 'resA'
  properties: {
    lowercaseobj: {
      lowerCaseStr: 'test'
    }
  }
}

output myObj object = {
  lowerCaseProp: resA.properties.lowercaseobj.lowerCaseStr
}");

            (_, _, compilation) = CompilationHelper.Compile(typeLoader, ("main.bicep", firstPassBicepFile));
            rewriter            = new TypeCasingFixerRewriter(compilation.GetEntrypointSemanticModel());

            newProgramSyntax = rewriter.Rewrite(compilation.SourceFileGrouping.EntryPoint.ProgramSyntax);
            PrintHelper.PrintAndCheckForParseErrors(newProgramSyntax).Should().Be(
                @"resource resA 'My.Rp/resA@2020-01-01' = {
  name: 'resA'
  properties: {
    lowercaseobj: {
      lowercasestr: 'test'
    }
  }
}

output myObj object = {
  lowerCaseProp: resA.properties.lowercaseobj.lowercasestr
}");
        }
Exemplo n.º 9
0
        /// <summary>
        /// Launches print control window for the specified data. (Real printer method)
        /// </summary>
        /// <param name="printJob"></param>
        public void LaunchPrintControl(PrintJobData printJob)
        {
            // check the print job data
            if (printJob == null || printJob.PrintJobTitle == null)
            {
                return;
            }

            LogHelper.LogDebug("Launch For Real Printer " + printJob.PrintJobTitle);

            try
            {
                _dispatcher.BeginInvoke(new Action(() =>
                {
                    // Update print job logic:
                    // if the window already created but we received additional data (like number of pages) then find that window and update it's data

                    // iterate through the list of windows
                    foreach (var f in listOfWindows)
                    {
                        LogHelper.LogDebug("Seek Window");

                        // get the data context of the window - has to be a PrintingControlViewModel
                        var dc = f.DataContext as PrintingControlViewModel;

                        // check the data context
                        if (dc != null)
                        {
                            // compare print job titles
                            if (dc.PrintJobTitle.Equals(printJob.PrintJobTitle))
                            {
                                LogHelper.LogDebug("Window found");
                                // update data
                                f.UpdateData(printJob);
                                return;
                            }
                        }
                    }

                    // if the job ain't present for some reason at this moment then leave
                    if (!PrintHelper.HasPrintJob(printJob.ServerHost, printJob.PrintJobTitle))
                    {
                        return;
                    }

                    // show preparing progress
                    MainController.Singleton.ShowProgressWindow("Preparing", "Your document is being prepared for printing, please wait...");

                    // set up an launch UI for the incoming data-+
                    PrintingControlWindow window = new PrintingControlWindow(printJob);
                    window.Closed += WindowClosed;

                    // add window to a list
                    listOfWindows.Add(window);

                    // show UI
                    window.Show();
                }), DispatcherPriority.Background);
            }
            catch (Exception ex)
            {
                WPFNotifier.Error(ex);
            }
        }
Exemplo n.º 10
0
        private async void SaveButton_OnClick(object sender, RoutedEventArgs e)
        {
            try
            {
                using (var db = new ProjectContext())
                {
                    //Save
                    if (flag == 0)
                    {
                        var invetario = new Inventario
                        {
                            Balance      = Convert.ToInt32(BalanceTextBox.Text),
                            AlmacenesId  = (int)AlmacenComboBox.SelectedValue,
                            LocacionesId = (int)LocacionComboBox.SelectedValue,
                            PartNumberId = await
                                           db.PartNumbers
                                           .Where(x => x.PartNumber == PartNumberAutoSuggestBox.Text)
                                           .Select(x => x.Id)
                                           .SingleOrDefaultAsync(),
                        };

                        var query = db.Inventario
                                    .Include(x => x.Almacenes)
                                    .Include(x => x.Locaciones)
                                    .Include(x => x.PartNumbers)
                                    .Count(x => x.AlmacenesId == invetario.AlmacenesId &&
                                           x.LocacionesId == invetario.LocacionesId &&
                                           x.PartNumberId == invetario.PartNumberId);

                        if (query >= 1)
                        {
                            var message = new MessageDialog("Ya existe el item que usted desea crear", "Advertencia");

                            await message.ShowAsync();

                            SaveButton.IsEnabled = false;
                        }
                        else
                        {
                            db.Inventario.Add(invetario);

                            await db.SaveChangesAsync();

                            cvs.Source = await db.Inventario
                                         .Include(x => x.Almacenes)
                                         .Include(x => x.Locaciones)
                                         .Include(x => x.PartNumbers)
                                         .OrderBy(x => x.Locaciones.Descripcion)
                                         .GroupBy(x => x.Almacenes.Descripcion)
                                         .ToListAsync();

                            InputModalDialog.IsModal = false;

                            MasterListView.SelectedItem = invetario;
                            MasterListView.ScrollIntoView(invetario);
                        }
                    }
                    //Edit
                    else if (flag == 1)
                    {
                        var itemSelected = (Inventario)MasterListView.SelectedItem;

                        if (MasterListView.SelectedItem != null)
                        {
                            itemSelected.PartNumberId =
                                await
                                db.PartNumbers.Where(x => x.PartNumber == PartNumberAutoSuggestBox.Text)
                                .Select(x => x.Id)
                                .SingleOrDefaultAsync();

                            itemSelected.AlmacenesId  = (int)AlmacenComboBox.SelectedValue;
                            itemSelected.LocacionesId = (int)LocacionComboBox.SelectedValue;
                            itemSelected.Balance      = Convert.ToInt32(BalanceTextBox.Text);
                            {
                                db.Inventario.Update(itemSelected);
                                await db.SaveChangesAsync();

                                cvs.Source = await db.Inventario
                                             .Include(x => x.Almacenes)
                                             .Include(x => x.Locaciones)
                                             .Include(x => x.PartNumbers)
                                             .OrderBy(x => x.Locaciones.Descripcion)
                                             .GroupBy(x => x.Almacenes.Descripcion)
                                             .ToListAsync();

                                InputModalDialog.IsModal = false;

                                MasterListView.SelectedItem = itemSelected;
                                MasterListView.ScrollIntoView(itemSelected);
                            }
                        }
                    }
                    var query1 = db.Inventario.Count();
                    if (query1 <= 0)
                    {
                        EmptyItemsBorder.Visibility = Visibility.Visible;
                    }
                    else
                    {
                        EmptyItemsBorder.Visibility = Visibility.Collapsed;
                    }
                }
            }
            catch (Exception ex)
            {
                var message = new MessageDialog(ex.Message);
                await message.ShowAsync();
            }
            //Repopulate Print Helper
            if (printHelper != null)
            {
                printHelper.UnregisterForPrinting();
                // Initalize common helper class and register for printing
                printHelper = new PrintHelper(this);
                printHelper.RegisterForPrinting();

                // Initialize print content for this scenario
                printHelper.PreparePrintContent(new InventarioReport());
            }

            //Enable
            MasterListView.IsEnabled       = true;
            ListViewCommandBar.IsEnabled   = true;
            SearchAutoSuggestBox.IsEnabled = true;
        }
Exemplo n.º 11
0
        private async void DeleteButton_OnClick(object sender, RoutedEventArgs e)
        {
            using (var db = new ProjectContext())
            {
                var itemToDelete = (Inventario)MasterListView.SelectedItem;
                if (MasterListView.SelectedItem != null)
                {
                    //MessageDialog
                    var dialog = new MessageDialog("¿Desea eliminar el item seleccionado?", "Advertencia");
                    dialog.Commands.Add(new UICommand("Si")
                    {
                        Id = 0
                    });
                    dialog.Commands.Add(new UICommand("No")
                    {
                        Id = 1
                    });

                    var result = await dialog.ShowAsync();

                    if (result != null && result.Label == "Si")
                    {
                        db.Inventario.Remove(itemToDelete);
                        await db.SaveChangesAsync();

                        cvs.Source = await db.Inventario
                                     .Include(x => x.Almacenes)
                                     .Include(x => x.Locaciones)
                                     .Include(x => x.PartNumbers)
                                     .OrderBy(x => x.Locaciones.Descripcion)
                                     .GroupBy(x => x.Almacenes.Descripcion)
                                     .ToListAsync();

                        MasterListView.SelectedItem = await db.Inventario
                                                      .Include(x => x.Almacenes)
                                                      .Include(x => x.Locaciones)
                                                      .Include(x => x.PartNumbers)
                                                      .OrderBy(x => x.Locaciones.Descripcion)
                                                      .GroupBy(x => x.Almacenes.Descripcion)
                                                      .FirstOrDefaultAsync();
                    }
                }
                var query = db.Inventario.Count();
                if (query <= 0)
                {
                    EmptyItemsBorder.Visibility = Visibility.Visible;
                }
                else
                {
                    EmptyItemsBorder.Visibility = Visibility.Collapsed;
                }
            }
            //Repopulate Print Helper
            if (printHelper != null)
            {
                printHelper.UnregisterForPrinting();
                // Initalize common helper class and register for printing
                printHelper = new PrintHelper(this);
                printHelper.RegisterForPrinting();

                // Initialize print content for this scenario
                printHelper.PreparePrintContent(new InventarioReport());
            }
        }
Exemplo n.º 12
0
        private void toolView_Click(object sender, EventArgs e)
        {
            IEnumerator enumControl         = _componentContainer.GetEnumerator();
            DataView    dt                  = null;
            Dictionary <string, string> dic = new Dictionary <string, string>();
            SnDataSet   temp                = _solution.DataSetList[0] as SnDataSet;
            GridControl grd                 = null;

            while (enumControl.MoveNext())
            {
                ICommonAttribute commonAttribute = enumControl.Current as ICommonAttribute;
                if (commonAttribute != null)
                {
                    if (temp.DataSetName == commonAttribute.DataSetName)
                    {
                        dic.Add(commonAttribute.ParamName, commonAttribute.Value);
                    }
                }
            }
            var       enumGridControl = _componentContainer.GetEnumerator();
            Hashtable htControls      = new Hashtable();

            while (enumGridControl.MoveNext())
            {
                GridControl grid = enumGridControl.Current as GridControl;
                if (grid != null)
                {
                    List <string> filter = new List <string>();
                    DevExpress.XtraGrid.Views.Grid.GridView view = grid.Views[0] as DevExpress.XtraGrid.Views.Grid.GridView;

                    foreach (GridColumn gcc in view.SortedColumns)
                    {
                        filter.Add(gcc.FieldName + " " + (gcc.SortOrder == ColumnSortOrder.Descending ? "DESC" : ""));
                    }
                    DataView dv = grid.DataSource as DataView;
                    if (dv != null)
                    {
                        dv.Sort = string.Join(",", filter.ToArray());
                        dt      = dv;
                    }
                    grd = grid;
                    //break;
                }
                if (!enumGridControl.Current.GetType().Equals(typeof(Column)))
                {
                    Control ctl = (Control)enumGridControl.Current;
                    htControls.Add(ctl.Name, ctl.Text);
                }
            }
            if (dt == null)
            {
                MessageBox.Show("数据源没有数据");
            }
            else
            {
                if (string.IsNullOrEmpty(temp.ReportPath))
                {
                    if (grd != null)
                    {
                        if (PrintHelper.IsPrintingAvailable)
                        {
                            PrintHelper.ShowPreview(grd);
                        }
                        else
                        {
                            MessageBox.Show("打印组件库没有发现!", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                }
                else
                {
                    Print(htControls, dic, dt, temp.ReportPath, false);
                }
            }
        }
Exemplo n.º 13
0
 private void CutFood()
 {
     PrintHelper.PrintWrite("切菜", DishContext.PrintColor);
 }
Exemplo n.º 14
0
        private ExporterCollection ConvertDataRow(ISimpleContainer simpleContainer)
        {
            ExporterCollection exporterCollection = new ExporterCollection();

            base.CurrentPosition = new Point(base.SectionBounds.DetailStart.X, base.SectionBounds.DetailStart.Y);
            BaseSection section = parent as BaseSection;

            DefaultLeftPosition = parent.Location.X;
            Size groupSize = Size.Empty;
            Size childSize = Size.Empty;

            if (section.Items.IsGrouped)
            {
                groupSize = section.Items[0].Size;
                childSize = section.Items[1].Size;
            }


            do
            {
                base.SaveSectionSize(section.Size);
                PrintHelper.AdjustSectionLocation(section);
                section.Size = this.SectionBounds.DetailSectionRectangle.Size;

                // did we have GroupedItems at all
                if (section.Items.IsGrouped)
                {
                    // GetType child navigator
                    IDataNavigator childNavigator = base.DataNavigator.GetChildNavigator();

                    base.Evaluator.SinglePage.IDataNavigator = childNavigator;

                    base.CurrentPosition = ConvertGroupHeader(exporterCollection, section, base.CurrentPosition);

                    section.Size          = base.RestoreSectionSize;
                    section.Items[0].Size = groupSize;
                    section.Items[1].Size = childSize;

                    childNavigator.Reset();
                    childNavigator.MoveNext();

                    //Convert children
                    if (childNavigator != null)
                    {
                        StandardPrinter.AdjustBackColor(simpleContainer, GlobalValues.DefaultBackColor);
                        do
                        {
                            section.Size          = base.RestoreSectionSize;
                            section.Items[0].Size = groupSize;
                            section.Items[1].Size = childSize;

                            FillRow(simpleContainer, childNavigator);
                            FireRowRendering(simpleContainer, childNavigator);
                            PrepareContainerForConverting(section, simpleContainer);

//							FireRowRendering(simpleContainer,childNavigator);
                            base.CurrentPosition = ConvertStandardRow(exporterCollection, simpleContainer);
                            CheckForPageBreak(section, exporterCollection);
                        }while (childNavigator.MoveNext());

                        // GroupFooter
                        base.ConvertGroupFooter(section, exporterCollection);

                        base.PageBreakAfterGroupChange(section, exporterCollection);

                        base.Evaluator.SinglePage.IDataNavigator = base.DataNavigator;
                    }
                }
                else
                {
                    // No Grouping at all, the first item in section.items is the DetailRow

                    Size containerSize = section.Items[0].Size;
                    FillRow(simpleContainer, base.DataNavigator);
                    FireRowRendering(simpleContainer, base.DataNavigator);
                    base.PrepareContainerForConverting(section, simpleContainer);
//					FireRowRendering(simpleContainer,base.DataNavigator);
                    base.CurrentPosition  = ConvertStandardRow(exporterCollection, simpleContainer);
                    section.Size          = base.RestoreSectionSize;
                    section.Items[0].Size = containerSize;
                }
                CheckForPageBreak(section, exporterCollection);
                ShouldDrawBorder(section, exporterCollection);
            }while (base.DataNavigator.MoveNext());

            SectionBounds.ReportFooterRectangle = new Rectangle(SectionBounds.ReportFooterRectangle.Left,
                                                                section.Location.Y + section.Size.Height,
                                                                SectionBounds.ReportFooterRectangle.Width,
                                                                SectionBounds.ReportFooterRectangle.Height);

            return(exporterCollection);
        }
Exemplo n.º 15
0
 public void PrintSelectedWarehouseOut()
 {
     var toPrints = Entities.Cast<WarehouseOut>().Where(o => o.IsSelected);
     foreach (var wo in toPrints)
     {
         var reportVM = new PrintInOutTemplateVM(wo.Id, "打印出库单");
         var dataSources = new Dictionary<string, object> { { "Header", reportVM.Header }, { "Lines", reportVM.Lines } };
         var printHelper = new PrintHelper(dataSources, "PrintTemplate\\内贸出库单\\上海长然出入库单.rdlc", null, true);
         printHelper.Run();
     }
 }
Exemplo n.º 16
0
        private void InitCommand()
        {
            PrintConfigurationSaveBaseCommand = new DelegateCommand((obj) =>
            {
                string msg = PrintHelper.VerifyPrintConfiguration(PrintConfiguration);
                if (string.IsNullOrEmpty(msg))
                {
                    int id = CommonService.SaveBarTenderPrintConfigXX(PrintConfiguration);
                    if (id > 0)
                    {
                        PrintConfiguration.Id = id;
                        MessageBox.Show("保存成功");
                    }

                    else
                    {
                        MessageBox.Show("保存失败,请联系管理员");
                    }
                }
                else
                {
                    MessageBox.Show(msg);
                }
            });

            TemplateSelectBaseCommand = new DelegateCommand((obj) =>
            {
                System.Windows.Forms.FolderBrowserDialog fbd = new System.Windows.Forms.FolderBrowserDialog();
                if (fbd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    PirntTemplates = PrintHelper.GetTenderPrintA4Templates(fbd.SelectedPath);
                }
            });

            DirectorySelectBaseCommand = new DelegateCommand((obj) =>
            {
                // 导出目录选择
                System.Windows.Forms.FolderBrowserDialog fbd = new System.Windows.Forms.FolderBrowserDialog();

                if (fbd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    HostConfig.HostValue = fbd.SelectedPath;
                    var result           = CommonService.SaveHostConfig(HostConfig);
                    if (result)
                    {
                        HostConfig = CommonService.GetHostConfig(DataGridId, HostName, User.ID);
                    }
                }
            });

            ExportBaseCommand = new DelegateCommand((obj) =>
            {
                if (Directory.Exists(HostConfig.HostValue))
                {
                    ExportView view = new ExportView(DataGridId, 1);
                    (view.DataContext as ExportViewModel).Export((type, outputEntity, checkBoxValue, orderedColumns) =>
                    {
                        view.Close();
                        if (type == 1)
                        {
                            DataTable datatable = new DataTable();
                            if (outputEntity == 1)
                            {
                                datatable = _service.GetExportData1("DGPrintA4", User.ID, CommonService.GetSqlWhereString(QueryParameter));
                                ExportHelper.ExportDataTableToExcel(datatable, HostConfig.HostValue, HostConfig.TypeDesciption + CommonService.GetQueryParameterValueString(QueryParameter));
                                MessageBox.Show("导出成功");
                            }
                            //else if (outputEntity == 2)
                            //{
                            //	datatable = _shippingService.GetShippingBillExprotDataTable2(UserDataId);
                            //	new Helper.DataTableImportExportHelper().ExportDataTableToExcel(datatable, HostConfig.HostValue, HostConfig.TypeDesciption);
                            //	MessageBox.Show("导出成功");
                            //}
                            //else if (outputEntity == 3)
                            //{
                            //	datatable = _shippingService.GetShippingBillExprotDataTable3(UserDataId, string.Join(",", orderedColumns));
                            //	new Helper.DataTableImportExportHelper().ExportDataTableToExcel(datatable, HostConfig.HostValue, HostConfig.TypeDesciption, checkBoxValue, 1, orderedColumns);
                            //	MessageBox.Show("导出成功");
                            //}
                        }
                    });
                    view.ShowDialog();
                }
                else
                {
                    MessageBox.Show("目录不存在,请先选择导出的目录");
                    DirectorySelectBaseCommand.Execute(null);
                }
                CommonService.WriteActionLog(new ActionOperationLogModel {
                    ActionName = "ExportBaseCommand", ActionDesc = HostConfig.TypeDesciption + HostConfig.TypeId.ToString(), UserId = User.ID, MainMenuId = Menu.ID, PKId = -1, HostName = HostName
                });
            });

            DataGridSaveCommand = new DelegateCommand((obj) =>
            {
                DataGridManagementService.SaveColumnConfigurationInUserInterface(obj as DataGrid, User.ID);
                MessageBox.Show("参数保存成功");
            });

            PrintBaseCommand = new DelegateCommand((obj) =>
            {
                string msg = PrintHelper.VerifyPrintConfiguration(PrintConfiguration);
                if (string.IsNullOrEmpty(msg))
                {
                    var selectedLists = ((obj as DataGrid).SelectedItems).Cast <LabelPrintHistoryModel>().ToList();
                    if (selectedLists.Count > 0)
                    {
                        string result = _print.BarTenderPrintA4(selectedLists, PrintConfiguration, selectedLists.Sum(x => x.PrintCount));
                        MessageBox.Show(result);
                        QueryCommand.Execute(null);
                    }
                    else
                    {
                        MessageBox.Show("先选择行数据,【CTRL】或【SHFIT】 多选行");
                    }
                }
                else
                {
                    MessageBox.Show(msg);
                }
            });

            QueryCommand = new DelegateCommand((obj) =>
            {
                PrintHistoryLists.Clear();
                _service.GetHistoryLists(CommonService.GetSqlWhereString(QueryParameter)).ForEach(x => PrintHistoryLists.Add(x));
            });

            DataGridManageCommand = new DelegateCommand((obj) =>
            {
                var grid = obj as DataGrid;
                UserDataGridFormatConfigurationView view = new UserDataGridFormatConfigurationView("DGPrintA4");
                (view.DataContext as UserDataGridFormatConfigurationViewModel).WithParam(null, (type, outputEntity) =>
                {
                    view.Close();
                    if (type == 1)
                    {
                        // 重新加载DataGrid格式
                        grid.Columns.Clear();
                        CommonService.GetUserDataGridColumn(User.ID, grid, 0);
                    }
                });
                view.ShowDialog();
            });
        }
Exemplo n.º 17
0
        private void contextMenuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            frnReport wFrom = new frnReport();
            if (e.ClickedItem.Text == "属性")
            {
                elementProperty();
            }
            tlVectorControl1.Operation = ToolOperation.Select;
            if (e.ClickedItem.Text == "短路计算")
            {

                wFrom.Owner = this;
                wFrom.Show();
                wFrom.Text = this.Text + "短路计算";
                wFrom.ShowText += "正在收集信息\t" + System.DateTime.Now.ToString();
                if (!addcheck(wFrom))
                {

                    return;
                }
                string duanluname = null;        //记录短路点的名字 如果是发生在支路上短路点的名字为线路连接的第一个母线名
                int tuxing = 0;
                int baobiao = 0;
                PSPDEV pspDuanlu = new PSPDEV();
                XmlElement element = tlVectorControl1.SVGDocument.CurrentElement;
                pspDuanlu.SUID = element.GetAttribute("Deviceid");
                pspDuanlu = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByKey", pspDuanlu);
                if (pspDuanlu == null)
                    return;
                if (pspDuanlu.Type != "05" && pspDuanlu.Type != "01")
                    return;
                frmDuanlu dudu = new frmDuanlu(pspDuanlu);
                dudu.projectsuid = tlVectorControl1.SVGDocument.SvgdataUid;
                ElectricShorti lec = new ElectricShorti();
                int n11 = 0, n2 = 0, n3 = 0;
                double n4 = 0;

                if (dudu.ShowDialog() == DialogResult.OK)
                {
                    //int bigsmall=Convert.ToInt32(dudu.DuanluBigsmall);
                    try
                    {
                        if (!lec.CheckDL(tlVectorControl1.SVGDocument.SvgdataUid, this.ProjectUID, 100))
                            return;
                        string nodeType;
                        if (dudu.DuanluBaobiao == "是")
                            baobiao = 1;
                        if (dudu.DuanluTuxing == "图形输出节点电压")
                            tuxing = 1;
                        if (dudu.DuanluTuxing == "图形输出短路电流")
                            tuxing = 2;
                        //Duanlu.Name = dudu.DuanluPoint;
                        //Duanlu = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByName", Duanlu);
                        n4 = (double)Convert.ToInt32(dudu.hscool) / 100;
                        nodeType = pspDuanlu.Type;
                        if (pspDuanlu.Type == "01")
                        {
                            n11 = 0;
                            n2 = pspDuanlu.Number;
                            switch (dudu.DuanluType)
                            {
                                case "单相接地":
                                    n3 = 1;
                                    break;

                                case "两相接地":
                                    n3 = 3;
                                    break;
                                case "两相故障":
                                    n3 = 2;
                                    break;
                                case "三相故障":
                                    n3 = 0;
                                    break;
                                default:
                                    n3 = 1;
                                    break;
                            }

                            string con = " ,PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + tlVectorControl1.SVGDocument.SvgdataUid+ "'AND PSPDEV.type='05'AND PSPDEV.KSwitchStatus = '0'order by PSPDEV.number";
                            PSPDEV psp = new PSPDEV();
                            IList list2 = Services.BaseService.GetList("SelectPSPDEVByCondition", con); ;
                            string dlr = null;
                            bool flag = false;             //记录读的是一般线路还是两绕组变压器上的母线还是三绕组上面的

                            string projectid = this.ProjectUID;
                            for (int i = 0; i < list2.Count; i++)
                            {
                                psp = list2[i] as PSPDEV;
                                con = " WHERE Name='" + psp.ISwitch + "' AND ProjectID = '" + projectid + "'" + "AND Type='07'";
                                IList listiswitch = Services.BaseService.GetList("SelectPSPDEVByCondition", con);
                                con = " WHERE Name='" + psp.JSwitch + "' AND ProjectID = '" + projectid + "'" + "AND Type='07'";
                                IList listjswitch = Services.BaseService.GetList("SelectPSPDEVByCondition", con);
                                PSPDEV pspiswitch = (PSPDEV)listiswitch[0];
                                PSPDEV pspjswitch = (PSPDEV)listjswitch[0];

                                if (pspDuanlu.Number == psp.FirstNode && pspiswitch.KSwitchStatus == "0" && pspjswitch.KSwitchStatus == "0")
                                {

                                    flag = true;
                                    dlr = "0" + " " + psp.FirstNode + " " + psp.LastNode + " " + psp.Number + " " + "0 " + " " + n3.ToString();

                                }
                                if (pspDuanlu.Number == psp.LastNode && pspiswitch.KSwitchStatus == "0" && pspjswitch.KSwitchStatus == "0")
                                {
                                    flag = true;
                                    dlr = "0" + " " + psp.FirstNode + " " + psp.LastNode + " " + psp.Number + " " + "1 " + " " + n3.ToString();
                                }
                                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\fault.txt"))
                                {
                                    File.Delete(System.Windows.Forms.Application.StartupPath + "\\fault.txt");
                                }
                                if (flag)
                                {

                                    break;                 //跳出本循环 进行母线的另外一个母线短路

                                }
                                if (!flag)
                                    continue;
                                //写入错误中

                            }
                            if (!flag)
                            {
                                  con = " ,PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + tlVectorControl1.SVGDocument.SvgdataUid + "'AND PSPDEV.type='02'AND PSPDEV.KSwitchStatus = '0' order by PSPDEV.number";
                                IList list3 = Services.BaseService.GetList("SelectPSPDEVByCondition", con);
                                for (int i = 0; i < list3.Count; i++)
                                {
                                    dlr = null;
                                    psp = list3[i] as PSPDEV;
                                    PSPDEV devFirst = new PSPDEV();

                                    con = " WHERE Name='" + psp.IName + "' AND ProjectID = '" + projectid + "'" + "AND Type='01'";
                                    devFirst = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", con);
                                    PSPDEV devLast = new PSPDEV();

                                    con = " WHERE Name='" + psp.JName + "' AND ProjectID = '" + projectid + "'" + "AND Type='01'";
                                    devLast = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", con);
                                    con = " WHERE Name='" + psp.ISwitch + "' AND ProjectID = '" + projectid + "'" + "AND Type='07'";
                                    IList listiswitch = Services.BaseService.GetList("SelectPSPDEVByCondition", con);
                                    con = " WHERE Name='" + psp.JSwitch + "' AND ProjectID = '" + projectid + "'" + "AND Type='07'";
                                    IList listjswitch = Services.BaseService.GetList("SelectPSPDEVByCondition", con);
                                    PSPDEV pspiswitch = (PSPDEV)listiswitch[0];
                                    PSPDEV pspjswitch = (PSPDEV)listjswitch[0];
                                    if (pspDuanlu.Number == devFirst.Number && pspiswitch.KSwitchStatus == "0" && pspjswitch.KSwitchStatus == "0")
                                    {

                                        flag = true;
                                        dlr = "0" + " " + devFirst.Number + " " + devLast.Number + " " + psp.Number + " " + "0" + " " + n3.ToString();

                                    }
                                    if (pspDuanlu.Number == devLast.Number && pspiswitch.KSwitchStatus == "0" && pspjswitch.KSwitchStatus == "0")
                                    {
                                        flag = true;
                                        dlr = "0" + " " + devFirst.Number + " " + devLast.Number + " " + psp.Number + " " + "1" + " " + n3.ToString();
                                    }
                                    if (flag)
                                    {
                                        break;                 //跳出本循环 进行母线的另外一个母线短路

                                    }
                                    if (!flag)
                                        continue;
                                    //写入错误中

                                }
                            }
                            if (!flag)
                            {
                                con = " ,PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + tlVectorControl1.SVGDocument.SvgdataUid + "'AND PSPDEV.type='03'AND PSPDEV.KSwitchStatus = '0' order by PSPDEV.number";
                                IList list4 = Services.BaseService.GetList("SelectPSPDEVByCondition", con);
                                for (int i = 0; i < list4.Count; i++)
                                {
                                    dlr = null;
                                    psp = list4[i] as PSPDEV;
                                    PSPDEV devINode = new PSPDEV();

                                    con = " WHERE Name='" + psp.IName + "' AND ProjectID = '" + projectid + "'" + "AND Type='01'";
                                    devINode = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", con);
                                    PSPDEV devJNode = new PSPDEV();

                                    con = " WHERE Name='" + psp.JName + "' AND ProjectID = '" + projectid + "'" + "AND Type='01'";
                                    devJNode = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", con);
                                    PSPDEV devKNode = new PSPDEV();

                                    con = " WHERE Name='" + psp.KName + "' AND ProjectID = '" + projectid + "'" + "AND Type='01'";
                                    devKNode = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", con);

                                    con = " WHERE Name='" + psp.ISwitch + "' AND ProjectID = '" + projectid + "'" + "AND Type='07'";
                                    IList listiswitch = Services.BaseService.GetList("SelectPSPDEVByCondition", con);
                                    con = " WHERE Name='" + psp.JSwitch + "' AND ProjectID = '" + projectid + "'" + "AND Type='07'";
                                    IList listjswitch = Services.BaseService.GetList("SelectPSPDEVByCondition", con);
                                    con = " WHERE Name='" + psp.HuganLine1 + "' AND ProjectID = '" + projectid + "'" + "AND Type='07'";
                                    IList listkswitch = Services.BaseService.GetList("SelectPSPDEVByCondition", con);
                                    PSPDEV pspiswitch = (PSPDEV)listiswitch[0];
                                    PSPDEV pspjswitch = (PSPDEV)listjswitch[0];
                                    PSPDEV pspkswitch = (PSPDEV)listkswitch[0];
                                    if (pspDuanlu.Number == devINode.Number && pspiswitch.KSwitchStatus == "0" && pspjswitch.KSwitchStatus == "0" && pspkswitch.KSwitchStatus == "0")
                                    {

                                        flag = true;
                                        dlr = "0" + " " + devINode.Number + " " + devJNode.Number + " " + psp.Number + " " + "0" + " " + n3.ToString();

                                    }
                                    if (pspDuanlu.Number == devJNode.Number && pspiswitch.KSwitchStatus == "0" && pspjswitch.KSwitchStatus == "0" && pspkswitch.KSwitchStatus == "0")
                                    {
                                        flag = true;
                                        dlr = "0" + " " + devINode.Number + " " + devJNode.Number + " " + psp.Number + " " + "1" + " " + n3.ToString();
                                    }
                                    if (pspDuanlu.Number == devKNode.Number && pspiswitch.KSwitchStatus == "0" && pspjswitch.KSwitchStatus == "0" && pspkswitch.KSwitchStatus == "0")
                                    {
                                        flag = true;
                                        dlr = "0" + " " + devINode.Number + " " + devKNode.Number + " " + psp.Number + " " + "1" + " " + n3.ToString();
                                    }

                                    if (flag)
                                    {
                                        break;                 //跳出本循环 进行母线的另外一个母线短路

                                    }
                                    if (!flag)
                                        continue;
                                    //写入错误中

                                }
                            }
                            if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\fault.txt"))
                            {
                                File.Delete(System.Windows.Forms.Application.StartupPath + "\\fault.txt");
                            }

                            FileStream VK = new FileStream((System.Windows.Forms.Application.StartupPath + "\\fault.txt"), FileMode.OpenOrCreate);
                            StreamWriter str11 = new StreamWriter(VK);
                            str11.Write(dlr);
                            str11.Close();
                            n4 = 0;

                        }
                        else if (pspDuanlu.Type == "05")
                        {
                            //n11 = pspDuanlu.FirstNode;
                            //n2 = pspDuanlu.LastNode;
                            n11 = pspDuanlu.Number;
                            n2 = n11;
                            switch (dudu.DuanluType)
                            {
                                case "单相接地":
                                    n3 = 1;
                                    break;

                                case "两相接地":
                                    n3 = 3;
                                    break;
                                case "两相故障":
                                    n3 = 2;
                                    break;
                                case "三相故障":
                                    n3 = 0;
                                    break;
                                default:
                                    n3 = 0;
                                    break;
                            }
                            string dlr = null;
                            if (n4 < 1 && n4 > 0)
                            {
                                duanluname = pspDuanlu.Name;
                            }
                            dlr = "0" + " " + pspDuanlu.FirstNode + " " + pspDuanlu.LastNode + " " + pspDuanlu.Number + " " + n4 + " " + n3.ToString();

                            if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\fault.txt"))
                            {
                                File.Delete(System.Windows.Forms.Application.StartupPath + "\\fault.txt");
                            }

                            FileStream VK = new FileStream((System.Windows.Forms.Application.StartupPath + "\\fault.txt"), FileMode.OpenOrCreate);
                            StreamWriter str11 = new StreamWriter(VK);
                            str11.Write(dlr);
                            str11.Close();
                        }
                        else
                        {
                            return;
                        }
                        XmlNodeList list = tlVectorControl1.SVGDocument.SelectNodes("svg/*[@flag='" + "1" + "']");
                        foreach (XmlNode node in list)
                        {
                            SvgElement elementde = node as SvgElement;
                            tlVectorControl1.SVGDocument.CurrentElement = elementde;
                            tlVectorControl1.Delete();
                        }
                        wFrom.ShowText += "\r\n进行短路计算!" + System.DateTime.Now.ToString();
                        shortcir shortCutCal = new shortcir();
                        shortCutCal.Show_shortcir(0,0);
                        //bool matrixflag=true;                //用来判断是否导纳矩阵的逆矩阵是否存在逆矩阵

                        string matrixstr = null;
                        if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Zmatrixcheck.txt"))
                        {
                            matrixstr = "正序导纳矩阵";
                            // matrixflag = false;
                        }
                        if (matrixstr != null)
                        {
                            matrixstr += ",";
                        }
                        if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Fmatrixcheck.txt"))
                        {
                            // matrixflag = false;
                            matrixstr += "负序导纳矩阵";
                        }
                        if (matrixstr != null)
                        {
                            matrixstr += ",";
                        }
                        if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Lmatrixcheck.txt"))
                        {
                            //matrixflag = false;
                            matrixstr += "零序导纳矩阵";
                        }
                        if (matrixstr != null)
                        {
                            wFrom.ShowText += "\r\n" + matrixstr + "不存在逆矩阵,请调整参数后再进行计算!" + System.DateTime.Now.ToString();
                            //MessageBox.Show(matrixstr + "不存在逆矩阵,请调整参数后再进行计算!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                        string duanResult = null;
                        duanResult += "短路电流简表" + "\r\n" + "\r\n";
                        if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\ShortcuitI.txt"))
                        {
                        }
                        else
                        {
                            return;
                        }
                         wFrom.ShowText += "\r\n结果显示!" + System.DateTime.Now.ToString();
                        FileStream shorcuit = new FileStream(System.Windows.Forms.Application.StartupPath + "\\ShortcuitI.txt", FileMode.Open);
                        StreamReader readLineGU = new StreamReader(shorcuit, System.Text.Encoding.Default);
                        string strLineGU;
                        string[] arrayGU;
                        char[] charSplitGU = new char[] { ' ' };
                        strLineGU = readLineGU.ReadLine();
                         int j = 0;
                        while (strLineGU != null)
                        {
                            arrayGU = strLineGU.Split(charSplitGU);
                            int i = 0;
                            string[] dev = new string[9];
                            dev.Initialize();
                            foreach (string str in arrayGU)
                            {
                                if (str != "")
                                {
                                    dev[i++] = str;
                                }
                            }
                            if (tuxing == 2 && j != 0)
                            {
                                PSPDEV CR = new PSPDEV();

                                if (dev[1] != "du")
                                {
                                   string con = " ,PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + tlVectorControl1.SVGDocument.SvgdataUid + "'AND PSPDEV.Name='" + dev[1] + "'";
                                    CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", con);
                                }
                                else
                                {
                                    string con = " ,PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + tlVectorControl1.SVGDocument.SvgdataUid + "'AND PSPDEV.Name='" + duanluname + "'AND PSPDEV.Type='05'";
                                    CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", con);
                                }

                                if (CR != null)
                                {
                                    if (CR.Type != "05")
                                    {
                                        XmlElement elementdl = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@Deviceid='" + CR.SUID + "']") as XmlElement;

                                        if (elementdl != null)
                                        {
                                            RectangleF bound = ((IGraph)elementdl).GetBounds();
                                            XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                                            n1.SetAttribute("x", Convert.ToString(bound.X));
                                            n1.SetAttribute("y", Convert.ToString(bound.Y - 20));
                                            n1.InnerText = (Convert.ToDouble(dev[3]) * 100 / (Math.Sqrt(3) * CR.ReferenceVolt)).ToString("N4");
                                            n1.SetAttribute("layer", SvgDocument.currentLayer);
                                            n1.SetAttribute("flag", "1");
                                            n1.SetAttribute("stroke", "#FF0000");
                                            tlVectorControl1.SVGDocument.RootElement.AppendChild(n1);
                                            tlVectorControl1.Operation = ToolOperation.Select;
                                            tlVectorControl1.Refresh();
                                        }
                                    }
                                    else
                                    {
                                        XmlElement elementdl = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@Deviceid='" + CR.SUID + "']") as XmlElement;

                                        if (elementdl != null)
                                        {
                                            PointF[] t = ((Polyline)elementdl).Points;

                                            PointF[] t2 = ((Polyline)elementdl).FirstTwoPoint;
                                            t = t2;
                                            PointF midt = new PointF((float)((t2[0].X + t2[1].X) / 2), (float)((t2[0].Y + t2[1].Y) / 2));
                                            float angel = 0f;
                                            angel = (float)(180 * Math.Atan2((t2[1].Y - t2[0].Y), (t2[1].X - t2[0].X)) / Math.PI);

                                            string l3 = Convert.ToString(midt.X);
                                            string l4 = Convert.ToString(midt.Y);

                                            string tran = ((Polyline)elementdl).Transform.ToString();

                                            PointF center = new PointF((float)(t[0].X + (t[1].X - t[0].X) / 2), (float)(t[0].Y + (t[1].Y - t[0].Y) / 2));
                                            XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                                            XmlElement n2dl = tlVectorControl1.SVGDocument.CreateElement("polyline") as Polyline;
                                            PointF pStart = new PointF(center.X + (float)(15 * Math.Sin((angel) * Math.PI / 180)), center.Y - (float)(15 * Math.Cos((angel) * Math.PI / 180)));
                                            PSPDEV psp = new PSPDEV();
                                            psp.FirstNode = CR.FirstNode;
                                            psp.LastNode = CR.LastNode;
                                            string con = " ,PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + tlVectorControl1.SVGDocument.SvgdataUid + "'AND PSPDEV.FirstNode='" + CR.FirstNode + "'AND PSPDEV.LastNode='"+CR.LastNode+"'";
                                            IList listParallel = Services.BaseService.GetList("SelectPSPDEVByCondition", con);

                                            PSPDEV tempss = new PSPDEV();

                                            foreach (PSPDEV devP in listParallel)
                                            {
                                                if ((angel > 10 && angel < 90) || (angel < 0 && Math.Abs(angel) < 90) || (angel > 180 && angel < 350))
                                                {
                                                    if (((devP.X1) > (CR.X1)))
                                                    {
                                                        pStart = new PointF(center.X - (float)(23 * Math.Sin((angel) * Math.PI / 180)), center.Y + (float)(23 * Math.Cos((angel) * Math.PI / 180)));

                                                    }
                                                }
                                                else if ((angel >= 0 && angel <= 10) || (angel >= 350 && angel <= 360) || (angel < 0 && Math.Abs(angel) <= 90))
                                                {
                                                    if (((devP.Y1) > (CR.Y1)))
                                                    {
                                                        pStart = new PointF(center.X - (float)(23 * Math.Sin((angel) * Math.PI / 180)), center.Y + (float)(23 * Math.Cos((angel) * Math.PI / 180)));

                                                    }
                                                }
                                                else if ((angel < 0 && Math.Abs(angel) > 90) || (angel >= 90 && angel <= 180))
                                                {
                                                    if (((devP.Y1) > (CR.Y1)))
                                                    {
                                                        pStart = new PointF(center.X - (float)(7 * Math.Sin((angel) * Math.PI / 180)), center.Y + (float)(7 * Math.Cos((angel) * Math.PI / 180)));

                                                    }
                                                }
                                            }

                                            PointF newp1 = new PointF(t[0].X + (t[1].X - t[0].X) / 2 - (float)(15 * Math.Sin(angel)), t[0].Y + (t[1].Y - t[0].Y) / 2 - (float)(15 * Math.Cos(angel)));

                                            n1.SetAttribute("x", Convert.ToString(pStart.X));
                                            n1.SetAttribute("y", Convert.ToString(pStart.Y));

                                            //if (Convert.ToDouble(dev[4]) >= 0)
                                            //{
                                            n1.InnerText = (Math.Abs(Convert.ToDouble(dev[3]) * 100 / (Math.Sqrt(3) * CR.ReferenceVolt))).ToString("N4");
                                            //}
                                            //else
                                            //{
                                            //    n1.InnerText = (Math.Abs(Convert.ToDouble(dev[3]))).ToString("N4");
                                            //}
                                            n1.SetAttribute("layer", SvgDocument.currentLayer);
                                            n1.SetAttribute("flag", "1");

                                            //if (Convert.ToDouble(dev[5]) == 1)
                                            //    n1.SetAttribute("stroke", "#FF0000");

                                            PointF p1 = new PointF(midt.X - (float)(10 * Math.Cos((angel + 25) * Math.PI / 180)), midt.Y - (float)(10 * Math.Sin((angel + 25) * Math.PI / 180)));
                                            PointF p2 = new PointF(midt.X - (float)(10 * Math.Cos((angel + 335) * Math.PI / 180)), midt.Y - (float)(10 * Math.Sin((angel + 335) * Math.PI / 180)));

                                            if (Convert.ToDouble(dev[3]) < 0)
                                            {
                                                p1 = new PointF(midt.X - (float)(10 * Math.Cos((angel + 155) * Math.PI / 180)), midt.Y - (float)(10 * Math.Sin((angel + 155) * Math.PI / 180)));
                                                p2 = new PointF(midt.X - (float)(10 * Math.Cos((angel + 205) * Math.PI / 180)), midt.Y - (float)(10 * Math.Sin((angel + 205) * Math.PI / 180)));
                                            }

                                            string l1 = Convert.ToString(p1.X);
                                            string l2 = Convert.ToString(p1.Y);
                                            string l5 = Convert.ToString(p2.X);
                                            string l6 = Convert.ToString(p2.Y);

                                            tlVectorControl1.SVGDocument.RootElement.AppendChild(n1);
                                            tlVectorControl1.Operation = ToolOperation.Select;

                                            tlVectorControl1.SVGDocument.CurrentElement = n1 as SvgElement;

                                            RectangleF ttt = ((Polyline)elementdl).GetBounds();

                                            tlVectorControl1.RotateSelection(angel, pStart);
                                            if (Math.Abs(angel) > 90)
                                                tlVectorControl1.RotateSelection(180, pStart);
                                            PointF newp = new PointF(center.X + 10, center.Y + 10);

                                            tlVectorControl1.Refresh();

                                        }
                                    }
                                }
                                if (CR.NodeType == "05")
                                {
                                    PSPDEV fl = new PSPDEV();
                                    string con = " ,PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + tlVectorControl1.SVGDocument.SvgdataUid + "'AND PSPDEV.Number='" + CR.FirstNode +"'";
                                    fl = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", con);
                                    duanResult += dev[0] + "," + dev[1] + "," + Convert.ToDouble(dev[3]) * 100 / (Math.Sqrt(3) * fl.ReferenceVolt) + "\r\n";
                                }
                                else
                                {
                                    duanResult += dev[0] + "," + dev[1] + "," + Convert.ToDouble(dev[3]) * 100 / (Math.Sqrt(3) * CR.ReferenceVolt) + "\r\n";
                                }

                            }
                            else if (tuxing==1&&j!=0)
                            {
                                PSPDEV CR = new PSPDEV();

                                if (dev[1] != "du")
                                {
                                    string con = " ,PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + tlVectorControl1.SVGDocument.SvgdataUid + "'AND PSPDEV.Name='" + dev[1] + "'";
                                    CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", con);
                                }
                                else
                                {
                                    string con = " ,PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + tlVectorControl1.SVGDocument.SvgdataUid + "'AND PSPDEV.Name='" + duanluname + "'AND PSPDEV.Type='05'";
                                    CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", con);
                                }

                                if (CR.NodeType == "05")
                                {
                                    PSPDEV fl = new PSPDEV();
                                    string con = " ,PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + tlVectorControl1.SVGDocument.SvgdataUid + "'AND PSPDEV.Number='" + CR.FirstNode + "'";
                                    fl = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", con);
                                    duanResult += dev[0] + "," + dev[1] + "," + Convert.ToDouble(dev[3]) * 100 / (Math.Sqrt(3) * fl.ReferenceVolt) + "\r\n";
                                }
                                else
                                {
                                    duanResult += dev[0] + "," + dev[1] + "," + Convert.ToDouble(dev[3]) * 100 / (Math.Sqrt(3) * CR.ReferenceVolt) + "\r\n";
                                }
                            }
                            else if (j==0)
                            {
                                duanResult += dev[0] + "," + dev[1] + "," + dev[3]+ "\r\n";
                            }
                            strLineGU = readLineGU.ReadLine();
                            j++;
                        }
                        readLineGU.Close();
                        string dianYaResult = null;
                        dianYaResult += "母线电压结果" + "\r\n" + "\r\n";
                        if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Sxdianya.txt"))
                        {
                        }
                        else
                        {
                            return;
                        }
                        FileStream dianYa = new FileStream(System.Windows.Forms.Application.StartupPath + "\\Sxdianya.txt", FileMode.Open);
                        StreamReader readLineDY = new StreamReader(dianYa, System.Text.Encoding.Default);
                        string strLineDY;
                        string[] arrayDY;
                        char[] charSplitDY = new char[] { ' ' };
                        strLineDY = readLineDY.ReadLine();
                        j = 0;
                        while (strLineDY != null)
                        {
                            arrayDY = strLineDY.Split(charSplitDY);
                            int i = 0;
                            string[] dev = new string[14];
                            dev.Initialize();
                            foreach (string str in arrayDY)
                            {
                                if (str != "")
                                {
                                    dev[i++] = str;
                                }
                            }
                            if (j == 0)
                            {
                                dianYaResult += dev[0] + "," + dev[1] + "," + dev[2] + "," + dev[3] + "," + dev[4] + "," + dev[5] + "," + dev[6] + "," + dev[7] + "," + dev[8] + "," +
             dev[9] + "," + dev[10] + "," + dev[11] + "," + dev[12] + "," + dev[13] + "\r\n";
                            }
                            else
                            {
                                bool flag = true;     //判断此母线是短路点母线还是一般的母线
                                PSPDEV CR = new PSPDEV();

                                if (dev[1] != "du")
                                {
                                    string con = " ,PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + tlVectorControl1.SVGDocument.SvgdataUid + "'AND PSPDEV.Name='" + dev[1] + "'";
                                    CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", con); ;
                                }
                                else
                                {
                                    flag = false;
                                    string con = " ,PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + tlVectorControl1.SVGDocument.SvgdataUid + "'AND PSPDEV.Name='" + duanluname + "'AND PSPDEV.Type='05'";
                                    CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", con);
                                }

                                //CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByNameANDSVG", CR);
                                if (tuxing == 1)
                                {
                                    XmlElement elementdl = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@Deviceid='" + CR.SUID + "']") as XmlElement;

                                    if (elementdl != null)
                                    {
                                        RectangleF bound = ((IGraph)elementdl).GetBounds();
                                        XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                                        XmlElement n22 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                                        XmlElement n33 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                                        n1.SetAttribute("x", Convert.ToString(bound.X));
                                        n1.SetAttribute("y", Convert.ToString(bound.Y - 60));
                                        n1.InnerText = "A相:" + (Convert.ToDouble(dev[2]) * CR.ReferenceVolt).ToString("N4") + "kV/" + (Convert.ToDouble(dev[3])).ToString("N4") + "°";
                                        n1.SetAttribute("layer", SvgDocument.currentLayer);
                                        n1.SetAttribute("flag", "1");
                                        tlVectorControl1.SVGDocument.RootElement.AppendChild(n1);
                                        tlVectorControl1.Operation = ToolOperation.Select;
                                        tlVectorControl1.Refresh();
                                        n22.SetAttribute("x", Convert.ToString(bound.X));
                                        n22.SetAttribute("y", Convert.ToString(bound.Y - 40));
                                        n22.InnerText = "B相:" + (Convert.ToDouble(dev[4]) * CR.ReferenceVolt).ToString("N4") + "kV/" + (Convert.ToDouble(dev[5])).ToString("N4") + "°";
                                        n22.SetAttribute("layer", SvgDocument.currentLayer);
                                        n22.SetAttribute("flag", "1");
                                        tlVectorControl1.SVGDocument.RootElement.AppendChild(n22);
                                        tlVectorControl1.Operation = ToolOperation.Select;
                                        tlVectorControl1.Refresh();
                                        n33.SetAttribute("x", Convert.ToString(bound.X));
                                        n33.SetAttribute("y", Convert.ToString(bound.Y - 20));
                                        n33.InnerText = "C相:" + (Convert.ToDouble(dev[6]) * CR.ReferenceVolt).ToString("N4") + "kV/" + (Convert.ToDouble(dev[7])).ToString("N4") + "°";
                                        n33.SetAttribute("layer", SvgDocument.currentLayer);
                                        n33.SetAttribute("flag", "1");
                                        tlVectorControl1.SVGDocument.RootElement.AppendChild(n33);
                                        tlVectorControl1.Operation = ToolOperation.Select;
                                        tlVectorControl1.Refresh();
                                    }
                                }
                                if (flag)
                                    dianYaResult += dev[0] + "," + dev[1] + "," + Convert.ToDouble(dev[2]) * CR.ReferenceVolt + "," + dev[3] + "," + Convert.ToDouble(dev[4]) * CR.ReferenceVolt + "," + dev[5] + "," + Convert.ToDouble(dev[6]) * CR.ReferenceVolt + "," + dev[7] + "," + Convert.ToDouble(dev[8]) * CR.ReferenceVolt + "," +
                                        dev[9] + "," + Convert.ToDouble(dev[10]) * CR.ReferenceVolt + "," + dev[11] + "," + Convert.ToDouble(dev[12]) * CR.ReferenceVolt + "," + dev[13] + "\r\n";
                                else
                                    dianYaResult += dev[0] + "," + duanluname + "上短路点" + "," + Convert.ToDouble(dev[2]) * CR.ReferenceVolt + "," + dev[3] + "," + Convert.ToDouble(dev[4]) * CR.ReferenceVolt + "," + dev[5] + "," + Convert.ToDouble(dev[6]) * CR.ReferenceVolt + "," + dev[7] + "," + Convert.ToDouble(dev[8]) * CR.ReferenceVolt + "," +
                                       dev[9] + "," + Convert.ToDouble(dev[10]) * CR.ReferenceVolt + "," + dev[11] + Convert.ToDouble(dev[12]) * CR.ReferenceVolt + "," + dev[13] + "\r\n";

                            }
                            strLineDY = readLineDY.ReadLine();
                            j++;
                        }
                        readLineDY.Close();
                        string dianLiuResult = null;
                        dianLiuResult += "支路电流结果" + "\r\n" + "\r\n";
                        if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Sxdianliu.txt"))
                        {
                        }
                        else
                        {
                            return;
                        }
                        FileStream dianLiu = new FileStream(System.Windows.Forms.Application.StartupPath + "\\Sxdianliu.txt", FileMode.Open);
                        StreamReader readLineDL = new StreamReader(dianLiu, System.Text.Encoding.Default);
                        string strLineDL;
                        string[] arrayDL;
                        char[] charSplitDL = new char[] { ' ' };
                        strLineDL = readLineDL.ReadLine();
                        j = 0;
                        while (strLineDL != null)
                        {
                            arrayDL = strLineDL.Split(charSplitDL);
                            int i = 0;
                            string[] dev = new string[15];
                            dev.Initialize();
                            foreach (string str in arrayDL)
                            {
                                if (str != "")
                                {
                                    dev[i++] = str;
                                }
                            }
                            if (j == 0)
                            {
                                dianLiuResult += dev[0] + "," + dev[1] + "," + dev[2] + "," + dev[3] + "," + dev[4] + "," + dev[5] + "," + dev[6] + "," + dev[7] + "," + dev[8] + "," +
                                             dev[9] + "," + dev[10] + "," + dev[11] + "," + dev[12] + "," + dev[13] + "," + dev[14] + "\r\n";
                            }
                            else
                            {
                                //PSPDEV CR = new PSPDEV();
                                //CR.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                //CR.Number = Convert.ToInt32(dev[2]);
                                //CR.Type = "Polyline";
                                //CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByNumberAndSvgUIDAndType", CR);

                                //因为在线路电流输出时既有一般线路的电流、两绕组和三绕组线路的电流还有接地电容器和电抗器的电流,因此只将电流输出就行了

                                PSPDEV CR = new PSPDEV();
                               // CR.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;

                                if (dev[0] != "du")
                                {
                                    CR.Name = dev[0];
                                }
                                else
                                    CR.Name = dev[1];
                                string con = " ,PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + tlVectorControl1.SVGDocument.SvgdataUid + "'AND PSPDEV.Name='" + CR.Name + "'AND PSPDEV.Type='01'";
                                CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", con);
                                if (tuxing == 1)
                                {
                                    //    XmlElement elementdl = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@id='" + CR.EleID + "']") as XmlElement;

                                    //    if (elementdl != null)
                                    //    {
                                    //        PointF[] t = ((Polyline)elementdl).Points;

                                    //        PointF[] t2 = ((Polyline)elementdl).FirstTwoPoint;
                                    //        t = t2;
                                    //        PointF midt = new PointF((float)((t2[0].X + t2[1].X) / 2), (float)((t2[0].Y + t2[1].Y) / 2));
                                    //        float angel = 0f;
                                    //        angel = (float)(180 * Math.Atan2((t2[1].Y - t2[0].Y), (t2[1].X - t2[0].X)) / Math.PI);

                                    //        string l3 = Convert.ToString(midt.X);
                                    //        string l4 = Convert.ToString(midt.Y);

                                    //        string tran = ((Polyline)elementdl).Transform.ToString();

                                    //        PointF center = new PointF((float)(t[0].X + (t[1].X - t[0].X) / 2), (float)(t[0].Y + (t[1].Y - t[0].Y) / 2));
                                    //        XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                                    //        XmlElement n2dl = tlVectorControl1.SVGDocument.CreateElement("polyline") as Polyline;
                                    //        PointF pStart = new PointF(center.X + (float)(15 * Math.Sin((angel) * Math.PI / 180)), center.Y - (float)(15 * Math.Cos((angel) * Math.PI / 180)));
                                    //        PSPDEV psp = new PSPDEV();
                                    //        psp.FirstNode = CR.FirstNode;
                                    //        psp.LastNode = CR.LastNode;
                                    //        psp.SvgUID = CR.SvgUID;
                                    //        PSPDEV tempss = new PSPDEV();
                                    //        IList listParallel = Services.BaseService.GetList("SelectPSPDEVBySvgUIDandFirstOrLastNode", psp);
                                    //        foreach (PSPDEV devP in listParallel)
                                    //        {
                                    //            if ((angel > 10 && angel < 90) || (angel < 0 && Math.Abs(angel) < 90) || (angel > 180 && angel < 350))
                                    //            {
                                    //                if (((devP.X1) > (CR.X1)))
                                    //                {
                                    //                    pStart = new PointF(center.X - (float)(23 * Math.Sin((angel) * Math.PI / 180)), center.Y + (float)(23 * Math.Cos((angel) * Math.PI / 180)));

                                    //                }
                                    //            }
                                    //            else if ((angel >= 0 && angel <= 10) || (angel >= 350 && angel <= 360) || (angel < 0 && Math.Abs(angel) <= 90))
                                    //            {
                                    //                if (((devP.Y1) > (CR.Y1)))
                                    //                {
                                    //                    pStart = new PointF(center.X - (float)(23 * Math.Sin((angel) * Math.PI / 180)), center.Y + (float)(23 * Math.Cos((angel) * Math.PI / 180)));

                                    //                }
                                    //            }
                                    //            else if ((angel < 0 && Math.Abs(angel) > 90) || (angel >= 90 && angel <= 180))
                                    //            {
                                    //                if (((devP.Y1) > (CR.Y1)))
                                    //                {
                                    //                    pStart = new PointF(center.X - (float)(7 * Math.Sin((angel) * Math.PI / 180)), center.Y + (float)(7 * Math.Cos((angel) * Math.PI / 180)));

                                    //                }
                                    //            }
                                    //        }

                                    //        PointF newp1 = new PointF(t[0].X + (t[1].X - t[0].X) / 2 - (float)(15 * Math.Sin(angel)), t[0].Y + (t[1].Y - t[0].Y) / 2 - (float)(15 * Math.Cos(angel)));

                                    //        n1.SetAttribute("x", Convert.ToString(pStart.X));
                                    //        n1.SetAttribute("y", Convert.ToString(pStart.Y));

                                    //        //if (Convert.ToDouble(dev[4]) >= 0)
                                    //        //{
                                    //        n1.InnerText = (Math.Abs(Convert.ToDouble(dev[3]) * 100 / (Math.Sqrt(3) * CR.ReferenceVolt))).ToString("N4");
                                    //        //}
                                    //        //else
                                    //        //{
                                    //        //    n1.InnerText = (Math.Abs(Convert.ToDouble(dev[3]))).ToString("N4");
                                    //        //}
                                    //        n1.SetAttribute("layer", SvgDocument.currentLayer);
                                    //        n1.SetAttribute("flag", "1");

                                    //        //if (Convert.ToDouble(dev[3]) == 1)
                                    //        //    n1.SetAttribute("stroke", "#FF0000");

                                    //        PointF p1 = new PointF(midt.X - (float)(10 * Math.Cos((angel + 25) * Math.PI / 180)), midt.Y - (float)(10 * Math.Sin((angel + 25) * Math.PI / 180)));
                                    //        PointF p2 = new PointF(midt.X - (float)(10 * Math.Cos((angel + 335) * Math.PI / 180)), midt.Y - (float)(10 * Math.Sin((angel + 335) * Math.PI / 180)));

                                    //        if (Convert.ToDouble(dev[3]) < 0)
                                    //        {
                                    //            p1 = new PointF(midt.X - (float)(10 * Math.Cos((angel + 155) * Math.PI / 180)), midt.Y - (float)(10 * Math.Sin((angel + 155) * Math.PI / 180)));
                                    //            p2 = new PointF(midt.X - (float)(10 * Math.Cos((angel + 205) * Math.PI / 180)), midt.Y - (float)(10 * Math.Sin((angel + 205) * Math.PI / 180)));
                                    //        }

                                    //        string l1 = Convert.ToString(p1.X);
                                    //        string l2 = Convert.ToString(p1.Y);
                                    //        string l5 = Convert.ToString(p2.X);
                                    //        string l6 = Convert.ToString(p2.Y);

                                    //        tlVectorControl1.SVGDocument.RootElement.AppendChild(n1);
                                    //        tlVectorControl1.Operation = ToolOperation.Select;

                                    //        tlVectorControl1.SVGDocument.CurrentElement = n1 as SvgElement;

                                    //        RectangleF ttt = ((Polyline)elementdl).GetBounds();

                                    //        tlVectorControl1.RotateSelection(angel, pStart);
                                    //        if (Math.Abs(angel) > 90)
                                    //            tlVectorControl1.RotateSelection(180, pStart);
                                    //        PointF newp = new PointF(center.X + 10, center.Y + 10);

                                    //        tlVectorControl1.Refresh();

                                }
                                dianLiuResult += dev[0] + "," + dev[1] + "," + dev[2] + "," + Convert.ToDouble(dev[3]) * 100 / (Math.Sqrt(3) * CR.ReferenceVolt) + "," + dev[4] + "," + Convert.ToDouble(dev[5]) * 100 / (Math.Sqrt(3) * CR.ReferenceVolt) + "," + dev[6] + "," + Convert.ToDouble(dev[7]) * 100 / (Math.Sqrt(3) * CR.ReferenceVolt) + "," + dev[8] + "," +
                                  Convert.ToDouble(dev[9]) * 100 / (Math.Sqrt(3) * CR.ReferenceVolt) + "," + dev[10] + "," + Convert.ToDouble(dev[11]) * 100 / (Math.Sqrt(3) * CR.ReferenceVolt) + "," + dev[12] + "," + Convert.ToDouble(dev[13]) * 100 / (Math.Sqrt(3) * CR.ReferenceVolt) + "," + dev[14] + "\r\n";

                                //if (CR.NodeType == "Polyline")
                                //{
                                //    PSPDEV fl = new PSPDEV();
                                //    fl.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                //    fl.Number = CR.FirstNode;
                                //    fl.Type = nodeType;
                                //    fl = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByNumberAndSvgUIDAndType", CR);
                                //    dianLiuResult += dev[0] + "," + dev[1] + "," + dev[2] + "," + Convert.ToDouble(dev[3]) * 100 / (Math.Sqrt(3) * fl.ReferenceVolt) + "," + dev[4] + "," + Convert.ToDouble(dev[5]) * 100 / (Math.Sqrt(3) * fl.ReferenceVolt) + "," + dev[6] + "," + Convert.ToDouble(dev[7]) * 100 / (Math.Sqrt(3) * fl.ReferenceVolt) + "," + dev[8] + "," +
                                //    Convert.ToDouble(dev[9]) * 100 / (Math.Sqrt(3) * fl.ReferenceVolt) + "," + dev[10] + "," + Convert.ToDouble(dev[11]) * 100 / (Math.Sqrt(3) * fl.ReferenceVolt) + dev[12] + "," + Convert.ToDouble(dev[13]) * 100 / (Math.Sqrt(3) * fl.ReferenceVolt) + "," + dev[14] + "\r\n";
                                //}
                                //else
                                //{
                                //    dianLiuResult += dev[0] + "," + dev[1] + "," + dev[2] + "," + Convert.ToDouble(dev[3]) * 100 / (Math.Sqrt(3) * CR.ReferenceVolt) + "," + dev[4] + "," + Convert.ToDouble(dev[5]) * 100 / (Math.Sqrt(3) * CR.ReferenceVolt) + "," + dev[6] + "," + Convert.ToDouble(dev[7]) * 100 / (Math.Sqrt(3) * CR.ReferenceVolt) + "," + dev[8] + "," +
                                //    Convert.ToDouble(dev[9]) * 100 / (Math.Sqrt(3) * CR.ReferenceVolt) + "," + dev[10] + "," + Convert.ToDouble(dev[11]) * 100 / (Math.Sqrt(3) * CR.ReferenceVolt) + dev[12] + "," + Convert.ToDouble(dev[13]) * 100 / (Math.Sqrt(3) * CR.ReferenceVolt) + "," + dev[14] + "\r\n";
                                //}

                            }

                            strLineDL = readLineDL.ReadLine();
                            j++;
                        }
                        readLineDL.Close();
                        if (baobiao == 1)
                        {
                             wFrom.ShowText += "\r\n形成报表!" + System.DateTime.Now.ToString();
                            if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\result.csv"))
                            {
                                File.Delete(System.Windows.Forms.Application.StartupPath + "\\result.csv");
                            }
                            FileStream tempGU = new FileStream((System.Windows.Forms.Application.StartupPath + "\\result.csv"), FileMode.OpenOrCreate);
                            StreamWriter strGU = new StreamWriter(tempGU, Encoding.GetEncoding("GB2312"));
                            strGU.Write(duanResult);
                            strGU.Close();
                            if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\result1.csv"))
                            {
                                File.Delete(System.Windows.Forms.Application.StartupPath + "\\result1.csv");
                            }
                            FileStream tempDY = new FileStream((System.Windows.Forms.Application.StartupPath + "\\result1.csv"), FileMode.OpenOrCreate);
                            StreamWriter strDY = new StreamWriter(tempDY, Encoding.GetEncoding("GB2312"));
                            strDY.Write(dianYaResult);
                            strDY.Close();
                            if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\result2.csv"))
                            {
                                File.Delete(System.Windows.Forms.Application.StartupPath + "\\result2.csv");
                            }
                            FileStream tempDL = new FileStream((System.Windows.Forms.Application.StartupPath + "\\result2.csv"), FileMode.OpenOrCreate);
                            StreamWriter strDL = new StreamWriter(tempDL, Encoding.GetEncoding("GB2312"));
                            strDL.Write(dianLiuResult);
                            strDL.Close();
                            if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\" + tlVectorControl1.SVGDocument.FileName + "短路计算结果.xls"))
                            {
                                File.Delete(System.Windows.Forms.Application.StartupPath + "\\" + tlVectorControl1.SVGDocument.FileName + "短路计算结果.xls");
                            }

                            Excel.Application ex;
                            Excel.Worksheet xSheet;
                            Excel.Application result1;
                            Excel.Application result2;
                            Excel.Worksheet tempSheet;
                            Excel.Worksheet tempSheet1;
                            Excel.Worksheet newWorksheet;
                            Excel.Worksheet newWorkSheet1;

                            object oMissing = System.Reflection.Missing.Value;
                            ex = new Excel.Application();
                            ex.Application.Workbooks.Add(System.Windows.Forms.Application.StartupPath + "\\result.csv");

                            xSheet = (Excel.Worksheet)ex.Worksheets[1];
                            ex.Worksheets.Add(System.Reflection.Missing.Value, xSheet, 1, System.Reflection.Missing.Value);
                            xSheet = (Excel.Worksheet)ex.Worksheets[2];
                            ex.Worksheets.Add(System.Reflection.Missing.Value, xSheet, 1, System.Reflection.Missing.Value);
                            xSheet = (Excel.Worksheet)ex.Worksheets[1];
                            result1 = new Excel.Application();
                            result1.Application.Workbooks.Add(System.Windows.Forms.Application.StartupPath + "\\result1.csv");
                            result2 = new Excel.Application();
                            result2.Application.Workbooks.Add(System.Windows.Forms.Application.StartupPath + "\\result2.csv");
                            tempSheet = (Excel.Worksheet)result1.Worksheets.get_Item(1);
                            tempSheet1 = (Excel.Worksheet)result2.Worksheets.get_Item(1);
                            newWorksheet = (Excel.Worksheet)ex.Worksheets.get_Item(2);
                            newWorkSheet1 = (Excel.Worksheet)ex.Worksheets.get_Item(3);
                            newWorksheet.Name = "母线电压";
                            newWorkSheet1.Name = "支路电流";
                            xSheet.Name = "短路电流";
                            ex.Visible = true;

                            tempSheet.Cells.Select();
                            tempSheet.Cells.Copy(System.Reflection.Missing.Value);
                            newWorksheet.Paste(System.Reflection.Missing.Value, System.Reflection.Missing.Value);
                            tempSheet1.Cells.Select();
                            tempSheet1.Cells.Copy(System.Reflection.Missing.Value);
                            newWorkSheet1.Paste(System.Reflection.Missing.Value, System.Reflection.Missing.Value);

                            xSheet.UsedRange.Font.Name = "楷体_GB2312";
                            newWorksheet.UsedRange.Font.Name = "楷体_GB2312";
                            newWorkSheet1.UsedRange.Font.Name = "楷体_GB2312";

                            xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 3]).MergeCells = true;
                            xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 1]).Font.Size = 20;
                            xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 1]).Font.Name = "黑体";
                            xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 1]).HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
                            xSheet.get_Range(xSheet.Cells[3, 1], xSheet.Cells[3, 3]).Interior.ColorIndex = 45;
                            xSheet.get_Range(xSheet.Cells[4, 1], xSheet.Cells[xSheet.UsedRange.Rows.Count, 1]).Interior.ColorIndex = 6;
                            xSheet.get_Range(xSheet.Cells[4, 3], xSheet.Cells[xSheet.UsedRange.Rows.Count, 13]).NumberFormat = "0.0000_ ";

                            newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 14]).MergeCells = true;
                            newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 1]).Font.Size = 20;
                            newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 1]).Font.Name = "黑体";
                            newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 1]).HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
                            newWorksheet.get_Range(newWorksheet.Cells[3, 1], newWorksheet.Cells[3, 14]).Interior.ColorIndex = 45;
                            newWorksheet.get_Range(newWorksheet.Cells[4, 1], newWorksheet.Cells[newWorksheet.UsedRange.Rows.Count, 1]).Interior.ColorIndex = 6;
                            newWorksheet.get_Range(newWorksheet.Cells[4, 3], newWorksheet.Cells[newWorksheet.UsedRange.Rows.Count, 13]).NumberFormat = "0.0000_ ";

                            newWorkSheet1.get_Range(newWorkSheet1.Cells[1, 1], newWorkSheet1.Cells[1, 15]).MergeCells = true;
                            newWorkSheet1.get_Range(newWorkSheet1.Cells[1, 1], newWorkSheet1.Cells[1, 1]).Font.Size = 20;
                            newWorkSheet1.get_Range(newWorkSheet1.Cells[1, 1], newWorkSheet1.Cells[1, 1]).Font.Name = "黑体";
                            newWorkSheet1.get_Range(newWorkSheet1.Cells[1, 1], newWorkSheet1.Cells[1, 1]).HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
                            newWorkSheet1.get_Range(newWorkSheet1.Cells[3, 1], newWorkSheet1.Cells[3, 15]).Interior.ColorIndex = 45;
                            newWorkSheet1.get_Range(newWorkSheet1.Cells[4, 1], newWorkSheet1.Cells[newWorkSheet1.UsedRange.Rows.Count, 1]).Interior.ColorIndex = 6;
                            newWorkSheet1.get_Range(newWorkSheet1.Cells[4, 2], newWorkSheet1.Cells[newWorkSheet1.UsedRange.Rows.Count, 2]).Interior.ColorIndex = 6;
                            newWorkSheet1.get_Range(newWorkSheet1.Cells[4, 4], newWorkSheet1.Cells[newWorkSheet1.UsedRange.Rows.Count, 14]).NumberFormat = "0.0000_ ";
                            xSheet.Rows.AutoFit();
                            xSheet.Columns.AutoFit();
                            newWorksheet.Rows.AutoFit();
                            newWorksheet.Columns.AutoFit();
                            newWorkSheet1.Rows.AutoFit();
                            newWorkSheet1.Columns.AutoFit();
                            newWorksheet.SaveAs(System.Windows.Forms.Application.StartupPath + "\\" + tlVectorControl1.SVGDocument.FileName + "短路计算结果.xls", Excel.XlFileFormat.xlXMLSpreadsheet, null, null, false, false, false, null, null, null);
                            System.Windows.Forms.Clipboard.Clear();
                            result1.Workbooks.Close();
                            result1.Quit();
                            result2.Workbooks.Close();
                            result2.Quit();
                             wFrom.ShowText += "\r\n结果成功!" + System.DateTime.Now.ToString();
                        }

                    }
                    catch (Exception e1)
                    {
                         wFrom.ShowText += "\r\n计算失败,短路数据有问题,请调整后再计算!" + System.DateTime.Now.ToString();
                       // MessageBox.Show("短路数据有问题,请调整后再计算!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
            else if (e.ClickedItem.Text == "区域打印")
            {
                setTJhide();
                PrintHelper ph = new PrintHelper(tlVectorControl1, mapview);
                ph.blshowflag = false;
                frmPrinter dlg = new frmPrinter();
                dlg.printHelper = ph;
                dlg.ShowDialog();
                setTJshow();
                return;
            }
        }
Exemplo n.º 18
0
        /// <summary>
        /// to do
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tsbtnPrint_Click(object sender, EventArgs e)
        {
            try
            {
                if (_SalesOrderReturn != null)
                {
                    DsSalesOrder ds = new DsSalesOrder();
                    ds.ExtendedProperties.Clear();
                    ds.Tables.Clear();

                    ds.ExtendedProperties.Add("ReportTitle", PharmacyClientConfig.Config.Store.Name);
                    ds.ExtendedProperties.Add("Addr", PharmacyClientConfig.Config.Store.Address);

                    string[] tel = PharmacyClientConfig.Config.Store.Tel.Split(',');

                    ds.ExtendedProperties.Add("Tel", tel[0]);
                    Guid   purchaseId   = this.PharmacyDatabaseService.GetSalesOrder(out msg, _SalesOrderReturn.SalesOrderID).PurchaseUnitId;
                    string purchaseName = this.PharmacyDatabaseService.GetPurchaseUnit(out msg, purchaseId).Name;
                    ds.ExtendedProperties.Add("PurchaseUnit", purchaseName);                                     //购买单位
                    ds.ExtendedProperties.Add("OrderCode", this.lblReturnNo.Text);                               //退单号
                    ds.ExtendedProperties.Add("SaleOrderNum", this.lblOrderNo.Text);                             //销售订单号
                    string saleMan = this.PharmacyDatabaseService.GetEmployeeByUserId(out msg, this._SalesOrderReturn.SellerID).Name;
                    ds.ExtendedProperties.Add("Saler", saleMan);                                                 //业务员
                    ds.ExtendedProperties.Add("Date", this._SalesOrderReturn.CreateTime.ToString("yyyy-MM-dd")); //记录建立日期



                    Guid   createrUid = _SalesOrderReturn.CreateUserId;
                    string creater    = this.PharmacyDatabaseService.GetUser(out msg, createrUid).Employee.Name;
                    ds.ExtendedProperties.Add("creater", creater);//开票员

                    Guid   CheckerUid = _SalesOrderReturn.OrderReturnCheckUserID;
                    var    Ch         = this.PharmacyDatabaseService.GetUser(out msg, CheckerUid);
                    string Checker    = " ";
                    if (Ch != null)
                    {
                        Checker = Ch.Employee.Name;
                    }
                    else
                    {
                        var rs = MessageBox.Show("该销售退货单据暂未验收,验收员为空!需要继续打印吗?", "提示", MessageBoxButtons.OKCancel);
                        if (rs != System.Windows.Forms.DialogResult.OK)
                        {
                            return;
                        }
                    }
                    ds.ExtendedProperties.Add("Checker", Checker);//开票员



                    DsSalesOrder.tableDataTable OrderDetailTable = new DsSalesOrder.tableDataTable();
                    foreach (SalesOrderReturnDetail detail in listSalesOrderReturnDetail.Where(r => r.ReturnAmount > 0).ToList())
                    {
                        //string
                        string  part        = detail.productName;
                        string  _partType   = detail.DictionaryDosageCode;
                        string  specialCode = detail.SpecificationCode;
                        string  productUnit = detail.FactoryName;
                        string  Origin      = detail.Origin;
                        string  batchNumber = detail.BatchNumber;
                        string  ValidDate   = detail.OutValidDate.ToString();
                        string  unit        = detail.MeasurementUnit;
                        decimal qty         = detail.ReturnAmount;
                        decimal unitPrice   = detail.ActualUnitPrice;
                        decimal price       = detail.ReturnAmount * detail.ActualUnitPrice;
                        string  Quanlity    = "合格";

                        OrderDetailTable.Rows.Add(new object[] { part, _partType, specialCode, productUnit, Origin, batchNumber, ValidDate, unit, qty, unitPrice, price, Quanlity });

                        OrderDetailTable.AcceptChanges();
                    }

                    ds.Tables.Add(OrderDetailTable);

                    using (PrintHelper printHelper = new PrintHelper("Reports\\RptSalesReturnList.rdlc", ds))
                    {
                        printHelper.Print();
                    }
                }
                else
                {
                    MessageBox.Show("没有数据可以打印!!!", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Log.Error(ex);
            }
        }
Exemplo n.º 19
0
        private void contextMenuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            if (e.ClickedItem.Text == "短路计算")
            {

            }

            if (e.ClickedItem.Text == "区域打印")
            {
                PrintHelper ph = new PrintHelper(tlVectorControl1, mapview);
                frmPrinter dlg = new frmPrinter();
                dlg.printHelper = ph;
                dlg.ShowDialog();
                return;
                ArrayList idlist = new ArrayList();
                ArrayList symlist = new ArrayList();

                SvgDocument _doc = new SvgDocument();

                Graph poly1 = tlVectorControl1.SVGDocument.CurrentElement as Graph;
                if (poly1 == null || poly1.GetAttribute("id") == "svg")
                {
                    return;
                }

                GraphicsPath gr1 = new GraphicsPath();
                gr1.AddPolygon(TLMath.getPolygonPoints(poly1));
                gr1 = (GraphicsPath)poly1.GPath.Clone();
                gr1.Transform((poly1 as IGraph).Transform.Matrix);

                RectangleF ef1 = gr1.GetBounds();
                ef1 = PathFunc.GetBounds(gr1);
                StringBuilder svgtxt = new StringBuilder("<?xml version=\"1.0\" encoding=\"utf-8\"?><svg id=\"svg\" width=\"" + ef1.Width + "\" height=\"" + ef1.Height + "\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns:itop=\"http://www.Itop.com/itop\">");

                XmlNodeList nlist = tlVectorControl1.SVGDocument.GetElementsByTagName("defs");
                if (nlist.Count > 0)
                {
                    XmlNode node = nlist[0];
                    svgtxt.AppendLine(node.OuterXml);
                }
                SvgElementCollection.ISvgElementEnumerator enumerator1 = tlVectorControl1.DrawArea.ElementList.GetEnumerator();// mouseAreaControl.PicturePanel.ElementList.GetEnumerator();
                while (enumerator1.MoveNext())
                {
                    IGraph graph1 = (IGraph)enumerator1.Current;

                    GraphicsPath path1 = (GraphicsPath)graph1.GPath.Clone();
                    if (!graph1.Visible || !graph1.DrawVisible || !graph1.Layer.Visible) continue;

                    GraphicsPath path2 = (GraphicsPath)graph1.GPath.Clone();
                    path2.Transform(graph1.Transform.Matrix);
                    RectangleF ef2 = PathFunc.GetBounds(path2);

                    if (ef1.Contains(ef2) || RectangleF.Intersect(ef1, ef2) != RectangleF.Empty)
                    {
                        SvgElement ele = (SvgElement)graph1;
                        svgtxt.AppendLine(ele.OuterXml);
                        if (graph1 is Use)
                        {
                            string symid = ((XmlElement)graph1).GetAttribute("xlink:href");
                            if (!symlist.Contains(symid))
                            {
                                symlist.Add(symid);
                            }
                        }
                        if (graph1.GetType().FullName == "ItopVector.Core.Figure.Polyline")
                        {
                            string IsLead = ((XmlElement)graph1).GetAttribute("IsLead");
                            if (IsLead != "")
                            {
                                if (ef1.Contains(ef2))
                                {
                                    idlist.Add(graph1.ID);
                                }
                            }
                        }
                    }

                }
                //symlist = ResetList(symlist);
                svgtxt.AppendLine("</svg>");
                _doc.LoadXml(svgtxt.ToString());
                _doc.SvgdataUid = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                frmPrintF pri = new frmPrintF();
                pri.Init(tlVectorControl1.SVGDocument.CurrentElement.ID, tlVectorControl1.SVGDocument.CurrentLayer.ID);
                if (pri.ShowDialog() == DialogResult.OK)
                {
                    frmSubPrint s = new frmSubPrint();
                    s.Vector = tlVectorControl1;
                    s.InitImg(pri.strzt, pri.strgs, pri.pri, idlist, symlist);
                    s.Open(_doc, ef1);
                    s.Show();
                }
            }

            if (e.ClickedItem.Text == "属性")
            {
                //if (!Check())
                //{
                //    return;
                //}
                XmlElement element = tlVectorControl1.SVGDocument.CurrentElement;
                if (element is Use)
                {
                    if (element.GetAttribute("xlink:href").Contains("Substation") || element.GetAttribute("xlink:href").Contains("motherlinenode"))
                    {

                        string str_power = getPower(element.GetAttribute("xlink:href"));

                        PSPDEV pspDev = new PSPDEV();
                        pspDev.EleID = element.GetAttribute("id");
                        pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev);
                        frmSubstation dlg;
                        if (pspDev != null)
                        {
                            dlg = new frmSubstation(pspDev);

                        }
                        else
                        {
                            pspDev = new PSPDEV();
                            pspDev.SUID = Guid.NewGuid().ToString();
                            pspDev.EleID = element.GetAttribute("id");
                            pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            pspDev.Number = -1;
                            pspDev.FirstNode = -1;
                            pspDev.LastNode = -1;
                            pspDev.Type = "Use";
                            if (element.GetAttribute("xlink:href").Contains("Substation"))
                            {
                                pspDev.Lable = "变电站";
                            }
                            else if (element.GetAttribute("xlink:href").Contains("motherlinenode"))
                            {
                                pspDev.Lable = "母线节点";
                            }
                            else if (element.GetAttribute("xlink:href").Contains("Power"))
                            {
                                pspDev.Lable = "电厂";
                            }
                            Services.BaseService.Create<PSPDEV>(pspDev);
                            dlg = new frmSubstation(pspDev);
                        }
                        dlg.Str_Power = str_power;

                        dlg.TYear = tlVectorControl1.SVGDocument.CurrentElement.GetAttribute("year");

                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            if (dlg.Name == null)
                            {
                                MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            PSPDEV pspName = new PSPDEV();
                            pspName.Name = dlg.Name;
                            pspName.Type = "Use";
                            pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                            if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID))
                            {
                                MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            pspDev.Name = dlg.Name;
                            XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']");
                            if (text != null)
                            {
                                (text as Text).InnerText = dlg.Name;
                                (text as Text).SetAttribute("print", dlg.IsTJ ? "no" : "yes");
                            }
                            pspDev.VoltR = Convert.ToDouble(dlg.VoltR);
                            pspDev.ReferenceVolt = Convert.ToDouble(dlg.ReferenceVolt);
                            pspDev.Burthen = Convert.ToDecimal(dlg.Burthen);
                            element.SetAttribute("print", dlg.IsTJ ? "no" : "yes");

                            pspDev.OutP = Convert.ToDouble(dlg.OutP);
                            pspDev.OutQ = Convert.ToDouble(dlg.OutQ); ;
                            //if (pspDev.InPutP==0)
                            pspDev.InPutP = Convert.ToDouble(dlg.InPutP);
                            pspDev.InPutQ = Convert.ToDouble(dlg.InPutQ);
                            pspDev.ReferenceVolt = Convert.ToDouble(dlg.ReferenceVolt);

                            if (dlg.NodeType == "是")
                            {
                                pspDev.NodeType = "0";
                            }
                            else
                            {
                                pspDev.NodeType = "1";
                            }
                            Services.BaseService.Update<PSPDEV>(pspDev);
                            tlVectorControl1.SVGDocument.CurrentElement.SetAttribute("year", dlg.TYear);
                        }
                    }
                    else if (element.GetAttribute("xlink:href").Contains("Power"))
                    {
                        PSPDEV pspDev = new PSPDEV();
                        pspDev.EleID = element.GetAttribute("id");
                        pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev);
                        frmSubstation dlg;
                        if (pspDev != null)
                        {
                            dlg = new frmSubstation(pspDev);
                        }
                        else
                        {
                            pspDev = new PSPDEV();
                            pspDev.SUID = Guid.NewGuid().ToString();
                            pspDev.EleID = element.GetAttribute("id");
                            pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            pspDev.Number = -1;
                            pspDev.FirstNode = -1;
                            pspDev.LastNode = -1;
                            pspDev.Type = "Use";
                            if (element.GetAttribute("xlink:href").Contains("Substation"))
                            {
                                pspDev.Lable = "变电站";
                            }
                            else if (element.GetAttribute("xlink:href").Contains("motherlinenode"))
                            {
                                pspDev.Lable = "母线节点";
                            }
                            else if (element.GetAttribute("xlink:href").Contains("Power"))
                            {
                                pspDev.Lable = "电厂";
                            }
                            Services.BaseService.Create<PSPDEV>(pspDev);
                            dlg = new frmSubstation(pspDev);
                            dlg.TYear = tlVectorControl1.SVGDocument.CurrentElement.GetAttribute("year");
                        }

                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            if (dlg.Name == null)
                            {
                                MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            PSPDEV pspName = new PSPDEV();
                            pspName.Name = dlg.Name;
                            pspName.Type = "Use";
                            pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                            if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID))
                            {
                                MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            pspDev.Name = dlg.Name;
                            XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']");
                            if (text != null)
                            {
                                (text as Text).InnerText = dlg.Name;
                            }
                            pspDev.VoltR = Convert.ToDouble(dlg.VoltR);
                            pspDev.Burthen = Convert.ToDecimal(dlg.Burthen);
                            pspDev.OutP = Convert.ToDouble(dlg.OutP);
                            pspDev.OutQ = Convert.ToDouble(dlg.OutQ);
                            pspDev.InPutP = Convert.ToDouble(dlg.InPutP);
                            pspDev.InPutQ = Convert.ToDouble(dlg.InPutQ);
                            pspDev.ReferenceVolt = Convert.ToDouble(dlg.ReferenceVolt);

                            if (dlg.NodeType == "是")
                            {
                                pspDev.NodeType = "0";
                            }
                            else
                            {
                                pspDev.NodeType = "2";
                            }
                            Services.BaseService.Update<PSPDEV>(pspDev);
                        }
                    }
                    else if (element.GetAttribute("xlink:href").Contains("dynamotorline"))
                    {
                        PSPDEV pspDev = new PSPDEV();
                        pspDev.EleID = element.GetAttribute("id");
                        pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev);
                        frmFadejie dlg;
                        if (pspDev != null)
                        {
                            dlg = new frmFadejie(pspDev, pspDev.SvgUID);
                        }
                        else
                        {
                            pspDev = new PSPDEV();
                            pspDev.SUID = Guid.NewGuid().ToString();
                            pspDev.EleID = element.GetAttribute("id");
                            pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            pspDev.Number = -1;
                            pspDev.FirstNode = -1;
                            pspDev.LastNode = 0;
                            pspDev.Type = "dynamotorline";
                            if (element.GetAttribute("xlink:href").Contains("dynamotorline"))
                            {
                                pspDev.Lable = "发电厂支路";
                            }
                            else if (element.GetAttribute("xlink:href").Contains("gndline"))
                            {
                                pspDev.Lable = "接地支路";
                            }
                            Services.BaseService.Create<PSPDEV>(pspDev);
                            dlg = new frmFadejie(pspDev, pspDev.SvgUID);
                        }
                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            if (dlg.Name == null)
                            {
                                MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            PSPDEV pspName = new PSPDEV();
                            pspName.Name = dlg.Name;
                            pspName.Type = "dynamotorline";
                            pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                            if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID))
                            {
                                MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            pspDev.Name = dlg.Name;
                            XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']");
                            if (text != null)
                            {
                                (text as Text).InnerText = dlg.Name;
                            }
                            pspDev.HuganLine1 = dlg.FirstNodeName;
                            pspDev.HuganLine3 = dlg.SwitchStatus;
                            if (dlg.OutP != "")
                                pspDev.OutP = Convert.ToDouble(dlg.OutP);
                            if (dlg.OutQ != "")
                                pspDev.OutQ = Convert.ToDouble(dlg.OutQ);
                            if (dlg.VoltR != "")
                                pspDev.VoltR = Convert.ToDouble(dlg.VoltR);
                            if (dlg.VoltV != "")
                                pspDev.VoltV = Convert.ToDouble(dlg.VoltV);
                            if (dlg.PositiveTQ != "")
                                pspDev.PositiveTQ = Convert.ToDouble(dlg.PositiveTQ);
                            if (dlg.NegativeTQ != "")
                                pspDev.ZeroTQ = Convert.ToDouble(dlg.NegativeTQ);
                            Services.BaseService.Update<PSPDEV>(pspDev);
                        }
                    }
                    else if (element.GetAttribute("xlink:href").Contains("gndline"))
                    {
                        PSPDEV pspDev = new PSPDEV();
                        pspDev.EleID = element.GetAttribute("id");
                        pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev);
                        frmFadejie dlg;
                        if (pspDev != null)
                        {
                            dlg = new frmFadejie(pspDev, pspDev.SvgUID);
                        }
                        else
                        {
                            pspDev = new PSPDEV();
                            pspDev.SUID = Guid.NewGuid().ToString();
                            pspDev.EleID = element.GetAttribute("id");
                            pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            pspDev.Number = -1;
                            pspDev.FirstNode = -1;
                            pspDev.LastNode = 0;
                            pspDev.Type = "gndline";
                            if (element.GetAttribute("xlink:href").Contains("dynamotorline"))
                            {
                                pspDev.Lable = "发电厂支路";
                            }
                            else if (element.GetAttribute("xlink:href").Contains("gndline"))
                            {
                                pspDev.Lable = "接地支路";
                            }
                            Services.BaseService.Create<PSPDEV>(pspDev);
                            dlg = new frmFadejie(pspDev, pspDev.SvgUID);
                        }
                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            if (dlg.Name == null)
                            {
                                MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            PSPDEV pspName = new PSPDEV();
                            pspName.Name = dlg.Name;
                            pspName.Type = "gndline";
                            pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                            if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID))
                            {
                                MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            pspDev.Name = dlg.Name;
                            XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']");
                            if (text != null)
                            {
                                (text as Text).InnerText = dlg.Name;
                            }
                            pspDev.HuganLine1 = dlg.FirstNodeName;
                            pspDev.HuganLine3 = dlg.SwitchStatus;
                            if (dlg.OutP != "")
                                pspDev.OutP = Convert.ToDouble(dlg.OutP);
                            if (dlg.OutQ != "")
                                pspDev.OutQ = Convert.ToDouble(dlg.OutQ);
                            if (dlg.VoltR != "")
                                pspDev.VoltR = Convert.ToDouble(dlg.VoltR);
                            if (dlg.VoltV != "")
                                pspDev.VoltV = Convert.ToDouble(dlg.VoltV);
                            if (dlg.PositiveTQ != "")
                                pspDev.PositiveTQ = Convert.ToDouble(dlg.PositiveTQ);
                            if (dlg.NegativeTQ != "")
                                pspDev.ZeroTQ = Convert.ToDouble(dlg.NegativeTQ);
                            Services.BaseService.Update<PSPDEV>(pspDev);
                        }
                    }
                    else if (element.GetAttribute("xlink:href").Contains("loadline"))
                    {
                        PSPDEV pspDev = new PSPDEV();
                        pspDev.EleID = element.GetAttribute("id");
                        pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev);
                        frmLoad dlg;
                        if (pspDev != null)
                        {
                            dlg = new frmLoad(pspDev);
                        }
                        else
                        {
                            pspDev = new PSPDEV();
                            pspDev.SUID = Guid.NewGuid().ToString();
                            pspDev.EleID = element.GetAttribute("id");
                            pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            pspDev.Number = -1;
                            pspDev.FirstNode = -1;
                            pspDev.LastNode = 0;
                            pspDev.Type = "loadline";

                            pspDev.Lable = "负荷支路";

                            Services.BaseService.Create<PSPDEV>(pspDev);
                            dlg = new frmLoad(pspDev);
                        }
                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            if (dlg.Name == null)
                            {
                                MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            PSPDEV pspName = new PSPDEV();
                            pspName.Name = dlg.Name;
                            pspName.Type = "loadline";
                            pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                            if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID))
                            {
                                MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            pspDev.Name = dlg.Name;
                            XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']");
                            if (text != null)
                            {
                                (text as Text).InnerText = dlg.Name;
                            }
                            pspDev.HuganLine1 = dlg.FirstNodeName;

                            pspDev.HuganLine3 = dlg.LoadSwitchState;
                            if (dlg.InPutP != "")
                                pspDev.InPutP = Convert.ToDouble(dlg.InPutP);
                            if (dlg.InPutQ != "")
                                pspDev.InPutQ = Convert.ToDouble(dlg.InPutQ);
                            if (dlg.VoltR != "")
                                pspDev.VoltR = Convert.ToDouble(dlg.VoltR);

                            Services.BaseService.Update<PSPDEV>(pspDev);
                        }
                    }
                    else if (element.GetAttribute("xlink:href").Contains("串联电容电抗器"))
                    {
                        PSPDEV pspDev = new PSPDEV();
                        pspDev.EleID = element.GetAttribute("id");
                        pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev);
                        frmCapacity dlg;

                        if (pspDev != null)
                        {
                            dlg = new frmCapacity(pspDev, pspDev.SvgUID);
                            dlg.SetEnable(true);
                        }
                        else
                        {
                            return;
                        }
                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            if (dlg.Name == null)
                            {
                                MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            PSPDEV pspName = new PSPDEV();
                            pspName.Name = dlg.Name;
                            pspName.Type = "串联电容电抗器";
                            pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                            if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID))
                            {
                                MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            pspDev.Name = dlg.Name;
                            XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']");
                            if (text != null)
                            {
                                (text as Text).InnerText = dlg.Name;
                            }
                            pspDev.HuganLine1 = dlg.FirstNodeName;

                            // pspDev.HuganLine2 = dlg.LastNodeName;
                            if (dlg.PositiveTQ != "")
                                pspDev.PositiveTQ = Convert.ToDouble(dlg.PositiveTQ);

                            Services.BaseService.Update<PSPDEV>(pspDev);
                        }
                    }
                    else if (element.GetAttribute("xlink:href").Contains("并联电容电抗器"))
                    {
                        PSPDEV pspDev = new PSPDEV();
                        pspDev.EleID = element.GetAttribute("id");
                        pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev);
                        frmCapacity dlg;

                        if (pspDev != null)
                        {
                            dlg = new frmCapacity(pspDev, pspDev.SvgUID);
                            dlg.SetEnable(false);
                        }
                        else
                        {
                            return;
                        }
                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            if (dlg.Name == null)
                            {
                                MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            PSPDEV pspName = new PSPDEV();
                            pspName.Name = dlg.Name;
                            pspName.Type = "并联电容电抗器";
                            pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                            if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID))
                            {
                                MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            pspDev.Name = dlg.Name;
                            XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']");
                            if (text != null)
                            {
                                (text as Text).InnerText = dlg.Name;
                            }
                            pspDev.HuganLine1 = dlg.FirstNodeName;
                            //pspDev.HuganLine2 = dlg.LastNodeName;
                            if (dlg.PositiveTQ != "")
                                pspDev.PositiveTQ = Convert.ToDouble(dlg.PositiveTQ);

                            Services.BaseService.Update<PSPDEV>(pspDev);
                        }
                    }
                    else if (element.GetAttribute("xlink:href").Contains("transformerthirdzu"))
                    {
                        PSPDEV pspDev = new PSPDEV();
                        pspDev.EleID = element.GetAttribute("id");
                        pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev);
                        frmThridTra dlg;

                        if (pspDev != null)
                        {
                            dlg = new frmThridTra(pspDev, pspDev.SvgUID);
                        }
                        else
                        {
                            return;
                        }
                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            if (dlg.Name == null)
                            {
                                MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            PSPDEV pspName = new PSPDEV();
                            pspName.Name = dlg.Name;
                            pspName.Type = "transformerthirdzu";
                            pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                            if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID))
                            {
                                MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            pspDev.Name = dlg.Name;
                            XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']");
                            if (text != null)
                            {
                                (text as Text).InnerText = dlg.Name;
                            }

                            pspDev.HuganLine1 = dlg.IName;
                            pspDev.HuganLine2 = dlg.JName;
                            pspDev.HuganLine3 = dlg.ISwitchState;
                            pspDev.HuganLine4 = dlg.JSwitchState;
                            pspDev.LineLevel = dlg.IType;
                            pspDev.LineType = dlg.JType;
                            pspDev.LineStatus = dlg.KType;
                            pspDev.KName = dlg.KName;
                            pspDev.KSwitchStatus = dlg.KSwitchState;
                            if (dlg.IK != "")
                            {
                                pspDev.K = Convert.ToDouble(dlg.KK);
                            }
                            if (dlg.JK != "")
                            {
                                pspDev.G = Convert.ToDouble(dlg.JK);
                            }
                            if (dlg.KK != "")
                            {
                                pspDev.BigP = Convert.ToDouble(dlg.KK);
                            }
                            if (dlg.IR != "")
                            {
                                pspDev.HuganTQ1 = Convert.ToDouble(dlg.IR);
                            }
                            if (dlg.JR != "")
                            {
                                pspDev.HuganTQ2 = Convert.ToDouble(dlg.JR);
                            }
                            if (dlg.KR != "")
                            {
                                pspDev.HuganTQ3 = Convert.ToDouble(dlg.KR);
                            }
                            if (dlg.ITQ != "")
                            {
                                pspDev.HuganTQ4 = Convert.ToDouble(dlg.ITQ);
                            }
                            if (dlg.JTQ != "")
                            {
                                pspDev.HuganTQ5 = Convert.ToDouble(dlg.JTQ);
                            }
                            if (dlg.KTQ != "")
                            {
                                pspDev.SmallTQ = Convert.ToDouble(dlg.KTQ);
                            }
                            if (dlg.ZeroTQ != "")
                                pspDev.ZeroTQ = Convert.ToDouble(dlg.ZeroTQ);

                            if (dlg.NeutralNodeTQ != "")
                                pspDev.BigTQ = Convert.ToDouble(dlg.NeutralNodeTQ);
                            Services.BaseService.Update<PSPDEV>(pspDev);
                        }
                    }
                    else if (element.GetAttribute("xlink:href").Contains("transformertwozu"))
                    {
                        PSPDEV pspDev = new PSPDEV();
                        pspDev.EleID = element.GetAttribute("id");
                        pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev);
                        frmTwoTra dlg;

                        if (pspDev != null)
                        {
                            dlg = new frmTwoTra(pspDev, pspDev.SvgUID);
                        }
                        else
                        {
                            return;
                        }
                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            if (dlg.Name == null)
                            {
                                MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            PSPDEV pspName = new PSPDEV();
                            pspName.Name = dlg.Name;
                            pspName.Type = "transformertwozu";
                            pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                            if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID))
                            {
                                MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            pspDev.Name = dlg.Name;
                            XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']");
                            if (text != null)
                            {
                                (text as Text).InnerText = dlg.Name;
                            }

                            pspDev.HuganLine1 = dlg.FirstName;
                            pspDev.HuganLine2 = dlg.LastName;
                            pspDev.HuganLine3 = dlg.FirstSwitchState;
                            pspDev.HuganLine4 = dlg.LastSwitchState;
                            pspDev.LineLevel = dlg.FirstType;
                            pspDev.LineType = dlg.LastType;

                            if (dlg.PositiveR != "")
                            {
                                pspDev.PositiveR = Convert.ToDouble(dlg.PositiveR);
                            }
                            if (dlg.PositiveTQ != "")
                            {
                                pspDev.PositiveTQ = Convert.ToDouble(dlg.PositiveTQ);
                            }

                            if (dlg.ZeroR != "")
                            {
                                pspDev.ZeroR = Convert.ToDouble(dlg.ZeroR);
                            }

                            if (dlg.ZeroTQ != "")
                            {
                                pspDev.ZeroTQ = Convert.ToDouble(dlg.ZeroTQ);
                            }

                            if (dlg.K != "")
                                pspDev.K = Convert.ToDouble(dlg.K);

                            if (dlg.NeutralNodeTQ != "")
                                pspDev.BigTQ = Convert.ToDouble(dlg.NeutralNodeTQ);
                            Services.BaseService.Update<PSPDEV>(pspDev);
                        }
                    }
                    else if (element.GetAttribute("xlink:href").Contains("1/2母联开关"))
                    {
                        PSPDEV pspDev = new PSPDEV();
                        pspDev.EleID = element.GetAttribute("id");
                        pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev);
                        frmMuLian dlg;

                        if (pspDev != null)
                        {
                            dlg = new frmMuLian(pspDev, pspDev.SvgUID);
                        }
                        else
                        {
                            return;
                        }
                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            if (dlg.Name == null)
                            {
                                MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            PSPDEV pspName = new PSPDEV();
                            pspName.Name = dlg.Name;
                            pspName.Type = "1/2母联开关";
                            pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                            if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID))
                            {
                                MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            pspDev.Name = dlg.Name;
                            XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']");
                            if (text != null)
                            {
                                (text as Text).InnerText = dlg.Name;
                            }

                            pspDev.HuganLine1 = dlg.FirstNodeName;
                            pspDev.HuganLine2 = dlg.LastNodeName;
                            pspDev.HuganLine3 = dlg.SwitchStatus;

                            Services.BaseService.Update<PSPDEV>(pspDev);
                        }
                    }
                    else if (element.GetAttribute("xlink:href").Contains("2/3母联开关"))
                    {
                        PSPDEV pspDev = new PSPDEV();
                        pspDev.EleID = element.GetAttribute("id");
                        pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev);
                        frmMuLian2 dlg;

                        if (pspDev != null)
                        {
                            dlg = new frmMuLian2(pspDev, pspDev.SvgUID);
                        }
                        else
                        {
                            return;
                        }
                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            if (dlg.Name == null)
                            {
                                MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            PSPDEV pspName = new PSPDEV();
                            pspName.Name = dlg.Name;
                            pspName.Type = "2/3母联开关";
                            pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                            if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID))
                            {
                                MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            pspDev.Name = dlg.Name;
                            XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']");
                            if (text != null)
                            {
                                (text as Text).InnerText = dlg.Name;
                            }

                            pspDev.HuganLine1 = dlg.INodeName;
                            pspDev.HuganLine2 = dlg.JNodeName;
                            pspDev.HuganLine3 = dlg.ILineName;
                            pspDev.HuganLine4 = dlg.JLineName;
                            pspDev.KName = dlg.ILoadName;
                            pspDev.KSwitchStatus = dlg.JLoadName;
                            pspDev.LineLevel = dlg.SwitchStatus1;
                            pspDev.LineType = dlg.SwitchStatus2;
                            pspDev.LineStatus = dlg.SwitchStatus3;

                            Services.BaseService.Update<PSPDEV>(pspDev);
                        }
                    }

                }
                else if ((element is Polyline) && element.GetAttribute("flag") != "1" && fileType == true)
                {

                    PSPDEV pspDev = new PSPDEV();
                    pspDev.EleID = element.GetAttribute("id");
                    pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                    pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev);

                    frmLinenew dlg2;
                    if (pspDev != null)
                    {
                        dlg2 = new frmLinenew(pspDev);
                        dlg2.derefucelineflag = Reducelineflag;
                    }
                    else
                    {
                        pspDev = new PSPDEV();
                        pspDev.SUID = Guid.NewGuid().ToString();
                        pspDev.EleID = element.GetAttribute("id");
                        pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        pspDev.Number = -1;
                        pspDev.FirstNode = -1;
                        pspDev.LastNode = -1;
                        pspDev.Type = "Polyline";
                        pspDev.Lable = "支路";
                        Services.BaseService.Create<PSPDEV>(pspDev);
                        dlg2 = new frmLinenew(pspDev);
                        dlg2.derefucelineflag = Reducelineflag;
                    }
                    dlg2.TYear = tlVectorControl1.SVGDocument.CurrentElement.GetAttribute("year");
                    dlg2.linevalue = tlVectorControl1.SVGDocument.CurrentElement.GetAttribute("linevalue");   //获得线路投资
                    if (dlg2.ShowDialog() == DialogResult.OK)
                    {
                        if (dlg2.Name == null)
                        {
                            MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                        PSPDEV pspName = new PSPDEV();
                        pspName.Name = dlg2.Name;
                        pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        pspName.Type = "Polyline";
                        IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                        if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID))
                        {
                            MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                        pspDev.Name = dlg2.Name;
                        pspDev.LineLength = Convert.ToDouble(dlg2.LineLength);
                        pspDev.LineR = Convert.ToDouble(dlg2.LineR);
                        pspDev.LineTQ = Convert.ToDouble(dlg2.LineTQ);
                        pspDev.LineGNDC = Convert.ToDouble(dlg2.LineGNDC);
                        pspDev.LineLevel = dlg2.LineLevel;
                        pspDev.ReferenceVolt = Convert.ToDouble(dlg2.ReferenceVolt);
                        pspDev.LineType = dlg2.LineType;
                        pspDev.LineStatus = dlg2.LineStatus;
                        WireCategory wirewire = new WireCategory();
                        wirewire.WireType = dlg2.LineType;
                        if (dlg2.linevalue != "")
                        {
                            pspDev.BigP = Convert.ToDouble(dlg2.linevalue);
                        }
                        if (dlg2.ReferenceVolt != "")
                        {
                            pspDev.ReferenceVolt = Convert.ToDouble(dlg2.ReferenceVolt);
                        }
                        WireCategory wirewire2 = new WireCategory();
                        wirewire2 = (WireCategory)Services.BaseService.GetObject("SelectWireCategoryByKey", wirewire);
                        //if (pspDev.LineR == 0)
                        //    pspDev.LineR = Convert.ToDouble(dlg2.LineLength)*wirewire2.WireR ;
                        //if (pspDev.LineTQ == 0)
                        //    pspDev.LineTQ = Convert.ToDouble(dlg2.LineLength) * wirewire2.WireTQ;
                        //if (pspDev.LineGNDC == 0)
                        //    pspDev.LineGNDC = Convert.ToDouble(dlg2.LineLength) * wirewire2.WireGNDC;
                        if (wirewire2 != null)
                            pspDev.LineChange = (double)wirewire2.WireChange;
                        string tempp = dlg2.LineLev;
                        int tel = tempp.Length;
                        if (tempp.Contains("kV") || tempp.Contains("KV") || tempp.Contains("kv") || tempp.Contains("Kv"))
                        {
                            tempp = tempp.Substring(0, tel - 2);
                        }
                        pspDev.VoltR = Convert.ToDouble(tempp);
                        tlVectorControl1.SVGDocument.CurrentElement.SetAttribute("year", dlg2.TYear);
                        tlVectorControl1.SVGDocument.CurrentElement.SetAttribute("linevalue", dlg2.linevalue);   //获得线路投资

                        //switch (dlg2.LineType)
                        //{
                        //    case "2*LGJ-400":
                        //        {
                        //            if (pspDev.LineR==0)
                        //            pspDev.LineR = Convert.ToDouble(dlg2.LineLength) * 0.04;
                        //            if (pspDev.LineTQ == 0)
                        //            pspDev.LineTQ = Convert.ToDouble(dlg2.LineLength) * 0.303;
                        //            if (pspDev.LineGNDC == 0)
                        //            pspDev.LineGNDC = Convert.ToDouble(dlg2.LineLength) * 17.9;
                        //            pspDev.LineChange = 1690;
                        //        } break;
                        //    case "2*LGJ-300":
                        //        {
                        //            if (pspDev.LineR == 0)
                        //            pspDev.LineR = Convert.ToDouble(dlg2.LineLength) * 0.054;
                        //            if (pspDev.LineTQ == 0)
                        //            pspDev.LineTQ = Convert.ToDouble(dlg2.LineLength) * 0.308;
                        //            if (pspDev.LineGNDC == 0)
                        //            pspDev.LineGNDC = Convert.ToDouble(dlg2.LineLength) * 17.7;
                        //            pspDev.LineChange = 1400;
                        //        } break;
                        //    case "2*LGJ-240":
                        //        {
                        //            if (pspDev.LineR == 0)
                        //            pspDev.LineR = Convert.ToDouble(dlg2.LineLength) * 0.066;
                        //            if (pspDev.LineTQ == 0)
                        //            pspDev.LineTQ = Convert.ToDouble(dlg2.LineLength) * 0.310;
                        //            if (pspDev.LineGNDC == 0)
                        //            pspDev.LineGNDC = Convert.ToDouble(dlg2.LineLength) * 17.5;
                        //            pspDev.LineChange = 1220;
                        //        } break;
                        //    case "LGJ-400":
                        //        {
                        //            if (pspDev.LineR == 0)
                        //            pspDev.LineR = Convert.ToDouble(dlg2.LineLength) * 0.08;
                        //            if (pspDev.LineTQ == 0)
                        //            pspDev.LineTQ = Convert.ToDouble(dlg2.LineLength) * 0.417;
                        //            if (pspDev.LineGNDC == 0)
                        //            pspDev.LineGNDC = Convert.ToDouble(dlg2.LineLength) * 13.2;
                        //            pspDev.LineChange = 845;
                        //        } break;

                        //}
                        Services.BaseService.Update<PSPDEV>(pspDev);
                        Topology2();
                    }
                }
                else if ((element is Polyline) && element.GetAttribute("flag") != "1" && fileType != true)
                {

                    PSPDEV pspDev = new PSPDEV();
                    pspDev.EleID = element.GetAttribute("id");
                    pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                    pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev);

                    frmLine dlg;
                    if (pspDev != null)
                    {
                        dlg = new frmLine(pspDev);
                    }
                    else
                    {
                        pspDev = new PSPDEV();
                        pspDev.SUID = Guid.NewGuid().ToString();
                        pspDev.EleID = element.GetAttribute("id");
                        pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        pspDev.Number = -1;
                        pspDev.FirstNode = -1;
                        pspDev.LastNode = -1;
                        pspDev.Type = "Polyline";
                        pspDev.Lable = "支路";
                        Services.BaseService.Create<PSPDEV>(pspDev);
                        dlg = new frmLine(pspDev);
                    }

                    if (dlg.ShowDialog() == DialogResult.OK)
                    {
                        if (dlg.Name == null)
                        {
                            MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                        PSPDEV pspName = new PSPDEV();
                        pspName.Name = dlg.Name;
                        pspName.Type = "Polyline";
                        pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                        if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID))
                        {
                            MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                        pspDev.Name = dlg.Name;
                        pspDev.LineLength = Convert.ToDouble(dlg.LineLength);
                        pspDev.LineLevel = dlg.LineLevel;
                        pspDev.LineType = dlg.LineType;
                        pspDev.LineStatus = dlg.LineStatus;
                        pspDev.PositiveR = Convert.ToDouble(dlg.PositiveR);
                        pspDev.PositiveTQ = Convert.ToDouble(dlg.PositiveTQ);
                        pspDev.ZeroR = Convert.ToDouble(dlg.ZeroR);
                        pspDev.ZeroTQ = Convert.ToDouble(dlg.ZeroTQ);
                        if (dlg.HuganFirst == "是")
                            pspDev.HuganFirst = 1;
                        else
                            pspDev.HuganFirst = 0;
                        pspDev.HuganLine1 = dlg.HuganLine1;
                        pspDev.HuganLine2 = dlg.HuganLine2;
                        pspDev.HuganLine3 = dlg.HuganLine3;
                        pspDev.HuganLine4 = dlg.HuganLine4;
                        pspDev.HuganTQ1 = Convert.ToDouble(dlg.HuganTQ1);
                        pspDev.HuganTQ2 = Convert.ToDouble(dlg.HuganTQ2);
                        pspDev.HuganTQ3 = Convert.ToDouble(dlg.HuganTQ3);
                        pspDev.HuganTQ4 = Convert.ToDouble(dlg.HuganTQ4);
                        pspDev.HuganTQ5 = Convert.ToDouble(dlg.HuganTQ5);
                        string tempp = dlg.LineLev;
                        int tel = tempp.Length;
                        if (tel == 1)
                            pspDev.VoltR = 0;
                        else
                        {
                            if (tempp.Contains("kV") || tempp.Contains("KV") || tempp.Contains("kv") || tempp.Contains("Kv"))
                            {
                                tempp = tempp.Substring(0, tel - 2);
                            }
                            pspDev.VoltR = Convert.ToDouble(tempp);
                        }
                        //switch (dlg.LineType)
                        //{
                        //    case "2*LGJ-400":
                        //        {
                        //            pspDev.LineR = Convert.ToDouble(dlg.LineLength) * 0.04;
                        //            pspDev.LineTQ = Convert.ToDouble(dlg.LineLength) * 0.303;
                        //            pspDev.LineGNDC = Convert.ToDouble(dlg.LineLength) * 17.9;
                        //            pspDev.LineChange = 1690;
                        //        } break;
                        //    case "2*LGJ-300":
                        //        {
                        //            pspDev.LineR = Convert.ToDouble(dlg.LineLength) * 0.054;
                        //            pspDev.LineTQ = Convert.ToDouble(dlg.LineLength) * 0.308;
                        //            pspDev.LineGNDC = Convert.ToDouble(dlg.LineLength) * 17.7;
                        //            pspDev.LineChange = 1400;
                        //        } break;
                        //    case "2*LGJ-240":
                        //        {
                        //            pspDev.LineR = Convert.ToDouble(dlg.LineLength) * 0.066;
                        //            pspDev.LineTQ = Convert.ToDouble(dlg.LineLength) * 0.310;
                        //            pspDev.LineGNDC = Convert.ToDouble(dlg.LineLength) * 17.5;
                        //            pspDev.LineChange = 1220;
                        //        } break;
                        //    case "LGJ-400":
                        //        {
                        //            pspDev.LineR = Convert.ToDouble(dlg.LineLength) * 0.08;
                        //            pspDev.LineTQ = Convert.ToDouble(dlg.LineLength) * 0.417;
                        //            pspDev.LineGNDC = Convert.ToDouble(dlg.LineLength) * 13.2;
                        //            pspDev.LineChange = 845;
                        //        } break;

                        //}
                        Services.BaseService.Update<PSPDEV>(pspDev);
                        Topology2();
                    }
                }
            }
            tlVectorControl1.Operation = ToolOperation.Select;
            //contextMenuStrip1.Hide();
        }
Exemplo n.º 20
0
 public void Show(ConsumerContext consumerContext)
 {
     ConsumerContext = consumerContext;
     PrintHelper.PrintWrite($"{consumerContext.ConsumerTable}桌,{consumerContext.ConsumerName}先生/女士,客人一共{consumerContext.CumsummerNumber}位", PrintColor);
 }
Exemplo n.º 21
0
 public override void Show()
 {
     PrintHelper.PrintWrite($"{Id}: {Name},推荐指数:★★★★★");
 }
Exemplo n.º 22
0
        private void toolStripButton5_Click(object sender, EventArgs e) //打印
        {
            try
            {
                if (ListPlan != null)
                {
                    DsSalesOrder ds = new DsSalesOrder();; //冲差价对象打印

                    ds.ExtendedProperties.Clear();
                    ds.Tables.Clear();

                    ds.ExtendedProperties.Add("ReportTitle", PharmacyClientConfig.Config.Store.Name);

                    ds.ExtendedProperties.Add("Supplyer", label10.Text);                              //购买单位
                    ds.ExtendedProperties.Add("PurchaseOrderCode", this.label2.Text);                 //采购单号
                    ds.ExtendedProperties.Add("PurchaseRefundOrderCode", ListPlan[0].DocumentNumber); //冲单单号
                    string Creator = PharmacyDatabaseService.GetEmployeeByUserId(out msg, ListPlan[0].CreateUserId).Name;
                    ds.ExtendedProperties.Add("Creator", Creator);
                    ds.ExtendedProperties.Add("RefundMoney", label12.Text); //总差额
                    ds.ExtendedProperties.Add("PurchaseDate", label8.Text); //记录建立日期
                    ds.ExtendedProperties.Add("Date", ListPlan[0].CreateTime.ToLongDateString());
                    DsSalesOrder.tableDataTable OrderDetailTable = new DsSalesOrder.tableDataTable();

                    foreach (DataGridViewRow dr in this.dataGridView1.Rows)
                    {
                        if (Convert.ToDecimal(dr.Cells[13].Value) == 0m)
                        {
                            continue;
                        }
                        string part        = dr.Cells[1].Value.ToString();
                        string _partType   = dr.Cells[2].Value.ToString();
                        string specialCode = dr.Cells[3].Value.ToString();
                        string productUnit = dr.Cells[4].Value.ToString();
                        string Origin      = string.Empty;
                        string batchNumber = dr.Cells[5].Value.ToString();
                        batchNumber = batchNumber.Contains("国药准字")?batchNumber.Substring(4, batchNumber.Length - 4):batchNumber;

                        string  ValidDate = dr.Cells[7].Value.ToString();
                        string  unit      = dr.Cells[8].Value.ToString();
                        decimal qty       = Convert.ToDecimal(dr.Cells[9].Value);
                        decimal unitPrice = Convert.ToDecimal(dr.Cells[12].Value) - Convert.ToDecimal(dr.Cells[10].Value);
                        decimal price     = Convert.ToDecimal(dr.Cells[13].Value);
                        string  Quanlity  = string.Empty;
                        OrderDetailTable.Rows.Add(new object[] { part, _partType, specialCode, productUnit, Origin, batchNumber, ValidDate, unit, qty, unitPrice, price, Quanlity });
                        OrderDetailTable.AcceptChanges();
                    }

                    ds.Tables.Add(OrderDetailTable);

                    using (PrintHelper printHelper = new PrintHelper("Reports\\RptPurchaseOrderRefundList.rdlc", ds))
                    {
                        printHelper.Print();
                    }
                }
                else
                {
                    MessageBox.Show("没有数据可以打印!!!", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Log.Error(ex);
            }
        }
Exemplo n.º 23
0
 static void ThreadAction()
 {
     PrintHelper.PrintCaseStep("Starting by Delegate");
 }
Exemplo n.º 24
0
 protected virtual void OnShowPrintPreview(string documentName)
 {
     PrintHelper.ShowPrintPreviewDialog(LayoutHelper.FindParentObject <Window>(this), (IPrintableControl)TreeListControl.View, documentName);
 }
Exemplo n.º 25
0
        public void Unneccessary_dependsOn_statements_are_removed_for_modules()
        {
            var bicepFile = @"
resource resA 'My.Rp/resA@2020-01-01' = {
  name: 'resA'
}

module modB 'modb.bicep' = {
  name: 'modB'
  params: {
    resA: resA.name
  }
  dependsOn: [
    resA
  ]
}

var varA = resA.name
var varB = {
  resA: varA
  modB: modB.name
}

module modC 'modC.bicep' = {
  name: 'modC'
  params: {
    resA: varB
  }
  dependsOn: [
    resA
    modB
  ]
}";

            var(_, _, compilation) = CompilationHelper.Compile(("main.bicep", bicepFile));
            var rewriter = new DependsOnRemovalRewriter(compilation.GetEntrypointSemanticModel());

            var newProgramSyntax = rewriter.Rewrite(compilation.SyntaxTreeGrouping.EntryPoint.ProgramSyntax);

            PrintHelper.PrettyPrint(newProgramSyntax).Should().Be(
                @"resource resA 'My.Rp/resA@2020-01-01' = {
  name: 'resA'
}

module modB 'modb.bicep' = {
  name: 'modB'
  params: {
    resA: resA.name
  }
}

var varA = resA.name
var varB = {
  resA: varA
  modB: modB.name
}

module modC 'modC.bicep' = {
  name: 'modC'
  params: {
    resA: varB
  }
}");
        }
Exemplo n.º 26
0
        private void PrintDocument_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            var top  = 10;
            var left = 10;
            var w    = e.PageSettings.Bounds.Width - 20;
            var h    = e.PageSettings.Bounds.Height;
            var g    = e.Graphics;

            top += g.printInBox(left, top, w, "Transport Management System", PrintHelper.f_20_bold, System.Drawing.StringAlignment.Center);
            top += g.printInBox(left, top, w, "Khanar 1 Sunsari", PrintHelper.f_10_bold, System.Drawing.StringAlignment.Center);
            top += g.printInBox(left, top, w, "9816985815", PrintHelper.f_7, System.Drawing.StringAlignment.Center);
            top += g.printInBox(left, top, w, "Invoice No:" + Trip.id.ToString(), PrintHelper.f_7_bold, System.Drawing.StringAlignment.Near);
            top += g.printInBox(left, top, w, "Staff Name:" + Trip.vehicle.vehicle_no, PrintHelper.f_8, System.Drawing.StringAlignment.Near);
            top += g.printInBox(left, top, w, "Staff Name:" + Trip.vehicle.staff.name, PrintHelper.f_8, System.Drawing.StringAlignment.Near);
            top += g.printInBox(left, top, w, "Date:" + Trip.date.ToString(), PrintHelper.f_7, System.Drawing.StringAlignment.Far);
            top += 10;
            g.DrawLine(Pens.Black, left, top, left + w, top);
            top += 5;
            var temptop = top;

            top += PrintHelper.drawtext(g,
                                        new string[] {
                "S.N",
                "Sender Name&Phone",
                "Receiver Name&Phone",
                "Item Name",
                "From",
                "To",
                "Deliver Place",
                "qty",
                "weight",
                "c.Amount"
            },
                                        new double[]
            {
                0, 0.03, 0.15, 0.15, 0.16, 0.12, 0.12, 0.12, .05, 0.05, 0.05
            }, top, w - 10, PrintHelper.f_7, Brushes.Black
                                        ) + 5;
            var bis = DB.Instance.tripitems.Where(o => o.bill_id == Trip.id).ToList();

            for (int i = offset; i < bis.Count; i++)
            {
                if (top + 50 > h - 20)
                {
                    g.drawlines(new double[]
                    {
                        0, 0.03, 0.15, 0.15, 0.16, 0.12, 0.12, 0.12, .05, 0.05, 0.05
                    },
                                temptop, w - 10, top - temptop, left);
                    offset         = i;
                    e.HasMorePages = true;
                    return;
                }
                g.DrawLine(Pens.Black, left, top, left + w, top);
                var item     = bis.ElementAt(i);
                var itemname = DB.Instance.orderitemlists.Find(item.item_id).itemname;
                top += PrintHelper.drawtext(g,
                                            new string[] {
                    (i + 1).ToString(),
                    item.sender_name + "\n" + item.sender_phone,
                    item.receivername + "\n" + item.receiverphone,
                    itemname,
                    item.location.name,
                    item.location1.name,
                    item.deliver_place.ToString(),
                    item.quantity.Value.ToString("0.###"),
                    item.weight.Value.ToString("0.###") + " " + item.unit.ToString(),
                    item.amount.Value.ToString("0.##")
                },
                                            new double[]
                {
                    0, 0.03, 0.15, 0.15, 0.16, 0.12, 0.12, 0.12, .05, 0.05, 0.05
                }, top, w - 10, PrintHelper.f_7, Brushes.Black
                                            ) + 5;
            }

            g.drawlines(new double[]
            {
                0, 0.03, 0.15, 0.15, 0.16, 0.12, 0.12, 0.12, .05, 0.05, 0.05
            },
                        temptop, w - 10, top - temptop, left);
        }
Exemplo n.º 27
0
        public void Loop_inside_a_loop()
        {
            var bicepFile = @"
var vmNames = [
  'vm1'
  'vm2'
]

var dataDisks = [
  {
    lun: 0
    diskSizeGb: 1023
  }
  {
    lun: 1
    diskSizeGb: 1023
  }
]

resource vmsLoop 'Microsoft.Compute/virtualMachines@2020-06-01' = [for i in range(0, length(vmNames)): {
  name: '${vmPrefix}-${vmNames[i]}'
  location: resourceGroup().location
  properties: {
    hardwareProfile: {
      vmSize: vmSize
    }
    osProfile: {
      computerName: '${vmPrefix}-${vmNames[i]}'
      adminUsername: '******'
      adminPassword: adminPassword
    }
    storageProfile: {
      dataDisks: [for j in range(0, length(dataDisks)): {
        diskSizeGB: dataDisks[j].diskSizeGb
        lun: dataDisks[j].lun
        createOption: 'Empty'
      }]
    }
  }
}]
";

            var(_, _, compilation) = CompilationHelper.Compile(("main.bicep", bicepFile));
            var rewriter = new ForExpressionSimplifierRewriter(compilation.GetEntrypointSemanticModel());

            var newProgramSyntax = rewriter.Rewrite(compilation.SourceFileGrouping.EntryPoint.ProgramSyntax);

            PrintHelper.PrintAndCheckForParseErrors(newProgramSyntax).Should().Be(
                @"var vmNames = [
  'vm1'
  'vm2'
]

var dataDisks = [
  {
    lun: 0
    diskSizeGb: 1023
  }
  {
    lun: 1
    diskSizeGb: 1023
  }
]

resource vmsLoop 'Microsoft.Compute/virtualMachines@2020-06-01' = [for item_1 in vmNames: {
  name: '${vmPrefix}-${item_1}'
  location: resourceGroup().location
  properties: {
    hardwareProfile: {
      vmSize: vmSize
    }
    osProfile: {
      computerName: '${vmPrefix}-${item_1}'
      adminUsername: '******'
      adminPassword: adminPassword
    }
    storageProfile: {
      dataDisks: [for item in dataDisks: {
        diskSizeGB: item.diskSizeGb
        lun: item.lun
        createOption: 'Empty'
      }]
    }
  }
}]");
        }
Exemplo n.º 28
0
        public static void Imprimir(classes.Entities.caja.DeclaracionValores dv, int idx)
        {
            PrintHelper printer = new PrintHelper();

            printer.PrintCLRF();
            printer.PrintText(string.Format("EID:    {0} - {1}", dv.Empresa_Id, dv.Empresa));
            printer.PrintText(string.Format("ESTID:    {0}", Sesion.Estacion_ID));
            printer.PrintText(string.Format("SID:   {0}", Sesion.Sesion_ID));
            printer.PrintText(string.Format("F:   {0:yyyy-MM-dd}     H:    {0:HH:mm:ss}", DateTime.Now));
            //printer.PrintText(string.Format("SID:   {0}", "35852"));
            // printer.PrintText("F:   2018-04-04    H:    21:10:20.917 ");
            printer.PrintCLRF();

            //Billetes
            printer.PrintText("Billetes");
            DataTable dtable = new DataTable();

            dtable.Columns.Add("Denominacion", typeof(System.String));
            dtable.Columns.Add("Cantidad", typeof(System.String));
            dtable.Columns.Add("Monto", typeof(System.String));
            foreach (classes.Entities.caja.DetalleDeclaracion dd in dv.Billetes)
            {
                dtable.Rows.Add(dd.Descripcion_Denominacion, dd.Cantidad, string.Format("{0:C2}", dd.Monto));
            }
            printer.PrintTable(dtable);
            printer.PrintText(string.Format("Tot Billetes:   {0}", dv.TotalBilletes));
            printer.PrintCLRF();

            //Monedas
            printer.PrintText("Monedas");
            dtable = new DataTable();
            dtable.Columns.Add("Denominacion", typeof(System.String));
            dtable.Columns.Add("Cantidad", typeof(System.String));
            dtable.Columns.Add("Monto", typeof(System.String));
            foreach (classes.Entities.caja.DetalleDeclaracion dd in dv.Monedas)
            {
                dtable.Rows.Add(dd.Descripcion_Denominacion, dd.Cantidad, string.Format("{0:C2}", dd.Monto));
            }
            printer.PrintTable(dtable);
            printer.PrintText(string.Format("Tot Monedas:   {0}", dv.TotalMonedas));
            printer.PrintCLRF();

            printer.PrintText(string.Format("Tot Ingresos Efectivo:   {0}", dv.TotalEfectivo));
            if (dv.Empresa_Id == 3)
            {
                printer.PrintText(string.Format("Tot Vouchers:   {0}", dv.TotalVouchers));
            }
            printer.PrintText(string.Format("Tot Vales Prepagado:   {0}", dv.TotalValesPrepagados));
            printer.PrintText(string.Format("Tot Vales Empresariales:   {0}", dv.TotalValesEmpresariales));
            printer.PrintText(string.Format("Tot Ingresos Declarados:   {0}", dv.TotalIngresosDeclarados));
            //printer.PrintText(string.Format("Tot Efectivo Sesión:   {0}", dv.TotalEfectivoSesion));
            printer.PrintText(string.Format("Tot Ingresos en Sistema:   {0}", dv.TotalIngresosSesion));

            if (dv.Incidencia.Length > 0)
            {
                printer.PrintLine();
                printer.PrintText(string.Format("Incidencia: {0}", dv.Incidencia));
            }
            printer.PrintLine();
            if (dv.Observaciones != null && dv.Observaciones.Trim().Length > 0)
            {
                printer.PrintText(string.Format("Observaciones: {0}", dv.Observaciones));
                printer.PrintText("================================");
                printer.PrintLine();
            }


            string sreferencia = "";
            string cBancaria   = "";

            printer.PrintText("================================");
            List <SICASv20.Entities.Empresas_Cuentas> lempresas = SICASv20.Entities.Empresas_Cuentas.Read(dv.Empresa_Id, (!dv.EslaUltima ? true : false));

            if (lempresas.Count > 0)
            {
                cBancaria = lempresas[0].CuentaBancaria;

                // Sesion.Caja_ID.Value.ToString().PadLeft(2) + idx.ToString() + string.Format("{0:MMdd}", DateTime.Now);


                if (lempresas[0].Empresa_ID == 601 & lempresas[0].CuentaBancaria == "009-07800-001-2" & lempresas[0].Cuenta_ID == 1)
                {
                    sreferencia = lempresas[0].Referencia.ToString();//"1111127";//lempresas[0].Referencia.ToString();
                }
                else
                {
                    sreferencia = Sesion.Caja_ID.Value.ToString().PadLeft(2) + idx.ToString() + string.Format("{0:MMdd}", DateTime.Now);
                }
            }

            //if (sreferencia == "")
            //{ sreferencia = Sesion.Caja_ID.Value.ToString().PadLeft(2) + idx.ToString() + string.Format("{0:MMdd}", DateTime.Now); }

            printer.PrintText(string.Format("Cuenta Bancaria: {0}", cBancaria));
            printer.PrintText(string.Format("Referencia Bancaria: {0}", sreferencia));

            // if (lempresas[0].Empresa_ID != 601 & lempresas[0].CuentaBancaria != "009-07800-001-2")
            //{
            // sreferencia = Sesion.Caja_ID.Value.ToString().PadLeft(2) + idx.ToString() + string.Format("{0:MMdd}", DateTime.Now.AddDays(-2));
            //}
            //else
            //{

            //    sreferencia = lempresas[0].Referencia.ToString();// "1111127";// Sesion.Caja_ID.Value.ToString().PadLeft(2) + idx.ToString() + string.Format("{0:MMdd}", DateTime.Now);

            //}



            printer.PrintText("================================");
            printer.PrintLine();

            /// para Impresion de Detalle por Zona. Aeropuerto
            if (dv.Empresa_Id == 3 && dv.ResumenZonasApto.Count > 0)
            {
                printer.Width = 350;
                printer.PrintLine();
                printer.PrintText("================================");
                printer.PrintText("Resumen por Zona");
                printer.PrintText("================================");
                //printer.PrintText("     " + "  Servicios  " + "     |       " + "    Monto   " + "      |       " + "Zona");
                //foreach (SICASv20.classes.Entities.caja.ResumenZonasApto rz in dv.ResumenZonasApto)
                //{
                //    printer.PrintText("     " + rz.Cantidad + "     |       " + string.Format("{0:C2}", rz.Monto) + "      |       " + rz.Zona);
                //}
                DataTable dtableZonas = new DataTable();
                dtableZonas.Columns.Add("Zona", typeof(System.String));
                dtableZonas.Columns.Add("Cantidad", typeof(System.String));
                dtableZonas.Columns.Add("Monto", typeof(System.String));
                foreach (classes.Entities.caja.ResumenZonasApto dd in dv.ResumenZonasApto)
                {
                    dtableZonas.Rows.Add(dd.Zona, dd.Cantidad, string.Format("{0:C2}", dd.Monto));
                }
                printer.PrintTable(dtableZonas);
            }
            printer.Width = 250;
            printer.Print();

            if (dv.EslaUltima && SICASv20.Entities.Estaciones.GetEsFranquicia(Sesion.Estacion_ID))
            {
                PrintHelper p1 = new PrintHelper();
                Dictionary <string, double> empresas = SICASv20.classes.Interfaces.DeclaracionValores.GetIngresosEfectivoOtrasCuentas(Sesion.Sesion_ID);
                foreach (string empresa in empresas.Keys)
                {
                    p1.PrintCLRF();
                    p1.PrintText("================================");
                    p1.PrintText("Ingresos Efectivo Otras Cuentas");
                    p1.PrintText(string.Format("ESTID:    {0}", Sesion.Estacion_ID));
                    p1.PrintText(string.Format("SID:   {0}", Sesion.Sesion_ID));
                    p1.PrintText(string.Format("F:   {0:yyyy-MM-dd}     H:    {0:HH:mm:ss}", DateTime.Now));
                    p1.PrintText(string.Format("{0}: {1}", empresa, empresas[empresa]));
                    p1.PrintText("================================");
                    p1.PrintLine();
                    p1.Print();
                }
            }
        }
Exemplo n.º 29
0
 public PrintResult Send(PrintOrderData data, PrintConfigData configData)
 {
     return(PrintHelper.Send(data, configData));
 }
Exemplo n.º 30
0
 protected override void OnAbort()
 {
     PrintHelper.Print(this, "OnAbort");
     this._innerChannel.Abort();
 }
Exemplo n.º 31
0
 public void PrintSelected()
 {
     var toPrints = Entities.Cast<WarehouseOut>().Where(o => o.IsSelected);
     foreach (var wo in toPrints)
     {
         var reportVM = new PrintWarehouseOutTemplateVM("出库", wo.Id);
         var dataSources = new Dictionary<string, object> { { "Header", reportVM.HeaderList }, { "Lines", reportVM.LineList } };
         var printHelper = new PrintHelper(dataSources, reportVM.PathName, null, true);
         printHelper.Run();
     }
 }
Exemplo n.º 32
0
 public void Print(String zplString)
 {
     PrintHelper.SendStringToPrinter(this.defaultPrinter, zplString);
 }
Exemplo n.º 33
0
        private void contextMenuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            if (e.ClickedItem.Text == "短路计算")
            {
                int tuxing = 0;
                int baobiao = 0;
                PSPDEV pspDuanlu = new PSPDEV();
                pspDuanlu.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                XmlElement element = tlVectorControl1.SVGDocument.CurrentElement;
                pspDuanlu.EleID = element.GetAttribute("id");
                pspDuanlu = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDuanlu);
                if (pspDuanlu == null)
                    return;
                if (pspDuanlu.Type == "Polyline" && pspDuanlu.Lable != "支路")
                    return;
                frmDuanlu dudu = new frmDuanlu(pspDuanlu);
                PSPDEV Duanlu = new PSPDEV();
                Duanlu.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;

                int n11 = 0, n2 = 0, n3 = 0, n4 = 0;

                if (dudu.ShowDialog() == DialogResult.OK)
                {
                    //int bigsmall=Convert.ToInt32(dudu.DuanluBigsmall);
                    CheckDL();
                    string nodeType;
                    if (dudu.DuanluBaobiao == "是")
                        baobiao = 1;
                    if (dudu.DuanluTuxing == "所有故障点短路电流")
                        tuxing = 1;
                    if (dudu.DuanluTuxing == "指定故障点短路电流")
                        tuxing = 2;
                    //Duanlu.Name = dudu.DuanluPoint;
                    //Duanlu = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByName", Duanlu);
                    n4 = Convert.ToInt32(dudu.hscool);
                    nodeType = pspDuanlu.Type;
                    if (pspDuanlu.Type == "Use")
                    {
                        n11 = 0;
                        n2 = pspDuanlu.Number;
                        switch (dudu.DuanluType)
                        {
                            case "单相接地":
                                n3 = 1;
                                break;

                            case "两相接地":
                                n3 = 3;
                                break;
                            case "两相故障":
                                n3 = 2;
                                break;
                            case "三相故障":
                                n3 = 0;
                                break;
                            default:
                                n3 = 1;
                                break;
                        }
                        string dlr = null;
                        dlr = "0" + " " + n3.ToString() + " " + pspDuanlu.Number + " " + "-1" + " " + "-1" + n4;

                        if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\fault.txt"))
                        {
                            File.Delete(System.Windows.Forms.Application.StartupPath + "\\fault.txt");
                        }

                        FileStream VK = new FileStream((System.Windows.Forms.Application.StartupPath + "\\fault.txt"), FileMode.OpenOrCreate);
                        StreamWriter str11 = new StreamWriter(VK);
                        str11.Write(dlr);
                        str11.Close();
                        n4 = 0;

                    }
                    else if (pspDuanlu.Type == "Polyline")
                    {
                        //n11 = pspDuanlu.FirstNode;
                        //n2 = pspDuanlu.LastNode;
                        n11 = pspDuanlu.Number;
                        n2 = n11;
                        switch (dudu.DuanluType)
                        {
                            case "单相接地":
                                n3 = 1;
                                break;

                            case "两相接地":
                                n3 = 3;
                                break;
                            case "两相故障":
                                n3 = 2;
                                break;
                            case "三相故障":
                                n3 = 0;
                                break;
                            default:
                                n3 = 1;
                                break;
                        }
                        string dlr = null;
                        dlr = "0" + " " + n3.ToString() + " " + pspDuanlu.Number + " " + pspDuanlu.FirstNode + " " + pspDuanlu.LastNode + " " + n4;

                        if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\fault.txt"))
                        {
                            File.Delete(System.Windows.Forms.Application.StartupPath + "\\fault.txt");
                        }

                        FileStream VK = new FileStream((System.Windows.Forms.Application.StartupPath + "\\fault.txt"), FileMode.OpenOrCreate);
                        StreamWriter str11 = new StreamWriter(VK);
                        str11.Write(dlr);
                        str11.Close();
                    }
                    else
                    {
                        return;
                    }
                    XmlNodeList list = tlVectorControl1.SVGDocument.SelectNodes("svg/*[@flag='" + "1" + "']");
                    foreach (XmlNode node in list)
                    {
                        SvgElement elementde = node as SvgElement;
                        tlVectorControl1.SVGDocument.CurrentElement = elementde;
                        tlVectorControl1.Delete();
                    }
                    shortcir shortCutCal = new shortcir();
                    shortCutCal.Show_shortcir(0,0);

                    string duanResult = null;
                    duanResult += "短路电流简表" + "\r\n" + "\r\n";
                    if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\ShortcuitI.txt"))
                    {
                    }
                    else
                    {
                        return;
                    }
                    FileStream shorcuit = new FileStream(System.Windows.Forms.Application.StartupPath + "\\ShortcuitI.txt", FileMode.Open);
                    StreamReader readLineGU = new StreamReader(shorcuit, System.Text.Encoding.Default);
                    string strLineGU;
                    string[] arrayGU;
                    char[] charSplitGU = new char[] { ' ' };
                    strLineGU = readLineGU.ReadLine();

                    while (strLineGU != null)
                    {
                        arrayGU = strLineGU.Split(charSplitGU);
                        int i = 0;
                        string[] dev = new string[9];
                        dev.Initialize();
                        foreach (string str in arrayGU)
                        {
                            if (str != "")
                            {
                                dev[i++] = str;
                            }
                        }
                        if (tuxing == 2)
                        {
                            PSPDEV CR = new PSPDEV();
                            CR.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            CR.Name = dev[1];
                            CR.Type = nodeType;
                            CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByName", CR);
                            if (CR != null)
                            {
                                if (CR.Type != "Polyline")
                                {
                                    XmlElement elementdl = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@id='" + CR.EleID + "']") as XmlElement;

                                    if (elementdl != null)
                                    {
                                        RectangleF bound = ((IGraph)elementdl).GetBounds();
                                        XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                                        n1.SetAttribute("x", Convert.ToString(bound.X));
                                        n1.SetAttribute("y", Convert.ToString(bound.Y - 20));
                                        n1.InnerText = (Convert.ToDouble(dev[3])).ToString("N4");
                                        n1.SetAttribute("layer", SvgDocument.currentLayer);
                                        n1.SetAttribute("flag", "1");
                                        tlVectorControl1.SVGDocument.RootElement.AppendChild(n1);
                                        tlVectorControl1.Operation = ToolOperation.Select;
                                        tlVectorControl1.Refresh();
                                    }
                                }
                                else
                                {
                                    XmlElement elementdl = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@id='" + CR.EleID + "']") as XmlElement;

                                    if (elementdl != null)
                                    {
                                        PointF[] t = ((Polyline)elementdl).Points;

                                        PointF[] t2 = ((Polyline)elementdl).FirstTwoPoint;
                                        t = t2;
                                        PointF midt = new PointF((float)((t2[0].X + t2[1].X) / 2), (float)((t2[0].Y + t2[1].Y) / 2));
                                        float angel = 0f;
                                        angel = (float)(180 * Math.Atan2((t2[1].Y - t2[0].Y), (t2[1].X - t2[0].X)) / Math.PI);

                                        string l3 = Convert.ToString(midt.X);
                                        string l4 = Convert.ToString(midt.Y);

                                        string tran = ((Polyline)elementdl).Transform.ToString();

                                        PointF center = new PointF((float)(t[0].X + (t[1].X - t[0].X) / 2), (float)(t[0].Y + (t[1].Y - t[0].Y) / 2));
                                        XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                                        XmlElement n2dl = tlVectorControl1.SVGDocument.CreateElement("polyline") as Polyline;
                                        PointF pStart = new PointF(center.X + (float)(15 * Math.Sin((angel) * Math.PI / 180)), center.Y - (float)(15 * Math.Cos((angel) * Math.PI / 180)));
                                        PSPDEV psp = new PSPDEV();
                                        psp.FirstNode = CR.FirstNode;
                                        psp.LastNode = CR.LastNode;
                                        psp.SvgUID = CR.SvgUID;
                                        PSPDEV tempss = new PSPDEV();
                                        IList listParallel = Services.BaseService.GetList("SelectPSPDEVBySvgUIDandFirstOrLastNode", psp);
                                        foreach (PSPDEV devP in listParallel)
                                        {
                                            if ((angel > 10 && angel < 90) || (angel < 0 && Math.Abs(angel) < 90) || (angel > 180 && angel < 350))
                                            {
                                                if (((devP.X1) > (CR.X1)))
                                                {
                                                    pStart = new PointF(center.X - (float)(23 * Math.Sin((angel) * Math.PI / 180)), center.Y + (float)(23 * Math.Cos((angel) * Math.PI / 180)));

                                                }
                                            }
                                            else if ((angel >= 0 && angel <= 10) || (angel >= 350 && angel <= 360) || (angel < 0 && Math.Abs(angel) <= 90))
                                            {
                                                if (((devP.Y1) > (CR.Y1)))
                                                {
                                                    pStart = new PointF(center.X - (float)(23 * Math.Sin((angel) * Math.PI / 180)), center.Y + (float)(23 * Math.Cos((angel) * Math.PI / 180)));

                                                }
                                            }
                                            else if ((angel < 0 && Math.Abs(angel) > 90) || (angel >= 90 && angel <= 180))
                                            {
                                                if (((devP.Y1) > (CR.Y1)))
                                                {
                                                    pStart = new PointF(center.X - (float)(7 * Math.Sin((angel) * Math.PI / 180)), center.Y + (float)(7 * Math.Cos((angel) * Math.PI / 180)));

                                                }
                                            }
                                        }

                                        PointF newp1 = new PointF(t[0].X + (t[1].X - t[0].X) / 2 - (float)(15 * Math.Sin(angel)), t[0].Y + (t[1].Y - t[0].Y) / 2 - (float)(15 * Math.Cos(angel)));

                                        n1.SetAttribute("x", Convert.ToString(pStart.X));
                                        n1.SetAttribute("y", Convert.ToString(pStart.Y));

                                        //if (Convert.ToDouble(dev[4]) >= 0)
                                        //{
                                        n1.InnerText = (Math.Abs(Convert.ToDouble(dev[3]))).ToString("N4");
                                        //}
                                        //else
                                        //{
                                        //    n1.InnerText = (Math.Abs(Convert.ToDouble(dev[3]))).ToString("N4");
                                        //}
                                        n1.SetAttribute("layer", SvgDocument.currentLayer);
                                        n1.SetAttribute("flag", "1");

                                        //if (Convert.ToDouble(dev[5]) == 1)
                                        //    n1.SetAttribute("stroke", "#FF0000");

                                        PointF p1 = new PointF(midt.X - (float)(10 * Math.Cos((angel + 25) * Math.PI / 180)), midt.Y - (float)(10 * Math.Sin((angel + 25) * Math.PI / 180)));
                                        PointF p2 = new PointF(midt.X - (float)(10 * Math.Cos((angel + 335) * Math.PI / 180)), midt.Y - (float)(10 * Math.Sin((angel + 335) * Math.PI / 180)));

                                        if (Convert.ToDouble(dev[3]) < 0)
                                        {
                                            p1 = new PointF(midt.X - (float)(10 * Math.Cos((angel + 155) * Math.PI / 180)), midt.Y - (float)(10 * Math.Sin((angel + 155) * Math.PI / 180)));
                                            p2 = new PointF(midt.X - (float)(10 * Math.Cos((angel + 205) * Math.PI / 180)), midt.Y - (float)(10 * Math.Sin((angel + 205) * Math.PI / 180)));
                                        }

                                        string l1 = Convert.ToString(p1.X);
                                        string l2 = Convert.ToString(p1.Y);
                                        string l5 = Convert.ToString(p2.X);
                                        string l6 = Convert.ToString(p2.Y);

                                        tlVectorControl1.SVGDocument.RootElement.AppendChild(n1);
                                        tlVectorControl1.Operation = ToolOperation.Select;

                                        tlVectorControl1.SVGDocument.CurrentElement = n1 as SvgElement;

                                        RectangleF ttt = ((Polyline)elementdl).GetBounds();

                                        tlVectorControl1.RotateSelection(angel, pStart);
                                        if (Math.Abs(angel) > 90)
                                            tlVectorControl1.RotateSelection(180, pStart);
                                        PointF newp = new PointF(center.X + 10, center.Y + 10);

                                        tlVectorControl1.Refresh();

                                    }
                                }
                            }

                        }
                        duanResult += dev[0] + "," + dev[1] + "," + dev[3] + "\r\n";
                        strLineGU = readLineGU.ReadLine();
                    }

                    string dianYaResult = null;
                    dianYaResult += "母线电压结果" + "\r\n" + "\r\n";
                    if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Sxdianya.txt"))
                    {
                    }
                    else
                    {
                        return;
                    }
                    FileStream dianYa = new FileStream(System.Windows.Forms.Application.StartupPath + "\\Sxdianya.txt", FileMode.Open);
                    StreamReader readLineDY = new StreamReader(dianYa, System.Text.Encoding.Default);
                    string strLineDY;
                    string[] arrayDY;
                    char[] charSplitDY = new char[] { ' ' };
                    strLineDY = readLineDY.ReadLine();
                    while (strLineDY != null)
                    {
                        arrayDY = strLineDY.Split(charSplitDY);
                        int i = 0;
                        string[] dev = new string[14];
                        dev.Initialize();
                        foreach (string str in arrayDY)
                        {
                            if (str != "")
                            {
                                dev[i++] = str;
                            }
                        }
                        PSPDEV CR = new PSPDEV();
                        CR.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        CR.Name = dev[1];
                        CR.Type = nodeType;
                        CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByName", CR);
                        if (tuxing == 1)
                        {
                            XmlElement elementdl = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@id='" + CR.EleID + "']") as XmlElement;

                            if (elementdl != null)
                            {
                                RectangleF bound = ((IGraph)elementdl).GetBounds();
                                XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                                XmlElement n22 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                                XmlElement n33 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                                n1.SetAttribute("x", Convert.ToString(bound.X));
                                n1.SetAttribute("y", Convert.ToString(bound.Y - 60));
                                n1.InnerText = "A相:" + (Convert.ToDouble(dev[8])).ToString("N4") + "Kv/" + (Convert.ToDouble(dev[9])).ToString("N4") + "°";
                                n1.SetAttribute("layer", SvgDocument.currentLayer);
                                n1.SetAttribute("flag", "1");
                                tlVectorControl1.SVGDocument.RootElement.AppendChild(n1);
                                tlVectorControl1.Operation = ToolOperation.Select;
                                tlVectorControl1.Refresh();
                                n22.SetAttribute("x", Convert.ToString(bound.X));
                                n22.SetAttribute("y", Convert.ToString(bound.Y - 40));
                                n22.InnerText = "B相:" + (Convert.ToDouble(dev[10])).ToString("N4") + "Kv/" + (Convert.ToDouble(dev[11])).ToString("N4") + "°";
                                n22.SetAttribute("layer", SvgDocument.currentLayer);
                                n22.SetAttribute("flag", "1");
                                tlVectorControl1.SVGDocument.RootElement.AppendChild(n22);
                                tlVectorControl1.Operation = ToolOperation.Select;
                                tlVectorControl1.Refresh();
                                n33.SetAttribute("x", Convert.ToString(bound.X));
                                n33.SetAttribute("y", Convert.ToString(bound.Y - 20));
                                n33.InnerText = "C相:" + (Convert.ToDouble(dev[12])).ToString("N4") + "Kv/" + (Convert.ToDouble(dev[13])).ToString("N4") + "°";
                                n33.SetAttribute("layer", SvgDocument.currentLayer);
                                n33.SetAttribute("flag", "1");
                                tlVectorControl1.SVGDocument.RootElement.AppendChild(n33);
                                tlVectorControl1.Operation = ToolOperation.Select;
                                tlVectorControl1.Refresh();
                            }
                        }
                        dianYaResult += dev[0] + "," + dev[1] + "," + dev[2] + "," + dev[3] + "," + dev[4] + "," + dev[5] + "," + dev[6] + "," + dev[7] + "," + dev[8] + "," +
                            dev[9] + "," + dev[10] + "," + dev[11] + "," + dev[12] + "," + dev[13] + "\r\n";
                        strLineDY = readLineDY.ReadLine();
                    }

                    string dianLiuResult = null;
                    dianLiuResult += "支路电流结果" + "\r\n" + "\r\n";
                    if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Sxdianliu.txt"))
                    {
                    }
                    else
                    {
                        return;
                    }
                    FileStream dianLiu = new FileStream(System.Windows.Forms.Application.StartupPath + "\\Sxdianliu.txt", FileMode.Open);
                    StreamReader readLineDL = new StreamReader(dianLiu, System.Text.Encoding.Default);
                    string strLineDL;
                    string[] arrayDL;
                    char[] charSplitDL = new char[] { ' ' };
                    strLineDL = readLineDL.ReadLine();
                    while (strLineDL != null)
                    {
                        arrayDL = strLineDL.Split(charSplitDL);
                        int i = 0;
                        string[] dev = new string[15];
                        dev.Initialize();
                        foreach (string str in arrayDL)
                        {
                            if (str != "")
                            {
                                dev[i++] = str;
                            }
                        }
                        PSPDEV CR = new PSPDEV();
                        CR.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        CR.Name = dev[1];
                        CR.Type = nodeType;
                        CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByName", CR);
                        if (tuxing == 1)
                        {
                            XmlElement elementdl = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@id='" + CR.EleID + "']") as XmlElement;

                            if (elementdl != null)
                            {
                                PointF[] t = ((Polyline)elementdl).Points;

                                PointF[] t2 = ((Polyline)elementdl).FirstTwoPoint;
                                t = t2;
                                PointF midt = new PointF((float)((t2[0].X + t2[1].X) / 2), (float)((t2[0].Y + t2[1].Y) / 2));
                                float angel = 0f;
                                angel = (float)(180 * Math.Atan2((t2[1].Y - t2[0].Y), (t2[1].X - t2[0].X)) / Math.PI);

                                string l3 = Convert.ToString(midt.X);
                                string l4 = Convert.ToString(midt.Y);

                                string tran = ((Polyline)elementdl).Transform.ToString();

                                PointF center = new PointF((float)(t[0].X + (t[1].X - t[0].X) / 2), (float)(t[0].Y + (t[1].Y - t[0].Y) / 2));
                                XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                                XmlElement n2dl = tlVectorControl1.SVGDocument.CreateElement("polyline") as Polyline;
                                PointF pStart = new PointF(center.X + (float)(15 * Math.Sin((angel) * Math.PI / 180)), center.Y - (float)(15 * Math.Cos((angel) * Math.PI / 180)));
                                PSPDEV psp = new PSPDEV();
                                psp.FirstNode = CR.FirstNode;
                                psp.LastNode = CR.LastNode;
                                psp.SvgUID = CR.SvgUID;
                                PSPDEV tempss = new PSPDEV();
                                IList listParallel = Services.BaseService.GetList("SelectPSPDEVBySvgUIDandFirstOrLastNode", psp);
                                foreach (PSPDEV devP in listParallel)
                                {
                                    if ((angel > 10 && angel < 90) || (angel < 0 && Math.Abs(angel) < 90) || (angel > 180 && angel < 350))
                                    {
                                        if (((devP.X1) > (CR.X1)))
                                        {
                                            pStart = new PointF(center.X - (float)(23 * Math.Sin((angel) * Math.PI / 180)), center.Y + (float)(23 * Math.Cos((angel) * Math.PI / 180)));

                                        }
                                    }
                                    else if ((angel >= 0 && angel <= 10) || (angel >= 350 && angel <= 360) || (angel < 0 && Math.Abs(angel) <= 90))
                                    {
                                        if (((devP.Y1) > (CR.Y1)))
                                        {
                                            pStart = new PointF(center.X - (float)(23 * Math.Sin((angel) * Math.PI / 180)), center.Y + (float)(23 * Math.Cos((angel) * Math.PI / 180)));

                                        }
                                    }
                                    else if ((angel < 0 && Math.Abs(angel) > 90) || (angel >= 90 && angel <= 180))
                                    {
                                        if (((devP.Y1) > (CR.Y1)))
                                        {
                                            pStart = new PointF(center.X - (float)(7 * Math.Sin((angel) * Math.PI / 180)), center.Y + (float)(7 * Math.Cos((angel) * Math.PI / 180)));

                                        }
                                    }
                                }

                                PointF newp1 = new PointF(t[0].X + (t[1].X - t[0].X) / 2 - (float)(15 * Math.Sin(angel)), t[0].Y + (t[1].Y - t[0].Y) / 2 - (float)(15 * Math.Cos(angel)));

                                n1.SetAttribute("x", Convert.ToString(pStart.X));
                                n1.SetAttribute("y", Convert.ToString(pStart.Y));

                                //if (Convert.ToDouble(dev[4]) >= 0)
                                //{
                                n1.InnerText = (Math.Abs(Convert.ToDouble(dev[3]))).ToString("N4");
                                //}
                                //else
                                //{
                                //    n1.InnerText = (Math.Abs(Convert.ToDouble(dev[3]))).ToString("N4");
                                //}
                                n1.SetAttribute("layer", SvgDocument.currentLayer);
                                n1.SetAttribute("flag", "1");

                                //if (Convert.ToDouble(dev[3]) == 1)
                                //    n1.SetAttribute("stroke", "#FF0000");

                                PointF p1 = new PointF(midt.X - (float)(10 * Math.Cos((angel + 25) * Math.PI / 180)), midt.Y - (float)(10 * Math.Sin((angel + 25) * Math.PI / 180)));
                                PointF p2 = new PointF(midt.X - (float)(10 * Math.Cos((angel + 335) * Math.PI / 180)), midt.Y - (float)(10 * Math.Sin((angel + 335) * Math.PI / 180)));

                                if (Convert.ToDouble(dev[3]) < 0)
                                {
                                    p1 = new PointF(midt.X - (float)(10 * Math.Cos((angel + 155) * Math.PI / 180)), midt.Y - (float)(10 * Math.Sin((angel + 155) * Math.PI / 180)));
                                    p2 = new PointF(midt.X - (float)(10 * Math.Cos((angel + 205) * Math.PI / 180)), midt.Y - (float)(10 * Math.Sin((angel + 205) * Math.PI / 180)));
                                }

                                string l1 = Convert.ToString(p1.X);
                                string l2 = Convert.ToString(p1.Y);
                                string l5 = Convert.ToString(p2.X);
                                string l6 = Convert.ToString(p2.Y);

                                tlVectorControl1.SVGDocument.RootElement.AppendChild(n1);
                                tlVectorControl1.Operation = ToolOperation.Select;

                                tlVectorControl1.SVGDocument.CurrentElement = n1 as SvgElement;

                                RectangleF ttt = ((Polyline)elementdl).GetBounds();

                                tlVectorControl1.RotateSelection(angel, pStart);
                                if (Math.Abs(angel) > 90)
                                    tlVectorControl1.RotateSelection(180, pStart);
                                PointF newp = new PointF(center.X + 10, center.Y + 10);

                                tlVectorControl1.Refresh();

                            }
                        }
                        dianLiuResult += dev[0] + "," + dev[1] + "," + dev[2] + "," + dev[3] + "," + dev[4] + "," + dev[5] + "," + dev[6] + "," + dev[7] + "," + dev[8] + "," +
                            dev[9] + "," + dev[10] + "," + dev[11] + dev[12] + "," + dev[13] + "," + dev[14] + "\r\n";
                        strLineDL = readLineDL.ReadLine();
                    }

                    if (baobiao == 1)
                    {
                        if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\result.csv"))
                        {
                            File.Delete(System.Windows.Forms.Application.StartupPath + "\\result.csv");
                        }
                        FileStream tempGU = new FileStream((System.Windows.Forms.Application.StartupPath + "\\result.csv"), FileMode.OpenOrCreate);
                        StreamWriter strGU = new StreamWriter(tempGU, Encoding.GetEncoding("GB2312"));
                        strGU.Write(duanResult);
                        strGU.Close();
                        if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\result1.csv"))
                        {
                            File.Delete(System.Windows.Forms.Application.StartupPath + "\\result1.csv");
                        }
                        FileStream tempDY = new FileStream((System.Windows.Forms.Application.StartupPath + "\\result1.csv"), FileMode.OpenOrCreate);
                        StreamWriter strDY = new StreamWriter(tempDY, Encoding.GetEncoding("GB2312"));
                        strDY.Write(dianYaResult);
                        strDY.Close();
                        if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\result2.csv"))
                        {
                            File.Delete(System.Windows.Forms.Application.StartupPath + "\\result2.csv");
                        }
                        FileStream tempDL = new FileStream((System.Windows.Forms.Application.StartupPath + "\\result2.csv"), FileMode.OpenOrCreate);
                        StreamWriter strDL = new StreamWriter(tempDL, Encoding.GetEncoding("GB2312"));
                        strDL.Write(dianLiuResult);
                        strDL.Close();
                        if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\" + "短路计算结果.xls"))
                        {
                            File.Delete(System.Windows.Forms.Application.StartupPath + "\\" + "短路计算结果.xls");
                        }

                        Excel.Application ex;
                        Excel.Worksheet xSheet;
                        Excel.Application result1;
                        Excel.Application result2;
                        Excel.Worksheet tempSheet;
                        Excel.Worksheet tempSheet1;
                        Excel.Worksheet newWorksheet;
                        Excel.Worksheet newWorkSheet1;

                        object oMissing = System.Reflection.Missing.Value;
                        ex = new Excel.Application();
                        ex.Application.Workbooks.Add(System.Windows.Forms.Application.StartupPath + "\\result.csv");

                        xSheet = (Excel.Worksheet)ex.Worksheets[1];
                        ex.Worksheets.Add(System.Reflection.Missing.Value, xSheet, 1, System.Reflection.Missing.Value);
                        xSheet = (Excel.Worksheet)ex.Worksheets[2];
                        ex.Worksheets.Add(System.Reflection.Missing.Value, xSheet, 1, System.Reflection.Missing.Value);
                        xSheet = (Excel.Worksheet)ex.Worksheets[1];
                        result1 = new Excel.Application();
                        result1.Application.Workbooks.Add(System.Windows.Forms.Application.StartupPath + "\\result1.csv");
                        result2 = new Excel.Application();
                        result2.Application.Workbooks.Add(System.Windows.Forms.Application.StartupPath + "\\result2.csv");
                        tempSheet = (Excel.Worksheet)result1.Worksheets.get_Item(1);
                        tempSheet1 = (Excel.Worksheet)result2.Worksheets.get_Item(1);
                        newWorksheet = (Excel.Worksheet)ex.Worksheets.get_Item(2);
                        newWorkSheet1 = (Excel.Worksheet)ex.Worksheets.get_Item(3);
                        newWorksheet.Name = "母线电压";
                        newWorkSheet1.Name = "支路电流";
                        xSheet.Name = "短路电流";
                        ex.Visible = true;

                        tempSheet.Cells.Select();
                        tempSheet.Cells.Copy(System.Reflection.Missing.Value);
                        newWorksheet.Paste(System.Reflection.Missing.Value, System.Reflection.Missing.Value);
                        tempSheet1.Cells.Select();
                        tempSheet1.Cells.Copy(System.Reflection.Missing.Value);
                        newWorkSheet1.Paste(System.Reflection.Missing.Value, System.Reflection.Missing.Value);
                        xSheet.Rows.AutoFit();
                        xSheet.Columns.AutoFit();
                        newWorksheet.Rows.AutoFit();
                        newWorksheet.Columns.AutoFit();
                        newWorkSheet1.Rows.AutoFit();
                        newWorkSheet1.Columns.AutoFit();
                        xSheet.UsedRange.Font.Name = "楷体_GB2312";
                        newWorksheet.UsedRange.Font.Name = "楷体_GB2312";
                        newWorkSheet1.UsedRange.Font.Name = "楷体_GB2312";

                        xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 3]).MergeCells = true;
                        xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 1]).Font.Size = 20;
                        xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 1]).Font.Name = "黑体";
                        xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 1]).HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
                        xSheet.get_Range(xSheet.Cells[3, 1], xSheet.Cells[3, 3]).Interior.ColorIndex = 45;
                        xSheet.get_Range(xSheet.Cells[4, 1], xSheet.Cells[xSheet.UsedRange.Rows.Count, 1]).Interior.ColorIndex = 6;
                        xSheet.get_Range(xSheet.Cells[4, 3], xSheet.Cells[xSheet.UsedRange.Rows.Count, 13]).NumberFormat = "0.0000_ ";

                        newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 14]).MergeCells = true;
                        newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 1]).Font.Size = 20;
                        newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 1]).Font.Name = "黑体";
                        newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 1]).HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
                        newWorksheet.get_Range(newWorksheet.Cells[3, 1], newWorksheet.Cells[3, 14]).Interior.ColorIndex = 45;
                        newWorksheet.get_Range(newWorksheet.Cells[4, 1], newWorksheet.Cells[newWorksheet.UsedRange.Rows.Count, 1]).Interior.ColorIndex = 6;
                        newWorksheet.get_Range(newWorksheet.Cells[4, 3], newWorksheet.Cells[newWorksheet.UsedRange.Rows.Count, 14]).NumberFormat = "0.0000_ ";

                        newWorkSheet1.get_Range(newWorkSheet1.Cells[1, 1], newWorkSheet1.Cells[1, 15]).MergeCells = true;
                        newWorkSheet1.get_Range(newWorkSheet1.Cells[1, 1], newWorkSheet1.Cells[1, 1]).Font.Size = 20;
                        newWorkSheet1.get_Range(newWorkSheet1.Cells[1, 1], newWorkSheet1.Cells[1, 1]).Font.Name = "黑体";
                        newWorkSheet1.get_Range(newWorkSheet1.Cells[1, 1], newWorkSheet1.Cells[1, 1]).HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
                        newWorkSheet1.get_Range(newWorkSheet1.Cells[3, 1], newWorkSheet1.Cells[3, 14]).Interior.ColorIndex = 45;
                        newWorkSheet1.get_Range(newWorkSheet1.Cells[4, 1], newWorkSheet1.Cells[newWorkSheet1.UsedRange.Rows.Count, 1]).Interior.ColorIndex = 6;
                        newWorkSheet1.get_Range(newWorkSheet1.Cells[4, 2], newWorkSheet1.Cells[newWorkSheet1.UsedRange.Rows.Count, 2]).Interior.ColorIndex = 6;
                        newWorkSheet1.get_Range(newWorkSheet1.Cells[4, 4], newWorkSheet1.Cells[newWorkSheet1.UsedRange.Rows.Count, 14]).NumberFormat = "0.0000_ ";

                        newWorksheet.SaveAs(System.Windows.Forms.Application.StartupPath + "\\" + "短路计算结果.xls", Excel.XlFileFormat.xlXMLSpreadsheet, null, null, false, false, false, null, null, null);
                        System.Windows.Forms.Clipboard.Clear();
                        result1.Workbooks.Close();
                        result1.Quit();
                        result2.Workbooks.Close();
                        result2.Quit();
                    }

                }
            }

            if (e.ClickedItem.Text == "区域打印")
            {
                PrintHelper ph = new PrintHelper(tlVectorControl1, mapview);
                frmPrinter dlg = new frmPrinter();
                dlg.printHelper = ph;
                dlg.ShowDialog();
                return;
                ArrayList idlist = new ArrayList();
                ArrayList symlist = new ArrayList();

                SvgDocument _doc = new SvgDocument();

                Graph poly1 = tlVectorControl1.SVGDocument.CurrentElement as Graph;
                if (poly1 == null || poly1.GetAttribute("id") == "svg")
                {
                    return;
                }

                GraphicsPath gr1 = new GraphicsPath();
                gr1.AddPolygon(TLMath.getPolygonPoints(poly1));
                gr1 = (GraphicsPath)poly1.GPath.Clone();
                gr1.Transform((poly1 as IGraph).Transform.Matrix);

                RectangleF ef1 = gr1.GetBounds();
                ef1 = PathFunc.GetBounds(gr1);
                StringBuilder svgtxt = new StringBuilder("<?xml version=\"1.0\" encoding=\"utf-8\"?><svg id=\"svg\" width=\"" + ef1.Width + "\" height=\"" + ef1.Height + "\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns:itop=\"http://www.Itop.com/itop\">");

                XmlNodeList nlist = tlVectorControl1.SVGDocument.GetElementsByTagName("defs");
                if (nlist.Count > 0)
                {
                    XmlNode node = nlist[0];
                    svgtxt.AppendLine(node.OuterXml);
                }
                SvgElementCollection.ISvgElementEnumerator enumerator1 = tlVectorControl1.DrawArea.ElementList.GetEnumerator();// mouseAreaControl.PicturePanel.ElementList.GetEnumerator();
                while (enumerator1.MoveNext())
                {
                    IGraph graph1 = (IGraph)enumerator1.Current;

                    GraphicsPath path1 = (GraphicsPath)graph1.GPath.Clone();
                    if (!graph1.Visible || !graph1.DrawVisible || !graph1.Layer.Visible) continue;

                    GraphicsPath path2 = (GraphicsPath)graph1.GPath.Clone();
                    path2.Transform(graph1.Transform.Matrix);
                    RectangleF ef2 = PathFunc.GetBounds(path2);

                    if (ef1.Contains(ef2) || RectangleF.Intersect(ef1, ef2) != RectangleF.Empty)
                    {
                        SvgElement ele = (SvgElement)graph1;
                        svgtxt.AppendLine(ele.OuterXml);
                        if (graph1 is Use)
                        {
                            string symid = ((XmlElement)graph1).GetAttribute("xlink:href");
                            if (!symlist.Contains(symid))
                            {
                                symlist.Add(symid);
                            }
                        }
                        if (graph1.GetType().FullName == "ItopVector.Core.Figure.Polyline")
                        {
                            string IsLead = ((XmlElement)graph1).GetAttribute("IsLead");
                            if (IsLead != "")
                            {
                                if (ef1.Contains(ef2))
                                {
                                    idlist.Add(graph1.ID);
                                }
                            }
                        }
                    }

                }
                //symlist = ResetList(symlist);
                svgtxt.AppendLine("</svg>");
                _doc.LoadXml(svgtxt.ToString());
                _doc.SvgdataUid = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                frmPrintF pri = new frmPrintF();
                pri.Init(tlVectorControl1.SVGDocument.CurrentElement.ID, tlVectorControl1.SVGDocument.CurrentLayer.ID);
                if (pri.ShowDialog() == DialogResult.OK)
                {
                    frmSubPrint s = new frmSubPrint();
                    s.Vector = tlVectorControl1;
                    s.InitImg(pri.strzt, pri.strgs, pri.pri, idlist, symlist);
                    s.Open(_doc, ef1);
                    s.Show();
                }
            }

            if (e.ClickedItem.Text == "属性")
            {
                //if (!Check())
                //{
                //    return;
                //}
                XmlElement element = tlVectorControl1.SVGDocument.CurrentElement;
                if (element is Use)
                {
                    if (element.GetAttribute("xlink:href").Contains("Substation") || element.GetAttribute("xlink:href").Contains("motherlinenode"))
                    {

                        string str_power = getPower(element.GetAttribute("xlink:href"));

                        PSPDEV pspDev = new PSPDEV();
                        pspDev.EleID = element.GetAttribute("id");
                        pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev);
                        frmSubstation dlg;
                        if (pspDev != null)
                        {
                            dlg = new frmSubstation(pspDev);

                        }
                        else
                        {
                            pspDev = new PSPDEV();
                            pspDev.SUID = Guid.NewGuid().ToString();
                            pspDev.EleID = element.GetAttribute("id");
                            pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            pspDev.Number = -1;
                            pspDev.FirstNode = -1;
                            pspDev.LastNode = -1;
                            pspDev.Type = "Use";
                            if (element.GetAttribute("xlink:href").Contains("Substation"))
                            {
                                pspDev.Lable = "变电站";
                            }
                            else if (element.GetAttribute("xlink:href").Contains("motherlinenode"))
                            {
                                pspDev.Lable = "母线节点";
                            }
                            else if (element.GetAttribute("xlink:href").Contains("Power"))
                            {
                                pspDev.Lable = "电厂";
                            }
                            Services.BaseService.Create<PSPDEV>(pspDev);
                            dlg = new frmSubstation(pspDev);
                        }
                        dlg.Str_Power = str_power;

                        dlg.TYear = tlVectorControl1.SVGDocument.CurrentElement.GetAttribute("year");

                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            if (dlg.Name == null)
                            {
                                MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            PSPDEV pspName = new PSPDEV();
                            pspName.Name = dlg.Name;
                            pspName.Type = "Use";
                            pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                            if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID))
                            {
                                MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            pspDev.Name = dlg.Name;
                            XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']");
                            if (text != null)
                            {
                                (text as Text).InnerText = dlg.Name;
                                (text as Text).SetAttribute("print", dlg.IsTJ ? "no" : "yes");
                            }
                            pspDev.VoltR = Convert.ToDouble(dlg.VoltR);
                            pspDev.ReferenceVolt = Convert.ToDouble(dlg.ReferenceVolt);
                            pspDev.Burthen = Convert.ToDecimal(dlg.Burthen);
                            element.SetAttribute("print", dlg.IsTJ ? "no" : "yes");

                            pspDev.OutP = Convert.ToDouble(dlg.OutP);
                            pspDev.OutQ = Convert.ToDouble(dlg.OutQ); ;
                            //if (pspDev.InPutP==0)
                            pspDev.InPutP = Convert.ToDouble(dlg.InPutP);
                            pspDev.InPutQ = Convert.ToDouble(dlg.InPutQ);
                            pspDev.ReferenceVolt = Convert.ToDouble(dlg.ReferenceVolt);

                            if (dlg.NodeType == "是")
                            {
                                pspDev.NodeType = "0";
                            }
                            else
                            {
                                pspDev.NodeType = "1";
                            }
                            Services.BaseService.Update<PSPDEV>(pspDev);
                            tlVectorControl1.SVGDocument.CurrentElement.SetAttribute("year", dlg.TYear);
                        }
                    }
                    else if (element.GetAttribute("xlink:href").Contains("Power"))
                    {
                        PSPDEV pspDev = new PSPDEV();
                        pspDev.EleID = element.GetAttribute("id");
                        pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev);
                        frmSubstation dlg;
                        if (pspDev != null)
                        {
                            dlg = new frmSubstation(pspDev);
                        }
                        else
                        {
                            pspDev = new PSPDEV();
                            pspDev.SUID = Guid.NewGuid().ToString();
                            pspDev.EleID = element.GetAttribute("id");
                            pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            pspDev.Number = -1;
                            pspDev.FirstNode = -1;
                            pspDev.LastNode = -1;
                            pspDev.Type = "Use";
                            if (element.GetAttribute("xlink:href").Contains("Substation"))
                            {
                                pspDev.Lable = "变电站";
                            }
                            else if (element.GetAttribute("xlink:href").Contains("motherlinenode"))
                            {
                                pspDev.Lable = "母线节点";
                            }
                            else if (element.GetAttribute("xlink:href").Contains("Power"))
                            {
                                pspDev.Lable = "电厂";
                            }
                            Services.BaseService.Create<PSPDEV>(pspDev);
                            dlg = new frmSubstation(pspDev);
                            dlg.TYear = tlVectorControl1.SVGDocument.CurrentElement.GetAttribute("year");
                        }

                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            if (dlg.Name == null)
                            {
                                MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            PSPDEV pspName = new PSPDEV();
                            pspName.Name = dlg.Name;
                            pspName.Type = "Use";
                            pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                            if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID))
                            {
                                MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            pspDev.Name = dlg.Name;
                            XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']");
                            if (text != null)
                            {
                                (text as Text).InnerText = dlg.Name;
                            }
                            pspDev.VoltR = Convert.ToDouble(dlg.VoltR);
                            pspDev.Burthen = Convert.ToDecimal(dlg.Burthen);
                            pspDev.OutP = Convert.ToDouble(dlg.OutP);
                            pspDev.OutQ = Convert.ToDouble(dlg.OutQ);
                            pspDev.InPutP = Convert.ToDouble(dlg.InPutP);
                            pspDev.InPutQ = Convert.ToDouble(dlg.InPutQ);
                            pspDev.ReferenceVolt = Convert.ToDouble(dlg.ReferenceVolt);

                            if (dlg.NodeType == "是")
                            {
                                pspDev.NodeType = "0";
                            }
                            else
                            {
                                pspDev.NodeType = "2";
                            }
                            Services.BaseService.Update<PSPDEV>(pspDev);
                        }
                    }
                    else if (element.GetAttribute("xlink:href").Contains("dynamotorline"))
                    {
                        PSPDEV pspDev = new PSPDEV();
                        pspDev.EleID = element.GetAttribute("id");
                        pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev);
                        frmFadejie dlg;
                        if (pspDev != null)
                        {
                            dlg = new frmFadejie(pspDev, pspDev.SvgUID);
                        }
                        else
                        {
                            pspDev = new PSPDEV();
                            pspDev.SUID = Guid.NewGuid().ToString();
                            pspDev.EleID = element.GetAttribute("id");
                            pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            pspDev.Number = -1;
                            pspDev.FirstNode = -1;
                            pspDev.LastNode = 0;
                            pspDev.Type = "dynamotorline";
                            if (element.GetAttribute("xlink:href").Contains("dynamotorline"))
                            {
                                pspDev.Lable = "发电厂支路";
                            }
                            else if (element.GetAttribute("xlink:href").Contains("gndline"))
                            {
                                pspDev.Lable = "接地支路";
                            }
                            Services.BaseService.Create<PSPDEV>(pspDev);
                            dlg = new frmFadejie(pspDev, pspDev.SvgUID);
                        }
                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            if (dlg.Name == null)
                            {
                                MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            PSPDEV pspName = new PSPDEV();
                            pspName.Name = dlg.Name;
                            pspName.Type = "dynamotorline";
                            pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                            if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID))
                            {
                                MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            pspDev.Name = dlg.Name;
                            XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']");
                            if (text != null)
                            {
                                (text as Text).InnerText = dlg.Name;
                            }
                            pspDev.HuganLine1 = dlg.FirstNodeName;
                            pspDev.HuganLine3 = dlg.SwitchStatus;
                            if (dlg.OutP != "")
                                pspDev.OutP = Convert.ToDouble(dlg.OutP);
                            if (dlg.OutQ != "")
                                pspDev.OutQ = Convert.ToDouble(dlg.OutQ);
                            if (dlg.VoltR != "")
                                pspDev.VoltR = Convert.ToDouble(dlg.VoltR);
                            if (dlg.VoltV != "")
                                pspDev.VoltV = Convert.ToDouble(dlg.VoltV);
                            if (dlg.PositiveTQ != "")
                                pspDev.PositiveTQ = Convert.ToDouble(dlg.PositiveTQ);
                            if (dlg.NegativeTQ != "")
                                pspDev.ZeroTQ = Convert.ToDouble(dlg.NegativeTQ);
                            Services.BaseService.Update<PSPDEV>(pspDev);
                        }
                    }
                    else if (element.GetAttribute("xlink:href").Contains("gndline"))
                    {
                        PSPDEV pspDev = new PSPDEV();
                        pspDev.EleID = element.GetAttribute("id");
                        pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev);
                        frmFadejie dlg;
                        if (pspDev != null)
                        {
                            dlg = new frmFadejie(pspDev, pspDev.SvgUID);
                        }
                        else
                        {
                            pspDev = new PSPDEV();
                            pspDev.SUID = Guid.NewGuid().ToString();
                            pspDev.EleID = element.GetAttribute("id");
                            pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            pspDev.Number = -1;
                            pspDev.FirstNode = -1;
                            pspDev.LastNode = 0;
                            pspDev.Type = "gndline";
                            if (element.GetAttribute("xlink:href").Contains("dynamotorline"))
                            {
                                pspDev.Lable = "发电厂支路";
                            }
                            else if (element.GetAttribute("xlink:href").Contains("gndline"))
                            {
                                pspDev.Lable = "接地支路";
                            }
                            Services.BaseService.Create<PSPDEV>(pspDev);
                            dlg = new frmFadejie(pspDev, pspDev.SvgUID);
                        }
                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            if (dlg.Name == null)
                            {
                                MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            PSPDEV pspName = new PSPDEV();
                            pspName.Name = dlg.Name;
                            pspName.Type = "gndline";
                            pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                            if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID))
                            {
                                MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            pspDev.Name = dlg.Name;
                            XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']");
                            if (text != null)
                            {
                                (text as Text).InnerText = dlg.Name;
                            }
                            pspDev.HuganLine1 = dlg.FirstNodeName;
                            pspDev.HuganLine3 = dlg.SwitchStatus;
                            if (dlg.OutP != "")
                                pspDev.OutP = Convert.ToDouble(dlg.OutP);
                            if (dlg.OutQ != "")
                                pspDev.OutQ = Convert.ToDouble(dlg.OutQ);
                            if (dlg.VoltR != "")
                                pspDev.VoltR = Convert.ToDouble(dlg.VoltR);
                            if (dlg.VoltV != "")
                                pspDev.VoltV = Convert.ToDouble(dlg.VoltV);
                            if (dlg.PositiveTQ != "")
                                pspDev.PositiveTQ = Convert.ToDouble(dlg.PositiveTQ);
                            if (dlg.NegativeTQ != "")
                                pspDev.ZeroTQ = Convert.ToDouble(dlg.NegativeTQ);
                            Services.BaseService.Update<PSPDEV>(pspDev);
                        }
                    }
                    else if (element.GetAttribute("xlink:href").Contains("loadline"))
                    {
                        PSPDEV pspDev = new PSPDEV();
                        pspDev.EleID = element.GetAttribute("id");
                        pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev);
                        frmLoad dlg;
                        if (pspDev != null)
                        {
                            dlg = new frmLoad(pspDev);
                        }
                        else
                        {
                            pspDev = new PSPDEV();
                            pspDev.SUID = Guid.NewGuid().ToString();
                            pspDev.EleID = element.GetAttribute("id");
                            pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            pspDev.Number = -1;
                            pspDev.FirstNode = -1;
                            pspDev.LastNode = 0;
                            pspDev.Type = "loadline";

                            pspDev.Lable = "负荷支路";

                            Services.BaseService.Create<PSPDEV>(pspDev);
                            dlg = new frmLoad(pspDev);
                        }
                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            if (dlg.Name == null)
                            {
                                MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            PSPDEV pspName = new PSPDEV();
                            pspName.Name = dlg.Name;
                            pspName.Type = "loadline";
                            pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                            if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID))
                            {
                                MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            pspDev.Name = dlg.Name;
                            XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']");
                            if (text != null)
                            {
                                (text as Text).InnerText = dlg.Name;
                            }
                            pspDev.HuganLine1 = dlg.FirstNodeName;

                            pspDev.HuganLine3 = dlg.LoadSwitchState;
                            if (dlg.InPutP != "")
                                pspDev.InPutP = Convert.ToDouble(dlg.InPutP);
                            if (dlg.InPutQ != "")
                                pspDev.InPutQ = Convert.ToDouble(dlg.InPutQ);
                            if (dlg.VoltR != "")
                                pspDev.VoltR = Convert.ToDouble(dlg.VoltR);

                            Services.BaseService.Update<PSPDEV>(pspDev);
                        }
                    }
                    else if (element.GetAttribute("xlink:href").Contains("串联电容电抗器"))
                    {
                        PSPDEV pspDev = new PSPDEV();
                        pspDev.EleID = element.GetAttribute("id");
                        pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev);
                        frmCapacity dlg;

                        if (pspDev != null)
                        {
                            dlg = new frmCapacity(pspDev, pspDev.SvgUID);
                            dlg.SetEnable(true);
                        }
                        else
                        {
                            return;
                        }
                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            if (dlg.Name == null)
                            {
                                MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            PSPDEV pspName = new PSPDEV();
                            pspName.Name = dlg.Name;
                            pspName.Type = "串联电容电抗器";
                            pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                            if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID))
                            {
                                MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            pspDev.Name = dlg.Name;
                            XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']");
                            if (text != null)
                            {
                                (text as Text).InnerText = dlg.Name;
                            }
                            pspDev.HuganLine1 = dlg.FirstNodeName;

                            // pspDev.HuganLine2 = dlg.LastNodeName;
                            if (dlg.PositiveTQ != "")
                                pspDev.PositiveTQ = Convert.ToDouble(dlg.PositiveTQ);

                            Services.BaseService.Update<PSPDEV>(pspDev);
                        }
                    }
                    else if (element.GetAttribute("xlink:href").Contains("并联电容电抗器"))
                    {
                        PSPDEV pspDev = new PSPDEV();
                        pspDev.EleID = element.GetAttribute("id");
                        pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev);
                        frmCapacity dlg;

                        if (pspDev != null)
                        {
                            dlg = new frmCapacity(pspDev, pspDev.SvgUID);
                            dlg.SetEnable(false);
                        }
                        else
                        {
                            return;
                        }
                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            if (dlg.Name == null)
                            {
                                MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            PSPDEV pspName = new PSPDEV();
                            pspName.Name = dlg.Name;
                            pspName.Type = "并联电容电抗器";
                            pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                            if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID))
                            {
                                MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            pspDev.Name = dlg.Name;
                            XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']");
                            if (text != null)
                            {
                                (text as Text).InnerText = dlg.Name;
                            }
                            pspDev.HuganLine1 = dlg.FirstNodeName;
                            //pspDev.HuganLine2 = dlg.LastNodeName;
                            if (dlg.PositiveTQ != "")
                                pspDev.PositiveTQ = Convert.ToDouble(dlg.PositiveTQ);

                            Services.BaseService.Update<PSPDEV>(pspDev);
                        }
                    }
                    else if (element.GetAttribute("xlink:href").Contains("transformerthirdzu"))
                    {
                        PSPDEV pspDev = new PSPDEV();
                        pspDev.EleID = element.GetAttribute("id");
                        pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev);
                        frmThridTra dlg;

                        if (pspDev != null)
                        {
                            dlg = new frmThridTra(pspDev, pspDev.SvgUID);
                        }
                        else
                        {
                            return;
                        }
                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            if (dlg.Name == null)
                            {
                                MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            PSPDEV pspName = new PSPDEV();
                            pspName.Name = dlg.Name;
                            pspName.Type = "transformerthirdzu";
                            pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                            if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID))
                            {
                                MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            pspDev.Name = dlg.Name;
                            XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']");
                            if (text != null)
                            {
                                (text as Text).InnerText = dlg.Name;
                            }

                            pspDev.HuganLine1 = dlg.IName;
                            pspDev.HuganLine2 = dlg.JName;
                            pspDev.HuganLine3 = dlg.ISwitchState;
                            pspDev.HuganLine4 = dlg.JSwitchState;
                            pspDev.LineLevel = dlg.IType;
                            pspDev.LineType = dlg.JType;
                            pspDev.LineStatus = dlg.KType;
                            pspDev.KName = dlg.KName;
                            pspDev.KSwitchStatus = dlg.KSwitchState;
                            if (dlg.IK != "")
                            {
                                pspDev.K = Convert.ToDouble(dlg.KK);
                            }
                            if (dlg.JK != "")
                            {
                                pspDev.G = Convert.ToDouble(dlg.JK);
                            }
                            if (dlg.KK != "")
                            {
                                pspDev.BigP = Convert.ToDouble(dlg.KK);
                            }
                            if (dlg.IR != "")
                            {
                                pspDev.HuganTQ1 = Convert.ToDouble(dlg.IR);
                            }
                            if (dlg.JR != "")
                            {
                                pspDev.HuganTQ2 = Convert.ToDouble(dlg.JR);
                            }
                            if (dlg.KR != "")
                            {
                                pspDev.HuganTQ3 = Convert.ToDouble(dlg.KR);
                            }
                            if (dlg.ITQ != "")
                            {
                                pspDev.HuganTQ4 = Convert.ToDouble(dlg.ITQ);
                            }
                            if (dlg.JTQ != "")
                            {
                                pspDev.HuganTQ5 = Convert.ToDouble(dlg.JTQ);
                            }
                            if (dlg.KTQ != "")
                            {
                                pspDev.SmallTQ = Convert.ToDouble(dlg.KTQ);
                            }
                            if (dlg.ZeroTQ != "")
                                pspDev.ZeroTQ = Convert.ToDouble(dlg.ZeroTQ);

                            if (dlg.NeutralNodeTQ != "")
                                pspDev.BigTQ = Convert.ToDouble(dlg.NeutralNodeTQ);
                            Services.BaseService.Update<PSPDEV>(pspDev);
                        }
                    }
                    else if (element.GetAttribute("xlink:href").Contains("transformertwozu"))
                    {
                        PSPDEV pspDev = new PSPDEV();
                        pspDev.EleID = element.GetAttribute("id");
                        pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev);
                        frmTwoTra dlg;

                        if (pspDev != null)
                        {
                            dlg = new frmTwoTra(pspDev, pspDev.SvgUID);
                        }
                        else
                        {
                            return;
                        }
                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            if (dlg.Name == null)
                            {
                                MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            PSPDEV pspName = new PSPDEV();
                            pspName.Name = dlg.Name;
                            pspName.Type = "transformertwozu";
                            pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                            if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID))
                            {
                                MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            pspDev.Name = dlg.Name;
                            XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']");
                            if (text != null)
                            {
                                (text as Text).InnerText = dlg.Name;
                            }

                            pspDev.HuganLine1 = dlg.FirstName;
                            pspDev.HuganLine2 = dlg.LastName;
                            pspDev.HuganLine3 = dlg.FirstSwitchState;
                            pspDev.HuganLine4 = dlg.LastSwitchState;
                            pspDev.LineLevel = dlg.FirstType;
                            pspDev.LineType = dlg.LastType;

                            if (dlg.PositiveR != "")
                            {
                                pspDev.PositiveR = Convert.ToDouble(dlg.PositiveR);
                            }
                            if (dlg.PositiveTQ != "")
                            {
                                pspDev.PositiveTQ = Convert.ToDouble(dlg.PositiveTQ);
                            }

                            if (dlg.ZeroR != "")
                            {
                                pspDev.ZeroR = Convert.ToDouble(dlg.ZeroR);
                            }

                            if (dlg.ZeroTQ != "")
                            {
                                pspDev.ZeroTQ = Convert.ToDouble(dlg.ZeroTQ);
                            }

                            if (dlg.K != "")
                                pspDev.K = Convert.ToDouble(dlg.K);

                            if (dlg.NeutralNodeTQ != "")
                                pspDev.BigTQ = Convert.ToDouble(dlg.NeutralNodeTQ);
                            Services.BaseService.Update<PSPDEV>(pspDev);
                        }
                    }
                    else if (element.GetAttribute("xlink:href").Contains("1/2母联开关"))
                    {
                        PSPDEV pspDev = new PSPDEV();
                        pspDev.EleID = element.GetAttribute("id");
                        pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev);
                        frmMuLian dlg;

                        if (pspDev != null)
                        {
                            dlg = new frmMuLian(pspDev, pspDev.SvgUID);
                        }
                        else
                        {
                            return;
                        }
                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            if (dlg.Name == null)
                            {
                                MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            PSPDEV pspName = new PSPDEV();
                            pspName.Name = dlg.Name;
                            pspName.Type = "1/2母联开关";
                            pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                            if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID))
                            {
                                MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            pspDev.Name = dlg.Name;
                            XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']");
                            if (text != null)
                            {
                                (text as Text).InnerText = dlg.Name;
                            }

                            pspDev.HuganLine1 = dlg.FirstNodeName;
                            pspDev.HuganLine2 = dlg.LastNodeName;
                            pspDev.HuganLine3 = dlg.SwitchStatus;

                            Services.BaseService.Update<PSPDEV>(pspDev);
                        }
                    }
                    else if (element.GetAttribute("xlink:href").Contains("2/3母联开关"))
                    {
                        PSPDEV pspDev = new PSPDEV();
                        pspDev.EleID = element.GetAttribute("id");
                        pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev);
                        frmMuLian2 dlg;

                        if (pspDev != null)
                        {
                            dlg = new frmMuLian2(pspDev, pspDev.SvgUID);
                        }
                        else
                        {
                            return;
                        }
                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            if (dlg.Name == null)
                            {
                                MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            PSPDEV pspName = new PSPDEV();
                            pspName.Name = dlg.Name;
                            pspName.Type = "2/3母联开关";
                            pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                            if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID))
                            {
                                MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            pspDev.Name = dlg.Name;
                            XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']");
                            if (text != null)
                            {
                                (text as Text).InnerText = dlg.Name;
                            }

                            pspDev.HuganLine1 = dlg.INodeName;
                            pspDev.HuganLine2 = dlg.JNodeName;
                            pspDev.HuganLine3 = dlg.ILineName;
                            pspDev.HuganLine4 = dlg.JLineName;
                            pspDev.KName = dlg.ILoadName;
                            pspDev.KSwitchStatus = dlg.JLoadName;
                            pspDev.LineLevel = dlg.SwitchStatus1;
                            pspDev.LineType = dlg.SwitchStatus2;
                            pspDev.LineStatus = dlg.SwitchStatus3;

                            Services.BaseService.Update<PSPDEV>(pspDev);
                        }
                    }

                }
                else if ((element is Polyline) && element.GetAttribute("flag") != "1" && fileType == true)
                {

                    PSPDEV pspDev = new PSPDEV();
                    pspDev.EleID = element.GetAttribute("id");
                    pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                    pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev);

                    frmLinenew dlg2;
                    if (pspDev != null)
                    {
                        dlg2 = new frmLinenew(pspDev);
                        dlg2.derefucelineflag = Reducelineflag;
                    }
                    else
                    {
                        pspDev = new PSPDEV();
                        pspDev.SUID = Guid.NewGuid().ToString();
                        pspDev.EleID = element.GetAttribute("id");
                        pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        pspDev.Number = -1;
                        pspDev.FirstNode = -1;
                        pspDev.LastNode = -1;
                        pspDev.Type = "Polyline";
                        pspDev.Lable = "支路";
                        Services.BaseService.Create<PSPDEV>(pspDev);
                        dlg2 = new frmLinenew(pspDev);
                        dlg2.derefucelineflag = Reducelineflag;
                    }
                    dlg2.TYear = tlVectorControl1.SVGDocument.CurrentElement.GetAttribute("year");
                    dlg2.linevalue = tlVectorControl1.SVGDocument.CurrentElement.GetAttribute("linevalue");   //获得线路投资
                    if (dlg2.ShowDialog() == DialogResult.OK)
                    {
                        if (dlg2.Name == null)
                        {
                            MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                        PSPDEV pspName = new PSPDEV();
                        pspName.Name = dlg2.Name;
                        pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        pspName.Type = "Polyline";
                        IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                        if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID))
                        {
                            MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                        pspDev.Name = dlg2.Name;
                        pspDev.LineLength = Convert.ToDouble(dlg2.LineLength);
                        pspDev.LineR = Convert.ToDouble(dlg2.LineR);
                        pspDev.LineTQ = Convert.ToDouble(dlg2.LineTQ);
                        pspDev.LineGNDC = Convert.ToDouble(dlg2.LineGNDC);
                        pspDev.LineLevel = dlg2.LineLevel;
                        pspDev.ReferenceVolt = Convert.ToDouble(dlg2.ReferenceVolt);
                        pspDev.LineType = dlg2.LineType;
                        pspDev.LineStatus = dlg2.LineStatus;
                        WireCategory wirewire = new WireCategory();
                        wirewire.WireType = dlg2.LineType;
                        if (dlg2.linevalue != "")
                        {
                            pspDev.BigP = Convert.ToDouble(dlg2.linevalue);
                        }
                        if (dlg2.ReferenceVolt != "")
                        {
                            pspDev.ReferenceVolt = Convert.ToDouble(dlg2.ReferenceVolt);
                        }
                        WireCategory wirewire2 = new WireCategory();
                        wirewire2 = (WireCategory)Services.BaseService.GetObject("SelectWireCategoryByKey", wirewire);
                        //if (pspDev.LineR == 0)
                        //    pspDev.LineR = Convert.ToDouble(dlg2.LineLength)*wirewire2.WireR ;
                        //if (pspDev.LineTQ == 0)
                        //    pspDev.LineTQ = Convert.ToDouble(dlg2.LineLength) * wirewire2.WireTQ;
                        //if (pspDev.LineGNDC == 0)
                        //    pspDev.LineGNDC = Convert.ToDouble(dlg2.LineLength) * wirewire2.WireGNDC;
                        if (wirewire2 != null)
                            pspDev.LineChange = (double)wirewire2.WireChange;
                        string tempp = dlg2.LineLev;
                        int tel = tempp.Length;
                        //tempp = tempp.Substring(0, tel - 2);
                        pspDev.VoltR = Convert.ToDouble(tempp);
                        tlVectorControl1.SVGDocument.CurrentElement.SetAttribute("year", dlg2.TYear);
                        tlVectorControl1.SVGDocument.CurrentElement.SetAttribute("linevalue", dlg2.linevalue);   //获得线路投资

                        //switch (dlg2.LineType)
                        //{
                        //    case "2*LGJ-400":
                        //        {
                        //            if (pspDev.LineR==0)
                        //            pspDev.LineR = Convert.ToDouble(dlg2.LineLength) * 0.04;
                        //            if (pspDev.LineTQ == 0)
                        //            pspDev.LineTQ = Convert.ToDouble(dlg2.LineLength) * 0.303;
                        //            if (pspDev.LineGNDC == 0)
                        //            pspDev.LineGNDC = Convert.ToDouble(dlg2.LineLength) * 17.9;
                        //            pspDev.LineChange = 1690;
                        //        } break;
                        //    case "2*LGJ-300":
                        //        {
                        //            if (pspDev.LineR == 0)
                        //            pspDev.LineR = Convert.ToDouble(dlg2.LineLength) * 0.054;
                        //            if (pspDev.LineTQ == 0)
                        //            pspDev.LineTQ = Convert.ToDouble(dlg2.LineLength) * 0.308;
                        //            if (pspDev.LineGNDC == 0)
                        //            pspDev.LineGNDC = Convert.ToDouble(dlg2.LineLength) * 17.7;
                        //            pspDev.LineChange = 1400;
                        //        } break;
                        //    case "2*LGJ-240":
                        //        {
                        //            if (pspDev.LineR == 0)
                        //            pspDev.LineR = Convert.ToDouble(dlg2.LineLength) * 0.066;
                        //            if (pspDev.LineTQ == 0)
                        //            pspDev.LineTQ = Convert.ToDouble(dlg2.LineLength) * 0.310;
                        //            if (pspDev.LineGNDC == 0)
                        //            pspDev.LineGNDC = Convert.ToDouble(dlg2.LineLength) * 17.5;
                        //            pspDev.LineChange = 1220;
                        //        } break;
                        //    case "LGJ-400":
                        //        {
                        //            if (pspDev.LineR == 0)
                        //            pspDev.LineR = Convert.ToDouble(dlg2.LineLength) * 0.08;
                        //            if (pspDev.LineTQ == 0)
                        //            pspDev.LineTQ = Convert.ToDouble(dlg2.LineLength) * 0.417;
                        //            if (pspDev.LineGNDC == 0)
                        //            pspDev.LineGNDC = Convert.ToDouble(dlg2.LineLength) * 13.2;
                        //            pspDev.LineChange = 845;
                        //        } break;

                        //}
                        Services.BaseService.Update<PSPDEV>(pspDev);
                        Topology2();
                    }
                }
                else if ((element is Polyline) && element.GetAttribute("flag") != "1" && fileType != true)
                {

                    PSPDEV pspDev = new PSPDEV();
                    pspDev.EleID = element.GetAttribute("id");
                    pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                    pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev);

                    frmLine dlg;
                    if (pspDev != null)
                    {
                        dlg = new frmLine(pspDev);
                    }
                    else
                    {
                        pspDev = new PSPDEV();
                        pspDev.SUID = Guid.NewGuid().ToString();
                        pspDev.EleID = element.GetAttribute("id");
                        pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        pspDev.Number = -1;
                        pspDev.FirstNode = -1;
                        pspDev.LastNode = -1;
                        pspDev.Type = "Polyline";
                        pspDev.Lable = "支路";
                        Services.BaseService.Create<PSPDEV>(pspDev);
                        dlg = new frmLine(pspDev);
                    }

                    if (dlg.ShowDialog() == DialogResult.OK)
                    {
                        if (dlg.Name == null)
                        {
                            MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                        PSPDEV pspName = new PSPDEV();
                        pspName.Name = dlg.Name;
                        pspName.Type = "Polyline";
                        pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                        if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID))
                        {
                            MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                        pspDev.Name = dlg.Name;
                        pspDev.LineLength = Convert.ToDouble(dlg.LineLength);
                        pspDev.LineLevel = dlg.LineLevel;
                        pspDev.LineType = dlg.LineType;
                        pspDev.LineStatus = dlg.LineStatus;
                        pspDev.PositiveR = Convert.ToDouble(dlg.PositiveR);
                        pspDev.PositiveTQ = Convert.ToDouble(dlg.PositiveTQ);
                        pspDev.ZeroR = Convert.ToDouble(dlg.ZeroR);
                        pspDev.ZeroTQ = Convert.ToDouble(dlg.ZeroTQ);
                        if (dlg.HuganFirst == "是")
                            pspDev.HuganFirst = 1;
                        else
                            pspDev.HuganFirst = 0;
                        pspDev.HuganLine1 = dlg.HuganLine1;
                        pspDev.HuganLine2 = dlg.HuganLine2;
                        pspDev.HuganLine3 = dlg.HuganLine3;
                        pspDev.HuganLine4 = dlg.HuganLine4;
                        pspDev.HuganTQ1 = Convert.ToDouble(dlg.HuganTQ1);
                        pspDev.HuganTQ2 = Convert.ToDouble(dlg.HuganTQ2);
                        pspDev.HuganTQ3 = Convert.ToDouble(dlg.HuganTQ3);
                        pspDev.HuganTQ4 = Convert.ToDouble(dlg.HuganTQ4);
                        pspDev.HuganTQ5 = Convert.ToDouble(dlg.HuganTQ5);
                        string tempp = dlg.LineLev;
                        int tel = tempp.Length;
                        if (tel == 1)
                            pspDev.VoltR = 0;
                        else
                        {
                            //tempp = tempp.Substring(0, tel - 2);
                            pspDev.VoltR = Convert.ToDouble(tempp);
                        }
                        //switch (dlg.LineType)
                        //{
                        //    case "2*LGJ-400":
                        //        {
                        //            pspDev.LineR = Convert.ToDouble(dlg.LineLength) * 0.04;
                        //            pspDev.LineTQ = Convert.ToDouble(dlg.LineLength) * 0.303;
                        //            pspDev.LineGNDC = Convert.ToDouble(dlg.LineLength) * 17.9;
                        //            pspDev.LineChange = 1690;
                        //        } break;
                        //    case "2*LGJ-300":
                        //        {
                        //            pspDev.LineR = Convert.ToDouble(dlg.LineLength) * 0.054;
                        //            pspDev.LineTQ = Convert.ToDouble(dlg.LineLength) * 0.308;
                        //            pspDev.LineGNDC = Convert.ToDouble(dlg.LineLength) * 17.7;
                        //            pspDev.LineChange = 1400;
                        //        } break;
                        //    case "2*LGJ-240":
                        //        {
                        //            pspDev.LineR = Convert.ToDouble(dlg.LineLength) * 0.066;
                        //            pspDev.LineTQ = Convert.ToDouble(dlg.LineLength) * 0.310;
                        //            pspDev.LineGNDC = Convert.ToDouble(dlg.LineLength) * 17.5;
                        //            pspDev.LineChange = 1220;
                        //        } break;
                        //    case "LGJ-400":
                        //        {
                        //            pspDev.LineR = Convert.ToDouble(dlg.LineLength) * 0.08;
                        //            pspDev.LineTQ = Convert.ToDouble(dlg.LineLength) * 0.417;
                        //            pspDev.LineGNDC = Convert.ToDouble(dlg.LineLength) * 13.2;
                        //            pspDev.LineChange = 845;
                        //        } break;

                        //}
                        Services.BaseService.Update<PSPDEV>(pspDev);
                        Topology2();
                    }
                }
            }
            tlVectorControl1.Operation = ToolOperation.Select;
            //contextMenuStrip1.Hide();
        }
Exemplo n.º 34
0
        private async void CustomPrint_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
        {
            if (customPrintTemplate == null)
            {
                var dialog = new MessageDialog("Could not find the data template resource called 'CustomPrintTemplate' under the listview called 'PrintSampleListView'.", "Incomplete XAML");
                await dialog.ShowAsync();

                return;
            }

            SampleController.Current.DisplayWaitRing = true;

            // Provide an invisible container
            _printHelper = new PrintHelper(CustomPrintContainer);

            var pageNumber = 0;

            foreach (var item in PrintSampleItems)
            {
                var grid = new Grid();
                grid.RowDefinitions.Add(new RowDefinition()
                {
                    Height = GridLength.Auto
                });
                grid.RowDefinitions.Add(new RowDefinition()
                {
                    Height = new GridLength(1, GridUnitType.Star)
                });
                grid.RowDefinitions.Add(new RowDefinition()
                {
                    Height = GridLength.Auto
                });

                // Static header
                var header = new TextBlock {
                    Text = "Windows Community Toolkit Sample App - Print Helper - Custom Print", Margin = new Thickness(0, 0, 0, 20)
                };
                Grid.SetRow(header, 0);
                grid.Children.Add(header);

                // Main content with layout from data template
                var cont = new ContentControl();
                cont.ContentTemplate = customPrintTemplate;
                cont.DataContext     = item;
                Grid.SetRow(cont, 1);
                grid.Children.Add(cont);

                // Footer with page number
                pageNumber++;
                var footer = new TextBlock {
                    Text = string.Format("page {0}", pageNumber), Margin = new Thickness(0, 20, 0, 0)
                };
                Grid.SetRow(footer, 2);
                grid.Children.Add(footer);

                _printHelper.AddFrameworkElementToPrint(grid);
            }

            _printHelper.OnPrintCanceled  += PrintHelper_OnPrintCanceled;
            _printHelper.OnPrintFailed    += PrintHelper_OnPrintFailed;
            _printHelper.OnPrintSucceeded += PrintHelper_OnPrintSucceeded;

            var printHelperOptions = new PrintHelperOptions(false);

            printHelperOptions.Orientation = (PrintOrientation)DefaultOrientationComboBox.SelectedItem;

            if (ShowOrientationSwitch.IsOn)
            {
                printHelperOptions.AddDisplayOption(StandardPrintTaskOptions.Orientation);
            }

            await _printHelper.ShowPrintUIAsync("Windows Community Toolkit Sample App", printHelperOptions);
        }
Exemplo n.º 35
0
		public static PrintFunc SetPrintErrorHandler (PrintFunc handler)
		{
			PrintHelper helper = new PrintHelper (handler);
			PrintFuncNative prev = g_set_printerr_handler (helper.Handler);
			helper = new PrintHelper (prev);
			return helper.Invoker;
		}
        private ExporterCollection ConvertInternal(ExporterCollection exporterCollection)
        {
            BaseSection section = table.Parent as BaseSection;

            ISimpleContainer headerRow     = null;
            Point            dataAreaStart = new Point(table.Items[0].Location.X, table.Items[0].Location.Y + base.CurrentPosition.Y);

            base.CurrentPosition = new Point(PrintHelper.DrawingAreaRelativeToParent(this.table.Parent, this.table).Location.X,
                                             base.SectionBounds.DetailArea.Top);

            base.DefaultLeftPosition = base.CurrentPosition.X;

            this.table.Items.SortByLocation();

            // Header

            var  simpleContainer = table.Items[0] as ISimpleContainer;
            Size containerSize   = Size.Empty;

            if (simpleContainer.Items.Count > 0)
            {
                simpleContainer.Location = new Point(simpleContainer.Location.X, simpleContainer.Location.Y);
                simpleContainer.Parent   = (BaseReportItem)this.table;

                base.SaveSectionSize(section.Size);
                containerSize = simpleContainer.Size;

                if (PrintHelper.IsTextOnlyRow(simpleContainer))
                {
                    headerRow = simpleContainer;
                    base.PrepareContainerForConverting(section, headerRow);
                    base.CurrentPosition = ConvertContainer(exporterCollection, headerRow, base.DefaultLeftPosition, base.CurrentPosition);
                }

                GroupHeader row = table.Items[1] as GroupHeader;

                if (row != null)
                {
                    //grouped
                    do
                    {
                        // GetType child navigator
                        IDataNavigator childNavigator = base.DataNavigator.GetChildNavigator;

                        base.Evaluator.SinglePage.IDataNavigator = childNavigator;
                        // Convert Grouping Header

                        base.CurrentPosition = ConvertGroupHeader(exporterCollection, section, base.CurrentPosition);

                        childNavigator.Reset();
                        childNavigator.MoveNext();

                        //Convert children
                        if (childNavigator != null)
                        {
                            do
                            {
                                StandardPrinter.AdjustBackColor(simpleContainer);
                                simpleContainer = table.Items[2] as ISimpleContainer;
                                containerSize   = simpleContainer.Size;

                                FillRow(simpleContainer, childNavigator);
                                FireRowRendering(simpleContainer, childNavigator);
                                PrepareContainerForConverting(section, simpleContainer);
                                base.CurrentPosition = ConvertStandardRow(exporterCollection, simpleContainer);

                                simpleContainer.Size = containerSize;
                                CheckForPageBreak(section, simpleContainer, headerRow, exporterCollection);
                            }while (childNavigator.MoveNext());

                            // GroupFooter
                            base.ConvertGroupFooter(table, exporterCollection);
                            base.PageBreakAfterGroupChange(section, exporterCollection);

                            base.Evaluator.SinglePage.IDataNavigator = base.DataNavigator;
                        }
                    }while (base.DataNavigator.MoveNext());
                }

                else
                {
                    // No Grouping at all

                    simpleContainer = table.Items[1] as ISimpleContainer;
                    base.SaveSectionSize(section.Size);
                    containerSize = simpleContainer.Size;

                    do
                    {
                        PrintHelper.AdjustSectionLocation(section);
                        CheckForPageBreak(section, simpleContainer, headerRow, exporterCollection);

                        FillRow(simpleContainer, base.DataNavigator);
                        FireRowRendering(simpleContainer, base.DataNavigator);
                        base.PrepareContainerForConverting(section, simpleContainer);

                        base.CurrentPosition = ConvertStandardRow(exporterCollection, simpleContainer);
                        simpleContainer.Size = containerSize;
                        section.Size         = base.RestoreSectionSize;
                    }while (base.DataNavigator.MoveNext());
                    base.DataNavigator.Reset();
                    base.DataNavigator.MoveNext();
                    SectionBounds.ReportFooterRectangle = new Rectangle(SectionBounds.ReportFooterRectangle.Left,
                                                                        base.CurrentPosition.Y,
                                                                        SectionBounds.ReportFooterRectangle.Width,
                                                                        SectionBounds.ReportFooterRectangle.Height);
                }
            }
            return(exporterCollection);
        }