예제 #1
0
        private void print(PrintObject printObject)
        {
            ////draw box.

            B_Draw_Box(60, 60, 6, 1150, 650);
            B_Prn_Text_TrueType_Uni(100, 100, 50, "Times New Roman", 1, 400, 0, 0, 0, "A1", Encoding.Unicode.GetBytes("样品编号:"), 1);             //UTF-16
            B_Prn_Text_TrueType_Uni(300, 100, 50, "Times New Roman", 1, 400, 0, 0, 0, "A2", Encoding.Unicode.GetBytes(printObject.SamCode), 1); //UTF-16
            ////划线
            B_Draw_Line('O', 300, 160, 300, 4);
            B_Prn_Text_TrueType_Uni(600, 100, 50, "Times New Roman", 1, 400, 0, 0, 0, "A3", Encoding.Unicode.GetBytes("□待测   □在侧   □已测"), 1); //UTF-16
            B_Prn_Text_TrueType_Uni(100, 200, 50, "Times New Roman", 1, 400, 0, 0, 0, "B1", Encoding.Unicode.GetBytes("监测项目:"), 1);           //UTF-16
            B_Prn_Text_TrueType_Uni(300, 200, 50, "Times New Roman", 1, 400, 0, 0, 0, "B2", Encoding.Unicode.GetBytes(printObject.Name), 1);  //UTF-16
            //////划线
            B_Draw_Line('O', 300, 260, 850, 4);
            //if (reagent.)


            if (printObject.SaveMethod != null)
            {
                B_Prn_Text_TrueType_Uni(100, 300, 50, "Times New Roman", 1, 400, 0, 0, 0, "C7", Encoding.Unicode.GetBytes("保存方法:"), 1);                //UTF-16

                B_Prn_Text_TrueType_Uni(300, 300, 50, "Times New Roman", 1, 400, 0, 0, 0, "C8", Encoding.Unicode.GetBytes(printObject.SaveMethod), 1); //UTF-16
            }

            B_Prn_Text_TrueType_Uni(100, 370, 50, "Times New Roman", 1, 400, 0, 0, 0, "d0", Encoding.Unicode.GetBytes("保存容器:"), 1);                    //UTF-16
            B_Prn_Text_TrueType_Uni(300, 370, 50, "Times New Roman", 1, 400, 0, 0, 0, "d1", Encoding.Unicode.GetBytes(printObject.Container), 1);      //UTF-16
            B_Prn_Text_TrueType_Uni(100, 450, 50, "Times New Roman", 1, 400, 0, 0, 0, "E1", Encoding.Unicode.GetBytes("采样时间:" + printObject.Time), 1); //UTF-16
            B_Draw_Line('O', 600, 500, 280, 4);
            B_Prn_Text_TrueType_Uni(100, 550, 50, "Times New Roman", 1, 400, 0, 0, 0, "F1", Encoding.Unicode.GetBytes(printObject.Company), 1);        //UTF-16
            B_Bar2d_QR(900, 400, 1, 11, 'M', 'A', 0, 0, 0, Encoding.UTF8.GetBytes(printObject.QrCode));

            // output.
            B_Print_Out(1);// copy 2.
        }
예제 #2
0
파일: StartGame.cs 프로젝트: shira789/Games
 static public void Introduction(Board board)
 {
     Console.Clear();
     Console.WriteLine(" *********START*********\n");
     PrintObject.Board(board.Matrix);
     Console.WriteLine("\nYou have finished setting up the game!\n" +
                       "Now choose a point from the enemy board to attack\n");
 }
        public virtual IPrintObject GetCopyOf(IPrintObject sourcePrintObject)
        {
            if (TryGetCopyOfTable(sourcePrintObject))
            {
                var lastTable = Tables.Item(Tables.Count);
                return(new PrintObject(lastTable.Table));
            }
            var sourceObject = new PrintObject(XmlElement);

            return(sourceObject.GetCopyOf(sourcePrintObject));
        }
