private void BtnGit_Click(object sender, EventArgs e)
        {
            try
            {
                BtnTaburcu.Enabled = true;
                btnSecSil.Enabled  = true;
                int z = 0;
                lblFiyat.Text = "";
                Hasta hastaBilgisi = Veritabani.TaburcuKontrol(txtOncekiIslem.Text, txtDosyaNo.Text);
                dataGridView1.DataSource = Veritabani.IslemAra("tblSevk", txtOncekiIslem.Text, txtDosyaNo.Text).Tables[0];
                if (dataGridView1.Rows.Count > 0)
                {
                    for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
                    {
                        DataGridViewCellStyle renk = new DataGridViewCellStyle();
                        if (Convert.ToBoolean(dataGridView1.Rows[i].Cells["taburcu"].Value) == true)
                        {
                            renk.BackColor = Color.White;
                            renk.ForeColor = Color.Black;
                        }
                        else
                        {
                            z++;
                            renk.BackColor = Color.Red;
                            renk.ForeColor = Color.Black;
                        }
                        dataGridView1.Rows[i].DefaultCellStyle = renk;
                    }
                }

                if (z == 0)
                {
                    MessageBox.Show("Hasta bu sevkten taburcu edilmiş.", "UYARI", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    BtnTaburcu.Enabled = false;
                }
                else
                {
                    BtnTaburcu.Enabled = true;
                    lblFiyat.Text      = Veritabani.FiyatHesapla(txtDosyaNo.Text, txtOncekiIslem.Text).ToString();
                }
            }
            catch (Exception a)
            {
                MessageBox.Show("Bir hata oluştu:" + a.Message, "UYARI", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
        private void PdDocument_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            int          iTopMargin = 0;
            StringFormat sformat    = new StringFormat();

            sformat.Alignment = StringAlignment.Near;
            e.Graphics.DrawString((DateTime.Now.ToShortDateString()), govde, sb, 700, 50);
            e.Graphics.DrawString("Selçuk Üniversitesi Tıp Fakültesi Hastanesi", baslik, sb, 250, 220);
            Image aImg = Image.FromFile(@"logo.png");

            e.Graphics.DrawImage(aImg, 20, 40, 220, 170);
            try
            {
                int iLeftMargin = 100;
                iTopMargin = 0;
                bool bMorePagesToPrint = false;
                int  iTmpWidth         = 0;
                bFirstPage = true;

                if (bFirstPage)
                {
                    foreach (DataGridViewColumn GridCol in dataGridView1.Columns)
                    {
                        iTmpWidth = (int)(Math.Floor((double)((double)GridCol.Width /
                                                              (double)iTotalWidth * (double)iTotalWidth *
                                                              ((double)e.MarginBounds.Width / (double)iTotalWidth))));

                        iHeaderHeight = (int)(e.Graphics.MeasureString(GridCol.HeaderText,
                                                                       GridCol.InheritedStyle.Font, iTmpWidth).Height) + 11;


                        arrColumnLefts.Add(iLeftMargin);
                        arrColumnWidths.Add(iTmpWidth);
                        iLeftMargin += iTmpWidth;
                    }
                }

                while (iRow <= dataGridView1.Rows.Count - 1)
                {
                    DataGridViewRow GridRow = dataGridView1.Rows[iRow];

                    iCellHeight = GridRow.Height + 5;
                    int iCount = 0;

                    if (iTopMargin + iCellHeight >= e.MarginBounds.Height + e.MarginBounds.Top)
                    {
                        bNewPage          = true;
                        bFirstPage        = false;
                        bMorePagesToPrint = true;
                        break;
                    }
                    else
                    {
                        if (bNewPage)
                        {
                            iTopMargin = 250;
                            foreach (DataGridViewColumn GridCol in dataGridView1.Columns)
                            {
                                e.Graphics.FillRectangle(new SolidBrush(Color.LightGray),
                                                         new Rectangle((int)arrColumnLefts[iCount], iTopMargin,
                                                                       (int)arrColumnWidths[iCount], iHeaderHeight));

                                e.Graphics.DrawRectangle(Pens.Black,
                                                         new Rectangle((int)arrColumnLefts[iCount], iTopMargin,
                                                                       (int)arrColumnWidths[iCount], iHeaderHeight));

                                e.Graphics.DrawString(GridCol.HeaderText, GridCol.InheritedStyle.Font,
                                                      new SolidBrush(GridCol.InheritedStyle.ForeColor),
                                                      new RectangleF((int)arrColumnLefts[iCount], iTopMargin,
                                                                     (int)arrColumnWidths[iCount], iHeaderHeight), strFormat);
                                iCount++;
                            }
                            bNewPage    = false;
                            iTopMargin += iHeaderHeight;
                        }
                        iCount = 0;

                        foreach (DataGridViewCell Cel in GridRow.Cells)
                        {
                            if (Cel.Value != null)
                            {
                                e.Graphics.DrawString(Cel.Value.ToString(), Cel.InheritedStyle.Font,
                                                      new SolidBrush(Cel.InheritedStyle.ForeColor),
                                                      new RectangleF((int)arrColumnLefts[iCount], (float)iTopMargin,
                                                                     (int)arrColumnWidths[iCount], (float)iCellHeight), strFormat);
                            }

                            e.Graphics.DrawRectangle(Pens.Black, new Rectangle((int)arrColumnLefts[iCount],
                                                                               iTopMargin, (int)arrColumnWidths[iCount], iCellHeight));

                            iCount++;
                        }
                    }
                    iRow++;
                    iTopMargin += iCellHeight;
                }


                if (bMorePagesToPrint)
                {
                    e.HasMorePages = true;
                }
                else
                {
                    e.HasMorePages = false;
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            e.Graphics.DrawString("Toplam tutar:" + Veritabani.FiyatHesapla(txtDosyaNo.Text, txtOncekiIslem.Text).ToString(), baslik, sb, 600, iTopMargin + 10);
            e.Graphics.DrawString(Veritabani.doktorIsmi(drKodu), baslik, sb, 550, iTopMargin + 60);
            e.Graphics.DrawString("İmza", baslik, sb, 550, iTopMargin + 80);
            e.Graphics.DrawString(DateTime.Now.ToShortDateString(), baslik, sb, 550, iTopMargin + 100);
        }