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
        private void FrmEditJob_Load(object sender, EventArgs e)
        {
            try
            {
                Priorities    = FaultPrioritiesRepository.GetActivePriorities();
                Complexities  = FaultComplexityRepository.GetActiveComplexities();
                Companies     = CompanyRepository.GetAllActive();
                Enigineers    = UsersinfoRepository.GetAllActiveEngineers();
                UploadedFiles = FaultRepository.GetFilesByFaultId(_customFault.Id).ToList();
                var fault = FaultRepository.GetFaultById(_customFault.Id);

                ddlCompany.DataSource    = Companies;
                ddlCompany.DisplayMember = "Name";
                ddlCompany.ValueMember   = "Id";

                ddlComplexity.DataSource    = Complexities;
                ddlComplexity.DisplayMember = "Name";
                ddlComplexity.ValueMember   = "Id";

                ddlPriority.DataSource    = Priorities;
                ddlPriority.DisplayMember = "Name";
                ddlPriority.ValueMember   = "Id";


                ddlAssignedTo.DataSource    = Enigineers;
                ddlAssignedTo.DisplayMember = "Name";
                ddlAssignedTo.ValueMember   = "Id";

                txtFaultDescription.Text    = fault.FaultDescription;
                txtLocation.Text            = fault.Location;
                txtMachineDescription.Text  = fault.MachineDescription;
                ddlAssignedTo.SelectedValue = fault.AssignedTo;
                ddlCompany.SelectedValue    = fault.CompanyId;
                ddlComplexity.SelectedValue = fault.Complexity;
                ddlPriority.SelectedValue   = fault.Priority;

                dataGridView1.AutoGenerateColumns = false;
                dataGridView1.DataSource          = UploadedFiles;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to load form", "Error !!!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #3
0
        public ActionResult Edit(int id)
        {
            var model = new FaultDTO();

            try
            {
                if (TempData["Message"] != null)
                {
                    ViewBag.Message = TempData["Message"];
                    ViewBag.IsError = TempData["IsError"];
                }

                ViewBag.Priorities    = FaultPrioritiesRepository.GetActivePriorities();
                ViewBag.Complexities  = FaultComplexityRepository.GetActiveComplexities();
                ViewBag.Companies     = CompanyRepository.GetAllActive();
                ViewBag.Enigineers    = UsersinfoRepository.GetAllActiveEngineers();
                ViewBag.UploadedFiles = FaultRepository.GetFilesByFaultId(id);

                var fault = FaultRepository.GetFaultById(id);
                if (fault != null)
                {
                    model.AssignedTo       = fault.AssignedTo;
                    model.CompanyId        = fault.CompanyId;
                    model.Complexity       = fault.Complexity;
                    model.FaultDescription = fault.FaultDescription;
                    model.FaultStatus      = fault.FaultStatus;
                    model.Id                 = fault.Id;
                    model.Location           = fault.Location;
                    model.MachineDescription = fault.MachineDescription;
                    model.Priority           = fault.Priority;
                    model.StartDate          = fault.StartDate;
                    return(View(model));
                }
                TempData["Message"] = "No job exists with this Id.";
                TempData["IsError"] = true;
                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
            }
            return(View(model));
        }
Example #4
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));
        }