Exemplo n.º 1
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)
            {
            }
        }
Exemplo n.º 2
0
        private void SetComboList(DataTable definition)
        {
            Result r = null;

            #region Read Dictionary names

            List <string> ids = new List <string>();
            foreach (DataRow row in definition.Rows)
            {
                if (ISM.Lib.Static.ToInt(row["valuetype"]) == 9 && !string.IsNullOrEmpty(ISM.Lib.Static.ToStr(row["dictid"])))
                {
                    ids.Add(ISM.Lib.Static.ToStr(row["dictid"]));
                }
            }

            int icur = ids.IndexOf("CURRENCY");
            if (icur < 0)
            {
                ids.Add("CURRENCY");
                icur = ids.Count - 1;
            }
            int ifee = ids.IndexOf("FEETYPE");
            if (ifee < 0)
            {
                ids.Add("FEETYPE");
                ifee = ids.Count - 1;
            }

            #endregion
            #region Get Dictionary Tables
            ArrayList tables = null;
            r = DictUtility.Get(_remote, ids.ToArray(), ref tables);
            #endregion
            #region Set Dictionary Table into Dynamic Column
            try
            {
                if (r.ResultNo == 0)
                {
                    FormulaHash.Clear();
                    LookUpHash.Clear();
                    RateHash.Clear();
                    int i = 0;
                    foreach (DataRow row in definition.Rows)
                    {
                        if (ISM.Lib.Static.ToInt(row["valuetype"]) == 9 && !string.IsNullOrEmpty(ISM.Lib.Static.ToStr(row["dictid"])))
                        {
                            string colname = string.Format("C{0}", ISM.Lib.Static.ToStr(row["itemid"]));
                            DevExpress.XtraGrid.Columns.GridColumn col = gridView1.Columns[colname];
                            if (col.ColumnEdit is RepositoryItemLookUpEdit)
                            {
                                FormUtility.Column_SetList(ref gridView1, col.AbsoluteIndex, (DataTable)tables[i]
                                                           , ISM.Lib.Static.ToStr(row["dictvaluefield"])
                                                           , ISM.Lib.Static.ToStr(row["dictdescfield"]), new int[] { 2 });
                                LookUpHash.Add(col.AbsoluteIndex, (DataTable)tables[i]);
                                //Тооцоолол хийхийн тулд томъёо болон хувийг авч байгаа хэсэг
                                DataTable lkuptable = (DataTable)tables[i];
                                if (Static.ToInt(row["calculate"]) == 1)
                                {
                                    foreach (DataRow dr in lkuptable.Rows)
                                    {
                                        foreach (DataColumn column in lkuptable.Columns)
                                        {
                                            if (column.ColumnName == "FORMULA")
                                            {
                                                if (Static.ToStr(dr["FORMULA"]) != "")
                                                {
                                                    FormulaHash.Add(Static.ToInt(dr["ID"]), Static.ToStr(dr["FORMULA"]));
                                                }
                                                else
                                                {
                                                    MessageBox.Show(string.Format("{0} талбарт томъёо оруулж өгөөгүй байна \r\nСистемийн админтай холбоо барина уу.", dr["NAME"]), "Алдаа гарлаа", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                                    this.Enabled = false;
                                                }
                                            }
                                            if (column.ColumnName == "RATE")
                                            {
                                                if (Static.ToStr(dr["RATE"]) != "")
                                                {
                                                    RateHash.Add(Static.ToInt(dr["ID"]), Static.ToStr(dr["RATE"]));
                                                }
                                                else
                                                {
                                                    MessageBox.Show(string.Format("{0} талбарт хэмжээ оруулж өгөөгүй байна \r\nСистемийн админтай холбоо барина уу.", dr["NAME"]), "Алдаа гарлаа", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                                    this.Enabled = false;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            i++;
                        }
                    }
                }
                else
                {
                    MessageBox.Show(r.ResultNo + ":" + r.ResultDesc + " Dictionary-д оруулаагүй байна");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Алдаа гарлаа", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            #endregion
            #region Set Dictionary Table into Fixed Column

            if (r.ResultNo == 0 && _showfixedvalues)
            {
                FormUtility.Column_SetList(ref gridView1, 5, (DataTable)tables[icur], "CURRENCY", "NAME");
                FormUtility.Column_SetList(ref gridView1, 9, (DataTable)tables[icur], "CURRENCY", "NAME");
                FormUtility.Column_SetList(ref gridView1, 13, (DataTable)tables[icur], "CURRENCY", "NAME");
                FormUtility.Column_SetList(ref gridView1, 6, (DataTable)tables[ifee], "TYPECODE", "NAME");
            }

            #endregion
        }
Exemplo n.º 3
0
        static public Result Get(EServ.Client client, int userno, string[] id, int privno, ref ArrayList tables)
        {
            Result r = new Result();

            if (id == null && id.Length <= 0)
            {
                return(r);
            }

            try
            {
                if (tables == null)
                {
                    tables = new ArrayList();
                }
                for (int i = 0; i < id.Length; i++)
                {
                    DataTable table = null;
                    string    name  = id[i].ToUpper();

                    string _dicfilename  = string.Format(@"{0}\Data\Dic_{1}.xml", Static.WorkingFolder, name);
                    string _infofilename = string.Format(@"{0}\Data\Dic_{1}.inf", Static.WorkingFolder, name);

                    #region Find the item from memory

                    DictItem item = null;
                    lock (_hash.SyncRoot)
                    {
                        item = (DictItem)_hash[name];
                        if (item == null)
                        {
                            item    = new DictItem();
                            item.Id = name;
                        }
                    }

                    #endregion

                    #region If item does not load into memory then load from local file

                    if (item.Table == null) // item.Loaded == DateTime.MinValue
                    {
                        if (File.Exists(_infofilename))
                        {
                            string[] lines = File.ReadAllLines(_infofilename);
                            if (lines != null && lines.Length > 0)
                            {
                                item.Loaded          = Static.ToDateTime(lines[0]);
                                item.RefreshInterval = Static.ToInt(lines[1]);
                                item.Name            = Static.ToStr(lines[2]);

                                table = new DataTable();
                                XmlReadMode mode = table.ReadXml(_dicfilename);
                                item.Table = table;
                            }
                        }
                    }

                    #endregion

                    #region Calculate needs for refresh

                    double lifetime = DateTime.Now.Subtract(item.Loaded).TotalSeconds;

                    if (item.Table == null || (item.RefreshInterval > 0 && lifetime > item.RefreshInterval))
                    {
                        FormUtility.ProgressFormShow("Түр хүлээнэ үү, таталт хийгдэж байна.", item.Id + "...");
                        Result res = Refresh(client, userno, privno, ref item);
                        if (res.ResultNo == 0)
                        {
                            table = item.Table;
                            lock (_hash.SyncRoot)
                            { _hash[item.Id] = item; }

                            #region Save into local file

                            string[] lines = new string[] {
                                Static.ToDateTimeStr(item.Loaded)
                                , Static.ToStr(item.RefreshInterval)
                                , item.Name
                            };
                            File.WriteAllLines(_infofilename, lines);
                            table.WriteXml(_dicfilename, XmlWriteMode.WriteSchema);

                            #endregion
                        }
                        else
                        {
                            r.ResultNo   = res.ResultNo;
                            r.ResultDesc = res.ResultDesc;
                        }
                    }
                    else
                    {
                        table = item.Table;
                    }

                    #endregion

                    tables.Add(table);
                }
            }
            catch (Exception ex)
            {
                r.ResultNo   = 9;
                r.ResultDesc = ex.ToString();
            }
            FormUtility.ProgressFormClose();
            return(r);
        }