Ejemplo n.º 1
0
        public void ListSetRow(DataRow row)
        {
            try
            {
                string name = Static.ToStr(row["name"]);
                if (string.IsNullOrEmpty(name))
                {
                    name = "[NO NAME]";
                }

                DynamicParameterItem item = ucParameterPanel1.ItemAdd(
                    Static.ToStr(row["itemid"])
                    , Static.ToStr(row["name"])
                    , Static.ToStr(row["name2"])
                    , Static.ToStr(row["value"])
                    , (ISM.Template.DynamicParameterType)Static.ToInt(row["valuetype"])
                    , Static.ToInt(row["valuelength"])
                    , Static.ToStr(row["valuedefault"])
                    , Static.ToBool(row["mandatory"])
                    , Static.ToStr(row["editmask"])
                    , Static.ToStr(row["description"])
                    , Static.ToStr(row["dictid"])
                    , Static.ToBool(row["dicteditable"])
                    , Static.ToStr(row["dictvaluefield"])
                    , Static.ToStr(row["dictdescfield"])
                    , Static.ToInt(row["orderno"])
                    );

                item.AttachId = (ulong)Static.ToLong(row["attachid"]);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Ejemplo n.º 2
0
        void vGridControl1_FocusedRowChanged(object sender, DevExpress.XtraVerticalGrid.Events.FocusedRowChangedEventArgs e)
        {
            try
            {
                if (e.Row == null)
                {
                    return;
                }
                DynamicParameterItem pi = (DynamicParameterItem)e.Row.Tag;
                _row = pi;

                if (pi != null)
                {
                    labelControl1.Text = pi.Description;
                }

                if (e.OldRow != null)
                {
                    DynamicParameterItem old = (DynamicParameterItem)e.OldRow.Tag;
                    OnEventRowChanged(pi.Id, e.Row.Index, pi.Value, old.Id, e.OldRow.Index, old.Value);
                }
                else
                {
                    OnEventRowChanged(pi.Id, e.Row.Index, pi.Value, pi.Id, e.Row.Index, pi.Value);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Ejemplo n.º 3
0
        public void ItemSetList(string Id, DataTable Table, string ValueField, string NameField, string Filter, int[] HiddenColumns)
        {
            try
            {
                EditorRow            erow = null;
                DynamicParameterItem pi   = ItemGet(Id);
                if (pi != null)
                {
                    erow = pi.Row;
                }

                if (erow != null)
                {
                    if (pi.ValueType == DynamicParameterType.List)
                    {
                        RepositoryItemLookUpEdit edit = (RepositoryItemLookUpEdit)erow.Properties.RowEdit;
                        if (pi.ValueType == DynamicParameterType.List)
                        {
                            FormUtility.LookUpEdit_SetList(ref edit, Table, ValueField.ToUpper(), NameField.ToUpper());
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
Ejemplo n.º 4
0
        void vGridControl1_CellValueChanged(object sender, DevExpress.XtraVerticalGrid.Events.CellValueChangedEventArgs e)
        {
            DynamicParameterItem pi = (DynamicParameterItem)e.Row.Tag;

            if (pi != null)
            {
                if (pi.Editing)
                {
                    e.Row.Appearance.ForeColor = System.Drawing.Color.Red;
                }

                switch (pi.ValueType)
                {
                case DynamicParameterType.Color:
                    //2011.06.21 ri.StoreColorAsInteger = true; болгосон тул шаардлагагүй

                    //Color c = (Color)e.Row.Properties.Value;
                    //pi.Value = string.Format("{0},{1},{2}", c.R, c.G, c.B);
                    break;

                default:
                    pi.Value = e.Row.Properties.Value;
                    break;
                }
            }
        }
Ejemplo n.º 5
0
        public DynamicParameterItem ItemAdd(string Id, string Name, string Name2, string Value, DynamicParameterType ValueType, int ValueLength, object ValueDefault, bool Mandatory, string EditMask, string Description, string DictId, bool DictEditable, string DictValueField, string DictDescField, int Orderno)
        {
            #region Creating new instance of DynamicParameterItem
            DynamicParameterItem pi = new DynamicParameterItem();
            pi.Id             = Id;
            pi.Name           = Name;
            pi.Name2          = Name2;
            pi.Value          = Value;
            pi.ValueType      = ValueType;
            pi.ValueLength    = (ValueLength <= 0 ? 12 : ValueLength);
            pi.ValueDefault   = ValueDefault;
            pi.Mandatory      = Mandatory;
            pi.EditMask       = EditMask;
            pi.Description    = Description;
            pi.DictId         = DictId;
            pi.DictEditable   = DictEditable;
            pi.DictValueField = DictValueField;
            pi.DictDescField  = DictDescField;
            pi.Orderno        = Orderno;
            #endregion

            #region Add item into list
            lock (_hitems.SyncRoot)
            {
                _hitems[Id] = pi;
                _aitems.Add(pi);
            }
            #endregion

            return(pi);
        }
Ejemplo n.º 6
0
        void riImageEdit_ButtonClick(object sender, ButtonPressedEventArgs e)
        {
            DevExpress.XtraEditors.ButtonEdit edit = sender as DevExpress.XtraEditors.ButtonEdit;
            DynamicParameterItem pi = _row;

            #region Loading picture data from the server
            GetAttachData(pi);
            #endregion

            #region Зургийн форм дуудах

            Image  newimage = null;
            Image  image    = null;
            string filename = null;

            if (pi.AttachData != null)
            {
                image = Static.ImageFromByte(pi.AttachData);
            }
            DialogResult dlg = ShowImageForm(image, ref newimage, ref filename);
            if (dlg == DialogResult.OK)
            {
                if (pi != null)
                {
                    //if (pi.Row != null) pi.Row.Properties.Value = filename;
                    edit.EditValue = filename;
                    pi.Editing     = true;
                    pi.Value       = filename;
                    pi.AttachData  = Static.ImageToByte(newimage);
                }
            }

            #endregion
        }
Ejemplo n.º 7
0
        public DynamicParameterItem ItemGet(string id)
        {
            DynamicParameterItem pi = null;

            lock (_hitems.SyncRoot)
            { pi = (DynamicParameterItem)_hitems[id]; }
            return(pi);
        }
Ejemplo n.º 8
0
 public void ItemDefaultAll()
 {
     for (int i = 0; i < vGridControl1.Rows.Count; i++)
     {
         DynamicParameterItem pi = (DynamicParameterItem)vGridControl1.Rows[i].Tag;
         if (pi != null)
         {
             ItemSetValue(pi.Id, pi.ValueDefault);
         }
     }
 }
Ejemplo n.º 9
0
        public List <DynamicParameterItem> ItemGetList()
        {
            List <DynamicParameterItem> ar = new List <DynamicParameterItem>();

            for (int i = 0; i < vGridControl1.Rows.Count; i++)
            {
                DynamicParameterItem pi = (DynamicParameterItem)vGridControl1.Rows[i].Tag;
                if (pi != null)
                {
                    ar.Add(pi);
                }
            }
            return(ar);
        }
Ejemplo n.º 10
0
        public object ItemGetValue(string Id)
        {
            object value            = null;
            DynamicParameterItem pi = ItemGet(Id);

            if (pi != null)
            {
                EditorRow row = pi.Row;
                if (row != null)
                {
                    value = row.Properties.Value;
                }
            }
            return(value);
        }
Ejemplo n.º 11
0
        private Result ReadBlob(ref byte[] newattachdata)
        {
            Result res = new Result();

            #region Зураг Browse хийгдэх үед AttachId дугаартай зураг татагдаагүй бол татах

            DynamicParameterItem pi = ucParameterPanel1.SelectedRow;
            if (pi.AttachId != 0 && pi.AttachData == null)
            {
                res = AttachUtility.GetBytes(_remote, _tableprivselect, pi.AttachId, ref newattachdata);
            }
            #endregion

            return(res);
        }
Ejemplo n.º 12
0
 public void ItemRemove(string Id)
 {
     if (!string.IsNullOrEmpty(Id))
     {
         lock (_hitems.SyncRoot)
         {
             DynamicParameterItem pi = (DynamicParameterItem)_hitems[Id];
             if (pi != null)
             {
                 _aitems.Remove(pi);
             }
             _hitems.Remove(Id);
         }
     }
 }
Ejemplo n.º 13
0
        void riImageEdit_ButtonClick(object sender, ButtonPressedEventArgs e)
        {
            DevExpress.XtraEditors.ImageEdit edit = sender as DevExpress.XtraEditors.ImageEdit;
            DynamicParameterItem             pi   = null; // _row;

            try
            {
                if (pi != null)
                {
                    object newobj = null;
                    OnEventButtonClick(pi.Id, pi.Row.Index, pi.Value, ref newobj);
                    if (newobj != null && !(newobj is DBNull))
                    {
                        #region Нүдэнд Зураг олгоход CellValueChanged эвэнт дуудагддаггүй юм байна. Тиймээс хэрэв эвэнтээр шинэ зураг орж ирвэл, олгох
                        edit.EditValue = newobj;
                        pi.Value       = newobj;
                        pi.Editing     = true;
                        #endregion
                    }
                }
            }
            catch
            { }

            #region Зургийн форм дуудах

            Image newvalue = null;
            Image value    = null;
            if (edit.EditValue != null && !(edit.EditValue is DBNull))
            {
                value = (Image)edit.EditValue;
            }

            DialogResult dlg = ShowImageForm(value, ref newvalue);
            if (dlg == DialogResult.OK)
            {
                edit.EditValue = newvalue;
                if (pi != null)
                {
                    pi.Editing = true;
                    pi.Value   = newvalue;
                }
            }

            #endregion
        }
Ejemplo n.º 14
0
        void vGridControl1_CellValueChanging(object sender, DevExpress.XtraVerticalGrid.Events.CellValueChangedEventArgs e)
        {
            bool editing = true;

            if (e.Value != null)
            {
                editing = !e.Value.Equals(e.Row.Properties.Value);
            }

            DynamicParameterItem pi = (DynamicParameterItem)e.Row.Tag;

            if (pi != null)
            {
                pi.Editing = editing;
            }

            _editing = editing;
        }
Ejemplo n.º 15
0
        public List <DynamicParameterItem> ItemCheckMandatory()
        {
            List <DynamicParameterItem> ar = new List <DynamicParameterItem>();

            for (int i = 0; i < vGridControl1.Rows.Count; i++)
            {
                DynamicParameterItem pi = (DynamicParameterItem)vGridControl1.Rows[i].Tag;
                if (pi != null)
                {
                    if (pi.Mandatory)
                    {
                        if (pi.Value == null || pi.Value == DBNull.Value || ISM.Lib.Static.ToStr(pi.Value) == "")
                        {
                            ar.Add(pi);
                        }
                    }
                }
            }
            return(ar);
        }
Ejemplo n.º 16
0
        void riFileEdit_ButtonClick(object sender, ButtonPressedEventArgs e)
        {
            DevExpress.XtraEditors.ButtonEdit edit = sender as DevExpress.XtraEditors.ButtonEdit;
            DynamicParameterItem pi = _row;

            if (pi != null)
            {
                switch (e.Button.Index)
                {
                case 0:
                    string       newvalue = null;
                    DialogResult dlg      = ShowFileForm((string)pi.Value, ref newvalue);
                    if (dlg == DialogResult.OK)
                    {
                        pi.Editing = true;
                        if (pi.Row != null)
                        {
                            //pi.Row.Properties.Value = newvalue;
                            edit.EditValue = newvalue;
                            pi.Value       = newvalue;
                        }
                        AttachUtility.FileRead(newvalue, ref pi.AttachData);
                    }
                    break;

                case 1:
                    if (pi != null)
                    {
                        string filename = Static.ToStr(pi.Value);
                        GetAttachData(pi);
                        if (!string.IsNullOrEmpty(filename))
                        {
                            Globals.ShellOpenFile(filename, pi.AttachData);
                        }
                    }
                    break;
                }
            }
        }
Ejemplo n.º 17
0
        public void ItemSetList(string Id, object Value, object Name)
        {
            try
            {
                EditorRow            erow = null;
                DynamicParameterItem pi   = ItemGet(Id);
                if (pi != null)
                {
                    erow = pi.Row;
                }

                if (erow != null)
                {
                    if (pi.ValueType == DynamicParameterType.List)
                    {
                        RepositoryItemLookUpEdit edit = (RepositoryItemLookUpEdit)erow.Properties.RowEdit;
                        FormUtility.LookUpEdit_SetList(ref edit, Value, Name);
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
Ejemplo n.º 18
0
        public void GetAttachData(DynamicParameterItem pi)
        {
            if (pi == null)
            {
                return;
            }

            if (pi.AttachId != 0 && pi.AttachData == null)
            {
                object newvalue      = null;
                byte[] newattachdata = null;

                try
                {
                    OnEventButtonClick(pi.Id, pi.ValueType, pi.Row.Index, pi.Value, pi.AttachId, pi.AttachData, ref newvalue, ref newattachdata);
                }
                catch
                { }
                if (newattachdata != null)
                {
                    pi.AttachData = newattachdata;
                }
            }
        }
Ejemplo n.º 19
0
        public void ItemSetValue(string Id, object Value)
        {
            EditorRow            erow = null;
            DynamicParameterItem pi   = ItemGet(Id);

            if (pi != null)
            {
                erow = pi.Row;
            }

            if (erow != null)
            {
                if (pi != null)
                {
                    pi.Value = Value;
                }
                if (pi == null || Value == null || Value == DBNull.Value)
                {
                    erow.Properties.Value = DBNull.Value;
                }
                else
                {
                    #region Setting property values and types

                    DateTime datevalue;
                    switch (pi.ValueType)
                    {
                    case DynamicParameterType.Text:
                        erow.Properties.Value = Static.ToStr(pi.Value);
                        break;

                    case DynamicParameterType.Decimal:
                        erow.Properties.Value = Static.ToDecimal(pi.Value);
                        break;

                    case DynamicParameterType.Date:
                        datevalue = Static.ToDate(pi.Value);
                        if (datevalue != DateTime.MinValue)
                        {
                            erow.Properties.Value = datevalue;
                        }
                        break;

                    case DynamicParameterType.DateTime:
                        datevalue = Static.ToDateTime(pi.Value);
                        if (datevalue != DateTime.MinValue)
                        {
                            erow.Properties.Value = datevalue;
                        }
                        break;

                    case DynamicParameterType.File:
                        erow.Properties.Value = Static.ToStr(pi.Value);
                        break;

                    case DynamicParameterType.Folder:
                        erow.Properties.Value = Static.ToStr(pi.Value);
                        break;

                    case DynamicParameterType.Picture:
                        erow.Properties.Value = (Image)pi.Value;
                        break;

                    case DynamicParameterType.Font:
                        erow.Properties.Value = (Font)pi.Value;
                        break;

                    case DynamicParameterType.Color:
                        erow.Properties.Value = (Color)pi.Value;
                        break;

                    case DynamicParameterType.List:
                        RepositoryItemLookUpEdit lue = (RepositoryItemLookUpEdit)erow.Properties.RowEdit;
                        object setvalue = DBNull.Value;
                        if (pi.Value != null)
                        {
                            DataTable dt = null;
                            #region Casting DataTable/DataView into DataTable
                            if (lue.DataSource is DataView)
                            {
                                DataView dv = (DataView)lue.DataSource;
                                dt = dv.Table;
                            }
                            else
                            {
                                dt = (DataTable)lue.DataSource;
                            }
                            #endregion
                            if (dt != null && dt.Columns.Count > 0)
                            {
                                #region Get data type of ValueMember column
                                Type totype = typeof(string);
                                if (string.IsNullOrEmpty(lue.ValueMember))
                                {
                                    totype = dt.Columns[0].DataType;
                                }
                                else
                                {
                                    if (dt.Columns.Contains(lue.ValueMember))
                                    {
                                        totype = dt.Columns[lue.ValueMember].DataType;
                                    }
                                }
                                #endregion
                                #region Converting value into data type
                                setvalue = EServ.Shared.Static.ConvToType(totype, pi.Value);
                                #endregion
                            }
                        }
                        erow.Properties.Value = setvalue;
                        break;

                    default:     // 1 and others is string type
                        erow.Properties.Value = Static.ToStr(pi.Value);
                        break;
                    }
                    #endregion
                }
            }
        }