public ClassSection ClassSection(Guid id) { try { var result = _classDataAccess.ClassSection(id); if (result != null) { var returnValue = new ClassSection { Id = result.Id, ClassId = result.ClassId, Class = result.Class.Name, SectionId = result.SectionId, Section = result.Section.Name, StatusId = result.StatusId, Status = result.Status.Name }; return(returnValue); } else { return(null); } } catch (Exception ex) { throw ex; } }
private void Write(ClassSection cs) { sb.AppendLine($"[{cs.Type} section]") .AppendLine($"\tname = {cs.Name}") .AppendLine($"\tspecies = {cs.Id:x}"); for (int i = 0; i < cs.Selectors.Length; i++) { var s = cs.Selectors[i]; sb.AppendLine($"{s.Address:x4}: sel[{i}] = {s}"); } if (cs.Type == SectionType.Class) { sb.AppendLine(); for (int i = 0; i < cs.Varselectors.Length; i++) { sb.AppendLine($"\tvarsel[{i}] = {cs.Varselectors[i]:x4}\t"); } } if (cs.FuncNames.Length > 0) { sb.AppendLine(); for (int i = 0; i < cs.FuncNames.Length; i++) { sb.AppendLine($"\tfunc[{i}] = {cs.Package.GetName(cs.FuncNames[i])} {cs.FuncCode[i]:x4}"); } } }
public async Task <IActionResult> EditClassSection(AssignSectionViewModel objClassSection) { if (ModelState.IsValid) { ClassSection objAssignSection = await _AssignSectionRepository.GetClassSectionById(objClassSection.ClassSection_Id); objAssignSection.Class_Id = objClassSection.Class_Id; objAssignSection.Section_Id = objClassSection.Section_Id; int result = await _AssignSectionRepository.UpdateClassSection(objAssignSection); if (result == 1) { TempData["Success"] = "Class Section Updted Successfully"; return(RedirectToAction("Index", "assignSection", new { area = "admin" })); } else { TempData["Error"] = "Updting Class Section Failed"; return(RedirectToAction("Index", "assignSection", new { area = "admin" })); } } return(View()); }
private void Bind_DropDown_Controls() { classSection = new ClassSection(); listSection = classSection.GetSectionDetails(); classType = new ClassType(); listClass = classType.GetClassDetails(); if (listSection != null) { listSection.Add(new ClassSectionModel { ClassSectionID = 0, SectionName = "Select" }); ddlSection.DataSource = listSection.OrderBy(x => x.ClassSectionID).ToList(); ddlSection.DisplayMember = "SectionName"; ddlSection.ValueMember = "ClassSectionID"; } if (listClass != null) { listClass.Add(new ClassTypeModel { ClassID = 0, ClassName = "Select", Active = true }); ddlClass.DataSource = listClass.OrderBy(x => x.ClassID).ToList(); ddlClass.DisplayMember = "ClassName"; ddlClass.ValueMember = "ClassID"; } }
private void BindConrols() { _classType = new ClassType(); _classSection = new ClassSection(); _listClassType = _classType.GetClassDetails(); _listSectionType = _classSection.GetSectionDetails(); if (_listClassType == null) { _listClassType = new List <ClassTypeModel>(); } _listClassType.Add(new ClassTypeModel { ClassID = 0, ClassName = "Select" }); ddlClass.DataSource = _listClassType.OrderBy(x => x.ClassID).ToList(); ddlClass.DisplayMember = "ClassName"; ddlClass.ValueMember = "ClassID"; if (_listSectionType == null) { _listSectionType = new List <ClassSectionModel>(); } _listSectionType.Add(new ClassSectionModel { ClassSectionID = 0, SectionName = "Select" }); ddlSection.DataSource = _listSectionType.OrderBy(x => x.ClassSectionID).ToList(); ddlSection.DisplayMember = "SectionName"; ddlSection.ValueMember = "ClassSectionID"; }
public async Task <IActionResult> AddClassSection(AssignSectionViewModel objClassSection) { if (ModelState.IsValid) { ClassSection newClassSection = new ClassSection { Class_Id = objClassSection.Class_Id, Section_Id = objClassSection.Section_Id }; int result = await _AssignSectionRepository.AddClassSection(newClassSection); if (result == 1) { TempData["Success"] = "Assign Section To Class Successfully"; return(RedirectToAction("Index", "assignSection", new { area = "admin" })); } else { TempData["Error"] = "Assign Section To Class Failed"; return(RedirectToAction("Index", "assignSection", new { area = "admin" })); } } return(View()); }
public ActionResult Create([Bind(Include = "ClassSectionId,ClassId,SectionId")] ClassSection classsection) { try { var isFound = db.ClassSections.Where(i => i.ClassId == classsection.ClassId && i.SectionId == classsection.SectionId).ToList(); if (isFound.Count > 0) { ModelState.AddModelError("", "Sorry this section already exist in this class"); } if (ModelState.IsValid) { db.ClassSections.Add(classsection); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ClassId = new SelectList(db.Class, "ClassId", "ClassName", classsection.ClassId); ViewBag.SectionId = new SelectList(db.Section, "SectionId", "SectionName", classsection.SectionId); return(View(classsection)); } catch (Exception e) { ViewBag.ERROR = e.Message.ToString(); return(View("ErrorPage")); } }
private void WriteClass(ClassSection s) { sb.AppendFormat("// {0:x4}", s.Address + 2).AppendLine(); var super = s.SuperClass; sb.AppendFormat("({0} {1} of {2}", s.Type == SectionType.Class ? "class" : "instance", s.Name, super != null ? super.Name : "").AppendLine(); sb.AppendLine(" (properties"); var pack = s.Package; for (int i = 4; i < s.Selectors.Length; i++) { if (i < s.Varselectors.Length) { sb.AppendFormat(" {0} {1:x}", pack.GetName(s.Varselectors[i]), s.Selectors[i]).AppendLine(); } else { sb.AppendFormat(" !!out of range!! {0:x}", s.Selectors[i]).AppendLine(); } } sb.AppendLine(" )"); for (int i = 0; i < s.FuncNames.Length; i++) { sb.AppendLine($" (method ({pack.GetName(s.FuncNames[i])}) // method_{s.FuncCode[i].TargetOffset:x4}"); Code code = s.Script.GetElement(s.FuncCode[i].TargetOffset) as Code; while (code != null) { if (code.XRefs.Any(r => !(r is FuncRef))) { sb.AppendLine($" {code.Label}"); } sb.AppendLine($" {code.Address:x4}:{code.Type:x2} {ArgsHexToString(code),-13} {code.Name,5} {ArgsToString(code)}"); if (code.IsReturn) { break; } if (code.IsCall) { sb.AppendLine(); } code = code.Next; } sb.AppendLine(" )"); } sb.AppendLine(")"); sb.AppendLine(); }
public ActionResult DeleteConfirmed(int id) { ClassSection classSection = db.Sections.Find(id); db.Sections.Remove(classSection); db.SaveChanges(); return(RedirectToAction("Index")); }
public int AddClassSection(ClassSection clsection) { try { _dbContext.ClassSection.Add(clsection); return(_dbContext.SaveChanges()); } catch (Exception ex) { throw ex; } }
public int DeleteClassSection(ClassSection classSection) { try { _dbContext.ClassSection.Add(classSection); _dbContext.Entry(classSection).State = EntityState.Modified; return(_dbContext.SaveChanges()); } catch (Exception ex) { throw ex; } }
public IActionResult DeleteClassSection([FromBody] ClassSection classSection) { try { var result = false; result = _classBusiness.DeleteClassSection(classSection.Id); return(Ok(result)); } catch (Exception ex) { return(BadRequest(ex)); } }
// GET: ClassSections/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ClassSection classSection = db.Sections.Find(id); if (classSection == null) { return(HttpNotFound()); } return(View(classSection)); }
public ActionResult Create([Bind(Include = "ID,SectionTitle,ClassName,StartingRegistrationNumber,EndingRegistrationNumber,SchoolID,CourseID")] ClassSection classSection) { if (ModelState.IsValid) { string id = User.Identity.GetUserId(); ClassForStudents classname = db.Classes.Single(d => d.Name.Equals(classSection.ClassName)); classSection.CourseID = classname.ID; classSection.SchoolID = id; db.Sections.Add(classSection); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(classSection)); }
public ActionResult DeleteConfirmed(int id) { try { ClassSection classsection = db.ClassSections.Find(id); db.ClassSections.Remove(classsection); db.SaveChanges(); return(RedirectToAction("Index")); } catch (Exception e) { ViewBag.ERROR = e.Message.ToString(); return(View("ErrorPage")); } }
public async Task <int> AddClassSection(ClassSection objClassSection) { try { await _lmsDbContext.ClassSection.AddAsync(objClassSection); await _lmsDbContext.SaveChangesAsync(); return(1); } catch (Exception ex) { return(-1); } }
public bool AddClassSection(ClassSection classSec) { var clSec = _db.ClassSections.Add(classSec); try { _db.SaveChanges(); } catch (Exception ex) { Console.WriteLine(ex.Message); return(false); } return(true); }
// GET: ClassSections/Edit/5 public ActionResult Edit(int?id) { string idd = User.Identity.GetUserId(); ViewBag.Courses = new SelectList(db.Classes.Where(d => d.SchoolID.Equals(idd)).ToList(), "Name", "Name"); if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ClassSection classSection = db.Sections.Find(id); if (classSection == null) { return(HttpNotFound()); } return(View(classSection)); }
private void BindDropDownControls() { fineSettings = new FineSettings(); listFineType = fineSettings.GetFineType(); classSection = new ClassSection(); listSection = classSection.GetSectionDetails(); classType = new ClassType(); listClass = classType.GetClassDetails(); if (listSection != null) { listSection.Add(new ClassSectionModel { ClassSectionID = 0, SectionName = "Select" }); ddlCurrentSection.DataSource = listSection.OrderBy(x => x.ClassSectionID).ToList(); ddlCurrentSection.DisplayMember = "SectionName"; ddlCurrentSection.ValueMember = "ClassSectionID"; } if (listFineType != null) { listFineType.Add(new FineTypeModel { FineTypeID = 0, FineType = "Select" }); ddlFeeType.DataSource = listFineType.OrderBy(x => x.FineTypeID).ToList(); ddlFeeType.DisplayMember = "FineType"; ddlFeeType.ValueMember = "FineTypeID"; } if (listClass != null) { listClass.Add(new ClassTypeModel { ClassID = 0, ClassName = "Select", Active = true }); ddlCurrentClass.DataSource = listClass.OrderBy(x => x.ClassID).ToList(); ddlCurrentClass.DisplayMember = "ClassName"; ddlCurrentClass.ValueMember = "ClassID"; } datePickerReport.Format = DateTimePickerFormat.Custom; datePickerReport.Value = DateTime.Now; datePickerReport.CustomFormat = "dd.MM.yyyy"; }
public string Promot(string PromotList, int PromotTo, int PromotToSec) { int counter = 0, total = 0; string[] values = PromotList.Split(','); for (int i = 0; i < values.Length; i++) { values[i] = values[i].Trim(); int id = int.Parse(values[i].ToString()); var st = db.Student.Single(kk => kk.StudentId == id); var PTO = db.ClassSections.Include(c => c.Class).Include(s => s.Section).Where(pto => pto.Class.ClassId == PromotTo && pto.Section.SectionId == PromotToSec).ToList(); ClassSection cs = new ClassSection(); cs = PTO[0]; if (st.Update == false && st.Closed == false) { st.ClassSection = cs; st.Update = true; db.Entry(st).State = EntityState.Modified; db.SaveChanges(); counter++; } total++; } int NotPromoted = total - counter; if (counter > 0) { return(counter + " Students of " + total + " could promoted successfully\n" + NotPromoted + "Students are already promoted "); } else { return("No one student could promoted\nif you want to do so, then first done prmotions then promot them again"); } }
private void buttonUpdate_Click(object sender, EventArgs e) { var data = (ClassSectionViewModel)dataGridViewSection.SelectedRows[0].DataBoundItem; if (textBoxSection.Text == "") { ProcessInvalid(labelSection); MessageBox.Show("Section field can't be empty", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (comboBoxTeacher.Text == "--Select--") { ProcessInvalid(labelTeacher); MessageBox.Show("Must Select a Class Teacher", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (CheckSectionExistsForUpdate(textBoxSection.Text, data.ClassSectionId)) { ProcessInvalid(labelSection); MessageBox.Show("Section already exists", "", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { var section = new ClassSection { ClassId = selectClassId, ClassSectionId = data.ClassSectionId, SectionName = textBoxSection.Text, IsActive = checkBoxIsActive.Checked, ClassTeacherId = (int)comboBoxTeacher.SelectedValue }; if (_settingService.UpdateSection(section)) { gridViewSelectedId = section.ClassSectionId.ToString(); LoadDataSection(_settingService.GetClassSectionList(selectClassId)); dataGridViewSection.Refresh(); ProcessValid(labelSection); ProcessValid(labelTeacher); MessageBox.Show("Data Updated Successfully!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Update failed", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
public bool UpdateSection(ClassSection classSection) { var cls = _db.ClassSections.First(x => x.ClassSectionId == classSection.ClassSectionId); cls.SectionName = classSection.SectionName; cls.IsActive = classSection.IsActive; cls.ClassTeacherId = classSection.ClassTeacherId; try { _db.SaveChanges(); } catch (Exception ex) { Console.WriteLine(ex.Message); return(false); } return(true); }
private void buttonAdd_Click(object sender, EventArgs e) { if (textBoxSection.Text == "") { ProcessInvalid(labelSection); MessageBox.Show("Section name can't be empty", "", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (comboBoxTeacher.Text == "--Select--") { ProcessInvalid(labelTeacher); MessageBox.Show("Must Select a Class Teacher", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (CheckSectionExists(textBoxSection.Text)) { ProcessInvalid(labelSection); MessageBox.Show("Section already exists", "", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { var classSec = new ClassSection { ClassId = selectClassId, SectionName = textBoxSection.Text, IsActive = checkBoxIsActive.Checked, ClassTeacherId = (int)comboBoxTeacher.SelectedValue }; if (_settingService.AddClassSection(classSec)) { MessageBox.Show("Data Saved Successfully!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); ProcessValid(labelSection); ProcessValid(labelTeacher); gridViewSelectedId = classSec.ClassSectionId.ToString(); LoadDataSection(_settingService.GetClassSectionList(classSec.ClassId)); dataGridViewSection.Refresh(); } else { MessageBox.Show("error"); } } }
// GET: /ClassSection/Delete/5 public ActionResult Delete(int?id) { try { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ClassSection classsection = db.ClassSections.Find(id); if (classsection == null) { return(HttpNotFound()); } return(View(classsection)); } catch (Exception e) { ViewBag.ERROR = e.Message.ToString(); return(View("ErrorPage")); } }
public bool AddClassSection(ClassSection classSection) { try { var clsection = new DbModel.ClassSection { Id = Guid.NewGuid(), ClassId = classSection.ClassId, SectionId = classSection.SectionId, StatusId = classSection.StatusId, CreatedDate = DateTime.UtcNow, CreatedBy = _username }; var result = _classDataAccess.AddClassSection(clsection); var returnValue = result > 0 ? true : false; return(returnValue); } catch (Exception ex) { throw ex; } }
// GET: /ClassSection/Edit/5 public ActionResult Edit(int?id) { try { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ClassSection classsection = db.ClassSections.Find(id); if (classsection == null) { return(HttpNotFound()); } ViewBag.ClassId = new SelectList(db.Class, "ClassId", "ClassName", classsection.ClassId); ViewBag.SectionId = new SelectList(db.Section, "SectionId", "SectionName", classsection.SectionId); return(View(classsection)); } catch (Exception e) { ViewBag.ERROR = e.Message.ToString(); return(View("ErrorPage")); } }
public async Task <ServiceResponse <object> > AddClassSectionMapping(ClassSectionDtoForAdd classSection) { try { var objToCreate = new ClassSection { ClassId = classSection.ClassId, SemesterId = classSection.SemesterId, SectionId = classSection.SectionId, SchoolBranchId = _LoggedIn_BranchID, NumberOfStudents = classSection.NumberOfStudents, Active = true, CreatedById = _LoggedIn_UserID, CreatedDatetime = DateTime.UtcNow }; await _context.ClassSections.AddAsync(objToCreate); await _context.SaveChangesAsync(); _serviceResponse.Success = true; _serviceResponse.Message = CustomMessage.Added; } catch (DbUpdateException ex) { if (ex.InnerException.Message.Contains("Cannot insert duplicate key row")) { _serviceResponse.Success = false; _serviceResponse.Message = CustomMessage.SqlDuplicateRecord; } else { throw ex; } } return(_serviceResponse); }
public void Add(ClassSection cs) { Classes.Add(cs); }
/// <summary> /// 更新 /// </summary> /// <param name="pathTime">时间表路径,文件夹</param> /// <param name="pathClass">课表路径,文件</param> /// <param name="changHeTime">长河时间</param> public static void Load(string pathTime, string pathClass) { //Console.WriteLine(); //Console.WriteLine("ChangHetime={0}", changHeTime); for (int i = 0; i < timeSections.Length; i++)//初始化 { timeSections[i] = new List <TimeSection>(); } for (int i = 0; i < classSection.GetLength(0); i++) { for (int j = 0; j < classSection.GetLength(1); j++) { classSection[i, j] = new ClassSection(); } } XElement ClassSection = XElement.Load(pathClass);//读取课表 foreach (var Sections in ClassSection.Elements()) { foreach (var Section in Sections.Elements()) { ClassSection classsection = new ClassSection { Name = Section.Attribute("Name").Value }; int week = int.Parse(Sections.Attribute("Week").Value); int @class = int.Parse(Section.Attribute("Class").Value); classSection[week, @class] = classsection; // Console.WriteLine(classSection[week].Count); // classSection[week][1] = classsection; // classSection[int.Parse(Sections.Attribute("Week").Value)][@class] = classsection; } } //for (int i = 0; i < classSection.GetLength(0); i++) //{ // for (int j = 0; j < classSection.GetLength(1); j++) // { // Console.WriteLine("i={0},j={1},Name={2}", i, j, classSection[i, j].Name); // } //} XElement TimeFile = XElement.Load(pathTime + "TimeFile.xml");//读取总起时间表,并解析时间段 foreach (var day in TimeFile.Elements()) { foreach (var File in day.Elements()) { LoadTimeSections(int.Parse(day.Attribute("week").Value), pathTime + File.Value); } } for (int i = 0; i < timeSections.Length; i++) { for (int j = 0; j < timeSections[i].Count; j++) { #region 计算结束时间 DateTime dt = DateTime.Now; DateTime st = timeSections[i][j].beginTime; timeSections[i][j].beginTime = new DateTime(dt.Year, dt.Month, dt.Day, st.Hour, st.Minute, st.Second); if (j < timeSections[i].Count - 1) { timeSections[i][j].endTime = timeSections[i][j + 1].beginTime; } else { timeSections[i][j].endTime = new DateTime(dt.Year, dt.Month, dt.Day).AddDays(1);//末尾,置为第二天00:00 } #endregion if (timeSections[i][j].Class >= 0) { classSection[i, timeSections[i][j].Class].EndTime = timeSections[i][j].endTime; } //Console.Write(timeSections[i][j].beginTime.ToString()); //Console.Write(" "); //Console.WriteLine(timeSections[i][j].endTime.ToString()); //Console.WriteLine(timeSections[i][j].ToString()); } } for (int i = 0; i < timeSections.Length; i++)//计算最后一节课的结束时间,辅助明日课表功能 { foreach (var item in timeSections[i]) { if (item.Class != -1) { LastClassEndTime[i] = item.endTime; } } } //foreach (var item in lastClassEndTime) //{ // Console.WriteLine(item); //} //Console.WriteLine(currentTimeSection.beginTime); //Console.WriteLine(currentTimeSection.endTime); //Console.WriteLine(); }
public void Add(ClassSection cs) { Sections.Add(cs); }