Ejemplo n.º 1
0
        public void deleteMem(Guid pid)
        {
            var     mems = _ecdal.GetEntities(m => m.PID == pid);
            XiaoYan xy   = null;

            foreach (var mem in mems)
            {
                xy = mem;
            }
            var    pers = _persondal.GetEntities(m => m.PID == pid);
            Person ps   = null;

            foreach (var per in pers)
            {
                ps = per;
            }
            var     accs = _account.GetEntities(m => m.Username == ps.Username);
            Account at   = null;

            foreach (var acc in accs)
            {
                at = acc;
            }
            if (xy != null)
            {
                _memdal.Delete(xy);
                _persondal.Delete(ps);
                _account.Delete(at);
            }
        }
Ejemplo n.º 2
0
        public DaYanService(string username)
        {
            _persondal = new PersonDal();
            _dayandal  = new DaYanDal();
            var resultp = _persondal.GetEntities(i => i.Username == username);

            foreach (var p in resultp)
            {
                _person = p;
            }
            var resultd = _dayandal.GetEntities(i => i.PID == _person.PID);

            foreach (var d in resultd)
            {
                _dayan = d;
            }
        }
Ejemplo n.º 3
0
        public ECService(string username)
        {
            _persondal = new PersonDal();
            _ecdal     = new XiaoYanDal();
            _memdal    = new XiaoYanDal();
            _account   = new AccountDal();
            var resultp = _persondal.GetEntities(i => i.Username == username);

            foreach (var p in resultp)
            {
                _person = p;
            }
            var resulte = _ecdal.GetEntities(i => i.PID == _person.PID);

            foreach (var e in resulte)
            {
                _ec = e;
            }
        }
Ejemplo n.º 4
0
        public XiaoYanService(string username)
        {
            _persondal  = new PersonDal();
            _xiaoyandal = new XiaoYanDal();
            var resultp = _persondal.GetEntities(i => i.Username == username);

            foreach (var p in resultp)
            {
                _person = p;
            }
            if (_person != null)
            {
                var resultx = _xiaoyandal.GetEntities(i => i.PID == _person.PID);
                foreach (var x in resultx)
                {
                    _xiaoyan = x;
                }
            }
        }
Ejemplo n.º 5
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            ECService ec   = new ECService(Label1.Text);
            PersonDal pd   = new PersonDal();
            var       pers = pd.GetEntities(m => m.Username == TextBox1.Text);
            Person    ps   = null;

            foreach (var per in pers)
            {
                ps = per;
            }
            if (ps != null)
            {
                ec.deleteMem(ps.PID);
                Response.Write("<script>alert('删除成功!')</script>");
            }
            else
            {
                Response.Write("<script>alert('未找到该用户!')</script>");
            }
        }
Ejemplo n.º 6
0
        //update member grade
        public bool updateMemGrade(Person person, string toGrade)
        {
            bool   res       = true;
            Person tPerson   = null;
            var    persondal = new PersonDal();
            //get the person's old profile
            var pres = persondal.GetEntities(m => m.PID == person.PID);

            try
            {
                foreach (var p in pres)
                {
                    tPerson = p;
                }
                if (person.Pgrade != toGrade)  //若前后grade不一致
                //update person first
                {
                    updatePersonGrade(person, toGrade);
                    //update Member later
                    switch (person.Pgrade)
                    {
                    case "XiaoYan":
                    case "EC": {
                        //get the old profile of the member
                        var oldmem   = new XiaoYan();
                        var xymemdal = new XiaoYanDal();
                        var mems     = xymemdal.GetEntities(m => m.PID == person.PID);
                        foreach (var p in mems)
                        {
                            oldmem = p;
                        }
                        //update the member profile
                        if (toGrade == "EC")
                        {
                            //XiaoYan=>EC,set EC flag
                            xymemdal.Update(new XiaoYan {
                                    XYID = oldmem.XYID,
                                    PID  = oldmem.PID, Sid = oldmem.Sid,
                                    isEC = true, isActive = oldmem.isActive
                                });
                        }
                        else if (toGrade == "XiaoYan")
                        {
                            //EC=>XiaoYan,unset EC flag
                            xymemdal.Update(new XiaoYan
                                {
                                    XYID     = oldmem.XYID,
                                    PID      = oldmem.PID,
                                    Sid      = oldmem.Sid,
                                    isEC     = false,
                                    isActive = oldmem.isActive
                                });
                        }
                        else if (toGrade == "DaYan")
                        {
                            var dymemdal = new DaYanDal();
                            //inactivate the xiaoyan
                            xymemdal.Update(new XiaoYan
                                {
                                    XYID     = oldmem.XYID,
                                    PID      = oldmem.PID,
                                    Sid      = oldmem.Sid,
                                    isEC     = oldmem.isEC,
                                    isActive = false
                                });
                            //insert a dayan
                            dymemdal.Insert(new DaYan
                                {
                                    DYID       = Guid.NewGuid(),
                                    PID        = oldmem.PID,
                                    Sid        = oldmem.Sid,
                                    isECleader = false,
                                    isActive   = true
                                });
                        }
                        break;
                    }

                    case "DaYan":
                    case "ECleader": {
                        var oldmem   = new DaYan();
                        var dymemdal = new DaYanDal();
                        var mems     = dymemdal.GetEntities(m => m.PID == person.PID);
                        foreach (var p in mems)
                        {
                            oldmem = p;
                        }

                        if (toGrade == "ECleader")
                        {        //DaYan=>ECleader,set ECleader flag
                            dymemdal.Update(new DaYan
                                {
                                    DYID       = oldmem.DYID,
                                    PID        = oldmem.PID,
                                    Sid        = oldmem.Sid,
                                    isECleader = true,
                                    isActive   = oldmem.isActive
                                });
                        }
                        else if (toGrade == "DaYan")
                        {        //ECleader=>DaYan,unset ECleader flag
                            dymemdal.Update(new DaYan
                                {
                                    DYID       = oldmem.DYID,
                                    PID        = oldmem.PID,
                                    Sid        = oldmem.Sid,
                                    isECleader = false,
                                    isActive   = oldmem.isActive
                                });
                        }
                        break;
                    }
                    }
                }
            }
            catch (Exception e)
            {
                res = false;
                using (StreamWriter writer =
                           new StreamWriter(@"C:\Users\JJH\Desktop\log.txt", true))
                {
                    writer.WriteLine(DateTime.Now.ToString());
                    writer.WriteLine(e.Message);
                    writer.WriteLine(e.StackTrace);
                }
            }
            return(res);
        }
