void selectSemesterAcception_Accepting(object sender, DialogControllerAcceptingEventArgs e)
        {
            ObjectSpace objectSpace = Application.CreateObjectSpace();
            ListView lv = ((ListView)((WindowController)sender).Window.View);
            Semester semester = lv.SelectedObjects.Count == 0 ? null : lv.SelectedObjects[0] as Semester;
            GroupOperator classroomsOp = new GroupOperator(CriteriaOperator.Parse("1=0"));
            ContainsOperator biOperator;
            string strParse = "";
            if (semester != null)
            {

                foreach (StudentClass studentClass in View.SelectedObjects)
                {
                    Data.CreateStudentClassTimetableData(objectSpace, studentClass.ClassCode, semester.SemesterName);

                    biOperator = new ContainsOperator("StudentClasses", new BinaryOperator("ClassCode", studentClass.ClassCode));
                    classroomsOp = new GroupOperator(GroupOperatorType.Or, classroomsOp, biOperator);

                    strParse += (strParse == "" ? string.Format("ClassCode='{0}'", studentClass.ClassCode) :
                        string.Format(" or ClassCode='{0}'", studentClass.ClassCode));
                }

                ReportData reportData = objectSpace.FindObject<ReportData>(
                    new BinaryOperator("Name", "Lịch lớp biên chế"));

                ReportServiceController rsc = ((WindowController)sender).Frame.GetController<ReportServiceController>();
                rsc.ShowPreview((IReportData)reportData, CriteriaOperator.Parse(strParse)); //classroomsOp);
            }
        }
        void selectSemesterAcception_Accepting(object sender, DialogControllerAcceptingEventArgs e)
        {
            ObjectSpace      objectSpace  = Application.CreateObjectSpace();
            ListView         lv           = ((ListView)((WindowController)sender).Window.View);
            Semester         semester     = lv.SelectedObjects.Count == 0 ? null : lv.SelectedObjects[0] as Semester;
            GroupOperator    classroomsOp = new GroupOperator(CriteriaOperator.Parse("1=0"));
            ContainsOperator biOperator;
            string           strParse = "";

            if (semester != null)
            {
                foreach (Student student in View.SelectedObjects)
                {
                    Data.CreateStudentTimetableData(objectSpace, student.StudentCode, semester.SemesterName);

                    biOperator   = new ContainsOperator("Students", new BinaryOperator("StudentCode", student.StudentCode));
                    classroomsOp = new GroupOperator(GroupOperatorType.Or, classroomsOp, biOperator);

                    strParse += (strParse == "" ? string.Format("StudentCode='{0}'", student.StudentCode) :
                                 string.Format(" or StudentCode='{0}'", student.StudentCode));
                }

                ReportData reportData = objectSpace.FindObject <ReportData>(
                    new BinaryOperator("Name", "Lịch sinh viên"));

                ReportServiceController rsc = ((WindowController)sender).Frame.GetController <ReportServiceController>();
                rsc.ShowPreview((IReportData)reportData, CriteriaOperator.Parse(strParse)); //classroomsOp);
            }
        }
Exemplo n.º 3
0
 private void DialogController_Accepting(object sender, DialogControllerAcceptingEventArgs e)
 {
     if (View is DetailView && ((DetailView)View).ViewEditMode == ViewEditMode.View)
     {
         View.ObjectSpace.CommitChanges();
     }
 }
Exemplo n.º 4
0
        void selectSemesterAcception_Accepting(object sender, DialogControllerAcceptingEventArgs e)
        {
            //Dictionary<string, WeekReportData> dicTeacherPeriodData;
            //WeekReportData currentWeekData;
            ObjectSpace objectSpace = Application.CreateObjectSpace();
            ListView    lv          = ((ListView)((WindowController)sender).Window.View);
            Semester    semester    = lv.SelectedObjects.Count == 0 ? null : lv.SelectedObjects[0] as Semester;

            if (semester != null)
            {
                string strParse = "";
                foreach (Teacher teacher in View.SelectedObjects)
                {
                    Data.CreateTeacherTimetableData(objectSpace, teacher.TeacherCode, semester.SemesterName);



                    strParse += (strParse == "" ? string.Format("TeacherCode='{0}'", teacher.TeacherCode) :
                                 string.Format("or TeacherCode='{0}'", teacher.TeacherCode));
                }
                ReportData reportData = objectSpace.FindObject <ReportData>(
                    new BinaryOperator("Name", "Lịch giảng viên"));

                ReportServiceController rsc = ((WindowController)sender).Frame.GetController <ReportServiceController>();
                rsc.ShowPreview((IReportData)reportData, CriteriaOperator.Parse(strParse));
            }
        }
Exemplo n.º 5
0
        //void gridView_SelectionChanged(object sender, EventArgs e)
        //{
        //    if (SecuritySystem.CurrentUser is Student)
        //    {
        //        Student student = SecuritySystem.CurrentUser as Student;
        //        string currentClass = student.StudentClass.ClassCode;

        //        ASPxGridView gc = sender as ASPxGridView;

        //        List<Vacancy> tempList = new List<Vacancy>(listVacancies);

        //        List<object> listobj = gc.GetSelectedFieldValues(new string[] { "LessonCode" });
        //        ObjectSpace objectSpace = Application.CreateObjectSpace();

        //        Vacancy vc;
        //        string strFilter = "", strInclude = "";
        //        foreach (int strLessonCode in listobj)
        //        {
        //            Lesson lesson = objectSpace.FindObject<Lesson>(new BinaryOperator("LessonCode", strLessonCode));
        //            strInclude += String.Format("OR ([LessonCode]={0})", lesson.LessonCode);
        //            foreach (TkbSemester tkbsem in lesson.TKBSemesters)
        //            {
        //                vc = new Vacancy(tkbsem.Day, tkbsem.Period, tkbsem.Weeks, (tkbsem.Classroom == null ? "" : tkbsem.Classroom.ClassroomCode));
        //                tempList.Add(vc);
        //            }
        //        }
        //        if (strInclude != "")
        //            strInclude = String.Format("({0})", strInclude.Substring(3));

        //        if (listobj.Count > 0)
        //        {
        //            using (XPCollection xpLesson = new XPCollection(objectSpace.Session, typeof(Lesson)))
        //            {

        //                foreach (Lesson lesson in xpLesson)
        //                {
        //                    foreach (TkbSemester tkbsem in lesson.TKBSemesters)
        //                    {
        //                        vc = new Vacancy(tkbsem.Day, tkbsem.Period, tkbsem.Weeks, (tkbsem.Classroom == null ? "" : tkbsem.Classroom.ClassroomCode));
        //                        if (Utils.IsConfictTKB(tempList, vc))
        //                        {
        //                            strFilter += String.Format("AND ([LessonCode]<>{0})", lesson.LessonCode);
        //                            break;
        //                        }
        //                    }
        //                }
        //                if (strFilter != "")
        //                    strFilter = String.Format("({0})", strFilter.Substring(4));

        //            }
        //        }
        //        if (strInclude != "" && strFilter != "")
        //        {
        //            strFilter = String.Format("({0} OR {1})", strFilter, strInclude);
        //        }
        //        else if (strInclude != "")
        //        {
        //            strFilter = strInclude;

        //        }

        //        if (strFilter != "")
        //        {
        //            if (gc.FilterExpression.Contains("TkbLesson.ClassIDs"))
        //            {
        //                gc.FilterExpression = string.Format("([TkbLesson.ClassIDs] Like '%{0}%') AND {1}", currentClass, strFilter);
        //            }
        //            else
        //            {
        //                gc.FilterExpression = strFilter;
        //            }
        //        }

        //    }
        //}

        //void gridView_DataBound(object sender, EventArgs e)
        //{
        //    if (SecuritySystem.CurrentUser is Student)
        //    {
        //        Student student = SecuritySystem.CurrentUser as Student;
        //        string currentClass = student.StudentClass.ClassCode;
        //        ASPxGridView gc = sender as ASPxGridView;
        //        if (gc.FilterExpression == "")
        //            gc.FilterExpression = string.Format("[TkbLesson.ClassIDs] Like '%{0}%'", currentClass);
        //    }
        //}

        void selectAcception_AcceptingStudent(object sender, DialogControllerAcceptingEventArgs e)
        {
            if (SecuritySystem.CurrentUser is Student)
            {
                ObjectSpace objectSpace           = Application.CreateObjectSpace();
                DevExpress.ExpressApp.ListView lv = ((DevExpress.ExpressApp.ListView)((WindowController)sender).Window.View);
                if (SecuritySystem.CurrentUser is Student)
                {
                    objectSpace.Session.BeginTransaction();
                    Student student        = SecuritySystem.CurrentUser as Student;
                    Student currentStudent = objectSpace.FindObject <Student>(
                        new BinaryOperator("StudentCode", student.StudentCode));
                    Lesson curLesson;
                    foreach (Lesson lesson in lv.SelectedObjects)
                    {
                        curLesson = objectSpace.FindObject <Lesson>(
                            new BinaryOperator("Oid", lesson.Oid));
                        RegisterDetail regdetail = new RegisterDetail(objectSpace.Session)
                        {
                            Student       = currentStudent,
                            Lesson        = curLesson,
                            RegisterState = objectSpace.FindObject <RegisterState>(
                                new BinaryOperator("Code", "SELECTED")),
                            CheckState = objectSpace.FindObject <RegisterState>(
                                new BinaryOperator("Code", "NOTCHECKED"))
                        };
                    }
                    objectSpace.Session.CommitTransaction();
                    //               View.ObjectSpace.CommitChanges();
                    View.ObjectSpace.Refresh();
                }
            }
        }
        private void dc_Accepting(object sender, DialogControllerAcceptingEventArgs e)
        {
            var address  = e.AcceptActionArgs.CurrentObject as AddressSelector;
            var protocol = (sender as DialogController).Tag as ProtocolRecord;

            protocol.Value = address.ToString();

            ObjectSpace.SetModified(protocol);
        }
Exemplo n.º 7
0
        void dialogCotnroller_Accepting(object sender, DialogControllerAcceptingEventArgs e)
        {
            ViewFilterContainer currentViewFilterContainer = (ViewFilterContainer)e.AcceptActionArgs.CurrentObject;
            ListView            targetView = GetTargetView();

            ((IModelListViewAdditionalCriteria)targetView.Model).AdditionalCriteria = currentViewFilterContainer.Criteria;
            targetView.CollectionSource.Criteria["ByViewFilterObject"] = CriteriaEditorHelper.GetCriteriaOperator(currentViewFilterContainer.Criteria, currentViewFilterContainer.ObjectType, targetView.ObjectSpace);
            oldListView = null;
            ShowView(targetView, e.ShowViewParameters);
        }
        private void Controller_Accepting(object sender, DialogControllerAcceptingEventArgs e)
        {
            string reportContainerHandle = (string)((WindowController)sender).Tag;

            ((DialogController)sender).Accepting -= Controller_Accepting;

            ReportParametersObjectBase reportParametersObject = (ReportParametersObjectBase)e.AcceptActionArgs.CurrentObject;

            PrintReport(reportParametersObject);
        }
