Пример #1
0
        private static void PrintView()
        {
            SAPbouiCOM.Form oForm = B1Connections.theAppl.Forms.ActiveForm;
            string pFORMUID = oForm.DataSources.UserDataSources.Item("pFORMUID").ValueEx;
            SAPbouiCOM.Form pForm = (SAPbouiCOM.Form)B1Connections.theAppl.Forms.Item(pFORMUID);

            StringBuilder sb = new StringBuilder();

            string cboBPLID = string.Empty;
            string edtFRDT = string.Empty;
            string edtTODT = string.Empty;
            string edtFRPRCCD = string.Empty;
            string edtTOPRCCD = string.Empty;
            string cboTRANSTY = string.Empty;

            string repFRPRCNM = string.Empty;
            string repTOPRCNM = string.Empty;
            string repBPLID = string.Empty;

            SAPbobsCOM.Recordset oRS;
            string strReportFiles = string.Empty;

            try
            {
                oRS = (SAPbobsCOM.Recordset)B1Connections.diCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);

                cboBPLID = pForm.DataSources.UserDataSources.Item("cboBPLID").Value;
                edtFRDT = pForm.DataSources.UserDataSources.Item("edtFRDT").Value;
                edtTODT = pForm.DataSources.UserDataSources.Item("edtTODT").Value;
                edtFRPRCCD = pForm.DataSources.UserDataSources.Item("edtFRPRCCD").Value;
                edtTOPRCCD = pForm.DataSources.UserDataSources.Item("edtTOPRCCD").Value;
                cboTRANSTY = pForm.DataSources.UserDataSources.Item("cboTRANSTY").Value;

                repFRPRCNM = pForm.DataSources.UserDataSources.Item("edtFRPRCNM").Value;
                repTOPRCNM = pForm.DataSources.UserDataSources.Item("edtTOPRCNM").Value;

                if (repFRPRCNM == "")
                    repFRPRCNM = "전체";

                if (repTOPRCNM == "")
                    repTOPRCNM = "전체";

                if (cboBPLID != "")
                    repBPLID = FN.GetRecordsetValue(string.Format("SELECT BPLName FROM OBPL WHERE BPLId = '{0}'",cboBPLID));              
                else
                    repBPLID = "전체";

                sb.Append(" EXEC KIS_SP_FI0050F1_HRD  @cboBPLID         = '{0}'        ");
                sb.Append("                         , @edtFRDT          = '{1}'        ");
                sb.Append("                         , @edtTODT          = '{2}'        ");
                sb.Append("                         , @edtFRPRCCD       = '{3}'        ");
                sb.Append("                         , @edtTOPRCCD       = '{4}'        ");
                sb.Append("                         , @cboTRANSTY       = '{5}'        ");
                oRS.DoQuery(string.Format(sb.ToString(), cboBPLID, edtFRDT, edtTODT, edtFRPRCCD, edtTOPRCCD, cboTRANSTY));

                strReportFiles = "\\RPT\\KOR\\KIS_FI0050F_HRD.RPT";

                if (!oRS.EoF)
                {

                    //리포트경로설정
                    string pStartPath = System.Reflection.Assembly.GetExecutingAssembly().Location;
                    pStartPath = pStartPath.Substring(0, pStartPath.LastIndexOf("\\"));

                    //데이터테이블가져옴.
                    System.Data.DataTable dt = FN.GetRecordsetToDataTable(string.Format(sb.ToString(), cboBPLID, edtFRDT, edtTODT, edtFRPRCCD, edtTOPRCCD, cboTRANSTY));
                    //dt = FN.SapRecordSetToDataTable(oRS);

                    using (CystalReportViewer rpt = new AddOnBase.CystalReportViewer())
                    {
                        try
                        {
                            rpt.crxReport.Load(pStartPath + strReportFiles);
                            rpt.crxReport.SetDataSource(dt);

                            //리포트파라미터설정
                            for (int i = 0; i <= rpt.crxReport.DataDefinition.FormulaFields.Count - 1; i++)
                            {
                                switch (rpt.crxReport.DataDefinition.FormulaFields[i].Name)
                                {
                                    case "DOCDT":
                                        rpt.crxReport.DataDefinition.FormulaFields[i].Text = "'" + edtFRDT + " ~ " + edtTODT + "'";
                                        break;
                                    case "FRPRCNM":
                                        rpt.crxReport.DataDefinition.FormulaFields[i].Text = "'" + repFRPRCNM + "'";
                                        break;
                                    case "TOPRCNM":
                                        rpt.crxReport.DataDefinition.FormulaFields[i].Text = "'" + repTOPRCNM + "'";
                                        break;
                                    case "repBPLID":
                                        rpt.crxReport.DataDefinition.FormulaFields[i].Text = "'" + repBPLID + "'";
                                        break;
                                }
                            }

                            rpt.ShowDialog(CFL.GetSBOWindow());

                        }
                        catch (Exception ex)
                        {
                            B1Connections.theAppl.StatusBar.SetText("PrintView " + ex.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error);
                        }
                    }
                }
                else
                    B1Connections.theAppl.StatusBar.SetText("출력 데이터가 존재 하지 않습니다. ", SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Warning);
            }

            catch (Exception ex)
            {
                B1Connections.theAppl.StatusBar.SetText("ET_btnPrt_AFItemPressed " + ex.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error);

            }
            finally
            {
                //oForm.Freeze(false);
            }
        }
