Exemple #1
0
        public void SnDataSource_Execute_WithSystemFiles()
        {
            DestroyPlayground();

            TestEquipment.EnsureNode(_testRootPath + "/SystemFolder1");
            TestEquipment.EnsureNode(_testRootPath + "/Folder1");

            //create a datasource to query simple content
            var snds = new SenseNetDataSource {
                Query = "InTree:" + _testRootPath
            };
            var results = snds.Select(DataSourceSelectArguments.Empty);

            //expected: 2 (test root and the folder)
            Assert.AreEqual(2, results.Count());

            //include system files and folders too (switch off AutoFilters)
            snds = new SenseNetDataSource
            {
                Query    = "InTree:" + _testRootPath,
                Settings = new QuerySettings {
                    EnableAutofilters = FilterStatus.Disabled
                }
            };

            results = snds.Select(DataSourceSelectArguments.Empty);

            //expected: 3 (test root and both normal and system folder)
            Assert.AreEqual(3, results.Count());
        }
 protected void rptEquipment_ItemCommand(object source, RepeaterCommandEventArgs e)
 {
     if (e.CommandName.Equals("delete"))
     {
         LinkButton           btnDelete = (LinkButton)e.CommandSource;
         TestEquipmentService rptbso    = new TestEquipmentService();
         if (rptbso.Delete(int.Parse(((LinkButton)e.CommandSource).CommandArgument)) > 0)
         {
             BindEquipment();
         }
         else
         {
             ScriptManager.RegisterStartupScript(this, GetType(), "alert", "alert('Không xóa được. Vui lòng thử lại.');", true);
         }
     }
     else if (e.CommandName.Equals("edit"))
     {
         LinkButton           btnEdit = (LinkButton)e.CommandSource;
         TestEquipment        equip   = new TestEquipment();
         TestEquipmentService rptbso  = new TestEquipmentService();
         equip             = rptbso.FindByKey(int.Parse(((LinkButton)e.CommandSource).CommandArgument));
         hdnDetailId.Value = equip.Id.ToString();
         if (equip.Quantity > 0)
         {
             txtQuantity.Text = equip.Quantity.ToString();
         }
         //txtMeasurement.Text = equip.Measurement;
         txtEquipmentName.Text = equip.DeviceName;
         txtMadeIn.Text        = equip.MadeIn;
         ScriptManager.RegisterStartupScript(this, GetType(), "showgpkh", "ShowDialogEquipment();", true);
     }
 }
Exemple #3
0
        public TestEquipment Update(TestEquipment obj)
        {
            TestEquipmentBO testequipmentBO = new TestEquipmentBO(obj);

            testequipmentDao.Update(testequipmentBO);
            return(obj);
        }
