Пример #1
0
        public static void GetSingleCtrlAutoBindingData(Control ctrl, object obj)
        {
            string ObjectName  = obj.GetType().Name;
            string bindingname = "";

            if (ctrl is AutoTextBox)
            {
                AutoTextBox textbox = ctrl as AutoTextBox;
                if (textbox.BindingFor == ObjectName)
                {
                    if (!string.IsNullOrWhiteSpace(textbox.BindingName))
                    {
                        bindingname = textbox.BindingName;
                        SetProperty(bindingname, obj, textbox.Text);
                    }
                }
            }
            else
            if (ctrl is TextBoxValidation)
            {
                TextBoxValidation textbox = ctrl as TextBoxValidation;
                if (textbox.BindingFor == ObjectName)
                {
                    if (!string.IsNullOrWhiteSpace(textbox.BindingName))
                    {
                        bindingname = textbox.BindingName;
                        SetProperty(bindingname, obj, textbox.Text);
                    }
                }
            }
            else
            if (ctrl is StatusTextbox)
            {
                StatusTextbox textbox = ctrl as StatusTextbox;
                if (textbox.BindingFor == ObjectName)
                {
                    if (!string.IsNullOrWhiteSpace(textbox.BindingName))
                    {
                        bindingname = textbox.BindingName;
                        SetProperty(bindingname, obj, textbox.Text);
                    }
                }
            }
            else
            if (ctrl is AutoMetroTextBox)
            {
                AutoMetroTextBox textbox = ctrl as AutoMetroTextBox;
                if (textbox.BindingFor == ObjectName)
                {
                    if (!string.IsNullOrWhiteSpace(textbox.BindingName))
                    {
                        bindingname = textbox.BindingName;
                        SetProperty(bindingname, obj, textbox.Text);
                    }
                }
            }
            else
            if (ctrl is AutoFileTextBox)
            {
                AutoFileTextBox textbox = ctrl as AutoFileTextBox;
                if (textbox.BindingFor == ObjectName)
                {
                    if (!string.IsNullOrWhiteSpace(textbox.BindingName))
                    {
                        bindingname = textbox.BindingName;
                        SetProperty(bindingname, obj, textbox.FileName);
                    }
                }
            }
            else
            if (ctrl is AutoCombobox)
            {
                AutoCombobox combobox = ctrl as AutoCombobox;
                if (combobox.BindingFor == ObjectName)
                {
                    if (!string.IsNullOrWhiteSpace(combobox.BindingName))
                    {
                        bindingname = combobox.BindingName;
                        SetProperty(bindingname, obj, combobox.SelectedValue);
                    }
                }
            }
            else
            if (ctrl is AutoSearchCombobox)
            {
                AutoSearchCombobox combobox = ctrl as AutoSearchCombobox;
                if (combobox.BindingFor == ObjectName)
                {
                    if (!string.IsNullOrWhiteSpace(combobox.BindingName))
                    {
                        bindingname = combobox.BindingName;
                        if (combobox.GetSelectedText == true)
                        {
                            SetProperty(bindingname, obj, combobox.Text);
                        }
                        else
                        {
                            SetProperty(bindingname, obj, combobox.SelectedValue);
                        }
                    }
                }
            }

            else
            if (ctrl is AutoDatetime)
            {
                AutoDatetime dtp = ctrl as AutoDatetime;
                if (dtp.BindingFor == ObjectName)
                {
                    if (!string.IsNullOrWhiteSpace(dtp.BindingName))
                    {
                        bindingname = dtp.BindingName;
                        SetProperty(bindingname, obj, dtp.Value);
                    }
                }
            }
            else
            if (ctrl is AutoXDatetime)
            {
                AutoXDatetime dtp = ctrl as AutoXDatetime;
                if (dtp.BindingFor == ObjectName)
                {
                    if (!string.IsNullOrWhiteSpace(dtp.BindingName))
                    {
                        bindingname = dtp.BindingName;
                        SetProperty(bindingname, obj, dtp.DateTime);
                    }
                }
            }
            else
            if (ctrl is AutoPictureBox)
            {
                AutoPictureBox ptb = ctrl as AutoPictureBox;
                if (ptb.BindingFor == ObjectName)
                {
                    if (!string.IsNullOrWhiteSpace(ptb.BindingName))
                    {
                        bindingname = ptb.BindingName;
                        SetProperty(bindingname, obj, ptb.PictureName);
                        if (!string.IsNullOrWhiteSpace(ptb.PictureOriginPath))
                        {
                            PictureUtility.SaveImg(ptb.PictureOriginPath);
                        }
                    }
                }
            }
        }
