Esempio n. 1
0
        //- To get Service orders  in Service Order with History

        public List <ServiceOrder> GetServiceOrders(string inventId, string progressId, string serviceorderId, string userName)
        {
            IAXHelper           axHelper         = ObjectFactory.GetInstance <IAXHelper>();
            List <ServiceOrder> serviceOrderList = new List <ServiceOrder>();

            try
            {
                DataTable resultTable = axHelper.GetServiceOrders(inventId, progressId, serviceorderId, userName);

                string status = "";
                foreach (DataRow row in resultTable.Rows)
                {
                    ServiceOrder serviceObject = new ServiceOrder();
                    serviceObject.ServiceOrderId = row["ServiceorderId"].ToString();
                    serviceObject.Customer       = new Models.Customer(row["CustAccount"].ToString(), row["CustomerName"].ToString());
                    serviceObject.CustomerPO     = row["CustomerPO"].ToString();
                    serviceObject.Description    = row["Description"].ToString();
                    status = row["Status"].ToString();
                    serviceObject.WOClassification   = new Models.WOClassification("", row["WOClassification"].ToString());
                    serviceObject.ServiceTechnician  = new Models.ServiceTechnician(row["ServiceTechnician"].ToString(), row["ServiceTechnicianNo"].ToString());
                    serviceObject.ServiceResponsible = new Models.ServiceTechnician(row["ServiceResponsible"].ToString(), "");
                    serviceObject.ServiceOrderDate   = Convert.ToDateTime(row["EntryDate"].ToString());
                    serviceObject.WOBillingAddress   = new Models.Address(row["BillingAddress"].ToString());
                    serviceObject.WOShippingAddress  = new Models.Address(row["ShippingAddress"].ToString());

                    if (status == "0")
                    {
                        serviceObject.Status = "In Process";
                    }
                    else if (status == "1")
                    {
                        serviceObject.Status = "Posted";
                    }
                    else if (status == "2")
                    {
                        serviceObject.Status = "Canceled";
                    }
                    serviceOrderList.Add(serviceObject);
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            return(serviceOrderList);
        }
 public JsonResult ClearServiceOrderLines()
 {
     string userName;
     ServiceOrder serviceOrder = new ServiceOrder();
     ServiceOrderLine serviceOrderLine = new ServiceOrderLine();
     List<ServiceOrderLine> serviceOrderLineEmptyList = new List<ServiceOrderLine>();
     userName = User.Identity.Name.ToString().Split('\\')[1];
     try
     {
         TempData["ServiceOrderLine"] = serviceOrderLineEmptyList;
         ViewData["ServiceOrderLine"] = serviceOrderLineEmptyList;
         serviceOrderLine.ServiceOrderLineList=serviceOrderLineEmptyList;
         serviceOrder.ServiceOrderLine = serviceOrderLine;
         TempData.Keep();
     }
     catch (Exception ex)
     {
         TempData.Keep();
         ExceptionLog.LogException(ex, userName);
     }
     return Json(serviceOrder, JsonRequestBehavior.AllowGet);
 }
        private List<ServiceOrder> GetServiceOrderDetailsByServiceOrder(string siteId, string serviceOrder)
        {
            string userName = null;

            ServiceOrder serviceOrderObject = new ServiceOrder();
            List<ServiceOrder> serviceOrderList = new List<ServiceOrder>();
            string process = "-1";

            try
            {
                userName = User.Identity.Name.ToString().Split('\\')[1];
                if (!String.IsNullOrEmpty(serviceOrder))
                {
                    serviceOrderList = serviceOrderObject.GetServiceOrders(siteId, process, serviceOrder, userName);
                    if (serviceOrderList.Count > 0)
                    {
                        serviceOrderObject.CustomerPO = serviceOrderList[0].CustomerPO;
                        serviceOrderObject.Customer = new Customer("", serviceOrderList[0].Customer.CustomerName);
                        serviceOrderObject.ServiceTechnician = new ServiceTechnician(serviceOrderList[0].ServiceTechnician.ServiceTechnicianName, serviceOrderList[0].ServiceTechnician.ServiceTechnicianNo);
                        serviceOrderObject.ServiceResponsible = new ServiceTechnician(serviceOrderList[0].ServiceResponsible.ServiceTechnicianName, "");

                        serviceOrderObject.WOBillingAddress = new Address(serviceOrderList[0].WOBillingAddress.AddresswithDesc);
                        serviceOrderObject.WOShippingAddress = new Address(serviceOrderList[0].WOShippingAddress.AddresswithDesc);
                        ViewData["ServiceOrderDetailsinRepairLines"] = serviceOrderList;
                        ViewData["Technician-No"] = serviceOrderList[0].ServiceTechnician.ServiceTechnicianNo.ToString();
                        TempData["Technician-No"] = serviceOrderList[0].ServiceTechnician.ServiceTechnicianNo.ToString();
                    }

                }
                else
                {
                    serviceOrderObject.ServiceOrderList = serviceOrderList;
                    ViewData["ServiceOrderDetailsinRepairLines"] = serviceOrderObject;
                }
                TempData.Keep();
            }
            catch (Exception ex)
            {
                TempData.Keep();
                ExceptionLog.LogException(ex, userName);
            }
            return serviceOrderList;
        }
        //
        // GET: /RepairLines/
        public ActionResult RepairLines()
        {
            TempData["ServiceOrderId"] = Session["SID"];
            TempData["RepairSiteId"]=Session["SiteID"];
            RepairType repairTypeObj = new RepairType();
            string userName = User.Identity.Name.ToString().Split('\\')[1];
            try
            {

                if (HttpContext.Session != null)
                {
                    if (Session["SiteID"] == null)
                    {
                        return RedirectToAction("ServiceOrderWithHistory", "WorkOrder");
                    }
                }
                if (TempData["ServiceOrderId"] != null)
                {
                    ServiceOrderLine serviceOrderLineobj = new ServiceOrderLine();
                    repairTypeObj.ServiceOrderLine = serviceOrderLineobj;

                    SerivceOrderPartLine serviceOrderPartLineObj = new SerivceOrderPartLine();
                    IEnumerable<SerivceOrderPartLine> serviceOrderPartLineCollection = null;
                    serviceOrderPartLineCollection = serviceOrderPartLineObj.GetSerialNumberByServiceOrder(TempData["ServiceOrderId"].ToString(), userName);
                    serviceOrderPartLineObj.ServiceOrderPartLineList = new SelectList(serviceOrderPartLineCollection, "SerialNumber", "SerialNumber", null);
                    ViewData["SerialNumberList"] = serviceOrderPartLineObj.ServiceOrderPartLineList;

                    repairTypeObj.ConditionList = new SelectList(repairTypeObj.GetCondtions(userName), "ConditionId", "ConditionName", null);
                    ViewData["Condition"] = repairTypeObj.ConditionList;

                    repairTypeObj.SysmptomAreaList = new SelectList(repairTypeObj.GetSymptomArea(userName), "SymptomAreaId", "SymptomAreaName", null);
                    ViewData["SymptomArea"] = repairTypeObj.SysmptomAreaList;

                    repairTypeObj.DiagnosisAreaList = new SelectList(repairTypeObj.GetDiagnosisArea(userName), "DiagonsisAreaId", "DiagonsisAreaName", null);
                    ViewData["DiagnosisArea"] = repairTypeObj.DiagnosisAreaList;

                    repairTypeObj.ResolutionList = new SelectList(repairTypeObj.GetResolution(userName), "ResolutionId", "ResolutionName", null);
                    ViewData["Resolution"] = repairTypeObj.ResolutionList;

                    repairTypeObj.RepairStageList = new SelectList(repairTypeObj.GetRepairStages(userName), "RepairStageId", "RepairStageName", null);
                    ViewData["RepairStage"] = repairTypeObj.RepairStageList;

                    //ServiceTechnician serviceTechnician = new ServiceTechnician();
                    //serviceTechnician.ServiceTechnicianList = new SelectList(serviceTechnician.GetTechnicians(userName), "ServiceTechnicianNo", "ServiceTechnicianName", null);
                    //ViewData["ServiceTechnicianList"] = serviceTechnician.ServiceTechnicianList;

                    ServiceOrder ServiceOrder = new ServiceOrder();
                    ServiceOrder.ServiceOrderList = GetServiceOrderDetailsByServiceOrder(TempData["RepairSiteId"].ToString(), TempData["ServiceOrderId"].ToString());
                    repairTypeObj.ServiceOrders = ServiceOrder;
                    ViewData["ServiceOrderDetailsinRepairLines"] = repairTypeObj.ServiceOrders.ServiceOrderList;

                    ServiceTechnician serviceTechnician = new ServiceTechnician();
                    IEnumerable<ServiceTechnician> serviceTechnicianCollection = null;
                    serviceTechnicianCollection = serviceTechnician.GetTechnicians(userName);

                    if (!String.IsNullOrEmpty(TempData["Technician-No"].ToString()))
                    {
                        serviceTechnician.ServiceTechnicianList = new SelectList(serviceTechnicianCollection, "ServiceTechnicianNo", "ServiceTechnicianName", serviceTechnicianCollection.First<ServiceTechnician>().ServiceTechnicianNo = TempData["Technician-No"].ToString());
                    }
                    else
                    {
                        serviceTechnician.ServiceTechnicianList = new SelectList(serviceTechnicianCollection, "ServiceTechnicianNo", "ServiceTechnicianName", null);
                    }
                    ViewData["ServiceTechnicianList"] = serviceTechnician.ServiceTechnicianList;

                    //List<RepairType> RepairLineList = (new RepairType()).GetRepairLineDetails(TempData["ServiceOrderId"].ToString(), userName);
                    //repairTypeObj.RepairLineList = new SelectList(repairTypeObj.GetRepairLineDetails(TempData["ServiceOrderId"].ToString(), userName));
                    //ViewData["RepairLinesList"] = GetRepairLinesDetails(TempData["ServiceOrderId"].ToString());

                    TempData.Keep();
                }
                else
                {
                    return RedirectToAction("ServiceOrderWithHistory","WorkOrder");
                }
            }
            catch (Exception ex)
            {
                TempData.Keep();
                ExceptionLog.LogException(ex, userName);

            }
            return View(repairTypeObj);
        }
        // GET: /ServiceOrderProcess/
        public ActionResult ServiceOrderProcess()
        {
            string userName = "";
            TempData["ServiceOrderId"] = Session["SID"];
            TempData["WorkOrderSiteId"] = Session["SiteID"];
            userName = User.Identity.Name.ToString().Split('\\')[1];
            SerivceOrderPartLine serivceOrderPartLineObject = new SerivceOrderPartLine();
            ServiceOrderLine serivceOrderLineObject = new ServiceOrderLine();
            List<ServiceOrderLine> serviceOrderLineList = new List<ServiceOrderLine>();

            try
            {
                if (HttpContext.Session != null)
                {
                    if (Session["SiteID"] == null)
                    {
                        return RedirectToAction("ServiceOrderWithHistory");
                    }
                }
                if (TempData["ServiceOrderId"] != null)
                {

                    serivceOrderLineObject.ServiceOrderLineList = serviceOrderLineList;
                    serivceOrderPartLineObject.ServiceOrderLine = serivceOrderLineObject;

                    FailureCode failureCodeObject = new FailureCode();
                    IEnumerable<FailureCode> failureCodeCollection = failureCodeObject.GetFailureCode(userName);
                    failureCodeObject.FailureCodeList = new SelectList(failureCodeCollection, "FailureCodeNo", "FailureDescription", null);
                    ViewData["FailureCodeList"] = failureCodeObject.FailureCodeList;

                    PartDetails partDetails = new PartDetails();
                    partDetails.PartDetailsList = new SelectList(partDetails.GetItemNumbers(userName), "ItemNumber", "ItemNumber", null);
                    ViewData["PartNumberList"] = partDetails.PartDetailsList;

                    LineProperty LinePropertyObject = new LineProperty();
                    IEnumerable<LineProperty> LinePropertyCollection = LinePropertyObject.GetLineProperty(userName);
                    LinePropertyObject.LinePropertyList = new SelectList(LinePropertyCollection, "LinePropertyCode", "LinePropertyDescription", null);
                    ViewData["LinePropertyList"] = LinePropertyObject.LinePropertyList;

                    IEnumerable<SerivceOrderPartLine> serviceOrderPartLineCollection = null;

                    serviceOrderPartLineCollection = serivceOrderPartLineObject.GetSerialNumberByServiceOrder(TempData["ServiceOrderId"].ToString(), userName);

                    serivceOrderPartLineObject.ServiceOrderPartLineList = new SelectList(serviceOrderPartLineCollection, "ServiceObjectRelation", "SerialNumber", null);

                    ViewData["SORelationList"] = serivceOrderPartLineObject.ServiceOrderPartLineList;
                    ViewData["WorkSerialNumberList"] = serivceOrderPartLineObject.ServiceOrderPartLineList;
                    ViewData["ServiceOrderPartLines"] = GetServiceOrderPartLinesByServiceOrderID(TempData["ServiceOrderId"].ToString());

                    ServiceOrder ServiceOrder = new ServiceOrder();
                    ServiceOrder.ServiceOrderList = GetServiceOrderDetailsByServiceOrder(TempData["WorkOrderSiteId"].ToString(), TempData["ServiceOrderId"].ToString());
                    serivceOrderPartLineObject.ServiceOrders = ServiceOrder;
                    ViewData["ServiceOrderLineinProcess"] = serivceOrderPartLineObject.ServiceOrders.ServiceOrderList;

                    ServiceTechnician serviceTechnician = new ServiceTechnician();
                    IEnumerable<ServiceTechnician> serviceTechnicianCollection = null;
                    serviceTechnicianCollection=serviceTechnician.GetTechnicians(userName);

                    if (!String.IsNullOrEmpty(TempData["Technician"].ToString()))
                    {
                        serviceTechnician.ServiceTechnicianList = new SelectList(serviceTechnicianCollection, "ServiceTechnicianNo", "ServiceTechnicianName", serviceTechnicianCollection.First<ServiceTechnician>().ServiceTechnicianNo = TempData["Technician"].ToString());
                    }
                    else
                    {
                        serviceTechnician.ServiceTechnicianList = new SelectList(serviceTechnicianCollection, "ServiceTechnicianNo", "ServiceTechnicianName", null);
                    }
                    ViewData["ServiceTechnicianLoadList"] = serviceTechnician.ServiceTechnicianList;

                    Site site = new Site();
                    IEnumerable<Site> siteCollection = null;
                    siteCollection = site.GetSites(userName);
                    if (!String.IsNullOrEmpty(TempData["WorkOrderSiteId"].ToString()))
                    {
                        site.SiteList = new SelectList(siteCollection, "SiteId", "SiteName", siteCollection.First<Site>().SiteID = TempData["WorkOrderSiteId"].ToString());
                    }
                    else
                    {
                        site.SiteList = new SelectList(siteCollection, "SiteId", "SiteName", siteCollection.First<Site>().SiteID);
                    }

                    ViewData["siteList"] = site.SiteList;
                    ViewData["TranasactionTypes"] = TransactionType.GetTransactionTypes();
                    TempData.Keep();
                }
                else
                {
                   return RedirectToAction("ServiceOrderWithHistory");
                   // return View("ServiceOrderWithHistory", serivceOrderPartLineObject);
                    //throw new Exception("Select the service order number in Service Order with history page");

                }
            }
            catch (Exception ex)
            {
                TempData.Keep();
                ExceptionLog.LogException(ex, userName);
               // throw new Exception("Select the service order number in Service Order with history page");
                //return RedirectToAction("ServiceOrderWithHistory");
             //  return Json("Select the service order number in Service Order with history page",JsonRequestBehavior.AllowGet);

            }

            return View(serivceOrderPartLineObject);
        }
Esempio n. 6
0
        //- To get Service orders  in Service Order with History
        public List<ServiceOrder> GetServiceOrders(string inventId, string progressId, string serviceorderId, string userName)
        {
            IAXHelper axHelper = ObjectFactory.GetInstance<IAXHelper>();
            List<ServiceOrder> serviceOrderList = new List<ServiceOrder>();
            try
            {
                DataTable resultTable = axHelper.GetServiceOrders(inventId, progressId, serviceorderId, userName);

                string status = "";
                foreach (DataRow row in resultTable.Rows)
                {
                    ServiceOrder serviceObject = new ServiceOrder();
                    serviceObject.ServiceOrderId = row["ServiceorderId"].ToString();
                    serviceObject.Customer = new Models.Customer( row["CustAccount"].ToString(),  row["CustomerName"].ToString() );
                    serviceObject.CustomerPO = row["CustomerPO"].ToString();
                    serviceObject.Description = row["Description"].ToString();
                    status = row["Status"].ToString();
                    serviceObject.WOClassification = new Models.WOClassification("",row["WOClassification"].ToString());
                    serviceObject.ServiceTechnician = new Models.ServiceTechnician(row["ServiceTechnician"].ToString(), row["ServiceTechnicianNo"].ToString());
                    serviceObject.ServiceResponsible = new Models.ServiceTechnician(row["ServiceResponsible"].ToString(), "");
                    serviceObject.ServiceOrderDate = Convert.ToDateTime(row["EntryDate"].ToString());
                    serviceObject.WOBillingAddress = new Models.Address(row["BillingAddress"].ToString());
                    serviceObject.WOShippingAddress = new Models.Address(row["ShippingAddress"].ToString());

                    if (status == "0")
                    {
                        serviceObject.Status = "In Process";
                    }
                    else if (status == "1")
                    {
                        serviceObject.Status = "Posted";
                    }
                    else if (status == "2")
                    {
                        serviceObject.Status = "Canceled";
                    }
                    serviceOrderList.Add(serviceObject);

                }
            }
            catch (Exception e)
            {
                throw e;

            }
            return serviceOrderList;
        }
        public JsonResult GetServiceOrderLinesHistoryBySerialNumberPartNumber(ServiceOrder model, string serialNumber, string partNumber)
        {
            string userName = null;
            try
            {
                userName = User.Identity.Name.ToString().Split('\\')[1];
                if (HttpContext.Session != null)
                {
                    if (Session["SiteID"] == null)
                    {
                        return Json("SessionExpired", JsonRequestBehavior.AllowGet);
                    }
                }
                if (TempData["ServiceOrderLine"] == null)
                {
                    List<ServiceOrderLine> serviceOrderLineNewList= GetServiceOrderLinesBySerialNumberPartNumber(partNumber, serialNumber, "");
                    if (serviceOrderLineNewList.Count == 0)
                    {
                        throw new Exception("No service order lines found for the entered part number");
                    }
                    else
                    {
                        ViewData["ServiceOrderLine"] = serviceOrderLineNewList[0];
                    }
                }
                else
                {
                    List<ServiceOrderLine> serviceOrderLineExistingList = TempData["ServiceOrderLine"] as List<ServiceOrderLine>;
                    List<ServiceOrderLine> serviceOrderLineNewList = GetServiceOrderLinesBySerialNumberPartNumber(partNumber, serialNumber, "");
                    if (serviceOrderLineNewList.Count > 0)
                    {
                        if (serviceOrderLineExistingList != null)
                        {
                            serviceOrderLineExistingList.Add(serviceOrderLineNewList.First());
                        }
                        else
                        {
                            serviceOrderLineExistingList = new List<ServiceOrderLine>();
                            serviceOrderLineExistingList.Add(serviceOrderLineNewList.First());
                        }
                    }
                    else
                    {
                        throw new Exception("No service order lines found for the entered part number");
                    }
                    ViewData["ServiceOrderLine"] = serviceOrderLineExistingList;
                }
                TempData["ServiceOrderLine"] = ViewData["ServiceOrderLine"];
                TempData.Keep();
            }
            catch (Exception ex)
            {
                TempData.Keep();
                if (ex.Message != "No service order lines found for the entered part number")
                {
                    ExceptionLog.LogException(ex, userName);
                }
                throw ex;

            }
            return Json(ViewData["ServiceOrderLine"], JsonRequestBehavior.AllowGet);
        }
        public ActionResult CheckIn()
        {
            ServiceOrder serviceOrder = new ServiceOrder();
            Customer customer = new Customer();
            WOClassification woClassification = new WOClassification();
            List<WOClassification> woClassificationCollection = new List<WOClassification>();
            ServiceTechnician serviceTechnician = new ServiceTechnician();
            List<ServiceTechnician> serviceTechnicianCollection = new List<ServiceTechnician>();
            PartDetails partDetails = new PartDetails();
            List<PartDetails> partDetailsCollection = new List<PartDetails>();
            ServiceOrderLine serviceOrderLine = new ServiceOrderLine();
            List<ServiceOrderLine> serviceOrderLineList = new List<ServiceOrderLine>();
            List<Address> addressList = new List<Address>();
            string userName = null;
            userName = User.Identity.Name.ToString().Split('\\')[1];
            try
            {
                if (HttpContext.Session != null)
                {
                    if (Session["SiteID"] == null)
                    {
                        RedirectToAction("ServiceOrderWithHistory", "WorkOrder");
                    }
                }
                IEnumerable<Customer> customerCollection = customer.GetCustomers(User.Identity.Name.ToString().Split('\\')[1]);
                customer.CustomerList = new SelectList(customerCollection, "CustomerAccount", "CustomerName", null);
                serviceOrder.Customer = customer;
                ViewData["CustomerList"] = customer.CustomerList;

                woClassification.WOClassificationList = new SelectList(woClassificationCollection.AsEnumerable<WOClassification>(), "WOClassificationCode", "WOClassificationName", null);
                serviceOrder.WOClassification = woClassification;

                serviceTechnician.ServiceTechnicianList = new SelectList(serviceTechnicianCollection.AsEnumerable<ServiceTechnician>(), "ServiceTechnicianNo", "ServiceTechnicianName", null);
                serviceOrder.ServiceTechnician = serviceTechnician;
                serviceOrder.ServiceResponsible = serviceTechnician;

                partDetails.PartDetailsList = new SelectList(partDetailsCollection.AsEnumerable<PartDetails>(), "ItemNumber", "ItemNumber", null);
                ViewData["PartNumberList"] = partDetails.PartDetailsList;
                serviceOrder.PartDetails = partDetails;

                ViewData["ServiceOrderLine"] = serviceOrderLineList;
                TempData["ServiceOrderLine"] = serviceOrderLineList;

                serviceOrderLine.ServiceOrderLineList = serviceOrderLineList;
                serviceOrder.ServiceOrderLine = serviceOrderLine;
                ViewData["BillingAddress"] = addressList;
                ViewData["ShippingAddress"] = addressList;
                serviceOrder.BillingAddressList = addressList;
                serviceOrder.ShippingAddressList = addressList;

                ViewData["ServiceOrder"] = serviceOrder;
                TempData.Keep();
            }
            catch(Exception ex)
            {
                TempData.Keep();
                ExceptionLog.LogException(ex, userName);
            }

            return View(serviceOrder);
        }
        public JsonResult GetOtherDetails(string customerAccount)
        {
            WOClassification woClassification = new WOClassification();
            ServiceTechnician serviceTechnician = new ServiceTechnician();
            PartDetails partDetails = new PartDetails();
            ServiceOrder serviceOrder = new ServiceOrder();
            ServiceOrderLine serviceOrderLine = new ServiceOrderLine();
            string userName = null;
            try
            {
                if (customerAccount != null)
                {

                    userName = User.Identity.Name.ToString().Split('\\')[1];
                    List<Address> addressList = (new Address()).GetCustomerAddress(customerAccount, userName);
                    List<Address> addressShipping = (from item1 in addressList
                                                     where item1.IsShipping == "1"
                                                     select item1).ToList<Address>();
                    List<Address> addressBilling = (from item1 in addressList
                                                    where item1.IsBilling == "1"
                                                    select item1).ToList<Address>();
                    if (addressShipping.Count >= 1)
                    {
                        for (int i=0; i <= addressShipping.Count-1; i++)
                        {
                            if (i == 0)
                            {
                                addressShipping[i].IsSelected = "checked";
                            }
                            else
                            {
                                addressShipping[i].IsSelected = null;
                            }
                        }

                        serviceOrder.ShippingAddressList = addressShipping;
                    }
                    //ViewData["BillingAddress"] = addressBilling;
                    //ViewData["ShippingAddress"] = addressShipping;
                    TempData["CustomerAccount"] = customerAccount;
                    serviceOrder.BillingAddressList = addressBilling;

                    IEnumerable<WOClassification> woClassificationCollection = woClassification.GetWOClassification(User.Identity.Name.ToString().Split('\\')[1]);
                    woClassification.WOClassificationList = new SelectList(woClassificationCollection, "WOClassificationCode", "WOClassificationName", null);
                    //ViewData["WOClassificationList"] = woClassification.WOClassificationList;
                    serviceOrder.WOClassification = woClassification;
                    IEnumerable<ServiceTechnician> serviceTechnicianCollection = serviceTechnician.GetTechnicians(User.Identity.Name.ToString().Split('\\')[1]);
                    serviceTechnician.ServiceTechnicianList = new SelectList(serviceTechnicianCollection, "ServiceTechnicianNo", "ServiceTechnicianName", null);
                    //ViewData["ServiceTechnicianList"] = serviceTechnician.ServiceTechnicianList;
                    //ViewData["ServiceResponsibleList"] = serviceTechnician.ServiceTechnicianList;
                    serviceOrder.ServiceTechnician = serviceTechnician;
                    serviceOrder.ServiceResponsible = serviceTechnician;

                    IEnumerable<PartDetails> partDetailsCollection = partDetails.GetItemNumbers(User.Identity.Name.ToString().Split('\\')[1]);
                    //partDetails.PartDetailsList1 = partDetailsCollection.ToList<PartDetails>();
                    partDetails.PartDetailsList = new SelectList(partDetailsCollection, "ItemNumber", "ItemNumber", null);
                    ViewData["PartNumberList"] = partDetails.PartDetailsList;
                    serviceOrder.PartDetails = partDetails;
                    serviceOrderLine.ServiceOrderLineList = new List<ServiceOrderLine>();
                    serviceOrder.ServiceOrderLine = serviceOrderLine;
                }
                TempData.Keep();
            }
            catch (Exception ex)
            {
                TempData.Keep();
                ExceptionLog.LogException(ex, userName);
            }
            return Json(serviceOrder, JsonRequestBehavior.AllowGet);
        }
        public JsonResult CreateServiceOrder( string customerAccount, string customerPo,string addressId, string technicinanNo, string responsibleNo, string woClassification, string customerComments)
        {
            string userName = null;
            string newSerivceOrder = null;
            bool isSuccess = false;
            ServiceOrder serviceOrder = new ServiceOrder();
            ServiceOrderLine serviceOrderLine = new ServiceOrderLine();
            List<ServiceOrderLine> emptyList = new List<ServiceOrderLine>();
            try
            {
                userName = User.Identity.Name.ToString().Split('\\')[1];

                if (HttpContext.Session != null)
                {
                    if (Session["SiteID"] == null)
                    {
                        return Json("SessionExpired", JsonRequestBehavior.AllowGet);
                    }
                }
                isSuccess = serviceOrder.CreateServiceOrder(TempData["SiteId"].ToString(), customerAccount, addressId == null ? null : addressId.ToString(), customerPo, technicinanNo, responsibleNo, woClassification, customerComments, out newSerivceOrder, userName);
                if (isSuccess)
                {
                    isSuccess = serviceOrderLine.CreateServiceOrderLinesItem(newSerivceOrder, (List<ServiceOrderLine>)TempData["ServiceOrderLine"], userName);
                }
                else
                {

                }
                if (isSuccess)
                {

                    ViewData["ServiceOrderLine"] = emptyList;
                    TempData["ServiceOrderLine"] = emptyList;
                }
                TempData.Keep();
            }
            catch (Exception ex)
            {
                TempData.Keep();
                if (!isSuccess)
                {
                    ExceptionLog.LogException(ex, userName);
                    throw ex;
                }
            }
            return Json(ViewData["ServiceOrderLine"], JsonRequestBehavior.AllowGet);
        }