Exemplo n.º 1
0
        protected void URLPopUpControlAddMaterialForThisLocation_OnBeforePopUpOpened(object sender, EventArgs e)
        {
            SaveDataIntoDataItemFromControls();

            // create a new ledger and show this as a popup
            Material NewMat = new Material();

            NewMat.MaterialUnit = ControlObjectContext.MaterialUnitSet.First();
            NewMat.PurchaseLedgerBookingCode = ControlObjectContext.LedgerBookingCodeSet.First();;
            NewMat.SalesLedgerBookingCode    = ControlObjectContext.LedgerBookingCodeSet.First();;
            NewMat.Category                 = "Other";
            NewMat.VATPercentage            = 19;
            NewMat.Location                 = DataItem as Location;
            NewMat.Location.MaterialForDirt = NewMat;

            ControlObjectContext.AddToMaterialSet(NewMat);
            ControlObjectContext.SaveChanges(SaveOptions.DetectChangesBeforeSave);

            URLPopUpControlAddMaterialForThisLocation.URLToPopup = "webformpopup.aspx?uc=StockMaterial&Id=" + NewMat.Id.ToString();
        }