protected override void RefreshReport() { base.RefreshReport(); int CompanyId = int.Parse(Parameters.Find(p => p.Name == "CompanyId").Value); DateTime Date = DateTime.Parse(Parameters.Find(p => p.Name == "Date").Value); ReportParameter[] reportParam = new ReportParameter[1]; EBalanceSheetReportDS bsDataSource = new EBalanceSheetReportDS(); AssetTableAdapter assetAdapter = new AssetTableAdapter(); LiabilityTableAdapter liabilityAdapter = new LiabilityTableAdapter(); EquityTableAdapter equityAdapter = new EquityTableAdapter(); ECompanyDS companyDataSource = new ECompanyDS(); tblCompaniesTableAdapter companyAdapter = new tblCompaniesTableAdapter(); assetAdapter.Fill(bsDataSource.Asset, CompanyId, Date, 1); liabilityAdapter.Fill(bsDataSource.Liability, CompanyId, Date, 2); equityAdapter.Fill(bsDataSource.Equity, CompanyId, Date, 3); companyAdapter.Fill(companyDataSource.tblCompanies, CompanyId); reportViewer.Reset(); reportViewer.LocalReport.ReportPath = Properties.Settings.Default.ReportPath + "Balance Sheet.rdlc"; reportParam[0] = new ReportParameter("Date", Date.ToString("MM'/'dd'/'yyyy"), false); reportViewer.LocalReport.SetParameters(reportParam); reportViewer.LocalReport.DataSources.Add(new ReportDataSource("Asset", bsDataSource.Tables["Asset"])); reportViewer.LocalReport.DataSources.Add(new ReportDataSource("Liability", bsDataSource.Tables["Liability"])); reportViewer.LocalReport.DataSources.Add(new ReportDataSource("Equity", bsDataSource.Tables["Equity"])); reportViewer.LocalReport.DataSources.Add(new ReportDataSource("Company", companyDataSource.Tables["tblCompanies"])); reportViewer.RefreshReport(); }
public string updateKnowledgePoint(KnowledgePoint updatedKnowledgePoint) { KnowledgePointTableAdapter kpAdapter = new KnowledgePointTableAdapter(); //check knowledge point exist if (kpAdapter.GetKnowledgePointById(updatedKnowledgePoint.id).Count > 0) { int success = kpAdapter.UpdateKnowledgePoint(updatedKnowledgePoint.name, (int)(updatedKnowledgePoint.priority), updatedKnowledgePoint.posX, updatedKnowledgePoint.posY, Convert.ToDateTime(updatedKnowledgePoint.createDate), Convert.ToDateTime(updatedKnowledgePoint.modifiedDate), Convert.ToInt32(updatedKnowledgePoint.courseId), updatedKnowledgePoint.id); if (success == 0) { return "Failed in update the details"; } } else { //int success = kpAdapter.InsertNewKnowledgePoint(updatedKnowledgePoint.name, (int)updatedKnowledgePoint.priority, updatedKnowledgePoint.posX, updatedKnowledgePoint.posY, Convert.ToDateTime("1/1/1753 12:00:00"), Convert.ToDateTime("1/1/1753 12:00:00"), Convert.ToInt32(updatedKnowledgePoint.courseId)); int success = kpAdapter.InsertNewKnowledgePoint(updatedKnowledgePoint.name, (int)updatedKnowledgePoint.priority, updatedKnowledgePoint.posX, updatedKnowledgePoint.posY, Convert.ToDateTime(updatedKnowledgePoint.createDate), Convert.ToDateTime(updatedKnowledgePoint.modifiedDate), Convert.ToInt32(updatedKnowledgePoint.courseId)); if (success == 0) { return "Failed in add the details"; } } KnowledgePointParentChildRelationTableAdapter relationAdapter = new KnowledgePointParentChildRelationTableAdapter(); var updateTable = updatedKnowledgePoint.parentsKnowledgePointsId; relationAdapter.DeleteAllByChildId(updatedKnowledgePoint.id); for (int j = 0; j < updateTable.Count; j++) { relationAdapter.InsertNewRelation(updatedKnowledgePoint.id, updateTable[j]); } KnowledgePointAssetRelationTableAdapter assetAdapter = new KnowledgePointAssetRelationTableAdapter(); assetAdapter.DeleteRelationByKnowledgePointId(updatedKnowledgePoint.id); for (int j = 0; j < updatedKnowledgePoint.assets.Count; j++) { assetAdapter.InsertNewAssetRelation(updatedKnowledgePoint.id, updatedKnowledgePoint.assets[j].id, updatedKnowledgePoint.assets[j].start, updatedKnowledgePoint.assets[j].end); } AssetTableAdapter ata = new AssetTableAdapter(); for (int j = 0; j < updatedKnowledgePoint.messageBox.messageList.Count; j++) { assetAdapter.InsertNewAssetRelation(updatedKnowledgePoint.id, ata.GetIdByAssetName(updatedKnowledgePoint.messageBox.messageList[j].messageId.ToString())[0].Id, -1, -1); } return "Success"; }
public List<KnowledgePoint> GetKnowledgePointList(string courseCode, string CourseNumber) { List<KnowledgePoint> list = new List<KnowledgePoint>(); KnowledgePointTableAdapter kpAdapter = new KnowledgePointTableAdapter(); KnowledgePointParentChildRelationTableAdapter kpRelationAdatper = new KnowledgePointParentChildRelationTableAdapter(); KnowledgePointAssetRelationTableAdapter kpAssetAdapter = new KnowledgePointAssetRelationTableAdapter(); CourseTableAdapter courseAdapter = new CourseTableAdapter(); var courseIdList = courseAdapter.GetIdByCourseDetails(courseCode, Convert.ToInt32(CourseNumber)); int courseId = courseIdList[0].Id; PriorityTableAdapter priorityAdapter = new PriorityTableAdapter(); AssetTableAdapter assetAdapter = new AssetTableAdapter(); AssetTypeTableAdapter assetTypeAdapter = new AssetTypeTableAdapter(); foreach (var row in kpAdapter.GetKnowledgePointByCourseId(courseId)) { KnowledgePoint kp = new KnowledgePoint(row.Id, courseCode + CourseNumber, row.Name, row.xPos, row.yPos); kp.priority = (Priority)Enum.Parse(typeof(Priority), priorityAdapter.GetPriorityById(row.Priority)[0].Priority); kp.createDate = row.CreatedTime.ToString("G"); kp.modifiedDate = row.LastModifiedTime.ToString("G"); foreach (var relation in kpRelationAdatper.GetParentIdByChildId(row.Id)) { kp.addParent(relation.ParentKnowledgePointId); } foreach (var relatedAsset in kpAssetAdapter.GetAssetListByKnowledgePointId(row.Id)) { foreach (var assetPointer in assetAdapter.GetAssetDetailById(relatedAsset.AssetId)) { AssetType type = (AssetType)Enum.Parse(typeof(AssetType), assetTypeAdapter.GetDataById(assetPointer.AssetType)[0].AssetType); if (type == AssetType.PDF | type == AssetType.PPT | type == AssetType.Audio | type == AssetType.Video) { AssetPointer pointer = new AssetPointer(assetPointer.Id, assetPointer.Path + assetPointer.AssetName, type, relatedAsset.Start, relatedAsset.End); kp.addAsset(pointer); } else if (type == AssetType.SelfTest) { int selftestId = Convert.ToInt32(assetPointer.AssetName); SelfTestTableAdapter stAdapter = new SelfTestTableAdapter(); var st = stAdapter.GetSelfTestDataById(Convert.ToInt32(assetPointer.AssetName))[0]; SelfTestQuesion stQuestion = new SelfTestQuesion(st.Question, st.AnswerKey); kp.addTestQuestion(stQuestion); } else if (type == AssetType.QandA) { int messageId = Convert.ToInt32(assetPointer.AssetName); QandATableAdapter qaAdapter = new QandATableAdapter(); var qa = qaAdapter.GetQAsById(messageId)[0]; Message message = new Message(qa.Id, "user Id: " + qa.AskedBy, qa.Question); try { string answerTypeString = (new AnswerTypeTableAdapter()).GetDataById(qa.AnswerType)[0].AnswerType; Answer answer = new Answer(answerTypeString, qa.Answer); } catch { } finally { message.addAnswer(new Answer(AnswerType.NoAnswer, "")); } message.createTime = qa.CreatedTime.ToString("G"); kp.messageBox.lastModifiedDate = qa.CreatedTime.ToString("G"); kp.addMessage(message); } } } kp.createDate = row.CreatedTime.ToString("G"); kp.modifiedDate = row.LastModifiedTime.ToString("G"); list.Add(kp); } return list; }
public string insertNewMessage(string courseCode, string courseNumber, string userId, string message) { QandATableAdapter qaAdapter = new QandATableAdapter(); CourseTableAdapter courseAdapter = new CourseTableAdapter(); AssetTableAdapter assetAdapter = new AssetTableAdapter(); var table = courseAdapter.GetIdByCourseDetails(courseCode, Convert.ToInt32(courseNumber)); if (table.Count > 0) { qaAdapter.InsertNewQuestion(message, Convert.ToInt32(userId), null, null, DateTime.Now, null, Convert.ToInt32(table[0].Id)); var qaTable = qaAdapter.GetMessageListByCourseId(Convert.ToInt32(table[0].Id)); int qaID = qaTable[qaTable.Count-1].Id; assetAdapter.InsertAsset(qaID.ToString(), qaID.ToString(), 3104); return "success"; } return "failed"; }