Exemplo n.º 1
0
        public void DrawAll(DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e, string fieldname = "Stt")
        {
            if (e.Column.FieldName == fieldname)
            {
                if (e.RowHandle >= 0)
                {
                    e.DisplayText = (e.RowHandle + 1).ToString();
                }
            }
            if (colTotalDescription != null)
            {
                string text = string.Empty;
                if (e.Column == colTotalDescription)
                {
                    obj  = m_Gridview.GetRow(e.RowHandle);
                    text = e.CellValue != null?e.CellValue.ToString() : "";

                    text = ProductUtility.ConvertToDescription(obj, ProductUtility.QuotationDetailToDescription);
                    GridCellInfo cell = e.Cell as GridCellInfo;
                    e.Appearance.FillRectangle(e.Cache, e.Bounds);
                    StringFormat f = cell.ViewInfo.PaintAppearance.GetStringFormat(TextOptions.DefaultOptionsMultiLine);
                    e.Graphics.DrawString(text, cell.ViewInfo.PaintAppearance.Font,
                                          cell.ViewInfo.PaintAppearance.GetForeBrush(e.Cache),
                                          e.Bounds, f);
                    e.Handled = true;
                }
            }
            if (colProductPicture != null && colProductPicturePath != null)
            {
                if (e.Column == colProductPicture)
                {
                    string path = string.Empty;
                    path = m_Gridview.GetRowCellValue(e.RowHandle, colProductPicturePath) != null?m_Gridview.GetRowCellValue(e.RowHandle, colProductPicturePath).ToString() : "";

                    Image img = PictureUtility.GetImg(path);
                    e.Graphics.DrawImage(img, e.Bounds.X, e.Bounds.Y, e.Bounds.Height, e.Bounds.Height);
                }
            }
            if (colDimensionPicturePath != null && colDimensionPicture != null)
            {
                if (e.Column == colDimensionPicture)
                {
                    string path = string.Empty;
                    path = m_Gridview.GetRowCellValue(e.RowHandle, colDimensionPicturePath) != null?m_Gridview.GetRowCellValue(e.RowHandle, colDimensionPicturePath).ToString() : "";

                    if (FileUtility.PathIsImage(path))
                    {
                        e.DisplayText = "";
                        Image img = PictureUtility.GetImg(path);
                        e.Graphics.DrawImage(img, e.Bounds.X, e.Bounds.Y, e.Bounds.Height, e.Bounds.Height);
                    }
                    //else
                    //    e.DisplayText = path;
                }
            }
        }
Exemplo n.º 2
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);
                        }
                    }
                }
            }
        }
Exemplo n.º 3
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);
                }
            }
        }