Exemplo n.º 9
0
        private void DialogController_Accepting(object sender, DialogControllerAcceptingEventArgs e)
        {
            var view            = ((DialogController)sender).Frame.View;
            var selectedObjects = (Rol)view.CurrentObject;
            var masterView      = (ListView)view.Tag;

            var persona = (Persona)((PropertyCollectionSource)masterView.CollectionSource).MasterObject;

            persona.Roles.Add(selectedObjects);
        }
        private void SavePasswordHistory(object sender, DialogControllerAcceptingEventArgs e)
        {
            IObjectSpace objectSpace = Application.CreateObjectSpace(typeof(PasswordHistory));

            PasswordHistory passwordHistory = objectSpace.CreateObject <PasswordHistory>();

            passwordHistory.ModificationDate = DateTime.Now;
            passwordHistory.UserId           = SecuritySystem.CurrentUserId.ToString();
            objectSpace.CommitChanges();

            //TODO: Yeli
            //Create a store procedure that check password caducity
        }
Exemplo n.º 11
0
        private void DialogController_Accepting(object sender, DialogControllerAcceptingEventArgs e)
        {
            var selectedObjects = e.AcceptActionArgs.SelectedObjects;
            var originante      = (BasicObject)((PropertyCollectionSource)View.CollectionSource).MasterObject;

            foreach (BasicObject selectedObject in selectedObjects)
            {
                var nuevoVinculo = ObjectSpace.CreateObject <Vinculo>();
                nuevoVinculo.Originante   = originante;
                nuevoVinculo.Destinatario = selectedObject;

                View.CollectionSource.Add(nuevoVinculo);
            }
        }
Exemplo n.º 12
0
        private void dialogController_Accepting(object sender, DialogControllerAcceptingEventArgs e)
        {
            var selectedObjects = e.AcceptActionArgs.SelectedObjects;
            var originante      = this.GetMasterObject <Persona>();

            foreach (Persona selectedObject in selectedObjects)
            {
                var nuevoVinculo = ObjectSpace.CreateObject <Relacion>();
                nuevoVinculo.PersonaVinculante = originante;
                nuevoVinculo.PersonaVinculado  = selectedObject;
                nuevoVinculo.RelacionTipo      = null;

                View.CollectionSource.Add(nuevoVinculo);
            }
        }
Exemplo n.º 13
0
        private async void DialogControllerImportarPlanilha_Accepting(object sender, DialogControllerAcceptingEventArgs e)
        {
            DataTableCollection dtcollectionImport = null;


            ((DialogController)sender).AcceptAction.Enabled["NoEnabled"] = false;
            //Necessário para não fechar a janela após a conclusão do processamento
            e.Cancel = true;
            e.AcceptActionArgs.Action.Caption = "Procesando";

            var          parametros = (ParametrosImportComponentEJunta)e.AcceptActionArgs.SelectedObjects[0];
            MemoryStream stream     = new MemoryStream();

            stream.Seek(0, SeekOrigin.Begin);

            var arquivo = parametros.Padrao;

            arquivo.SaveToStream(stream);

            stream.Seek(0, SeekOrigin.Begin);

            using (var excelReader = new ExcelDataReaderHelper.Excel.Reader(stream))
            {
                dtcollectionImport = excelReader.CreateDataTableCollection(false);
            }


            var import         = new ImportComponentEJunta(objectSpaceProvider, parametrosImportComponentEJunta);
            var progress       = new Progress <ImportProgressReport>(import.LogTrace);
            var simpleProgress = new Progress <string>();

            await Observable.Start(() => import.ImportarComponente(dtcollectionImport["Piece"], progress));

            parametros.ConcluidoComponente = true;

            await Observable.Start(() => import.ImportarJuntas(dtcollectionImport["Joints"], progress));

            parametros.ConcluidoJuntas = true;

            //var gerador = new Calculator.ProcessoLoteLPPM.GerarLoteLPPM(objectSpaceProvider);
            //await gerador.GerarLoteLPPMAsync(simpleProgress);
            //parametros.ConcluidoLoteLPPM = true;


            objectSpace.CommitChanges();
            e.AcceptActionArgs.Action.Caption = "Finalizado";
            ((DialogController)sender).AcceptAction.Enabled["NoEnabled"] = true;
        }
Exemplo n.º 14
0
        private void CPAResultItem_DialogController_Accepting(object sender, DialogControllerAcceptingEventArgs e)
        {
            var dir = ((PersonaDireccion)View.CurrentObject).Direccion;

            if (e.AcceptActionArgs.SelectedObjects.Count < 1)
            {
                return;
            }
            var selectedCPA = (CPA.CPAResultItem)e.AcceptActionArgs.SelectedObjects[0];
            var selectedLoc = (CPA.LocalidadResultItem)((DialogController)sender).Tag;

            dir.CodigoPostal  = selectedCPA.CPA;
            dir.Calle         = selectedCPA.Calle;
            dir.Localidad     = null;
            dir.LocalidadOtra = selectedLoc.Nombre;
        }
Exemplo n.º 15
0
        void dialogCotnroller_Accepting(object sender, DialogControllerAcceptingEventArgs e)
        {
            ViewFilterContainer currentViewFilterContainer = (ViewFilterContainer)e.AcceptActionArgs.CurrentObject;
            ListView            targetView = GetTargetView();

            ((IModelListViewAdditionalCriteria)targetView.Model).AdditionalCriteria = currentViewFilterContainer.Criteria;
            targetView.CollectionSource.Criteria["ByViewFilterObject"] = CriteriaEditorHelper.GetCriteriaOperator(currentViewFilterContainer.Criteria, currentViewFilterContainer.ObjectType, targetView.ObjectSpace);
            ShowViewParameters parameters = new ShowViewParameters(targetView);

            parameters.TargetWindow = TargetWindow.Current;
            parameters.Context      = TemplateContext.View;
            ShowViewSource source = new ShowViewSource(Frame, showNavigationItemController.ShowNavigationItemAction);

            Application.ShowViewStrategy.ShowView(parameters, source);
            oldListView = null;
        }
        private void DcOnAccepting(object sender, DialogControllerAcceptingEventArgs eventArgs)
        {
            var templateField = eventArgs.AcceptActionArgs.CurrentObject as TextTemplateEditParameters;

            if (templateField != null && templateField.EditTemplates != null)
            {
                var doctor = ObjectSpace.GetObject(SecuritySystem.CurrentUser as Doctor);
                if (doctor != null)
                {
                    // удаляем все шаблоны этого типа
                    doctor.DeleteTemplates(templateField.TemplateType);
                    // создаем новые
                    doctor.CreateTemplates(templateField.Text, templateField.TemplateType);
                    ObjectSpace.SetModified(templateField);
                }
            }
        }
        protected void dialogController_Accepting(object sender, DialogControllerAcceptingEventArgs e)
        {
            DialogController dialogController = (DialogController)sender;

            dialogController.Accepting -= dialogController_Accepting;
            string data = Convert.ToString(dialogController.Tag);
            ViewVariantParameterObject parameter = dialogController.Window.View.CurrentObject as ViewVariantParameterObject;

            if (data == STR_NewViewVariant_Id)
            {
                NewViewVariant(parameter);
            }
            else if (data == STR_EditViewVariant_Id)
            {
                EditViewVariant(parameter);
            }
        }
Exemplo n.º 18
0
        private async void DialogControllerImportarPlanilha_Accepting(object sender, DialogControllerAcceptingEventArgs e)
        {
            ((DialogController)sender).AcceptAction.Enabled["NoEnabled"] = false;

            //Necessário para não fechar a janela após a conclusão do processamento
            e.Cancel = true;
            e.AcceptActionArgs.Action.Caption = "Procesando";

            var          parametros = (ParametrosAtualizacaoTabelasAuxiliares)e.AcceptActionArgs.SelectedObjects[0];
            MemoryStream stream     = new MemoryStream();

            stream.Seek(0, SeekOrigin.Begin);

            var arquivo = parametros.Padrao;

            arquivo.SaveToStream(stream);

            stream.Seek(0, SeekOrigin.Begin);

            using (var excelReader = new ExcelDataReaderHelper.Excel.Reader(stream))
            {
                dtcollectionImport = excelReader.CreateDataTableCollection(false);
            }

            var itba     = new ImportTabelaAuxiliares(objectSpace, parametrosAtualizacaoTabelasAuxiliares);
            var progress = new Progress <ImportProgressReport>(itba.LogTrace);

            await Observable.Start(() => itba.ImportarDiametro(dtcollectionImport["TabDiametro"], progress));

            await Observable.Start(() => itba.ImportarSchedule(dtcollectionImport["Schedule"], progress));

            await Observable.Start(() => itba.ImportarPercInspecao(dtcollectionImport["PercInspecao"], progress));

            await Observable.Start(() => itba.ImportarProcessoSoldagem(dtcollectionImport["ProcessoSoldagem"], progress));

            await Observable.Start(() => itba.ImportarContrato(dtcollectionImport["Contrato"], progress));

            await Observable.Start(() => itba.ImportarEAP(dtcollectionImport["EAPPipe"], progress));

            objectSpace.CommitChanges();
            e.AcceptActionArgs.Action.Caption = "Finalizado";
            ((DialogController)sender).AcceptAction.Enabled["NoEnabled"] = true;
        }
Exemplo n.º 19
0
        void h_Accepting(object sender, DialogControllerAcceptingEventArgs e)
        {
            if (View.CurrentObject != null)
            {
                if (((Ogrenci)View.CurrentObject).Belgeler.Count > 0)
                {
                    XPCollection <Belgeler> OgrenciBelgeleri = new XPCollection <Belgeler>(((XPObjectSpace)View.ObjectSpace).Session, ((Ogrenci)View.CurrentObject).Belgeler);
                    for (int i = OgrenciBelgeleri.Count; i > 0; i--)
                    {
                        if (OgrenciBelgeleri[i - 1].Dosya != null)
                        {
                            OgrenciBelgeleri[i - 1].Dosya.Delete();
                        }
                        OgrenciBelgeleri[i - 1].Delete();
                    }
                }
                ((Ogrenci)View.CurrentObject).Delete();
            }
            else if (View.SelectedObjects.Count > 0)
            {
                List <Ogrenci> ogrenciler = View.SelectedObjects.Cast <Ogrenci>().ToList();
                for (int i = ogrenciler.Count; i > 0; i--)
                {
                    if (ogrenciler[i - 1].Belgeler.Count > 0)
                    {
                        XPCollection <Belgeler> tesisBelgeleri = new XPCollection <Belgeler>(ogrenciler[i - 1].Session, ogrenciler[i - 1].Belgeler);
                        for (int l = tesisBelgeleri.Count; l > 0; l--)
                        {
                            if (tesisBelgeleri[l - 1].Dosya != null)
                            {
                                tesisBelgeleri[l - 1].Dosya.Delete();
                            }
                            tesisBelgeleri[l - 1].Delete();
                        }
                    }
                    ogrenciler[i - 1].Delete();
                }
            }

            ((XPObjectSpace)View.ObjectSpace).Session.PurgeDeletedObjects();
            View.ObjectSpace.CommitChanges();
            viewClose();
        }
