Ejemplo n.º 1
0
        public static void SetValue(Control control, string textValue, Type columnType)
        {
            IEnumerator enumerator = null;

            if (control is TextBox)
            {
                TextBox box = (TextBox)control;
                box.Text = textValue;
            }
            if (control is Label)
            {
                Label label = (Label)control;
                label.Text = textValue;
            }
            if (control is UltraLabel)
            {
                UltraLabel label2 = (UltraLabel)control;
                label2.Text = textValue;
            }
            if (control is UltraDateTimeEditor)
            {
                UltraDateTimeEditor editor = (UltraDateTimeEditor)control;
                editor.Text = textValue;
            }
            if (control is UltraTextEditor)
            {
                UltraTextEditor editor2 = (UltraTextEditor)control;
                editor2.Text = textValue;
            }
            if (control is UltraNumericEditor)
            {
                UltraNumericEditor editor3 = (UltraNumericEditor)control;
                if (editor3.NumericType == NumericType.Double)
                {
                    editor3.Value = double.Parse(textValue, CultureInfo.CurrentCulture);
                }
                else
                {
                    editor3.Value = long.Parse(textValue, CultureInfo.CurrentCulture);
                }
            }
            if (control is UltraMaskedEdit)
            {
                UltraMaskedEdit edit = (UltraMaskedEdit)control;
                edit.Text = textValue;
            }
            if (control is UltraCheckEditor)
            {
                UltraCheckEditor editor4 = (UltraCheckEditor)control;
                if ((textValue == "true") || (textValue == "True"))
                {
                    editor4.Checked = true;
                }
                else
                {
                    editor4.Checked = false;
                }
            }
            if (control is CheckBox)
            {
                CheckBox box2 = (CheckBox)control;
                if ((textValue == "true") || (textValue == "True"))
                {
                    box2.Checked = true;
                }
                else
                {
                    box2.Checked = false;
                }
            }
            if (!(control is ComboBox))
            {
                goto Label_0252;
            }
            ComboBox box3        = (ComboBox)control;
            object   objectValue = RuntimeHelpers.GetObjectValue(box3.SelectedValue);

            if (box3.DisplayMember == box3.ValueMember)
            {
                box3.SelectedIndex = box3.FindStringExact(textValue);
                goto Label_0252;
            }
            string valueMember = box3.ValueMember;

            valueMember = valueMember.Substring(valueMember.IndexOf(".") + 1);
            try
            {
                enumerator = box3.Items.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    object      obj3 = RuntimeHelpers.GetObjectValue(enumerator.Current);
                    DataRowView view = (DataRowView)obj3;
                    if (view.Row[valueMember].ToString().Trim().Equals(textValue.Trim()))
                    {
                        box3.SelectedItem = RuntimeHelpers.GetObjectValue(obj3);
                        goto Label_023F;
                    }
                }
            }
            finally
            {
                if (enumerator is IDisposable)
                {
                    (enumerator as IDisposable).Dispose();
                }
            }
Label_023F:
            box3.SelectedValue = RuntimeHelpers.GetObjectValue(ConvertStringToTyped(textValue, columnType));
Label_0252:
            if (typeof(DeklaritComboBox).IsAssignableFrom(control.GetType()))
            {
                DeklaritComboBox box4 = (DeklaritComboBox)control;
                object           obj4 = RuntimeHelpers.GetObjectValue(box4.Value);
                if (box4.DisplayMember == box4.ValueMember)
                {
                    box4.SelectedIndex = box4.FindStringExact(textValue);
                }
                else
                {
                    string str2 = box4.ValueMember;
                    str2 = str2.Substring(str2.IndexOf(".") + 1);
                    ValueListItemEnumerator enumerator2 = box4.Items.GetEnumerator();
                    while (enumerator2.MoveNext())
                    {
                        ValueListItem current    = enumerator2.Current;
                        DataRowView   listObject = (DataRowView)current.ListObject;
                        if (listObject.Row[str2].ToString().Trim().Equals(textValue.Trim()))
                        {
                            box4.SelectedItem = current;
                            break;
                        }
                    }
                    box4.Value = RuntimeHelpers.GetObjectValue(ConvertStringToTyped(textValue, columnType));
                }
            }
            if (typeof(UltraComboEditor).IsAssignableFrom(control.GetType()))
            {
                UltraComboEditor editor5 = (UltraComboEditor)control;
                object           obj5    = RuntimeHelpers.GetObjectValue(editor5.Value);
                if (editor5.DisplayMember == editor5.ValueMember)
                {
                    editor5.SelectedIndex = editor5.FindStringExact(textValue);
                }
                else
                {
                    string str3 = editor5.ValueMember;
                    str3 = str3.Substring(str3.IndexOf(".") + 1);
                    ValueListItemEnumerator enumerator3 = editor5.Items.GetEnumerator();
                    while (enumerator3.MoveNext())
                    {
                        ValueListItem item2 = enumerator3.Current;
                        DataRowView   view3 = (DataRowView)item2.ListObject;
                        if (view3.Row[str3].ToString().Trim().Equals(textValue.Trim()))
                        {
                            editor5.SelectedItem = item2;
                            break;
                        }
                    }
                    editor5.Value = RuntimeHelpers.GetObjectValue(ConvertStringToTyped(textValue, columnType));
                }
            }
        }
