public async Task <ActionResult> DeleteConfirmed(int id) { keyboardentry16 keyboardentry16 = await db.keyboardentry16.FindAsync(id); db.keyboardentry16.Remove(keyboardentry16); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task <ActionResult> Edit([Bind(Include = "id,asset_id,assetLocation_id,make_id,model_id,productnumber,serialnumber,assetowner,Type,classification_id,warranty,warrantyupto,remarks,lastedit,active")] keyboardentry16 keyboardentry16) { if (ModelState.IsValid) { db.Entry(keyboardentry16).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(keyboardentry16)); }
// GET: /Keyboard/Delete/5 public async Task <ActionResult> Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } keyboardentry16 keyboardentry16 = await db.keyboardentry16.FindAsync(id); if (keyboardentry16 == null) { return(HttpNotFound()); } return(View(keyboardentry16)); }
public bool ValidateandInsert(string[] cells) { keyboardentry16 monitor = new keyboardentry16(); int makeId; bool flag = false; bool asset_Id = CheckDuplicate("keyboardentry16", "asset_id", "S", cells[1].Trim()); if (asset_Id) { return(false); } else { monitor.asset_id = cells[1].Trim(); flag = true; } bool assetLocation = CheckDuplicate("mas_assetlocation", "assetLocation", "S", cells[2].Trim()); if (assetLocation) { monitor.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(); monitor.assetLocation_id = cells[2].Trim(); } bool make = CheckDupOnSQLString("select count(Id) from mas_make where make = '" + cells[3].Trim() + "' and accessoryId = (select id from mas_accessory where accessory = 'KEYBOARD')"); if (make) { makeId = ReturnId("select Id from mas_make where make = '" + cells[3].Trim() + "' and accessoryId = (select id from mas_accessory where accessory = 'KEYBOARD')"); monitor.make_id = makeId; //Convert.ToInt32(db.mas_make.Where(i => i.make.Contains(cells[6].Trim())).Where(i=>i.accessoryId=).Select(i => i.id).FirstOrDefault()); } else { mas_make mak = new mas_make(); mak.make = cells[3].Trim(); mak.active = true; mak.accessoryId = Convert.ToInt32(db.mas_Accessory.Where(i => i.accessory == "KEYBOARD").Select(i => i.id).FirstOrDefault()); db.mas_make.Add(mak); db.SaveChanges(); makeId = mak.id; monitor.make_id = makeId; flag = true; } bool model = CheckDupOnSQLString("select count(id) from mas_model where model='" + cells[4].Trim() + "' and make_id=" + makeId + ""); if (model) { int modelId = ReturnId("select Id from mas_model where model= '" + cells[4].Trim() + "' AND make_id =" + makeId + ""); monitor.model_id = modelId; } else { mas_model mod = new mas_model(); mod.accessoryId = Convert.ToInt32(db.mas_Accessory.Where(i => i.accessory == "KEYBOARD").Select(i => i.id).FirstOrDefault()); mod.make_id = makeId; mod.model = cells[4].Trim(); //mod.configuration = cells[7].Trim(); mod.active = true; db.mas_model.Add(mod); db.SaveChanges(); monitor.model_id = mod.id; flag = true; } monitor.serialnumber = cells[5].Trim(); monitor.productnumber = cells[6].Trim(); monitor.Type = cells[7].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() + "'"); monitor.assetowner = ownerId; } else { mas_owner own = new mas_owner(); own.owner = cells[8].Trim(); own.active = true; db.mas_owner.Add(own); db.SaveChanges(); monitor.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() + "'"); monitor.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(); monitor.classification_id = clas.id; flag = true; } bool warty; if (cells[10].ToString() == "Yes") { warty = true; } else { warty = false; } monitor.warranty = warty; //if (cells[11].Trim() != "NA" && cells[11].Trim() != null) //{ // monitor.warrantyupto = Convert.ToDateTime(cells[11].Trim()); //} monitor.remarks = cells[11].Trim(); monitor.active = true; monitor.lastedit = DateTime.Now; db.keyboardentry16.Add(monitor); db.SaveChanges(); return(flag); }