Exemplo n.º 20
0
        private void prepararNuevoMovimiento(DialogControllerAcceptingEventArgs e, TipoMovimiento tipoMovimiento)
        {
            var nuevoMovimiento = ObjectSpace.CreateObject <TMovimiento>();

            nuevoMovimiento.TipoMovimiento     = tipoMovimiento;
            nuevoMovimiento.ObjetoConHistorial = (TObjetoConHistorial)e.AcceptActionArgs.SelectedObjects[0];
            InicializarValores(ObjectSpace, nuevoMovimiento);

            e.ShowViewParameters.CreatedView  = Application.CreateDetailView(ObjectSpace, nuevoMovimiento, false);
            e.ShowViewParameters.TargetWindow = TargetWindow.NewModalWindow;
            e.ShowViewParameters.Context      = TemplateContext.PopupWindow;

            var dc = Application.CreateController <DialogController>();

            dc.SaveOnAccept = false;
            dc.Accepting   += (s, e1) => View.CollectionSource.Add((TMovimiento)e1.AcceptActionArgs.CurrentObject);
            dc.Cancelling  += (s, e1) => ((TMovimiento)((DialogController)s).Frame.View.CurrentObject).Delete();

            e.ShowViewParameters.Controllers.Add(dc);
        }
        /// <summary>
        /// Speichert die aktuelle Zeitbuchung und generiert mögliche Wiederholungen
        /// unter Berücksichtigung von Wochenenden, festen und beweglichen Feiertagen
        /// wenn die Option "Wochenende und Feiertag ignorieren" gewählt wurde.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dialogController_Accepting(object sender, DialogControllerAcceptingEventArgs e)
        {
            var booking = e.AcceptActionArgs.CurrentObject as IBooking;

            var j        = 0;
            var nextDate = booking.Date;

            NextFinancialDate(booking, ref j, ref nextDate);
            booking.Date = nextDate;

            if (booking.Repetition <= 1)
            {
                return;
            }

            j = 1;
            for (var i = 1; i < booking.Repetition; i++)
            {
                var nextBooking = _currentObjectSpace.CreateObject <IBooking>();
                nextBooking.Project         = booking.Project;
                nextBooking.StartTime       = booking.StartTime;
                nextBooking.Task            = booking.Task;
                nextBooking.TaskDescription = booking.TaskDescription;
                nextBooking.Customer        = booking.Customer;
                nextBooking.Employee        = booking.Employee;

                nextDate = booking.Date.AddDays(j);

                NextFinancialDate(booking, ref j, ref nextDate);

                nextBooking.Date    = nextDate;
                nextBooking.EndTime = booking.EndTime;
                j++;
            }

            _currentObjectSpace.CommitChanges();
            //ObjectSpace.CommitChanges();
            ObjectSpace.Refresh();
        }
        void selectSemesterForClassTransactionTrackingAcception_Accepting(object sender, DialogControllerAcceptingEventArgs e)
        {
            ObjectSpace objectSpace = Application.CreateObjectSpace();
            ListView lv = ((ListView)((WindowController)sender).Window.View);
            Semester semester = lv.SelectedObjects.Count == 0 ? null : lv.SelectedObjects[0] as Semester;
            //GroupOperator classroomsOp = new GroupOperator(CriteriaOperator.Parse("1=0"));
            //ContainsOperator biOperator;
            string strParse = "";
            if (semester != null)
            {
                //NestedObjectSpace nobj= objectSpace.CreateNestedObjectSpace();
                foreach (StudentClass studentClass in View.SelectedObjects)
                {

                    ClassTransactionTracking ct = objectSpace.FindObject<ClassTransactionTracking>
                        (CriteriaOperator.Parse("StudentClass.ClassCode = ? and Semester.SemesterName = ?",
                        studentClass.ClassCode, semester.SemesterName));
                    if (ct == null)
                    {
                        ct = objectSpace.CreateObject<ClassTransactionTracking>();
                        ct.Semester = objectSpace.FindObject<Semester>(CriteriaOperator.Parse("SemesterName=?", semester.SemesterName));
                        ct.StudentClass = objectSpace.FindObject<StudentClass>(CriteriaOperator.Parse("ClassCode=?", studentClass.ClassCode));
                        ct.Save();
                    }
                    //biOperator = new ContainsOperator("StudentClasses", new BinaryOperator("ClassCode", studentClass.ClassCode));
                    //classroomsOp = new GroupOperator(GroupOperatorType.Or, classroomsOp, biOperator);

                    strParse += (strParse == "" ? string.Format("StudentClass.ClassCode='{0}'", studentClass.ClassCode) :
                        string.Format(" or StudentClass.ClassCode='{0}'", studentClass.ClassCode));
                }
                objectSpace.CommitChanges();
                ReportData reportData = objectSpace.FindObject<ReportData>(
                    new BinaryOperator("Name", "Tỉ lệ nợ lớp biên chế NHHK"));
                strParse = string.Format("({0}) and Semester.SemesterName= '{1}'", strParse, semester.SemesterName);

                ReportServiceController rsc = ((WindowController)sender).Frame.GetController<ReportServiceController>();
                rsc.ShowPreview((IReportData)reportData, CriteriaOperator.Parse(strParse)); //classroomsOp);
            }
        }
