Exemplo n.º 1
0
        //根据fieldid, tabid,找出prop,前提是fieldid非零
        public DBCustomProperty FindPropByID(string fieldid, string tabid)
        {
            DBCustomClass dbClass = FindDbClassByTabid(tabid);

            if (dbClass == null)
            {
                return(null);
            }

            //每个字段
            foreach (DBCustomProperty prop in dbClass)
            {
                if (prop != null && prop.Key == fieldid)
                {
                    return(prop);
                }
                if (prop.Value != null && prop.Value is DBCustomClass)
                {
                    DBCustomProperty ret = FindPropInPropByFieldID(prop, fieldid);
                    if (ret != null)
                    {
                        return(ret);
                    }
                }
            }
            return(null);
        }
Exemplo n.º 2
0
        private void PreviewPanel_MouseMove(object sender, MouseEventArgs e)
        {
            if (m_3DEngie == null)
            {
                return;
            }

            int xoff = m_oldX - e.X;
            int yoff = m_oldY - e.Y;

            if (e.Button == MouseButtons.Left)
            {
                DBCustomClass dbClass = ((PageDesc)m_Pages[0]).dbClass;
                if (dbClass.ExistLuaFunction("CustomPreviewMouseMove"))
                {
                    try
                    {
                        object[] results = dbClass.CallLuaFunction("CustomPreviewMouseMove", new object[] { yoff });
                    }
                    catch (Exception)
                    {
                    }
                }
                else
                {
                    m_3DEngie.ZoomView(yoff); // 只会在使用sceneeditor时起作用
                }
            }

            m_oldX = e.X;
            m_oldY = e.Y;
        }
Exemplo n.º 3
0
 public bool ShouldSerializeValue()
 {
     /*
      * if (defobjValue == null)// && m_objValue == null)
      *  return false;
      * else
      */
     {
         if (m_objValue is DBCustomClass)
         {
             DBCustomClass clsSrc = (DBCustomClass)m_objValue;
             if (clsSrc.IsVirtualField)
             {
                 return(false);
             }
             else
             {
                 return(!clsSrc.Value.Equals(defobjValue));
             }
         }
         else if (m_objValue != null)
         {
             return(!m_objValue.Equals(defobjValue));
         }
         else
         {
             return(false);
         }
     }
 }
Exemplo n.º 4
0
        //递归体
        private DBCustomProperty FindPropInPropByFieldID(DBCustomProperty prop, string fieldid)
        {
            if (prop.Value == null)
            {
                return(null);                     //修正在从表字段中不能保存脚本的问题
            }
            DBCustomClass cls = prop.Value as DBCustomClass;

            //找正常属性
            foreach (DBCustomProperty iprop in cls)
            {
                //找到了
                if (iprop.Key == fieldid)
                {
                    return(iprop);
                }
            }

            //找虚拟字段之类的
            foreach (DBCustomProperty iprop in cls)
            {
                if (iprop.Value != null && iprop.Value is DBCustomClass)
                {
                    DBCustomProperty ret = FindPropInPropByFieldID(iprop, fieldid);
                    if (ret != null)
                    {
                        return(ret);
                    }
                }
            }

            return(null);
        }
Exemplo n.º 5
0
        private void DoFind()
        {
            string InputContent = textBox.Text;

            if (InputContent == string.Empty)
            {
                return;
            }

            string fieldToFind = string.Empty;

            foreach (RadioButton radio in m_Radiobuttons)
            {
                if (radio.Visible && radio.Checked)
                {
                    fieldToFind = radio.Tag.ToString().Trim();
                }
            }

            bool bFindByNodeText = false;

            if (radioButton6.Checked)
            {
                bFindByNodeText = true;
            }

            DBCustomClass dbClass = ((PageDesc)m_FatherForm.Pages[0]).dbClass;

            //正常加载树时的查找
            if (dbClass.ExistLuaFunction("NotUsingOptimize") &&
                (bool)(dbClass.CallLuaFunction("NotUsingOptimize")[0])
                )
            {
                if (m_AllFoundNodes.Count == 0)
                {
                    GenerateFindResult(fieldToFind, InputContent, bFindByNodeText);
                }
                if (m_AllFoundNodes.Count == 0)
                {
                    MessageBox.Show("没找到符合的记录。");
                    return;
                }

                m_CurIndex++;
                if (m_CurIndex >= m_AllFoundNodes.Count)
                {
                    m_CurIndex = 0;
                }
                m_tree.SelectedNode = (TreeNode)(m_AllFoundNodes[m_CurIndex]);

                m_tree.Focus();
            }
            else //使用了优化方式加载树时的查找
            {
                theNodeFinder.Init(fieldToFind, InputContent, bFindByNodeText, m_tree, m_FatherForm.Conn, m_FatherForm.CatFields, m_FatherForm.MainTableName,
                                   m_FatherForm.DisplayField, m_FatherForm.TblMain.PrimaryKey, (m_FatherForm.Pages[0] as PageDesc).id);
                theNodeFinder.FindNext();
            }
        }
