Example #1
0
        public Result ItemSetListFromDictionary(EServ.Client client, int userno)
        {
            Result r = null;

            #region Read Dictionary names

            List <string> ids = new List <string>();
            List <DynamicParameterItem> list = ItemGetList();
            foreach (DynamicParameterItem pi in list)
            {
                if (!string.IsNullOrEmpty(pi.DictId))
                {
                    ids.Add(pi.DictId);
                }
            }

            #endregion

            #region Get Dictionary Tables
            ArrayList tables = null;
            r = DictUtility.Get(client, userno, ids.ToArray(), ref tables);
            #endregion

            #region Set Dictionary table into control

            if (r.ResultNo == 0)
            {
                int i = 0;
                foreach (DynamicParameterItem pi in list)
                {
                    if (!string.IsNullOrEmpty(pi.DictId))
                    {
                        this.ItemSetList(pi.Id, (DataTable)tables[i], pi.DictValueField, pi.DictDescField);
                        i++;
                    }
                }
            }

            #endregion

            return(r);
        }
Example #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
        }