Exemplo n.º 23
0
        //private void BookRegister_Execute(object sender, SimpleActionExecuteEventArgs e)
        //{
        //    double numcredits = 0;
        //    Decimal sumTuitionFee = 0;
        //    ListEditor listEditor = ((ListView)View).Editor as ListEditor;
        //    PopUpMessage ms;
        //    DialogController dc;
        //    ObjectSpace objectSpace = Application.CreateObjectSpace();
        //    if (listEditor != null)
        //    {
        //        if (SecuritySystem.CurrentUser is Student)
        //        {

        //            //kiem tra rang buoc so tin chi min
        //            foreach (RegisterDetail regDetail in ((ListView)View).SelectedObjects)
        //            {
        //                numcredits += regDetail.Lesson.Subject.Credit;

        //            }
        //            ConstrainstParameter cparam = objectSpace.FindObject<ConstrainstParameter>(
        //            new BinaryOperator("Code", "MINCREDITS"));
        //            if (cparam != null && numcredits < Convert.ToDouble(cparam.Value))
        //            {

        //                ms = objectSpace.CreateObject<PopUpMessage>();
        //                ms.Title = "Lỗi đăng ký";
        //                ms.Message = string.Format("Không đăng ký ít hơn {0} tín chỉ!", cparam.Value);
        //                e.ShowViewParameters.CreatedView = Application.CreateDetailView(
        //                     objectSpace, ms);
        //                e.ShowViewParameters.TargetWindow = TargetWindow.NewModalWindow;
        //                e.ShowViewParameters.CreatedView.Caption = "Thông báo";
        //                dc = Application.CreateController<DialogController>();
        //                dc.AcceptAction.Active.SetItemValue("object", false);
        //                dc.CancelAction.Caption = "Đóng";
        //                dc.SaveOnAccept = false;
        //                e.ShowViewParameters.Controllers.Add(dc);

        //                return;
        //            }
        //            //kiem tra rang buoc so tin chi max
        //            cparam = View.ObjectSpace.FindObject<ConstrainstParameter>(
        //            new BinaryOperator("Code", "MAXCREDITS"));
        //            if (cparam != null && numcredits > Convert.ToDouble(cparam.Value))
        //            {

        //                ms = objectSpace.CreateObject<PopUpMessage>();
        //                ms.Title = "Lỗi đăng ký";
        //                ms.Message = string.Format("Không đăng ký nhiều hơn {0} tín chỉ!", cparam.Value);
        //                e.ShowViewParameters.CreatedView = Application.CreateDetailView(
        //                     objectSpace, ms);
        //                e.ShowViewParameters.TargetWindow = TargetWindow.NewModalWindow;
        //                e.ShowViewParameters.CreatedView.Caption = "Thông báo";
        //                dc = Application.CreateController<DialogController>();
        //                dc.AcceptAction.Active.SetItemValue("object", false);
        //                dc.CancelAction.Caption = "Đóng";
        //                dc.SaveOnAccept = false;
        //                e.ShowViewParameters.Controllers.Add(dc);


        //                return;
        //            }

        //            numcredits = 0;
        //            sumTuitionFee = 0;
        //            string lessonCodelist = "";

        //            foreach (RegisterDetail regDetail in ((ListView)View).SelectedObjects)
        //            {
        //                if (regDetail.RegisterState.Code == "SELECTED")
        //                {
        //                    numcredits += regDetail.Lesson.Subject.Credit;
        //                    sumTuitionFee += regDetail.Lesson.TuitionFee;
        //                    View.ObjectSpace.SetModified(regDetail);
        //                    View.ObjectSpace.SetModified(regDetail.Lesson);
        //                    regDetail.RegisterState = View.ObjectSpace.FindObject<RegisterState>(
        //                        new BinaryOperator ("Code","BOOKED"));
        //                    regDetail.CheckState = View.ObjectSpace.FindObject<RegisterState>(
        //                        new BinaryOperator("Code", "NOTCHECKED"));
        //                    regDetail.Lesson.NumRegistration++;
        //                    lessonCodelist += (String.Format("{0}({1})-", regDetail.Lesson.LessonName, regDetail.Lesson.Subject.SubjectCode));
        //                }
        //            }
        //            lessonCodelist = lessonCodelist.TrimEnd('-');
        //            //create Account transaction
        //            AccountTransaction act = View.ObjectSpace.CreateObject<AccountTransaction>();
        //            Student stud = View.ObjectSpace.FindObject<Student>(
        //                new BinaryOperator("Oid", SecuritySystem.CurrentUserId));
        //            act.Student = stud;
        //            act.MoneyAmount = -sumTuitionFee;
        //            act.TransactingDate = DateTime.Now;
        //            act.Description = string.Format("Học phí [{0}] phải đóng cho {1} tín chỉ đăng ký: [{2}], do [{3}] thực hiện đăng ký", stud.StudentCode, numcredits, lessonCodelist, stud.FullName);
        //            act.Save();

        //            View.ObjectSpace.CommitChanges();

        //            ms = objectSpace.CreateObject<PopUpMessage>();
        //            ms.Title = "Thực hiện đăng ký thành công";
        //            ms.Message = string.Format("Bạn đã chọn đăng ký {0} nhóm lớp môn học, với số tiền {1}", numcredits, sumTuitionFee);
        //            ms.Message += "\r\n Vui lòng xem kết quả giao dịch học phí!!!";
        //            e.ShowViewParameters.CreatedView = Application.CreateDetailView(
        //                 objectSpace, ms);
        //            e.ShowViewParameters.TargetWindow = TargetWindow.NewModalWindow;
        //            e.ShowViewParameters.CreatedView.Caption = "Thông báo";
        //            dc = Application.CreateController<DialogController>();
        //            dc.AcceptAction.Active.SetItemValue("object", false);
        //            dc.CancelAction.Caption = "Đóng";
        //            dc.SaveOnAccept = false;
        //            e.ShowViewParameters.Controllers.Add(dc);

        //        }
        //        else
        //        {

        //            Dictionary<string, double> studentnumcredits = new Dictionary<string, double>();
        //            Dictionary<string, decimal> studentFee = new Dictionary<string, decimal>();
        //            Dictionary<string, string> studentLessonCodeList = new Dictionary<string, string>();
        //            Dictionary<string, string> lessonCannotReg = new Dictionary<string, string>();
        //            foreach (RegisterDetail regDetail in View.SelectedObjects)
        //            {

        //                if (!studentnumcredits.ContainsKey(regDetail.Student.StudentCode))
        //                {
        //                    studentnumcredits.Add(regDetail.Student.StudentCode, 0);
        //                }
        //                if (!studentFee.ContainsKey(regDetail.Student.StudentCode))
        //                {
        //                    studentFee.Add(regDetail.Student.StudentCode, 0);
        //                }
        //                if (!studentLessonCodeList.ContainsKey(regDetail.Student.StudentCode))
        //                {
        //                    studentLessonCodeList.Add(regDetail.Student.StudentCode, "");
        //                }
        //                View.ObjectSpace.SetModified(regDetail);
        //                View.ObjectSpace.SetModified(regDetail.Lesson);
        //                if (regDetail.RegisterState.Code == "SELECTED")
        //                {
        //                    if (regDetail.Lesson.NumRegistration >= regDetail.Lesson.NumExpectation)
        //                    {
        //                        if (!lessonCannotReg.ContainsKey(regDetail.Lesson.LessonName))
        //                        {
        //                            lessonCannotReg.Add(regDetail.Lesson.LessonName, "");
        //                        }
        //                        lessonCannotReg[regDetail.Lesson.LessonName] += string.Format("[{0}]-", regDetail.Student.StudentCode);
        //                        regDetail.Note = "Over Sized";
        //                    }
        //                    else
        //                    {
        //                        studentnumcredits[regDetail.Student.StudentCode] += regDetail.Lesson.Subject.Credit;
        //                        studentFee[regDetail.Student.StudentCode] += regDetail.Lesson.TuitionFee;
        //                        studentLessonCodeList[regDetail.Student.StudentCode] += (String.Format("{0}({1})-", regDetail.Lesson.LessonName, regDetail.Lesson.Subject.SubjectCode));


        //                        regDetail.RegisterState = View.ObjectSpace.FindObject<RegisterState>(
        //                        new BinaryOperator("Code", "BOOKED"));
        //                        regDetail.Lesson.NumRegistration++;
        //                    }
        //                }
        //            }
        //            int numstudent = 0;
        //            double credit = 0;
        //            decimal sumfee = 0;
        //            foreach (string studCode in studentLessonCodeList.Keys)
        //            {
        //                if (studentnumcredits[studCode] > 0)
        //                {
        //                    numstudent++;
        //                    credit += studentnumcredits[studCode];
        //                    sumfee += studentFee[studCode];

        //                    //create Account transaction
        //                    AccountTransaction act = View.ObjectSpace.CreateObject<AccountTransaction>();
        //                    Student studnew = View.ObjectSpace.FindObject<Student>(
        //                        new BinaryOperator("StudentCode", studCode));
        //                    act.Student = studnew;
        //                    act.MoneyAmount = -studentFee[studCode];
        //                    act.TransactingDate = DateTime.Now;
        //                    act.Description = string.Format("Học phí sinh viên [{0}] phải đóng cho {1} tín chỉ đăng ký là {2:0,0},\r\n bao gồm: [{3}],\r\n [{4}] thực hiện đăng ký",
        //                        studnew.StudentCode, studentnumcredits[studCode], studentFee[studCode], studentLessonCodeList[studCode].TrimEnd('-'), SecuritySystem.CurrentUserName);
        //                    act.Save();
        //                }
        //            }

        //            View.ObjectSpace.CommitChanges();

        //            ms = objectSpace.CreateObject<PopUpMessage>();
        //            ms.Title = "Thực hiện đăng ký (Booked) thành công";
        //            ms.Message = string.Format("Bạn đã chọn đăng ký cho {0} sinh viên, với số tiền {1:0,0} cho tổng số {2:0,0} tín chỉ học",
        //                numstudent, sumfee, credit);
        //            ms.Message += "\r\n Vui lòng xem kết quả giao dịch học phí!!!";
        //            if (lessonCannotReg.Count > 0)
        //            {
        //                string strmessage = "";
        //                foreach (KeyValuePair<string, string> keypair in lessonCannotReg)
        //                {
        //                    strmessage += string.Format("Nhóm lớp MH:[{0}], sinh viên [{1}] \r\n", keypair.Key, keypair.Value.TrimEnd('-'));
        //                }
        //                ms.Message += "\r\nKhông đăng ký được do quá sĩ số:\r\n" + strmessage;
        //            }
        //            e.ShowViewParameters.CreatedView = Application.CreateDetailView(
        //                 objectSpace, ms);
        //            e.ShowViewParameters.TargetWindow = TargetWindow.NewModalWindow;
        //            e.ShowViewParameters.CreatedView.Caption = "Thông báo";
        //            dc = Application.CreateController<DialogController>();
        //            e.ShowViewParameters.Controllers.Add(dc);
        //            dc.AcceptAction.Active.SetItemValue("object", false);
        //            dc.CancelAction.Caption = "Đóng";
        //            dc.SaveOnAccept = false;
        //        }
        //    }
        //}
        //private void ConfirmRegister_Execute(object sender, SimpleActionExecuteEventArgs e)
        //{

        //    ListEditor listEditor = ((ListView)View).Editor as ListEditor;
        //    if (listEditor != null)
        //    {
        //        int i = 0;
        //        string messsage = "";
        //        ObjectSpace objectSpace = Application.CreateObjectSpace();
        //        PopUpMessage ms = objectSpace.CreateObject<PopUpMessage>();
        //        ms.Message = messsage;
        //        DialogController dc = Application.CreateController<DialogController>();
        //        if (View.SelectedObjects.Count > 0)
        //        {
        //            foreach (RegisterDetail regDetail in ((ListView)View).SelectedObjects)
        //            {
        //                regDetail.RegisterState = View.ObjectSpace.FindObject<RegisterState>(
        //                        new BinaryOperator("Code", "PRINTED"));
        //                if (regDetail.CheckState.Code == "CHECKED")
        //                {
        //                    View.ObjectSpace.SetModified(regDetail);
        //                    regDetail.CheckState = View.ObjectSpace.FindObject<RegisterState>(
        //                        new BinaryOperator("Code", "CONFIRMED"));
        //                    i++;
        //                }
        //            }
        //            View.ObjectSpace.CommitChanges();
        //            messsage = string.Format("Đã xác nhận kết quả cho \"{0}\" Nhóm MH, \r\n Nhấn OK để in kết quả!", i);
        //            ms.Title = "Kết quả xác nhận!";
        //            dc.Accepting += dc_Accepting_Report;
        //            dc.SaveOnAccept = false;
        //        }
        //        else
        //        {
        //            messsage = "Vui lòng chọn tất cả các môn đã kiểm tra";
        //            ms.Title = "Chưa chọn môn xác nhận!";
        //        }


        //        e.ShowViewParameters.CreatedView = Application.CreateDetailView(
        //            objectSpace, ms);
        //        e.ShowViewParameters.TargetWindow = TargetWindow.NewModalWindow;
        //        e.ShowViewParameters.CreatedView.Caption = "Thông báo";
        //        e.ShowViewParameters.Controllers.Add(dc);
        //    }
        //}

        #endregion

        void dc_Accepting_Report(object sender, DialogControllerAcceptingEventArgs e)
        {
            Controller  controller  = sender as Controller;
            ObjectSpace objectSpace = Application.CreateObjectSpace();
            ReportData  rd          = objectSpace.FindObject <ReportData>(
                new BinaryOperator("Name", "Kết quả ĐK 1 SV"));

            if (rd != null)
            {
                XafReport report = rd.LoadXtraReport(objectSpace);

                CriteriaOperator criteriaOperator = CriteriaOperator.TryParse(
                    String.Format("[Student.Oid] = '{0}'", SecuritySystem.CurrentUserId));
                Student student = objectSpace.FindObject <Student>(criteriaOperator);
                report.Filtering.Filter = criteriaOperator.ToString();
                MemoryStream stream = new MemoryStream();
                report.ExportToPdf(stream);
                if (HttpContext.Current != null)
                {
                    byte[] buffer             = stream.GetBuffer();
                    string contentType        = "application/pdf";
                    string contentDisposition = "attachment; filename=" + student.StudentCode + ".pdf";
                    HttpContext.Current.Response.Clear();
                    HttpContext.Current.Response.Buffer = false;
                    HttpContext.Current.Response.AppendHeader("Content-Type", contentType);
                    HttpContext.Current.Response.AppendHeader("Content-Transfer-Encoding", "binary");
                    HttpContext.Current.Response.AppendHeader("Content-Disposition", contentDisposition);
                    HttpContext.Current.Response.BinaryWrite(buffer);
                    HttpContext.Current.Response.End();
                }
                else
                {
                    report.ShowPreview();
                }
                controller.Dispose();
            }
        }
Exemplo n.º 24
0
        private void DialogController_Execute(object sender, DialogControllerAcceptingEventArgs e)
        {
            var dir = ((PersonaDireccion)View.CurrentObject).Direccion;

            if (e.AcceptActionArgs.SelectedObjects.Count < 1)
            {
                return;
            }
            var selectedLoc = (CPA.LocalidadResultItem)e.AcceptActionArgs.SelectedObjects[0];

            var cps = CPA.ObtenerCPA(selectedLoc.Codigo, dir.Calle, dir.Numero);

            var collectionSource = new CollectionSource(ObjectSpace, typeof(CPA.CPAResultItem));

            foreach (var cp in cps)
            {
                collectionSource.Add(cp);
            }

            var view = Application.CreateListView(Application.GetListViewId(typeof(CPA.CPAResultItem)), collectionSource,
                                                  false);

            view.Editor.AllowEdit = false;
            e.AcceptActionArgs.ShowViewParameters.CreatedView  = view;
            e.AcceptActionArgs.ShowViewParameters.TargetWindow = TargetWindow.NewModalWindow;
            e.AcceptActionArgs.ShowViewParameters.Context      = TemplateContext.PopupWindow;
            var dc = Application.CreateController <DialogController>();

            e.AcceptActionArgs.ShowViewParameters.Controllers.Add(dc);

            dc.Tag          = selectedLoc;
            dc.SaveOnAccept = false;
            dc.Accepting   += CPAResultItem_DialogController_Accepting;
            //Truco para forzar la apertura de la view; por lo visto es la unica forma de encadenar dos Popup views
            Application.ShowViewStrategy.ShowView(e.AcceptActionArgs.ShowViewParameters,
                                                  new ShowViewSource(Frame, e.AcceptActionArgs.Action));
        }
