Exemple #1
0
        private void xxxxx(object sender, EventArgs e)
        {
            int tstID = (int)tstGridView.GetFocusedRowCellValue(colTSTIDt);

            rprTklfTableAdapter.Fill(teklifDataSet.RPR_TKLF, tstID, "T");
            TeklifDataSet.RPR_TKLFRow rprTklfRow = (TeklifDataSet.RPR_TKLFRow)teklifDataSet.RPR_TKLF.Rows[0];

            hdrTmp = rprTklfRow.USTNOT;

            PrintingSystem         ps   = new PrintingSystem();
            PrintableComponentLink link = new PrintableComponentLink(ps);

            link.Component = tsfGridControl;

            link.PaperKind      = System.Drawing.Printing.PaperKind.A4;
            link.Landscape      = true;
            link.Margins.Left   = 50;
            link.Margins.Right  = 50;
            link.Margins.Top    = 50;
            link.Margins.Bottom = 50;

            var    Font = new Font("Tahoma", 10, FontStyle.Bold);
            object frm  = tstGridView.GetFocusedRowCellDisplayText(colFRTIDt);
            object rot  = tstGridView.GetFocusedRowCellValue(colROTt);
            object mot  = tstGridView.GetFocusedRowCellValue(colMOTt);
            object hOrg = tstGridView.GetFocusedRowCellValue(colORGSt);
            object hDst = tstGridView.GetFocusedRowCellValue(colDSTSt);
            object mOrg = tstGridView.GetFocusedRowCellValue(colPOLSt);
            object mDst = tstGridView.GetFocusedRowCellValue(colPOUSt);

            PageHeaderFooter phf  = link.PageHeaderFooter as PageHeaderFooter;
            string           mdlH = string.Format("Talep/Teklif {0} ", tstGridView.GetFocusedRowCellValue(colTSTIDt));

            phf.Header.Content.AddRange(new string[] { "", mdlH, "" });
            phf.Header.LineAlignment = BrickAlignment.Far;
            phf.Header.Font          = Font;

            int    frtID = (int)tstGridView.GetFocusedRowCellValue(colFRTIDt);
            string firma = Program.MF.FrtAd(frtID);

            string lblFRT      = "Firma";
            string lblTKLTRH   = "Teklif Tarihi";
            string lblGCRTRH   = "Geçerlilik Tarihi";
            string lblHORGS    = "Çı kı ş  Yeri";
            string lblHDSTS    = "Varı ş  Yeri";
            string lblMORGS    = "Çı kı ş  Limanı";
            string lblMDSTS    = "Varı ş  Limanı";
            string lblMALCINSI = "Mal Cinsi";


            tsfGridView.OptionsPrint.RtfReportHeader =
                hdrTmp
                .Replace("@lblFRT@", lblFRT)
                .Replace("@FRT@", firma)

                .Replace("@lblTKLTRH@", lblTKLTRH)
                .Replace("@TKLTRH@", tstGridView.GetFocusedRowCellDisplayText(colTKLTRHt))

                .Replace("@lblGCRTRH@", lblGCRTRH)
                .Replace("@GCRTRH@", tstGridView.GetFocusedRowCellDisplayText(colGCRTRHt))

                .Replace("@ROT@", tstGridView.GetFocusedRowCellDisplayText(colROTt))
                .Replace("@MOT@", tstGridView.GetFocusedRowCellDisplayText(colMOTt))

                .Replace("@lblHORGS@", lblHORGS)
                .Replace("@HORGS@", tstGridView.GetFocusedRowCellDisplayText(colORGSt))

                .Replace("@lblHDSTS@", lblHDSTS)
                .Replace("@HDSTS@", tstGridView.GetFocusedRowCellDisplayText(colDSTSt))

                .Replace("@lblMORGS@", lblMORGS)
                .Replace("@MORGS@", tstGridView.GetFocusedRowCellDisplayText(colPOLSt))

                .Replace("@lblMDSTS@", lblMDSTS)
                .Replace("@MDSTS@", tstGridView.GetFocusedRowCellDisplayText(colPOUSt))

                .Replace("@DTM@", tstGridView.GetFocusedRowCellDisplayText(colDTMt))
                .Replace("@PTM@", tstGridView.GetFocusedRowCellDisplayText(colPTMt))

                .Replace("@lblMALCINSI@", lblMALCINSI)
                .Replace("@MALCINSI@", tstGridView.GetFocusedRowCellDisplayText(colMALCINSIt))

                .Replace("@INFO@", tstGridView.GetFocusedRowCellDisplayText(colINFOt));

            string s = tstGridView.GetFocusedRowCellDisplayText(colGCRTRHt);

            //            phf.Footer.Content.AddRange(new string[] { "[Date Printed] [Time Printed]", "", Program.USR });
            //            phf.Footer.LineAlignment = BrickAlignment.Near;

            link.CreateDocument();
            link.ShowPreview();
        }