Exemplo n.º 6
0
 public void SetRealValue(object value)
 {
     SetValue(value);
     if (Parent != null && Parent is DBCustomClass)
     {
         DBCustomClass parentClass = (DBCustomClass)Parent;
         parentClass.OnAsynNotifyEvent(2, this);
     }
 }
Exemplo n.º 7
0
        private int GetUnusedID(string strFieldName, object oDeafult)
        {
            if (m_keyvalue == null)
            {
                return(-1);
            }
            DBCustomClass subdbclass = m_dbclass;
            //string sql = string.Format("SELECT * FROM {0}", subdbclass.MainTable);
            //DataTable tbl = Helper.GetDataTable(sql, MainForm.conn);
            DataTable tbl         = Helper.GetDataTableProxy(subdbclass.MainTable, MainForm.conn);
            int       nFieldIndex = -1;

            for (int i = 0; i < subdbclass.DBPrimaryKey.Length; i++)
            {
                m_findkeyvalues[i] = null;// GetNextID(subdbclass.DBPrimaryKey[i]);
                if (subdbclass.DBPrimaryKey[i].ToString().ToLower() == strFieldName.ToLower())
                {
                    nFieldIndex = i;
                }
                else if (m_keyvalue.Contains(subdbclass.DBPrimaryKey[i]))
                {
                    m_findkeyvalues[i] = m_keyvalue[subdbclass.DBPrimaryKey[i]];
                }
            }
            if (oDeafult != null && oDeafult != DBNull.Value)
            {
                m_findkeyvalues[nFieldIndex] = oDeafult;
            }
            else
            {
                m_findkeyvalues[nFieldIndex] = GetNextID(strFieldName);
            }
            if (Program.EnableRemoting && subdbclass.MainTable.Length > 7 && subdbclass.MainTable.Substring(0, 7) == "RTTEST_")
            {
                m_findkeyvalues[nFieldIndex] = Convert.ToInt32(m_findkeyvalues[nFieldIndex]);
                DataTableProxy proxy = DataTableServerProxy.GetDataTableProxy();
                m_findkeyvalues = proxy.UTGetTableID(subdbclass.MainTable, m_findkeyvalues);
            }
            else
            {
                bool bFirstTry = true;
                while (tbl.Rows.Find(m_findkeyvalues) != null)
                {
                    m_findkeyvalues[nFieldIndex] = Convert.ToInt32(m_findkeyvalues[nFieldIndex]) + (bFirstTry == true ? 1 : 1 /*1000*/); // 现在的id太大了
                    bFirstTry = false;
                }
            }
            m_keyvalue[strFieldName] = m_findkeyvalues[nFieldIndex];
            if (oDeafult == DBNull.Value || Convert.ToInt32(m_findkeyvalues[nFieldIndex]) != Convert.ToInt32(oDeafult))
            {
                SetLastID(strFieldName, Convert.ToInt32(m_findkeyvalues[nFieldIndex]));
            }
            return(Convert.ToInt32(m_findkeyvalues[nFieldIndex]));
        }
Exemplo n.º 8
0
        public static void DelDBClass(DBCustomClass cls)
        {
            if (!m_bEnabled)
            {
                return;
            }

            string strkey = GetDBClassKey(cls.ParentFieldID);

            if (!m_pooldbclass.ContainsKey(strkey))
            {
                m_pooldbclass.Add(strkey, cls);
            }
        }
