Ejemplo n.º 1
0
        void dgvReport_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex == -1 || e.ColumnIndex == -1)
            {
                return;
            }

            if (dgvReport.Columns[e.ColumnIndex].Name == COL_BUTTON.Name)
            {
                string reportName = dgvReport[COL_REPORT_NAME.Name, e.RowIndex].Value.ToString();
                int    t          = (int)TrasenFrame.Classes.ReportPaper.PrinterTargetType.自定义打印机;
                if (dgvReport[COL_TYPE.Name, e.RowIndex].Value.ToString() == TrasenFrame.Classes.ReportPaper.PrinterTargetType.报表打印机.ToString())
                {
                    t = (int)TrasenFrame.Classes.ReportPaper.PrinterTargetType.报表打印机;
                }
                if (dgvReport[COL_TYPE.Name, e.RowIndex].Value.ToString() == TrasenFrame.Classes.ReportPaper.PrinterTargetType.发票打印机.ToString())
                {
                    t = (int)TrasenFrame.Classes.ReportPaper.PrinterTargetType.发票打印机;
                }
                string pname = dgvReport[COL_PRINTER_NAME.Name, e.RowIndex].Value.ToString();

                FrmSelectTarget dlgSelected = new FrmSelectTarget(pname, t);

                dlgSelected.OnAfterSelected += delegate(TrasenFrame.Classes.ReportPaper.PrinterTargetType type, string printName)
                {
                    ReportPaper.SetReportPaperPrinter(reportName, printName, (int)type);
                    dgvReport[COL_TYPE.Name, e.RowIndex].Value         = type.ToString();
                    dgvReport[COL_PRINTER_NAME.Name, e.RowIndex].Value = printName;
                    reportPapers = TrasenFrame.Classes.ReportPaper.LoadLocalReportPapers(TrasenFrame.Forms.FrmMdiMain.Database);
                };
                dlgSelected.ShowDialog();

                //静态方法调用测试
                //int t;
                //string name;
                //if ( FrmSelectTarget.SetReportPaperPrinterConfig( reportName , out t , out name ) )
                //{
                //    dgvReport[COL_TYPE.Name , e.RowIndex].Value = ((TrasenFrame.Classes.ReportPaper.PrinterTargetType)t).ToString();
                //    dgvReport[COL_PRINTER_NAME.Name , e.RowIndex].Value = name;
                //}
            }
        }
Ejemplo n.º 2
0
        public RESTStatus AddPaperTemplate(SQLLib sql, ReportPaper req, NetworkConnectionInfo ni)
        {
#if !TXTREPORT
            if (ni.HasAcl(ACLFlags.ChangeServerSettings) == false)
            {
                ni.Error   = "Access denied";
                ni.ErrorID = ErrorFlags.AccessDenied;
                return(RESTStatus.Denied);
            }

            if (req == null)
            {
                ni.Error   = "Invalid data";
                ni.ErrorID = ErrorFlags.InvalidData;
                return(RESTStatus.Fail);
            }

            if (string.IsNullOrWhiteSpace(req.Name) == true)
            {
                ni.Error   = "Invalid data";
                ni.ErrorID = ErrorFlags.InvalidData;
                return(RESTStatus.Fail);
            }

            req.Name = req.Name.ToUpper().Trim();

            if (SupportedNames.Contains(req.Name) == false)
            {
                ni.Error   = "Invalid data";
                ni.ErrorID = ErrorFlags.InvalidData;
                return(RESTStatus.Fail);
            }

            if (req.data == null)
            {
                lock (ni.sqllock)
                {
                    sql.ExecSQL("DELETE from ReportPapers WHERE ID=@id",
                                new SQLParam("@id", req.Name));
                }
                return(RESTStatus.Success);
            }
            else
            {
                if (RenderReport.RenderReportData(req.data, new Dictionary <string, object>()) == null)
                {
                    ni.Error   = "Rendering of report failed";
                    ni.ErrorID = ErrorFlags.InvalidData;
                    return(RESTStatus.Fail);
                }

                lock (ni.sqllock)
                {
                    if (sql.ExecSQL("if exists(select * from ReportPapers where [ID]=@ID) update ReportPapers set [Data]=@data,DT=getutcdate() where [ID]=@ID else insert into ReportPapers ([ID],[Data]) values(@ID,@data)",
                                    new SQLParam("@ID", req.Name),
                                    new SQLParam("@data", req.data)) == false)
                    {
                        ni.Error   = "SQL Error";
                        ni.ErrorID = ErrorFlags.SQLError;
                        return(RESTStatus.Fail);
                    }
                }
            }
            return(RESTStatus.Success);
#else
            ni.Error   = "Unsupported functionality";
            ni.ErrorID = ErrorFlags.SystemError;
            return(RESTStatus.Fail);
#endif
        }