Пример #2
0
        public static void GetAutoBindingData(Control controls, object obj)
        {
            string ObjectName  = obj.GetType().Name;
            string bindingname = "";

            foreach (Control ctrl in controls.Controls)
            {
                if (ctrl is AutoTextBox)
                {
                    AutoTextBox textbox = ctrl as AutoTextBox;
                    if (textbox.BindingFor != ObjectName)
                    {
                        continue;
                    }
                    if (string.IsNullOrWhiteSpace(textbox.BindingName))
                    {
                        continue;
                    }
                    bindingname = textbox.BindingName;
                    SetProperty(bindingname, obj, textbox.Text);
                }
                else
                if (ctrl is TextBoxValidation)
                {
                    TextBoxValidation textbox = ctrl as TextBoxValidation;
                    if (textbox.BindingFor != ObjectName)
                    {
                        continue;
                    }
                    if (string.IsNullOrWhiteSpace(textbox.BindingName))
                    {
                        continue;
                    }
                    bindingname = textbox.BindingName;
                    SetProperty(bindingname, obj, textbox.Text);
                }
                else
                if (ctrl is StatusTextbox)
                {
                    StatusTextbox textbox = ctrl as StatusTextbox;
                    if (textbox.BindingFor != ObjectName)
                    {
                        continue;
                    }
                    if (string.IsNullOrWhiteSpace(textbox.BindingName))
                    {
                        continue;
                    }
                    bindingname = textbox.BindingName;
                    SetProperty(bindingname, obj, textbox.Text);
                }
                else
                if (ctrl is AutoMetroTextBox)
                {
                    AutoMetroTextBox textbox = ctrl as AutoMetroTextBox;
                    if (textbox.BindingFor != ObjectName)
                    {
                        continue;
                    }
                    if (string.IsNullOrWhiteSpace(textbox.BindingName))
                    {
                        continue;
                    }
                    bindingname = textbox.BindingName;
                    SetProperty(bindingname, obj, textbox.Text);
                }
                else
                if (ctrl is AutoFileTextBox)
                {
                    AutoFileTextBox textbox = ctrl as AutoFileTextBox;
                    if (textbox.BindingFor != ObjectName)
                    {
                        continue;
                    }
                    if (string.IsNullOrWhiteSpace(textbox.BindingName))
                    {
                        continue;
                    }
                    bindingname = textbox.BindingName;
                    string text = string.IsNullOrWhiteSpace(textbox.FileName) == true ? textbox.Text : textbox.FileName;
                    SetProperty(bindingname, obj, text);
                }
                else
                if (ctrl is AutoCombobox)
                {
                    AutoCombobox combobox = ctrl as AutoCombobox;
                    if (combobox.BindingFor != ObjectName)
                    {
                        continue;
                    }
                    if (string.IsNullOrWhiteSpace(combobox.BindingName))
                    {
                        continue;
                    }
                    bindingname = combobox.BindingName;
                    SetProperty(bindingname, obj, combobox.SelectedValue);
                }
                else
                if (ctrl is AutoSearchCombobox)
                {
                    AutoSearchCombobox combobox = ctrl as AutoSearchCombobox;
                    if (combobox.BindingFor != ObjectName)
                    {
                        continue;
                    }
                    if (string.IsNullOrWhiteSpace(combobox.BindingName))
                    {
                        continue;
                    }
                    bindingname = combobox.BindingName;
                    if (combobox.GetSelectedText == true)
                    {
                        SetProperty(bindingname, obj, combobox.Text);
                    }
                    else
                    {
                        SetProperty(bindingname, obj, combobox.SelectedValue);
                    }
                }

                else
                if (ctrl is AutoDatetime)
                {
                    AutoDatetime dtp = ctrl as AutoDatetime;
                    if (dtp.BindingFor != ObjectName)
                    {
                        continue;
                    }
                    if (string.IsNullOrWhiteSpace(dtp.BindingName))
                    {
                        continue;
                    }
                    bindingname = dtp.BindingName;
                    SetProperty(bindingname, obj, dtp.Value);
                }
                else
                if (ctrl is AutoXDatetime)
                {
                    AutoXDatetime dtp = ctrl as AutoXDatetime;
                    if (dtp.BindingFor != ObjectName)
                    {
                        continue;
                    }
                    if (string.IsNullOrWhiteSpace(dtp.BindingName))
                    {
                        continue;
                    }
                    bindingname = dtp.BindingName;
                    SetProperty(bindingname, obj, dtp.DateTime);
                }
                else
                if (ctrl is AutoPictureBox)
                {
                    AutoPictureBox ptb = ctrl as AutoPictureBox;
                    if (ptb.BindingFor != ObjectName)
                    {
                        continue;
                    }
                    if (string.IsNullOrWhiteSpace(ptb.BindingName))
                    {
                        continue;
                    }
                    bindingname = ptb.BindingName;
                    SetProperty(bindingname, obj, ptb.PictureName);
                    if (!string.IsNullOrWhiteSpace(ptb.PictureOriginPath))
                    {
                        PictureUtility.SaveImg(ptb.PictureOriginPath);
                    }
                }
                if (ctrl is AutoMaterialCheckBox)
                {
                    AutoMaterialCheckBox cb = ctrl as AutoMaterialCheckBox;
                    if (cb.BindingFor != ObjectName)
                    {
                        continue;
                    }
                    if (string.IsNullOrWhiteSpace(cb.BindingName))
                    {
                        continue;
                    }
                    bindingname = cb.BindingName;
                    SetProperty(bindingname, obj, cb.Checked);
                }
                if (ctrl.Controls.Count > 0)
                {
                    GetAutoBindingData(ctrl, obj);
                }
            }
        }