Ejemplo n.º 1
0
        public static void printare(int index, string cnp)
        {
            try{
               FileStream f = new FileStream("Print.doc", FileMode.Truncate, FileAccess.ReadWrite, FileShare.ReadWrite);
               //f = new FileStream("Print.txt", FileMode.OpenOrCreate, FileAccess.Write, FileShare.ReadWrite);

               StreamWriter f_out = new StreamWriter(f);
               int i, nr = 0, nr_crt = 0, i1 = "rezultate_H".Length, j;
               string s;

               string nume, dn, danlz, adresa, nrtel, email, medic, nrtel_spital, spital, H, IS, B, ME, rezH, rezIS, rezB, rezME;
               OleDbConnection aConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=MedLab_DataBase.mdb");
               aConnection.Open();
               OleDbCommand aCommand = new OleDbCommand("SELECT * FROM INREGISTRARI WHERE IDCerere=@index", aConnection);
               aCommand.Parameters.Add("@index", OleDbType.Integer, 100, "IDCerere").Value = index;

               OleDbDataReader myreader = aCommand.ExecuteReader(CommandBehavior.CloseConnection);
               myreader.Read();
               medic = myreader.GetString(4);
               nume = myreader.GetString(2);
               spital = myreader.GetString(5);
               danlz = myreader.GetString(7);
               nrtel_spital = myreader.GetString(8);
               H = myreader.GetString(9);
               IS = myreader.GetString(10);
               B = myreader.GetString(11);
               ME = myreader.GetString(12);
               rezH = myreader.GetString(14);
               rezIS = myreader.GetString(15);
               rezB = myreader.GetString(16);
               rezME = myreader.GetString(17);

               myreader.Close();
               OleDbConnection aConnection2 = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=MedLab_DataBase.mdb");
               aConnection2.Open();
               OleDbCommand aCommand2 = new OleDbCommand("SELECT * FROM Pacienti WHERE Cnp=@cnp", aConnection2);
               aCommand2.Parameters.Add("@cnp", OleDbType.VarChar, 100, "Cnp").Value = cnp;

               OleDbDataReader myreader2 = aCommand2.ExecuteReader(CommandBehavior.CloseConnection);
               myreader2.Read();
               nrtel = myreader2.GetString(2);
               email = myreader2.GetString(3);
               adresa = myreader2.GetString(4);
               dn = myreader2.GetString(5);

               try
               {
               s = "\t\t\t\tBULETIN DE ANALIZE\n\n\n\n\n";
               f_out.Write(s);
               s = "\tNUME PACIENT\t\t\t" + nume + "\n" + "\tDATA NASTERII\t\t\t" + dn + "\n" + "\tCNP\t\t\t\t" + cnp + "\n" + "\tADRESA\t\t\t\t" + adresa + "\n" + "\tTELEFON\t\t\t\t" + nrtel + "\n" + "\tEMAIL\t\t\t\t" + email + "\n\n" + "\tMEDIC\t\t\t\t" + medic + "\n" + "\tINSTITUTIE\t\t\t\t" + spital + "\n\n" + "\tDATA EFECTUARII ANALIZELOR\t" + danlz + "\n\n\n\n\n";
               f_out.Write(s);

               s = ".............................................................................\n";
               f_out.Write(s);
               s = "DENUMIRE\t\tREZULTAT\tUM\tVALORI DE REFERINTA\n";
               f_out.Write(s);
               s = ".............................................................................\n";
               f_out.Write(s);
               if (H.Length > 4)
               {
                   s = "HEMATOLOGIE\n";
                   f_out.Write(s);
                   for (i = 4; i < H.Length; i++)
                   {
                       if (H[i] != ';')
                       {
                           nr = nr * 10 + int.Parse(H[i].ToString());
                       }
                       else
                       {
                           nr_crt++;
                           s = nr_crt.ToString() + "." + s1[nr].Substring(0, s1[nr].IndexOf(' '));
                           nr = 0;
                           f_out.Write(s);
                           //i1=i2= "rezultate_h".Length;
                           s = "";
                           for (j = i1; j < rezH.Length; j++)
                           {
                               if (rezH[j] != ';')
                               {
                                   s += rezH[j].ToString();

                               }
                               else { s += "\n"; f_out.Write(s); i1 = j; j = rezH.Length; s = ""; }

                           }

                           // f_out.Write("\n");

                       }
                   }
               }

               if (IS.Length > 4)
               {
                   s = "IMUNOLOGIE SI SEROLOGIE\n";
                   f_out.Write(s);
                   for (i = 4; i < IS.Length; i++)
                   {
                       if (IS[i] != ';')
                       {
                           nr = nr * 10 + int.Parse(IS[i].ToString());
                       }
                       else
                       {
                           nr_crt++;
                           s = nr_crt.ToString() + "." + s3[nr].Substring(0, s3[nr].IndexOf(' ')) + "\n";
                           nr = 0;
                           f_out.Write(s);
                       }
                   }
               }

               if (ME.Length > 4)
               {
                   s = "MARKERI ENDOCRINI\n";
                   f_out.Write(s);
                   for (i = 4; i < ME.Length; i++)
                   {
                       if (ME[i] != ';')
                       {
                           nr = nr * 10 + int.Parse(ME[i].ToString());
                       }
                       else
                       {
                           nr_crt++;
                           s = nr_crt.ToString() + "." + s4[nr].Substring(0, s4[nr].IndexOf(' ')) + "\n";
                           nr = 0;
                           f_out.Write(s);
                       }
                   }
               }
               if (B.Length > 4)
               {
                   s = "BIOCHIMIE\n";
                   f_out.Write(s);
                   for (i = 4; i < B.Length; i++)
                   {
                       if (B[i] != ';')
                       {
                           nr = nr * 10 + int.Parse(B[i].ToString());
                       }
                       else
                       {
                           nr_crt++;
                           s = nr_crt.ToString() + "." + s2[nr].Substring(0, s2[nr].IndexOf(' ')) + "\n";
                           nr = 0;
                           f_out.Write(s);
                       }
                   }

               }
               }
               catch (IOException exc)
               {
               Console.WriteLine(exc.Message + "print");
               }
               f_out.Close();

               // Get the path that stores user documents.
               string myDocumentsPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
               PrintDialog pd = new PrintDialog();
               System.Drawing.Printing.PrintDocument docToPrint = new System.Drawing.Printing.PrintDocument();
               docToPrint.DocumentName = "Print.doc";

               pd.Dispose();

               pd.Document = docToPrint;

               DialogResult result = pd.ShowDialog();

               // If the result is OK then print the document.
               if (result == DialogResult.OK)
               {
                   docToPrint.Print();
               }

               }
               catch (Exception exc)
               {

               Console.WriteLine(exc.Message.ToString());

               }
        }