Exemplo n.º 9
0
 public void GetCameraInfo()
 {
     if (m_3DEngie != null)
     {
         int px, py, pz, lx, ly, lz, width, height;
         m_3DEngie.GetCameraInfo(out px, out py, out pz, out lx, out ly, out lz, out width, out height);
         DBCustomClass dbClass = ((PageDesc)m_Pages[0]).dbClass;
         if (dbClass.ExistLuaFunction("GetCameraInfo"))
         {
             object[] results = dbClass.CallLuaFunction("GetCameraInfo",
                                                        new object[] { px, py, pz, lx, ly, lz, width, height });
         }
     }
 }
Exemplo n.º 10
0
        private void PreviewPanel_DoubleClick(object sender, EventArgs e)
        {
            if (m_3DEngie != null)
            {
                m_3DEngie.ToggleRotateModelEditor();

                // run dbclick-handler in lua.
                DBCustomClass dbClass = ((PageDesc)m_Pages[0]).dbClass;
                if (dbClass.ExistLuaFunction("PreviewDoubleClick"))
                {
                    object[] results = dbClass.CallLuaFunction("PreviewDoubleClick");
                }
            }
        }
Exemplo n.º 11
0
 public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
 {
     if (sourceType == typeof(string) && context.Instance is CustomClass)
     {
         CustomPropertyDescriptor desc = (CustomPropertyDescriptor)context.PropertyDescriptor;
         if (desc.Property.Value is CustomClass)
         {
             DBCustomClass cls = ((DBCustomClass)(desc.Property.Value));
             if (!cls.IsVirtualField) //虚拟字段本身不能修改值
             {
                 return(true);
             }
         }
     }
     return(base.CanConvertFrom(context, sourceType));
 }
Exemplo n.º 12
0
        /// <summary>
        /// 保存脚本到数据库和内存,如果内存中没有tab页,则只进数据库.此函数目前只被脚本调用
        /// </summary>
        /// <param name="fieldid"></param>
        /// <param name="tabid"></param>
        /// <param name="strCode"></param>
        /// <returns></returns>
        public string SaveScriptIntoDatabase(string fieldid, string tabid, string strCode)
        {
            DBCustomClass    dbclass = FindDbClassByTabid(tabid);
            DBCustomProperty prop    = FindPropByID(fieldid, tabid);

            if (fieldid == "0")
            {
                //是Tab页脚本
                //DBCustomClass dbclass = FindDbClassByTabid(tabid);
                if (dbclass != null)
                {
                    dbclass.SetScriptCode(null, strCode);
                    dbclass.SaveScript(null);
                    string logcomment = string.Format("PropertyName={0}, FieldID={1}", "#", fieldid);
                    //logscript.Log(TimeLog.enumLogType.ltend, null, null, logcomment + " 脚本被更改!");
                    dbclass.DoScript(null);
                    return("OK");
                }
            }
            else
            {
                //是属性脚本
                //DBCustomClass dbclass = FindDbClassByTabid(tabid);
                //DBCustomProperty prop = FindPropByID(fieldid, tabid);
                if (prop != null && dbclass != null)
                {
                    //内存中有脚本
                    dbclass.SetScriptCode(prop, strCode);
                    dbclass.SaveScript(prop);
                    string logcomment = string.Format("PropertyName={0}, FieldID={1}", prop.Name, prop.Key);
                    //logscript.Log(TimeLog.enumLogType.ltend, null, null, logcomment + " 脚本被更改!");
                    dbclass.DoScript(prop);
                    return("OK");
                }
            }

            //内存中没有脚本,直接进数据库
            string strMainTable = prop == null ? "" : (prop.Parent as DBCustomClass).MainTable;

            return(DBProcess.SaveScriptByID(strMainTable, fieldid, tabid, strCode) ? "OK" : "NG");
        }
Exemplo n.º 13
0
        public static DBCustomClass GetDBClass(object parent, LuaEx lua, int nTabId, int nParentFieldId, int nParentFieldType)
        {
            if (!m_bEnabled)
            {
                return(new DBCustomClass(parent, lua, nTabId, nParentFieldId, nParentFieldType));
            }

            string        strkey = GetDBClassKey(nParentFieldId);
            DBCustomClass cls    = null;

            if (m_pooldbclass.ContainsKey(strkey))
            {
                cls = m_pooldbclass[strkey];
                m_pooldbclass.Remove(strkey);
                cls.ReInit(parent, nParentFieldType);
            }
            else
            {
                cls = new DBCustomClass(parent, lua, nTabId, nParentFieldId, nParentFieldType);
            }
            return(cls);
        }