Пример #2
0
        private static void PrintView()
        {
            SAPbouiCOM.Form oForm = B1Connections.theAppl.Forms.ActiveForm;
            StringBuilder sb = new StringBuilder();

            string edtFRDT = string.Empty;
            string edtTODT = string.Empty;

            string cboPAPERTP = string.Empty;

            SAPbobsCOM.Recordset oRS;
            string strReportFiles = string.Empty;

            try
            {
                oRS = (SAPbobsCOM.Recordset)B1Connections.diCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);

                string DOCNUMS = oForm.Items.Item("edtDOCNUM").Specific.value;

                sb.Append(" EXEC [KIS_SP_SD0030A_HRD]                ");
                sb.Append(" 	   @DOCNUMS	= '{0}'	                 ");

                oRS.DoQuery(string.Format(sb.ToString(), DOCNUMS));

                strReportFiles = "\\RPT\\KOR\\KIS_SD0030A_HRD.RPT";

                if (!oRS.EoF)
                {

                    //리포트경로설정
                    string pStartPath = System.Reflection.Assembly.GetExecutingAssembly().Location;
                    pStartPath = pStartPath.Substring(0, pStartPath.LastIndexOf("\\"));

                    //데이터테이블가져옴.
                    System.Data.DataTable dt = FN.GetRecordsetToDataTable(string.Format(sb.ToString(), DOCNUMS));
                    //dt = FN.SapRecordSetToDataTable(oRS);


                    using (CystalReportViewer rpt = new AddOnBase.CystalReportViewer())
                    {
                        try
                        {
                            rpt.crxReport.Load(pStartPath + strReportFiles);
                            rpt.crxReport.SetDataSource(dt);

                            //리포트파라미터설정
                            for (int i = 0; i <= rpt.crxReport.DataDefinition.FormulaFields.Count - 1; i++)
                            {
                                switch (rpt.crxReport.DataDefinition.FormulaFields[i].Name)
                                {
                                    //case "DOCDT":
                                    //    rpt.crxReport.DataDefinition.FormulaFields[i].Text = "'" + edtDOCDTF + " ~ " + edtDOCDTT + "'";
                                    //    break;

                                    //case "CLTNAM":
                                    //    rpt.crxReport.DataDefinition.FormulaFields[i].Text = "'" + B1Connections.diCompany.CompanyName + "'";
                                    //    break;
                                    //case "PRTLMT":
                                    //    rpt.crxReport.DataDefinition.FormulaFields[i].Text = "'" + strFrDate + " ~ " + strToDate + "'";
                                    //    break;
                                }
                            }

                            rpt.ShowDialog(CFL.GetSBOWindow());

                        }
                        catch (Exception ex)
                        {
                            B1Connections.theAppl.StatusBar.SetText("PrintView " + ex.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error);
                        }
                    }
                }
                else
                    B1Connections.theAppl.StatusBar.SetText("출력 데이터가 존재 하지 않습니다. ", SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Warning);
            }

            catch (Exception ex)
            {
                B1Connections.theAppl.StatusBar.SetText("ET_btnPrt_AFItemPressed " + ex.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error);

            }
            finally
            {
                //oForm.Freeze(false);
            }
        }
Пример #3
0
        private static void PrintView()
        {

            SAPbouiCOM.Form oForm = B1Connections.theAppl.Forms.ActiveForm;
            string strReportFiles = string.Empty;
            StringBuilder sb = null;

            string strCALLPER = string.Empty;
            string strCENTCE_FR = string.Empty;
            string strCENTCE_TO = string.Empty;

            try
            {
                strReportFiles = "\\RPT\\KOR\\KIS_SO0260F_HRD.RPT";


                //리포트경로설정
                string pStartPath = System.Reflection.Assembly.GetExecutingAssembly().Location;
                pStartPath = pStartPath.Substring(0, pStartPath.LastIndexOf("\\"));

                //데이터테이블가져옴.
                SAPbouiCOM.UserDataSources oUDS = oForm.DataSources.UserDataSources;

                strCALLPER = oUDS.Item("edtCALLPER").ValueEx;
                strCENTCE_FR = oUDS.Item("edtCENTCD1").ValueEx;
                strCENTCE_TO = oUDS.Item("edtCENTCD2").ValueEx;

                sb = new StringBuilder();
                //조회
                sb.AppendFormat(" EXEC KIS_SP_SO0260F2_HRD @pPERSON = '{0}', @pCENTCD_FR ='{1}', @pCENTCD_TO = '{2}' ", strCALLPER, strCENTCE_FR, strCENTCE_TO);

                System.Data.DataTable dt = FN.GetRecordsetToDataTable(sb.ToString());
                using (CystalReportViewer rpt = new AddOnBase.CystalReportViewer())
                {
                    try
                    {
                        rpt.crxReport.Load(pStartPath + strReportFiles);
                        rpt.crxReport.SetDataSource(dt);

                        //리포트파라미터설정
                        for (int i = 0; i <= rpt.crxReport.DataDefinition.FormulaFields.Count - 1; i++)
                        {
                            switch (rpt.crxReport.DataDefinition.FormulaFields[i].Name)
                            {

                                //case "REQYM":
                                //    rpt.crxReport.DataDefinition.FormulaFields[i].Text = "'" + ForMulaREQYM + "'";
                                //    break;

                                //case "CLTNAM":
                                //    rpt.crxReport.DataDefinition.FormulaFields[i].Text = "'" + B1Connections.diCompany.CompanyName + "'";
                                //    break;
                                //case "PRTLMT":
                                //    rpt.crxReport.DataDefinition.FormulaFields[i].Text = "'" + strFrDate + " ~ " + strToDate + "'";
                                //    break;
                            }
                        }

                        rpt.ShowDialog(CFL.GetSBOWindow());

                    }
                    catch (Exception ex)
                    {
                        B1Connections.theAppl.StatusBar.SetText("PrintView " + ex.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error);
                    }
                }
            }
            catch (Exception ex)
            {
                B1Connections.theAppl.StatusBar.SetText("ET_btnPrt_AFItemPressed " + ex.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error);

            }
            finally
            {
                //oForm.Freeze(false);
            }
        }
