예제 #1
0
            public static void CurrencyFormat(object sender, ConvertEventArgs e)
            {
                if (e.Value is System.DBNull)
                {
                    return;
                }

                e.Value = (Convert.ToDouble(e.Value)).ToString("C");
            }
예제 #2
0
            public static void DateFormat(object sender, ConvertEventArgs e)
            {
                if (e.Value is System.DBNull)
                {
                    return;
                }

                e.Value = Convert.ToDateTime(e.Value).ToShortDateString();
            }
예제 #3
0
            public static void PercentFormat(object sender, ConvertEventArgs e)
            {
                if (e.Value is System.DBNull)
                {
                    return;
                }

                double percentValue = Convert.ToDouble(e.Value);
                percentValue = percentValue / 100;
                e.Value = percentValue.ToString("P0");
            }
예제 #4
0
 /// <summary>
 /// TextBox控件绑定到货币类型数据源时的数据显示格式处理,添加到控件的Format事件。
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 public static void TextBox_Currency_Format(object sender, ConvertEventArgs e)
 {
     if (e.Value != null)
     {
         try
         {
             e.Value = ((int)e.Value).ToString() + "张";
         }
         catch
         {
         }
     }
 }
예제 #5
0
 /// <summary>
 /// TextBox控件绑定到货币类型数据源时的数据显示格式处理,添加到控件的Format事件。
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 public static void TextBox_Currency_Format1(object sender, ConvertEventArgs e)
 {
     if (e.Value != null)
     {
         try
         {
             e.Value = ((float)e.Value).ToString("0.00") + "元";
         }
         catch
         {
         }
     }
 }
예제 #6
0
        protected virtual void AppointmentTypeToIconConverter(object o, ConvertEventArgs e)
        {
            AppointmentType type = (AppointmentType)e.Value;

            if (type == AppointmentType.Pattern)
            {
                e.Value = RecurringIcon;
            }
            else
            {
                e.Value = NormalIcon;
            }
        }
예제 #7
0
        private void CheckBoxBinding_Format(object sender, ConvertEventArgs e)
        {
            switch (e.Value.ToString())
            {
            case "true":
                e.Value = true;
                break;

            default:
                e.Value = false;
                break;
            }
        }
예제 #8
0
 protected override void OnFormat(ConvertEventArgs cevent)
 {
     if (this._converter != null)
     {
         var converterdValue = this._converter.Convert(cevent.Value, cevent.DesiredType, _converterParameter,
                                                       _converterCulture);
         cevent.Value = converterdValue;
     }
     else
     {
         base.OnFormat(cevent);
     }
 }
예제 #9
0
        /// <summary>
        /// This handles converting from the selected index to a value
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event arguments</param>
        private void RoleStatus_Parse(object sender, ConvertEventArgs e)
        {
            ComboBox c = (ComboBox)(((Binding)sender).Control);

            if (c.SelectedIndex != -1)
            {
                e.Value = c.Items[c.SelectedIndex];
            }
            else
            {
                e.Value = null;
            }
        }
예제 #10
0
        private void ExtractBit7FromGivenRegisterContent(object sender, ConvertEventArgs e)
        {
            var givenRegisterContent = (int)e.Value;

            if ((givenRegisterContent & 128) != 0)
            {
                e.Value = "1";
            }
            else
            {
                e.Value = "0";
            }
        }
예제 #11
0
        private void ConvertRegisterContentToHexWith4Digits(object sender, ConvertEventArgs e)
        {
            var givenNumber = (int)e.Value;

            if (givenNumber == 0)
            {
                e.Value = "0000";
            }
            else
            {
                e.Value = givenNumber.ToString("X4").ToUpper();
            }
        }
예제 #12
0
        public static void LocalCurrency(object sender, ConvertEventArgs cevent)
        {
            // The method converts only to string type. Test this using the DesiredType.
            if ((cevent.DesiredType != typeof(string)) || cevent.Value == null)
            {
                return;
            }
            NumberFormatInfo nfi = (NumberFormatInfo)CultureInfo.CurrentCulture.NumberFormat.Clone();

            nfi.CurrencySymbol = LocalSimbolCurrency;
            // Use the ToString method to format the value as currency ("c").
            cevent.Value = ((decimal)cevent.Value).ToString("c" + DecimalLenght, nfi);
        }