Exemplo n.º 25
0
        private void PagoAplicarCuota_DialogController_Accepting(object sender, DialogControllerAcceptingEventArgs e)
        {
            var selectedCuotas = e.AcceptActionArgs.SelectedObjects;

            if (selectedCuotas.Count == 0)
            {
                e.Cancel = true;
                return;
            }

            var pago = this.GetMasterObject <Pago>( );

            foreach (ComprobanteCuota cuota in selectedCuotas)
            {
                var apl = ObjectSpace.CreateObject <PagoAplicacion>( );
                apl.Cuota = cuota;
                //El uso del enum DebitoCredito del tipo de comprobante, nos permite considerar signo de la aplicación (los comprobantes y cuotas se guardan todos positivos)
                apl.Importe = cuota.Saldo * ( decimal )cuota.Comprobante.Tipo.DebitoCredito;
                apl.Cambio  = 1;
                apl.Especie = cuota.Comprobante.Especie;

                pago.Aplicaciones.Add(apl);
            }
        }
        void selectSemesterAcception_Accepting(object sender, DialogControllerAcceptingEventArgs e)
        {
            //Dictionary<string, WeekReportData> dicTeacherPeriodData;
            //WeekReportData currentWeekData;
            ObjectSpace objectSpace = Application.CreateObjectSpace();
            ListView lv = ((ListView)((WindowController)sender).Window.View);
            Semester semester = lv.SelectedObjects.Count == 0 ? null : lv.SelectedObjects[0] as Semester;
            if (semester != null)
            {
                string strParse = "";
                foreach (Teacher teacher in View.SelectedObjects)
                {
                    Data.CreateTeacherTimetableData(objectSpace, teacher.TeacherCode, semester.SemesterName);

                    strParse += (strParse == "" ? string.Format("TeacherCode='{0}'", teacher.TeacherCode) :
                        string.Format("or TeacherCode='{0}'", teacher.TeacherCode));
                }
                ReportData reportData = objectSpace.FindObject<ReportData>(
                    new BinaryOperator("Name", "Lịch giảng viên"));

                ReportServiceController rsc = ((WindowController)sender).Frame.GetController<ReportServiceController>();
                rsc.ShowPreview((IReportData)reportData, CriteriaOperator.Parse(strParse));
            }
        }
Exemplo n.º 27
0
        private async void DialogControllerImportarPlanilha_Accepting(object sender, DialogControllerAcceptingEventArgs e)
        {
            DataTableCollection dtcollectionImport = null;

            ((DialogController)sender).AcceptAction.Enabled["NoEnabled"] = false;
            //Necessário para não fechar a janela após a conclusão do processamento
            e.Cancel = true;
            e.AcceptActionArgs.Action.Caption = "Procesando";

            var          parametros = (ParametrosImportSpoolJuntaExcel)e.AcceptActionArgs.SelectedObjects[0];
            MemoryStream stream     = new MemoryStream();

            stream.Seek(0, SeekOrigin.Begin);

            var arquivo = parametros.Padrao;

            arquivo.SaveToStream(stream);

            stream.Seek(0, SeekOrigin.Begin);

            using (var excelReader = new ExcelDataReaderHelper.Excel.Reader(stream))
            {
                dtcollectionImport = excelReader.CreateDataTableCollection(false);
            }

            var import   = new ImportSpoolEJunta(objectSpace, parametrosImportSpoolJuntaExcel);
            var progress = new Progress <ImportProgressReport>(import.LogTrace);

            await Observable.Start(() => import.ImportarSpools(dtcollectionImport["SGS"], progress));

            await Observable.Start(() => import.ImportarJuntas(dtcollectionImport["SGJ"], progress));

            objectSpace.CommitChanges();
            e.AcceptActionArgs.Action.Caption = "Finalizado";
            ((DialogController)sender).AcceptAction.Enabled["NoEnabled"] = true;
        }
Exemplo n.º 28
0
 void dialogController_Accepting(object sender, DialogControllerAcceptingEventArgs e)
 {
 }
        void selectAcception_Accepting(object sender, DialogControllerAcceptingEventArgs e)
        {
            ListView lv = (ListView)((WindowController)sender).Window.View;
            ObjectSpace objectSpace = Application.CreateObjectSpace();
            PopUpMessage ms = objectSpace.CreateObject<PopUpMessage>();
            int i = 0;
            if (View.SelectedObjects.Count > 0)
            {
                if (lv.SelectedObjects.Count > 0)
                {
                    AccountTransactionFile actFile = objectSpace.FindObject<AccountTransactionFile>(
                        CriteriaOperator.Parse("Oid=?", ((AccountTransactionFile)View.SelectedObjects[0]).Oid));

                    string tempStudentFolderPath;
                    string tempStudentLogFile;
                    string templogname = "";
                    if (HttpContext.Current != null)
                    {
                        tempStudentFolderPath = HttpContext.Current.Request.MapPath("~/tempFolder");
                        templogname = actFile.CsvFile.FileName + DateTime.Now.ToString("dd-MM-yyyy-HHmmss") + "-log.html";
                        tempStudentLogFile = HttpContext.Current.Request.MapPath("~/tempFolder/" + templogname);
                    }
                    else
                    {
                        tempStudentFolderPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "tempFolder");
                        templogname = actFile.CsvFile.FileName + DateTime.Now.ToString("dd-MM-yyyy-HHmmss") + "-log.html";
                        tempStudentLogFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "tempFolder/", templogname);
                    }

                    if (!Directory.Exists(tempStudentFolderPath))
                        Directory.CreateDirectory(tempStudentFolderPath);
                    using (System.IO.StreamWriter fileStreamlog = new System.IO.StreamWriter(tempStudentLogFile, true))
                    {
                        fileStreamlog.WriteLine("<html><header><title>" + actFile.CsvFile.FileName + DateTime.Now.ToString("dd-MM-yyyy-HHmmss") + "-log </title>	" +
                   "<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\" />" +
                   "</head><body>\r\n<table border=\"1px\"> <tr><Th>DÒNG</Th><th>MSSV</th><th>HỌ TÊN</Th><Th>SỐ TIỀN</Th><Th>NGÀY THỰC HIỆN</Th><Th> NỘI DUNG </Th><th>GHI CHÚ</th></Tr>");
                        foreach (MyImportResult myImportResult in lv.SelectedObjects)
                        {

                            if (myImportResult.CanImport)
                            {
                                fileStreamlog.WriteLine("<tr>");
                                AccountTransaction acc = objectSpace.CreateObject<AccountTransaction>();
                                string[] datas = myImportResult.Data.Split('|');
                                fileStreamlog.WriteLine(string.Format("<TD>{0}</TD>", myImportResult.Line));
                                acc.Student = objectSpace.FindObject<Student>(new BinaryOperator("StudentCode", datas[0]));
                                fileStreamlog.WriteLine(string.Format ("<TD>{0}</td><td>{1}</td>",acc.Student.StudentCode,acc.Student.FullName));
                                acc.MoneyAmount = Decimal.Parse(datas[3].ToString());
                                try
                                {
                                    acc.TransactingDate = new DateTime(1900, 1, 1).AddDays(
                                        Double.Parse(datas[4].ToString()) - 2);
                                }
                                catch
                                {
                                    acc.TransactingDate = DateTime.Now;
                                }
                                acc.Semester = objectSpace.FindObject<Semester>(
                                    CriteriaOperator.Parse("SemesterName = ?", actFile.Semester.SemesterName));
                                acc.Description = datas[5].ToString();
                                acc.DateCreated = acc.DateModified = DateTime.Now;
                                acc.ImportDescription = actFile.Note;
                                fileStreamlog.WriteLine(string.Format("<TD>{0:0,0}</td><td>{1:dd-MM-yyyy} {1:HH}:{1:mm}</td><td>{2}</td><td>{3}</td>",
                                    acc.MoneyAmount, acc.TransactingDate,acc.Description,actFile.Note));
                                acc.Save();
                                i++;
                                fileStreamlog.WriteLine("</tr>");
                            }
                        }
                        fileStreamlog.WriteLine("</table></body></html>");
                        fileStreamlog.Close();
                    }
                    objectSpace.SetModified(actFile);
                    actFile.IsImported = true;
                    actFile.ResultLink = "/tempFolder/" + templogname;

                    objectSpace.CommitChanges();
                    this.View.Refresh();
                    ms.Title = "Kết quả import dữ liệu";
                    ms.Message = string.Format("Đã import thành công {0} dòng dữ liệu vào hệ thống", i);
                    ShowViewParameters svp = new ShowViewParameters();
                    svp.CreatedView = Application.CreateDetailView(
                         objectSpace, ms);
                    svp.TargetWindow = TargetWindow.NewModalWindow;
                    svp.CreatedView.Caption = "Thông báo";
                    DialogController dc = Application.CreateController<DialogController>();
                    svp.Controllers.Add(dc);
                    dc.AcceptAction.Active.SetItemValue("object", false);
                    dc.CancelAction.Caption = "Đóng";
                    dc.SaveOnAccept = false;
                    Application.ShowViewStrategy.ShowView(svp, new ShowViewSource(null, null));
                }
            }
        }
 void dialogController_Accepting(object sender, DialogControllerAcceptingEventArgs e)
 {
     UnitOfWork uow2 = (UnitOfWork)objectSpace.Session;
     //uow2.BeginTransaction();
     try
     {
         ProdRouteListTransfer rL = uow2.FindObject<ProdRouteListTransfer>(new DevExpress.Data.Filtering.BinaryOperator("Oid", rListTransfer.Oid));
         prodOrderFinish.Post(uow2);
         rL.Post();
         uow2.CommitChanges();
     }
     catch (Exception ex)
     {
         DevExpress.XtraEditors.XtraMessageBox.Show(string.Format("错误 : ", ex.Message));
         uow2.RollbackTransaction();
     }
 }
        protected void HandleAccept(Object sender, DialogControllerAcceptingEventArgs e)
        {
            string reportContainerHandle = (string)((WindowController)sender).Tag;
            ReportParametersObjectBase reportParametersObject = (ReportParametersObjectBase)e.AcceptActionArgs.CurrentObject;
            var criteria = reportParametersObject.GetCriteria();
            var sorting = reportParametersObject.GetSorting();
            // ((DialogController)sender).Accepting -= HandleAccept;

            var reportController = Frame.GetController<ReportServiceController>();
            Guard.ArgumentNotNull(reportController, "reportController");

            ShowReportPreview(reportContainerHandle, reportParametersObject, criteria, true, sorting, true, e.AcceptActionArgs.ShowViewParameters);

            // отмена действия для поддержки множественного запуска отчета с разными параметрами
            e.Cancel = true;
        }
