Exemplo n.º 1
0
 //重置
 protected void DeleteAll_Click(object sender, EventArgs e)
 {
     try
     {
         //AwardPeople.Reset();
         //tAchievement.Reset();
         tachievement.Reset();
         tAwardName.Reset();
         dAwardTime.Reset();
         dAwardwSpecies.Reset();
         FirstAward.Reset();
         AwardNum.Reset();
         dAwardForm.Reset();
         dGrade.Reset();
         tRemark.Reset();
         dSecrecyLevel.Reset();
         tGivenAgency.Reset();
         Unit1.Reset();
         Unit2.Reset();
         Unit3.Reset();
         Unit4.Reset();
         Unit5.Reset();
         DropDownList_Sort.Reset();
         Members.Reset();
         PageContext.RegisterStartupScript("clearFile();");
     }
     catch (Exception ex)
     {
         pm.SaveError(ex, this.Request);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Allows for conversion of <see cref="IUnit"/> derived type.
        /// </summary>
        /// <remarks>
        /// Note: the type <typeparamref name="TN1"/> must be a relative of <typeparamref name="T1"/>.
        /// Note: the type <typeparamref name="TN2"/> must be a relative of <typeparamref name="T2"/>.
        /// Note: the type <typeparamref name="TN3"/> must be a relative of <typeparamref name="T3"/>.
        /// </remarks>
        /// <typeparam name="TN1">The new type you want to convert the current scalar's type to.</typeparam>
        /// <typeparam name="TN2">The new type you want to convert the current scalar's type to.</typeparam>
        /// <typeparam name="TN3">The new type you want to convert the current scalar's type to.</typeparam>
        /// <returns>A new scalar with type of <typeparamref name="TN1"/>, <typeparamref name="TN2"/>, <typeparamref name="TN3"/> who's value has been converted to <typeparamref name="TN1"/>, <typeparamref name="TN2"/>, <typeparamref name="TN3"/> .</returns>
        public Scalar <TN1, TN2, TN3> To <TN1, TN2, TN3>()
            where TN1 : class, IUnit, new()
            where TN2 : class, IUnit, new()
            where TN3 : class, IUnit, new()
        {
            TN1 newUnit1 = new TN1();
            TN2 newUnit2 = new TN2();
            TN3 newUnit3 = new TN3();

            foreach (Type i in Unit1.GetType().GetInterfaces())
            {
                if (newUnit1.GetType().GetInterface(i.Name) == null)
                {
                    throw new InvalidCastException(String.Format(CultureInfo.CurrentCulture, "You cannot convert {0} to {1}", Unit1.GetType(), newUnit1.GetType()));
                }
            }
            foreach (Type i in Unit2.GetType().GetInterfaces())
            {
                if (newUnit2.GetType().GetInterface(i.Name) == null)
                {
                    throw new InvalidCastException(String.Format(CultureInfo.CurrentCulture, "You cannot convert {0} to {1}", Unit2.GetType(), newUnit2.GetType()));
                }
            }
            foreach (Type i in Unit3.GetType().GetInterfaces())
            {
                if (newUnit3.GetType().GetInterface(i.Name) == null)
                {
                    throw new InvalidCastException(String.Format(CultureInfo.CurrentCulture, "You cannot convert {0} to {1}", Unit3.GetType(), newUnit3.GetType()));
                }
            }

            double firstUnitValue  = ConvertUnits(newUnit1.GetType(), Unit1.GetType(), Value, Unit1Power);
            double secondUnitValue = ConvertUnits(newUnit2.GetType(), Unit2.GetType(), firstUnitValue, Unit2Power);
            double newValue        = ConvertUnits(newUnit3.GetType(), Unit3.GetType(), secondUnitValue, Unit3Power);

            return(new Scalar <TN1, TN2, TN3>()
            {
                Value = newValue,
                Unit1 = newUnit1,
                Unit2 = newUnit2,
                Unit3 = newUnit3,
                Unit1Power = Unit1Power,
                Unit2Power = Unit2Power,
                Unit3Power = Unit3Power,
            });
        }
Exemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            // number
            StringBuilder returnString = new StringBuilder(Value.ToString(CultureInfo.CurrentCulture));

            // first unit
            returnString.AppendFormat(
                " {0}{1}",
                Unit1.GetType().Name,
                ((Unit1Power == 1) ?
                 String.Empty :
                 ("^" + Unit1Power)));

            // divider
            returnString.Append((Unit2Power < 0) ? "/" : "*");

            // second unit
            returnString.AppendFormat(
                "{0}{1}",
                Unit2.GetType().Name,
                ((Unit2Power == 1) ?
                 String.Empty :
                 ("^" + Math.Abs(Unit2Power))));

            // divider
            returnString.Append((Unit2Power < 0 && Unit3Power < 0) ? "*" : "/");

            // third unit
            returnString.AppendFormat(
                "{0}{1}",
                Unit3.GetType().Name,
                ((Unit3Power == 1) ?
                 String.Empty :
                 ("^" + Math.Abs(Unit3Power))));

            return(returnString.ToString());
        }