예제 #13
0
 public static void rdSum_Parse(object sender, ConvertEventArgs e)
 {
     if (e.Value != System.DBNull.Value && e.Value != null && !string.IsNullOrEmpty(Convert.ToString(e.Value)))
     {
         //Делаем так, чтобы дробные числа всегда корректно переводились
         double d;
         if (SafeConvertToString(Convert.ToString(e.Value), out d))
         {
             d       = Math.Round(d, 2);
             e.Value = d;
         }
     }
 }
예제 #14
0
 private void OnCustomerResultName_Convert(object sender, ConvertEventArgs e)
 {
     if (e.DesiredType == typeof(string))
     {
         if (viewModel.SelectedResult != null && viewModel.SelectedResult.SearchType == SearchType.Customer)
         {
             e.Value = viewModel.SelectedResult.Name;
         }
         else
         {
             e.Value = null;
         }
     }
 }
예제 #15
0
 public void DateFormat(object sender, ConvertEventArgs e)
 {
     if ((e.DesiredType == typeof(string)) && (e.Value != null))
     {
         if (e.Value.Equals(DBNull.Value))
         {
             e.Value = "";
         }
         else if ((DateTime.Compare(Conversions.ToDate(e.Value), new UltraDateTimeEditor().MinDate) < 0) || (DateTime.Compare(Conversions.ToDate(e.Value), new UltraDateTimeEditor().MaxDate) > 0))
         {
             e.Value = "";
         }
     }
 }
예제 #16
0
        public override void ObjectParse(object sender, ConvertEventArgs e)
        {
            Font font = (DataSource as TextAttibute).Font;

            if ((bool)e.Value)
            {
                font = new Font(font, font.Style | style);
            }
            else
            {
                font = new Font(font, font.Style & (~style));
            }
            e.Value = font;
        }
예제 #17
0
        public override void ObjectFormat(object sender, ConvertEventArgs e)
        {
            ComboBoxEdit comboBoxEdit = ((sender as Binding).BindableComponent as ComboBoxEdit);
            string       rowHeight    = string.Format("{0:f2}倍行高", e.Value);

            for (int index = 0; index < comboBoxEdit.Properties.Items.Count; index++)
            {
                if (comboBoxEdit.Properties.Items[index].ToString() == rowHeight)
                {
                    e.Value = index;
                    break;
                }
            }
        }
예제 #18
0
        public override void ObjectFormat(object sender, ConvertEventArgs e)
        {
            ComboBoxEdit comboBoxEdit = ((sender as Binding).BindableComponent as ComboBoxEdit);
            Font         font         = e.Value as Font;

            for (int index = 0; index < comboBoxEdit.Properties.Items.Count; index++)
            {
                if (comboBoxEdit.Properties.Items[index].ToString() == "-" + font.Size)
                {
                    e.Value = index;
                    break;
                }
            }
        }
예제 #19
0
        public override void ObjectFormat(object sender, ConvertEventArgs e)
        {
            string       fontName     = (e.Value as Font).Name;
            ComboBoxEdit comboBoxEdit = ((sender as Binding).BindableComponent as ComboBoxEdit);

            if (comboBoxEdit.Properties.Items.Contains(fontName))
            {
                e.Value = comboBoxEdit.Properties.Items.IndexOf(fontName);
            }
            else
            {
                e.Value = 0;
            }
        }
예제 #20
0
 void CheckBoxEndOn_Parse(object sender, ConvertEventArgs e)
 {
     // from control to object
     if (e.DesiredType == typeof(DateTime?) && e.Value is bool)
     {
         //e.Value = ((bool)e.Value == true ? DateTime.Today : (DateTime?)null);
         if ((bool)e.Value == true)
         {
             e.Value = dtpEndDate.Value;
         }
         //else
         //    e.Value = ((Schedule)((BindingSource)((Binding)sender).DataSource).Current).EndDate;
     }
 }
