コード例 #1
0
        public void AddOrderItemReport(OrderItemReport_ NewReport)
        {
            dbContext = new DbServiceProviderAppEntities();

            //Holen der maximalen Order_item_report_id:
            Guid NextId = Guid.NewGuid();

            //Umwandeln des OrderItemReport in das DB-Objekt
            order_item_report DbNewReport = new order_item_report
            {
                createdat     = DateTime.Now,
                order_item_id = NewReport.OrderItemId,
                comment       = NewReport.Comment,
                Id            = NextId
            };

            dbContext.Set <order_item_report>().Add(DbNewReport);
            dbContext.SaveChanges();

            //Umwandeln der OrderItemReportAppendix in die DB-Objekte


            foreach (OrderItemReportAppendix oima in NewReport.Appendix)
            {
                Guid AppendixId = Guid.NewGuid();
                order_item_report_appendix DbOima = new order_item_report_appendix
                {
                    Id                   = AppendixId,
                    createdat            = DateTime.Now,
                    order_item_report_id = DbNewReport.Id,
                    appendix             = oima.Picture
                };

                dbContext.Set <order_item_report_appendix>().Add(DbOima);
            }

            UpdateDataBase();
            StartSynchronisation();
        }
コード例 #2
0
        public void AddOrderItemReport(OrderItemReport NewReport)
        {
            dbContext = new DbServiceProviderAppEntities();

            //Holen der maximalen Order_item_report_id:
            int NextId = (from oim in dbContext.order_item_report
                          select oim.Id).Max() + 1;

            //Umwandeln des OrderItemReport in das DB-Objekt
            order_item_report DbNewReport = new order_item_report
            {
                report_date   = NewReport.ReportDate,
                order_item_id = NewReport.OrderItemId,
                comment       = NewReport.Comment,
                Id            = NextId
            };

            dbContext.Set <order_item_report>().Add(DbNewReport);
            dbContext.SaveChanges();

            //Umwandeln der OrderItemReportAppendix in die DB-Objekte
            foreach (OrderItemReportAppendix oima in NewReport.Appendix)
            {
                order_item_report_appendix DbOima = new order_item_report_appendix
                {
                    order_item_report_id = DbNewReport.Id,
                    appendix             = oima.Picture
                };

                dbContext.Set <order_item_report_appendix>().Add(DbOima);
            }

            //schreiben der Änderung in die spa_changes Tabelle
            dbContext.Set <spa_changes>().Add(new spa_changes {
                order_id = NewReport.OrderItemId, change_date = DateTime.Now
            });
            UpdateDataBase();
        }