Exemplo n.º 32
0
 private void dc_Accepting(object sender, DialogControllerAcceptingEventArgs e)
 {
 }
        void selectAcception_AcceptingAdmin(object sender, DialogControllerAcceptingEventArgs e)
        {
            ObjectSpace objectSpace = Application.CreateObjectSpace();
            DevExpress.ExpressApp.ListView lv = ((DevExpress.ExpressApp.ListView)((WindowController)sender).Window.View);
            User u = (User)SecuritySystem.CurrentUser;
            XPCollection<Role> xpc = new XPCollection<Role>(u.Roles,
                new BinaryOperator("Name", "Administrators"));
            XPCollection<Role> xpc2 = new XPCollection<Role>(u.Roles,
              new BinaryOperator("Name", "DataAdmins"));
            if (xpc.Count + xpc2.Count > 0)
            {

                objectSpace.Session.BeginTransaction();

                Student currentStudent;
                Lesson curLesson;
                foreach (string studentCode in listStudentCode)
                {
                    currentStudent = objectSpace.FindObject<Student>(
                    new BinaryOperator("StudentCode", studentCode));
                    foreach (Lesson lesson in lv.SelectedObjects)
                    {
                        curLesson = objectSpace.FindObject<Lesson>(
                        new BinaryOperator("Oid", lesson.Oid));
                        RegisterDetail regdetail = new RegisterDetail(objectSpace.Session)
                        {
                            Student = currentStudent,
                            Lesson = curLesson,
                            RegisterState = objectSpace.FindObject<RegisterState>(
                                new BinaryOperator("Code", "SELECTED")),
                            CheckState =objectSpace.FindObject<RegisterState>(
                                new BinaryOperator("Code", "NOTCHECKED"))
                        };
                        RuleSet ruleSet = new RuleSet();

                        RuleSetValidationResult result = ruleSet.ValidateTarget(regdetail, DefaultContexts.Save);
                        if (ValidationState.Invalid ==
                            result.GetResultItem("RegisterDetail.StudentRegLessonSemester").State)
                        {
                            regdetail.Delete();
                        }
                        else
                        {
                            regdetail.Save();
                        }

                    }
                }
                objectSpace.Session.CommitTransaction();

                PopUpMessage ms = objectSpace.CreateObject<PopUpMessage>();
                ms.Title = "Lỗi đăng ký";
                ms.Message = string.Format("Error");
                ShowViewParameters svp = new ShowViewParameters();
                svp.CreatedView = Application.CreateDetailView(
                     objectSpace, ms);
                svp.TargetWindow = TargetWindow.NewModalWindow;
                svp.CreatedView.Caption = "Thông báo";
                DialogController  dc = Application.CreateController<DialogController>();
                svp.Controllers.Add(dc);

                dc.SaveOnAccept = false;
                Application.ShowViewStrategy.ShowView(svp,new ShowViewSource(null,null));
                ////               View.ObjectSpace.CommitChanges();
                //View.ObjectSpace.Refresh();
                //ListView view = null;
                //Frame currentFrame = ((ActionBase)sender).Controller.Frame;
                //switch (currentFrame.View.ObjectTypeInfo.Name)
                //{
                //    case "Student":
                //        view = Application.CreateListView(objectSpace,typeof(RegisterDetail),true);
                //        break;
                //}
                //currentFrame.SetView(view);
                //e.Cancel = true;
            }
        }
        void selectAcception_AcceptingAdmin(object sender, DialogControllerAcceptingEventArgs e)
        {
            Dictionary<string, int> dicLessonCurrentRegNum = new Dictionary<string, int>();
            ObjectSpace objectSpace = Application.CreateObjectSpace();
            ListView lv = ((ListView)((WindowController)sender).Window.View);
            User u = (User)SecuritySystem.CurrentUser;
            XPCollection<Role> xpc = new XPCollection<Role>(u.Roles,
                new BinaryOperator("Name", "Administrators"));
            XPCollection<Role> xpc2 = new XPCollection<Role>(u.Roles,
              new BinaryOperator("Name", "DataAdmins"));
            if (xpc.Count + xpc2.Count > 0)
            {

                objectSpace.Session.BeginTransaction();

                Student currentStudent;
                Lesson curLesson;
                Dictionary<string, List<string>> errorstudent = new Dictionary<string, List<string>>();
                int numregok = 0;
                foreach (string studentCode in dicStudentRegDetail.Keys)
                {
                    currentStudent = objectSpace.FindObject<Student>(
                    new BinaryOperator("StudentCode", studentCode));
                    foreach (Lesson lesson in lv.SelectedObjects)
                    {
                        if (!dicLessonCurrentRegNum.ContainsKey(lesson.LessonName))
                        {
                            dicLessonCurrentRegNum[lesson.LessonName] = 0;
                        }
                        //si so chon chua vuot qua
                        if (lesson.NumExpectation > dicLessonCurrentRegNum[lesson.LessonName] + lesson.NumRegistration)
                        {
                            curLesson = objectSpace.FindObject<Lesson>(
                            new BinaryOperator("Oid", lesson.Oid));
                            RegisterDetail regdetail = new RegisterDetail(objectSpace.Session)
                            {
                                Student = currentStudent,
                                Lesson = curLesson,
                                RegisterState = objectSpace.FindObject<RegisterState>(
                                new BinaryOperator("Code", "SELECTED")),
                                CheckState = objectSpace.FindObject<RegisterState>(
                                    new BinaryOperator("Code", "NOTCHECKED"))
                            };
                            RuleSet ruleSet = new RuleSet();

                            RuleSetValidationResult result = ruleSet.ValidateTarget(regdetail, DefaultContexts.Save);
                            if (ValidationState.Invalid ==
                                result.GetResultItem("RegisterDetail.StudentRegLessonSemester").State)
                            {
                                if (!errorstudent.ContainsKey(currentStudent.StudentCode))
                                    errorstudent.Add(currentStudent.StudentCode, new List<string>());
                                if (!errorstudent[currentStudent.StudentCode].Contains(curLesson.Subject.SubjectCode))
                                    errorstudent[currentStudent.StudentCode].Add(curLesson.Subject.SubjectCode);
                                regdetail.Delete();
                            }
                            else
                            {
                                numregok++;
                                dicLessonCurrentRegNum[lesson.LessonName]++;
                                regdetail.Save();
                            }
                        }
                        else
                        {
                            if (!errorstudent.ContainsKey(currentStudent.StudentCode))
                                errorstudent.Add(currentStudent.StudentCode, new List<string>());
                            if (!errorstudent[currentStudent.StudentCode].Contains(lesson.Subject.SubjectCode))
                                errorstudent[currentStudent.StudentCode].Add(lesson.Subject.SubjectCode);
                        }

                    }
                }
                objectSpace.Session.CommitTransaction();
                PopUpMessage ms = objectSpace.CreateObject<PopUpMessage>();
                if (errorstudent.Count > 0)
                {
                    ms.Title = "Có lỗi khi chọn nhóm MH đăng ký!";
                    ms.Message = string.Format("Đã chọn được cho {0} sinh viên với {1} lượt nhóm MH\r\n", dicStudentRegDetail.Count, numregok);
                    string strmessage = "Không chọn được nhóm môn học do trùng môn đã đăng ký hoặc hết chỗ: ";
                    foreach (KeyValuePair<string, List<string>> keypair in errorstudent)
                    {
                        strmessage += string.Format("Sinh viên:[{0}] - Môn:[",keypair.Key);
                        foreach (string str in keypair.Value)
                        {
                            strmessage+= str +",";
                        }
                        strmessage= strmessage.TrimEnd(',');
                        strmessage += "]\r\n";
                    }
                    ms.Message += strmessage;
                }
                else
                {
                    ms.Title = "Chọn nhóm MH thành công";
                    ms.Message = string.Format("Chọn nhóm MH thành công cho {0} sinh viên với {1} lượt nhóm MH\r\n", dicStudentRegDetail.Count, numregok);
                }
                ShowViewParameters svp = new ShowViewParameters();
                svp.CreatedView = Application.CreateDetailView(
                     objectSpace, ms);
                svp.TargetWindow = TargetWindow.NewModalWindow;
                svp.CreatedView.Caption = "Thông báo";
                DialogController dc = Application.CreateController<DialogController>();
                svp.Controllers.Add(dc);

                dc.SaveOnAccept = false;
                Application.ShowViewStrategy.ShowView(svp, new ShowViewSource(null, null));
            }
        }
        void printRegisterReport_Accepting(object sender, DialogControllerAcceptingEventArgs e)
        {
            DetailView detailView = ((DetailView)((WindowController)sender).Window.View);
            ObjectSpace objectSpace = detailView.ObjectSpace;
            RegisterDetailReportParametersObject rdrObj =
                (RegisterDetailReportParametersObject) detailView.CurrentObject;
            ReportData rd = objectSpace.FindObject<ReportData>(
                new BinaryOperator("Name", "Kết quả ĐK 1 SV"));

            if (rd != null)
            {
                XafReport report = rd.LoadXtraReport(objectSpace);

                //CriteriaOperator criteriaOperator = CriteriaOperator.TryParse(
                //        String.Format("[Student.Oid] = '{0}'", SecuritySystem.CurrentUserId));
                //Student stud = objectSpace.FindObject<Student>(CriteriaOperator.TryParse(
                //        String.Format("[Oid] = '{0}'", SecuritySystem.CurrentUserId)));

                //Frame.GetController<ReportServiceController>().ShowPreview((IReportData)rd, criteriaOperator);
                report.SetFilteringObject(rdrObj);// = rdrObj.GetCriteria().ToString();//criteriaOperator.ToString();
                MemoryStream stream = new MemoryStream();
                report.ExportToPdf(stream);

                if (HttpContext.Current != null)
                {

                    byte[] buffer = stream.GetBuffer();
                    string contentType = "application/pdf";
                    string contentDisposition = "attachment; filename=KQDK_" + rdrObj.Student.StudentCode + ".pdf";
                    HttpContext.Current.Response.Clear();
                    HttpContext.Current.Response.Buffer = false;
                    HttpContext.Current.Response.AppendHeader("Content-Type", contentType);
                    HttpContext.Current.Response.AppendHeader("Content-Transfer-Encoding", "binary");
                    HttpContext.Current.Response.AppendHeader("Content-Disposition", contentDisposition);
                    HttpContext.Current.Response.BinaryWrite(buffer);
                    HttpContext.Current.Response.End();
                }
                else
                {
                    report.ShowPreview();
                }

            }
            else
            {
                throw new UserFriendlyException("Không tìm thấy báo biểu phù hợp");
            }
        }
        void dc_Book_Accepting(object sender, DialogControllerAcceptingEventArgs e)
        {
            Controller controller = sender as Controller;
            ObjectSpace objectSpace = Application.CreateObjectSpace();

            ReportData rd = objectSpace.FindObject<ReportData>(
                new BinaryOperator("Name", "Kết quả ĐK 1 SV"));
            if (rd != null)
            {
                XafReport report = rd.LoadXtraReport(objectSpace);

                CriteriaOperator criteriaOperator = CriteriaOperator.TryParse(
                        String.Format("[Student.Oid] = '{0}'", SecuritySystem.CurrentUserId));
                Student stud = objectSpace.FindObject<Student>(CriteriaOperator.TryParse(
                        String.Format("[Oid] = '{0}'", SecuritySystem.CurrentUserId)));

                ConstrainstParameter cpNHHK = objectSpace.FindObject<ConstrainstParameter>(
                               new BinaryOperator("Code", "REGISTERSEMESTER"));

                RegisterDetailReportParametersObject rdrObj = new RegisterDetailReportParametersObject(objectSpace.Session);

                rdrObj.Student = stud;
                int nhhk = Convert.ToInt32(cpNHHK.Value);
                nhhk += 1; //NHHK kế tiếp
                Semester sem = objectSpace.FindObject<Semester>(new BinaryOperator(
                    "SemesterName", nhhk, BinaryOperatorType.Equal));
                if (sem == null) //thử nhhk của năm mới
                {
                    nhhk = (nhhk / 10 + 1) * 10 + 1;
                    sem = objectSpace.FindObject<Semester>(new BinaryOperator(
                    "SemesterName", nhhk, BinaryOperatorType.Equal));
                }

                if (sem == null)
                    throw new UserFriendlyException("Người Quản trị chưa thiết lập NHHK để ĐKMH, vui lòng liên hệ quản trị viên.");

                rdrObj.Semester = sem;
                rdrObj.Student = stud;

                report.SetFilteringObject(rdrObj);
                MemoryStream stream = new MemoryStream();
                report.ExportToPdf(stream);

                if (HttpContext.Current != null)
                {

                    byte[] buffer = stream.GetBuffer();
                    string contentType = "application/pdf";
                    string contentDisposition = "attachment; filename=KQDK_" + stud.StudentCode + ".pdf";
                    HttpContext.Current.Response.Clear();
                    HttpContext.Current.Response.Buffer = false;
                    HttpContext.Current.Response.AppendHeader("Content-Type", contentType);
                    HttpContext.Current.Response.AppendHeader("Content-Transfer-Encoding", "binary");
                    HttpContext.Current.Response.AppendHeader("Content-Disposition", contentDisposition);
                    HttpContext.Current.Response.BinaryWrite(buffer);
                    HttpContext.Current.Response.End();
                }
                else
                {
                    report.ShowPreview();
                }
                controller.Dispose();

            }
        }
        void selectAcception_AcceptingStudent(object sender, DialogControllerAcceptingEventArgs e)
        {
            RuleSet ruleSet = new RuleSet();
            RuleSetValidationResult result;

            if (SecuritySystem.CurrentUser is Student)
            {
                ObjectSpace objectSpace = Application.CreateObjectSpace();
                ListView lv = ((ListView)((WindowController)sender).Window.View);
                if (SecuritySystem.CurrentUser is Student)
                {
                    objectSpace.Session.BeginTransaction();
                     PopUpMessage ms = objectSpace.CreateObject<PopUpMessage>();
                    ms.Title = "Chọn nhóm MH thành công";
                    ms.Message = "";
                    Student student = SecuritySystem.CurrentUser as Student;
                    Student currentStudent = objectSpace.FindObject<Student>(
                        new BinaryOperator("StudentCode", student.StudentCode));
                    Lesson curLesson;
                    int checkresult, selectsubject=0;
                    double selectcredits = 0;
                    string subjectcoderesult, msgresult;
                    foreach (Lesson lesson in lv.SelectedObjects)
                    {
                        if (Utils.IsConfictPrerequisite(objectSpace, student.StudentCode, lesson.Subject.SubjectCode, out checkresult, out subjectcoderesult))
                        {
                            switch (checkresult)
                            {
                                case 1: msgresult = "học trước"; break;
                                case 2: msgresult = "tiên quyết"; break;
                                default: msgresult = "-"; break;
                            };
                            Subject subj = objectSpace.FindObject<Subject>(CriteriaOperator.Parse("SubjectCode =?", subjectcoderesult));
                            ms.Message += string.Format("Không chọn được môn [{0}]{1} do vi phạm môn {2} là [{3}]{4}\r\n",
                                lesson.Subject.SubjectCode, lesson.Subject.SubjectName, msgresult, subj.SubjectCode, subj.SubjectName);
                            continue;
                        }
                        curLesson = objectSpace.FindObject<Lesson>(
                        new BinaryOperator("Oid", lesson.Oid));

                        RegisterDetail regdetail = new RegisterDetail(objectSpace.Session)
                        {
                            Student = currentStudent,
                            Lesson = curLesson,
                            RegisterState = objectSpace.FindObject<RegisterState>(
                                new BinaryOperator("Code", "SELECTED")),
                            CheckState = objectSpace.FindObject<RegisterState>(
                                new BinaryOperator("Code", "NOTCHECKED"))
                        };
                        selectcredits += curLesson.Subject.Credit;
                        selectsubject++;
                        result = ruleSet.ValidateTarget(regdetail, DefaultContexts.Save);
                        if (ValidationState.Invalid ==
                            result.GetResultItem("RegisterDetail.StudentRegLessonSemester").State)
                        {
                            regdetail.Delete();
                            selectcredits -= curLesson.Subject.Credit;
                            selectsubject--;
                        }

                    }
                    objectSpace.Session.CommitTransaction();

                    View.ObjectSpace.Refresh();

                    ms.Message += string.Format("Tổng số chọn được {0} nhóm lớp môn học với {1} tín chỉ.", selectsubject, selectcredits);
                    ShowViewParameters svp = new ShowViewParameters();
                    svp.CreatedView = Application.CreateDetailView(
                         objectSpace, ms);
                    svp.TargetWindow = TargetWindow.NewModalWindow;
                    svp.CreatedView.Caption = "Thông báo";
                    DialogController dc = Application.CreateController<DialogController>();
                    svp.Controllers.Add(dc);
                    dc.AcceptAction.Active.SetItemValue("object", false);
                    dc.CancelAction.Caption = "Đóng";
                    dc.SaveOnAccept = false;
                    Application.ShowViewStrategy.ShowView(svp, new ShowViewSource(null, null));
                }
            }
        }
        //void gridView_SelectionChanged(object sender, EventArgs e)
        //{
        //    if (SecuritySystem.CurrentUser is Student)
        //    {
        //        Student student = SecuritySystem.CurrentUser as Student;
        //        string currentClass = student.StudentClass.ClassCode;
        //        ASPxGridView gc = sender as ASPxGridView;
        //        List<Vacancy> tempList = new List<Vacancy>(listVacancies);
        //        List<object> listobj = gc.GetSelectedFieldValues(new string[] { "LessonCode" });
        //        ObjectSpace objectSpace = Application.CreateObjectSpace();
        //        Vacancy vc;
        //        string strFilter = "", strInclude = "";
        //        foreach (int strLessonCode in listobj)
        //        {
        //            Lesson lesson = objectSpace.FindObject<Lesson>(new BinaryOperator("LessonCode", strLessonCode));
        //            strInclude += String.Format("OR ([LessonCode]={0})", lesson.LessonCode);
        //            foreach (TkbSemester tkbsem in lesson.TKBSemesters)
        //            {
        //                vc = new Vacancy(tkbsem.Day, tkbsem.Period, tkbsem.Weeks, (tkbsem.Classroom == null ? "" : tkbsem.Classroom.ClassroomCode));
        //                tempList.Add(vc);
        //            }
        //        }
        //        if (strInclude != "")
        //            strInclude = String.Format("({0})", strInclude.Substring(3));
        //        if (listobj.Count > 0)
        //        {
        //            using (XPCollection xpLesson = new XPCollection(objectSpace.Session, typeof(Lesson)))
        //            {
        //                foreach (Lesson lesson in xpLesson)
        //                {
        //                    foreach (TkbSemester tkbsem in lesson.TKBSemesters)
        //                    {
        //                        vc = new Vacancy(tkbsem.Day, tkbsem.Period, tkbsem.Weeks, (tkbsem.Classroom == null ? "" : tkbsem.Classroom.ClassroomCode));
        //                        if (Utils.IsConfictTKB(tempList, vc))
        //                        {
        //                            strFilter += String.Format("AND ([LessonCode]<>{0})", lesson.LessonCode);
        //                            break;
        //                        }
        //                    }
        //                }
        //                if (strFilter != "")
        //                    strFilter = String.Format("({0})", strFilter.Substring(4));
        //            }
        //        }
        //        if (strInclude != "" && strFilter != "")
        //        {
        //            strFilter = String.Format("({0} OR {1})", strFilter, strInclude);
        //        }
        //        else if (strInclude != "")
        //        {
        //            strFilter = strInclude;
        //        }
        //        if (strFilter != "")
        //        {
        //            if (gc.FilterExpression.Contains("TkbLesson.ClassIDs"))
        //            {
        //                gc.FilterExpression = string.Format("([TkbLesson.ClassIDs] Like '%{0}%') AND {1}", currentClass, strFilter);
        //            }
        //            else
        //            {
        //                gc.FilterExpression = strFilter;
        //            }
        //        }
        //    }
        //}
        //void gridView_DataBound(object sender, EventArgs e)
        //{
        //    if (SecuritySystem.CurrentUser is Student)
        //    {
        //        Student student = SecuritySystem.CurrentUser as Student;
        //        string currentClass = student.StudentClass.ClassCode;
        //        ASPxGridView gc = sender as ASPxGridView;
        //        if (gc.FilterExpression == "")
        //            gc.FilterExpression = string.Format("[TkbLesson.ClassIDs] Like '%{0}%'", currentClass);
        //    }
        //}
        void selectAcception_AcceptingStudent(object sender, DialogControllerAcceptingEventArgs e)
        {
            if (SecuritySystem.CurrentUser is Student)
            {
                ObjectSpace objectSpace = Application.CreateObjectSpace();
                DevExpress.ExpressApp.ListView lv = ((DevExpress.ExpressApp.ListView)((WindowController)sender).Window.View);
                if (SecuritySystem.CurrentUser is Student)
                {
                    objectSpace.Session.BeginTransaction();
                    Student student = SecuritySystem.CurrentUser as Student;
                    Student currentStudent = objectSpace.FindObject<Student>(
                        new BinaryOperator("StudentCode", student.StudentCode));
                    Lesson curLesson;
                    foreach (Lesson lesson in lv.SelectedObjects)
                    {
                        curLesson = objectSpace.FindObject<Lesson>(
                        new BinaryOperator("Oid", lesson.Oid));
                        RegisterDetail regdetail = new RegisterDetail(objectSpace.Session)
                        {
                            Student = currentStudent,
                            Lesson = curLesson,
                            RegisterState =  objectSpace.FindObject<RegisterState>(
                                new BinaryOperator ("Code","SELECTED")),
                            CheckState = objectSpace.FindObject<RegisterState>(
                                new BinaryOperator("Code", "NOTCHECKED"))
                        };

                    }
                    objectSpace.Session.CommitTransaction();
                    //               View.ObjectSpace.CommitChanges();
                    View.ObjectSpace.Refresh();
                }
            }
        }
        void selectAcception_AcceptingAdmin(object sender, DialogControllerAcceptingEventArgs e)
        {
            Dictionary <string, int> dicLessonCurrentRegNum = new Dictionary <string, int>();
            ObjectSpace         objectSpace = Application.CreateObjectSpace();
            ListView            lv          = ((ListView)((WindowController)sender).Window.View);
            User                u           = (User)SecuritySystem.CurrentUser;
            XPCollection <Role> xpc         = new XPCollection <Role>(u.Roles,
                                                                      new BinaryOperator("Name", "Administrators"));
            XPCollection <Role> xpc2 = new XPCollection <Role>(u.Roles,
                                                               new BinaryOperator("Name", "DataAdmins"));

            if (xpc.Count + xpc2.Count > 0)
            {
                objectSpace.Session.BeginTransaction();

                Student currentStudent;
                Lesson  curLesson;
                Dictionary <string, List <string> > errorstudent = new Dictionary <string, List <string> >();
                int numregok = 0;
                foreach (string studentCode in dicStudentRegDetail.Keys)
                {
                    currentStudent = objectSpace.FindObject <Student>(
                        new BinaryOperator("StudentCode", studentCode));
                    foreach (Lesson lesson in lv.SelectedObjects)
                    {
                        if (!dicLessonCurrentRegNum.ContainsKey(lesson.LessonName))
                        {
                            dicLessonCurrentRegNum[lesson.LessonName] = 0;
                        }
                        //si so chon chua vuot qua
                        if (lesson.NumExpectation > dicLessonCurrentRegNum[lesson.LessonName] + lesson.NumRegistration)
                        {
                            curLesson = objectSpace.FindObject <Lesson>(
                                new BinaryOperator("Oid", lesson.Oid));
                            RegisterDetail regdetail = new RegisterDetail(objectSpace.Session)
                            {
                                Student       = currentStudent,
                                Lesson        = curLesson,
                                RegisterState = objectSpace.FindObject <RegisterState>(
                                    new BinaryOperator("Code", "SELECTED")),
                                CheckState = objectSpace.FindObject <RegisterState>(
                                    new BinaryOperator("Code", "NOTCHECKED"))
                            };
                            RuleSet ruleSet = new RuleSet();

                            RuleSetValidationResult result = ruleSet.ValidateTarget(regdetail, DefaultContexts.Save);
                            if (ValidationState.Invalid ==
                                result.GetResultItem("RegisterDetail.StudentRegLessonSemester").State)
                            {
                                if (!errorstudent.ContainsKey(currentStudent.StudentCode))
                                {
                                    errorstudent.Add(currentStudent.StudentCode, new List <string>());
                                }
                                if (!errorstudent[currentStudent.StudentCode].Contains(curLesson.Subject.SubjectCode))
                                {
                                    errorstudent[currentStudent.StudentCode].Add(curLesson.Subject.SubjectCode);
                                }
                                regdetail.Delete();
                            }
                            else
                            {
                                numregok++;
                                dicLessonCurrentRegNum[lesson.LessonName]++;
                                regdetail.Save();
                            }
                        }
                        else
                        {
                            if (!errorstudent.ContainsKey(currentStudent.StudentCode))
                            {
                                errorstudent.Add(currentStudent.StudentCode, new List <string>());
                            }
                            if (!errorstudent[currentStudent.StudentCode].Contains(lesson.Subject.SubjectCode))
                            {
                                errorstudent[currentStudent.StudentCode].Add(lesson.Subject.SubjectCode);
                            }
                        }
                    }
                }
                objectSpace.Session.CommitTransaction();
                PopUpMessage ms = objectSpace.CreateObject <PopUpMessage>();
                if (errorstudent.Count > 0)
                {
                    ms.Title   = "Có lỗi khi chọn nhóm MH đăng ký!";
                    ms.Message = string.Format("Đã chọn được cho {0} sinh viên với {1} lượt nhóm MH\r\n", dicStudentRegDetail.Count, numregok);
                    string strmessage = "Không chọn được nhóm môn học do trùng môn đã đăng ký hoặc hết chỗ: ";
                    foreach (KeyValuePair <string, List <string> > keypair in errorstudent)
                    {
                        strmessage += string.Format("Sinh viên:[{0}] - Môn:[", keypair.Key);
                        foreach (string str in keypair.Value)
                        {
                            strmessage += str + ",";
                        }
                        strmessage  = strmessage.TrimEnd(',');
                        strmessage += "]\r\n";
                    }
                    ms.Message += strmessage;
                }
                else
                {
                    ms.Title   = "Chọn nhóm MH thành công";
                    ms.Message = string.Format("Chọn nhóm MH thành công cho {0} sinh viên với {1} lượt nhóm MH\r\n", dicStudentRegDetail.Count, numregok);
                }
                ShowViewParameters svp = new ShowViewParameters();
                svp.CreatedView = Application.CreateDetailView(
                    objectSpace, ms);
                svp.TargetWindow        = TargetWindow.NewModalWindow;
                svp.CreatedView.Caption = "Thông báo";
                DialogController dc = Application.CreateController <DialogController>();
                svp.Controllers.Add(dc);

                dc.SaveOnAccept = false;
                Application.ShowViewStrategy.ShowView(svp, new ShowViewSource(null, null));
            }
        }
