public StudentsGroupsManagementWindow(studentsgroup s) { InitializeComponent(); cur = s; Title = "Изменить группу"; NameTextBox.Text = s.Name; CourseTextBox.Text = s.Course.ToString(); DateInPicker.SelectedDate = s.DateIn; DateOutPicker.SelectedDate = s.DateOut; InitFaculties(); int idx = FacultiesComboBox.Items.IndexOf(s.department.faculty.Name); if (idx >= 0) FacultiesComboBox.SelectedIndex = idx; idx = DepartmentsComboBox.Items.IndexOf(s.department.Name); if (idx >= 0) DepartmentsComboBox.SelectedIndex = idx; SubjectList = (DBCollection)Resources["SubjectList"]; try { List<dynamic> lst = DBModel.Instance.GetSubjectsByGroupDynamic(cur.Name); foreach (var i in lst) SubjectList.Add(i); } catch (DBException ex) { Message.Show(ex.Message, MessageTypes.Error); } IsEdit = true; }
private async Task <bool> CopyEntriesToDay(DBCollection collection, DateTime targetDay) { if (collection.Count == 0) { return(false); } var newCollection = new DBCollection(new DataTree(collection.Name)); var somethingFiltered = false; foreach (DBDocument doc in collection) { // Remove id to make as new doc[DBDocument.Id].Remove(); // Remove timestamps, they will be applied automatically based on date doc["starttimestamp"].Remove(); doc["endtimestamp"].Remove(); // Remove approval and export data. All pasted entries must be approved again. doc["approvedbymanager"] = false; doc["approvedbyworker"] = false; doc["exported_ax"] = false; doc["exportfailurecount_ax"] = 0; doc["exporttimestamp_ax"].Remove(); doc["exported_visma"] = false; doc["exporttimestamp_visma"].Remove(); // Set target date doc["date"] = targetDay; bool filtered = false; if (!doc["project"].Empty) { var project = DBDocument.FindOne("project", doc["project"][DBDocument.Id]); if (project != null && project["status"] == "Done") { filtered = true; somethingFiltered = true; } } if (!filtered) { newCollection.Add(doc); } } await newCollection.UpdateDatabaseAsync(new DBCallProperties() { RunWithPrivileges = 5 }); return(somethingFiltered); }
public TeachersManagementWindow(dynamic teacher) { InitializeComponent(); curTeacher = teacher; Title = "Изменить преподавателя"; PControl.SetPerson(curTeacher.person); SubjectsList = (DBCollection)Resources["SubjectsList"]; DepartmentsList = (DBCollection)Resources["DepartmentsList"]; List<dynamic> lst = DBModel.Instance.GetSubjectsByTeacher(curTeacher); foreach (var i in lst) SubjectsList.Add(i); lst = DBModel.Instance.GetDepartmentsByTeacher(curTeacher); foreach (var i in lst) DepartmentsList.Add(i); IsEdit = true; }