Ejemplo n.º 7
0
        /*Retrieve the basic infomation by condition.*/
        public IEnumerable <Person> GetAll(Expression <Func <Person, bool> > predicate)
        {
            var _model = _pdl.GetEntities(predicate);

            return(_model);
        }
Ejemplo n.º 8
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            Helper    helper = new Helper();
            PersonDal pd     = new PersonDal();
            Expression <Func <Person, bool> > name = i => i.Pname == TextBox13.Text;
            Expression <Func <Person, bool> > sex  = i => i.Psex == DropDownList1.Text;
            Expression <Func <Person, bool> > pro  = i => i.Ppro == TextBox15.Text;
            //Expression<Func<Person, bool>> sid = i => i.Ppro == TextBox4.Text;
            Expression <Func <Person, bool> > username = i => i.Username == TextBox17.Text;
            Expression <Func <Person, bool> > exp      = i => i.PID != null;
            IEnumerable <Person> entity = null;

            if (TextBox17.Text != "")
            {
                entity = pd.GetEntities(i => i.Username == TextBox17.Text);
            }
            else if (DropDownList1.Text != "" || TextBox15.Text != "" || TextBox13.Text != "")
            {
                if (DropDownList1.Text == "" && TextBox15.Text == "" && TextBox13.Text != "")
                {
                    entity = pd.GetEntities(i => i.Pname == TextBox13.Text);
                }
                else if (DropDownList1.Text != "" && TextBox15.Text == "" && TextBox13.Text == "")
                {
                    entity = pd.GetEntities(i => i.Psex == DropDownList1.Text);
                }
                else if (DropDownList1.Text == "" && TextBox15.Text != "" && TextBox13.Text == "")
                {
                    entity = pd.GetEntities(i => i.Ppro == TextBox15.Text);
                }
                else if (DropDownList1.Text != "" && TextBox15.Text != "" && TextBox13.Text == "")
                {
                    entity = pd.GetEntities(i => i.Ppro == TextBox15.Text && i.Psex == DropDownList1.Text);
                }
                else if (DropDownList1.Text == "" && TextBox15.Text != "" && TextBox13.Text != "")
                {
                    entity = pd.GetEntities(i => i.Ppro == TextBox15.Text && i.Pname == TextBox13.Text);
                }
                else if (DropDownList1.Text != "" && TextBox15.Text == "" && TextBox13.Text != "")
                {
                    entity = pd.GetEntities(i => i.Psex == DropDownList1.Text && i.Pname == TextBox13.Text);
                }
                else if (DropDownList1.Text != "" && TextBox15.Text != "" && TextBox13.Text != "")
                {
                    entity = pd.GetEntities(i => i.Psex == DropDownList1.Text && i.Pname == TextBox13.Text && i.Ppro == TextBox15.Text);
                }
            }
            else
            {
                entity = null;
            }
            if (entity != null)
            {
                GridView1.DataSource = entity;
                GridView1.DataBind();
                //i => ((Convert(i.PID) != null) AndAlso (i.Psex == value(ASP.query_aspx).DropDownList1.Text))

                Response.Write("<script>alert('查询成功!')</script>");
            }
            else
            {
                Response.Write("<script>alert('未查到相关信息!')</script>");
            }
        }