private void FillModel(int WorkListID) { VST_WorkListBLL bll = new VST_WorkListBLL(WorkListID); if (bll.Model == null) { return; } ID = bll.Model.ID; RelateStaff = bll.Model.RelateStaff; Route = bll.Model.Route; Client = bll.Model.Client; VisitTemplate = bll.Model.Template; WorkingClassify = bll.Model.WorkingClassify; IsComplete = bll.Model.IsComplete.ToUpper() == "Y"; BeginTime = bll.Model.BeginTime; EndTime = bll.Model.EndTime; PlanID = bll.Model.PlanID; Remark = bll.Model.Remark; InsertTime = bll.Model.InsertTime; //详细工作项目 Items = new List <VisitWorkItem>(bll.Items.Count); foreach (VST_WorkItem item in bll.Items) { Items.Add(new VisitWorkItem(item)); } #region ID转名称 try { if (RelateStaff != 0) { Org_Staff s = new Org_StaffBLL(RelateStaff).Model; if (s != null) { RelateStaffName = s.RealName; } } if (Route != 0) { VST_Route r = new VST_RouteBLL(Route).Model; if (r != null) { RouteName = r.Name; } } if (Client != 0) { CM_Client c = new CM_ClientBLL(Client).Model; if (c != null) { ClientName = c.FullName; } } if (VisitTemplate != 0) { VST_VisitTemplate t = new VST_VisitTemplateBLL(VisitTemplate).Model; if (t != null) { VisitTemplateName = t.Name; } } if (WorkingClassify != 0) { Dictionary_Data dic = DictionaryBLL.GetDicCollections("VST_WorkingClassify")[WorkingClassify.ToString()]; if (dic != null) { WorkingClassifyName = dic.Name; } } } catch { } #endregion }
/// <summary> /// 新增巡店工作日志(门店拜访记录) /// </summary> /// <param name="User"></param> /// <param name="VisitWorkJson"></param> /// <returns>大于0:成功 -1:Json字符串无法解析 -2:新增拜访工作记录失败</returns> public static int VisitWorkAdd(UserInfo User, VisitWork Work) { LogWriter.WriteLog("PBMIFService.VisitWorkAdd:UserName="******",VisitWorkJson=" + JsonConvert.SerializeObject(Work)); try { VisitWork v = Work; if (v == null) return -1; //Json字符串无法解析 VST_WorkListBLL bll; if (Work.ID == 0 || new VST_WorkListBLL(Work.ID).Model == null) { bll = new VST_WorkListBLL(); bll.Model.RelateStaff = v.RelateStaff == 0 ? User.StaffID : v.RelateStaff; bll.Model.Route = v.Route; bll.Model.Client = v.Client; bll.Model.Template = v.VisitTemplate; bll.Model.WorkingClassify = v.WorkingClassify == 0 ? 1 : v.WorkingClassify; bll.Model.IsComplete = v.IsComplete ? "Y" : "N"; bll.Model.BeginTime = v.BeginTime; bll.Model.EndTime = v.EndTime; bll.Model.PlanID = v.PlanID; bll.Model.Remark = v.Remark; bll.Model.ApproveFlag = 2; bll.Model.InsertStaff = User.StaffID; } else { bll = new VST_WorkListBLL(Work.ID); bll.Model.IsComplete = v.IsComplete ? "Y" : "N"; bll.Model.EndTime = v.EndTime; bll.Model.Remark = v.Remark; } if (bll.Model.ID == 0) { int worklistid = bll.Add(); if (worklistid <= 0) return -2; //新增拜访工作记录失败 Work.ID = worklistid; } else { if (bll.Update() < 0) return -3; //更新拜访工作记录失败 } foreach (VisitWork.VisitWorkItem item in v.Items) { if (item.WorkItemID > 0) continue; VST_WorkItem detail = new VST_WorkItem(); detail.WorkList = Work.ID; if (item.ProcessCode != "") { VST_Process m = new VST_ProcessBLL(item.ProcessCode).Model; if (m != null) detail.Process = m.ID; } detail.WorkTime = item.WorkTime; detail.Remark = item.Remark; int detailid = bll.AddDetail(detail); switch (item.ProcessCode) { #region 进店详细属性 case "JD": { int JobType = 0, JudgeMode = 0; float Longitude = 0, Latitude = 0; if (item.ExtParams.ContainsKey("JobType")) int.TryParse(item.ExtParams["JobType"].ToString(), out JobType); if (item.ExtParams.ContainsKey("JudgeMode")) int.TryParse(item.ExtParams["JudgeMode"].ToString(), out JudgeMode); if (item.ExtParams.ContainsKey("Longitude")) float.TryParse(item.ExtParams["Longitude"].ToString(), out Longitude); if (item.ExtParams.ContainsKey("Latitude")) float.TryParse(item.ExtParams["Latitude"].ToString(), out Latitude); VST_WorkItem_JDBLL jdbll = new VST_WorkItem_JDBLL(); jdbll.Model.Job = detailid; jdbll.Model.JobType = JobType; jdbll.Model.JudgeMode = JudgeMode; jdbll.Model.Longitude = Longitude; jdbll.Model.Latitude = Latitude; if (item.ExtParams.ContainsKey("Remark")) jdbll.Model.Remark = item.ExtParams["Remark"].ToString(); jdbll.Add(); break; } #endregion default: break; } } return Work.ID; } catch (System.Exception err) { LogWriter.WriteLog("PBMIFService.VisitWorkAdd Exception Error!", err); return -100; } }
private void FillModel(int WorkListID) { VST_WorkListBLL bll = new VST_WorkListBLL(WorkListID); if (bll.Model == null) return; ID = bll.Model.ID; RelateStaff = bll.Model.RelateStaff; Route = bll.Model.Route; Client = bll.Model.Client; VisitTemplate = bll.Model.Template; WorkingClassify = bll.Model.WorkingClassify; IsComplete = bll.Model.IsComplete.ToUpper() == "Y"; BeginTime = bll.Model.BeginTime; EndTime = bll.Model.EndTime; PlanID = bll.Model.PlanID; Remark = bll.Model.Remark; InsertTime = bll.Model.InsertTime; //详细工作项目 Items = new List<VisitWorkItem>(bll.Items.Count); foreach (VST_WorkItem item in bll.Items) { Items.Add(new VisitWorkItem(item)); } #region ID转名称 try { if (RelateStaff != 0) { Org_Staff s = new Org_StaffBLL(RelateStaff).Model; if (s != null) RelateStaffName = s.RealName; } if (Route != 0) { VST_Route r = new VST_RouteBLL(Route).Model; if (r != null) RouteName = r.Name; } if (Client != 0) { CM_Client c = new CM_ClientBLL(Client).Model; if (c != null) ClientName = c.FullName; } if (VisitTemplate != 0) { VST_VisitTemplate t = new VST_VisitTemplateBLL(VisitTemplate).Model; if (t != null) VisitTemplateName = t.Name; } if (WorkingClassify != 0) { Dictionary_Data dic = DictionaryBLL.GetDicCollections("VST_WorkingClassify")[WorkingClassify.ToString()]; if (dic != null) WorkingClassifyName = dic.Name; } } catch { } #endregion }