Exemplo n.º 4
0
        public static void SetSingleCtrlAutoBindingData(Control ctrl, object obj)
        {
            if (obj == null)
            {
                return;
            }
            string ObjectName  = obj.GetType().Name;
            string bindingname = "";
            object val         = null;

            if (ctrl is AutoTextBox)
            {
                AutoTextBox textbox = ctrl as AutoTextBox;
                if (textbox.BindingFor == ObjectName)
                {
                    if (!string.IsNullOrWhiteSpace(textbox.BindingName))
                    {
                        bindingname  = textbox.BindingName;
                        val          = GetPropertyValue(bindingname, obj);
                        textbox.Text = val != null?val.ToString() : "";
                    }
                }
            }
            else
            if (ctrl is TextBoxValidation)
            {
                TextBoxValidation textbox = ctrl as TextBoxValidation;
                if (textbox.BindingFor == ObjectName)
                {
                    if (!string.IsNullOrWhiteSpace(textbox.BindingName))
                    {
                        bindingname  = textbox.BindingName;
                        val          = GetPropertyValue(bindingname, obj);
                        textbox.Text = val != null?val.ToString() : "";
                    }
                }
            }
            else
            if (ctrl is StatusTextbox)
            {
                StatusTextbox textbox = ctrl as StatusTextbox;
                if (textbox.BindingFor == ObjectName)
                {
                    if (!string.IsNullOrWhiteSpace(textbox.BindingName))
                    {
                        bindingname  = textbox.BindingName;
                        val          = GetPropertyValue(bindingname, obj);
                        textbox.Text = val != null?val.ToString() : "";
                    }
                }
            }
            else
            if (ctrl is AutoMetroTextBox)
            {
                AutoMetroTextBox textbox = ctrl as AutoMetroTextBox;
                if (textbox.BindingFor == ObjectName)
                {
                    if (!string.IsNullOrWhiteSpace(textbox.BindingName))
                    {
                        bindingname  = textbox.BindingName;
                        val          = GetPropertyValue(bindingname, obj);
                        textbox.Text = val != null?val.ToString() : "";
                    }
                }
            }
            else
            if (ctrl is AutoFileTextBox)
            {
                AutoFileTextBox textbox = ctrl as AutoFileTextBox;
                if (textbox.BindingFor == ObjectName)
                {
                    if (!string.IsNullOrWhiteSpace(textbox.BindingName))
                    {
                        bindingname  = textbox.BindingName;
                        val          = GetPropertyValue(bindingname, obj);
                        textbox.Text = val != null?val.ToString() : "";

                        textbox.FileName = textbox.Text;
                    }
                }
            }
            else
            if (ctrl is AutoDatetime)
            {
                AutoDatetime dtp = ctrl as AutoDatetime;
                if (dtp.BindingFor == ObjectName)
                {
                    if (!string.IsNullOrWhiteSpace(dtp.BindingName))
                    {
                        bindingname = dtp.BindingName;
                        val         = GetPropertyValue(bindingname, obj);
                        dtp.Value   = val != null?Convert.ToDateTime(val) : UtilityFunction.minDate;
                    }
                }
            }
            else
            if (ctrl is AutoXDatetime)
            {
                AutoXDatetime dtp = ctrl as AutoXDatetime;
                if (dtp.BindingFor == ObjectName)
                {
                    if (!string.IsNullOrWhiteSpace(dtp.BindingName))
                    {
                        bindingname  = dtp.BindingName;
                        val          = GetPropertyValue(bindingname, obj);
                        dtp.DateTime = val != null?Convert.ToDateTime(val) : UtilityFunction.minDate;
                    }
                }
            }
            else
            if (ctrl is AutoPictureBox)
            {
                AutoPictureBox ptb = ctrl as AutoPictureBox;
                if (ptb.BindingFor == ObjectName)
                {
                    if (!string.IsNullOrWhiteSpace(ptb.BindingName))
                    {
                        bindingname     = ptb.BindingName;
                        val             = GetPropertyValue(bindingname, obj);
                        ptb.PictureName = val != null?val.ToString() : "";

                        ptb.Image = PictureUtility.GetImg(ptb.PictureName);
                        if (ptb.Image == null)
                        {
                            ptb.Image = TmTech_v1.Properties.Resources.unknow;
                        }
                        ptb.SizeMode = PictureBoxSizeMode.StretchImage;
                    }
                }
            }
            else
            if (ctrl is AutoCombobox)
            {
                AutoCombobox cbb = ctrl as AutoCombobox;
                if (cbb.BindingFor == ObjectName)
                {
                    if (!string.IsNullOrWhiteSpace(cbb.BindingName))
                    {
                        bindingname       = cbb.BindingName;
                        val               = GetPropertyValue(bindingname, obj);
                        cbb.SelectedValue = val != null?Convert.ToInt32(val) : 0;
                    }
                }
            }
            else
            if (ctrl is AutoSearchCombobox)
            {
                AutoSearchCombobox cbb = ctrl as AutoSearchCombobox;
                if (cbb.BindingFor == ObjectName)
                {
                    if (!string.IsNullOrWhiteSpace(cbb.BindingName))
                    {
                        bindingname = cbb.BindingName;
                        val         = GetPropertyValue(bindingname, obj);
                        if (cbb.GetSelectedText == true)
                        {
                            cbb.Text = val != null?val.ToString() : "";
                        }
                        else
                        {
                            cbb.SelectedValue = val != null?Convert.ToInt32(val) : 0;
                        }
                    }
                }
            }
        }
