Example #1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public DateTime Birthday(AgeType type = AgeType.Any)
        {
            var age = Age(type);
              var year = DateTime.Now.Year - age;

              return Date(year);
        }
        public static void SelectAgeGroup(AgeType age)
        {
            IWebElement divAge = LocalWait.Until(ExpectedConditions.ElementExists(By.ClassName(classNameToFind: "ageGroup")));
            IWebElement cboAge = LocalWait.Until(ExpectedConditions.ElementExists(By.ClassName(classNameToFind: "k-dropdown")));

            cboAge.Click();

            IWebElement select = LocalWait.Until(ExpectedConditions.ElementExists(By.Id(idToFind: "analAgeGroup-list")));
            ReadOnlyCollection <IWebElement> options = select.FindElements(By.TagName(tagNameToFind: "li"));

            for (int i = 0; i < options.Count; i++)
            {
                if (options[i].Text == age.ToString() && !IsAgeSelected(age))
                {
                    string jscript = string.Format(format: "$('#analAgeGroup').data('kendoDropDownList').select({0});", arg0: i);
                    try
                    {
                        ((IJavaScriptExecutor)Driver.Instance).ExecuteScript(jscript);
                        cboAge.Click();
                        ((IJavaScriptExecutor)Driver.Instance).ExecuteScript(script: "vrhProfileGrid.ChangedAgeGroup();");
                    }
                    catch (Exception ex)
                    {
                        jscript = string.Format(format: "alert('{0}');", arg0: ex.Message);
                        ((IJavaScriptExecutor)Driver.Instance).ExecuteScript(jscript);
                    }
                    break;
                }
            }
        }
Example #3
0
        public static int ConvertAge(int petAge, AgeType ageType)
        {
            int convertAge = 0;

            switch (ageType)
            {
            case AgeType.Cat:
            {
                convertAge = ConvertCatToHuman(petAge);
                break;
            }

            case AgeType.Dog:
            {
                convertAge = ConvertToDog(petAge);
                break;
            }

            case AgeType.Human:
            {
                Console.WriteLine("Not available.");
                break;
            }
            }

            return(convertAge);
        }
Example #4
0
 public Plant(AgeType ageType, double x, double y, double radius)
 {
     _AgeType = ageType;
     _X       = x;
     _Y       = y;
     _Radius  = radius;
 }
Example #5
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public int Age(AgeType type = AgeType.Any)
        {
            int age;

              switch (type)
              {
            case AgeType.Child:
              age = Natural(1, 12);
              break;
            case AgeType.Teen:
              age = Natural(13, 19);
              break;
            case AgeType.Adult:
              age = Natural(18, 120);
              break;
            case AgeType.Senior:
              age = Natural(65, 120);
              break;
            default:
              age = Natural(1, 120);
              break;
              }

              return age;
        }
Example #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public int Age(AgeType type = AgeType.Any)
        {
            int age;

            switch (type)
            {
            case AgeType.Child:
                age = Natural(1, 12);
                break;

            case AgeType.Teen:
                age = Natural(13, 19);
                break;

            case AgeType.Adult:
                age = Natural(18, 120);
                break;

            case AgeType.Senior:
                age = Natural(65, 120);
                break;

            default:
                age = Natural(1, 120);
                break;
            }

            return(age);
        }
Example #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public DateTime Birthday(AgeType type = AgeType.Any)
        {
            var age  = Age(type);
            var year = DateTime.Now.Year - age;

            return(Date(year));
        }
        public static void SelectAgeGroupDoesNotWorkWithKendo(AgeType age)
        {
            IWebElement cbo      = LocalWait.Until(ExpectedConditions.ElementExists(By.ClassName(classNameToFind: "ageGroup")));
            IWebElement cboAge   = LocalWait.Until(ExpectedConditions.ElementExists(By.ClassName(classNameToFind: "k-dropdown")));
            var         ageGroup = new SelectElement(cboAge);

            ageGroup.SelectByValue(age.ToString());
        }
Example #9
0
 public Age()
 {
    
     ageYear = 0;
     ageDay = 0;
     theAgeType = AgeType.infant;
     deathChance = 0;
 }