Exemplo n.º 14
0
 public queryCommand(DBCustomClass dc, object[] ao)
 {
     this.ao = ao;
     this.dc = dc;
 }
Exemplo n.º 15
0
        private void Init(CustomProperty prop, DBCustomClass cls)
        {
            m_keyvaluehelper       = new NewRowKeyValueHelper(m_keyvalue);
            m_newrowkeyvaluehelper = new NewRowKeyValueHelper(m_htnewrow); //用于在 onnewrecord事件中让用户可以有机会更改新记录的内容

            DBCustomClass dbclass = cls;

            if (dbclass.ParentFieldType == 2) //如果是真实字段,要找到虚拟字段
            {
                NewRecordForm frm = new NewRecordForm();
                ArrayList     arr = new ArrayList();
                foreach (CustomProperty subprop in dbclass)
                {
                    if (subprop.ValueType == enumValueType.vtExpandNode && subprop.Value is DBCustomClass)
                    {
                        DBCustomClass subdbclass = subprop.Value as DBCustomClass;
                        if (subdbclass.ParentFieldType != 2)
                        {
                            //m_key = subprop.Key;
                            //m_dbclass = subprop.Value as DBCustomClass;
                            int nAddIdx = frm.listBox1.Items.Add(subprop.Name);
                            arr.Add(subprop);
                            //break;
                        }
                    }
                }
                if (frm.listBox1.Items.Count > 1)
                {
                    frm.listBox1.SelectedIndex = 0;
                }
                if (frm.listBox1.Items.Count == 1 || (frm.listBox1.Items.Count > 1 && frm.listBox1.SelectedIndex >= 0 && frm.ShowDialog() == System.Windows.Forms.DialogResult.OK))
                {
                    CustomProperty subprop = (frm.listBox1.Items.Count == 1 ? arr[0] : arr[frm.listBox1.SelectedIndex]) as CustomProperty;
                    m_key     = subprop.Key;
                    m_dbclass = subprop.Value as DBCustomClass;
                    m_opprop  = subprop;
                }
                else
                {
                    throw new Exception("新建动作被取消。");
                }
            }
            else
            {
                m_opprop = prop;
                //m_key = null;//暂时置空
                m_key     = prop.Key;
                m_dbclass = cls;
            }
            if (m_dbclass == null || m_key == null)
            {
                throw new Exception("不能在此字段中新建子表记录。");
            }

            m_findkeyvalues = new object[m_dbclass.DBPrimaryKey.Length];
            for (int i = 0; i < m_findkeyvalues.Length; i++)
            {
                m_findkeyvalues[i] = null;
            }
            foreach (string strKeyField in m_dbclass.DBPrimaryKey)
            {
                m_keyvalue[strKeyField] = null;
            }
        }
Exemplo n.º 16
0
        //只有在树结点中输入新值,才会调用这里
        public void SetValue(object value)
        {
            if (value == Value)
            {
                return;
            }

            if (Parent != null && Parent is CustomClass)
            {
                CustomClass o = (CustomClass)Parent;
                if (ValueType == enumValueType.vtCombo)
                {
                    o.OnDataValidate(this, ComboValues[value], value);
                }
                else
                {
                    o.OnDataValidate(this, value, value);
                }
            }

            if (Parent != null && Parent is DBCustomClass)
            {
                ((DBCustomClass)Parent).MarkValueChanged();
            }

            bool bRealField = false;

            if (m_objValue is DBCustomClass) //如果是树,则需要影响下面的结点,而不是简单替换值
            {
                DBCustomClass cls = (DBCustomClass)m_objValue;
                bRealField = cls.ParentFieldType != 1;
                //cls.Value = value;
                //cls.GetDynamicClass(new object[] { value }); //不能直接使用value,因可能是修改的非主键字段,要获取这个真正的主键
                if (bRealField)
                {
                    cls.ReplaceSubFindKey(this, value);
                }
                cls.OnAsynNotifyEvent(1, null);//todo:多个页存在同一表同一字段时,会导致重复刷新多次
            }
            else
            {
                m_objValue = value;
                bRealField = true;
            }
            //如果改了主键值,则需要特殊处理
            if (Parent != null && Parent is DBCustomClass && bRealField)
            {
                DBCustomClass parentClass = (DBCustomClass)Parent;
                //parentClass.DBPrimaryKey
                parentClass.ModifyFindKeys(this, value);
            }
            if (Parent != null && Parent is CustomClass)
            {
                CustomClass o = (CustomClass)Parent;
                if (ValueType == enumValueType.vtCombo)
                {
                    o.OnAfterDataValidate(this, ComboValues[value], value);
                }
                else
                {
                    o.OnAfterDataValidate(this, value, value);
                }
            }
        }
