protected void btnDel_Click(object sender, EventArgs e) { string strId = editid.Text.Trim(); try { Guid id = new Guid(strId); SYCRM.BLL.Area BF = new SYCRM.BLL.Area(); SYCRM.Model.Area MF = new SYCRM.Model.Area(); MF = BF.GetModel(id); List<SYCRM.Model.Area> listMA = BF.GetModelList("WBS like '%" + MF.WBS + "%'"); foreach (SYCRM.Model.Area a in listMA) { BF.Delete(a.Id); } Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "删除成功!", "<script>alert('删除成功!');window.location.href='Area.aspx'</script>"); } catch { Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "删除失败!", "<script>alert('删除失败!');window.location.href='Area.aspx'</script>"); } }
List<SYCRM.Model.Area> GetOwnArea(Guid areaid) { List<SYCRM.Model.Area> listMF = new List<SYCRM.Model.Area>(); SYCRM.BLL.Area BF = new SYCRM.BLL.Area(); SYCRM.Model.Area pRoot = BF.GetModel(areaid); if (pRoot == null) { labErr.Visible = true; labErr.Text = "账户数据错误!请联系系统管理员!"; return null; } string strWhere = " status=1 and WBS like'" + pRoot.WBS + "%'"; strWhere += " order by WBS"; listMF = BF.GetModelList(strWhere); return listMF; }
protected void btnSave_Click(object sender, EventArgs e) { string strId = editid.Text.Trim(); try { Guid id = new Guid(strId); SYCRM.Model.Area MF = new SYCRM.Model.Area(); SYCRM.BLL.Area BF = new SYCRM.BLL.Area(); MF = BF.GetModel(id); MF.Name = tbShowName.Text.Trim(); MF.Des = tb_ShowDes.Text.Trim(); string strOldWBS = MF.WBS; MF.WBS = DDLLayer.SelectedValue + "." + MF.Id.ToString(); MF.status = 1; BF.Update(MF); List<SYCRM.Model.Area> listMA = BF.GetModelList("WBS like '%" + strOldWBS + ".%'"); foreach (SYCRM.Model.Area a in listMA) { a.WBS = MF.WBS + "." + a.Id.ToString(); BF.Update(a); } Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "修改成功!", "<script>alert('修改成功!');window.location.href='Area.aspx'</script>"); } catch { Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "修改失败!", "<script>alert('修改失败!');window.location.href='Area.aspx'</script>"); } }
private void BindData() { List<SYCRM.Model.Area> listMF = new List<SYCRM.Model.Area>(); SYCRM.BLL.Area BF = new SYCRM.BLL.Area(); string strWhere = " status=1 "; if (!tb_KeyWords.Text.Trim().Equals("")) { strWhere += " and [Name] like '%" + tb_KeyWords.Text.Trim() + "%'"; } strWhere += " order by WBS"; listMF = BF.GetModelList(strWhere); RpArea.DataSource = handleList(listMF); RpArea.DataBind(); DDLLayer.DataSource = handleList(listMF); DDLLayer.DataBind(); }
List<SYCRM.Model.Area> GetOwnArea(Guid areaid) { List<SYCRM.Model.Area> listMF = new List<SYCRM.Model.Area>(); SYCRM.BLL.Area BF = new SYCRM.BLL.Area(); SYCRM.Model.Area pRoot = BF.GetModel(areaid); if (pRoot == null) { return null; } string strWhere = " status=1 and WBS like'" + pRoot.WBS + "%'"; strWhere += " order by WBS"; listMF = BF.GetModelList(strWhere); return listMF; }
List<SYCRM.Model.Customer> HandleList(List<SYCRM.Model.Customer> list) { List<SYCRM.Model.CustomerProduct> listAllCP = new List<SYCRM.Model.CustomerProduct>(); SYCRM.BLL.CustomerProduct bcp = new SYCRM.BLL.CustomerProduct(); listAllCP = bcp.GetModelList(""); List<SYCRM.Model.Product> listAllP = new List<SYCRM.Model.Product>(); SYCRM.BLL.Product bp = new SYCRM.BLL.Product(); listAllP = bp.GetModelList(""); List<SYCRM.Model.Agent> listAllA = new List<SYCRM.Model.Agent>(); SYCRM.BLL.Agent ba = new SYCRM.BLL.Agent(); listAllA = ba.GetModelList(""); List<SYCRM.Model.Area> listAllAA = new List<SYCRM.Model.Area>(); SYCRM.BLL.Area baa = new SYCRM.BLL.Area(); listAllAA = baa.GetModelList(""); foreach (SYCRM.Model.Customer c in list) { #region 产品 List<SYCRM.Model.CustomerProduct> listtempCP = listAllCP.Where(Item => Item.CustomerId == c.Id && Item.Status==1).ToList(); List<SYCRM.Model.Product> listtempP = new List<SYCRM.Model.Product>(); if (listtempCP.Count > 0) { listtempP = listAllP.Where(Item => listtempCP.Where(b => b.ProductId == Item.Id).Count() > 0 && Item.status == 1).ToList(); if (listtempP.Count > 0) { foreach(SYCRM.Model.Product p in listtempP) { c.ProductName += p.Name+ " "; } } else { c.ProductName = "无"; } } else { c.ProductName = "无"; } #endregion #region 区域 List<SYCRM.Model.Area> listTempAA = new List<SYCRM.Model.Area>(); listTempAA = listAllAA.Where(item => item.Id == c.Area).ToList(); if (listTempAA.Count > 0) { string strName = listTempAA[0].Name; if (listTempAA[0].status == 2) { strName = listTempAA[0].Name + "(已删除)"; } c.AreaName = strName; } else { c.AreaName = "无"; } #endregion #region 服务人员 List<SYCRM.Model.Agent> listTempA = new List<SYCRM.Model.Agent>(); listTempA = listAllA.Where(item => item.Id == c.AgentId).ToList(); if (listTempA.Count > 0) { string strName = listTempA[0].Name; if (listTempA[0].status == 2) { strName = listTempA[0].Name + "(已删除)"; } c.ChargeName = strName; } else { c.ChargeName = "无"; } #endregion } return list; }