Example #10
0
        public static bool IsAgeSelected(AgeType age)
        {
            Driver.PleaseWait();
            IWebElement divAge      = LocalWait.Until(ExpectedConditions.ElementExists(By.ClassName(classNameToFind: "ageGroup")));
            IWebElement cboAge      = LocalWait.Until(ExpectedConditions.ElementExists(By.ClassName(classNameToFind: "k-dropdown")));
            IWebElement ageSelected = LocalWait.Until(ExpectedConditions.ElementExists(By.ClassName(classNameToFind: "k-input")));

            return(ageSelected.Text == age.ToString());
        }
Example #11
0
    public static List <AgeType> GetMyAge()
    {
        AgeType condition = new AgeType();
        AgeType value     = new AgeType();

        condition.ExhibitionID = AdminMethod.ExhibitionID;
        List <AgeType> list = TableOperate <AgeType> .Select(value, condition);

        return(list);
    }
        //Admin/Position/Update
        public ActionResult Update(int id)
        {
            AgeType agetype = db.AgeTypes.Find(id);

            if (agetype == null)
            {
                return(HttpNotFound());
            }
            return(View(agetype));
        }
        public ActionResult Update(AgeType agetype)
        {
            if (ModelState.IsValid)
            {
                db.Entry(agetype).State = EntityState.Modified;

                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(agetype));
        }
        public ActionResult Create(AgeType agetype)
        {
            if (ModelState.IsValid)
            {
                db.AgeTypes.Add(agetype);
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }
            return(View(agetype));
        }
Example #15
0
        List <Plant> CreatePlants()
        {
            List <Plant> plants = new List <Plant>();

            System.IO.FileInfo plantsXML_File = new System.IO.FileInfo("..\\..\\data\\plants.xml");

            if (!plantsXML_File.Exists)
            {
                MessageBox.Show(string.Format("XML does NOT exist!\nPath: {0}", plantsXML_File.FullName));
                return(plants);
            }

            System.Xml.XmlDocument xmlDocument = new System.Xml.XmlDocument();
            xmlDocument.Load(plantsXML_File.FullName);
            System.Xml.XmlElement xmlRoot = xmlDocument.DocumentElement;

            foreach (System.Xml.XmlNode xmlNode in xmlRoot)
            {
                System.Xml.XmlAttributeCollection nodeAttributes = xmlNode.Attributes;

                string plantXStr       = nodeAttributes.GetNamedItem("x").Value;
                double plantX          = double.Parse(plantXStr);
                double plantY          = double.Parse(nodeAttributes.GetNamedItem("y").Value);
                double plantRadius     = double.Parse(nodeAttributes.GetNamedItem("radius").Value);
                string plantAgeTypeStr = nodeAttributes.GetNamedItem("ageType").Value;

                System.Xml.XmlNode   fillAttr     = nodeAttributes.GetNamedItem("fill");
                string               fillColorStr = null;
                System.Drawing.Color fillColor    = System.Drawing.Color.Empty;
                if (fillAttr != null)
                {
                    fillColorStr = fillAttr.Value;
                    fillColor    = System.Drawing.ColorTranslator.FromHtml(fillColorStr);
                }

                AgeType plantAgeType = AgeTypeConverter.FromString(plantAgeTypeStr);

                if (plantAgeType == AgeType.MAX)
                {
                    MessageBox.Show(string.Format("XML Error: Invalid age type: {0}", plantAgeTypeStr));
                }

                Plant singlePlant = new Plant(plantAgeType, plantX, plantY, plantRadius);
                if (!fillColor.IsEmpty)
                {
                    singlePlant.SetFillColor(fillColor);
                }
                plants.Add(singlePlant);
            }


            return(plants);
        }
        //Admin/Position/Delete
        public ActionResult Delete(int id)
        {
            AgeType agetype = db.AgeTypes.Find(id);

            if (agetype == null)
            {
                return(HttpNotFound());
            }
            db.AgeTypes.Remove(agetype);
            db.SaveChanges();

            return(RedirectToAction("Index"));
        }