Exemplo n.º 17
0
        //生成新记录的默认值(主键值及其他字段值)
        public bool GernateDefaultValue()
        {
            DBCustomClass subdbclass = m_dbclass;

            string[] strSubReleations = subdbclass.GetKeyFromParentField(Convert.ToInt32(m_key), false);//获取关联关系的行数
            if (strSubReleations == null)
            {
                return(false);
            }

            switch (strSubReleations.Length)
            {
            case 0:     //无关联关系
                goto case 1;

            case 1:     //单行关联关系
                //主表关联字段内容要复制到子表对应字段
                if (m_dbclass.Parent != null)
                {
                    DBCustomClass parentClass = m_dbclass.Parent as DBCustomClass;
                    //Hashtable MainTableKeys = Helper.TransToHashTable(parentClass.DBPrimaryKey, true);
                    Hashtable subTableKeys      = Helper.TransToHashTable(m_dbclass.DBPrimaryKey, true);
                    Hashtable htSubReleations   = Helper.TransToHashTable(strSubReleations, true);
                    string[]  strMainReleations = subdbclass.GetKeyFromParentField(Convert.ToInt32(m_key), true);   //获取关联关系的行数
                    //填充主从表关联字段都为主键的内容
                    for (int i = 0; i < subdbclass.DBPrimaryKey.Length; i++)
                    {
                        string strKeyField = (string)subdbclass.DBPrimaryKey[i];
                        if (i > /*=*/ strSubReleations.Length)
                        {
                            m_keyvalue[strKeyField] = GetUnusedID(strKeyField);
                        }
                        else
                        {
                            string strMainField = string.Empty;     // = strMainReleations[i].ToLower();
                            string strSubField  = string.Empty;     // = strSubReleations[i].ToLower();
                            GetMainFieldAndSubField(ref strMainField, ref strSubField, strMainReleations, strSubReleations, strKeyField);

                            if (htSubReleations.Contains(strKeyField.ToLower()))
                            {    //如果从表主键字段在关联关系中,则为外键,需要使用主表字段值作为内容
                                //m_keyvalue[strKeyField] = parentClass.Value;      //使用主键字段值作为默认值
                                if (parentClass.ID != null && parentClass.ID.ToLower() == strMainField)
                                {
                                    m_keyvalue[strKeyField] = GetUnusedID(strKeyField, parentClass.Value);     //使用主表字段值作为默认值,如果子表已经存在则自动换为不存在的值
                                }
                                else
                                {
                                    m_keyvalue[strKeyField] = GetUnusedID(strKeyField, parentClass.GetFieldValue(strMainField));     //如果真实字段不是关联关系中的主表字段,则需要从数据库中读,todo:可能其他TAB页在内存中修改了这个值,则会有问题
                                }
                                m_newvalue[strMainField] = strSubField;
                                //m_newvalue[strKeyField.ToString]

                                /*
                                 * if (subdbclass.DBPrimaryKey.Length > 1)
                                 * {
                                 *  m_keyvalue[strKeyField] = parentClass.Value;
                                 * }
                                 * else
                                 * {
                                 *  string strmsg = string.Format("从表({0})的主键({1})在关联关系中,不能新建记录。请检查关联关系设置或者从表设置是否正确。",
                                 *      subdbclass.MainTable, strKeyField);
                                 *  System.Windows.Forms.MessageBox.Show(strmsg, "错误", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Stop);
                                 *  throw new Exception(strmsg);
                                 * }*/
                            }
                            else
                            {
                                //将从表每个主键字段生成现在没有ID值
                                m_keyvalue[strKeyField] = GetUnusedID(strKeyField);
                                // 必然s trMainField 和 strSubField 都是 string.empty, 算了
                                //m_newvalue[strMainField] = strSubField;
                            }
                        }
                    }
                    //当从表中的关联字段非主键时,也需要正确填充
                    for (int i = 0; i < strSubReleations.Length; i++)
                    {
                        string strsubfield = strSubReleations[i];

                        // 判断 strsubfield 是否是从表的 key
                        bool bIsSubKey = false;
                        foreach (object subDbKey in subdbclass.DBPrimaryKey)
                        {
                            if (strsubfield == subDbKey.ToString().ToLower())
                            {
                                bIsSubKey = true;
                                break;
                            }
                        }

                        if (!bIsSubKey)
                        {
                            if (parentClass.ID != null && parentClass.ID.ToLower() == strMainReleations[i])
                            {
                                m_keyvalue[strsubfield] = parentClass.Value;
                            }
                            else
                            {
                                m_keyvalue[strsubfield] = parentClass.GetFieldValue(strMainReleations[i]);
                            }
                        }
                    }
                }
                break;

            default:    //多行关联关系
                if (m_dbclass.Parent != null)
                {
                    DBCustomClass parentClass       = m_dbclass.Parent as DBCustomClass;
                    Hashtable     MainTableKeys     = Helper.TransToHashTable(parentClass.DBPrimaryKey, true);
                    Hashtable     subTableKeys      = Helper.TransToHashTable(m_dbclass.DBPrimaryKey, true);
                    string[]      strMainReleations = subdbclass.GetKeyFromParentField(Convert.ToInt32(m_key), true);//获取关联关系的行数

                    for (int i = 0; i < strMainReleations.Length; i++)
                    {
                        string strMainField         = strMainReleations[i].ToLower();
                        string strSubField          = strSubReleations[i].ToLower();
                        bool   bMainDBKey           = MainTableKeys.Contains(strMainField);
                        bool   bSubDBKey            = subTableKeys.Contains(strSubField);
                        string strSubDBKeyFieldName = subTableKeys[strSubField].ToString();
                        if (bMainDBKey && bSubDBKey)
                        {                                                                               //主从表字段都为主键,则使用主表字段内容作为默认值
                            m_keyvalue[strSubDBKeyFieldName] = parentClass.GetFieldValue(strMainField); //parentClass.Value; //parentClass[MainTableKeys[strMainField].ToString()];
                            m_newvalue[strMainField]         = strSubField;
                        }
                        else if (!bSubDBKey)
                        {    //从表为非主键,则默认值为默认行中的内容
                            DataRow def_row = CustomClassCache.GetPropDefaultValue(parentClass.MainTable);
                            if (def_row != null)
                            {
                                m_keyvalue[strSubDBKeyFieldName] = def_row[strSubDBKeyFieldName];
                            }
                        }
                        else if (bSubDBKey)
                        {    //主表字段非主键,从表字段为主键字段,则从表默认值为自动递增就可以了
                            m_keyvalue[strSubDBKeyFieldName] = GetUnusedID(strSubDBKeyFieldName, parentClass.GetFieldValue(strMainField));
                            m_newvalue[strMainField]         = strSubField;
                        }
                    }

                    // keys还是要全部填满,即使不在对应关系中。已修复,待测试。
                    foreach (object key in m_keyvalue.Keys)
                    {
                        if (m_keyvalue[key] == null)
                        {
                            m_keyvalue[key] = GetUnusedID(key.ToString(), 1000);
                            break;
                        }
                    }
                }
                break;
            }

            //return true;
            return(GernateDefaultRowValue()); //生成剩余其他的字段值
        }