Ejemplo n.º 2
0
        private void printToolStripMenuItem_Click(object sender, EventArgs e)
        {
            PrintDocument printDocument = new PrintDocument();
            printDocument.PrintPage += PrintDocument_PrintPage;

            PrintDialog dialog = new PrintDialog();
            dialog.PrinterSettings = printDocument.PrinterSettings;

            if (dialog.ShowDialog(this) == DialogResult.OK)
            {
                printDocument.Print();
            }
            dialog.Dispose();
        }
Ejemplo n.º 3
0
        private void Print()
        {
            PrintDialog printDialog = new PrintDialog();
            PrintDocument printImage = new PrintDocument();

            printImage.DocumentName = "Cropper Captured Image";
            printImage.PrintPage += OnPrintPage;

            printDialog.Document = printImage;

            DialogResult result = printDialog.ShowDialog();

            // Send print message
            try
            {
                if (result == DialogResult.OK)
                    printImage.Print();
            }
            catch (InvalidPrinterException)
            {
                ShowPrintError();
            }
            finally
            {
                printImage.Dispose();
                printDialog.Dispose();
            }
        }
Ejemplo n.º 4
0
        public void PrinterSetting()
        {
            PrintDialog pDlg = new PrintDialog();
            PrintPreviewDialog ppDlg = new PrintPreviewDialog();
            try
            {
                //��������ֵ��PrinterSettings
                PrinterSettings ps = new PrinterSettings();

                //����ѡ��ҳ
                pDlg.AllowSomePages = true;

                //ָ����ӡ�ĵ�
                pDlg.Document = document;

                //��ʾ�Ի���
                DialogResult result = pDlg.ShowDialog();
                if (result == DialogResult.OK)
                {
                    //�����ӡ����
                    ps = pDlg.PrinterSettings;

                    ppDlg.Text = "��ӡԤ��";
                    ppDlg.WindowState = FormWindowState.Maximized;
                    ppDlg.PrintPreviewControl.Zoom = 1;
                    //ָ����ӡ�ĵ�
                    ppDlg.Document = document;
                    ppDlg.ShowDialog();
                }

            }
            catch (System.Drawing.Printing.InvalidPrinterException e)
            {
                MessageBox.Show("�����ڿ��������Ӵ�ӡ��!", "δ�ҵ���ӡ��");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "��ӡ����");
            }
            finally
            {
                pDlg.Dispose();
                pDlg = null;
                ppDlg.Dispose();
                ppDlg = null;
            }
        }