Example #17
0
    protected void Page_Load(object sender, EventArgs e)
    {
        AgeType condition = new AgeType();
        AgeType value     = new AgeType();
        string  title     = GetstringKey("name");

        if (title != "")
        {
            condition.AgeName = "%" + title + "%";
            condition.AddAttach("AgeName", "like");
        }
        condition.ExhibitionID = AdminMethod.ExhibitionID;
        m_tableManageList      = TableOperate <AgeType> .SelectByPage(value, condition, "order by  OrderID asc", PageSize, PageIndex, ref Count);

        DataBind();
        name.Value = title;
    }
Example #18
0
        public int GetAge(AgeType ageType)
        {
            if (State == AnimalState.Dead)
            {
                return(-1);
            }

            switch (ageType)
            {
            case AgeType.Days:
                return((DateTime.Now - BirthDate).Days);

            case AgeType.Years:
                return(DateTime.Now.Year - BirthDate.Year);

            default:
                return(-1);
            }
        }
Example #19
0
        internal Result <IEnumerable <AgeType> > GetAgeType()
        {
            var result     = new Result <IEnumerable <AgeType> >();
            var data       = new List <AgeType>();
            var connection = GetSqlConnection();

            try
            {
                var command = new SqlCommand(@"gs_getAgeType", connection);
                command.CommandType = System.Data.CommandType.StoredProcedure;
                connection.Open();

                var drOutput = command.ExecuteReader();

                using (drOutput)
                {
                    while (drOutput.Read())
                    {
                        var item = new AgeType();
                        item.AgeId   = (drOutput["AgeId"] != Convert.DBNull) ? int.Parse(drOutput["AgeId"].ToString()) : 0;
                        item.AgeName = (drOutput["AgeName"] != Convert.DBNull) ? drOutput["AgeName"].ToString() : null;
                        data.Add(item);
                    }
                    result.Return = data;
                }
            }
            catch (Exception ee)
            {
                WriteError(ee.ToString());
                result.IsError   = true;
                result.ErrorDesc = ee.ToString();
            }
            finally
            {
                if (connection != null)
                {
                    connection.Dispose();
                }
            }
            return(result);
        }
Example #20
0
 private void CheckAgeType()
 {
     if (ageYear >= oldAge)
     {
         theAgeType = AgeType.senior;
     }
     else if (ageYear >= adultAge)
     {
         theAgeType = AgeType.adult;
     }
     else if (ageYear >= teenAge)
     {
         theAgeType = AgeType.teen;
     }
     else
     {
         
         theAgeType = AgeType.infant;
        
     }
 }