Exemplo n.º 18
0
        //完成新建记录后,需要修改 DBClass 当前主表记录中所有与从表的关联字段,不然不能正确地显示从表的内容
        public void SetNewValue(CustomProperty prop)
        {
            DBCustomClass cls = prop.Parent as DBCustomClass;

            //if (cls != null)
            //{
            //    cls.MarkValueChanged();
            //}

            foreach (string key in m_newvalue.Keys) //获取所有的主表字段名
            {
                CustomProperty dbprop = null;
                if (key.ToLower() == prop.ID.ToLower())
                {
                    dbprop = prop;
                }
                else
                {
                    dbprop = cls[key];
                }

                if (dbprop != null)
                {
                    dbprop.SetValue(GetNewValue(key));
                    cls.OnAsynNotifyEvent(2, dbprop);
                }
            }
            //当前字段不是关联字段,可能是顶层虚拟字段或者其他虚拟字段,需要重新载入当前
            if (m_dbclass != null && m_dbclass.PrimaryKey.Length > 1)
            {
                object[]  keyvalues  = new object[m_dbclass.PrimaryKey.Length];
                Hashtable htkeyvalue = Helper.TransHashTableCase(m_keyvalue, true);
                for (int i = 0; i < m_dbclass.PrimaryKey.Length; i++)
                {
                    keyvalues[i] = htkeyvalue[m_dbclass.PrimaryKey[i]];
                }
                m_dbclass.ReloadDBData(keyvalues);
            }
            else if (m_dbclass != null && m_dbclass.PrimaryKey.Length == 1)
            {
                DBCustomClass dbParent = prop.Parent as DBCustomClass;
                if (dbParent != null)
                {
                    if (m_dbclass.PrimaryKey.Length == dbParent.FindKeys.Length)
                    {
                        m_dbclass.ReloadDBData(dbParent.FindKeys);
                    }
                    else
                    {
                        object[]  keyvalues  = new object[m_dbclass.PrimaryKey.Length];
                        Hashtable htkeyvalue = Helper.TransHashTableCase(m_keyvalue, true);
                        for (int i = 0; i < m_dbclass.PrimaryKey.Length; i++)
                        {
                            keyvalues[i] = htkeyvalue[m_dbclass.PrimaryKey[i]];
                        }
                        m_dbclass.ReloadDBData(keyvalues);
                    }
                }
            }

            cls.OnAsynNotifyEvent(1, null);
        }