예제 #4
0
        void AddPrintObject(int startX, int startY, ContentType contentType, string printText, Bitmap image, StringAlignment align)
        {
            PrintObject po = new PrintObject();

            po.startX      = startX;
            po.startY      = startY;
            po.contentType = contentType;
            po.text        = printText;
            po.align       = align;
            po.image       = image;

            printList.Add(po);
        }
        // prints each sheet of the idw(fileIter) to it's own pdf file.
        // if there's more than one sheet referencing the same assembly, they will be combined in one multi-page pdf

        // this is not at all tested yet....
        private Boolean PrintPDF(VDF.Vault.Currency.Entities.FileIteration fileIter, VDF.Vault.Currency.Connections.Connection connection, ref string errMessage, ref string logMessage)
        {
            try
            {
                if (fileIter.EntityName.EndsWith(".idw")) // only print idws
                {
                    // make sure folder exists for downloading idw into.
                    logMessage += "Checking Target Directory...";
                    System.IO.DirectoryInfo targetDir = new System.IO.DirectoryInfo(TargetFolder);
                    if (!targetDir.Exists)
                    {
                        targetDir.Create();
                    }
                    logMessage += "OK" + "\r\n";

                    // download the idw from the vault
                    logMessage += "Downloading idw from the vault...";
                    VDF.Vault.Settings.AcquireFilesSettings downloadSettings = new VDF.Vault.Settings.AcquireFilesSettings(connection)
                    {
                        LocalPath = new VDF.Currency.FolderPathAbsolute(targetDir.FullName),
                    };
                    downloadSettings.AddFileToAcquire(fileIter, VDF.Vault.Settings.AcquireFilesSettings.AcquisitionOption.Download);
                    connection.FileManager.AcquireFiles(downloadSettings);

                    string fileName = downloadSettings.LocalPath.ToString() + @"\" + fileIter.ToString();

                    PrintObject printOb = new PrintObject();
                    string      errMsg  = "";
                    string      logMsg  = "";

                    if (!printOb.printToPDF(fileName, PDFPath, PDFPrinterName, PS2PDFProgrameName, GSWorkingFolder, ref errMsg, ref logMsg))
                    {
                        return(false);
                    }
                    else
                    {
                        return(true);
                    }
                }
                else
                {
                    logMessage += "File is not an idw, nothing to print.";
                    return(true);
                }
            }
            catch (Exception)
            {
                errMessage += "Unknown Error in function PrintPDF\r\n";
                return(false);
            }
        }
예제 #6
0
        public IPrintObject GetCopyOf(IPrintObject sourcePrintObject)
        {
            if (InternalTable == null)
            {
                return(null);
            }
            if (TryAppendCopyOfTable(sourcePrintObject))
            {
                return(new PrintObject(InternalTable));
            }
            var sourceObject = new PrintObject(XmlElement);

            return(sourceObject.GetCopyOf(sourcePrintObject));
        }
예제 #7
0
        //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

        public static bool OpenDoor(sys_configurationprinters pPrinter)
        {
            bool result        = false;
            bool hasPermission = FrameworkUtils.HasPermissionTo("HARDWARE_DRAWER_OPEN");

            if (pPrinter != null && hasPermission)
            {
                try
                {
                    switch (pPrinter.PrinterType.Token)
                    {
                    //Impressora SINOCAN em ambiente Windows
                    case "THERMAL_PRINTER_WINDOWS":
                    //Impressora SINOCAN em ambiente Linux
                    case "THERMAL_PRINTER_LINUX":
                    //Impressora SINOCAN em ambiente WindowsLinux/Socket
                    case "THERMAL_PRINTER_SOCKET":
                    //Impressora SINOCAN em ambiente WindowsLinux/USB
                    case "THERMAL_PRINTER_USB":
                        PrintObject printObjectSINOCAN = new PrintObject(0);
                        // Deprecated
                        //int m = Convert.ToInt32(GlobalFramework.Settings["DoorValueM"]);
                        //int t1 = Convert.ToInt32(GlobalFramework.Settings["DoorValueT1"]);
                        //int t2 = Convert.ToInt32(GlobalFramework.Settings["DoorValueT2"]);
                        // Open Drawer
                        //TK016249 - Impressoras - Diferenciação entre Tipos
                        int m  = GlobalFramework.LoggedTerminal.ThermalPrinter.ThermalOpenDrawerValueM;
                        int t1 = GlobalFramework.LoggedTerminal.ThermalPrinter.ThermalOpenDrawerValueT1;
                        int t2 = GlobalFramework.LoggedTerminal.ThermalPrinter.ThermalOpenDrawerValueT2;
                        printObjectSINOCAN.OpenDoor(pPrinter.PrinterType.Token, pPrinter.NetworkName, m, t1, t2);
                        //Audit
                        FrameworkUtils.Audit("CASHDRAWER_OPEN", resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "audit_message_cashdrawer_open"));

                        break;
                    }

                    result = true;
                }
                catch (Exception ex)
                {
                    _log.Warn(ex.Message, ex);
                }
            }

            return(result);
        }
 public static bool CreateNewPdfFile(PrintObject printObject)
 {
     if (printObject.FilePaths == null)
     {
         return(false);
     }
     printObject.NewPdfFile = new PdfDocument(new PdfWriter(printObject.PathName));
     foreach (var fileName in printObject.FilePaths)
     {
         var selectedPdfDocument = new PdfDocument(new PdfReader(fileName));
         int numberOfPages       = selectedPdfDocument.GetNumberOfPages();
         selectedPdfDocument.CopyPagesTo(1, numberOfPages, printObject.NewPdfFile);
         if (numberOfPages % 2 == 1 && printObject.FilePaths.Last() != fileName)
         {
             printObject.NewPdfFile.AddNewPage();
         }
     }
     printObject.NewPdfFile.Close();
     return(true);
 }
