public ActionResult Edit(ManageComputers model) { try { using (DSRCManagementSystemEntities1 db = new DSRCManagementSystemEntities1()) { var obj_Comp = db.computermanagements.Where(o => o.managementid == model.ID).Select(o => o).FirstOrDefault(); obj_Comp.Manufacturer = model.Manufacturer; obj_Comp.CPUID = model.CPUID; obj_Comp.MonitorID = model.MonitorID; obj_Comp.OsId = Convert.ToInt32(model.OS); obj_Comp.Memory = model.Memory; obj_Comp.cpu = model.CPU; obj_Comp.ComputerStatusNew = model.ComputerStatus; obj_Comp.ComputerName = model.ComputerName; obj_Comp.IP = model.IP; db.SaveChanges(); return(Json("Success", JsonRequestBehavior.AllowGet)); } } catch (Exception Ex) { string actionName = this.ControllerContext.RouteData.Values["action"].ToString(); string controllerName = this.ControllerContext.RouteData.Values["controller"].ToString(); ExceptionHandlingController.ExceptionDetails(Ex, actionName, controllerName); } return(Json("Success", JsonRequestBehavior.AllowGet)); }
public ActionResult AddNewComputer(ManageComputers model, string cmpname) { try { DSRCManagementSystemEntities1 db = new DSRCManagementSystemEntities1(); var Already = db.computermanagements.Where(x => x.ComputerName == model.ComputerName && x.ISDelete == false).Select(o => o).FirstOrDefault(); if (Already != null) { return(Json("Already", JsonRequestBehavior.AllowGet)); } else { if (ModelState.IsValid) { // DSRCManagementSystemEntities1 db = new DSRCManagementSystemEntities1(); if (model.ComputerStatus == "1") { model.ComputerStatus = "Active"; } else { model.ComputerStatus = "Inactive"; } var Compobj = db.computermanagements.CreateObject(); Compobj.Manufacturer = model.Manufacturer.Trim(); Compobj.CPUID = model.CPUID.Trim(); Compobj.MonitorID = model.MonitorID.Trim(); Compobj.Memory = model.Memory; Compobj.ComputerStatusNew = model.ComputerStatus; Compobj.ComputerName = model.ComputerName.Trim(); Compobj.ISDelete = false; Compobj.IP = model.IP; Compobj.cpu = model.CPU.Trim(); Compobj.OsId = model.OSID; db.computermanagements.AddObject(Compobj); db.SaveChanges(); return(Json("Success", JsonRequestBehavior.AllowGet)); } else { return(View()); } } } catch (Exception Ex) { string actionName = this.ControllerContext.RouteData.Values["action"].ToString(); string controllerName = this.ControllerContext.RouteData.Values["controller"].ToString(); ExceptionHandlingController.ExceptionDetails(Ex, actionName, controllerName); } return(View()); }
public ActionResult Edit(int ID) { DSRCManagementSystemEntities1 db = new DSRCManagementSystemEntities1(); var obj = new ManageComputers(); try{ obj = (from t in db.computermanagements where t.ISDelete == false join s in db.Master_Os on t.OsId equals s.OsId where t.managementid == ID select new ManageComputers() { OSID = s.OsId, ID = t.managementid, Manufacturer = t.Manufacturer, CPUID = t.CPUID, MonitorID = t.MonitorID, OS = s.OsName, Memory = t.Memory, CPU = t.cpu, ComputerStatus = t.ComputerStatusNew, ComputerName = t.ComputerName, IP = t.IP, }).FirstOrDefault(); if (obj.ComputerStatus == "Active") { ViewBag.ComputerStatusList = new SelectList(new[] { new { Text = "Active", Value = "Active" }, new { Text = "Inactive", Value = "Inactive" } }, "Text", "Value", obj.ComputerStatus); } else { ViewBag.ComputerStatusList = new SelectList(new[] { new { Text = "Inactive", Value = "Inactive" }, new { Text = "Active", Value = "Active" } }, "Text", "Value", obj.ComputerStatus); } var OSList = db.Master_Os.ToList(); ViewBag.OSIDList = new SelectList(OSList, "OsId", "OsName", obj.OSID); return(View(obj)); } catch (Exception Ex) { string actionName = this.ControllerContext.RouteData.Values["action"].ToString(); string controllerName = this.ControllerContext.RouteData.Values["controller"].ToString(); ExceptionHandlingController.ExceptionDetails(Ex, actionName, controllerName); } return(View(obj)); }
private void radMenuItem18_Click(object sender, EventArgs e) { ManageComputers manageComputers = new ManageComputers(); manageComputers.ShowDialog(); }
public ActionResult ManageComputers(ManageComputers model, FormCollection form) { ModelState.Clear(); DSRCManagementSystemEntities1 db = new DSRCManagementSystemEntities1(); DSRCManagementSystem.Models.ManageComputers objcmp = new DSRCManagementSystem.Models.ManageComputers(); List <DSRCManagementSystem.Models.ManageComputers> CmpList = new List <DSRCManagementSystem.Models.ManageComputers>(); try{ bool status = form["Inactive"].Contains("true"); if (status == true) { CmpList = (from c in db.computermanagements where c.ISDelete == false && c.ComputerStatusNew == "Inactive" join s in db.Master_Os on c.OsId equals s.OsId select new DSRCManagementSystem.Models.ManageComputers() { ID = c.managementid, Manufacturer = c.Manufacturer, CPUID = c.CPUID, MonitorID = c.MonitorID, OS = s.OsName, Memory = c.Memory, OSID = s.OsId, CPU = c.cpu, ComputerStatus = c.ComputerStatusNew, ComputerName = c.ComputerName, IP = c.IP, }).ToList(); var OSList = db.Master_Os.ToList(); foreach (var item in CmpList) { var Assignedlist = db.ComputerAssigneds.Where(x => x.Managementid == item.ID).FirstOrDefault(); if (Assignedlist != null) { item.Alreadyassigned = 1; } else { item.Alreadyassigned = 0; } } ViewBag.OSIDList = new SelectList(OSList, "OsId", "OsName"); var value = Convert.ToInt32(TempData["assigned"]); } else { CmpList = (from c in db.computermanagements where c.ISDelete == false && c.ComputerStatusNew == "Active" join s in db.Master_Os on c.OsId equals s.OsId select new DSRCManagementSystem.Models.ManageComputers() { ID = c.managementid, Manufacturer = c.Manufacturer, CPUID = c.CPUID, MonitorID = c.MonitorID, OS = s.OsName, Memory = c.Memory, OSID = s.OsId, CPU = c.cpu, ComputerStatus = c.ComputerStatusNew, ComputerName = c.ComputerName, IP = c.IP, }).ToList(); var OSList = db.Master_Os.ToList(); foreach (var item in CmpList) { var Assignedlist = db.ComputerAssigneds.Where(x => x.Managementid == item.ID).FirstOrDefault(); if (Assignedlist != null) { item.Alreadyassigned = 1; } else { item.Alreadyassigned = 0; } } ViewBag.OSIDList = new SelectList(OSList, "OsId", "OsName"); var value = Convert.ToInt32(TempData["assigned"]); } } catch (Exception Ex) { string actionName = this.ControllerContext.RouteData.Values["action"].ToString(); string controllerName = this.ControllerContext.RouteData.Values["controller"].ToString(); ExceptionHandlingController.ExceptionDetails(Ex, actionName, controllerName); } return(View(CmpList.ToList())); }
public ActionResult AssignComputer(AssignComputersNew model) { try { DSRCManagementSystemEntities1 db = new DSRCManagementSystemEntities1(); //var AlreadyEmp = db.ComputerAssigneds.Where(x => x.Userid == model.UserId && x.ISDelete == false).Select(o => o).FirstOrDefault(); var AlreadyComp = (from p in db.computermanagements.Where(x => x.ComputerName == model.ComputerName && x.ISDelete == false) join t in db.ComputerAssigneds on p.managementid equals t.Managementid where t.ISDelete == false select new { ComputerName = p.ComputerName, }).FirstOrDefault(); // var already = db.ComputerAssigneds.Where(x => x. == model.UserId).Select(o => o).FirstOrDefault(); //if (AlreadyEmp != null) //{ // return Json("AlreadyEmp", JsonRequestBehavior.AllowGet); //} if (AlreadyComp != null) { return(Json("AlreadyComp", JsonRequestBehavior.AllowGet)); } else { var deptid = db.Departments.FirstOrDefault(o => o.DepartmentName == model.Departmentvalue).DepartmentId; ComputerAssigned Asgobj = null; ComputerAssigned repeatcheck = db.ComputerAssigneds.Where(r => r.Managementid == model.Managementid && r.ISDelete == true).FirstOrDefault(); if (repeatcheck != null) { Asgobj = repeatcheck; db.SaveChanges(); } else { Asgobj = db.ComputerAssigneds.CreateObject(); db.ComputerAssigneds.AddObject(Asgobj); } Asgobj.Userid = model.UserId; Asgobj.Locationid = model.LocationId; Asgobj.Managementid = model.Managementid; Asgobj.Departmentid = deptid; Asgobj.pendriveAccessnew = model.Pendrive.Equals("1") ? true : false; Asgobj.WorkStation = model.WorkstationNumber.Trim(); Asgobj.ComponentId = model.ComponentId; Asgobj.UPSID = model.UPSID; Asgobj.ISDelete = false; db.SaveChanges(); var item = db.ComputerAssigneds.OrderByDescending(i => i.Assignid).FirstOrDefault(); DSRCManagementSystem.UserAssetMapping obj = new DSRCManagementSystem.UserAssetMapping(); var Rcheck = db.UserAssetMappings.Where(r => r.AssignId == item.Assignid).FirstOrDefault(); if (!string.IsNullOrEmpty(model.ComponentId)) { if (Rcheck == null) { obj.UseID = model.UserId; obj.IsActive = true; obj.AssignId = item.Assignid; obj.Component = model.ComponentId; db.UserAssetMappings.AddObject(obj); db.SaveChanges(); } else { string[] splitComponentId = model.ComponentId.ToString().Split(','); foreach (var s in splitComponentId) { if (s.Length > 0) { obj.AssetID = Convert.ToInt32(s); } } Rcheck.UseID = model.UserId; Rcheck.IsActive = true; Rcheck.AssignId = item.Assignid; Rcheck.Component = model.ComponentId; //obj.UseID = model.UserId; //obj.IsActive = true; //obj.AssignId = item.Assignid; //obj.Component = model.ComponentId; //db.UserAssetMappings.AddObject(obj); db.SaveChanges(); } } else { if (Rcheck == null) { var UserAssetObj = db.UserAssetMappings.CreateObject(); UserAssetObj.AssignId = item.Assignid; UserAssetObj.UseID = model.UserId; UserAssetObj.AssetID = null; UserAssetObj.Component = model.ComponentId; UserAssetObj.IsActive = true; db.UserAssetMappings.AddObject(UserAssetObj); } } db.SaveChanges(); ManageComputers val = new ManageComputers(); val.Alreadyassigned = 1; TempData["Assigned"] = 1; return(Json("Success", JsonRequestBehavior.AllowGet)); } } catch (Exception Ex) { string actionName = this.ControllerContext.RouteData.Values["action"].ToString(); string controllerName = this.ControllerContext.RouteData.Values["controller"].ToString(); ExceptionHandlingController.ExceptionDetails(Ex, actionName, controllerName); } return(Json("Success", JsonRequestBehavior.AllowGet)); }