Пример #4
0
        private static void PrintView()
        {
            SAPbouiCOM.Form oForm = B1Connections.theAppl.Forms.ActiveForm;
            SAPbobsCOM.Recordset oRS = null;
            StringBuilder sb = new StringBuilder();
            string strBillNo = string.Empty;
            string strCardCD = string.Empty;
            string strRptFile = string.Empty;
            string strSP = string.Empty;
            string xSQL = string.Empty;
            string strValue = string.Empty;

            try
            {
                SAPbouiCOM.Grid oGrid;
                oRS = (SAPbobsCOM.Recordset)B1Connections.diCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);

                if (oForm.PaneLevel == 3)
                {
                    oGrid = (SAPbouiCOM.Grid)oForm.Items.Item("grd3").Specific;

                    //선택한 BILLNO을 출력하기 위해 임시테이블에 저장한다.
                    for (int i = 0; i <= oGrid.DataTable.Rows.Count - 1; i++)
                    {
                        if (oGrid.DataTable.Columns.Item("CHK").Cells.Item(i).Value == CFL.YES_MARK)
                        {
                            strBillNo = FN.GetGridCellValue(ref oGrid, "BILLNO", i).Trim();
                            sb.AppendFormat(",{0}", strBillNo);
                        }

                        strValue = sb.ToString();
                        if (strValue.Length > 0)
                            strValue = strValue.Remove(0, 1);

                    }

                    if (string.IsNullOrEmpty(strValue))


                        oRS = null;
                    SAPbobsCOM.Recordset oRS_Report;
                    oRS_Report = (SAPbobsCOM.Recordset)B1Connections.diCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);

                    //리포트경로설정
                    string pStartPath = System.Reflection.Assembly.GetExecutingAssembly().Location;

                    pStartPath = pStartPath.Substring(0, pStartPath.LastIndexOf("\\"));

                    // 사업장 : 1번 선택, 카테고리: --매출(O) 선택
                    xSQL = string.Format("EXEC KIS_SP_SO0230F2_HRD @pBPLID = '{0}' , @pCATEGORY = '{1}', @pPUBLISH_LIST = '{2}' ", "1", "O", strValue);
                    oRS_Report.DoQuery(xSQL);

                    //데이터테이블가져옴.
                    strRptFile = "\\RPT\\KOR\\" + "KIS_SO0230A_HRD.rpt";
                    System.Data.DataTable dt;
                    dt = CFL.SapRecordSetToDataTable(oRS_Report);

                    using (CystalReportViewer rpt = new AddOnBase.CystalReportViewer())
                    {
                        try
                        {
                            rpt.crxReport.Load(pStartPath + strRptFile);
                            rpt.crxReport.SetDataSource(dt);

                            ////리포트파라미터설정
                            //rpt.ShowDialog();
                            rpt.ShowDialog(CFL.GetSBOWindow());
                            //rpt.Show();

                        }
                        catch (Exception ex)
                        {
                            System.Windows.Forms.MessageBox.Show(ex.Message);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                B1Connections.theAppl.StatusBar.SetText(ex.ToString(), BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Error);
            }
            finally
            {
                if (oRS != null) { Marshal.ReleaseComObject(oRS); } oRS = null;
                oForm.Freeze(false);
            }
        }
Пример #5
0
        private static void PrintView()
        {
            SAPbouiCOM.Form oForm = B1Connections.theAppl.Forms.ActiveForm;
            SAPbobsCOM.Recordset oRS;
            //oForm.Freeze(true);
            try
            {

                oRS = (SAPbobsCOM.Recordset)B1Connections.diCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);

                //리포트경로설정
                string pStartPath = System.Reflection.Assembly.GetExecutingAssembly().Location;

                pStartPath = pStartPath.Substring(0, pStartPath.LastIndexOf("\\"));

                string pformuid = oForm.DataSources.UserDataSources.Item("pformuid").ValueEx;
                SAPbouiCOM.Form pForm = (SAPbouiCOM.Form)B1Connections.theAppl.Forms.Item(pformuid);
                SAPbouiCOM.UserDataSources UDSs = pForm.DataSources.UserDataSources;


                //string U_YEAR = UDSs.Item("cboYEAR").ValueEx;//회계연도
                string edtDOCDT = FN.GetDateString(UDSs.Item("edtDOCDT").ValueEx);//회계연도
                string U_DEPDOM = UDSs.Item("cboDEPDOM").ValueEx;//버젼
                string U_FACLASS_F = UDSs.Item("edtFACLASF").ValueEx;//자산클래스 시작
                string U_FACLASS_T = UDSs.Item("edtFACLAST").ValueEx;//자산클래스 종료
                string U_AC01_F = UDSs.Item("edtACCTCDT").ValueEx;//계정과목 시작
                string U_AC01_T = UDSs.Item("edtACCTCDF").ValueEx;//계정과목 종료
                string U_MAINCD = UDSs.Item("edtMAINCD").ValueEx;//대분류
                string U_MIDCD = UDSs.Item("edtMIDCD").ValueEx;//중분류
                string U_SUBCD = UDSs.Item("edtSUBCD").ValueEx;//소분류
                string U_SSUBCD = UDSs.Item("edtSSUBCD").ValueEx;//소소분류

                string chkACTY = UDSs.Item("chkACTY").ValueEx;//고정자산 활성
                string chkACTN = UDSs.Item("chkACTN").ValueEx;//고정자산 비활성
                string U_STATUS = "";

                if (chkACTY == "Y" && chkACTN == "Y")
                {
                    U_STATUS = "";
                }
                else if (chkACTY == "Y" && chkACTN == "N")
                {
                    U_STATUS = "A";
                }
                else if (chkACTY == "N" && chkACTN == "Y")
                {
                    U_STATUS = "U";
                }


                pformuid = null;
                pForm = null;
                UDSs = null;

                System.Text.StringBuilder isb = new System.Text.StringBuilder();
                isb.Append("EXEC [KIS_SP_FA0150F1] ");
                isb.Append(" @edtDOCDT ='{0}'");
                isb.Append(" ,@U_DEPDOM ='{1}'");
                isb.Append(" ,@U_FACLASS_F ='{2}'");
                isb.Append(" ,@U_FACLASS_T ='{3}'");
                isb.Append(" ,@U_AC01_F ='{4}'");
                isb.Append(" ,@U_AC01_T ='{5}'");
                isb.Append(" ,@U_MAINCD ='{6}'");
                isb.Append(" ,@U_MIDCD ='{7}'");
                isb.Append(" ,@U_SUBCD ='{8}'");
                isb.Append(" ,@U_SSUBCD ='{9}'");
                isb.Append(" ,@U_STATUS ='{10}'");



                string sQry = string.Format(isb.ToString(), edtDOCDT, U_DEPDOM, U_FACLASS_F, U_FACLASS_T, U_AC01_F, U_AC01_T, U_MAINCD, U_MIDCD, U_SUBCD, U_SSUBCD, U_STATUS);


                oRS.DoQuery(sQry);

                //데이터테이블가져옴.
                System.Data.DataTable dt;
                dt = CFL.SapRecordSetToDataTable(oRS);


                using (CystalReportViewer rpt = new AddOnBase.CystalReportViewer())
                {
                    try
                    {
                        rpt.crxReport.Load(pStartPath + @"\\RPT\\KOR\\KIS_SD0041F_HRD.rpt");
                        rpt.crxReport.SetDataSource(dt);

                        ////리포트파라미터설정
                        //for (i = 0; i <= rpt.crxReport.DataDefinition.FormulaFields.Count - 1; i++)
                        //{
                        //    switch (rpt.crxReport.DataDefinition.FormulaFields[i].Name)
                        //    {
                        //        case "{@AcctName}":
                        //            rpt.crxReport.DataDefinition.FormulaFields[i].Text = "\'" + "ACCTNAME" + "\'";
                        //            break;
                        //        case "{@BPName}":
                        //            rpt.crxReport.DataDefinition.FormulaFields[i].Text = "\'" + "BP_NAME" + "\'";
                        //            break;

                        //    }
                        //}

                        //rpt.ShowDialog();
                        rpt.ShowDialog(CFL.GetSBOWindow());
                        //rpt.Show();

                    }
                    catch (Exception ex)
                    {

                        System.Windows.Forms.MessageBox.Show(ex.Message);
                    }
                }
            }
            catch (Exception ex)
            {
                B1Connections.theAppl.StatusBar.SetText("ET_btnPrt_AFItemPressed " + ex.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error);

            }
            finally
            {
                //oForm.Freeze(false);
            }

        }
