protected void bindDDL() { SYCRM.BLL.Agent agentBll = new SYCRM.BLL.Agent(); IList<SYCRM.Model.Agent> agentList = new List<SYCRM.Model.Agent>(); agentList = agentBll.GetModelList(" 1=1 "); ddlAgent.DataSource = agentList; ddlAgent.DataTextField = "Name"; ddlAgent.DataValueField = "Id"; ddlAgent.DataBind(); ListItem li = new ListItem("请选择", "0"); ddlAgent.Items.Insert(0, li); SYCRM.BLL.Product ProductBll = new SYCRM.BLL.Product(); IList<SYCRM.Model.Product> ProductList = new List<SYCRM.Model.Product>(); ProductList = ProductBll.GetModelList(" status=1 order by code asc "); dbProduct.DataSource = ProductList; dbProduct.DataTextField = "CodeName"; dbProduct.DataValueField = "Id"; dbProduct.DataBind(); }
protected void tbnDel_Click(object sender, EventArgs e) { CheckBox cb; SYCRM.BLL.Agent BA = new SYCRM.BLL.Agent(); for (int i = 0; i < GridViewList.Rows.Count; i++) { cb = (CheckBox)GridViewList.Rows[i].FindControl("CBSelect"); if (cb.Checked) { try { SYCRM.Model.Agent ma = BA.GetModel(new Guid(GridViewList.DataKeys[i].Value.ToString())); ma.status = 2; BA.Update(ma); } catch { } } } bindGV(); Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "用户删除!", "<script>alert('用户成功删除!');</script>"); }
protected void btnSubmit_Click(object sender, EventArgs e) { if (textmanagerID.Text.Trim() != "") { if (textpass.Text.Trim() != "") { List<SYCRM.Model.Agent> listMA = new List<SYCRM.Model.Agent>(); SYCRM.BLL.Agent BA = new SYCRM.BLL.Agent(); string strWhere = " UserName='******' and Password = '******'"; listMA = BA.GetModelList(strWhere); if (listMA.Count == 1) { Session["User"] = listMA[0]; if (Request.QueryString["url"] != null) { Response.Redirect(Request.QueryString["url"].ToString()); } Response.Redirect("~/struct/sms.aspx"); } else { lbErr.Text = "用户名/密码错误"; } } else { lbErr.Text = "密码不能为空"; } } else { lbErr.Text = "用户名不能为空"; } }
protected void btnAdd_Click(object sender, EventArgs e) { SYCRM.Model.Agent manauser = Session["User"] as SYCRM.Model.Agent; SYCRM.Model.Agent user = new SYCRM.Model.Agent(); List<SYCRM.Model.Agent> listuser = new List<SYCRM.Model.Agent>(); SYCRM.BLL.Agent ba = new SYCRM.BLL.Agent(); string strLayer = DDLLayer.SelectedValue; string[] layerarray = strLayer.Split('.'); if (layerarray.Count() == 0) { labErr.Visible = true; labErr.Text = "账户数据错误!请联系系统管理员!"; return; } user.AreaId = new Guid(layerarray[layerarray.Count() - 1]); user.Address = tbAddress.Text.Trim(); user.Des = tb_ShowDes.Text.Trim(); user.Email = tbMail.Text.Trim(); user.IDCard = tbIDCard.Text.Trim(); user.Phone = tbPhone.Text.Trim(); user.UserType = int.Parse(ddlUserType.SelectedValue); if(manauser.AreaId==user.AreaId&&user.UserType.Value==1) { labErr.Visible = true; labErr.Text = "账户数据错误!请联系系统管理员!"; return; } user.Position = new Guid(ddlPost.SelectedValue); user.Sex = int.Parse(ddlSex.SelectedValue); user.status = 1; user.Password = tbPassword.Text; user.UserName = tbLoginName.Text.Trim(); listuser = ba.GetModelList(" UserName ='******'"); if (listuser.Count > 0) { labErr.Visible = true; labErr.Text = "已存在登录名,请修改!"; return; } user.Name = tbName.Text.Trim(); ba.Add(user); Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "添加成功!", "<script>alert('添加成功!');window.location.href=window.location.href</script>"); }
protected void Page_Load(object sender, EventArgs e) { SYCRM.BLL.Agent agent = new SYCRM.BLL.Agent(); List<SYCRM.Model.Agent> listA = agent.GetModelList(""); }
private void bindPage() { SYCRM.Model.Customer cus = new SYCRM.Model.Customer(); SYCRM.BLL.Customer cusBll = new SYCRM.BLL.Customer(); cus = cusBll.GetModel(cusId); lbName.Text = cus.Name; lbage.Text = cus.UserAge.ToString(); if (cus.UserSex == 1) { lbsex.Text = "男"; } else { lbsex.Text = "女"; } if (cus.Area != null) { SYCRM.BLL.Area areaBll = new SYCRM.BLL.Area(); SYCRM.Model.Area area = areaBll.GetModel(cus.Area); if (area != null) { lbarea.Text = area.Name; } } SYCRM.Model.Agent a = Session["User"] as SYCRM.Model.Agent; if (a.AreaId != null) { List<SYCRM.Model.Area> listA = GetOwnArea(a.AreaId); if (listA == null) { NoP(); return; } if (cus.Area == a.AreaId) { hdP.Value = "2"; } else if (listA.Where(Items => Items.Id == cus.Area).ToList().Count > 0) { hdP.Value = "1"; } else { NoP(); } } else { NoP(); return; } lbbabayname.Text = cus.BabyName; lbbabysex.Text = cus.BabySexName; lbbrithday.Text = cus.BadyBirthday.ToString(); lbtel.Text = cus.Phone.ToString(); lbaddress.Text = cus.Address; if (cus.AgentId != null) { SYCRM.BLL.Agent agentBll = new SYCRM.BLL.Agent(); SYCRM.Model.Agent agent = agentBll.GetModel(cus.AgentId); if (agent != null) { lbagent.Text = agent.Name; } } lbdes.Text = cus.Des; lbAddTime.Text = cus.AddTime.Value.ToShortDateString().ToString(); if (cus.AddUserId != null) { SYCRM.BLL.Agent agentBll = new SYCRM.BLL.Agent(); SYCRM.Model.Agent agent = agentBll.GetModel(cus.AddUserId); if (agent != null) { lbAaddUser.Text = agent.Name; } } 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.CustomerProduct> listtempCP = listAllCP.Where(Item => Item.CustomerId == cus.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) { cus.ProductName += p.Code.ToString()+" "+p.Name +" "; } } else { cus.ProductName = "无"; } } lbproduct.Text = cus.ProductName; }
void bindAllGV() { SYCRM.Model.Agent manauser = Session["User"] as SYCRM.Model.Agent; List<SYCRM.Model.Area> listMA = GetOwnArea(manauser.AreaId); string strWhere = " status=1 "; if (tbName.Text.Trim() != "") { strWhere += " and [Name] like '%" + tbName.Text.Trim() + "%' "; } if (ddlUserType.SelectedValue != "0") { if (ddlUserType.SelectedValue == "1") { strWhere += " and UserType = 1 "; } if (ddlUserType.SelectedValue == "2") { strWhere += " and UserType = 2 "; } } strWhere += " and Id <> '" + manauser.Id.ToString() + "'"; strWhere += " and UserName <> 'admin' "; strWhere += " order by AreaId, UserType, Sex, Name"; List<SYCRM.Model.Agent> listMAG = new List<SYCRM.Model.Agent>(); SYCRM.BLL.Agent BF = new SYCRM.BLL.Agent(); listMAG = BF.GetModelList(strWhere); GridViewList.DataSource = handleAList(listMAG); GridViewList.DataBind(); }
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; }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { if (Session["User"] != null) { SYCRM.Model.Agent manauser = Session["User"] as SYCRM.Model.Agent; hdarea.Value = manauser.AreaId.ToString(); bindddl(manauser); } else { Response.Redirect("~/login.aspx"); } //if (Request.QueryString["id"] != null) { SYCRM.Model.Agent manauser =Session["User"] as SYCRM.Model.Agent; string strId = manauser.Id.ToString(); if (strId != "") { bool wrong = false; Guid id = new Guid(); try { id = new Guid(strId); } catch { wrong = true; } if (wrong) { Response.Redirect("agent.aspx"); } else { SYCRM.Model.Agent user = new SYCRM.Model.Agent(); SYCRM.BLL.Agent ba = new SYCRM.BLL.Agent(); user = ba.GetModel(id); if (user != null) { bind(user); } else { Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "数据错误!", "<script>alert('数据错误!');</script>"); } } } else { Response.Redirect("mine.aspx"); } } } }
protected void btnSave_Click(object sender, EventArgs e) { bool wrong = false; Guid id = new Guid(); try { id = new Guid(hdId.Value); } catch { wrong = true; } if (wrong) { Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "数据错误!", "<script>alert('数据错误!');</script>"); return; } SYCRM.Model.Agent manauser = Session["User"] as SYCRM.Model.Agent; SYCRM.Model.Agent user = new SYCRM.Model.Agent(); List<SYCRM.Model.Agent> listuser = new List<SYCRM.Model.Agent>(); SYCRM.BLL.Agent ba = new SYCRM.BLL.Agent(); user = ba.GetModel(id); if (user == null) { Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "数据错误!", "<script>alert('数据错误!');</script>"); return; } string strLayer = DDLLayer.SelectedValue; string[] layerarray = strLayer.Split('.'); if (layerarray.Count() == 0) { labErr.Visible = true; labErr.Text = "账户数据错误!请联系系统管理员!"; return; } user.AreaId = new Guid(layerarray[layerarray.Count() - 1]); user.Address = tbAddress.Text.Trim(); user.Des = tb_ShowDes.Text.Trim(); user.Email = tbMail.Text.Trim(); user.IDCard = tbIDCard.Text.Trim(); user.Phone = tbPhone.Text.Trim(); user.UserType = int.Parse(ddlUserType.SelectedValue); user.Position = new Guid(ddlPost.SelectedValue); user.Sex = int.Parse(ddlSex.SelectedValue); user.status = 1; if (tbPassword.Text != "") { user.Password = tbPassword.Text; } user.Name = tbName.Text.Trim(); ba.Update(user); Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "修改成功!", "<script>alert('修改成功!');</script>"); }