Exemplo n.º 19
0
        public static Hashtable[] GetComboCaches(string key, DBCustomClass dbClass)
        {
            if (m_htComboCaches[key] == null)
            {
                Hashtable[] htReturn = new Hashtable[3];

                string[] keys            = key.Split(new Char[] { ',' });
                string   strlisttable    = keys[0];
                string   strliscondition = keys[1];
                string   strlistf        = keys[2];
                string   strlistk        = keys[3];
                string   strlistfex      = keys[4];

                string sql = "SELECT * FROM " + strlisttable;
                if (strliscondition.Length > 0)
                {
                    sql += " WHERE " + strliscondition;
                }
                /*DataTable tbl = Helper.GetDataTable(sql, Conn);*/
                DataTable tbl = GetDataTableWithKeyProxy(strlisttable, strliscondition, null);

                Hashtable comhashkeys          = new Hashtable();
                Hashtable comhashvalues        = new Hashtable();
                Hashtable comhashfieldsex      = dbClass.GetListFieldExArray(strlistfex); // 下拉框可以获取一些额外的字段,以便于脚本访问从表字段内容
                Hashtable modihash             = comhashfieldsex == null ? null : (Hashtable)comhashfieldsex.Clone();
                Hashtable comfieldsexContainer = new Hashtable();
                foreach (DataRow comborow in tbl.Rows)
                {
                    string strkey      = dbClass.GetFieldStrNoLower(comborow, strlistk);
                    string newStrListF = dbClass.GetFieldStr(comborow, strlistf) + "[" + strkey + "]";

                    comhashkeys[newStrListF] = strkey;
                    comhashvalues[strkey]    = newStrListF;
                    if (comhashfieldsex != null)
                    {
                        foreach (string eachkey in comhashfieldsex.Keys)
                        {
                            if (comborow[eachkey] != null)
                            {
                                modihash[eachkey] = comborow[eachkey].ToString();
                            }
                            else
                            {
                                modihash[eachkey] = "";
                            }
                        }
                        if (comhashfieldsex.Count > 0 && !comfieldsexContainer.ContainsKey(strkey))
                        {
                            comfieldsexContainer[strkey] = modihash.Clone(); // 每一行形成一个HASHTABLE
                        }
                    }
                }

                htReturn[0] = comhashkeys;
                htReturn[1] = comhashvalues;
                htReturn[2] = comfieldsexContainer; // 每一行记录形成一个HASHTABLE,容器的KEY值中listfieldID值

                if (m_htComboCaches.Keys.Count > comboCacheSize)
                {
                    m_htComboCaches.Clear();
                }

                m_htComboCaches[key] = htReturn;
            }

            return((Hashtable[])(m_htComboCaches[key]));
        }
Exemplo n.º 20
0
 public NewRowHelper(DBCustomClass cls)
 {
     Init(null, cls);
 }