Пример #6
0
        private static void PrintView2()
        {
            SAPbouiCOM.Form oForm = B1Connections.theAppl.Forms.ActiveForm;
            //oForm.Freeze(true);
            try
            {
                //리포트경로설정
                string pStartPath = System.Reflection.Assembly.GetExecutingAssembly().Location;

                pStartPath = pStartPath.Substring(0, pStartPath.LastIndexOf("\\"));


                SAPbouiCOM.Grid oGrid = oForm.Items.Item("grd").Specific;
                XDocument root = XDocument.Parse(oGrid.DataTable.SerializeAsXML(BoDataTableXmlSelect.dxs_DataOnly));


                #region 지로개별인쇄 자료의 선택된 코드를 Concat
                var rowsLinq = from c in root.Descendants("Row")
                               where c.Elements("Cells").Elements("Cell").Any(o => o.Element("ColumnUid").Value == "U_CHK" && o.Element("Value").Value == "Y")
                               select c;

                if (rowsLinq.Count() == 0)
                {
                    FN.Trace("처리할 자료가 존재하지 않습니다.", BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Error);
                    return;
                }

                var colsLinq = from oColumns in rowsLinq.Descendants("Cell")
                               where (string)oColumns.Element("ColumnUid") == "Code" && oColumns.Elements("Value").Any()
                               select new { Code = oColumns.Element("Value").Value };


                string strCodes = String.Join(",", colsLinq.AsEnumerable().Select(o => "'" + o.Code + "'").ToArray());
                #endregion


                // 지로개별인쇄의 코드에 해당하는 자료 조회
                StringBuilder pQuery = new StringBuilder();
                pQuery.AppendLine(" SELECT ISNULL(MAX(MMM.U_RDNM_1),'') AS U_RDNM_1    ");
                pQuery.AppendLine(" 	 , ISNULL(MAX(MMM.U_BPPER_1),'구독료담당자') AS U_BPPER_1    ");
                pQuery.AppendLine(" 	 , ISNULL(MAX(MMM.U_ZIPCD1_1),'') AS U_ZIPCD1_1    ");
                pQuery.AppendLine(" 	 , RTRIM(LTRIM(ISNULL(MAX(MMM.U_ADDR1_1),'') + ' ' + ISNULL(MAX(MMM.U_ADDR1_D_1),''))) AS U_ADDR1_1 ");
                pQuery.AppendLine(" 	 , ISNULL(MAX(MMM.U_RMK_1),'') AS U_RMK_1  ");
                pQuery.AppendLine(" 	 , ISNULL(MAX(MMM.U_RDNM_2),'') AS U_RDNM_2    ");
                pQuery.AppendLine(" 	 , ISNULL(MAX(MMM.U_BPPER_2),'구독료담당자') AS U_BPPER_2    ");
                pQuery.AppendLine("      , ISNULL(MAX(MMM.U_ZIPCD1_2),'') AS U_ZIPCD1_2    ");
                pQuery.AppendLine("      , RTRIM(LTRIM(ISNULL(MAX(MMM.U_ADDR1_2),'') + ' ' + ISNULL(MAX(MMM.U_ADDR1_D_2),''))) AS U_ADDR1_2 ");
                pQuery.AppendLine("      , ISNULL(MAX(MMM.U_RMK_2),'') AS U_RMK_2  ");
                pQuery.AppendLine("      , ISNULL(MAX(MMM.U_RDNM_3),'') AS U_RDNM_3    ");
                pQuery.AppendLine(" 	 , ISNULL(MAX(MMM.U_BPPER_3),'구독료담당자') AS U_BPPER_3    ");
                pQuery.AppendLine("      , ISNULL(MAX(MMM.U_ZIPCD1_3),'') AS U_ZIPCD1_3    ");
                pQuery.AppendLine("      , RTRIM(LTRIM(ISNULL(MAX(MMM.U_ADDR1_3),'') + ' ' + ISNULL(MAX(MMM.U_ADDR1_D_3),''))) AS U_ADDR1_3 ");
                pQuery.AppendLine("      , ISNULL(MAX(MMM.U_RMK_3),'') AS U_RMK_3");
                pQuery.AppendLine("   FROM (    ");
                pQuery.AppendLine(" 		SELECT MM.U_ROWIDX  ");
                pQuery.AppendLine(" 			 , CASE MM.U_ROW WHEN 1 THEN MM.U_ZIPCD1 ELSE NULL END AS U_ZIPCD1_1    ");
                pQuery.AppendLine(" 			 , CASE MM.U_ROW WHEN 2 THEN MM.U_ZIPCD1 ELSE NULL END AS U_ZIPCD1_2    ");
                pQuery.AppendLine(" 			 , CASE MM.U_ROW WHEN 3 THEN MM.U_ZIPCD1 ELSE NULL END AS U_ZIPCD1_3    ");
                pQuery.AppendLine(" 		     , CASE MM.U_ROW WHEN 1 THEN MM.U_ADDR1 ELSE NULL END AS U_ADDR1_1      ");
                pQuery.AppendLine(" 			 , CASE MM.U_ROW WHEN 2 THEN MM.U_ADDR1 ELSE NULL END AS U_ADDR1_2      ");
                pQuery.AppendLine(" 			 , CASE MM.U_ROW WHEN 3 THEN MM.U_ADDR1 ELSE NULL END AS U_ADDR1_3      ");
                pQuery.AppendLine(" 			 , CASE MM.U_ROW WHEN 1 THEN MM.U_RDNM ELSE NULL END AS U_RDNM_1        ");
                pQuery.AppendLine(" 			 , CASE MM.U_ROW WHEN 2 THEN MM.U_RDNM ELSE NULL END AS U_RDNM_2        ");
                pQuery.AppendLine(" 			 , CASE MM.U_ROW WHEN 3 THEN MM.U_RDNM ELSE NULL END AS U_RDNM_3		");
                pQuery.AppendLine(" 			 , CASE MM.U_ROW WHEN 1 THEN MM.U_ADDR1_D ELSE NULL END AS U_ADDR1_D_1  ");
                pQuery.AppendLine(" 			 , CASE MM.U_ROW WHEN 2 THEN MM.U_ADDR1_D ELSE NULL END AS U_ADDR1_D_2  ");
                pQuery.AppendLine(" 			 , CASE MM.U_ROW WHEN 3 THEN MM.U_ADDR1_D ELSE NULL END AS U_ADDR1_D_3  ");
                pQuery.AppendLine(" 			 , CASE MM.U_ROW WHEN 1 THEN MM.U_RMK ELSE NULL END AS U_RMK_1          ");
                pQuery.AppendLine(" 			 , CASE MM.U_ROW WHEN 2 THEN MM.U_RMK ELSE NULL END AS U_RMK_2          ");
                pQuery.AppendLine(" 			 , CASE MM.U_ROW WHEN 3 THEN MM.U_RMK ELSE NULL END AS U_RMK_3          ");
                pQuery.AppendLine(" 			 , CASE MM.U_ROW WHEN 1 THEN MM.U_BPPER ELSE NULL END AS U_BPPER_1      ");
                pQuery.AppendLine(" 			 , CASE MM.U_ROW WHEN 2 THEN MM.U_BPPER ELSE NULL END AS U_BPPER_2      ");
                pQuery.AppendLine(" 			 , CASE MM.U_ROW WHEN 3 THEN MM.U_BPPER ELSE NULL END AS U_BPPER_3      ");
                pQuery.AppendLine(" 		  FROM (SELECT CONVERT(INT, ROW_NUMBER() OVER (PARTITION BY M.U_ROWIDX ORDER BY M.U_ROWIDX)) AS U_ROW ");
                pQuery.AppendLine(" 					 , M.U_ROWIDX   ");
                pQuery.AppendLine(" 					 , M.U_RDNM     ");
                pQuery.AppendLine(" 					 , M.U_BPPER    ");
                pQuery.AppendLine(" 					 , CASE WHEN ISNULL(M.U_ZIPCD1,'') = '' THEN NULL ELSE LEFT(REPLACE(M.U_ZIPCD1,'-',''),3) + '-' + RIGHT(REPLACE(M.U_ZIPCD1,'-',''),3) END AS U_ZIPCD1   ");
                pQuery.AppendLine(" 					 , M.U_ADDR1    ");
                pQuery.AppendLine(" 					 , M.U_ADDR1_D  ");
                pQuery.AppendLine(" 					 , M.U_MARKYM   ");
                pQuery.AppendLine(" 					 , M.U_RMK      ");
                pQuery.AppendLine(" 				  FROM (SELECT CONVERT(INT, ((ROW_NUMBER() OVER (ORDER BY A.Code) - 1) / 3)) AS U_ROWIDX  ");
                pQuery.AppendLine(" 							 , A.U_RDNM ");
                pQuery.AppendLine(" 							 , (SELECT F.U_BPPER FROM [@KIS_SO0030M_HRD] F WHERE F.Code = A.U_RDCD) AS U_BPPER  ");
                pQuery.AppendLine(" 							 , A.U_ZIPCD1   ");
                pQuery.AppendLine(" 							 , A.U_ADDR1    ");
                pQuery.AppendLine(" 							 , A.U_ADDR1_D  ");
                pQuery.AppendLine(" 							 , A.U_MARKYM   ");
                pQuery.AppendLine(" 							 , A.U_RMK      ");
                pQuery.AppendLine(" 						  FROM [@KIS_SO0220M_HRD] A ");
                pQuery.AppendLine(" 						 WHERE A.Code IN ({0})  ");
                pQuery.AppendLine(" 				       ) M  ");
                pQuery.AppendLine(" 			   ) MM ");
                pQuery.AppendLine("        ) MMM    ");
                pQuery.AppendLine(" GROUP BY MMM.U_ROWIDX   ");


                System.Data.DataTable dt = FN.GetSqlQueryToDataTable(string.Format(pQuery.ToString(), strCodes));

                using (CystalReportViewer rpt = new AddOnBase.CystalReportViewer())
                {
                    try
                    {
                        rpt.crxReport.Load(pStartPath + @"\\RPT\\KOR\\KIS_SO0221A_HRD.rpt");
                        rpt.crxReport.SetDataSource(dt);

                        ////리포트파라미터설정
                        //for (i = 0; i <= rpt.crxReport.DataDefinition.FormulaFields.Count - 1; i++)
                        //{
                        //    switch (rpt.crxReport.DataDefinition.FormulaFields[i].Name)
                        //    {
                        //        case "{@AcctName}":
                        //            rpt.crxReport.DataDefinition.FormulaFields[i].Text = "\'" + "ACCTNAME" + "\'";
                        //            break;
                        //        case "{@BPName}":
                        //            rpt.crxReport.DataDefinition.FormulaFields[i].Text = "\'" + "BP_NAME" + "\'";
                        //            break;

                        //    }
                        //}

                        //Report Viewer 실행
                        //rpt.ShowDialog();
                        rpt.ShowDialog(CFL.GetSBOWindow());
                        //rpt.Show();

                    }
                    catch (Exception ex)
                    {

                        System.Windows.Forms.MessageBox.Show(ex.Message);
                    }
                }
            }
            catch (Exception ex)
            {
                B1Connections.theAppl.StatusBar.SetText("OnAfterItemPressed_btnLabel " + ex.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error);

            }
            finally
            {
                //oForm.Freeze(false);
            }

        }