Ejemplo n.º 2
0
        private void CalcCountPlanRate(UltraCheckEditor cbx_Checked, UltraNumericEditor edt_Num, UltraCheckEditor cbx_Fcflag, Label lbl_Result)
        {
            try
            {
                UltraGridRow row = ultraGrid1.ActiveRow;

                if (ultraGrid1.Rows.Count <= 0 || row == null)
                {
                    lbl_Result.Text = "";
                    return;
                }

                if (!cbx_Checked.Checked || cbx_Fcflag.Checked)
                {
                    lbl_Result.Text = "";
                    return;
                }

                if (edt_Num.Value == null || string.IsNullOrEmpty(edt_Num.Value.ToString().Trim()))
                {
                    lbl_Result.Text = "";
                    return;
                }

                if (Edt_WgtLL.Value == null || string.IsNullOrEmpty(Edt_WgtLL.Value.ToString().Trim()))
                {
                    lbl_Result.Text = "";
                    return;
                }

                if (row.ParentRow != null)
                    row = row.ParentRow;

                string strTotal = Convert.ToString(row.Cells["FN_ZZ_WEIGHT"].Value).Trim();

                if (string.IsNullOrEmpty(strTotal) || strTotal.Equals("0"))
                {
                    strTotal = Convert.ToString(row.Cells["FN_ZC_ENTERWEIGHT"].Value).Trim();
                }

                if (string.IsNullOrEmpty(strTotal) || strTotal.Equals("0"))
                {
                    strTotal = Convert.ToString(row.Cells["FN_BILLET_WEIGHT"].Value).Trim();
                }

                if (string.IsNullOrEmpty(strTotal) || strTotal.Equals("0"))
                {
                    lbl_Result.Text = "";
                    return;
                }

                decimal dUnit = 0.0M;
                decimal dCount = 0.0M;
                decimal dTotal = 0.0M;

                bool bOK = decimal.TryParse(strTotal, out dTotal);

                if (!bOK)
                {
                    lbl_Result.Text = "";
                    return;
                }

                bOK = decimal.TryParse(edt_Num.Value.ToString().Trim(), out dCount);

                if (!bOK)
                {
                    lbl_Result.Text = "";
                    return;
                }

                bOK = decimal.TryParse(Edt_WgtLL.Value.ToString().Trim(), out dUnit);

                if (!bOK || dUnit <= 0)
                {
                    lbl_Result.Text = "";
                    return;
                }

                decimal dRate = Math.Round(100 * dCount * dUnit / dTotal, 2);

                if (dRate < 95.0M)
                {
                    lbl_Result.ForeColor = Color.Red;
                }
                else if (dRate > 107.0M)
                {
                    lbl_Result.ForeColor = Color.Blue;
                }
                else
                {
                    lbl_Result.ForeColor = Color.Green;
                }

                lbl_Result.Text = Convert.ToString(dRate) + "%";
            }
            catch
            {
                lbl_Result.Text = "";
            }
        }
Ejemplo n.º 3
0
 public static void SetReadOnly(Control control, bool readOnlyValue)
 {
     if (control is TextBox)
     {
         TextBox box = (TextBox)control;
         box.ReadOnly = readOnlyValue;
     }
     if (control is Label)
     {
         Label label = (Label)control;
         label.Enabled = !readOnlyValue;
     }
     if (control is UltraDateTimeEditor)
     {
         UltraDateTimeEditor editor = (UltraDateTimeEditor)control;
         editor.Enabled = !readOnlyValue;
     }
     if (control is UltraTextEditor)
     {
         UltraTextEditor editor2 = (UltraTextEditor)control;
         editor2.Enabled = !readOnlyValue;
     }
     if (control is UltraNumericEditor)
     {
         UltraNumericEditor editor3 = (UltraNumericEditor)control;
         editor3.Enabled = !readOnlyValue;
     }
     if (control is UltraMaskedEdit)
     {
         UltraMaskedEdit edit = (UltraMaskedEdit)control;
         edit.Enabled = !readOnlyValue;
     }
     if (control is UltraCheckEditor)
     {
         UltraCheckEditor editor4 = (UltraCheckEditor)control;
         editor4.Enabled = !readOnlyValue;
     }
     if (control is CheckBox)
     {
         CheckBox box2 = (CheckBox)control;
         box2.Enabled = !readOnlyValue;
     }
     if (control is ComboBox)
     {
         ComboBox box3 = (ComboBox)control;
         box3.Enabled = !readOnlyValue;
     }
     if (control is Button)
     {
         Button button = (Button)control;
         button.Enabled = !readOnlyValue;
     }
     if (control is LinkUltraLabelPrompt)
     {
         LinkUltraLabelPrompt prompt = (LinkUltraLabelPrompt)control;
         prompt.Enabled = !readOnlyValue;
     }
     if (typeof(DeklaritComboBox).IsAssignableFrom(control.GetType()))
     {
         DeklaritComboBox box4 = (DeklaritComboBox)control;
         box4.Enabled = !readOnlyValue;
     }
     if (typeof(UltraComboEditor).IsAssignableFrom(control.GetType()))
     {
         UltraComboEditor editor5 = (UltraComboEditor)control;
         editor5.Enabled = !readOnlyValue;
     }
 }