예제 #21
0
        private void BinImg_Format(object sender, ConvertEventArgs e)
        {
            if (e.Value == null)
            {
                e.Value = null;
                return;
            }
            byte[]       b      = ((Binary)e.Value).ToArray();
            MemoryStream stream = new MemoryStream(b);
            Bitmap       bitmap = new Bitmap(stream);

            stream.Close();
            e.Value = bitmap;
        }
예제 #22
0
 private void FormatPercent(object sender, ConvertEventArgs e)
 {
     if (decimal.TryParse(e.Value == null ? null : e.Value.ToString(), out decimal comissao))
     {
         if (comissao > 0.99m)
         {
             e.Value = (((decimal)e.Value) / 100).ToString("#,##0.00%");
         }
         else
         {
             e.Value = ((decimal)e.Value).ToString("#,##0.00%");
         }
     }
 }
예제 #23
0
        protected override void OnParse(ConvertEventArgs cevent)
        {
            if (this._converter != null)
            {
                object converterdValue = this._converter.ConvertBack(cevent.Value, cevent.DesiredType, _converterParameter,
                                                                     _converterCulture);

                cevent.Value = converterdValue;
            }
            else
            {
                base.OnParse(cevent);
            }
        }
예제 #24
0
        private void phoneBinding_Parse(Object sender, ConvertEventArgs e)
        {
            String phoneNumberAndExt = e.Value.ToString();

            int    extIndex    = phoneNumberAndExt.IndexOf("x");
            String ext         = phoneNumberAndExt.Substring(extIndex).Trim();
            String phoneNumber = phoneNumberAndExt.Substring(0, extIndex).Trim();

            DataRowView currentRow = (DataRowView)BindingContext[employeesTable, "Employees"].Current;

            currentRow["Extension"] = ext.Substring(1);

            e.Value = phoneNumber;
        }
예제 #25
0
 public override void ObjectParse(object sender, ConvertEventArgs e)
 {
     if ((int)e.Value == 0)
     {
         e.Value = 0;
         relateControl.Enabled = true;
     }
     else
     {
         e.Value = -1;
         relateControl.Enabled = false;
     }
     relateControl.Refresh();
 }
예제 #26
0
        private void OnDateTimePicker_Parse(object sender, ConvertEventArgs e)
        {
            // CONTROL => OBJECT
            // e.Value is the formatted value coming from the control, we change it to want we want to set on the object

            if (this.dateTimePicker.Checked)
            {
                e.Value = new Nullable <DateTime>(Convert.ToDateTime(e.Value));
            }
            else
            {
                e.Value = null;
            }
        }
예제 #27
0
        void textLUBinding_Parse(object sender, ConvertEventArgs e)
        {
            Binding    b  = (Binding)sender;
            DataTable  dt = (DataTable)((BindingSource)b.DataSource).DataSource;
            DataColumn dc = dt.Columns[b.BindingMemberInfo.BindingMember];

            if (_performLookups &&
                !string.IsNullOrEmpty(e.Value.ToString()))
            {
//e.Value = _lookupTables.GetValueMember(dc.ExtendedProperties["foreign_key_resultset_name"].ToString(), e.Value.ToString(), "", e.Value.ToString());
                //e.Value = _sharedUtils.GetLookupValueMember(dc.ExtendedProperties["foreign_key_resultset_name"].ToString(), e.Value.ToString(), "", e.Value.ToString());
                e.Value = _sharedUtils.GetLookupValueMember(((DataRowView)((BindingSource)b.DataSource).Current).Row, dc.ExtendedProperties["foreign_key_dataview_name"].ToString(), e.Value.ToString(), "", e.Value.ToString());
            }
        }
예제 #28
0
        void OnFormat(object sender, ConvertEventArgs e)
        {
            if (_keyProperty > 0)
            {
                _errorProvider.SetError(_comboBox, "");
                return;
            }

            if (string.IsNullOrEmpty(_comboBox.Text))
            {
                e.Value = "";
                _errorProvider.SetError(_comboBox, string.Format("{0} required.", _friendlyName));
            }
        }
