コード例 #1
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            cpuentry16 cpuentry16 = await db.cpuentry16.FindAsync(id);

            db.cpuentry16.Remove(cpuentry16);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
コード例 #2
0
        public async Task <ActionResult> Edit([Bind(Include = "id,asset_id,assetLocation_id,make_id,model_id,productnumber,serialnumber,assetowner,configuration,warranty,warrantyupto,remarks,lastedit,accessory_id,active")] cpuentry16 cpuentry16)
        {
            if (ModelState.IsValid)
            {
                db.Entry(cpuentry16).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(cpuentry16));
        }
コード例 #3
0
        // GET: /CPUEntry/Details/5
        public async Task <ActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            cpuentry16 cpuentry16 = await db.cpuentry16.FindAsync(id);

            if (cpuentry16 == null)
            {
                return(HttpNotFound());
            }
            return(View(cpuentry16));
        }
コード例 #4
0
        public bool ValidateandInsert(string[] cells)
        {
            cpuentry16 cpu = new cpuentry16();
            int        makeId;
            bool       flag     = false;
            bool       asset_Id = CheckDuplicate("cpuentry16", "asset_id", "S", cells[1].Trim());

            if (asset_Id)
            {
                return(false);
            }
            else
            {
                cpu.asset_id = cells[1].Trim();
                flag         = true;
            }
            bool assetLocation = CheckDuplicate("mas_assetlocation", "assetLocation", "S", cells[2].Trim());

            if (assetLocation)
            {
                cpu.assetLocation_id = cells[2].Trim();
                flag = true;
            }
            else
            {
                mas_assetLocation al = new mas_assetLocation();
                al.assetLocation = cells[2].Trim();
                al.active        = true;
                db.mas_assetlocation.Add(al);
                db.SaveChanges();
                cpu.assetLocation_id = cells[2].Trim();
            }

            bool make = CheckDuplicate("mas_make", "make", "S", cells[6].Trim());

            if (make)
            {
                makeId      = ReturnId("select Id from mas_make where make = '" + cells[6].Trim() + "'");
                cpu.make_id = makeId;
            }
            else
            {
                mas_make mak = new mas_make();
                mak.make        = cells[6].Trim();
                mak.active      = true;
                mak.accessoryId = 1;
                db.mas_make.Add(mak);
                db.SaveChanges();
                makeId      = mak.id;
                cpu.make_id = makeId;
                flag        = true;
            }
            bool model = CheckDupOnSQLString("select count(id) from mas_model where model='" + cells[3].Trim() + "' and make_id=" + makeId + "");

            if (model)
            {
                int modelId = ReturnId("select Id from mas_model where model= '" + cells[3].Trim() + "'");
                cpu.model_id = modelId;
            }
            else
            {
                mas_model mod = new mas_model();
                mod.accessoryId   = 1;
                mod.make_id       = makeId;
                mod.model         = cells[3].Trim();
                mod.configuration = cells[7].Trim();
                mod.active        = true;
                db.mas_model.Add(mod);
                db.SaveChanges();
                cpu.model_id = mod.id;
                flag         = true;
            }



            cpu.serialnumber  = cells[4].Trim();
            cpu.productnumber = cells[5].Trim();
            String config = cells[7].Replace("\"", "");

            cpu.configuration = config.Trim();

            bool owner = CheckDupOnSQLString("select count(id) from mas_owner where owner='" + cells[8].Trim() + "'");

            if (owner)
            {
                int ownerId = ReturnId("select Id from mas_owner where owner = '" + cells[8].Trim() + "'");
                cpu.assetowner = ownerId;
            }
            else
            {
                mas_owner own = new mas_owner();
                own.owner  = cells[8].Trim();
                own.active = true;
                db.mas_owner.Add(own);
                db.SaveChanges();
                cpu.assetowner = own.id;
                flag           = true;
            }

            bool classfication = CheckDupOnSQLString("select count(id) from mas_classification where classification='" + cells[9].Trim() + "'");

            if (classfication)
            {
                int classification = ReturnId("select Id from mas_classification where classification= '" + cells[9].Trim() + "'");
                cpu.classification_id = classification;
            }
            else
            {
                mas_classification clas = new mas_classification();
                clas.classification = cells[9].Trim();
                clas.active         = true;
                db.mas_classification.Add(clas);
                db.SaveChanges();
                cpu.classification_id = clas.id;
                flag = true;
            }

            bool warty;

            if (cells[10].ToString() == "Yes")
            {
                warty = true;
            }
            else
            {
                warty = false;
            }

            cpu.warranty = warty;
            if (cells[11].Trim() != "NA")
            {
                cpu.warrantyupto = Convert.ToDateTime(cells[11].Trim());
            }
            cpu.remarks  = cells[12].Trim();
            cpu.active   = true;
            cpu.lastedit = DateTime.Now;
            db.cpuentry16.Add(cpu);

            db.SaveChanges();
            return(flag);
        }