private void btnSaveAndClose_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { OnOkButton(); if (scheduleId.Text.Trim() == "0") { ScheduleServices scheduleServices = new ScheduleServices(); String[] listDepartment = checkedComboBoxEditDepartments.EditValue.ToString().Split(','); for (int i = 0; i < listDepartment.Length; i++) { if (listDepartment[i].Trim() != "") { ScheduleDepartment schedule = new ScheduleDepartment(); schedule.idSchedule = scheduleServices.getLastScheduleId(); schedule.idDepartment = Int32.Parse(listDepartment[i]); scheduleServices.createScheduleForDepartment(schedule); } } String[] listPosition = checkedComboBoxEditPosition.EditValue.ToString().Split(','); for (int i = 0; i < listPosition.Length; i++) { if (listPosition[i].Trim() != "") { SchedulePosition schedule = new SchedulePosition(); schedule.idPosition = Int32.Parse(listPosition[i]); schedule.idSchedule = scheduleServices.getLastScheduleId(); scheduleServices.createSchedulePosition(schedule); } } } }
public void AddScheduleForDepartment(ScheduleDepartment scheduleDepartment) { db = new LinQDataContext(); ScheduleDepartment schedule = new ScheduleDepartment(); schedule = scheduleDepartment; db.ScheduleDepartments.InsertOnSubmit(schedule); db.SubmitChanges(); }
public void deleteSchdeduleDepartment(ScheduleDepartment scheduleDepartment) { db = new LinQDataContext(); ScheduleDepartment sch = new ScheduleDepartment(); sch = db.ScheduleDepartments.FirstOrDefault(x => x.idSchedule == scheduleDepartment.idSchedule && x.idDepartment == scheduleDepartment.idDepartment); if (sch != null) { db.ScheduleDepartments.DeleteOnSubmit(sch); db.SubmitChanges(); } }
private void schedulerDataStorage_AppointmentsDeleted(object sender, PersistentObjectsEventArgs e) { ScheduleServices scheduleServices = new ScheduleServices(); for (int i = 0; i < schedulerControl1.SelectedAppointments.Count; i++) { Appointment apt = schedulerControl1.SelectedAppointments[i]; if (apt.CustomFields["UniqueID"] != null && apt.CustomFields["DepartmentsList"] != null) { int idSchedule = Int32.Parse(apt.CustomFields["UniqueID"].ToString()); String[] listDepartment = apt.CustomFields["DepartmentsList"].ToString().Split(','); for (int j = 0; j < listDepartment.Length; j++) { if (listDepartment[j].Trim() != "") { ScheduleDepartment scheduleDepartment = new ScheduleDepartment(); scheduleDepartment.idSchedule = idSchedule; scheduleDepartment.idDepartment = Int32.Parse(listDepartment[j]); //MessageBox.Show(scheduleDepartment.idSchedule + "--" + scheduleDepartment.idDepartment); scheduleServices.deleteScheduleDepartment(scheduleDepartment); } } String[] listPosition = apt.CustomFields["PositionList"].ToString().Split(','); for (int k = 0; k < listPosition.Length; k++) { if (listPosition[i].Trim() != "") { SchedulePosition schedule = new SchedulePosition(); schedule.idPosition = Int32.Parse(listPosition[k]); //MessageBox.Show(scheduleServices.getLastScheduleId().ToString()); schedule.idSchedule = idSchedule; scheduleServices.deleteSchedulePosition(schedule); } } } } scheduleTableAdapter.Update(giaDinhUniversityDataSet); giaDinhUniversityDataSet.AcceptChanges(); }
public void deleteScheduleDepartment(ScheduleDepartment scheduleDepartment) { scheduleDepartmentDao.deleteSchdeduleDepartment(scheduleDepartment); }
public void createScheduleForDepartment(ScheduleDepartment schedule) { scheduleDepartmentDao.AddScheduleForDepartment(schedule); }
public virtual bool SaveFormData(Appointment appointment) { ScheduleServices scheduleServices = new ScheduleServices(); appointment.CustomFields["ApprovalStatus"] = comboBoxEditApprovalStatus.SelectedItem.ToString(); appointment.CustomFields["DepartmentsList"] = checkedComboBoxEditDepartments.EditValue.ToString(); //MessageBox.Show("--->"+ checkedComboBoxEditDepartments.EditValue.ToString()); appointment.CustomFields["PositionList"] = checkedComboBoxEditPosition.EditValue.ToString(); if (scheduleId.Text.Trim() == "0") { //MessageBox.Show("Them moi"); //MessageBox.Show(scheduleServices.getLastScheduleId().ToString()); /* * String[] listDepartment = checkedComboBoxEditDepartments.EditValue.ToString().Split(','); * for (int i = 0; i < listDepartment.Length; i++) * { * MessageBox.Show(listDepartment[i]); * ScheduleDepartment schedule = new ScheduleDepartment(); * schedule.idSchedule = scheduleServices.getLastScheduleId(); * schedule.idDepartment = Int32.Parse(listDepartment[i]); * scheduleServices.createScheduleForDepartment(schedule); * }*/ } else { if (schedulePositionTemp.Text.Trim() == "nothing") { String[] listPosition = checkedComboBoxEditPosition.EditValue.ToString().Split(','); for (int i = 0; i < listPosition.Length; i++) { if (listPosition[i].Trim() != "") { //MessageBox.Show("--->+"+ listPosition[i]); SchedulePosition schedule = new SchedulePosition(); schedule.idPosition = Int32.Parse(listPosition[i]); schedule.idSchedule = Int32.Parse(scheduleId.Text); scheduleServices.createSchedulePosition(schedule); } } } else { String[] listPosition = checkedComboBoxEditPosition.EditValue.ToString().Split(','); String[] listpositionTemp = schedulePositionTemp.Text.Split(','); List <string> listChoose = new List <string>(listPosition); List <string> listTemp = new List <string>(listpositionTemp); List <string> listDelete = new List <string>(listpositionTemp); List <string> listInsert = new List <string>(listPosition); listChoose.ForEach(y => { listTemp.ForEach(x => { if (y.Trim() == x.Trim()) { listInsert.Remove(y); listDelete.Remove(x); } }); }); listDelete.ForEach(x => { if (x.Trim() != "") { SchedulePosition schedule = new SchedulePosition(); schedule.idSchedule = Int32.Parse(scheduleId.Text); schedule.idPosition = Int32.Parse(x); scheduleServices.deleteSchedulePosition(schedule); } }); listInsert.ForEach(x => { SchedulePosition schedule = new SchedulePosition(); schedule.idSchedule = Int32.Parse(scheduleId.Text); schedule.idPosition = Int32.Parse(x); scheduleServices.createSchedulePosition(schedule); }); } if (scheduleDepartmentTemp.Text.Trim() == "nothing") { String[] listDepartment = checkedComboBoxEditDepartments.EditValue.ToString().Split(','); for (int i = 0; i < listDepartment.Length; i++) { if (listDepartment[i].Trim() != "") { ScheduleDepartment schedule = new ScheduleDepartment(); schedule.idSchedule = Int32.Parse(scheduleId.Text); schedule.idDepartment = Int32.Parse(listDepartment[i]); scheduleServices.createScheduleForDepartment(schedule); } } } else { String[] listDepartment = checkedComboBoxEditDepartments.EditValue.ToString().Split(','); String[] listDepartmentTemp = scheduleDepartmentTemp.Text.Split(','); List <string> listChoose = new List <string>(listDepartment); List <string> listTemp = new List <string>(listDepartmentTemp); List <string> listDelete = new List <string>(listDepartmentTemp); List <string> listInsert = new List <string>(listDepartment); listChoose.ForEach(y => { listTemp.ForEach(x => { if (y.Trim() == x.Trim()) { listInsert.Remove(y); listDelete.Remove(x); } }); }); listDelete.ForEach(x => { if (x.Trim() != "") { ScheduleDepartment schedule = new ScheduleDepartment(); schedule.idSchedule = Int32.Parse(scheduleId.Text); schedule.idDepartment = Int32.Parse(x); scheduleServices.deleteScheduleDepartment(schedule); } }); listInsert.ForEach(x => { if (x.Trim() != "") { ScheduleDepartment schedule = new ScheduleDepartment(); schedule.idSchedule = Int32.Parse(scheduleId.Text); schedule.idDepartment = Int32.Parse(x); scheduleServices.createScheduleForDepartment(schedule); } }); } } return(true); }