Example #21
0
    protected void AddLog(string ids)
    {
        AgeType condition = new AgeType();
        AgeType value     = new AgeType();

        condition.AddConditon(" and id in(" + ids + ")");
        List <AgeType> list = TableOperate <AgeType> .Select(value, condition);

        if (list.Count > 0)
        {
            string deltitle = "";
            for (int i = 0; i < list.Count; i++)
            {
                deltitle += list[i].AgeName + ",";
            }
            deltitle = deltitle.TrimEnd(',');
            if (deltitle != "")
            {
                string logbrief = "管理员:【" + AdminMethod.AdminFullName + "】在" + DateTime.Now.GetDateTimeFormats('f')[0].ToString() + "删除了【" + deltitle + "】的年龄段";
                Lognet.AddLogin(logbrief);
            }
        }
    }
        protected static void SetParametry(FrameworkElement fe, int procent, bool UsePosition, AgeType at, TypeSize type)
        {
            Size primarySize = new Size(SystemParameters.PrimaryScreenWidth, SystemParameters.PrimaryScreenHeight);

            if (GetUseParentSize(fe))
            {
                if (fe.Parent is FrameworkElement)
                {
                    var parent = (FrameworkElement)fe.Parent;
                    primarySize = new Size(parent.Width == 0 ? parent.ActualWidth : parent.Width, parent.Height == 0 ? parent.ActualHeight : parent.Height);
                }
                else if (fe.Parent is Decorator)
                {
                    var parent = (Decorator)fe.Parent;
                    primarySize = new Size(parent.Width == 0 ? parent.ActualWidth : parent.Width, parent.Height == 0 ? parent.ActualHeight : parent.Height);
                }
            }

            fe.Width     = double.NaN;
            fe.MinWidth  = 0;
            fe.MaxWidth  = double.PositiveInfinity;
            fe.Height    = double.NaN;
            fe.MinHeight = 0;
            fe.MaxHeight = double.PositiveInfinity;

            if (!GetUsePosition(fe))
            {
                switch (at)
                {
                case AgeType.Width:
                    switch (type)
                    {
                    case TypeSize.Current:
                        fe.Width  = primarySize.Width * procent / 100;
                        fe.Height = double.NaN;
                        break;

                    case TypeSize.Static:
                        fe.Width     = fe.MinWidth = fe.MaxWidth = primarySize.Width * procent / 100;
                        fe.Height    = double.NaN;
                        fe.MinHeight = 0;
                        fe.MaxHeight = double.PositiveInfinity;
                        break;

                    case TypeSize.Max:
                        fe.MaxWidth  = primarySize.Width * procent / 100;
                        fe.MaxHeight = double.PositiveInfinity;
                        break;

                    case TypeSize.Min:
                        fe.MinWidth  = primarySize.Width * procent / 100;
                        fe.MinHeight = 0;
                        break;
                    }
                    break;

                case AgeType.Height:
                    switch (type)
                    {
                    case TypeSize.Current:
                        fe.Width  = double.NaN;
                        fe.Height = primarySize.Height * procent / 100;
                        break;

                    case TypeSize.Static:
                        fe.Width  = fe.MinWidth = fe.MaxWidth = double.NaN;
                        fe.Height = fe.MinHeight = fe.MaxHeight = primarySize.Height * procent / 100;
                        break;

                    case TypeSize.Max:
                        fe.MaxWidth  = double.PositiveInfinity;
                        fe.MaxHeight = primarySize.Height * procent / 100;
                        break;

                    case TypeSize.Min:
                        fe.MinWidth  = 0;
                        fe.MinHeight = primarySize.Height * procent / 100;
                        break;
                    }
                    break;

                case AgeType.FullSize:
                    switch (type)
                    {
                    case TypeSize.Current:
                        fe.Width  = primarySize.Width * procent / 100;
                        fe.Height = primarySize.Height * procent / 100;
                        break;

                    case TypeSize.Static:
                        fe.Width  = fe.MinWidth = fe.MaxWidth = primarySize.Width * procent / 100;
                        fe.Height = fe.MinHeight = fe.MaxHeight = primarySize.Height * procent / 100;
                        break;

                    case TypeSize.Max:
                        fe.MaxWidth  = primarySize.Width * procent / 100;
                        fe.MaxHeight = primarySize.Height * procent / 100;
                        break;

                    case TypeSize.Min:
                        fe.MinWidth  = primarySize.Width * procent / 100;
                        fe.MinHeight = primarySize.Height * procent / 100;
                        break;
                    }
                    break;
                }
            }
            else
            {
                Window parent = NTW.Common.FindAncestor <Window>(fe);
                if (parent != null)
                {
                    switch (WindowPositionBehaviour.GetWindowPosition(parent))
                    {
                    case Data.WindowPosition.Left:
                    case Data.WindowPosition.LeftBottom:
                    case Data.WindowPosition.LeftTop:
                    case Data.WindowPosition.Right:
                    case Data.WindowPosition.RightBottom:
                    case Data.WindowPosition.RightTop:
                        switch (type)
                        {
                        case TypeSize.Current:
                            fe.Width  = double.NaN;
                            fe.Height = primarySize.Height * procent / 100;
                            break;

                        case TypeSize.Static:
                            fe.Width    = double.NaN;
                            fe.MinWidth = 0;
                            fe.MaxWidth = double.PositiveInfinity;
                            fe.Height   = fe.MinHeight = fe.MaxHeight = primarySize.Height * procent / 100;
                            break;

                        case TypeSize.Max:
                            fe.MaxWidth  = double.PositiveInfinity;
                            fe.MaxHeight = primarySize.Height * procent / 100;
                            break;

                        case TypeSize.Min:
                            fe.MinWidth  = 0;
                            fe.MinHeight = primarySize.Height * procent / 100;
                            break;
                        }
                        break;

                    case Data.WindowPosition.Top:
                    case Data.WindowPosition.Bottom:
                        switch (type)
                        {
                        case TypeSize.Current:
                            fe.Width  = primarySize.Width * procent / 100;
                            fe.Height = double.NaN;
                            break;

                        case TypeSize.Static:
                            fe.Width     = fe.MinWidth = fe.MaxWidth = primarySize.Width * procent / 100;
                            fe.Height    = double.NaN;
                            fe.MinHeight = 0;
                            fe.MaxHeight = double.PositiveInfinity;
                            break;

                        case TypeSize.Max:
                            fe.MaxWidth  = primarySize.Width * procent / 100;
                            fe.MaxHeight = double.PositiveInfinity;
                            break;

                        case TypeSize.Min:
                            fe.MinWidth  = primarySize.Width * procent / 100;
                            fe.MinHeight = 0;
                            break;
                        }
                        break;
                    }
                }
                else
                {
                    Popup pParent = NTW.Common.FindAncestor <Popup>(fe);

                    if (pParent != null)
                    {
                        switch (FrameworkElementPositionBehaviour.GetFrameworkElementPosition(pParent))
                        {
                        case Data.WindowPosition.Left:
                        case Data.WindowPosition.LeftBottom:
                        case Data.WindowPosition.LeftTop:
                        case Data.WindowPosition.Right:
                        case Data.WindowPosition.RightBottom:
                        case Data.WindowPosition.RightTop:
                            switch (type)
                            {
                            case TypeSize.Current:
                                fe.Width  = double.NaN;
                                fe.Height = primarySize.Height * procent / 100;
                                break;

                            case TypeSize.Static:
                                fe.Width  = fe.MinWidth = fe.MaxWidth = double.NaN;
                                fe.Height = fe.MinHeight = fe.MaxHeight = primarySize.Height * procent / 100;
                                break;

                            case TypeSize.Max:
                                fe.MaxWidth  = double.NaN;
                                fe.MaxHeight = primarySize.Height * procent / 100;
                                break;

                            case TypeSize.Min:
                                fe.MinWidth  = double.NaN;
                                fe.MinHeight = primarySize.Height * procent / 100;
                                break;
                            }
                            break;

                        case Data.WindowPosition.Top:
                        case Data.WindowPosition.Bottom:
                            switch (type)
                            {
                            case TypeSize.Current:
                                fe.Width  = primarySize.Width * procent / 100;
                                fe.Height = double.NaN;
                                break;

                            case TypeSize.Static:
                                fe.Width  = fe.MinWidth = fe.MaxWidth = primarySize.Width * procent / 100;
                                fe.Height = fe.MinHeight = fe.MaxHeight = double.NaN;
                                break;

                            case TypeSize.Max:
                                fe.MaxWidth  = primarySize.Width * procent / 100;
                                fe.MaxHeight = double.NaN;
                                break;

                            case TypeSize.Min:
                                fe.MinWidth  = primarySize.Width * procent / 100;
                                fe.MinHeight = double.NaN;
                                break;
                            }
                            break;
                        }
                    }
                }
            }
        }
 public static void SetAgeType(DependencyObject obj, AgeType value)
 {
     obj.SetValue(AgeTypeProperty, value);
 }
