private void b_print_Click(object sender, EventArgs e)
        {
            var table = "Costume_reservation_list";

            Utile.RepoerDB rdb = new Utile.RepoerDB(table);
            rdb.deleteAll();
            for (var i = 0; i < dataGridView1.RowCount; i++)
            {
                Dictionary <string, string> dataitem = new Dictionary <string, string>();
                dataitem.Add("ReceiptDate", dataGridView1.Rows[i].Cells[1].Value.ToString());
                dataitem.Add("StoreName", dataGridView1.Rows[i].Cells[2].Value.ToString());
                dataitem.Add("CostumeCode", dataGridView1.Rows[i].Cells[3].Value.ToString());
                dataitem.Add("FacilityName", dataGridView1.Rows[i].Cells[4].Value.ToString());
                var reservationdate = dataGridView1.Rows[i].Cells[5].Value.ToString() + " " +
                                      dataGridView1.Rows[i].Cells[6].Value.ToString() + "~" +
                                      dataGridView1.Rows[i].Cells[7].Value.ToString() + " " +
                                      dataGridView1.Rows[i].Cells[8].Value.ToString();
                dataitem.Add("ReservationDate", reservationdate);
                dataitem.Add("CostumerNamekana", dataGridView1.Rows[i].Cells[10].Value.ToString());
                dataitem.Add("CostumerName", dataGridView1.Rows[i].Cells[9].Value.ToString());
                dataitem.Add("Sex", dataGridView1.Rows[i].Cells[11].Value.ToString());
                dataitem.Add("Remarks", dataGridView1.Rows[i].Cells[12].Value.ToString());

                var store   = DB.m_store.getSingleName(dataGridView1.Rows[i].Cells[2].Value.ToString());
                var costume = DB.m_costume.getSingle(store.store_code,
                                                     dataGridView1.Rows[i].Cells[3].Value.ToString());

                var    photo_root        = System.Configuration.ConfigurationManager.AppSettings["photo_root"];
                var    Costume_Image     = System.Configuration.ConfigurationManager.AppSettings["Costume_Image"];
                var    Costume_Image_Dir = System.IO.Path.Combine(photo_root, Costume_Image);
                string image1            = costume.image1;
                var    path = System.IO.Path.Combine(Costume_Image_Dir, store.store_name
                                                     , costume.costume_code, image1);

                dataitem.Add("Folder", System.IO.Path.GetFullPath(path));
                rdb.insert(dataitem);
            }

            PrintForm P = new PrintForm();

            P.PrintReport.Load(@"Asset/Format/Costume_reservation_list.flxr", "Costume_reservation_list");
            P.c1FlexViewer.DocumentSource = P.PrintReport;
            P.Show();
        }