예제 #9
0
        public void CopyBookmark()
        {
            using (var doc = WordprocessingDocument.Open(TemplatePath, true, new OpenSettings {
                AutoSave = false
            }))
            {
                var table = new WordDocumentTable(doc);
                table.Select("Table1");
                var bookmarks = new WordDocumentBookmarks(doc);
                var bkm       = new WordDocumentBookmark(doc);
                bkm.Select("order_caption");
                var dest = new PrintObject(table.Table);

                Assert.IsFalse(bookmarks.Exists("order_caption_copy"));

                bkm.CopyTo(dest);

                Assert.IsTrue(bookmarks.Exists("order_caption_copy"));
            }
        }
예제 #10
0
        public void LocateSubmarinesOnBoard(Player player)
        {
            bool   IsSuccess = true;
            string message   = null;

            SetGame.SetUp();

            for (int i = 0; i < player.Submarines.Length; i++)
            {
                do
                {
                    if (!IsSuccess)
                    {
                        message = "Error Placing the submarine, try another points";
                    }
                    Point[]        points    = SetGame.GetSubmarineEdgePoints(player.Submarines[i], player.MyBoard.Matrix, message);
                    PlaceSubmarine placeTool = new PlaceSubmarine(ref player.Submarines[i], points[0], points[1], PlayerA.MyBoard);
                    IsSuccess = placeTool.IsPlaced();
                } while (!IsSuccess);
            }
            PrintObject.Board(PlayerA.MyBoard.Matrix);
        }
예제 #11
0
        public void GetCopyOfTableToFooter()
        {
            using (var doc = WordprocessingDocument.Open(TemplatePath, true, new OpenSettings {
                AutoSave = false
            }))
            {
                var table = new WordDocumentTable(doc);
                table.Select("Table1");
                var footer = doc.MainDocumentPart.FooterParts
                             .Select(f => f.Footer)
                             .LastOrDefault();

                var source = new PrintObject(table.Table);
                var dest   = new PrintObject(footer);

                Assert.AreEqual(footer.Descendants <Table>().Count(), 0);

                dest.GetCopyOf(source);

                Assert.AreEqual(footer.Descendants <Table>().Count(), 1);
            }
        }
예제 #12
0
파일: SetGame.cs 프로젝트: shira789/Games
        public static Point[] GetSubmarineEdgePoints(Submarine submarine, Square[,] matrix, string message = null)
        {
            Point[] endPoints = new Point[2];
            Console.WriteLine(message + "\n");

            Console.WriteLine("Place the following Submarine:\t");
            PrintObject.Submarine(submarine.Size);
            PrintObject.Board(matrix);

            for (int i = 0; i < 2; i++)
            {
                endPoints[i] = new Point();
                InputPoint.GetPoint(ref endPoints[i]);

                if (endPoints[0] == endPoints[1] && endPoints[0] != null)
                {
                    Console.WriteLine("Choose 2 different points from each other");
                    i = 0;
                }
            }

            return(endPoints);
        }
