Exemplo n.º 1
0
        void FisYazdir(bool Disigner, string pkSatislar, string SatisFisTipi, string fkSatisFisiSecimi)
        {
            System.Data.DataSet ds       = new DataSet("Test");
            DataTable           FisDetay = DB.GetData(@"exec sp_SatisDetay " + pkSatislar + ",1");

            FisDetay.TableName = "FisDetay";
            ds.Tables.Add(FisDetay);
            DataTable Fis = DB.GetData(@"exec sp_Satislar " + pkSatislar);

            if (Fis.Rows.Count == 0)
            {
                MessageBox.Show("Satış Bulunamadı");
                return;
            }
            string fkFirma = Fis.Rows[0]["fkFirma"].ToString();

            Fis.TableName = "Fis";
            ds.Tables.Add(Fis);

            //şirket bilgileri
            DataTable Sirket = DB.GetData(@"select top 1 * from Sirketler with(nolock)");

            Sirket.TableName = "Sirket";
            ds.Tables.Add(Sirket);

            //Bakiye bilgileri
            DataTable Bakiye = DB.GetData(@"select Tutar as OncekiBakiye,Borc, OdemeSekli from KasaHareket with(nolock)
                    where fkSatislar=" + pkSatislar);

            Bakiye.TableName = "Bakiye";
            ds.Tables.Add(Bakiye);

            //Firma bilgileri
            //DataTable Musteri = DB.GetData("select *,dbo.fon_MusteriBakiyesi(pkFirma) as Bakiye from Firmalar with(nolock) where pkFirma=" + fkFirma);
            DataTable Musteri = DB.GetData("select * from VM_Musteriler where pkFirma=" + fkFirma);

            Musteri.TableName = "Musteri";
            ds.Tables.Add(Musteri);

            string exedizini = Path.GetDirectoryName(Application.ExecutablePath);

            string RaporDosyasi = exedizini + "\\Raporlar\\" + SatisFisTipi + ".repx";
            //string RaporDosyasi = exedizini + "\\Raporlar\\MusteriSatis.repx";
            //XtraReport rapor = new XtraReport();
            xrCariHareket rapor = new xrCariHareket();

            //rapor.AfterPrint
            //rapor.Disposed
            //rapor.EndUpdate
            //rapor.IsDisposed
            //rapor.IsSingleChild

            //rapor.SaveComponents
            //rapor.SaveComponents += new
            //EventHandler<SaveComponentsEventArgs>(report_SaveComponents);
            rapor.DataSource = ds;

            if (File.Exists(RaporDosyasi))
            {
                rapor.LoadLayout(RaporDosyasi);
            }
            else
            {
                MemoryStream ms = RaporUtil.GetMemStr(fkSatisFisiSecimi, pkSatislar);
                if (ms == null)
                {
                    MessageBox.Show("Dosya Bulunamadı");
                }
                else
                {
                    rapor.LoadLayout(ms);
                }
            }

            rapor.Name        = SatisFisTipi;
            rapor.Report.Name = SatisFisTipi;

            if (Disigner)
            {
                /*
                 * // Create a Design Tool and assign the report to it.
                 * ReportDesignTool designTool = new ReportDesignTool(rapor);
                 * designTool.Report.DrawGrid = true;
                 * // Access the Designer form's properties.
                 * designTool.DesignForm.SetWindowVisibility(DesignDockPanelType.FieldList |
                 * DesignDockPanelType.PropertyGrid, false);
                 *
                 * //designTool.DesignForm.OpenReport()
                 * //rapor.DesignerLoaded += report_DesignerLoaded;
                 * designTool.ShowDesignerDialog();
                 */
                rapor.ShowDesignerDialog();


                string filePath = @"XtraReport1.repx";

                rapor.SaveLayout(filePath);

                FileStream   fStream   = new FileStream(filePath, FileMode.Open, FileAccess.Read);
                long         sayac     = fStream.Length;
                BinaryReader bReader   = new BinaryReader(fStream);
                byte[]       byteResim = bReader.ReadBytes((int)sayac);
                string       sql       = "";
                ArrayList    alist     = new ArrayList();
                alist.Add(new SqlParameter("@pkSatisFisiSecimi", fkSatisFisiSecimi));
                alist.Add(new SqlParameter("@rapor_dosya", byteResim));

                sql = @"update SatisFisiSecimi set rapor_dosya=@rapor_dosya,guncelleme_tarihi=getdate() where pkSatisFisiSecimi=@pkSatisFisiSecimi";
                string sonuc = DB.ExecuteSQL(sql, alist);
            }
            else
            {
                rapor.ShowPreview();
            }
        }