Exemplo n.º 5
0
        public static void SetAutoBindingData(Control controls, object obj)
        {
            if (obj == null)
            {
                return;
            }
            string ObjectName  = obj.GetType().Name;
            string bindingname = "";
            object val         = null;

            foreach (Control ctrl in controls.Controls)
            {
                if (ctrl is TextBoxValidation)
                {
                    TextBoxValidation textbox = ctrl as TextBoxValidation;
                    if (textbox.BindingFor != ObjectName)
                    {
                        continue;
                    }
                    if (string.IsNullOrWhiteSpace(textbox.BindingName))
                    {
                        continue;
                    }
                    bindingname  = textbox.BindingName;
                    val          = GetPropertyValue(bindingname, obj);
                    textbox.Text = val != null?val.ToString() : "";
                }
                else if (ctrl is StatusTextbox)
                {
                    StatusTextbox textbox = ctrl as StatusTextbox;
                    if (textbox.BindingFor != ObjectName)
                    {
                        continue;
                    }
                    if (string.IsNullOrWhiteSpace(textbox.BindingName))
                    {
                        continue;
                    }
                    bindingname  = textbox.BindingName;
                    val          = GetPropertyValue(bindingname, obj);
                    textbox.Text = val != null?val.ToString() : "";

                    if (!string.IsNullOrWhiteSpace(textbox.StatusFieldName))
                    {
                        var statusValue = GetPropertyValue(textbox.StatusFieldName, obj);
                        int status      = statusValue != null?Convert.ToInt32(statusValue) : 0;

                        textbox.Display(status);
                    }
                }
                else if (ctrl is AutoTextBox)
                {
                    AutoTextBox textbox = ctrl as AutoTextBox;
                    if (textbox.BindingFor != ObjectName)
                    {
                        continue;
                    }
                    if (string.IsNullOrWhiteSpace(textbox.BindingName))
                    {
                        continue;
                    }
                    bindingname  = textbox.BindingName;
                    val          = GetPropertyValue(bindingname, obj);
                    textbox.Text = val != null?val.ToString() : "";
                }

                else if (ctrl is AutoMetroTextBox)
                {
                    AutoMetroTextBox textbox = ctrl as AutoMetroTextBox;
                    if (textbox.BindingFor != ObjectName)
                    {
                        continue;
                    }
                    if (string.IsNullOrWhiteSpace(textbox.BindingName))
                    {
                        continue;
                    }
                    bindingname  = textbox.BindingName;
                    val          = GetPropertyValue(bindingname, obj);
                    textbox.Text = val != null?val.ToString() : "";
                }
                else if (ctrl is AutoFileTextBox)
                {
                    AutoFileTextBox textbox = ctrl as AutoFileTextBox;
                    if (textbox.BindingFor != ObjectName)
                    {
                        continue;
                    }
                    if (string.IsNullOrWhiteSpace(textbox.BindingName))
                    {
                        continue;
                    }
                    bindingname  = textbox.BindingName;
                    val          = GetPropertyValue(bindingname, obj);
                    textbox.Text = val != null?val.ToString() : "";

                    if (FileUtility.PathIsImage(textbox.Text))
                    {
                        textbox.FilePath = PictureUtility.getImgLocation(textbox.Text);
                    }
                    textbox.FileName = textbox.Text;
                }
                else if (ctrl is AutoDatetime)
                {
                    AutoDatetime dtp = ctrl as AutoDatetime;
                    if (dtp.BindingFor != ObjectName)
                    {
                        continue;
                    }
                    if (string.IsNullOrWhiteSpace(dtp.BindingName))
                    {
                        continue;
                    }
                    bindingname = dtp.BindingName;
                    val         = GetPropertyValue(bindingname, obj);
                    dtp.Value   = val != null?Convert.ToDateTime(val) : UtilityFunction.minDate;
                }
                else if (ctrl is AutoXDatetime)
                {
                    AutoXDatetime dtp = ctrl as AutoXDatetime;
                    if (dtp.BindingFor != ObjectName)
                    {
                        continue;
                    }
                    if (string.IsNullOrWhiteSpace(dtp.BindingName))
                    {
                        continue;
                    }
                    bindingname  = dtp.BindingName;
                    val          = GetPropertyValue(bindingname, obj);
                    dtp.DateTime = val != null?Convert.ToDateTime(val) : UtilityFunction.minDate;
                }
                else if (ctrl is AutoPictureBox)
                {
                    AutoPictureBox ptb = ctrl as AutoPictureBox;
                    if (ptb.BindingFor != ObjectName)
                    {
                        continue;
                    }
                    if (string.IsNullOrWhiteSpace(ptb.BindingName))
                    {
                        continue;
                    }
                    bindingname     = ptb.BindingName;
                    val             = GetPropertyValue(bindingname, obj);
                    ptb.PictureName = val != null?val.ToString() : "";

                    ptb.Image = PictureUtility.GetImg(ptb.PictureName);
                    if (ptb.Image == null)
                    {
                        ptb.Image = TmTech_v1.Properties.Resources.unknow;
                    }
                    ptb.SizeMode = PictureBoxSizeMode.StretchImage;
                }
                else if (ctrl is AutoCombobox)
                {
                    AutoCombobox cbb = ctrl as AutoCombobox;
                    if (cbb.BindingFor != ObjectName)
                    {
                        continue;
                    }
                    if (string.IsNullOrWhiteSpace(cbb.BindingName))
                    {
                        continue;
                    }
                    bindingname       = cbb.BindingName;
                    val               = GetPropertyValue(bindingname, obj);
                    cbb.SelectedValue = val != null?Convert.ToInt32(val) : 0;
                }
                else if (ctrl is AutoSearchCombobox)
                {
                    AutoSearchCombobox cbb = ctrl as AutoSearchCombobox;
                    if (cbb.BindingFor != ObjectName)
                    {
                        continue;
                    }
                    if (string.IsNullOrWhiteSpace(cbb.BindingName))
                    {
                        continue;
                    }
                    bindingname = cbb.BindingName;
                    val         = GetPropertyValue(bindingname, obj);
                    if (cbb.GetSelectedText == true)
                    {
                        cbb.Text = val != null?val.ToString() : "";
                    }
                    else
                    {
                        cbb.SelectedValue = val != null?Convert.ToInt32(val) : 0;
                    }
                }
                else if (ctrl is AutoMaterialCheckBox)
                {
                    AutoMaterialCheckBox cb = ctrl as AutoMaterialCheckBox;
                    if (cb.BindingFor != ObjectName)
                    {
                        continue;
                    }
                    if (string.IsNullOrWhiteSpace(cb.BindingName))
                    {
                        continue;
                    }
                    bindingname = cb.BindingName;
                    val         = GetPropertyValue(bindingname, obj);
                    cb.Checked  = val == null ? false : Convert.ToBoolean(val);
                }
                if (ctrl.Controls.Count > 0)
                {
                    SetAutoBindingData(ctrl, obj);
                }
            }
        }