Exemple #2
0
        private void b_print_Click(object sender, EventArgs e)
        {
            //TODO 印書DBへの登録
            string table = "Reservation_list";

            Utile.RepoerDB rdb = new Utile.RepoerDB(table);
            rdb.deleteAll();
            for (var i = 0; i < dataGridView1.Rows.Count; i++)
            {
                var reservation_time = dataGridView1.Rows[i].Cells[3].Value.ToString() + "~" +
                                       dataGridView1.Rows[i].Cells[4].Value.ToString();
                Dictionary <string, string> dataitem = new Dictionary <string, string>();
                var reservationDate = DateTime.Parse(dataGridView1.Rows[i].Cells[2].Value.ToString());
                dataitem.Add("ReservationDate", reservationDate.ToLongDateString());
                dataitem.Add("Store", dataGridView1.Rows[i].Cells[1].Value.ToString());
                dataitem.Add("ReservationTime", reservation_time);
                dataitem.Add("Facility", dataGridView1.Rows[i].Cells[5].Value.ToString());
                dataitem.Add("CustomerName", dataGridView1.Rows[i].Cells[6].Value.ToString());
                dataitem.Add("CustomerNameKana", dataGridView1.Rows[i].Cells[7].Value.ToString());
                dataitem.Add("Sex", dataGridView1.Rows[i].Cells[8].Value.ToString());
                dataitem.Add("ShootingPurpose", dataGridView1.Rows[i].Cells[9].Value.ToString());
                dataitem.Add("CostumeCode", dataGridView1.Rows[i].Cells[10].Value.ToString());
                dataitem.Add("CostumeReservationDate", dataGridView1.Rows[i].Cells[11].Value.ToString());
                dataitem.Add("Remarks", dataGridView1.Rows[i].Cells[12].Value.ToString());

                rdb.insert(dataitem);
            }

            //印書開始
            PrintForm p = new PrintForm();

            p.PrintReport.Load(@"./Asset/Format/Reservation_list.flxr", "Reservation_list レポート");
            p.c1FlexViewer.DocumentSource = p.PrintReport;
            p.Show();

            //TODO ボタンの活性化
            b_print.Enabled  = true;
            b_return.Enabled = true;
        }
        //印刷ボタン
        private void b_print_Click(object sender, EventArgs e)
        {
            //顧客情報登録
            Dictionary <string, string> dataitem = new Dictionary <string, string>();

            dataitem.Add("ReceptionCode", t_uketsuke_code.Text.ToString());
            dataitem.Add("ReceptionDate", t_uketsuke_date.Text.ToString());
            dataitem.Add("CustomerCode", t_kokyaku_code.Text.ToString());
            var customer = DB.m_customer.getSingle(t_kokyaku_code.Text.ToString());

            dataitem.Add("CustomerNamekana", customer.surname_kana + customer.name_kana);
            dataitem.Add("CustomerName", t_kokyakumei.Text.ToString());
            dataitem.Add("CustomerBirthday", t_seinengappi.Text.ToString());
            dataitem.Add("CustomerAge", t_nenrei.Text.ToString());
            dataitem.Add("CustomerSex", t_seibetsu.Text.ToString());
            dataitem.Add("CustomerZipcode", t_postalcode.Text.ToString());
            dataitem.Add("CustomerAddress1", t_sichouson.Text.ToString());
            dataitem.Add("CustomerAddress2", t_banchi.Text.ToString() + t_apart.Text.ToString());
            dataitem.Add("CustomerPhonenumber1", t_denwabango.Text.ToString());
            dataitem.Add("CustomerPhonenumber2", customer.phone_number2);
            dataitem.Add("CustomerPhonenumber3", customer.phone_number3);
            dataitem.Add("CustomerFaxnumber1", customer.fax_number);
            dataitem.Add("CustomerMailaddress", t_mail.Text.ToString());

            string table = "Reception_card";

            Utile.RepoerDB rdb = new Utile.RepoerDB(table);
            rdb.deleteAll();
            rdb.insert(dataitem);

            //名簿-家族情報登録
            List <DB.m_family> families = new List <DB.m_family>();

            families = DB.m_family.getOnlyCode(t_kokyaku_code.Text.ToString());

            table = "Reception_card_NameList";
            rdb   = new Utile.RepoerDB(table);
            rdb.deleteAll();

            foreach (DB.m_family family in families)
            {
                Dictionary <string, string> dataitem1 = new Dictionary <string, string>();
                dataitem1.Add("NameListNamekana", family.surname_kana + family.name_kana);
                dataitem1.Add("NameListName", family.surname + family.name);
                dataitem1.Add("NameListBirthday", family.birthday.Value.ToShortDateString());
                int age = getAge(family.birthday.Value);
                dataitem1.Add("NameListAge", age.ToString());
                dataitem1.Add("NameListSex", Enum.ToObject(typeof(Utile.Data.性別), int.Parse(family.sex)).ToString());
                dataitem1.Add("NameListRelationship", family.relationship);
                dataitem1.Add("NameListRemarks", family.remarks);
                rdb.insert(dataitem1);
            }


            //名簿-追加情報登録
            table = "Reception_card_NameListIncluding";
            rdb   = new Utile.RepoerDB(table);

            Dictionary <string, string> dataitem2 = new Dictionary <string, string>();

            using (var db = new DB.DBConnect())
            {   //オープン処理がないと怒られる。
                db.npg.Open();
                StringBuilder sb = new StringBuilder();
                sb.Append(@"select distinct
                             fr.shooting_purpose as shooting_purpose
                            ");
                sb.Append(@"from
                            t_reception r 
                            INNER JOIN t_reservation re ON 
                            r.reception_code = re.reception_code
                            INNER JOIN t_facility_reservation fr ON
                            re.facility_reservation_code = fr.facility_reservation_code
                            INNER JOIN m_facility f ON
                            fr.facility_code = f.facility_code
                            ");
                sb.Append(@" where r.reception_code ='@reception_code'".Replace("@reception_code", reception_code));
                sb.Append(@"order by fr.shooting_purpose");

                var command = new NpgsqlCommand(sb.ToString(), db.npg);

                var dataReader = command.ExecuteReader();
                dataReader.Read();
                if (dataReader.HasRows)
                {
                    dataitem2.Add("NameListUseClassification", dataReader["shooting_purpose"].ToString());
                }
            }
            string d = DB.t_shooting_data.getShootingDate(t_kokyaku_code.Text.ToString());

            DateTime.TryParse(d, out DateTime Day);
            String secondDay = d != "" ? Day.ToShortDateString():"";

            dataitem2.Add("NameListShootingdate", secondDay);
            dataitem2.Add("NameListRemarks", t_taiou_naiyou.Text.ToString());

            rdb.deleteAll();
            rdb.insert(dataitem2);

            //施設予約
            table = "Reception_card_Reservation";
            rdb   = new Utile.RepoerDB(table);
            rdb.deleteAll();
            for (var i = 0; i < dataGridView1.RowCount; i++)
            {
                Dictionary <string, string> dataitem3 = new Dictionary <string, string>();
                dataitem3.Add("ReservationFacility", dataGridView1.Rows[i].Cells[0].Value.ToString());
                dataitem3.Add("ReservationDate", dataGridView1.Rows[i].Cells[1].Value.ToString());
                dataitem3.Add("ReservationRemarks", dataGridView1.Rows[i].Cells[2].Value.ToString());
                rdb.insert(dataitem3);
            }

            //衣装予約登録
            table = "Reception_card_Costume";
            rdb   = new Utile.RepoerDB(table);
            rdb.deleteAll();
            for (var i = 0; i < dataGridView2.RowCount; i++)
            {
                Dictionary <string, string> dataitem4 = new Dictionary <string, string>();
                var    store             = DB.m_store.getSingleName(dataGridView2.Rows[i].Cells[1].Value.ToString());
                var    costume           = DB.m_costume.getSingle(store.store_code, dataGridView2.Rows[i].Cells[2].Value.ToString());
                var    photo_root        = System.Configuration.ConfigurationManager.AppSettings["photo_root"];
                var    Costume_Image     = System.Configuration.ConfigurationManager.AppSettings["Costume_Image"];
                var    Costume_Image_Dir = System.IO.Path.Combine(photo_root, Costume_Image);
                string image1            = costume.image1;
                var    path = System.IO.Path.Combine(Costume_Image_Dir, store.store_name, dataGridView2.Rows[i].Cells[2].Value.ToString(), image1);


                dataitem4.Add("CostumeThumbnail", System.IO.Path.GetFullPath(path));
                dataitem4.Add("CostumeFacility", dataGridView2.Rows[i].Cells[0].Value.ToString());
                dataitem4.Add("CostumeCode", dataGridView2.Rows[i].Cells[2].Value.ToString());
                dataitem4.Add("CostumeRemarks", dataGridView2.Rows[i].Cells[3].Value.ToString());
                rdb.insert(dataitem4);
            }


            PrintForm p = new PrintForm();

            p.PrintReport.Load(@"./Asset/Format/Reception_card.flxr", "Reception_card レポート");
            p.c1FlexViewer.DocumentSource = p.PrintReport;
            p.Show();
        }
        //印刷ボタンが押されて場合に、やりとり履歴一覧出力をCALLする。
        private void b_print_Click(object sender, EventArgs e)
        {
            //TODO 印刷用DBを更新
            //受付情報を帳票DBへ登録

            string table = "Exchange_history";

            Utile.RepoerDB rdb = new Utile.RepoerDB(table);
            rdb.deleteAll();

            DB.t_reception reception;
            DateTime.TryParse(t_start_time_from.ToString(), out DateTime start_date);
            DateTime.TryParse(t_start_time_to.ToString(), out DateTime end_date);
            String title = "";

            if (t_start_time_to == null && t_start_time_from != null)
            {
                title = start_date.ToString("yyyy年MM月dd日") + "からの対応履歴";
            }
            else if (t_start_time_to != null && t_start_time_from == null)
            {
                title = end_date.ToString("yyyy年MM月dd日") + "までの対応履歴";
            }
            else if (t_start_time_from == null && t_start_time_to == null)
            {
                title = "                              対応履歴";
            }
            else
            {
                title = start_date.ToString("yyyy年MM月dd日") + "~" +
                        end_date.ToString("yyyy年MM月dd日") + "間の対応履歴";
            }


            for (int i = 0; i < dataGridView1.RowCount; i++)
            {
                if (!(bool)dataGridView1.Rows[i].Cells[0].Value)
                {
                    Dictionary <string, string> dataitem = new Dictionary <string, string>();
                    reception = DB.t_reception.getSingle(dataGridView1.Rows[i].Cells[1].Value.ToString());

                    dataitem.Add("reportTiTLE", title);
                    dataitem.Add("receiptDate", dataGridView1.Rows[i].Cells[2].Value.ToString());
                    dataitem.Add("receiptTime", dataGridView1.Rows[i].Cells[3].Value.ToString());
                    dataitem.Add("receiptStore", dataGridView1.Rows[i].Cells[4].Value.ToString());
                    dataitem.Add("receiptStaff", dataGridView1.Rows[i].Cells[5].Value.ToString());
                    dataitem.Add("receiptCustomername", dataGridView1.Rows[i].Cells[6].Value.ToString());
                    dataitem.Add("receiptStatus", dataGridView1.Rows[i].Cells[7].Value.ToString());
                    dataitem.Add("receiptMemo", dataGridView1.Rows[i].Cells[8].Value.ToString());
                    dataitem.Add("receiptClaim", reception.claim);

                    rdb.insert(dataitem);
                }
            }


            //印刷処理
            PrintForm p = new PrintForm();

            p.PrintReport.Load(@"./Asset/Format/Exchange_history.flxr", "対応履歴一覧表 レポート");
            p.c1FlexViewer.DocumentSource = p.PrintReport;
            p.Show();

            //他のボタンを活性に戻す。
            b_print_exclusion.Enabled = true;
            b_print.Enabled           = true;
            b_return.Enabled          = true;
        }
        private void b_print_Click(object sender, EventArgs e)
        {
            //DBに登録
            collect();

            //顧客情報格納
            string table = "Order_list1";
            Dictionary <string, string> item = new Dictionary <string, string>();

            item.Add("customerCode", MainForm.session_t_reception.customer_code.ToString());
            item.Add("folderName", Save_dir.Trim());
            DB.m_customer cus = DB.m_customer.getSingle(MainForm.session_t_reception.customer_code.ToString());
            item.Add("customerSurnameKana", cus.surname_kana);
            item.Add("customerNameKana", cus.name_kana);
            item.Add("customerSurName", cus.surname);
            item.Add("customerName", cus.name);
            item.Add("orderEntryDate", MainForm.session_t_reception.receipt_date.ToString("yyyy年MM月dd日"));

            Utile.RepoerDB rdb = new Utile.RepoerDB(table);
            rdb.deleteAll();
            rdb.insert(item);

            //写真データ格納

            table = "Order_list2";
            rdb   = new Utile.RepoerDB(table);
            rdb.deleteAll();
            using (var dbc = new DB.DBConnect())
            {
                dbc.npg.Open();
                StringBuilder sb = new StringBuilder();
                sb.Append(@"select * ");
                sb.Append(@"from t_selection as s ");
                sb.Append(@"where s.reception_code = '@reception_code' ".Replace("@reception_code", MainForm.session_t_reception.reception_code));

                NpgsqlCommand command    = new NpgsqlCommand(sb.ToString(), dbc.npg);
                var           dataReader = command.ExecuteReader();
                while (dataReader.Read())
                {
                    if ((int)dataReader["images"] != 0)
                    {
                        string path = System.IO.Path.Combine(Secondary_Select_dir, dataReader["folder_name"].ToString().Trim(), ((int)dataReader["color"]).ToString());
                        foreach (string fpath in System.IO.Directory.GetFiles(path, "*", System.IO.SearchOption.AllDirectories))
                        {
                            item = new Dictionary <string, string>();
                            item.Add("product", dataReader["color"].ToString() + " - " + dataReader["product_name"].ToString());
                            //会計処理が未実装のため""をいれる
                            item.Add("unit", "");
                            item.Add("photo", System.IO.Path.GetFullPath(fpath));
                            rdb.insert(item);
                        }
                    }
                }
            }

            PrintForm p = new PrintForm();

            p.PrintReport.Load(@"./Asset/Format/Order_list.flxr", "発注内容一覧");
            p.c1FlexViewer.DocumentSource = p.PrintReport;
            p.Show();
        }
        private void b_okiniiri_Click(object sender, EventArgs e)
        {
            //情報をデータベースに登録
            collect();

            // 顧客情報格納
            string table = "ContactSheet";

            Utile.RepoerDB rdb = new Utile.RepoerDB(table);
            rdb.deleteAll();

            //レポート作成用DBにタグにチェックがついている写真情報を格納する
            foreach (tagControl tc in this.tagsPanel.Controls)
            {
                if (tc.d_tag.Checked && tc.d_tagName.SelectedIndex == 0)
                {
                    using (var dbc = new DB.DBConnect())
                    {
                        //毎回読むのも非効率かな?
                        dbc.npg.Open();
                        StringBuilder sb = new StringBuilder();
                        sb.Append(@"select * ");
                        sb.Append(@"from t_selection as s ");
                        sb.Append(@"where s.reception_code = '@reception_code'".Replace("@reception_code", MainForm.session_t_reception.reception_code));

                        NpgsqlCommand command    = new NpgsqlCommand(sb.ToString(), dbc.npg);
                        var           dataReader = command.ExecuteReader();
                        while (dataReader.Read())
                        {
                            var color = (int)dataReader["color"];
                            if (tc.tagId == color)
                            {
                                var path  = System.IO.Path.Combine(Secondary_Select_dir, ((string)dataReader["folder_name"]).Trim(), tc.tagId.ToString());
                                var count = 0;
                                Dictionary <string, string> item = new Dictionary <string, string>();

                                foreach (string fpath in System.IO.Directory.GetFiles(path, "*", System.IO.SearchOption.AllDirectories))
                                {
                                    count++;

                                    //写真のファイル名フルパスの取得
                                    var fname = System.IO.Path.GetFileName(fpath);
                                    if (count % 3 == 1)
                                    {
                                        item.Add("customerCode", MainForm.session_t_reception.customer_code.ToString());
                                        item.Add("folderName", Save_dir.Trim());
                                        DB.m_customer cus = DB.m_customer.getSingle(MainForm.session_t_reception.customer_code.ToString());
                                        item.Add("customerSurnameKana", cus.surname_kana);
                                        item.Add("customerNameKana", cus.name_kana);
                                        item.Add("customerSurName", cus.surname);
                                        item.Add("customerName", cus.name);
                                        item.Add("orderEntryDate", MainForm.session_t_reception.receipt_date.ToString("yyyy年MM月dd日"));

                                        item.Add("filename1", fname);
                                        item.Add("image1", System.IO.Path.GetFullPath(fpath));
                                    }
                                    else if (count % 3 == 2)
                                    {
                                        item.Add("filename2", fname);
                                        item.Add("image2", System.IO.Path.GetFullPath(fpath));
                                    }
                                    else
                                    {
                                        item.Add("filename3", fname);
                                        item.Add("image3", System.IO.Path.GetFullPath(fpath));
                                        count = 0;
                                        rdb.insert(item);
                                        item.Clear();
                                    }
                                }
                                if (count != 0)
                                {
                                    rdb.insert(item);
                                }
                            }
                        }
                    }
                }
            }

            PrintForm p = new PrintForm();

            p.PrintReport.Load(@"./Asset/Format/ContactSheet.flxr", "ContactSheet");
            p.c1FlexViewer.DocumentSource = p.PrintReport;
            p.Show();
        }
        private void b_print_Click(object sender, EventArgs e)
        {
            //顧客情報の登録
            string table = "Customer_Information";

            Utile.RepoerDB rdb = new Utile.RepoerDB(table);
            rdb.deleteAll();

            for (var i = 0; i < dataGridView1.RowCount; i++)
            {
                var families = DB.m_family.getOnlyCode(dataGridView1.Rows[i].Cells[1].Value.ToString());
                if (families.Any(x => x != null))
                {
                    foreach (var family in families)
                    {
                        Dictionary <string, string> dataitem = new Dictionary <string, string>();
                        dataitem.Add("customerCode", dataGridView1.Rows[i].Cells[1].Value.ToString());
                        var customer = DB.m_customer.getSingle(dataGridView1.Rows[i].Cells[1].Value.ToString());
                        dataitem.Add("customerSurNameKana", customer.surname_kana);
                        dataitem.Add("customerNamekana", customer.name_kana);
                        dataitem.Add("customerSurName", customer.surname);
                        dataitem.Add("customerName", customer.name);
                        dataitem.Add("customerBirthday", customer.birthday.ToLongDateString());
                        dataitem.Add("customerAge", getAge(customer.birthday).ToString());
                        dataitem.Add("customerSex", Enum.GetName(typeof(Utile.Data.性別), int.Parse(customer.sex)));
                        dataitem.Add("customerPostalNumber", customer.postal_code);
                        dataitem.Add("customerAddress1", customer.address1);
                        dataitem.Add("customerAddress2", customer.address2);
                        dataitem.Add("customerAddress3", customer.address3);
                        dataitem.Add("customerPhoneNumber1", customer.phone_number1);
                        dataitem.Add("customerPhoneNumber2", customer.phone_number2);
                        dataitem.Add("customerPhoneNumber3", customer.phone_number3);
                        dataitem.Add("customerFAX", customer.fax_number);
                        dataitem.Add("customerEMail", customer.mail_address);
                        var member = DB.m_member.getSingle(dataGridView1.Rows[i].Cells[1].Value.ToString());

                        if (member != null)
                        {
                            dataitem.Add("memberType", Enum.GetName(typeof(Utile.Data.会員種別), int.Parse(member.membership_type)));
                            dataitem.Add("memberJoinDate", member.date.ToLongDateString());
                        }

                        dataitem.Add("familySurnameKana", family.surname_kana);
                        dataitem.Add("familyNameKana", family.name_kana);
                        dataitem.Add("familySurname", family.surname);
                        dataitem.Add("familyName", family.name);
                        dataitem.Add("familyBirthday", family.birthday.Value.ToLongDateString());
                        dataitem.Add("familyAge", getAge(family.birthday.Value).ToString());
                        dataitem.Add("familySex", Enum.GetName(typeof(Utile.Data.性別), int.Parse(family.sex)));

                        rdb.insert(dataitem);
                    }
                }
                else
                {
                    Dictionary <string, string> dataitem = new Dictionary <string, string>();
                    dataitem.Add("customerCode", dataGridView1.Rows[i].Cells[1].Value.ToString());
                    var customer = DB.m_customer.getSingle(dataGridView1.Rows[i].Cells[1].Value.ToString());
                    dataitem.Add("customerSurNameKana", customer.surname_kana);
                    dataitem.Add("customerNamekana", customer.name_kana);
                    dataitem.Add("customerSurName", customer.surname);
                    dataitem.Add("customerName", customer.name);
                    dataitem.Add("customerBirthday", customer.birthday.ToLongDateString());
                    dataitem.Add("customerAge", getAge(customer.birthday).ToString());
                    dataitem.Add("customerSex", Enum.GetName(typeof(Utile.Data.性別), int.Parse(customer.sex)));
                    dataitem.Add("customerPostalNumber", customer.postal_code);
                    dataitem.Add("customerAddress1", customer.address1);
                    dataitem.Add("customerAddress2", customer.address2);
                    dataitem.Add("customerAddress3", customer.address3);
                    dataitem.Add("customerPhoneNumber1", customer.phone_number1);
                    dataitem.Add("customerPhoneNumber2", customer.phone_number2);
                    dataitem.Add("customerPhoneNumber3", customer.phone_number3);
                    dataitem.Add("customerFAX", customer.fax_number);
                    dataitem.Add("customerEMail", customer.mail_address);

                    var member = DB.m_member.getSingle(dataGridView1.Rows[i].Cells[1].Value.ToString());
                    if (member != null)
                    {
                        dataitem.Add("memberType", Enum.GetName(typeof(Utile.Data.会員種別), int.Parse(member.membership_type)));
                        dataitem.Add("memberJoinDate", member.date.ToLongDateString());
                    }
                    rdb.insert(dataitem);
                }
            }


            PrintForm p = new PrintForm();

            p.PrintReport.Load(@"./Asset/Format/Customer_infomation.flxr", "顧客情報 レポート");
            p.c1FlexViewer.DocumentSource = p.PrintReport;
            p.Show();
        }