为什么我的代码无法找到数据表?

时间:2016-09-07 03:56:01

标签: c# asp.net-mvc-3 datatable report

我在下面使用此代码生成报告。我的问题是为什么我的数据表的某个内容无法通过我的代码找到? ds.dt_ProposedSeminars就是表格。

public JsonResult ReportProposal(int year)
{
    string Userkey = "gHeOai6bFzWskyUxX2ivq4+pJ7ALwbzwF55dZvy/23BrHAfvDVj7mg  ";
    string PassKey = "lLAHwegN8zdS7mIZyZZj+EmzlkUXkvEYxLvgAYjuBVtU8sw6wKXy2g  ";

    JsonResult result = new JsonResult();
    MemoryStream oStream;

    PCSO_ProposedSeminars rpt = new PCSO_ProposedSeminars();
    dsPCSO_TrainingProgram ds = new dsPCSO_TrainingProgram();

    //-----------------------------------------------------
    var seminars = db.Certificates
            .Where(x => x.Year.Value.Year == year && !x.IsApproved.HasValue)
            .Select(z => z).Distinct();

    foreach (var train in seminars)
    {
             string trainingProgram = train.CertificateName;
             string resourcePerson = train.ResourceSpeaker;
             string target = "";

             var classifications = db.CertificateTrainingClassifications.Where(a => a.CertificateId == train.CertificateId).Select(b=>b.TrainingClassification.Classification);

             int x = 1;

             foreach (var classification in classifications)
             {
                 if (classifications.Count() > 1)
                 {
                     if (x == 1) target += classification;
                     else target +=  ", " + classification;
                 }
                 else target += classification;

                 x++;
             }

             if (train.TargetParticipants.HasValue)
             {
                 target += "/" + train.TargetParticipants.Value + ((train.TargetParticipants != null) ? " pax" : "");
             }

             if (train.IsPerBatch.Value)
             {
                 target += "/batch";
             }

             string duration = train.Duration.Value + " days";
             decimal estimatedExpenses = new decimal();
             estimatedExpenses = train.EstimatedExpenses.Value;

             ds.dt_ProposedSeminars.Adddt_ProposedSeminarsRow(
                     trainingProgram,
                     resourcePerson,
                     target,
                     duration,
                     estimatedExpenses);
        }

        DataTable dtable = new DataTable();
        dtable = ds.dt_ProposedSeminars;

        rpt.SetDataSource(dtable);
        rpt.Refresh();
        rpt.SetParameterValue(0, year);
        rpt.SetParameterValue(1, "");
        rpt.SetParameterValue(2, "Head, Training Unit, Admin Department");

        oStream = (MemoryStream)rpt.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);

        string filename = Convert.ToString((DateTime.Now.Month) + Convert.ToString(DateTime.Now.Day) + Convert.ToString(DateTime.Now.Year) + Convert.ToString(DateTime.Now.Hour) + Convert.ToString(DateTime.Now.Minute) + Convert.ToString(DateTime.Now.Second) + Convert.ToString(DateTime.Now.Millisecond)) + "RequestApplication";
        var len = oStream.Length;

        FileTransferServiceClient client2 = new FileTransferServiceClient();
        RemoteFileInfo rmi = new RemoteFileInfo();
        DateTime dt = DateTime.Now;

        DownloadRequest dr = new DownloadRequest();
        string fId = client2.UploadFileGetId("", filename, len, PassKey, Userkey, oStream);
        result.Data = new
         {
             fileId = fId,
             filename = filename
         };
        rpt.Close();
        rpt.Dispose();

        oStream.Close();
        oStream.Dispose();

        result.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
        return result;
    }

以下是截图:

这是错误。

  

'PIMS_Reports.TrainingProgram.dsPCSO_TrainingProgram'不包含'dt_ProposedSeminars'的定义,也没有扩展方法'dt_ProposedSeminars'接受第一个类型的争论

     找不到'PIMS_Reports.TrainingProgram.dsPCSO_TrainingProgram'(您是否缺少using指令汇编参考?)

1 个答案:

答案 0 :(得分:-1)

错误消息指出您的dsPCSO_TrainingProgram类不包含名为dt_PropsedSeminars的方法或属性。

这堂课是什么样的?