public JsonResult SaveComment(long?id, string comment) { object s = new { type = "failed", message = "Saving failed!" }; if (id == null) { return(Json(s, JsonRequestBehavior.AllowGet)); } try { if (ModelState.IsValid) { OSC_IndividualScorecard_Current oSC_IndividualScorecard_Current = db.IndividualScorecards.Find(id); oSC_IndividualScorecard_Current.Comments = comment; db.Entry(oSC_IndividualScorecard_Current).State = EntityState.Modified; db.SaveChanges(); } s = new { type = "success", message = "Successfully saved!" }; } catch (Exception ex) { s = new { type = "failed", message = "Saving failed!\nError occured:\n" + ex.Message.ToString() }; } return(Json(s, JsonRequestBehavior.AllowGet)); }
public ActionResult Create([Bind(Include = "ManagerId,PRDUserId,Name,IsActive")] OSC_Manager oSC_Manager) { #region "BTSS" string role; string user_name; try { role = Session["role"].ToString(); user_name = Session["logon_user"].ToString(); string grp_id = Session["grp_id"].ToString(); ViewBag.CanAdd = af.CanAdd(grp_id, "Team"); if (!ViewBag.CanAdd) { return(HttpNotFound()); } } catch (Exception exception) { string result = exception.Message.ToString(); return(HttpNotFound()); } #endregion "BTSS" #region "Method" if (ModelState.IsValid) { db.Managers.Add(oSC_Manager); db.SaveChanges(); return(RedirectToAction("Index")); } #endregion "Method" #region "Return" return(View(oSC_Manager)); #endregion "Return" }
public ActionResult Create([Bind(Include = "ActivityId,RepId,Month,Year,DateFrom,DateTo,Activity,NoOfHours,DateModified,ModifiedBy,NoOfDays,TeamId,IsActive")] OSC_ActivityTracker oSC_ActivityTracker) { #region "BTSS" string role; string user_name; try { role = Session["role"].ToString(); user_name = Session["logon_user"].ToString(); string grp_id = Session["grp_id"].ToString(); ViewBag.CanAdd = af.CanAdd(grp_id, "Activity Tracker"); if (!ViewBag.CanAdd) { return(HttpNotFound()); } } catch (Exception exception) { string result = exception.Message.ToString(); return(HttpNotFound()); } #endregion "BTSS" #region "AddValues" oSC_ActivityTracker.Month = Convert.ToDateTime(oSC_ActivityTracker.DateFrom).Month; oSC_ActivityTracker.Year = Convert.ToDateTime(oSC_ActivityTracker.DateFrom).Year; oSC_ActivityTracker.DateModified = DateTime.Now; oSC_ActivityTracker.ModifiedBy = user_name; oSC_ActivityTracker.IsActive = true; #endregion "AddValues" #region "Method" if (ModelState.IsValid) { db.ActivityTrackers.Add(oSC_ActivityTracker); db.SaveChanges(); return(RedirectToAction("Index")); } #endregion "Method" #region "Return" return(View(oSC_ActivityTracker)); #endregion "Return" }
public ActionResult Create([Bind(Include = "EntryId,TeamId,RepId,GainLossOccurances,GainLossAmount,CallManagementScore,ProjectResponsibility,ScheduleAdherence,Compliance,ProductAccuracy,Commitment,JHValues,CallEfficiency,Engagement,AdministrativeProcedures,Month,Year,DateUploaded,UploadedBy,IsActive,ActiveProjects,CompletedProjects,PeriodCoverage")] OSC_ManualEntry oSC_ManualEntry) { #region "BTSS" string role; string user_name; try { role = Session["role"].ToString(); user_name = Session["logon_user"].ToString(); string grp_id = Session["grp_id"].ToString(); ViewBag.CanAdd = af.CanAdd(grp_id, "Manual Entries"); if (!ViewBag.CanAdd) { return(HttpNotFound()); } } catch (Exception exception) { string result = exception.Message.ToString(); return(HttpNotFound()); } #endregion "BTSS" #region "AddValues" oSC_ManualEntry.Month = Convert.ToDateTime(oSC_ManualEntry.PeriodCoverage).Month; oSC_ManualEntry.Year = Convert.ToDateTime(oSC_ManualEntry.PeriodCoverage).Year; oSC_ManualEntry.DateUploaded = DateTime.Now; oSC_ManualEntry.UploadedBy = user_name; oSC_ManualEntry.IsActive = true; #endregion "AddValues" #region "Method" if (ModelState.IsValid) { db.ManualEntries.Add(oSC_ManualEntry); db.SaveChanges(); return(RedirectToAction("Index")); } #endregion "Method" #region "Return" return(View(oSC_ManualEntry)); #endregion "Return" }
//Create public bool Create(OSC_ImportNPT paramObj) { bool result = false; try { if (ModelState.IsValid) { db.NPT.Add(paramObj); db.SaveChanges(); result = true; } } catch (Exception ex) { _err.MessageType = "Server Error"; _err.MessageDescription = ex.Message.ToString(); return(result); } return(result); }
public ActionResult Create([Bind(Include = "DepartmentId,DepartmentName,IsActive")] OSC_Department oSC_Department) { #region "BTSS" string role; string user_name; try { role = Session["role"].ToString(); user_name = Session["logon_user"].ToString(); string grp_id = Session["grp_id"].ToString(); ViewBag.CanAdd = af.CanAdd(grp_id, "Department"); if (!ViewBag.CanAdd) { return(HttpNotFound()); } } catch (Exception exception) { string result = exception.Message.ToString(); return(HttpNotFound()); } #endregion "BTSS" #region "AddValues" oSC_Department.IsActive = true; #endregion "AddValues" #region "Method" if (ModelState.IsValid) { db.Departments.Add(oSC_Department); db.SaveChanges(); return(RedirectToAction("Index")); } #endregion "Method" #region "Return" return(View(oSC_Department)); #endregion "Return" }
public ActionResult Import([Bind(Include = "ImportId,Month,Year")] Import import, HttpPostedFileBase bip, HttpPostedFileBase biq, HttpPostedFileBase biqd, HttpPostedFileBase aiq, HttpPostedFileBase ta, HttpPostedFileBase npt) { string logon_user = Session["logon_user"].ToString(); ViewBag.Months = db.months; ViewBag.Years = db.years; #region "BIP" if (bip == null || bip.ContentLength == 0) { ViewBag.ErrorBIP = "No file selected"; } else { if (bip.FileName.EndsWith("xls") || bip.FileName.EndsWith("xlsx")) { string fname = Path.GetFileName(bip.FileName); string path = Server.MapPath("~/ImportFile/" + fname); if (System.IO.File.Exists(path)) { System.IO.File.Delete(path); } bip.SaveAs(path); ImportFiles i = new ImportFiles(); int result1 = i.ImportBIProd(path, import, DateTime.Now, logon_user); if (result1 == 1) { ViewBag.MessageBIP = "Success"; } else { ViewBag.ErrorBIP = "Failed"; } } else { ViewBag.ErrorBIP = "File type is incorrect"; } } #endregion "BIP" #region "BIQ" if (biq == null || biq.ContentLength == 0) { ViewBag.ErrorBIQ = "No file selected"; } else { if (biq.FileName.EndsWith("xls") || biq.FileName.EndsWith("xlsx")) { string fname = Path.GetFileName(biq.FileName); string path = Server.MapPath("~/ImportFile/" + fname); if (System.IO.File.Exists(path)) { System.IO.File.Delete(path); } biq.SaveAs(path); ImportFiles i = new ImportFiles(); int result2 = i.ImportBIQual(path, import, DateTime.Now, logon_user); if (result2 == 1) { ViewBag.MessageBIQ = "Success"; } else { ViewBag.ErrorBIQ = "Failed"; } } else { ViewBag.ErrorBIQ = "File type is incorrect"; } } #endregion "BIQ" #region "BIQD" if (biqd == null || biqd.ContentLength == 0) { ViewBag.ErrorBIQD = "No file selected"; } else { if (biqd.FileName.EndsWith("xls") || biqd.FileName.EndsWith("xlsx")) { string fname = Path.GetFileName(biqd.FileName); string path = Server.MapPath("~/ImportFile/" + fname); if (System.IO.File.Exists(path)) { System.IO.File.Delete(path); } biqd.SaveAs(path); ImportFiles i = new ImportFiles(); int result2 = i.ImportBIQualD(path, import, DateTime.Now, logon_user); if (result2 == 1) { ViewBag.MessageBIQD = "Success"; } else { ViewBag.ErrorBIQD = "Failed"; } } else { ViewBag.ErrorBIQD = "File type is incorrect"; } } #endregion "BIQD" #region "AIQ" if (aiq == null || aiq.ContentLength == 0) { ViewBag.ErrorAIQ = "No file selected"; } else { if (aiq.FileName.EndsWith("xls") || aiq.FileName.EndsWith("xlsx")) { string fname = Path.GetFileName(aiq.FileName); string path = Server.MapPath("~/ImportFile/" + fname); if (System.IO.File.Exists(path)) { System.IO.File.Delete(path); } aiq.SaveAs(path); #region "EXCEL" Excel.Application application = new Excel.Application(); Excel.Workbook workbook = application.Workbooks.Open(path); Excel.Worksheet worksheet = workbook.ActiveSheet; Excel.Range range = worksheet.UsedRange; List <OSC_ImportAIQ> list = new List <OSC_ImportAIQ>(); for (int row = 2; row <= range.Rows.Count; row++) { OSC_ImportAIQ obj = new OSC_ImportAIQ(); obj.Agent = ((Excel.Range)range.Cells[row, 1]).Text; obj.IntervalStaffedDuration = af.GetSecondsFormat(((Excel.Range)range.Cells[row, 2]).Text); obj.TotalPercServiceTime = Convert.ToDouble(((Excel.Range)range.Cells[row, 3]).Text); obj.TotalACDCalls = Convert.ToInt32(((Excel.Range)range.Cells[row, 4]).Text); obj.ExtInCalls = Convert.ToInt32(((Excel.Range)range.Cells[row, 5]).Text); obj.ExtInAvgActiveDur = af.GetSecondsFormat(((Excel.Range)range.Cells[row, 6]).Text); obj.ExtOutCalls = Convert.ToInt32(((Excel.Range)range.Cells[row, 7]).Text); obj.AvgExtOutActiveDur = af.GetSecondsFormat(((Excel.Range)range.Cells[row, 8]).Text); obj.ACDWrapUpTime = af.GetSecondsFormat(((Excel.Range)range.Cells[row, 9]).Text); obj.ACDTalkTime = af.GetSecondsFormat(((Excel.Range)range.Cells[row, 10]).Text); obj.ACDRingTime = af.GetSecondsFormat(((Excel.Range)range.Cells[row, 11]).Text); obj.Aux = af.GetSecondsFormat(((Excel.Range)range.Cells[row, 12]).Text); obj.AvgHoldDur = af.GetSecondsFormat(((Excel.Range)range.Cells[row, 13]).Text); obj.IntervalIdleDur = af.GetSecondsFormat(((Excel.Range)range.Cells[row, 14]).Text); obj.Transfers = Convert.ToInt32(((Excel.Range)range.Cells[row, 15]).Text); obj.HeldContacts = Convert.ToInt32(((Excel.Range)range.Cells[row, 16]).Text); obj.Redirects = Convert.ToInt32(((Excel.Range)range.Cells[row, 17]).Text); obj.Month = import.Month; obj.Year = import.Year; obj.DateUploaded = DateTime.Now; obj.UploadedBy = User.Identity.Name; list.Add(obj); } foreach (OSC_ImportAIQ obj in list) { obj.RepId = db.Representatives.Where(r => (r.AIQUserId == obj.Agent) && ((bool)r.IsCurrent)).FirstOrDefault().RepId; obj.TeamId = db.Representatives.Where(r => (r.AIQUserId == obj.Agent) && ((bool)r.IsCurrent)).FirstOrDefault().TeamId; db.AIQ.Add(obj); } try { db.SaveChanges(); ViewBag.MessageBIP = "Success"; if (System.IO.File.Exists(path)) { System.IO.File.Delete(path); } } catch (Exception ex) { ViewBag.ErrorBIP = "Error: " + ex.Message.ToString(); if (System.IO.File.Exists(path)) { System.IO.File.Delete(path); } } #endregion "EXCEL" } else { ViewBag.ErrorAIQ = "File type is incorrect"; } } #endregion "AIQ" #region "TA" if (ta == null || ta.ContentLength == 0) { ViewBag.ErrorTA = "No file selected"; } else { if (ta.FileName.EndsWith("xls") || ta.FileName.EndsWith("xlsx")) { string fname = Path.GetFileName(ta.FileName); string path = Server.MapPath("~/ImportFile/" + fname); if (System.IO.File.Exists(path)) { System.IO.File.Delete(path); } ta.SaveAs(path); #region "EXCEL" Excel.Application application = new Excel.Application(); Excel.Workbook workbook = application.Workbooks.Open(path); Excel.Worksheet worksheet = workbook.ActiveSheet; Excel.Range range = worksheet.UsedRange; List <OSC_ImportTA> list = new List <OSC_ImportTA>(); for (int row = 2; row <= range.Rows.Count; row++) { OSC_ImportTA obj = new OSC_ImportTA(); obj.AssignedId = ((Excel.Range)range.Cells[row, 1]).Text; obj.Group = ((Excel.Range)range.Cells[row, 2]).Text; obj.FirstName = ((Excel.Range)range.Cells[row, 3]).Text; obj.MiddleInt = ((Excel.Range)range.Cells[row, 4]).Text; obj.LastName = ((Excel.Range)range.Cells[row, 5]).Text; obj.CreateDateTime = ((Excel.Range)range.Cells[row, 6]).Text; obj.BusinessArea = ((Excel.Range)range.Cells[row, 7]).Text; obj.WorkType = ((Excel.Range)range.Cells[row, 8]).Text; obj.Status = ((Excel.Range)range.Cells[row, 9]).Text; obj.Queue = ((Excel.Range)range.Cells[row, 10]).Text; obj.Suspended = ((Excel.Range)range.Cells[row, 11]).Text; obj.SuspendDate = ((Excel.Range)range.Cells[row, 12]).Text; obj.UnsuspendDate = ((Excel.Range)range.Cells[row, 13]).Text; obj.LastStatusUpdate = ((Excel.Range)range.Cells[row, 14]).Text; obj.Account = ((Excel.Range)range.Cells[row, 15]).Text; obj.GAC = ((Excel.Range)range.Cells[row, 16]).Text; obj.Assoc = ((Excel.Range)range.Cells[row, 17]).Text; obj.Certificate = ((Excel.Range)range.Cells[row, 18]).Text; obj.CheckAmount = ((Excel.Range)range.Cells[row, 19]).Text; obj.First_Name = ((Excel.Range)range.Cells[row, 20]).Text; obj.Last_Name = ((Excel.Range)range.Cells[row, 21]).Text; obj.CustomerNo = ((Excel.Range)range.Cells[row, 22]).Text; obj.ProductType = ((Excel.Range)range.Cells[row, 23]).Text; obj.AdminSystem = ((Excel.Range)range.Cells[row, 24]).Text; obj.CheckAmountTotal = ((Excel.Range)range.Cells[row, 25]).Text; obj.UCIVendorMatchDate = ((Excel.Range)range.Cells[row, 26]).Text; obj.ReasonCodeForAdv = ((Excel.Range)range.Cells[row, 27]).Text; obj.ReasonDescription = ((Excel.Range)range.Cells[row, 28]).Text; obj.TinSourceType = ((Excel.Range)range.Cells[row, 29]).Text; obj.SSBusinessUnit = ((Excel.Range)range.Cells[row, 30]).Text; obj.Month = import.Month; obj.Year = import.Year; obj.DateUploaded = DateTime.Now; obj.UploadedBy = User.Identity.Name; list.Add(obj); } foreach (OSC_ImportTA obj in list) { if (Convert.ToDateTime(obj.CreateDateTime).Month == obj.Month) { obj.RepId = db.Representatives.Where(r => (r.PRDUserId == obj.AssignedId) && ((bool)r.IsCurrent)).FirstOrDefault().RepId; obj.TeamId = af.GetTeamIdByGroupId(obj.Group, "BI").TeamId; db.TA.Add(obj); } } try { db.SaveChanges(); ViewBag.MessageBIP = "Success"; if (System.IO.File.Exists(path)) { System.IO.File.Delete(path); } } catch (Exception ex) { ViewBag.ErrorBIP = "Error: " + ex.Message.ToString(); if (System.IO.File.Exists(path)) { System.IO.File.Delete(path); } } #endregion "EXCEL" } else { ViewBag.ErrorTA = "File type is incorrect"; } } #endregion "TA" #region "NPT" if (npt == null || npt.ContentLength == 0) { ViewBag.ErrorNPT = "No file selected"; } else { if (npt.FileName.EndsWith("xls") || npt.FileName.EndsWith("xlsx")) { string fname = Path.GetFileName(npt.FileName); string path = Server.MapPath("~/ImportFile/" + fname); if (System.IO.File.Exists(path)) { System.IO.File.Delete(path); } npt.SaveAs(path); #region "EXCEL" Excel.Application application = new Excel.Application(); Excel.Workbook workbook = application.Workbooks.Open(path); Excel.Worksheet worksheet = workbook.ActiveSheet; Excel.Range range = worksheet.UsedRange; List <OSC_ImportNPT> list = new List <OSC_ImportNPT>(); for (int row = 2; row <= range.Rows.Count; row++) { OSC_ImportNPT obj = new OSC_ImportNPT(); obj.Activity = ((Excel.Range)range.Cells[row, 1]).Text; obj.DateOfActivity = Convert.ToDateTime(((Excel.Range)range.Cells[row, 2]).Text); obj.TimeSpent = Convert.ToDouble(((Excel.Range)range.Cells[row, 3]).Text) * 60; obj.TypeOfActivity = ((Excel.Range)range.Cells[row, 4]).Text; obj.CreatedBy = ((Excel.Range)range.Cells[row, 5]).Text; obj.ItemType = ((Excel.Range)range.Cells[row, 6]).Text; obj.Path = ((Excel.Range)range.Cells[row, 7]).Text; obj.Month = import.Month; obj.Year = import.Year; obj.DateUploaded = DateTime.Now; obj.UploadedBy = User.Identity.Name; obj.Source = "Import"; list.Add(obj); } foreach (OSC_ImportNPT obj in list) { if (Convert.ToDateTime(obj.DateOfActivity).Month == obj.Month) { obj.RepId = db.Representatives.Where(r => (r.LastName + ", " + r.FirstName == obj.CreatedBy) && ((bool)r.IsCurrent)).FirstOrDefault().RepId; obj.TeamId = db.Representatives.Where(r => (r.LastName + ", " + r.FirstName == obj.CreatedBy) && ((bool)r.IsCurrent)).FirstOrDefault().TeamId; db.NPT.Add(obj); } } try { db.SaveChanges(); ViewBag.MessageBIP = "Success"; if (System.IO.File.Exists(path)) { System.IO.File.Delete(path); } } catch (Exception ex) { ViewBag.ErrorBIP = "Error: " + ex.Message.ToString(); if (System.IO.File.Exists(path)) { System.IO.File.Delete(path); } } #endregion "EXCEL" } else { ViewBag.ErrorNPT = "File type is incorrect"; } } #endregion "NPT" return(View("Index")); }