Example #1
0
        public ActionResult Add(int masterRecordID, ECallMasterRecordType masterRecordType)
        {
            //# validation
            if (masterRecordID < 0)
                throw new SystemException("Invalid Entity ID");

            if (masterRecordType == ECallMasterRecordType.quotation)
                return this.Add_FromQuotation(masterRecordID);
            else if (masterRecordType == ECallMasterRecordType.maintenance)
                return this.Add_FromMaintenance(masterRecordID);
            else
                return this.Add_FromCustomer(masterRecordID);
        }
Example #2
0
        public ActionResult Edit(int id, ECallMasterRecordType masterRecordType)
        {
            ECallRecord model;

            //# validation
            if (id < 0)
                throw new SystemException("Invalid Entity ID");

            //# get old record
            var records = from e in this._db.recsys_order
                          join cd in this._db.recsys_relate_customers on e.customer_id equals cd.id into cds
                          from cd in cds.DefaultIfEmpty()
                          join c in this._db.recsys_customers on cd.customer_id equals c.id into cs
                          from c in cs.DefaultIfEmpty()
                          join u in this._db.recsys_users on e.update_user_id equals u.id into uss
                          from u in uss.DefaultIfEmpty()
                          join d1 in this._db.recsys_district on cd.district1 equals d1.id into d1s
                          from d1 in d1s.DefaultIfEmpty()
                          join d2 in this._db.recsys_district on cd.district2 equals d2.id into d2s
                          from d2 in d2s.DefaultIfEmpty()
                          join t1 in this._db.recsys_users on e.engineer_id_1 equals t1.id into t1s
                          from t1 in t1s.DefaultIfEmpty()
                          join t2 in this._db.recsys_users on e.engineer_id_2 equals t2.id into t2s
                          from t2 in t2s.DefaultIfEmpty()
                          join t3 in this._db.recsys_users on e.engineer_id_3 equals t3.id into t3s
                          from t3 in t3s.DefaultIfEmpty()
                          join t4 in this._db.recsys_users on e.engineer_id_4 equals t4.id into t4s
                          from t4 in t4s.DefaultIfEmpty()
                          join cu in this._db.recsys_users on e.call_pickup_user_id equals cu.id into cus
                          from cu in cus.DefaultIfEmpty()
                          where e.id == id
                          select
                          new
                          {
                              ECall = e,
                              CustomerData = cd,
                              masterCustomer = c,
                              UpdateUserName = u.name,
                              WorkingDistrictName = d2.name,
                              MailingDistrictName = d1.name,
                              Technician1Name = t1.name,
                              Technician2Name = t2.name,
                              Technician3Name = t3.name,
                              Technician4Name = t4.name,
                              CallPickerName = cu.name
                          };

            var record = records.FirstOrDefault();

            //# validation
            if (record == null)
                throw new RecordNotFoundException();

            model = new ECallRecord()
            {
                //# field mapping
                CompleteDate = record.ECall.completion_date.HasValue ? record.ECall.completion_date.Value.ToString("dd-MM-yyyy") : string.Empty,
                EndTimeHour = record.ECall.end_time.HasValue ? Convert.ToString(record.ECall.end_time.Value.Hours) : string.Empty,
                EndTimeMinute = record.ECall.end_time.HasValue ? Convert.ToString(record.ECall.end_time.Value.Minutes) : string.Empty,
                ActualStartTimeHour = record.ECall.actual_start_time.HasValue ? Convert.ToString(record.ECall.actual_start_time.Value.Hours) : string.Empty,///Peter
                ActualStartTimeMinute = record.ECall.actual_start_time.HasValue ? Convert.ToString(record.ECall.actual_start_time.Value.Minutes) : string.Empty,
                ActualEndTimeHour = record.ECall.actual_end_time.HasValue ? Convert.ToString(record.ECall.actual_end_time.Value.Hours) : string.Empty,///Peter
                ActualEndTimeMinute = record.ECall.actual_end_time.HasValue ? Convert.ToString(record.ECall.actual_end_time.Value.Minutes) : string.Empty,
                engineer_id_1 = record.ECall.engineer_id_1,
                engineer_id_2 = record.ECall.engineer_id_2,
                engineer_id_3 = record.ECall.engineer_id_3,
                engineer_id_4 = record.ECall.engineer_id_4,
                fault = record.ECall.fault,
                model = record.ECall.model,
                repair = record.ECall.repair,
                repair_date = record.ECall.repair_date.HasValue ? record.ECall.repair_date.Value.ToString("dd-MM-yyyy") : string.Empty,
                report = record.ECall.report,
                reviewer = record.ECall.reviewer,
                StartTimeHour = record.ECall.start_time.HasValue ? Convert.ToString(record.ECall.start_time.Value.Hours) : string.Empty,
                StartTimeMinute = record.ECall.start_time.HasValue ? Convert.ToString(record.ECall.start_time.Value.Minutes) : string.Empty,
                tc = record.ECall.tc.ToString() == "1",
                address1 = record.CustomerData.address1,
                address2 = record.CustomerData.address2,
                call_pickup_user_id = record.ECall.call_pickup_user_id,
                CallPickerName = record.CallPickerName,
                center = record.CustomerData.center,
                code = record.CustomerData.code,
                contact = record.CustomerData.contact,
                customer_code = record.CustomerData.customer_code,
                district1 = record.CustomerData.district1,
                district2 = record.CustomerData.district2,
                email = record.CustomerData.email,
                fax1 = record.CustomerData.fax1,
                fax2 = record.CustomerData.fax2,
                group_id = record.CustomerData.group_id,
                id = record.ECall.id,
                last_update = record.ECall.last_update,
                last_update_user_name = record.UpdateUserName,
                MailingDistrictName = record.MailingDistrictName,
                name = record.CustomerData.name,
                chi_name = record.CustomerData.chi_name,
                prefix = record.CustomerData.prefix,
                remark = record.CustomerData.remark,
                remark2 = record.ECall.remark,
                status = record.ECall.status,
                tel1 = record.CustomerData.tel1,
                tel2 = record.CustomerData.tel2,
                title = record.CustomerData.title.HasValue ? record.CustomerData.title.Value : 0,
                type = record.CustomerData.type.HasValue ? record.CustomerData.type.Value : 0,
                WorkingDistrictName = record.WorkingDistrictName,
                create_date = record.ECall.create_date,
                Technician1Name = record.Technician1Name,
                Technician2Name = record.Technician2Name,
                Technician3Name = record.Technician3Name,
                Technician4Name = record.Technician4Name,
                //customer_reference_number = record.CustomerData.reference_number,
                //customer_reference_number = record.CustomerData.reference_number,
                //get the newset number
                customer_reference_number = record.masterCustomer.reference_number,
                JobNumber = record.ECall.job_number,
                order_status = (int)record.ECall.order_status,

                //# settings
                SaveResult = null,
                Mode = PageMode.Edit,
                FetchRecordTime = DateTime.Now,
                MasterRecordType = masterRecordType,

                //# masters
                Districts = this._db.recsys_district
                                                        .Where(theDistrict => theDistrict.status == 1)
                                                        .OrderBy(theDistrict => theDistrict.name),
                Groups = this._db.recsys_group
                                                        .Where(theGroup => theGroup.status == 1)
                                                        .OrderBy(theGroup => theGroup.name),
                Titles = this._title,
                Statuses = this._status,
                Reviewers = this._db.recsys_users
                                                        .Where(theUser => theUser.status == 1)
                                                        .OrderBy(theUser => theUser.name)
                                                        .Select(theUser => new Reviewer()
                                                        {
                                                            ID = theUser.id,
                                                            Name = theUser.name
                                                        }),
                OrderStatuses = this._orderStatuses
            };

            return PartialView("AddEdit", model);
        }
Example #3
0
        public ActionResult DetailsEdit(int id, ECallMasterRecordType masterRecordType, 
            string appFrameSelector = "",           //# for used in Order-> index page to pass app frame Selector of the iframe
            string menuButtonSelector = ""          //# for used in Order-> index page to pass menu buttonSelector of the iframe
            )
        {
            ECallDetailsViewModel model;

            //# validation
            if (id < 0)
                throw new SystemException("Invalid Entity ID");

            model = new ECallDetailsViewModel()
            {
                id = id,
                Mode = PageMode.Edit,
                MasterRecordType = masterRecordType,
                CustomAppFrameSelector = appFrameSelector,
                CustomMenuButtonSelector = menuButtonSelector
            };

            return View("Details", model);
        }