Example #24
0
    public void SetChance(AgeType age)
    {
        if(age== AgeType.adult)
        {
            chance = 1;
            
        }
        else
        {
            
            chance =0.1f;
        }


    }
Example #25
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string action = GetstringKey("action");



        int ID = GetIntKey("ID");

        AgeType condition = new AgeType();
        AgeType v         = new AgeType();

        if (ID == 0)
        {
            Response.Write("");
            return;
        }

        condition.ID = ID;
        AgeType myView = TableOperate <AgeType> .GetRowData(v, condition);

        if (myView.ID == 0)
        {
            Response.Write("");
            return;
        }

        AgeType condition2 = new AgeType();
        AgeType V2         = new AgeType();

        condition2.AddConditon(" and ID<>'" + condition.ID + "'");
        condition2.ExhibitionID = AdminMethod.ExhibitionID;
        string strOrder = string.Empty;

        condition2.OrderID = myView.OrderID;
        if (action == "up")
        {
            //向上,现在是时间越早越在上面
            condition2.AddAttach("OrderID", "<");
            strOrder = " order by OrderID  DESC"; //时间从大到小
        }
        else
        {
            condition2.AddAttach("OrderID", ">");
            strOrder = " order by OrderID ASC";
        }


        List <AgeType> desOrderMdl = TableOperate <AgeType> .Select(V2, condition2, 1, strOrder);

        if (desOrderMdl.Count != 1)
        {
            Response.Write("");
            return;
        }


        AgeType conditionU = new AgeType();

        conditionU.ID      = myView.ID;
        conditionU.OrderID = desOrderMdl[0].OrderID;
        TableOperate <AgeType> .Update(conditionU);

        AgeType conditionU2 = new AgeType();

        conditionU2.ID      = desOrderMdl[0].ID;
        conditionU2.OrderID = myView.OrderID;
        TableOperate <AgeType> .Update(conditionU2);

        Response.StatusCode = 200;
        Response.Write(conditionU2.ID);
    }
 public int GetCountByAgeType(AgeType a)
 {
     return(People.Count(p => p.AgeType == a));
 }
 public AgeObject(uint value, AgeType ageType)
 {
     Value   = value;
     AgeType = ageType;
 }