예제 #29
0
 private void bind_Parse(object sender, ConvertEventArgs e)
 {
     try
     {
         var val = e.Value.ToString();
         if (val == "")
         {
             e.Value = null;
         }
     }
     catch (Exception ex)
     {
     }
 }
예제 #30
0
        // Called when formatting value is needed
        private static void BindingFormat(object sender, ConvertEventArgs e)
        {
            var _sender = sender as Binding;

            if (_sender != null && _sender.Control.Tag is FormatValueDelegate)
            {
                var _data  = (FormatValueDelegate)_sender.Control.Tag;
                var _value = _data.Invoke(_sender.BindingManagerBase.Current, _sender.BindingMemberInfo.BindingField);
                if (_value != null)
                {
                    e.Value = _value.ToString();
                }
            }
        }
예제 #31
0
 /**
  * Function to format the zip code with a hyphen between the first 5 and last 4 digits for readability
  */
 private void FormatZipCode(object sender, ConvertEventArgs e)
 {
     if (e.Value.GetType().ToString() == "System.String")
     {
         string s = e.Value.ToString();
         if (IsInt64(s))
         {
             if (s.Length == 9)
             {
                 e.Value = s.Substring(0, 5) + "-" +
                           s.Substring(5, 4);
             }
         }
     }
 }
예제 #32
0
        /// <summary>
        /// Invokes list item formatting
        /// </summary>
        protected String PerformFormat(object item)
        {
            if (HasEvents)
            {
                ConvertEventHandler handler = (ConvertEventHandler)Events[FormatEvent];
                if (handler != null)
                {
                    var e = new ConvertEventArgs(item, typeof(String));
                    handler(this, e);
                    return(e.Value != null?e.Value.ToString() : null);
                }
            }

            return(null);
        }
예제 #33
0
 void LapTimeView_MPHDelta_Format(object sender, ConvertEventArgs e)
 {
     if ((Single)e.Value == 0)
     {
         this.lapMPHDeltaLabel1.ForeColor = Color.Black;
     }
     else if ((Single)e.Value > 0)
     {
         this.lapMPHDeltaLabel1.ForeColor = Color.Green;
     }
     else
     {
         this.lapMPHDeltaLabel1.ForeColor = Color.Red;
     }
 }
 private void ReturnEmpty(
   object sender, ConvertEventArgs e)
 {
   e.Value = GetEmptyValue(e.DesiredType);
 }
예제 #35
0
 /// <summary>
 /// 转换文件的某些过程中触发
 /// </summary>
 /// <param name="e"></param>
 private void OnConvertEvent(ConvertEventArgs e)
 {
     if (m_processBar.InvokeRequired)
     {
         Convertor.ConvertEventHandler invokeProcess = new Convertor.ConvertEventHandler(OnConvertEvent);
         this.Invoke(invokeProcess, new object[] { e });
     }
     else
     {
         switch (e.ConvertedNum)
         {
             case 0:
                 m_processBar.Visible = true;
                 m_processBar.Minimum = 0;
                 m_processBar.Maximum = e.TotalFileNum;
                 m_processBar.Value = 0;
                 m_processBar.Step = 1;
                 break;
             case -1:
                 m_processBar.Step = 0;
                 m_processBar.Visible = false;
                 break;
             default:
                 m_processBar.PerformStep();
                 break;
         }
     }
 }
 /// <summary>
 /// Updates the customer's last activity date after the basket has been converted
 /// </summary>
 /// <param name="sender">
 /// The sender.
 /// </param>
 /// <param name="e">
 /// The e.
 /// </param>
 private void OnBasketConverted(BasketConversionBase sender, ConvertEventArgs<BasketConversionPair> e)
 {
     foreach (var pair in e.CovertedEntities.ToArray())
     {
         var customer = (ICustomer)pair.CustomerBasket.Customer;
         customer.LastActivityDate = DateTime.Now;
         MerchelloContext.Current.Services.CustomerService.Save(customer);
     }
 }