예제 #13
0
        int AlignCenter(PrintObject po)
        {
            int startPosition = 0;
            int objectSize    = 0;
            int pageSize      = 150;

            if (po.contentType == ContentType.Text)
            {
                SizeF textSize = printGraphics.MeasureString(po.text, printFont);
                objectSize = (int)textSize.Width;
            }
            else if (po.contentType == ContentType.BoldText)
            {
                SizeF textSize = printGraphics.MeasureString(po.text, printFont);
                objectSize = (int)textSize.Width;
            }
            else if (po.contentType == ContentType.Image)
            {
                objectSize = po.image.Height;
            }

            startPosition = ((pageSize - objectSize) / 2);
            return(startPosition);
        }
        public IPrintObject CopyTo(IPrintObject destPrintObject)
        {
            var sourceObject = new PrintObject(XmlElement);

            return(sourceObject.CopyTo(destPrintObject));
        }
예제 #15
0
        public IPrintObject GetCopyOf(IPrintObject sourcePrintObject)
        {
            var sourceObject = new PrintObject(XmlElement);

            return(sourceObject.GetCopyOf(sourcePrintObject));
        }
예제 #16
0
파일: SetGame.cs 프로젝트: shira789/Games
 public static void Introduction(Player player)
 {
     Console.WriteLine("Welcome to the Submarine Game! this is your board, and your submarine Territory.\n");
     PrintObject.Board(player.MyBoard.Matrix);
 }
        //  use ERP names instead of file names.
        private Boolean PDFfileUpdate(VDF.Vault.Currency.Entities.FileIteration fileIter, VDF.Vault.Currency.Connections.Connection connection, ref string logMessage, ref string errMessage)
        {
            try
            {
                // download the file
                System.IO.DirectoryInfo targetDir = new System.IO.DirectoryInfo(m_TargetFolder);
                if (!targetDir.Exists)
                {
                    targetDir.Create();
                }

                VDF.Vault.Settings.AcquireFilesSettings downloadSettings = new VDF.Vault.Settings.AcquireFilesSettings(connection)
                {
                    LocalPath = new VDF.Currency.FolderPathAbsolute(targetDir.FullName),
                };
                downloadSettings.AddFileToAcquire(fileIter, VDF.Vault.Settings.AcquireFilesSettings.AcquisitionOption.Download);

                VDF.Vault.Results.AcquireFilesResults results =
                    connection.FileManager.AcquireFiles(downloadSettings);

                string fileName = downloadSettings.LocalPath.ToString() + @"\" + fileIter.ToString();

                // ipts and iams are easier to deal with than idws
                if (fileName.EndsWith(".ipt") || fileName.EndsWith(".iam"))
                {
                    PrintObject printOb = new PrintObject();

                    if (printOb.deletePDF(fileName, m_PDFPath, ref logMessage, ref errMessage))
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else if (fileName.EndsWith(".idw")) // for idws we have to loop through each drawing sheet
                {
                    try
                    {
                        string modelName = "";

                        // set up lists for storing the actual model names the sheets are referencing
                        List <string> modelNames = new List <string>();
                        List <VDF.Vault.Currency.Entities.FileIteration> fIterations = new List <VDF.Vault.Currency.Entities.FileIteration>();

                        VDF.Vault.Currency.Properties.PropertyDefinitionDictionary propDefs =
                            new VDF.Vault.Currency.Properties.PropertyDefinitionDictionary();
                        Inventor.ApprenticeServerComponent       oApprentice = new ApprenticeServerComponent();
                        Inventor.ApprenticeServerDrawingDocument drgDoc;
                        drgDoc = (Inventor.ApprenticeServerDrawingDocument)oApprentice.Document;
                        oApprentice.Open(fileName);
                        drgDoc = (Inventor.ApprenticeServerDrawingDocument)oApprentice.Document;
                        ACW.PropDef[] filePropDefs =
                            connection.WebServiceManager.PropertyService.GetPropertyDefinitionsByEntityClassId("FILE");
                        ACW.PropDef vaultNamePropDef = filePropDefs.Single(n => n.SysName == "Name");

                        // for each sheet in the idw, search the vault for the sheet's corresponding ipt or iam
                        foreach (Sheet sh in drgDoc.Sheets)
                        {
                            if (sh.DrawingViews.Count > 0)  // I added this line because one pdf with a BOM only sheet
                                                            // kept failing.  This line fixed the problemf or that file
                                                            // but it is definitely not well tested...
                            {
                                errMessage += " " + sh.DrawingViews[1].ReferencedDocumentDescriptor.DisplayName + "found";
                                if (sh.DrawingViews.Count > 0)
                                {
                                    modelName = sh.DrawingViews[1].ReferencedDocumentDescriptor.DisplayName;

                                    PrintObject printOb = new PrintObject();
                                    if (printOb.deletePDF(modelName, m_PDFPath, ref logMessage, ref errMessage))
                                    {
                                        //logMessage += "Deleted PDF: " + pair.Value.Value.ToString() + "\r\n";
                                        //we already logged a message in the deletePDF function
                                    }
                                    else
                                    {
                                        logMessage += logMessage;
                                        errMessage += "Can not delete PDF Error1 in function FileUpdate\r\n";
                                        return(false);
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        logMessage += logMessage;
                        errMessage += "Can not delete PDF Error2 in function FileUpdate\r\n" + ex.Message + "\r\n";
                        return(false);
                    }
                }
                return(true);
            }

            catch (Exception)
            {
                logMessage += logMessage;
                errMessage += errMessage;
                return(false);
            }
        }
예제 #18
0
        private void print(PrintObject printObject)
        {
            ////draw box.

            B_Draw_Box(60, 60, 6, 1150, 650);
            B_Prn_Text_TrueType_Uni(100, 100, 50, "Times New Roman", 1, 400, 0, 0, 0, "A1", Encoding.Unicode.GetBytes("样品编号:"), 1);             //UTF-16
            B_Prn_Text_TrueType_Uni(300, 100, 50, "Times New Roman", 1, 400, 0, 0, 0, "A2", Encoding.Unicode.GetBytes(printObject.SamCode), 1); //UTF-16
            ////划线
            B_Draw_Line('O', 300, 160, 300, 4);
            B_Prn_Text_TrueType_Uni(600, 100, 50, "Times New Roman", 1, 400, 0, 0, 0, "A3", Encoding.Unicode.GetBytes("□待测   □在侧   □已测"), 1); //UTF-16
            B_Prn_Text_TrueType_Uni(100, 200, 50, "Times New Roman", 1, 400, 0, 0, 0, "B1", Encoding.Unicode.GetBytes("监测项目:"), 1);           //UTF-16
            B_Prn_Text_TrueType_Uni(300, 200, 50, "Times New Roman", 1, 400, 0, 0, 0, "B2", Encoding.Unicode.GetBytes(printObject.Name), 1);  //UTF-16
            //////划线
            B_Draw_Line('O', 300, 260, 850, 4);
            //if (reagent.)
            if (printObject.Reagent.Equals("硝酸"))
            {
                B_Prn_Text_TrueType_Uni(80, 300, 50, "Times New Roman", 1, 400, 0, 0, 0, "C7", Encoding.Unicode.GetBytes("■"), 1);//UTF-16
            }
            else
            {
                B_Prn_Text_TrueType_Uni(80, 300, 50, "Times New Roman", 1, 400, 0, 0, 0, "C0", Encoding.Unicode.GetBytes("□"), 1); //UTF-16
            }
            B_Prn_Text_TrueType_Uni(100, 300, 50, "Times New Roman", 1, 400, 0, 0, 0, "C1", Encoding.Unicode.GetBytes("硝酸"), 1);   //UTF-16
            if (printObject.Reagent.Equals("硫酸"))
            {
                B_Prn_Text_TrueType_Uni(280, 300, 50, "Times New Roman", 1, 400, 0, 0, 0, "C7", Encoding.Unicode.GetBytes("■"), 1);//UTF-16
            }
            else
            {
                B_Prn_Text_TrueType_Uni(280, 300, 50, "Times New Roman", 1, 400, 0, 0, 0, "C0", Encoding.Unicode.GetBytes("□"), 1); //UTF-16
            }
            B_Prn_Text_TrueType_Uni(300, 300, 50, "Times New Roman", 1, 400, 0, 0, 0, "C2", Encoding.Unicode.GetBytes("硫酸"), 1);    //UTF-16
            if (printObject.Reagent.Equals("盐酸"))
            {
                B_Prn_Text_TrueType_Uni(480, 300, 50, "Times New Roman", 1, 400, 0, 0, 0, "C7", Encoding.Unicode.GetBytes("■"), 1);//UTF-16
            }
            else
            {
                B_Prn_Text_TrueType_Uni(480, 300, 50, "Times New Roman", 1, 400, 0, 0, 0, "C0", Encoding.Unicode.GetBytes("□"), 1); //UTF-16
            }
            B_Prn_Text_TrueType_Uni(500, 300, 50, "Times New Roman", 1, 400, 0, 0, 0, "C3", Encoding.Unicode.GetBytes("盐酸"), 1);    //UTF-16
            if (printObject.Reagent.Equals("磷酸"))
            {
                B_Prn_Text_TrueType_Uni(680, 300, 50, "Times New Roman", 1, 400, 0, 0, 0, "C7", Encoding.Unicode.GetBytes("■"), 1);//UTF-16
            }
            else
            {
                B_Prn_Text_TrueType_Uni(680, 300, 50, "Times New Roman", 1, 400, 0, 0, 0, "C0", Encoding.Unicode.GetBytes("□"), 1); //UTF-16
            }
            B_Prn_Text_TrueType_Uni(700, 300, 50, "Times New Roman", 1, 400, 0, 0, 0, "C4", Encoding.Unicode.GetBytes("磷酸"), 1);    //UTF-16
            if (printObject.Reagent.Equals("碱"))
            {
                B_Prn_Text_TrueType_Uni(880, 300, 50, "Times New Roman", 1, 400, 0, 0, 0, "C7", Encoding.Unicode.GetBytes("■"), 1); //UTF-16
            }
            else
            {
                B_Prn_Text_TrueType_Uni(880, 300, 50, "Times New Roman", 1, 400, 0, 0, 0, "C0", Encoding.Unicode.GetBytes("□"), 1); //UTF-16
            }
            B_Prn_Text_TrueType_Uni(900, 300, 50, "Times New Roman", 1, 400, 0, 0, 0, "C5", Encoding.Unicode.GetBytes("碱"), 1);     //UTF-16
            if (printObject.Reagent.Equals("其他"))
            {
                B_Prn_Text_TrueType_Uni(1030, 300, 50, "Times New Roman", 1, 400, 0, 0, 0, "C7", Encoding.Unicode.GetBytes("■"), 1); //UTF-16
            }
            else
            {
                B_Prn_Text_TrueType_Uni(1030, 300, 50, "Times New Roman", 1, 400, 0, 0, 0, "C0", Encoding.Unicode.GetBytes("□"), 1);              //UTF-16
            }
            B_Prn_Text_TrueType_Uni(1050, 300, 50, "Times New Roman", 1, 400, 0, 0, 0, "C6", Encoding.Unicode.GetBytes("其他"), 1);                 //UTF-16
            B_Prn_Text_TrueType_Uni(350, 370, 50, "Times New Roman", 1, 400, 0, 0, 0, "d1", Encoding.Unicode.GetBytes(printObject.Container), 1); //UTF-16
            B_Prn_Text_TrueType_Uni(350, 450, 50, "Times New Roman", 1, 400, 0, 0, 0, "E1", Encoding.Unicode.GetBytes(printObject.Time), 1);      //UTF-16
            B_Prn_Text_TrueType_Uni(350, 550, 50, "Times New Roman", 1, 400, 0, 0, 0, "F1", Encoding.Unicode.GetBytes(printObject.Company), 1);   //UTF-16
            B_Bar2d_QR(900, 400, 1, 11, 'M', 'A', 0, 0, 0, Encoding.UTF8.GetBytes(printObject.QrCode));

            // output.
            B_Print_Out(1);// copy 2.
        }
예제 #19
0
        private void PrintEvent()
        {
            string samCode = tbSamCode.Text;

            if (samCode.Equals(""))
            {
                MessageBox.Show("请输入采样编号");
                return;
            }

            string company = tbCompany.Text;

            if (company.Equals(""))
            {
                MessageBox.Show("请输入检测公司名称");
                return;
            }

            //准备要打印的数据,首先计算一下选中的总数量
            int rowsCount = dgSamData.Rows.Count;
            int count     = 0;

            for (int i = 0; i < rowsCount; i++)
            {
                //                DataGridViewCheckBoxCell dataGridViewCheckBoxCell = ((DataGridViewCheckBoxCell) dgSamData.Rows[i].Cells["Column1"]);
                //                if (dataGridViewCheckBoxCell.Value.Equals("true"))
                //                {
                //                    MessageBox.Show("有选中的,第" + i + "行");
                //
                //                }
                DataGridViewCheckBoxCell dataGridViewCheckBoxCell =
                    ((DataGridViewCheckBoxCell)dgSamData.Rows[i].Cells["Column1"]);
                if (dataGridViewCheckBoxCell.Value == dataGridViewCheckBoxCell.TrueValue)
                {
                    DataGridViewTextBoxCell countTextBoxCell =
                        (DataGridViewTextBoxCell)dgSamData.Rows[i].Cells["Column7"];
                    Debug.Assert(countTextBoxCell != null, "countTextBoxCell != null");
                    count += (int)countTextBoxCell.Value;
                    Console.WriteLine("选中了第" + i + "行,数量是:" + countTextBoxCell.Value + "总数量是:" + count);
                    Console.WriteLine("------------");
                }
            }
            //初始化打印环境
            initialPrint();
            for (int i = 0; i < rowsCount; i++)
            {
                DataGridViewCheckBoxCell dataGridViewCheckBoxCell =
                    ((DataGridViewCheckBoxCell)dgSamData.Rows[i].Cells["Column1"]);
                if (dataGridViewCheckBoxCell.Value == dataGridViewCheckBoxCell.TrueValue)
                {
                    //这里进行选中对象转换
                    DataGridViewTextBoxCell countTextBoxCell =
                        (DataGridViewTextBoxCell)dgSamData.Rows[i].Cells["Column7"];
                    //这是要循环打印的次数
                    int printCount = (int)countTextBoxCell.Value;
                    for (int j = 0; j < printCount; j++)
                    {
                        PrintObject printObject = new PrintObject();
                        printObject.Company    = company;
                        printObject.Container  = (string)dgSamData.Rows[i].Cells["Column5"].Value;
                        printObject.SaveMethod = (string)dgSamData.Rows[i].Cells["Column6"].Value;
                        Console.WriteLine(printObject.SaveMethod);
                        //取得分组编号单元格
                        DataGridViewTextBoxCell dataGridViewTextBoxCell =
                            (DataGridViewTextBoxCell)dgSamData.Rows[i].Cells["Column2"];
                        if (dataGridViewTextBoxCell.Value == null)
                        {
                            DataGridViewTextBoxCell nameViewTextBoxCell =
                                (DataGridViewTextBoxCell)dgSamData.Rows[i].Cells["Column3"];
                            printObject.Name = (string)nameViewTextBoxCell.Value;
                        }
                        else
                        {
                            printObject.Name = (string)dataGridViewTextBoxCell.Value;
                        }

                        printObject.Reagent = (string)dgSamData.Rows[i].Cells["Column4"].Value;
                        //                        if (printCount > 1)
                        //                        {
                        printObject.SamCode = samCode + "-" + printNum;
                        //                        }
                        //                        else
                        //                        {
                        //                            printObject.SamCode = samCode;
                        //                        }

                        printObject.QrCode = samCode + "#" + printNum + "#" + count;
                        printObject.Time   = DateTime.Now.ToLongDateString();
                        print(printObject);
                        printNum++;
                    }
                }
            }
            B_ClosePrn();
            printNum = 1;
        }
예제 #20
0
 public Form1()
 {
     InitializeComponent();
     _printObject = new PrintObject();
 }