Пример #7
0
        private static void PrintView()
        {
            SAPbouiCOM.Form oForm = B1Connections.theAppl.Forms.ActiveForm;
            //oForm.Freeze(true);
            try
            {
                //리포트경로설정
                string pStartPath = System.Reflection.Assembly.GetExecutingAssembly().Location;

                pStartPath = pStartPath.Substring(0, pStartPath.LastIndexOf("\\"));


                SAPbouiCOM.Grid oGrid = oForm.Items.Item("grd").Specific;
                XDocument root = XDocument.Parse(oGrid.DataTable.SerializeAsXML(BoDataTableXmlSelect.dxs_DataOnly));


                #region 지로개별인쇄 자료의 선택된 코드를 Concat
                var rowsLinq = from c in root.Descendants("Row")
                             where c.Elements("Cells").Elements("Cell").Any(o => o.Element("ColumnUid").Value == "U_CHK" && o.Element("Value").Value == "Y")
                             select c;

                if (rowsLinq.Count() == 0)
                {
                    FN.Trace("처리할 자료가 존재하지 않습니다.", BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Error);
                    return;
                }

                var colsLinq = from oColumns in rowsLinq.Descendants("Cell")
                               where (string)oColumns.Element("ColumnUid") == "Code" && oColumns.Elements("Value").Any()
                               select new { Code = oColumns.Element("Value").Value };


                string strCodes = String.Join(",", colsLinq.AsEnumerable().Select(o => o.Code).ToArray());
                #endregion


                // 지로개별인쇄의 코드에 해당하는 자료 조회
                StringBuilder pQuery = new StringBuilder();
                pQuery.AppendLine(" SELECT Code                                                                                 ");
                pQuery.AppendLine("      , U_PRINTDT                                                                            ");
                pQuery.AppendLine("      , U_SEQ                                                                                ");
                pQuery.AppendLine("      , U_PRINT                                                                              ");
                pQuery.AppendLine("      , U_GIRONO                                                                             ");
                pQuery.AppendLine("      , U_RDCD                                                                               ");
                pQuery.AppendLine("      , U_RDNM                                                                               ");
                pQuery.AppendLine("      , (SELECT F.U_BPPER FROM [@KIS_SO0030M_HRD] F WHERE F.Code = U_RDCD) AS U_BPPER        ");
                pQuery.AppendLine("      , U_RDNO                                                                               ");
                pQuery.AppendLine("      , ISNULL(U_ADDR1, '') + ' ' + ISNULL(U_ADDR1_D, '') AS U_ADDR1                         ");
                pQuery.AppendLine("      , U_BRCNM AS U_BRCCD                                                                   ");
                pQuery.AppendLine("      , U_REQYM                                                                              ");
                pQuery.AppendLine("      , U_USEYM                                                                              ");
                pQuery.AppendLine("      , U_CNT                                                                                ");
                pQuery.AppendLine("      , U_REQAMT                                                                             ");
                pQuery.AppendLine("      , U_MARKYM                                                                             ");
                pQuery.AppendLine("      , (SELECT TOP(1) F.NAME FROM [@KIS_SO0050M_HRD] F WHERE F.CODE = U_PAYCD) AS U_PAYCD   ");
                pQuery.AppendLine("      , (SELECT U_SMLNM FROM [@KIS_AD00201] F WHERE U_SMLCD = U_PAPERTP) AS U_PAPERTP        ");
                pQuery.AppendLine("      , U_RMK                                                                                ");
                pQuery.AppendLine("   FROM [@KIS_SO0220M_HRD]                                                                   ");
                pQuery.AppendLine("  WHERE Code IN ({0})                                                                        ");


                System.Data.DataTable dt = FN.GetRecordsetToDataTable(string.Format(pQuery.ToString(), strCodes));

                using (CystalReportViewer rpt = new AddOnBase.CystalReportViewer())
                {
                    try
                    {
                        rpt.crxReport.Load(pStartPath + @"\\RPT\\KOR\\KIS_SO0220A_HRD.rpt");
                        rpt.crxReport.SetDataSource(dt);

                        ////리포트파라미터설정
                        //for (i = 0; i <= rpt.crxReport.DataDefinition.FormulaFields.Count - 1; i++)
                        //{
                        //    switch (rpt.crxReport.DataDefinition.FormulaFields[i].Name)
                        //    {
                        //        case "{@AcctName}":
                        //            rpt.crxReport.DataDefinition.FormulaFields[i].Text = "\'" + "ACCTNAME" + "\'";
                        //            break;
                        //        case "{@BPName}":
                        //            rpt.crxReport.DataDefinition.FormulaFields[i].Text = "\'" + "BP_NAME" + "\'";
                        //            break;

                        //    }
                        //}

                        //Report Viewer 실행
                        //rpt.ShowDialog();
                        rpt.ShowDialog(CFL.GetSBOWindow());
                        //rpt.Show();

                    }
                    catch (Exception ex)
                    {

                        System.Windows.Forms.MessageBox.Show(ex.Message);
                    }
                }
            }
            catch (Exception ex)
            {
                B1Connections.theAppl.StatusBar.SetText("OnAfterItemPressed_btnPRINT " + ex.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error);

            }
            finally
            {
                //oForm.Freeze(false);
            }

        }
