public int DeleteStudent(StudentRecords record) { context.StudentRecords.Remove(record); var response = context.SaveChanges(); return(response); }
public int UpdateStudent(StudentRecords record) { context.Entry(record).State = EntityState.Modified; int response = context.SaveChanges(); return(response); }
public int AddStudent(StudentRecords record) { context.StudentRecords.Add(record); int response = context.SaveChanges(); return(response); }
public void RunTransactions() { // Execute PowerShell script that runs COBOL programs var psScript = new StringBuilder(); var path = @"C:\Users\ag4488\Documents\Visual Studio 2019\Projects\cobol-nodejs-data-hooks\cobol-os"; psScript.AppendLine($"$WorkingDir = \"{path}\""); //psScript.AppendLine("$CurrMasterDataFile = Join-Path $WorkingDir \"\\data\\students.dat\""); //psScript.AppendLine("$fileExist = Test-Path $CurrMasterDataFile"); //psScript.AppendLine("if ($fileExist) {Remove-Item $CurrMasterDataFile}"); //psScript.AppendLine("$OrigMasterDataFile = Join-Path $WorkingDir \"\\data\\students_orig.dat\""); //psScript.AppendLine("$DestinationFile = Join-Path $WorkingDir \"\\data\\students.dat\""); //psScript.AppendLine("Copy-Item $OrigMasterDataFile -Destination $DestinationFile"); psScript.AppendLine("$Executable = Join-Path $WorkingDir \"\\studentwrite.exe\""); psScript.AppendLine("& $Executable"); // remove students.dat file and rename students1.dat //psScript.AppendLine("Remove-Item $CurrMasterDataFile"); //psScript.AppendLine("$NewMasterDataFile = Join-Path $WorkingDir \"\\data\\students1.dat\""); //psScript.AppendLine("Rename-Item -Path $NewMasterDataFile -NewName \"students.dat\""); List <string> results = RunScript(psScript.ToString()); path = @"C:\Users\ag4488\Documents\Visual Studio 2019\Projects\cobol-nodejs-data-hooks\cobol-os\data\students1.dat"; var recs = new StudentRecords(path); var allrecs = recs.GetAllRecords(); Assert.IsTrue(allrecs.Count == 39); }
private void Dashboard_Load(object sender, EventArgs e) { var path = @"C:\Users\ag4488\Documents\Visual Studio 2019\Projects\cobol-nodejs-data-hooks\cobol-os\data\students.dat"; var recs = new StudentRecords(path); var allrecs = recs.GetAllRecords(); dgvStudentRecords.DataSource = null; //ds.Dispose(); ds = new DataSet(); ds.Tables.Add(); ds.Tables[0].Columns.Add("StudentId"); ds.Tables[0].Columns.Add("LastName"); ds.Tables[0].Columns.Add("Initials"); ds.Tables[0].Columns.Add("DOB"); ds.Tables[0].Columns.Add("PhoneNo"); ds.Tables[0].Columns.Add("ProgramCode"); ds.Tables[0].Columns.Add("Gender"); ds.Tables[0].Columns.Add("LoanAmount"); foreach (var rec in allrecs) { ds.Tables[0].Rows.Add(rec.StudentId, rec.LastName, rec.Initials, rec.DOB, rec.PhoneNo, rec.ProgramCode, rec.Gender, rec.LoanAmount); } ds.Tables[0].AcceptChanges(); dgvStudentRecords.DataSource = ds.Tables[0]; }
public override global::System.Data.DataSet Clone() { StudentRecords cln = ((StudentRecords)(base.Clone())); cln.InitVars(); cln.SchemaSerializationMode = this.SchemaSerializationMode; return(cln); }
public void ReadAllRecords() { var path = @"C:\Users\ag4488\Documents\Visual Studio 2019\Projects\cobol-nodejs-data-hooks\cobol-os\data\students.dat"; var recs = new StudentRecords(path); var allrecs = recs.GetAllRecords(); Assert.IsTrue(allrecs.Count > 0); }
public IActionResult UpdateStudentRecord(StudentRecords record) { if (!ModelState.IsValid) { return(BadRequest("Cannot save the changes!")); } var response = repo.UpdateStudent(record); return(Ok(response)); }
public IActionResult PostNewStudent(StudentRecords record) { if (!ModelState.IsValid) { return(BadRequest("Invalid Data")); } var response = repo.AddStudent(record); return(Ok(response)); }
private List <StudentData> GetStudentData(StudentRecords sRecords) { List <StudentData> sData = new List <StudentData>(); foreach (StudentRecord sRec in sRecords.GetRecordList()) { sData.Add(new StudentData(sRec.StudentId, sRec.StudentName)); } return(sData); }
public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs) { StudentRecords ds = new StudentRecords(); global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); global::System.Xml.Schema.XmlSchemaAny any = new global::System.Xml.Schema.XmlSchemaAny(); any.Namespace = ds.Namespace; sequence.Items.Add(any); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();) { schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte()));) { ; } if ((s1.Position == s1.Length)) { return(type); } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return(type); }
private void MainForm_Load(object sender, EventArgs e) { // prepare data // read the student record file // encode barcode for the id // set instruction text instrLabel1.Text = Strings.S.INSTR_LABEL1; instrLabel2.Text = Strings.S.INSTR_LABEL2; instrLabel3.Text = Strings.S.INSTR_LABEL3; instrLabel4.Text = Strings.S.INSTR_LABEL4; // set the group text selectionGroupBox.Text = Strings.S.GRP_HEADER; AllStudentsLabel.Text = Strings.S.ALL_STUDENTS; SelectedStudentsLabel.Text = Strings.S.SEL_STUDENTS; // set the time cursor Cursor.Current = Cursors.WaitCursor; // initialize the all student list box StudentRecords sRecords = StudentRecords.GetStudentRecords(); List <StudentData> sData = new List <StudentData>(); if (sRecords != null) { sData = GetStudentData(sRecords); } foreach (StudentData sD in sData) { this.allStudentsListBox.Items.Add(sD); } this.AllStudentsCountLabel.Text = Convert.ToString(allStudentsListBox.Items.Count); this.SelStudentsCountLabel.Text = Convert.ToString(selStudentsListBox.Items.Count); if (selStudentsListBox.Items.Count == 0) { okButton.Enabled = false; } else { okButton.Enabled = true; } Cursor.Current = Cursors.Default; }
private void bnRefreshData_Click(object sender, EventArgs e) { var path = @"C:\Users\ag4488\Documents\Visual Studio 2019\Projects\cobol-nodejs-data-hooks\cobol-os\data\students.dat"; var recs = new StudentRecords(path); var allrecs = recs.GetAllRecords(); ds.Tables[0].Rows.Clear(); foreach (var rec in allrecs) { ds.Tables[0].Rows.Add(rec.StudentId, rec.LastName, rec.Initials, rec.DOB, rec.PhoneNo, rec.ProgramCode, rec.Gender, rec.LoanAmount); } ds.Tables[0].AcceptChanges(); //dgvStudentRecords.DataSource = ds.Tables[0]; }
//Given FSID this will fetch all the current mark progress of said section public List<SectionRecords> Get_Section_Records(int id) { //return teacher_id.ToString(); List<SectionRecords> records = new List<SectionRecords>(); string query = "select MarksDistribution.MDID,MarksDistribution.Weigtage,MarksDistribution.TotalMarks,MarksDistribution.Title " + "from MarksDistribution,FacultySections " + "where MarksDistribution.FSID = FacultySections.FSID and MarksDistribution.FSID = " + id; string connectionString = ConfigurationManager.AppSettings["SqlDBConn"].ToString(); using (SqlConnection connection = new SqlConnection(connectionString)) { SqlCommand command = new SqlCommand(query, connection); command.Parameters.AddWithValue("@tPatSName", "Your-Parm-Value"); connection.Open(); SqlDataReader reader = command.ExecuteReader(); try { while (reader.Read()) { SectionRecords temp = new SectionRecords(); temp.weightage = reader.GetDouble(reader.GetOrdinal("Weigtage")); temp.MDID = reader.GetInt32(reader.GetOrdinal("MDID")); temp.totalmarks = reader.GetDouble(reader.GetOrdinal("TotalMarks")); temp.title_setter(reader.GetInt32(reader.GetOrdinal("Title"))); /*query= "Student.SName,Student.StudentID,MarksRecord.ObtainedMarks "+ "from MarksDistribution,MarksRecord,Student "+ "where MarksDistribution.MDID=MarksRecord.MDID and MarksRecord.StudentID=Student.StudentID and MarksDistribution.MDID="+temp.MDID; */ /*string connectionString2 = ConfigurationManager.AppSettings["SqlDBConn"].ToString(); using (SqlConnection connection2 = new SqlConnection(connectionString2)) { SqlCommand command2 = new SqlCommand(query, connection2); command2.Parameters.AddWithValue("@tPatSName", "Your-Parm-Value"); SqlDataReader reader2 = command2.ExecuteReader(); try { while (reader2.Read()) { StudentRecords temp2 = new StudentRecords(); temp2.ID = reader.GetInt32(reader.GetOrdinal("StudentID")); temp2.Name = reader.GetString(reader.GetOrdinal("SName")); temp2.obtained = reader.GetDouble(reader.GetOrdinal("ObtainedMarks")); temp.SRs.Add(temp2); } } finally { reader2.Close(); } }*/ records.Add(temp); } } finally { reader.Close(); } for(int i=0;i<records.Count;i++) { int count = 0; double max = 0,min= records[i].totalmarks, average=0;bool no_records_found = true; query = "Select Student.SName,Student.StudentID,MarksRecord.ObtainedMarks " + "from MarksDistribution,MarksRecord,Student " + "where MarksDistribution.MDID=MarksRecord.MDID and MarksRecord.StudentID=Student.StudentID and MarksDistribution.MDID=" + records[i].MDID; command = new SqlCommand(query, connection); command.Parameters.AddWithValue("@tPatSName", "Your-Parm-Value"); reader = command.ExecuteReader(); try { while(reader.Read()) { StudentRecords temp2 = new StudentRecords(); temp2.ID = reader.GetInt32(reader.GetOrdinal("StudentID")); temp2.Name = reader.GetString(reader.GetOrdinal("SName")); temp2.obtained = reader.GetDouble(reader.GetOrdinal("ObtainedMarks")); if (temp2.obtained > max) max = temp2.obtained; if (temp2.obtained < min) min = temp2.obtained; average += temp2.obtained; records[i].SRs.Add(temp2); count++; no_records_found = false; } if(no_records_found) { min = 0; average = 0; } } finally { reader.Close(); } records[i].max = max; records[i].min = min; records[i].average = average/count; } } SectionRecords.assign = 0; SectionRecords.quiz = 0; SectionRecords.pro = 0; SectionRecords.fyp = 0; SectionRecords.lab = 0; SectionRecords.pres = 0; return records; }
public StudentRecords GetById(int id) { StudentRecords record = context.StudentRecords.Find(id); return(record); }