Example #1
0
        public ActionResult UploadFiles(FaultDTO model, HttpPostedFileBase postedfile)
        {
            ViewBag.Priorities    = FaultPrioritiesRepository.GetActivePriorities();
            ViewBag.Complexities  = FaultComplexityRepository.GetActiveComplexities();
            ViewBag.Companies     = CompanyRepository.GetAllActive();
            ViewBag.Enigineers    = UsersinfoRepository.GetAllActiveEngineers();
            ViewBag.UploadedFiles = FaultRepository.GetFilesByFaultId(model.Id);

            try
            {
                var imageLibrary = new FaultLibrary();
                if (postedfile != null)
                {
                    var filePath = SaveImage(postedfile);
                    imageLibrary.FileName     = postedfile.FileName;
                    imageLibrary.Url          = filePath;
                    imageLibrary.FaultId      = model.Id;
                    imageLibrary.ModifiedBy   = this.CurrentSession.LoggedUser.Id;
                    imageLibrary.ModifiedDate = DateTime.Now;
                    imageLibrary.CreatedDate  = DateTime.Now;
                    imageLibrary.CreatedBy    = this.CurrentSession.LoggedUser.Id;
                }

                FaultRepository.SaveFile(imageLibrary);
                TempData["Message"] = "Files uploaded successfully !!!";
                TempData["IsError"] = false;
                return(RedirectToAction("Edit", new { id = model.Id }));
            }
            catch (Exception ex)
            {
                TempData["Message"] = "Files uploaded successfully !!!";
                TempData["IsError"] = false;
            }
            return(RedirectToAction("Edit", new { id = model.Id }));
        }
