//获取完成合同的详细数据 public ActionResult GetWinHeTongData() { var id = Request["id"] == null ? 0 : int.Parse(Request["id"]); if (id == 0) { return(Json(new { ret = "no" }, JsonRequestBehavior.AllowGet)); } var temp = T_BaoJiaToPService.LoadEntities(x => x.id == id).FirstOrDefault(); string XiangMuName = temp.KHComname; string HanShuiStr = temp.HanShuiID == null ? "" : temp.T_BoolItem.str; string bak = temp.T_WinBak.FirstOrDefault() == null?"":temp.T_WinBak.FirstOrDefault().Bak; var mmp = from a in temp.YXB_Baojia select new { ID = a.id, CPname = a.T_ChanPinName.MyTexts, CpXingHao = a.T_ChanPinName1.MyTexts, CpMoney = a.WinMoney, WinYunFei = a.WinYunFei, BaoJiaMoney = a.BaoJiaMoney, CPShuLiang = a.CPShuLiang, BaoJiaYunFei = a.BaoJiaYunFei, Remark = a.Remark, Cpdengji = a.T_ChanPinName11.MyTexts }; return(Json(new { ret = "ok", temp = mmp, XiangMuName = XiangMuName, HanShuiStr = HanShuiStr, bak = bak }, JsonRequestBehavior.AllowGet)); }
//获取要修改的信息数据 public ActionResult EditBaoJiaTop() { var editid = Convert.ToInt64(Request["khid"]); var emp = T_BaoJiaToPService.LoadEntities(x => x.id == editid); var temp = from a in emp select new { BaoJiaID = a.id, HanShuiID = a.HanShuiID, GhTime = a.GhTime, Addess = a.Addess, Kh_List_id = a.Kh_List_id, KHComname = a.KHComname, JieShuanFanShi = a.JieShuanFanShi, DaiBanYunShu = a.DaiBanYunShu, JiShuYaoQiu = a.JiShuYaoQiu, HeTongQianDing = a.HeTongQianDing, HanshuiStr = a.T_BoolItem.str, PiaoJuID = a.PiaoJuID, stoptime = a.StopTime }; var arraddess = temp.ToList()[0].Addess.Split(','); return(Json(new { ret = "ok", temp = temp, Province = arraddess[0], City = arraddess[1], Village = arraddess[2] }, JsonRequestBehavior.AllowGet)); // var ifture= YXB_BaojiaService.LoadEntities(x => x.BaoJiaTop_id == editid).DefaultIfEmpty(); //if (ifture.First() == null) //{ //} //else //{ // return Json(new { ret = "no" }, JsonRequestBehavior.AllowGet); //} }
private string addBaoJiaTOP(T_BaoJiaToP tbop, ref long ThisAddId, bool Bl, ref string msg) { string ret; if (Bl) { var editid = Convert.ToInt64(Request["editID"]); tbop = T_BaoJiaToPService.LoadEntities(x => x.id == editid).FirstOrDefault(); tbop.GhTime = Convert.ToDateTime(Request["GhTime"]); } else { tbop.DelFlag = delFlag; tbop.AddTime = MvcApplication.GetT_time(); string Ttime = Request["GhTime"]; var tsplit = Ttime.Split('/'); tbop.GhTime = new DateTime(int.Parse(tsplit[2]), int.Parse(tsplit[1]), int.Parse(tsplit[0])); } tbop.Kh_List_id = Request["khidselect"] != null?int.Parse(Request["khidselect"]) : 0; tbop.DaiBanYunShu = Request["DaiBanYunShu"]; tbop.HeTongQianDing = Request["HeTongQianDing"]; tbop.JieShuanFanShi = Request["JieShuanFanShi"]; tbop.JiShuYaoQiu = Request["JiShuYaoQiu"]; tbop.KHComname = Request["KHComname"]; tbop.HanShuiID = int.Parse(Request["HanShuiID"]); tbop.PiaoJuID = int.Parse(Request["PiaojiuID"]); string Addess = Request["Province"].ToString() + "," + Request["City"].ToString() + "," + Request["Village"].ToString(); tbop.Addess = Addess; try { if (Bl) { T_BaoJiaToPService.EditEntity(tbop); ThisAddId = tbop.id; msg = "修改成功!"; } else { T_BaoJiaToPService.AddEntity(tbop); var ThisAddId_list = YXB_Kh_listService.LoadEntities(x => x.id == tbop.Kh_List_id).FirstOrDefault(); ThisAddId = ThisAddId_list.T_BaoJiaToP.Max(x => x.id); msg = "添加成功,请继续添加产品信息!"; } ret = "ok"; } catch (Exception ex) { ret = ex.ToString(); } return(ret); }
//完成合同 public ActionResult OverHeTongt() { int pageIndex = Request["page"] != null?int.Parse(Request["page"]) : 1; int pageSize = Request["rows"] != null?int.Parse(Request["rows"]) : 25; int TotalCount = 0; var Tbjtop = T_BaoJiaToPService.LoadEntities(a => a.DelFlag == 0 && a.YXB_Baojia.All(x => x.WIN == 0)).DefaultIfEmpty().ToList(); List <T_BaoJiaToP> tbjp = new List <T_BaoJiaToP>(); foreach (var t in Tbjtop) { if (t == null) { List <SlcClass> lscs = new List <SlcClass>(); return(Json(new { rows = lscs, total = TotalCount }, JsonRequestBehavior.AllowGet)); } if (t.YXB_Baojia.All(x => x.BaoJiaMoney != null) && t.YXB_Baojia.Count > 0) { tbjp.Add(t); } } var temp = from a in tbjp select new SlcClass { ID = a.id, JiShuYaoQiu = a.JiShuYaoQiu, Addess = a.Addess, DaiBanYunShu = a.DaiBanYunShu, JieShuanFanShi = a.JieShuanFanShi, HeTongQianDing = a.HeTongQianDing, TOPaddtime = a.AddTime, KHname = a.YXB_Kh_list.KHname, KHComname = a.KHComname, KHperson = a.YXB_Kh_list.KHperson, KHfaren = a.YXB_Kh_list.KHfaren, KHzhiwu = a.YXB_Kh_list.KHzhiwu, KHphoto = a.YXB_Kh_list.KHphoto, NewTime = a.YXB_Kh_list.NewTime, UName = a.YXB_Kh_list.UserInfo.UName, Denjiu = a.T_YSItems.MyText }; var templist = temp.ToList(); for (int i = 0; i < templist.Count; i++) { templist[i].Addess = ArrF(templist[i].Addess); } return(Json(new { rows = templist, total = TotalCount }, JsonRequestBehavior.AllowGet)); }
//查询月总汇 public ActionResult GetMonthSumData() { var Utime = Convert.ToDateTime(Request["Utime"]); var Dtime = Convert.ToDateTime(Request["Dtime"]); List <Month> retMonth = new List <Month>(); var oldtemp = T_BaoJiaToPService.LoadEntities(x => x.AddTime < Utime); if (T_BaoJiaToPService.LoadEntities(x => x.AddTime < Utime).FirstOrDefault() == null) { retMonth.Add(new Month { ID = 0, WinCount = 0, LostCount = 0, DaiDingCount = 0, SumCount = 0, WinDML = 0, lostDML = 0, DdDml = 0, SumDMLCount = 0 }); } else { retMonth.Add(GetMonthVar(oldtemp, 0, 0)); } //获取成功失败原因列表 var yyItem = T_YSItemsService.LoadEntities(x => x.Items == 1 && x.ID != 1); List <Items>[] Rlis = new List <Items> [2]; Rlis[0] = AddList(yyItem, oldtemp); oldtemp = T_BaoJiaToPService.LoadEntities(x => x.AddTime >= Utime && x.AddTime <= Dtime).DefaultIfEmpty(); Rlis[1] = AddList(yyItem, oldtemp); retMonth.Add(GetMonthVar(oldtemp, retMonth[0].DaiDingCount, retMonth[0].DdDml)); oldtemp = T_BaoJiaToPService.LoadEntities(x => x.AddTime <= Dtime); retMonth.Add(GetMonthVar(oldtemp, 0, 0)); #region 成功失败待定金额百分比 var LostYuanyinItem = T_WinBakService.LoadEntities(x => x.AddTime < Utime).DefaultIfEmpty(); //获取报价人员 var Uload = UserInfoService.LoadEntities(x => x.BuMenID == 1).DefaultIfEmpty(); //获取成功或失败的信息 var DMYuanyinItem = T_WinBakService.LoadEntities(x => x.AddTime >= Utime && x.AddTime <= Dtime).DefaultIfEmpty(); //获取待定信息 var DaiDingData = T_BaoJiaToPService.LoadEntities(x => x.AddTime >= Utime && x.AddTime <= Dtime).Where(x => x.T_WinBak.Count() == 0).DefaultIfEmpty(); //.Sum(a => a.YXB_Baojia.Sum(m => m.CPShuLiang * (m.BaoJiaMoney + m.BaoJiaYunFei))); var DMyyItem = from a in DMYuanyinItem select new { PerName = a.T_BaoJiaToP.YXB_Kh_list.UserInfo.PerSonName, WinMoney = a.YuanYin == 1 ? a.T_BaoJiaToP.YXB_Baojia.Sum(m => m.CPShuLiang * (m.WinMoney + m.WinYunFei)):0, LostMoney = a.YuanYin != 1 ? a.T_BaoJiaToP.YXB_Baojia.Sum(m => m.CPShuLiang * (m.WinMoney + m.WinYunFei)) : 0, DaiDingMoney = a.T_BaoJiaToP.YXB_Baojia.Where(m => m.WIN == 0).Sum(m => m.CPShuLiang * (m.BaoJiaMoney + m.BaoJiaYunFei)), }; List <Items> WinLostMoney = new List <Items>(); foreach (var f in Uload) { Items its = new Items(); its.PName = f.PerSonName; its.Wmoney = DMyyItem.Where(x => x.PerName == its.PName).Sum(x => x.WinMoney) == null ? 0 : DMyyItem.Where(x => x.PerName == its.PName).Sum(x => x.WinMoney); its.Lmoney = DMyyItem.Where(x => x.PerName == its.PName).Sum(x => x.LostMoney) == null ? 0 : DMyyItem.Where(x => x.PerName == its.PName).Sum(x => x.LostMoney); var itm = DaiDingData.Where(x => x.YXB_Kh_list.UserInfo.PerSonName == f.PerSonName).DefaultIfEmpty().Sum(x => x.YXB_Baojia.Sum(y => (y.BaoJiaMoney + y.BaoJiaYunFei) * y.CPShuLiang)); its.Dmoney = itm == null ? 0 : itm; its.WPercent = Rounds((its.Wmoney / DMyyItem.Sum(x => x.WinMoney) * 100) == null ? 0 : its.Wmoney / DMyyItem.Sum(x => x.WinMoney) * 100); its.LPercent = Rounds((its.Lmoney / DMyyItem.Sum(x => x.LostMoney) * 100) == null ? 0 :its.Lmoney / DMyyItem.Sum(x => x.LostMoney) * 100); var Summoneydd = DaiDingData.Sum(x => x.YXB_Baojia.Sum(y => (y.BaoJiaMoney + y.BaoJiaYunFei) * y.CPShuLiang)); its.DPercent = Rounds(Summoneydd == null ? 0 : its.Dmoney / Summoneydd * 100); WinLostMoney.Add(its); } //添加总数 Items ims = new Items(); ims.PName = "合计"; ims.Wmoney = WinLostMoney.Sum(x => x.Wmoney); ims.Lmoney = WinLostMoney.Sum(x => x.Lmoney); ims.Dmoney = WinLostMoney.Sum(x => x.Dmoney); ims.WPercent = Convert.ToInt32(WinLostMoney.Sum(x => x.WPercent)); ims.LPercent = Convert.ToInt32(WinLostMoney.Sum(x => x.LPercent)); ims.DPercent = Convert.ToInt32(WinLostMoney.Sum(x => x.DPercent)); WinLostMoney.Add(ims); #endregion return(Json(new { ret = "ok", temp = retMonth, LostItem = Rlis, XiangXi = WinLostMoney }, JsonRequestBehavior.AllowGet)); }
//修改报价信息 public ActionResult EditBJInfo() { long id = Convert.ToInt64(Request["BaoJiaID"]); long CPname = Convert.ToInt64(Request["CPname"]); long CPxh = Convert.ToInt64(Request["CPxh"]); int CPShuLiang = Convert.ToInt32(Request["CPShuLiang"]); long HanShuiID = Convert.ToInt64(Request["HanShuiID"]); long CPDengJiID = Convert.ToInt64(Request["CPDengJiID"]); long PiaoJuID = Convert.ToInt64(Request["PiaoJuID"]); string BeiZhu = Request["BeiZhu"]; DateTime GhTime = Convert.ToDateTime(Request["GhTime"]); string KHname = Request["KHname"]; string KHperson = Request["KHperson"]; string KHzhiwu = Request["KHzhiwu"]; string KHphoto = Request["KHphoto"]; string KHfaren = Request["KHfaren"]; string JiShuYaoQiu = Request["JiShuYaoQiu"]; string ProvinceIDname = Request["ProvinceIDname"]; string CityIDname = Request["CityIDname"]; string VillageIDname = Request["VillageIDname"]; string DaiBanYunShu = Request["DaiBanYunShu"]; string JieShuanFanShi = Request["JieShuanFanShi"]; string HeTongQianDing = Request["HeTongQianDing"]; var bj = YXB_BaojiaService.LoadEntities(x => x.id == id).FirstOrDefault(); if (bj != null) { bj.CPname = CPname; bj.CPXingHao = CPxh; bj.CPShuLiang = CPShuLiang; bj.CPDengJiID = CPDengJiID; bj.Remark = BeiZhu; if (YXB_BaojiaService.EditEntity(bj)) { var bjtop = T_BaoJiaToPService.LoadEntities(x => x.id == bj.BaoJiaTop_id).FirstOrDefault(); if (bjtop != null) { bjtop.HanShuiID = HanShuiID; bjtop.PiaoJuID = PiaoJuID; bjtop.GhTime = GhTime; bjtop.JiShuYaoQiu = JiShuYaoQiu; if (ProvinceIDname != null && ProvinceIDname != "") { var str = ProvinceIDname; if (CityIDname != null && CityIDname != "") { str = str + "," + CityIDname; if (VillageIDname != null && VillageIDname != "") { str = str + "," + VillageIDname; } } bjtop.Addess = str; } bjtop.DaiBanYunShu = DaiBanYunShu; bjtop.JieShuanFanShi = JieShuanFanShi; bjtop.HeTongQianDing = HeTongQianDing; if (T_BaoJiaToPService.EditEntity(bjtop)) { var khlist = YXB_Kh_listService.LoadEntities(x => x.id == bjtop.Kh_List_id).FirstOrDefault(); if (khlist != null) { khlist.KHname = KHname; khlist.KHperson = KHperson; khlist.KHzhiwu = KHzhiwu; khlist.KHphoto = KHphoto; khlist.KHfaren = KHfaren; if (YXB_Kh_listService.EditEntity(khlist)) { return(Json(new { ret = "yes", msg = "修改成功!" }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { ret = "no", msg = "修改失败,发生在第三阶段!" }, JsonRequestBehavior.AllowGet)); } } } else { return(Json(new { ret = "no", msg = "修改失败,发生在第二阶段!" }, JsonRequestBehavior.AllowGet)); } } } else { return(Json(new { ret = "no", msg = "修改失败,发生在第一阶段!" }, JsonRequestBehavior.AllowGet)); } } return(Json(new { ret = "no", msg = "修改失败!" }, JsonRequestBehavior.AllowGet));; }