Ejemplo n.º 1
0
        /// <summary>
        /// 导出报表(用户数据)
        /// </summary>
        /// <param name="TradeAccount">客户账号</param>
        /// <param name="UserName">客户姓名</param>
        /// <param name="TelPhone">手机号码</param>
        /// <param name="Broker">经纪人</param>
        /// <param name="orgid">会员名称</param>
        /// <param name="IsBroker">是否经纪人</param>
        /// <param name="starttime">开始时间</param>
        /// <param name="endtime">结束时间</param>
        /// <param name="reporttype">报表类型</param>
        /// <param name="LoginID">登陆标识</param>
        /// <returns>报表地址</returns>
        public ReportForms GetReportFormsUser(string TradeAccount,string UserName,string TelPhone,string Broker,string orgid,string IsBroker,
            DateTime starttime, DateTime endtime, int reporttype, string LoginID)
        {
            ReportForms forms = new ReportForms();
            string rfile = string.Empty;
            try
            {
                TradeUser TdUser = new TradeUser();
                #region 判断登陆标识是否过期

                if (!ComFunction.ExistUserLoginID(LoginID, ref TdUser))
                {
                    forms.Result = false;
                    forms.Desc = ResCode.UL003Desc;
                    return forms;
                }
                if (UserType.NormalType == TdUser.UType)
                {
                    forms.Result = false;
                    forms.Desc = ComFunction.NotRightUser;
                    return forms;
                }
                string LoginOrgID = "";
                if (UserType.OrgType == TdUser.UType && !string.IsNullOrEmpty(TdUser.OrgId))
                {
                    //PartSearchCondition = " and orgid in (select orgid from #tmp) ";
                    LoginOrgID = TdUser.OrgId;
                }
                #endregion
                if (!(reporttype >= 0 && reporttype <= 11))
                {
                    forms.Result = false;
                    forms.Desc = "报表类型错误";
                    return forms;
                }

                DateTime dt = DateTime.Now;

                switch (reporttype) //确定导出文件名称
                {
                    case 11: rfile = string.Format("U{0}.xls", dt.ToString("yyyyMMddHHmmssfff"));
                        break;
                }

                System.Data.Common.DbParameter OutputParam = DbHelper.CreateDbParameter(JinTong.Jyrj.Data.DataBase.Type,
                    "@Result", DbParameterType.String, 1, ParameterDirection.Output);

                string path = ComFunction.ReportFilePath + "\\" + dt.ToString("yyyyMM");
                DbHelper.RunProcedureExecuteSql("P_ReportExportExcelUser",
                    new System.Data.Common.DbParameter[]{
                        DbHelper.CreateDbParameter(JinTong.Jyrj.Data.DataBase.Type,
                    "@LoginOrgID",DbParameterType.String,LoginOrgID,ParameterDirection.Input),
                         DbHelper.CreateDbParameter(JinTong.Jyrj.Data.DataBase.Type,
                    "@TradeAccount",DbParameterType.String,TradeAccount,ParameterDirection.Input),
                     DbHelper.CreateDbParameter(JinTong.Jyrj.Data.DataBase.Type,
                    "@UserName",DbParameterType.String,UserName,ParameterDirection.Input),
                     DbHelper.CreateDbParameter(JinTong.Jyrj.Data.DataBase.Type,
                    "@TelPhone",DbParameterType.String,TelPhone,ParameterDirection.Input),
                     DbHelper.CreateDbParameter(JinTong.Jyrj.Data.DataBase.Type,
                    "@Broker",DbParameterType.String,Broker,ParameterDirection.Input),
                     DbHelper.CreateDbParameter(JinTong.Jyrj.Data.DataBase.Type,
                    "@orgid",DbParameterType.String,orgid,ParameterDirection.Input),
                     DbHelper.CreateDbParameter(JinTong.Jyrj.Data.DataBase.Type,
                    "@IsBroker",DbParameterType.String,IsBroker,ParameterDirection.Input),

                         DbHelper.CreateDbParameter(JinTong.Jyrj.Data.DataBase.Type,
                    "@BeginDate",DbParameterType.DateTime,starttime,ParameterDirection.Input),
                      DbHelper.CreateDbParameter(JinTong.Jyrj.Data.DataBase.Type,
                    "@EndDate",DbParameterType.DateTime,endtime,ParameterDirection.Input),
                       DbHelper.CreateDbParameter(JinTong.Jyrj.Data.DataBase.Type,
                    "@ReportType",DbParameterType.Int,reporttype,ParameterDirection.Input),
                        DbHelper.CreateDbParameter(JinTong.Jyrj.Data.DataBase.Type,
                    "@ReportDir",DbParameterType.String,path,ParameterDirection.Input),
                         DbHelper.CreateDbParameter(JinTong.Jyrj.Data.DataBase.Type,
                    "@ReportFile",DbParameterType.String,rfile,ParameterDirection.Input),
                            OutputParam});

                if (0 == Convert.ToInt32(OutputParam.Value))
                {
                    forms.Result = true;
                    forms.Desc = "报表导出成功";
                    forms.ReportAddr = ComFunction.ReportAddr + dt.ToString("yyyyMM") + "/" + rfile; //URL地址
                }
                else
                {
                    forms.Result = false;
                    forms.Desc = "报表导出失败";
                    forms.ReportAddr = string.Empty;
                }
            }
            catch (Exception ex)
            {
                ComFunction.WriteErr(ex);
                forms.Result = false;
                forms.Desc = "报表导出错误";
                forms.ReportAddr = string.Empty;
            }
            return forms;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 导出报表
        /// </summary>
        /// <param name="starttime">开始时间</param>
        /// <param name="endtime">结束时间</param>
        /// <param name="reporttype">报表类型(0有效订单,1限价挂单,2入库单,3平仓,4资金变动,5账户结余)</param>
        /// <param name="LoginID">管理员或组织登陆标识</param>
        /// <returns>报表地址</returns>
        public ReportForms GetReportForms(DateTime starttime, DateTime endtime, int reporttype, string LoginID)
        {
            string reportAddr = string.Empty;
            ReportForms forms = new ReportForms();
            string rfile = string.Empty;
            try
            {
                TradeUser TdUser = new TradeUser();
                #region 判断登陆标识是否过期

                if (!ComFunction.ExistUserLoginID(LoginID, ref TdUser))
                {
                    forms.Result = false;
                    forms.Desc = ResCode.UL003Desc;
                    return forms;
                }
                if (UserType.NormalType == TdUser.UType)
                {
                    forms.Result = false;
                    forms.Desc = ComFunction.NotRightUser;
                    return forms;
                }
                #endregion
                if (!(reporttype >= 0 && reporttype <= 10))
                {
                    forms.Result = false;
                    forms.Desc = "报表类型错误";
                    return forms;
                }

                DateTime dt = DateTime.Now;

                switch (reporttype) //确定导出文件名称
                {
                    case 0: rfile = string.Format("Y{0}.xls", dt.ToString("yyyyMMddHHmmssfff"));
                        break;
                    case 1: rfile = string.Format("X{0}.xls", dt.ToString("yyyyMMddHHmmssfff"));
                        break;
                    case 2: rfile = string.Format("R{0}.xls", dt.ToString("yyyyMMddHHmmssfff"));
                        break;
                    case 3: rfile = string.Format("T{0}.xls", dt.ToString("yyyyMMddHHmmssfff"));
                        break;
                    case 4: rfile = string.Format("Z{0}.xls", dt.ToString("yyyyMMddHHmmssfff"));
                        break;
                    case 5: rfile = string.Format("M{0}.xls", dt.ToString("yyyyMMddHHmmssfff"));
                        break;
                    default: rfile = string.Format("B{0}.xls", dt.ToString("yyyyMMddHHmmssfff"));
                        break;
                }

                System.Data.Common.DbParameter OutputParam = DbHelper.CreateDbParameter(JinTong.Jyrj.Data.DataBase.Type,
                    "@Result", DbParameterType.String, 1, ParameterDirection.Output);

                if (UserType.OrgType == TdUser.UType && !string.IsNullOrEmpty(TdUser.OrgId))
                {
                    DbHelper.RunProcedureExecuteSql("P_ReportExportExcelAgent",
                       new System.Data.Common.DbParameter[]{
                         DbHelper.CreateDbParameter(JinTong.Jyrj.Data.DataBase.Type,
                    "@BeginDate",DbParameterType.DateTime,starttime,ParameterDirection.Input),
                      DbHelper.CreateDbParameter(JinTong.Jyrj.Data.DataBase.Type,
                    "@EndDate",DbParameterType.DateTime,endtime,ParameterDirection.Input),
                    DbHelper.CreateDbParameter(JinTong.Jyrj.Data.DataBase.Type,
                    "@Agentid",DbParameterType.String,TdUser.OrgId,ParameterDirection.Input),
                       DbHelper.CreateDbParameter(JinTong.Jyrj.Data.DataBase.Type,
                    "@ReportType",DbParameterType.Int,reporttype,ParameterDirection.Input),
                        DbHelper.CreateDbParameter(JinTong.Jyrj.Data.DataBase.Type,
                    "@ReportDir",DbParameterType.String,ComFunction.ReportFilePath + "\\" + dt.ToString("yyyyMM"),ParameterDirection.Input),
                         DbHelper.CreateDbParameter(JinTong.Jyrj.Data.DataBase.Type,
                    "@ReportFile",DbParameterType.String,rfile,ParameterDirection.Input),
                            OutputParam});
                }
                else
                {
                    string path = ComFunction.ReportFilePath + "\\" + dt.ToString("yyyyMM");
                    DbHelper.RunProcedureExecuteSql("P_ReportExportExcel",
                        new System.Data.Common.DbParameter[]{
                         DbHelper.CreateDbParameter(JinTong.Jyrj.Data.DataBase.Type,
                    "@BeginDate",DbParameterType.DateTime,starttime,ParameterDirection.Input),
                      DbHelper.CreateDbParameter(JinTong.Jyrj.Data.DataBase.Type,
                    "@EndDate",DbParameterType.DateTime,endtime,ParameterDirection.Input),
                       DbHelper.CreateDbParameter(JinTong.Jyrj.Data.DataBase.Type,
                    "@ReportType",DbParameterType.Int,reporttype,ParameterDirection.Input),
                        DbHelper.CreateDbParameter(JinTong.Jyrj.Data.DataBase.Type,
                    "@ReportDir",DbParameterType.String,path,ParameterDirection.Input),
                         DbHelper.CreateDbParameter(JinTong.Jyrj.Data.DataBase.Type,
                    "@ReportFile",DbParameterType.String,rfile,ParameterDirection.Input),
                            OutputParam});
                }

                if (0 == Convert.ToInt32(OutputParam.Value))
                {
                    forms.Result = true;
                    forms.Desc = "报表导出成功";
                    forms.ReportAddr = ComFunction.ReportAddr + dt.ToString("yyyyMM") + "/" + rfile; //URL地址
                }
                else
                {
                    forms.Result = false;
                    forms.Desc = "报表导出失败";
                    forms.ReportAddr = string.Empty;
                }
            }
            catch (Exception ex)
            {
                ComFunction.WriteErr(ex);
                forms.Result = false;
                forms.Desc = "报表导出错误";
                forms.ReportAddr = string.Empty;
            }
            return forms;
        }