Exemple #2
0
        private void exportSatis(string dil, bool eMail = false)
        {
            int tstID = (int)tstGridView.GetFocusedRowCellValue(colTSTIDt);

            rprTklfTableAdapter.Fill(teklifDataSet.RPR_TKLF, tstID, dil);
            TeklifDataSet.RPR_TKLFRow rprTklfRow = (TeklifDataSet.RPR_TKLFRow)teklifDataSet.RPR_TKLF.Rows[0];
            string tklfTE = "Teklif";

            if (dil == "T")
            {
                colORGf.Caption     = "Çıkış";
                colDSTf.Caption     = "Varış";
                colBRMf.Caption     = "Birim";
                colTRNTIMEf.Caption = "Transit Süre";

                colSKDY.Caption  = "KDV%";
                colSDVZf.Caption = "Para Birim";

                colSFYTf.Caption  = "Fiyat";
                colSFYT1f.Caption = "Min";
                colSFYT2f.Caption = "-45";
                colSFYT3f.Caption = "+45";
                colSFYT4f.Caption = "+100";
                colSFYT5f.Caption = "+250";
                colSFYT6f.Caption = "+300";
                colSFYT7f.Caption = "+500";
                colSFYT8f.Caption = "+1000";

                colSFYTE.Caption  = "Fiyat";
                colSFYT1E.Caption = "Min";
                colSFYT2E.Caption = "-45";
                colSFYT3E.Caption = "+45";
                colSFYT4E.Caption = "+100";
                colSFYT5E.Caption = "+250";
                colSFYT6E.Caption = "+300";
                colSFYT7E.Caption = "+500";
                colSFYT8E.Caption = "+1000";
            }
            else
            {
                tklfTE              = "Tender";
                colORGf.Caption     = "Origin";
                colDSTf.Caption     = "Destination";
                colBRMf.Caption     = "Unit";
                colTRNTIMEf.Caption = "Transit Time";

                colSKDY.Caption  = "%VAT";
                colSDVZf.Caption = "Currency";

                colSFYTf.Caption  = "Rate";
                colSFYT1f.Caption = "Min";
                colSFYT2f.Caption = "-45";
                colSFYT3f.Caption = "+45";
                colSFYT4f.Caption = "+100";
                colSFYT5f.Caption = "+250";
                colSFYT6f.Caption = "+300";
                colSFYT7f.Caption = "+500";
                colSFYT8f.Caption = "+1000";

                colSFYTE.Caption  = "Rate";
                colSFYT1E.Caption = "Min";
                colSFYT2E.Caption = "-45";
                colSFYT3E.Caption = "+45";
                colSFYT4E.Caption = "+100";
                colSFYT5E.Caption = "+250";
                colSFYT6E.Caption = "+300";
                colSFYT7E.Caption = "+500";
                colSFYT8E.Caption = "+1000";
            }

            if (colG9.GroupIndex == 0)
            {
                tsfGridView.CollapseAllGroups();
                //tsfGridView.OptionsView.ShowFooter = true;
                tsfGridView.OptionsPrint.ExpandAllGroups = false;
                tsfGridView.OptionsPrint.PrintFooter     = true;
                //tsfGridView.OptionsPrint.AutoWidth = false;
                tsfGridView.OptionsPrint.AutoWidth = true;
            }
            else
            {
                tsfGridView.ExpandAllGroups();
                //tsfGridView.OptionsView.ShowFooter = false;
                tsfGridView.OptionsPrint.ExpandAllGroups = true;
                tsfGridView.OptionsPrint.PrintFooter     = false;
                //tsfGridView.OptionsPrint.AutoWidth = false;
                tsfGridView.OptionsPrint.AutoWidth = true;
                //tsfGridView.BestFitColumns();
            }

            RichEditDocumentServer richServer = new RichEditDocumentServer();

            richServer.RtfText = rprTklfRow.ALTNOT;
            //richServer.Document.AppendText(" SENER");
            if (!rprTklfRow.IsDTYNOTNull())
            {
                if (string.IsNullOrEmpty(richServer.Text))
                {
                    richServer.RtfText = rprTklfRow.DTYNOT;
                }
                else
                {
                    richServer.Document.AppendRtfText(rprTklfRow.DTYNOT);
                }
            }

            tsfGridView.OptionsPrint.RtfReportFooter = richServer.RtfText;
            tsfGridView.OptionsPrint.RtfPageFooter   = rprTklfRow.FOOTER;


            PrintingSystem         ps   = new PrintingSystem();
            PrintableComponentLink link = new PrintableComponentLink(ps);

            link.Component = tsfGridControl;

            link.PaperKind      = System.Drawing.Printing.PaperKind.A4;
            link.Landscape      = false;
            link.Margins.Left   = 10;
            link.Margins.Right  = 10;
            link.Margins.Top    = 10;
            link.Margins.Bottom = 10;

//            tsfGridView.OptionsPrint.RtfPageHeader =
            tsfGridView.OptionsPrint.RtfReportHeader =
                rprTklfRow.USTNOT
                .Replace("@TSTID@", rprTklfRow.TSTID.ToString())
                .Replace("@FIRMA@", rprTklfRow.FIRMA)
                .Replace("@TLPTRH@", rprTklfRow.TLPTRHS)
                .Replace("@TKLTRH@", rprTklfRow.TKLTRHS)
                .Replace("@GCRTRH@", rprTklfRow.GCRTRHS)
                .Replace("@ROT@", rprTklfRow.ROT)
                .Replace("@MOT@", rprTklfRow.MOT)
                .Replace("@PTM@", rprTklfRow.PTM)
                .Replace("@DTM@", rprTklfRow.DTM)

                .Replace("@HORGS@", rprTklfRow.HORGS)
                .Replace("@HDSTS@", rprTklfRow.HDSTS)
                .Replace("@MORGS@", rprTklfRow.MORGS)
                .Replace("@MDSTS@", rprTklfRow.MDSTS)

                .Replace("@MALCINSI@", rprTklfRow["MALCINSI"].ToString())
                .Replace("@INFO@", rprTklfRow.INFO);

            link.CreateDocument();

            if (eMail)
            {
                if (string.IsNullOrWhiteSpace(rprTklfRow.EMAILS))
                {
                    XtraMessageBox.Show("eMail adresi bulunamadı", "eMail Teklif", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    return;
                }

                Cursor = Cursors.WaitCursor;
                try
                {
                    MainDataSet.SMTPRow SMTP = Program.MF.SMTP();
                    MailMessage         mail = new MailMessage();

                    // Create a new memory stream and export the report into it as PDF.
                    MemoryStream ms = new MemoryStream();
                    link.ExportToPdf(ms);

                    // Create a new attachment and put the PDF report into it.
                    ms.Seek(0, System.IO.SeekOrigin.Begin);
                    Attachment att = new Attachment(ms, string.Format("{0}-{1}.pdf", tklfTE, tstID), "application/pdf");
                    mail.Attachments.Add(att);

                    mail.To.Add(rprTklfRow.EMAILS);

                    mail.Subject    = rprTklfRow.EMAILSUBJECT;
                    mail.Body       = rprTklfRow.EMAILBODY;
                    mail.IsBodyHtml = true;

                    mail.From = new MailAddress(SMTP.MAIL_FROM_ADDRESS, SMTP.MAIL_FROM_DISPLAY_NAME);
                    SmtpClient smtp = new SmtpClient(SMTP.CLIENT_HOST);
                    smtp.Credentials = new System.Net.NetworkCredential(SMTP.CREDENTIALS_USER_NAME, SMTP.CREDENTIALS_USER_PASSWORD);
                    smtp.EnableSsl   = SMTP.ENABLE_SSL == "T" ? true : false;
                    smtp.Port        = SMTP.PORT;

                    smtp.Send(mail);

                    int    len = (int)ms.Length;
                    byte[] img = new byte[len];
                    ms.Read(img, 0, len);
                    //teklifQueriesTableAdapter.DOC_INS2("TST", tstID, "Teklif", ".pdf", "TKLF", Program.USR, len, img);
                    teklifQueriesTableAdapter.DOC_INS2("TST", tstID, string.Format("Teklif {0}", tstGridView.GetFocusedRowCellValue(colRVSNOt)), ".pdf", "TKLF", Program.USR, len, img);

                    // Close the memory stream.
                    ms.Close();
                    ms.Flush();

                    rptInfo rpti = new rptInfo();
                    rpti.put("TKLF", "TST", tstID, Program.USR, "F", "eMail Teklif");
                    Program.MF.reportDone(rpti, false);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(this, "Error sending eMail.\n" + ex.ToString());
                }
                finally
                {
                    Cursor = Cursors.Default;
                }
            }
            else
            {
                link.ShowPreviewDialog();

                if (XtraMessageBox.Show("İşlem tamamlandı mı?", "Print", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                {
                    MemoryStream ms = new MemoryStream();
                    link.ExportToPdf(ms);
                    ms.Seek(0, System.IO.SeekOrigin.Begin);
                    int    len = (int)ms.Length;
                    byte[] img = new byte[len];
                    ms.Read(img, 0, len);
                    ms.Close();

                    teklifQueriesTableAdapter.DOC_INS2("TST", tstID, string.Format("Teklif {0}", tstGridView.GetFocusedRowCellValue(colRVSNOt)), ".pdf", "TKLF", Program.USR, len, img);
                    rptInfo rpti = new rptInfo();
                    rpti.put("TKLF", "TST", tstID, Program.USR, "F", "eMail Teklif");
                    Program.MF.reportDone(rpti, false);
                }
            }
        }