Example #2
0
 private void btnUpload_Click(object sender, EventArgs e)
 {
     try
     {
         foreach (var file in uploadedFiles)
         {
             var imageLibrary = new FaultLibrary();
             imageLibrary.FileName     = file.Split('@')[0];
             imageLibrary.Url          = file.Split('@')[1];
             imageLibrary.FaultId      = _customFault.Id;
             imageLibrary.ModifiedBy   = AuthenticatedDetails.LoggedUser.Id;
             imageLibrary.ModifiedDate = DateTime.Now;
             imageLibrary.CreatedDate  = DateTime.Now;
             imageLibrary.CreatedBy    = AuthenticatedDetails.LoggedUser.Id;
             FaultRepository.SaveFile(imageLibrary);
             UploadedFiles = FaultRepository.GetFilesByFaultId(_customFault.Id).ToList();
             dataGridView1.AutoGenerateColumns = false;
             dataGridView1.DataSource          = UploadedFiles;
         }
         MessageBox.Show("Files Added Successfully !!!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     catch (Exception ex)
     {
         MessageBox.Show("Failed to load form", "Error !!!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Example #3
0
 public static int SaveFile(FaultLibrary entity)
 {
     using (var Context = new NPDEntities())
     {
         Context.Set <FaultLibrary>().Add(entity);
         return(Context.SaveChanges());
     }
 }
Example #4
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (Convert.ToInt32(ddlCompany.SelectedValue) <= 0)
                {
                    MessageBox.Show("Please select company ", "Required", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                if (string.IsNullOrEmpty(txtLocation.Text))
                {
                    MessageBox.Show("Please enter location", "Required", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                if (Convert.ToInt32(ddlPriority.SelectedValue) <= -1)
                {
                    MessageBox.Show("Please select priority ", "Required", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                if (Convert.ToInt32(ddlComplexity.SelectedValue) <= -1)
                {
                    MessageBox.Show("Please select complexity ", "Required", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                if (Convert.ToInt32(ddlAssignedTo.SelectedValue) <= 0)
                {
                    MessageBox.Show("Please select engineer ", "Required", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                var imageLibrary = new FaultLibrary();

                var fault = new Fault();
                fault.CreatedDate        = DateTime.Now;
                fault.CreatedBy          = AuthenticatedDetails.LoggedUser.Id;
                fault.Status             = 1;
                fault.CompanyId          = Convert.ToInt32(ddlCompany.SelectedValue);
                fault.Complexity         = Convert.ToInt32(ddlComplexity.SelectedValue);
                fault.FaultDescription   = txtFaultDescription.Text;
                fault.FaultStatus        = Convert.ToInt32(ddlPriority.SelectedValue) < 1 ? 0 : 1;
                fault.Location           = txtLocation.Text;
                fault.MachineDescription = txtMachineDescription.Text;
                fault.ModifiedBy         = AuthenticatedDetails.LoggedUser.Id;
                fault.ModifiedDate       = DateTime.Now;
                fault.Priority           = Convert.ToInt32(ddlPriority.SelectedValue);
                fault.StartDate          = DateTime.Now;
                fault.AssignedTo         = Convert.ToInt32(ddlAssignedTo.SelectedValue);
                fault.FaultLibraries     = new List <FaultLibrary>();

                FaultRepository.SaveFault(fault);
                MessageBox.Show("Job Added Successfully !!!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                _parent.ViewJobs();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to load form", "Error !!!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #5
0
        public ActionResult Add(FaultDTO model, HttpPostedFileBase postedfile)
        {
            ViewBag.Priorities   = FaultPrioritiesRepository.GetActivePriorities();
            ViewBag.Complexities = FaultComplexityRepository.GetActiveComplexities();
            ViewBag.Companies    = CompanyRepository.GetAllActive();
            ViewBag.Enigineers   = UsersinfoRepository.GetAllActiveEngineers();
            try
            {
                if (model.CompanyId == null || model.CompanyId <= 0)
                {
                    ViewBag.Message = "Please select company";
                    ViewBag.IsError = true;
                    return(View(model));
                }
                if (string.IsNullOrEmpty(model.Location))
                {
                    ViewBag.Message = "Please enter location name";
                    ViewBag.IsError = true;
                    return(View(model));
                }
                if (model.Priority == null)
                {
                    ViewBag.Message = "Please select priority";
                    ViewBag.IsError = true;
                    return(View(model));
                }
                if (model.Complexity == null)
                {
                    ViewBag.Message = "Please select complexity";
                    ViewBag.IsError = true;
                    return(View(model));
                }
                if (model.AssignedTo == null || model.AssignedTo <= 0)
                {
                    ViewBag.Message = "Please select an engineer";
                    ViewBag.IsError = true;
                    return(View(model));
                }
                var imageLibrary = new FaultLibrary();
                if (postedfile != null)
                {
                    var filePath = SaveImage(postedfile);
                    imageLibrary.FileName     = postedfile.FileName;
                    imageLibrary.Url          = filePath;
                    imageLibrary.ModifiedBy   = this.CurrentSession.LoggedUser.Id;
                    imageLibrary.ModifiedDate = DateTime.Now;
                    imageLibrary.CreatedDate  = DateTime.Now;
                    imageLibrary.CreatedBy    = this.CurrentSession.LoggedUser.Id;
                }
                var fault = new Fault()
                {
                    CompanyId          = model.CompanyId,
                    CreatedDate        = DateTime.Now,
                    CreatedBy          = this.CurrentSession.LoggedUser.Id,
                    Complexity         = model.Complexity,
                    FaultDescription   = model.FaultDescription,
                    FaultStatus        = model.Priority < 1 ? 0 : 1,
                    Location           = model.Location,
                    MachineDescription = model.MachineDescription,
                    ModifiedBy         = this.CurrentSession.LoggedUser.Id,
                    ModifiedDate       = DateTime.Now,
                    Priority           = model.Priority,
                    StartDate          = DateTime.Now,
                    Status             = 1,
                    AssignedTo         = model.AssignedTo,
                    FaultLibraries     = new List <FaultLibrary>()
                };
                if (!string.IsNullOrEmpty(imageLibrary.Url))
                {
                    imageLibrary.FaultId = fault.Id;
                    fault.FaultLibraries.Add(imageLibrary);
                }

                FaultRepository.SaveFault(fault);
                TempData["Message"] = "Job added successfully !!!";
                TempData["IsError"] = false;
                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                ViewBag.Message = "Failed to save job details";
                ViewBag.IsError = true;
            }
            return(View(model));
        }
Example #6
0
        public ActionResult Edit(FaultDTO model)
        {
            ViewBag.Priorities    = FaultPrioritiesRepository.GetActivePriorities();
            ViewBag.Complexities  = FaultComplexityRepository.GetActiveComplexities();
            ViewBag.Companies     = CompanyRepository.GetAllActive();
            ViewBag.Enigineers    = UsersinfoRepository.GetAllActiveEngineers();
            ViewBag.UploadedFiles = FaultRepository.GetFilesByFaultId(model.Id);

            try
            {
                if (model.CompanyId == null || model.CompanyId <= 0)
                {
                    ViewBag.Message = "Please select company";
                    ViewBag.IsError = true;
                    return(View(model));
                }
                if (string.IsNullOrEmpty(model.Location))
                {
                    ViewBag.Message = "Please enter location name";
                    ViewBag.IsError = true;
                    return(View(model));
                }
                if (model.Priority == null)
                {
                    ViewBag.Message = "Please select priority";
                    ViewBag.IsError = true;
                    return(View(model));
                }
                if (model.Complexity == null)
                {
                    ViewBag.Message = "Please select complexity";
                    ViewBag.IsError = true;
                    return(View(model));
                }
                if (model.AssignedTo == null || model.AssignedTo <= 0)
                {
                    ViewBag.Message = "Please select an engineer";
                    ViewBag.IsError = true;
                    return(View(model));
                }
                if (model.StartDate == null)
                {
                    ViewBag.Message = "Please enter start date";
                    ViewBag.IsError = true;
                    return(View(model));
                }
                var imageLibrary = new FaultLibrary();

                var fault = FaultRepository.GetFaultById(model.Id);

                fault.CompanyId          = model.CompanyId;
                fault.Complexity         = model.Complexity;
                fault.FaultDescription   = model.FaultDescription;
                fault.FaultStatus        = model.Priority < 1 ? 0 : 1;
                fault.Location           = model.Location;
                fault.MachineDescription = model.MachineDescription;
                fault.ModifiedBy         = this.CurrentSession.LoggedUser.Id;
                fault.ModifiedDate       = DateTime.Now;
                fault.Priority           = model.Priority;
                fault.StartDate          = model.StartDate;
                fault.AssignedTo         = model.AssignedTo;

                FaultRepository.UpdateFault(fault);
                TempData["Message"] = "Job added successfully !!!";
                TempData["IsError"] = false;
                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                ViewBag.Message = "Failed to save job details";
                ViewBag.IsError = true;
            }
            return(View(model));
        }