Exemplo n.º 40
0
        private void DialogControllerOnAccepting(object sender, DialogControllerAcceptingEventArgs args)
        {
            View view = ((DialogController)sender).Frame.View;

            SynchronizeInfo(view);
        }
Exemplo n.º 41
0
 void dc_Accepting(object sender, DialogControllerAcceptingEventArgs e)
 {
     (e.AcceptActionArgs.CurrentObject as DispTypeCreateInfo).IsAccepted = true;
 }
        void selectSemesterForClassTransactionTrackingAcception_Accepting(object sender, DialogControllerAcceptingEventArgs e)
        {
            ObjectSpace objectSpace = Application.CreateObjectSpace();
            ListView    lv          = ((ListView)((WindowController)sender).Window.View);
            Semester    semester    = lv.SelectedObjects.Count == 0 ? null : lv.SelectedObjects[0] as Semester;
            //GroupOperator classroomsOp = new GroupOperator(CriteriaOperator.Parse("1=0"));
            //ContainsOperator biOperator;
            string strParse = "";

            if (semester != null)
            {
                //NestedObjectSpace nobj= objectSpace.CreateNestedObjectSpace();
                foreach (StudentClass studentClass in View.SelectedObjects)
                {
                    ClassTransactionTracking ct = objectSpace.FindObject <ClassTransactionTracking>
                                                      (CriteriaOperator.Parse("StudentClass.ClassCode = ? and Semester.SemesterName = ?",
                                                                              studentClass.ClassCode, semester.SemesterName));
                    if (ct == null)
                    {
                        ct              = objectSpace.CreateObject <ClassTransactionTracking>();
                        ct.Semester     = objectSpace.FindObject <Semester>(CriteriaOperator.Parse("SemesterName=?", semester.SemesterName));
                        ct.StudentClass = objectSpace.FindObject <StudentClass>(CriteriaOperator.Parse("ClassCode=?", studentClass.ClassCode));
                        ct.Save();
                    }
                    //biOperator = new ContainsOperator("StudentClasses", new BinaryOperator("ClassCode", studentClass.ClassCode));
                    //classroomsOp = new GroupOperator(GroupOperatorType.Or, classroomsOp, biOperator);

                    strParse += (strParse == "" ? string.Format("StudentClass.ClassCode='{0}'", studentClass.ClassCode) :
                                 string.Format(" or StudentClass.ClassCode='{0}'", studentClass.ClassCode));
                }
                objectSpace.CommitChanges();
                ReportData reportData = objectSpace.FindObject <ReportData>(
                    new BinaryOperator("Name", "Tỉ lệ nợ lớp biên chế NHHK"));
                strParse = string.Format("({0}) and Semester.SemesterName= '{1}'", strParse, semester.SemesterName);

                ReportServiceController rsc = ((WindowController)sender).Frame.GetController <ReportServiceController>();
                rsc.ShowPreview((IReportData)reportData, CriteriaOperator.Parse(strParse)); //classroomsOp);
            }
        }
