Exemplo n.º 1
0
        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>");
            }
        }
Exemplo n.º 2
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            SYCRM.Model.Area MF = new SYCRM.Model.Area();
            SYCRM.BLL.Area BF = new SYCRM.BLL.Area();

            //if (DateTime.TryParse(tbFDate.Text.Trim(), out temp))
            {
                MF.Name = tbShowName.Text.Trim();
                MF.Des = tb_ShowDes.Text.Trim();
                //MF.WBS = DDLLayer.SelectedValue
                MF.status = 1;
                BF.Add(MF);
                if (MF.Id == null)
                {
                    Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "添加失败!", "<script>alert('添加失败!');window.location.href='Area.aspx'</script>");
                    return;
                }
                else
                {
                    MF.WBS = DDLLayer.SelectedValue + "." + MF.Id;
                    BF.Update(MF);
                    Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "添加成功!", "<script>alert('添加成功!');window.location.href='Area.aspx'</script>");
                }
            }
        }
Exemplo n.º 3
0
        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>");
            }
        }
Exemplo n.º 4
0
        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;
        }
Exemplo n.º 5
0
        List<SYCRM.Model.Customer> handleAList(List<SYCRM.Model.Customer> listMA)
        {
            foreach (SYCRM.Model.Customer a in listMA)
            {
                SYCRM.Model.Area MArea = new SYCRM.Model.Area();
                SYCRM.BLL.Area BArea = new SYCRM.BLL.Area();

                MArea = BArea.GetModel(a.Area);

                if (MArea != null)
                {
                    a.AreaName = MArea.Name;
                }
                else
                {
                    a.AreaName = "区域已删除";
                }
            }
            return listMA;
        }
Exemplo n.º 6
0
        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();
        }
Exemplo n.º 7
0
        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;
        }
Exemplo n.º 8
0
        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;
        }
Exemplo n.º 9
0
        List<SYCRM.Model.Agent> handleAList(List<SYCRM.Model.Agent> listMA)
        {
            foreach (SYCRM.Model.Agent a in listMA)
            {
                SYCRM.Model.Area MArea = new SYCRM.Model.Area();
                SYCRM.BLL.Area BArea = new SYCRM.BLL.Area();

                MArea = BArea.GetModel(a.AreaId);

                if (MArea != null)
                {
                    a.AreaName = MArea.Name;
                }
                else
                {
                    a.AreaName = "区域已删除";
                }

                SYCRM.Model.Position MPosition = new SYCRM.Model.Position();
                SYCRM.BLL.Position BPosition = new SYCRM.BLL.Position();

                MPosition = BPosition.GetModel(a.Position);

                if (MPosition != null)
                {
                    a.PostName = MPosition.Name;
                }
                else
                {
                    a.PostName = "职位已删除";
                }
            }
            return listMA;
        }
Exemplo n.º 10
0
        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;
        }
Exemplo n.º 11
0
        void bind(SYCRM.Model.Agent user)
        {
            hdId.Value = user.Id.ToString();

            SYCRM.Model.Area ma = new SYCRM.Model.Area();
            SYCRM.BLL.Area ba = new SYCRM.BLL.Area();

            if (user.AreaId != null)
            {
                ma = ba.GetModel(user.AreaId);
                if (ma == null)
                {
                    Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "数据错误!", "<script>alert('数据错误!');'</script>");
                }
                else
                {
                    ddlUserType.SelectedValue = user.UserType.Value.ToString();
                    DDLLayer.SelectedValue = ma.WBS.ToString();
                    ddlSex.SelectedValue = user.Sex.Value.ToString();
                    ddlPost.SelectedValue = user.Position.ToString();

                    tbAddress.Text = user.Address;
                    tb_ShowDes.Text = user.Des;
                    tbMail.Text = user.Email;
                    tbIDCard.Text = user.IDCard;
                    tbPhone.Text = user.Phone;

                    tbLoginName.Text = user.UserName;
                    tbName.Text = user.Name;
                }
            }
            else
            {
                Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "数据错误!", "<script>alert('数据错误!');'</script>");
            }
        }