public ActionResult Index2(string userId, string type, string SalesNo) { int typeValue = int.Parse(type); PModel model = new PModel(); model.Month = new List <KeyValueModel>(); DateTime now = DateTime.Now; model.Month.Add(new KeyValueModel() { key = now.AddMonths(-2).ToString("yyyyMM"), keyValue = now.AddMonths(-2).ToString("yyyy年MM月"), isSelected = false }); model.Month.Add(new KeyValueModel() { key = now.AddMonths(-1).ToString("yyyyMM"), keyValue = now.AddMonths(-1).ToString("yyyy年MM月"), isSelected = false }); model.Month.Add(new KeyValueModel() { key = now.ToString("yyyyMM"), keyValue = now.ToString("yyyy年MM月"), isSelected = true }); model.Month.Add(new KeyValueModel() { key = now.AddMonths(1).ToString("yyyyMM"), keyValue = now.AddMonths(1).ToString("yyyy年MM月"), isSelected = false }); model.Month.Add(new KeyValueModel() { key = now.AddMonths(2).ToString("yyyyMM"), keyValue = now.AddMonths(2).ToString("yyyy年MM月"), isSelected = false }); model.Brand = new List <KeyValueModel>(); JS5_S12_BRAND_INFOTableAdapter ad = new JS5_S12_BRAND_INFOTableAdapter(); var ents = ad.GetDataBy(); foreach (var ent in ents) { model.Brand.Add(new KeyValueModel() { key = ent.BRAND_CODE, keyValue = ent.BRAND_NAME, isSelected = false }); } model.Brand.First().isSelected = true; model.Prodect = new List <KeyValueModel>(); var ad2 = new JS5_S12_PRODUCT_TYPE_INFOTableAdapter(); var ents2 = ad2.GetDataBy(); foreach (var ent in ents2) { model.Prodect.Add(new KeyValueModel() { key = ent.ID, keyValue = ent.TREE_NODE_NAME, isSelected = false }); } model.Prodect.First().isSelected = true; marketSalesApp salesApp = new marketSalesApp(); model.UserId = userId; model.type = typeValue; model.salesCode = SalesNo; if (typeValue == 1) { model.OrgList = new List <KeyValueModel>(); var orglist = salesApp.getEmpOrgBySalesNo(SalesNo, "BUManager"); foreach (var org in orglist) { var orginfo = salesApp.getOrgInfo(org.ORG_ID); model.OrgList.Add(new KeyValueModel() { key = orginfo.id, keyValue = orginfo.MANAGE_ORG_NAME }); } model.OrgList.First().isSelected = true; ViewData["VModel"] = getdata(model.Brand.First().key, model.Prodect.First().key, now.ToString("yyyyMM"), userId, typeValue, SalesNo, model.OrgList.First().key); } else if (typeValue == 2) { model.CityList = new List <KeyValueModel>(); var orglist = salesApp.getEmpOrgBySalesNo(SalesNo, "Citymanager"); foreach (var org in orglist) { var orginfo = salesApp.getOrgInfo(org.ORG_ID); model.CityList.Add(new KeyValueModel() { key = orginfo.id, keyValue = orginfo.MANAGE_ORG_NAME }); } model.CityList.First().isSelected = true; ViewData["VModel"] = getdata(model.Brand.First().key, model.Prodect.First().key, now.ToString("yyyyMM"), userId, typeValue, SalesNo, model.CityList.First().key); } ViewData["PModel"] = model; //ViewData["ValueModel"] = model; return(View("PSIView")); }
// GET: PSI public ActionResult Index(string userId) { if (userId.Equals(null)) { return(View("_NoFunction")); } // UserRoleAd.GetDataByCode(); marketSalesApp salesApp = new marketSalesApp(); var userInfo = salesApp.getUserInfoBySalesNo(userId); if (userInfo == null) { return(View("_NoFunction")); } userId = userInfo.id; var empEntitys = salesApp.getEmpOrgBySalesNo(userInfo.SalesNo); List <string> rolues = new List <string>(); foreach (var empEnt in empEntitys) { if (!rolues.Exists(p => p.Equals(empEnt.JOB_CODE)) && (empEnt.JOB_CODE.Equals("BUManager") || empEnt.JOB_CODE.Equals("Citymanager"))) { rolues.Add(empEnt.JOB_CODE); } } int type = 1; //判断用户角色 if (rolues.Count <= 0) { return(View("_NoFunction")); } else { if (rolues.Exists(p => p.Equals("BUManager")) && rolues.Exists(p => p.Equals("Citymanager")))//表示是多角色需要进入多角色选择画面 { ViewData["userInfo"] = new userInfo() { userId = userInfo.id, salesCode = userInfo.SalesNo }; return(View("_SelectRoue")); } else if (rolues.Exists(p => p.Equals("BUManager")))//进入战区长功能 { type = 1; } else//进入城市经理功能 { type = 2; } } PModel model = new PModel(); model.Month = new List <KeyValueModel>(); DateTime now = DateTime.Now; model.Month.Add(new KeyValueModel() { key = now.AddMonths(-2).ToString("yyyyMM"), keyValue = now.AddMonths(-2).ToString("yyyy年MM月"), isSelected = false }); model.Month.Add(new KeyValueModel() { key = now.AddMonths(-1).ToString("yyyyMM"), keyValue = now.AddMonths(-1).ToString("yyyy年MM月"), isSelected = false }); model.Month.Add(new KeyValueModel() { key = now.ToString("yyyyMM"), keyValue = now.ToString("yyyy年MM月"), isSelected = true }); model.Month.Add(new KeyValueModel() { key = now.AddMonths(1).ToString("yyyyMM"), keyValue = now.AddMonths(1).ToString("yyyy年MM月"), isSelected = false }); model.Month.Add(new KeyValueModel() { key = now.AddMonths(2).ToString("yyyyMM"), keyValue = now.AddMonths(2).ToString("yyyy年MM月"), isSelected = false }); model.Brand = new List <KeyValueModel>(); JS5_S12_BRAND_INFOTableAdapter ad = new JS5_S12_BRAND_INFOTableAdapter(); var ents = ad.GetDataBy(); foreach (var ent in ents) { model.Brand.Add(new KeyValueModel() { key = ent.BRAND_CODE, keyValue = ent.BRAND_NAME, isSelected = false }); } model.Brand.First().isSelected = true; model.Prodect = new List <KeyValueModel>(); var ad2 = new JS5_S12_PRODUCT_TYPE_INFOTableAdapter(); var ents2 = ad2.GetDataBy(); foreach (var ent in ents2) { model.Prodect.Add(new KeyValueModel() { key = ent.ID, keyValue = ent.TREE_NODE_NAME, isSelected = false }); } model.Prodect.First().isSelected = true; model.UserId = userId; model.type = type; model.salesCode = userInfo.SalesNo; if (type == 1) { model.OrgList = new List <KeyValueModel>(); var orglist = salesApp.getEmpOrgBySalesNo(userInfo.SalesNo, "BUManager"); foreach (var org in orglist) { var orginfo = salesApp.getOrgInfo(org.ORG_ID); model.OrgList.Add(new KeyValueModel() { key = orginfo.id, keyValue = orginfo.MANAGE_ORG_NAME }); } model.OrgList.First().isSelected = true; ViewData["VModel"] = getdata(model.Brand.First().key, model.Prodect.First().key, now.ToString("yyyyMM"), userId, type, userInfo.SalesNo, model.OrgList.First().key); } else if (type == 2) { model.CityList = new List <KeyValueModel>(); var orglist = salesApp.getEmpOrgBySalesNo(userInfo.SalesNo, "Citymanager"); foreach (var org in orglist) { var orginfo = salesApp.getOrgInfo(org.ORG_ID); model.CityList.Add(new KeyValueModel() { key = orginfo.id, keyValue = orginfo.MANAGE_ORG_NAME }); } model.CityList.First().isSelected = true; ViewData["VModel"] = getdata(model.Brand.First().key, model.Prodect.First().key, now.ToString("yyyyMM"), userId, type, userInfo.SalesNo, model.CityList.First().key); } ViewData["PModel"] = model; //ViewData["ValueModel"] = model; return(View("PSIView")); }
private VModel getdata(string BrandValue, string ProdectValue, string MonthValue, string UserId, int type, string salesCode, string orgCode) { VModel model = new VModel(); marketSalesApp salesApp = new marketSalesApp(); //组织ID 219 //查询目标总数 model.type = type; DateTime m = DateTime.ParseExact(MonthValue, "yyyyMM", CultureInfo.CurrentCulture); if (type == 2) { string porgCode = salesApp.getOrginfoBySubId(orgCode, "BU").id; model.OrgId = orgCode; model.OrgName = salesApp.getOrgInfo(orgCode).MANAGE_ORG_NAME; model.Prodect = ProdectValue; //查找Bill单号 JS5_S12_SALES_TARGET_BILL_MTableAdapter ad = new JS5_S12_SALES_TARGET_BILL_MTableAdapter(); var totalEnts = ad.GetDataBy(salesApp.getOrginfoBySubId(porgCode, "CHANNEL").id, model.Prodect, m.ToString("yyyy/MM"), BrandValue); if (totalEnts.Count <= 0) { model.TotalTagQty = 0; model.billNo = null; } else { model.billNo = totalEnts.First().BILL_NO; JS5_S12_SALES_TARGET_BILL_DTableAdapter dad = new JS5_S12_SALES_TARGET_BILL_DTableAdapter(); model.TotalTagQty = (int)dad.QtyQuery(BrandValue, porgCode, model.Prodect, model.billNo); } model.Brand = BrandValue; JS5_S12_BRAND_INFOTableAdapter BandAd = new JS5_S12_BRAND_INFOTableAdapter(); model.BrandName = BandAd.GetDataByCode(BrandValue).First().BRAND_NAME; model.Month = MonthValue; model.MonthName = m.ToString("yyyy年MM月"); JS5_S12_PRODUCT_TYPE_INFOTableAdapter prdAd = new JS5_S12_PRODUCT_TYPE_INFOTableAdapter(); model.ProdectName = prdAd.GetDataByCode(ProdectValue).First().TREE_NODE_NAME; //查询总共已提交数量 PSIApp psiApp = new PSIApp(); var cents = psiApp.CmList(model.Prodect, MonthValue, porgCode, BrandValue); model.TotalCQty = cents.Sum(p => p.cmQty).Value;//psiApp.TotalCmQty(ProdectValue, MonthValue, model.OrgId); model.UserId = UserId; model.subModel = new List <subVModel>(); var ents = psiApp.CmList(model.Prodect, MonthValue, model.OrgId, UserId, BrandValue); model.SelfTotalTagQty = psiApp.TagList(model.Prodect, MonthValue, model.OrgId, UserId, BrandValue).Sum(p => p.totalTagQty).Value; model.SelfTotalCQty = ents.Sum(p => p.cmQty).Value;//psiApp.TotalCmQty(ProdectValue, MonthValue, model.OrgId,UserId); model.cQtyModel = new List <qtyModel>(); DateTime startDay = m; DateTime temp = m; for (int i = 0; i < 35; i++) { if (startDay.Month == temp.Month) { int isClose = 0; if (DateTime.Compare(temp, DateTime.ParseExact(DateTime.Now.ToString("yyyy-MM-dd 00:00:00"), "yyyy-MM-dd HH:mm:ss", CultureInfo.CurrentCulture)) < 0) { isClose = 1; } var ent = ents.Find(p => p.day.Value.ToString("yyyy-MM-dd").Equals(temp.ToString("yyyy-MM-dd"))); if (ent != null) { model.cQtyModel.Add(new qtyModel() { day = temp.ToString("yyyy-MM-dd"), status = ent.status.HasValue ? ent.status.Value : 0, value = ent.cmQty.Value, isClose = isClose }); } else { model.cQtyModel.Add(new qtyModel() { day = temp.ToString("yyyy-MM-dd"), status = 0, value = 0, isClose = isClose }); } } temp = temp.AddDays(1); } } else { model.OrgId = orgCode; model.OrgName = salesApp.getOrgInfo(orgCode).MANAGE_ORG_NAME; model.Prodect = ProdectValue; //查找Bill单号 JS5_S12_SALES_TARGET_BILL_MTableAdapter ad = new JS5_S12_SALES_TARGET_BILL_MTableAdapter(); var totalEnts = ad.GetDataBy(salesApp.getOrginfoBySubId(orgCode, "CHANNEL").id, model.Prodect, m.ToString("yyyy/MM"), BrandValue); if (totalEnts.Count <= 0) { model.TotalTagQty = 0; model.billNo = null; } else { model.billNo = totalEnts.First().BILL_NO; JS5_S12_SALES_TARGET_BILL_DTableAdapter dad = new JS5_S12_SALES_TARGET_BILL_DTableAdapter(); model.TotalTagQty = (int)dad.QtyQuery(BrandValue, orgCode, model.Prodect, model.billNo); } model.Brand = BrandValue; JS5_S12_BRAND_INFOTableAdapter BandAd = new JS5_S12_BRAND_INFOTableAdapter(); model.BrandName = BandAd.GetDataByCode(BrandValue).First().BRAND_NAME; model.Month = MonthValue; model.MonthName = m.ToString("yyyy年MM月"); JS5_S12_PRODUCT_TYPE_INFOTableAdapter prdAd = new JS5_S12_PRODUCT_TYPE_INFOTableAdapter(); model.ProdectName = prdAd.GetDataByCode(ProdectValue).First().TREE_NODE_NAME; //查询总共已提交数量 PSIApp psiApp = new PSIApp(); var cents = psiApp.CmList(model.Prodect, MonthValue, model.OrgId, model.Brand); model.TotalCQty = cents.Sum(p => p.cmQty).Value;//psiApp.TotalCmQty(ProdectValue, MonthValue, model.OrgId); model.UserId = UserId; model.subModel = new List <subVModel>(); //查询城市列表 //JS5_S12_SALES_MANAGE_ORG_INFOTableAdapter orgInfo = new JS5_S12_SALES_MANAGE_ORG_INFOTableAdapter(); var orgs = salesApp.getOrginfoByPCode(orgCode, "CITY"); var tagEnts = psiApp.TagList(model.Prodect, MonthValue, model.OrgId, BrandValue); foreach (var org in orgs) { var ent = cents.Where(p => p.orgId.Equals(org.id)); var tagEnt = tagEnts.Find(p => p.orgId.Equals(org.id)); var sales = salesApp.getUserInfoByOrgId(org.id); //if (sales != null) //{ var subModel = new subVModel() { cmQty = ent.Sum(p => p.cmQty).Value, tagQty = tagEnt == null ? 0 : tagEnt.totalTagQty.Value, cityCode = org.id, cityName = org.MANAGE_ORG_NAME, popCode = "", popName = "", }; if (sales != null) { subModel.popCode = sales.id; subModel.popName = sales.Name; } model.subModel.Add(subModel); //} } } return(model); }