Example #28
0
 public static bool GetListOfProfiles(MeasureType theMeasureType, AgeType age)
 {
     GotoNameTab(theMeasureType);
     SelectAgeGroup(age);
     return(true);
 }
Example #29
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string action = GetstringKey("action");

        if (action != "save")
        {
            if (!string.IsNullOrEmpty(this.Request["iD"]))
            {
                int     _iD       = Convert.ToInt32(this.Request["iD"]);
                AgeType condition = new AgeType();
                condition.ID = _iD;
                news         = TableOperate <AgeType> .GetRowData(condition);

                iD.Value = Convert.ToString(news.ID);
            }
            DataBind();
        }
        else
        {
            Result  result         = new Result();
            string  logbrief       = "";
            AgeType newChannelNews = new AgeType();
            newChannelNews.ID = 0;
            newChannelNews.AutoForm(this.Page);
            string Title = newChannelNews.AgeName;
            int    _iD;
            if (!string.IsNullOrEmpty(this.Request["iD"]))
            {
                _iD = Convert.ToInt32(this.Request["iD"]);
                TableOperate <AgeType> .Update(newChannelNews);

                result.msg = "编辑成功,等待返回列表";
                logbrief   = "管理员:【" + AdminMethod.AdminFullName + "】在" + DateTime.Now.GetDateTimeFormats('f')[0].ToString() + "编辑了为【" + Title + "】的年龄段";
            }
            else
            {
                newChannelNews.AddTime      = DateTime.Now;
                newChannelNews.AddID        = AdminMethod.AdminID;
                newChannelNews.ExhibitionID = AdminMethod.ExhibitionID;
                newChannelNews.OrderID      = CloudSQL.GetNowTime();
                _iD = TableOperate <AgeType> .InsertReturnID(newChannelNews);

                result.msg = "添加成功,等待返回列表";
                logbrief   = "管理员:【" + AdminMethod.AdminFullName + "】在" + DateTime.Now.GetDateTimeFormats('f')[0].ToString() + "添加了为【" + Title + "】的年龄段";
            }

            if (_iD > 0)
            {
                result.isOk = true;
                Lognet.AddLogin(logbrief);
            }
            else
            {
                result.msg = "操作失败";
            }
            Response.ContentType = "text/json";
            Response.Write(new JavaScriptSerializer().Serialize(result));
            Response.End();
        }
        DataBind();
    }
Example #30
0
 public AgeValue(uint age, AgeType ageType)
 {
     Age     = age;
     AgeType = ageType;
 }