Exemple #4
0
        public ActionResult DeleteConfirmed(int id)
        {
            TestEquipment testEquipment = db.TestEquipments.Find(id);

            db.TestEquipments.Remove(testEquipment);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemple #5
0
 public ActionResult Edit([Bind(Include = "IdTestEquipment,TestEquipmentName,TestLabId")] TestEquipment testEquipment)
 {
     if (ModelState.IsValid)
     {
         db.Entry(testEquipment).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.TestLabId = new SelectList(db.TestLabs, "IdTestLab", "TestLabName", testEquipment.TestLabId);
     return(View(testEquipment));
 }
Exemple #6
0
        public ActionResult Create([Bind(Include = "IdTestEquipment,TestEquipmentName,TestLabId")] TestEquipment testEquipment)
        {
            if (ModelState.IsValid)
            {
                db.TestEquipments.Add(testEquipment);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.TestLabId = new SelectList(db.TestLabs, "IdTestLab", "TestLabName", testEquipment.TestLabId);
            return(View(testEquipment));
        }
 public ActionResult Edit([Bind(Include = "TestEquipmentID,TestID,EquipmentID")] TestEquipment testEquipment)
 {
     if (ModelState.IsValid)
     {
         db.Entry(testEquipment).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.EquipmentID = new SelectList(db.equipment, "EquipmentID", "Description", testEquipment.EquipmentID);
     ViewBag.TestID      = new SelectList(db.test, "TestID", "TestName", testEquipment.TestID);
     return(View(testEquipment));
 }
Exemple #8
0
        // GET: TestEquipments/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TestEquipment testEquipment = db.TestEquipments.Find(id);

            if (testEquipment == null)
            {
                return(HttpNotFound());
            }
            return(View(testEquipment));
        }
Exemple #9
0
        // GET: TestEquipments/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TestEquipment testEquipment = db.TestEquipments.Find(id);

            if (testEquipment == null)
            {
                return(HttpNotFound());
            }
            ViewBag.TestLabId = new SelectList(db.TestLabs, "IdTestLab", "TestLabName", testEquipment.TestLabId);
            return(View(testEquipment));
        }
Exemple #10
0
    public void Unequip(int slotIndex)
    {
        if (currentEquipment[slotIndex] != null)
        {
            TestEquipment oldItem = currentEquipment[slotIndex];
            inventory.Add(oldItem);

            currentEquipment[slotIndex] = new TestEquipment();

            if (onEquipmentChanged != null)
            {
                onEquipmentChanged.Invoke(null, oldItem);
            }
        }
    }
        // GET: TestEquipments/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TestEquipment testEquipment = db.testequipment.Find(id);

            if (testEquipment == null)
            {
                return(HttpNotFound());
            }
            ViewBag.EquipmentID = new SelectList(db.equipment, "EquipmentID", "Description", testEquipment.EquipmentID);
            ViewBag.TestID      = new SelectList(db.test, "TestID", "TestName", testEquipment.TestID);
            return(View(testEquipment));
        }
Exemple #12
0
        public void SnDataSource_Execute_Flatten1()
        {
            DestroyPlayground();

            TestEquipment.EnsureNode(_testRootPath + "/Folder1");
            TestEquipment.EnsureNode(_testRootPath + "/Folder1/Folder2");

            //create a datasource to query simple content
            var snds = new SenseNetDataSource {
                ContentPath = _testRootPath, FlattenResults = true
            };
            var results = snds.Select(DataSourceSelectArguments.Empty);

            //expected: Top 2 folders
            Assert.AreEqual(2, results.Count());
        }
Exemple #13
0
    public void Equip(TestEquipment newItem, int slotNum)
    {
        int slotIndex = (int)newItem.equipSlot;

        TestEquipment oldItem = null;

        if (currentEquipment[slotIndex] != null)
        {
            oldItem = currentEquipment[slotIndex];
            inventory.ChangeSlot(slotNum, oldItem);
        }
        currentEquipment[slotIndex] = newItem;

        if (onEquipmentChanged != null)
        {
            onEquipmentChanged.Invoke(newItem, oldItem);
        }
    }
    protected void btnSaveEquipment_Click(object sender, EventArgs e)
    {
        TestEquipmentService testEquipmentService = new TestEquipmentService();
        TestEquipment        testEquipment        = new TestEquipment();

        testEquipment.AuditReportId = ReportId;
        testEquipment.DeviceName    = txtEquipmentName.Text.Trim();
        testEquipment.Quantity      = Convert.ToInt32(txtQuantity.Text.Trim());
        //testEquipment.Measurement = txtMeasurement.Text.Trim();
        testEquipment.MadeIn   = txtMadeIn.Text.Trim();
        testEquipment.SerialNo = txtSerialNumber.Text.Trim();

        if (hdnDetailId.Value != "" && Convert.ToInt32(hdnDetailId.Value) > 0)
        {
            testEquipment.Id = Convert.ToInt32(hdnDetailId.Value);
            if (testEquipmentService.Update(testEquipment) != null)
            {
                BindEquipment();
            }
            else
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "showgpkh", "ShowDialogEquipment();", true);
                ScriptManager.RegisterStartupScript(this, GetType(), "message", "alert('Cập nhật không thành công. Vui lòng thử lại!');", true);
            }
        }
        else
        {
            int i = testEquipmentService.Insert(testEquipment);
            if (i > 0)
            {
                BindEquipment();
            }
            else
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "showgpkh", "ShowDialogAddEquipment();", true);
                ScriptManager.RegisterStartupScript(this, GetType(), "message", "alert('Thêm mới kê hoạch không thành công. Vui lòng thử lại!');", true);
            }
        }
    }
        public async Task <IActionResult> Post([FromBody] TestEquipmentView model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var test = new TestEquipment()
            {
                TECoutry         = model.Country,
                Name             = model.Name,
                TEManufatureDate = model.ManufactureDate,
                TEModel          = model.Model,
                TEProducer       = model.Producer,
                TEWorkNumber     = model.WorkNumber
            };
            await db.TestEquipments.AddAsync(test);

            await db.SaveAsync();

            return(CreatedAtAction("Get", new { id = test.Id }, test));
        }
        protected override void ControlsToData()
        {
            if (_hardwareItemDescription == null)
            {
                _hardwareItemDescription = new TestEquipment();
            }

            base.ControlsToData();

            var testEquipment = _hardwareItemDescription as TestEquipment;

            if (testEquipment != null)
            {
                testEquipment.FacilitiesRequirements = facilitiesRequirementsControl1.FacilitiesRequirements;
                testEquipment.Switching      = switchingListControl1.Switching;
                testEquipment.Specifications = specificationsControl1.Specifications;
                testEquipment.Resources      = resourceListControl1.Resources;
                testEquipment.Capabilities   = capabilitiesControl1.Capabilities;
                testEquipment.TerminalBlocks = terminalBlockListControl1.TestEquipmentTerminalBlocks;
                testEquipment.Paths          = pathListControl1.Paths;
                testEquipment.Controllers    = controllerListControl1.Controller;
                testEquipment.Software       = softwareItemListControl.ItemsDescriptions;
            }
        }
        void TestEquipmentControl_Validating(object sender, CancelEventArgs e)
        {
            TestEquipment testEquipment = TestEquipment;

            if (testEquipment != null)
            {
                if (testEquipment.FacilitiesRequirements != null)
                {
                    var svr = new SchemaValidationResult();
                    if (!testEquipment.FacilitiesRequirements.Validate(svr))
                    {
                        tabFacilities.ToolTipText = svr.ErrorMessage;
                    }
                }
                if (testEquipment.Controllers != null)
                {
                    foreach (Controller controller in testEquipment.Controllers)
                    {
                        var svr = new SchemaValidationResult();
                        if (!controller.Validate(svr))
                        {
                            tabControllers.ToolTipText = svr.ErrorMessage;
                        }
                    }
                }
                if (testEquipment.Software != null)
                {
                    foreach (ItemDescription itemDescription in testEquipment.Software)
                    {
                        var svr = new SchemaValidationResult();
                        if (!itemDescription.Validate(svr))
                        {
                            tabSoftware.ToolTipText = svr.ErrorMessage;
                        }
                    }
                }
                if (testEquipment.Paths != null)
                {
                    foreach (Path item in testEquipment.Paths)
                    {
                        var svr = new SchemaValidationResult();
                        if (!item.Validate(svr))
                        {
                            tabPaths.ToolTipText = svr.ErrorMessage;
                        }
                    }
                }
                if (testEquipment.Specifications != null)
                {
                    var svr = new SchemaValidationResult();
                    if (!testEquipment.Specifications.Validate(svr))
                    {
                        tabSpecifications.ToolTipText = svr.ErrorMessage;
                    }
                }
                if (testEquipment.Switching != null)
                {
                    var svr = new SchemaValidationResult();
                    if (!testEquipment.Switching.Validate(svr))
                    {
                        tabSwitching.ToolTipText = svr.ErrorMessage;
                    }
                }
                if (testEquipment.Resources != null)
                {
                    foreach (Resource item in testEquipment.Resources)
                    {
                        var svr = new SchemaValidationResult();
                        if (!item.Validate(svr))
                        {
                            tabResources.ToolTipText = svr.ErrorMessage;
                        }
                    }
                }
                if (testEquipment.Capabilities != null)
                {
                    var svr = new SchemaValidationResult();
                    if (!testEquipment.Capabilities.Validate(svr))
                    {
                        tabCapabilities.ToolTipText = svr.ErrorMessage;
                    }
                }
                if (testEquipment.TerminalBlocks != null)
                {
                    var svr = new SchemaValidationResult();
                    if (!testEquipment.TerminalBlocks.Validate(svr))
                    {
                        tabTerminalBlocks.ToolTipText = svr.ErrorMessage;
                    }
                }
            }
        }
Exemple #18
0
        public int Insert(TestEquipment obj)
        {
            TestEquipmentBO testequipmentBO = new TestEquipmentBO(obj);

            return(testequipmentDao.Insert(testequipmentBO));
        }