Пример #8
0
        private static void PrintView()
        {

            SAPbouiCOM.Form oForm = B1Connections.theAppl.Forms.ActiveForm;
            string pFORMUID = oForm.DataSources.UserDataSources.Item("pFORMUID").ValueEx;
            SAPbouiCOM.Form pForm = (SAPbouiCOM.Form)B1Connections.theAppl.Forms.Item(pFORMUID);
            StringBuilder sb = new StringBuilder();

            string REQYM = pForm.Items.Item("cboREQYM").Specific.Value;
            string PAPERTP = pForm.Items.Item("cboPAPERTP").Specific.Value;
            string FRBRCCD = pForm.Items.Item("cboFRBRCCD").Specific.Value;

            SAPbobsCOM.Recordset oRS;
            string strReportFiles = string.Empty;

            try
            {
                oRS = (SAPbobsCOM.Recordset)B1Connections.diCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);

                sb.Append(" EXEC [KIS_SP_SO0300F_HRD]                 ");
                sb.Append(" 	  	@REQYM='{0}'                      ");
                sb.Append(" 	  ,	@PAPERTP='{1}'                    ");
                sb.Append(" 	  ,	@FRBRCCD='{2}'                    ");
                sb.Append(" 	  ,	@TYPE='2'                         ");

                oRS.DoQuery(string.Format(sb.ToString(), REQYM, PAPERTP, FRBRCCD));

                strReportFiles = "\\RPT\\KOR\\KIS_SO0301F_HRD.RPT";

                if (!oRS.EoF)
                {

                    //리포트경로설정
                    string pStartPath = System.Reflection.Assembly.GetExecutingAssembly().Location;
                    pStartPath = pStartPath.Substring(0, pStartPath.LastIndexOf("\\"));

                    //데이터테이블가져옴.
                    System.Data.DataTable dt = FN.GetRecordsetToDataTable(string.Format(sb.ToString(), REQYM, PAPERTP, FRBRCCD));
                    //dt = FN.SapRecordSetToDataTable(oRS);

                    string ForMulaREQYM = REQYM;

                    ForMulaREQYM = FN.Left(REQYM, 4) + "년 " + FN.Right(REQYM, 2) + "월";

                    using (CystalReportViewer rpt = new AddOnBase.CystalReportViewer())
                    {
                        try
                        {
                            rpt.crxReport.Load(pStartPath + strReportFiles);
                            rpt.crxReport.SetDataSource(dt);

                            //리포트파라미터설정
                            for (int i = 0; i <= rpt.crxReport.DataDefinition.FormulaFields.Count - 1; i++)
                            {
                                switch (rpt.crxReport.DataDefinition.FormulaFields[i].Name)
                                {
                                    
                                    case "REQYM":
                                        rpt.crxReport.DataDefinition.FormulaFields[i].Text = "'" + ForMulaREQYM + "'";
                                        
                                        break;

                                    //case "CLTNAM":
                                    //    rpt.crxReport.DataDefinition.FormulaFields[i].Text = "'" + B1Connections.diCompany.CompanyName + "'";
                                    //    break;
                                    //case "PRTLMT":
                                    //    rpt.crxReport.DataDefinition.FormulaFields[i].Text = "'" + strFrDate + " ~ " + strToDate + "'";
                                    //    break;
                                }
                            }

                            rpt.ShowDialog(CFL.GetSBOWindow());

                        }
                        catch (Exception ex)
                        {
                            B1Connections.theAppl.StatusBar.SetText("PrintView " + ex.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error);
                        }
                    }
                }
                else
                    B1Connections.theAppl.StatusBar.SetText("출력 데이터가 존재 하지 않습니다. ", SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Warning);
            }

            catch (Exception ex)
            {
                B1Connections.theAppl.StatusBar.SetText("ET_btnPrt_AFItemPressed " + ex.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error);

            }
            finally
            {
                //oForm.Freeze(false);
            }
        }