Exemplo n.º 43
0
 void DialogController_Accepting(object sender, DialogControllerAcceptingEventArgs e)
 {
     Accepting(sender, e);
 }
        void dc_Accepting_Report(object sender, DialogControllerAcceptingEventArgs e)
        {
            Controller controller = sender as Controller;
            ObjectSpace objectSpace = Application.CreateObjectSpace();
            ReportData rd = objectSpace.FindObject<ReportData>(
                new BinaryOperator("Name", "Kết quả ĐK 1 SV"));
            if (rd != null)
            {
                XafReport report = rd.LoadXtraReport(objectSpace);

                CriteriaOperator criteriaOperator = CriteriaOperator.TryParse(
                        String.Format("[Student.Oid] = '{0}'", SecuritySystem.CurrentUserId));
                Student student = objectSpace.FindObject<Student>(criteriaOperator);
                report.Filtering.Filter = criteriaOperator.ToString();
                MemoryStream stream = new MemoryStream();
                report.ExportToPdf(stream);
                if (HttpContext.Current != null)
                {

                    byte[] buffer = stream.GetBuffer();
                    string contentType = "application/pdf";
                    string contentDisposition = "attachment; filename="+ student.StudentCode +".pdf";
                    HttpContext.Current.Response.Clear();
                    HttpContext.Current.Response.Buffer = false;
                    HttpContext.Current.Response.AppendHeader("Content-Type", contentType);
                    HttpContext.Current.Response.AppendHeader("Content-Transfer-Encoding", "binary");
                    HttpContext.Current.Response.AppendHeader("Content-Disposition", contentDisposition);
                    HttpContext.Current.Response.BinaryWrite(buffer);
                    HttpContext.Current.Response.End();
                }
                else
                {
                    report.ShowPreview();
                }
                controller.Dispose();

            }
        }
 private void DialogControllerOnAccepting(object sender, DialogControllerAcceptingEventArgs args)
 {
     View view = ((DialogController) sender).Frame.View;
     SynchronizeInfo(view);
 }