Example #1
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 = FaultRepository.GetFaultById(_customFault.Id);
                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.UpdateFault(fault);
                UpdateJobs();
                MessageBox.Show("Job Updated Successfully !!!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to load form", "Error !!!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #2
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));
        }