Exemple #1
0
 public TreeValueEventArgs(CustomClass Parent, CustomProperty Child)//, object id, object value)
 {
     m_parentclass = Parent;
     m_childclass = Child;
     //m_id = id;
     //m_class = Parent;
 }
Exemple #2
0
 public NewRowHelper(CustomProperty prop)
 {
     if (prop.Value is DBCustomClass)
     {
         Init(prop, prop.Value as DBCustomClass);
     }
 }
Exemple #3
0
 public ComboConverter(CustomProperty aproperty)
 {
     m_property = aproperty;
 }
Exemple #4
0
 public CustomPropertyDescriptor(ref CustomProperty myProperty, Attribute[] attrs)
     : base(myProperty.Name, attrs)
 {
     m_Property = myProperty;
 }
Exemple #5
0
 public bool OnAfterDataValidate(CustomProperty prop, object ID, object Value)
 {
     if (AfterDataValidate != null)
     {
         AfterDataValidate(prop, new PropertyAfterChangeEventArgs(ID, Value));
     }
     return true;
 }
Exemple #6
0
 public object OnCustomEditValue(CustomProperty prop, object Value)
 {
     if (OnEditValue != null)
     {
         return OnEditValue(prop, new CustomEditorEventArgs(prop.ID, Value));
     }
     return Value;
 }
Exemple #7
0
        public void RefreshAllTabSameFieldValue(CustomProperty prop)
        {
            DBCustomClass cls;
            object value;
            if (prop.Value is DBCustomClass)
            {
                cls = prop.Value as DBCustomClass;
                value = cls.Value;
            }
            else
            {
                cls = (DBCustomClass)prop.Parent;
                value = prop.Value;
            }
            if (prop.ValueType == enumValueType.vtCombo)
            {
                value = prop.ComboValues[prop.Value];
            }

            PageDesc page = (PageDesc)m_Pages[this.tabControl1.SelectedTabIndex - 1];
            //page.dbClass.ReloadDataOnSave = true;

            string strFindKeys = Helper.StringArrayToString(cls.FindKeys);

            int nSameFieldCount = 0;
            foreach (PageDesc pd in m_Pages)
            {
                //add by cuiwei 07.9.20
                //不直接修改,改送通知表
                if (pd.pg == null)
                {
                    continue;
                }
                else
                {
                    if (page == pd)
                        continue;
                    queryCommand qc = pd.qc;
                    qc.syncList.Add(new syncItem(cls.MainTable, prop.ID, value, strFindKeys));
                    if (qc.cls == null) qc.cls = cls;
                }
                //add end
            }
            ReloadProperties();
            
            if (nSameFieldCount > 0)
            {
                cls.ReloadDataOnSave = true;
            }
        }
Exemple #8
0
 public ComboConverter(CustomProperty aproperty)
 {
     m_property = aproperty;
 }
Exemple #9
0
        private void AfterPropertyChangedEvent(CustomProperty sender, PropertyAfterChangeEventArgs e)
        {
            if (sender is CustomProperty)
            {
                CustomProperty prop = (CustomProperty)sender;

                string svalue = e.value.ToString();
                try
                {
                    if (m_lua != null)
                    {
                        DoScript(prop);
                        LuaFunction fun = m_lua.GetFunction(GetRealFunctionName(prop.Key, "onaftervaluechanged"));//"__fname__" + prop.Key + ".onaftervaluechanged");
                        if (fun != null)
                            fun.Call(prop, e);
                    }
                }
                catch (Exception ex)
                {
                    //ScriptDebugForm frm = Program.MainForm.DebugForm;
                    //frm.OutputBox.Text += ex.Message + "\r\n";
                    //frm.Show();
                    //frm.BringToFront();
                    Helper.AddLog(ex.Message);
                }
                //GridItem item = propertyGrid1.SelectedGridItem;
                //CustomPropertyDescriptor desc = (CustomPropertyDescriptor)item.PropertyDescriptor;
                //CustomProperty specprop = desc.Property;          
            }
        }
Exemple #10
0
        private void BeforePropertyChangedEvent(CustomProperty sender, PropertyChangeEventArgs e)
        {
            if (sender is CustomProperty)
            {
                DBCustomProperty prop = (DBCustomProperty)sender;
                bool bRet = false;
                string sErrMsg = "未定义的错误";
                try
                {
                    if (m_lua != null)
                    {
                        DoScript(prop);//可能会有重名的字段,因不同表字段现在可以在同一TAB页中,需要加上parentfield.
                        LuaFunction fun = m_lua.GetFunction(GetRealFunctionName(prop.Key, "onbeforevaluechang"));//"__fname__" + prop.Key + ".onbeforevaluechang");
                        if (fun != null)
                        {
                            object[] retobjs = fun.Call(prop, e);
                            if (retobjs != null && retobjs.GetLength(0) > 0)
                            {
                                if (retobjs[0] is bool)
                                {
                                    bRet = (bool)retobjs[0];
                                    if (!bRet)
                                        sErrMsg = (string)retobjs[1];
                                }
                            }
                        }
                        else
                            bRet = true; //无函数表示没有脚本指定
                    }
                }
                catch (Exception ex)
                {
                    //ScriptDebugForm frm = Program.MainForm.DebugForm;
                    //frm.OutputBox.Text += ex.Message + "\r\n";
                    //frm.Show();
                    //frm.BringToFront();
                    Helper.AddLog(ex.Message);
                    sErrMsg = "LUA运行时错误:\r\n" + ex.Message;
                }
                if (!bRet)
                {
                    sErrMsg = sErrMsg.Replace("\\n", "\n");
                    sErrMsg = sErrMsg.Replace("\\t", "\t");
                    throw new Exception(sErrMsg);
                }
                else
                {
                    //尝试先锁定再提交修改
                    object[] findkeys = FindKeys == null ? (object[])prop.Tag : FindKeys;

                    // 加入限制:只能在<默认值>结点中修改挂接的子表的默认行的内容
                    bool bModifyingSubTableDefaults = true;
                    foreach (object _key in findkeys)
                    {
                        if (_key.ToString() != "0")
                        {
                            bModifyingSubTableDefaults = false;
                            break;
                        }
                    }
                    if (bModifyingSubTableDefaults)
                    {
                        if (!Program.MainForm.m_CurBaseForm.BaseTree.SelectedNode.Text.Contains("默认值"))
                            throw new Exception("不能在这里直接修改子表默认值,请先选择<默认值>结点,再进行修改。");
                        else
                        { 
                            if (!CanModifyDefaultVal())
                                throw new Exception("不允许修改默认值。");
                        }
                    }

                    if (!OnLockRecord(true, prop, findkeys))
                    {
                        throw new Exception(string.Format("这条记录已经被[{0}]在模块[{1}]中锁定,请等待解锁后,再进行修改操作。", 
                            m_reclock.GetServerLastLockUser(findkeys), m_reclock.GetServerLastLockModID(findkeys)));
                    }
                }
            }
        }
Exemple #11
0
        public void NewRecord(CustomProperty prop)
        {
            if (prop.Value is DBCustomClass)
            {
                string svalue = ((DBCustomClass)prop.Value).Value.ToString();
                NewRowHelper helper = new NewRowHelper(prop);
                if (MessageBox.Show(string.Format("您确定要在[{0}]表中新建记录吗?", helper.NewRowTableName), "确认",
                    MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                {
                    helper.GernateDefaultValue();
                    LuaFunction fun1 = m_lua.GetFunction(GetRealFunctionName(prop.Key, "onnewrecord"));//"__fname__" + prop.Key + ".oneditvalue");
                    DBCustomClass cls = prop.Value as DBCustomClass;
                    if (fun1 != null)
                    {
                        //object[] retobjs = fun1.Call(prop, svalue, helper.KeyValues, helper.SubProperty.ID); //需要传入从表主键Hash, key=字段名, value=空,让函数将hashtable填充好
                        object[] retobjs = fun1.Call(prop, svalue, helper.NewRowFieldValues, helper.SubProperty.ID); //需要传入从表主键Hash, key=字段名, value=空,让函数将hashtable填充好
                        
                        //如果返回真,就可以新建从表记录了
                        if (retobjs != null && retobjs.GetLength(0) > 0)
                        {
                            if (retobjs[0] is bool)
                            {
                                if ((bool)retobjs[0] == true)
                                {
                                    helper.NewRow(); //生成新记录并提交
                                    //prop.SetValue(helper.GetNewValue(prop)); //此函数强行刷新下属结点
                                    //OnAsynNotifyEvent(2, prop);
                                    helper.SetNewValue(prop);
                                }
                            }
                        }
                        //return e.value;
                    }
                    else //直接新建记录
                    {
                        helper.NewRow(); //生成新记录并提交
                        //prop.SetValue(helper.GetNewValue(prop)); //此函数强行刷新下属结点
                        //if (prop.Value is DBCustomClass && (prop.Value as DBCustomClass).ParentFieldType == 1) //为虚拟字段上新建从表记录时,需要 getDynamicclass
                        //OnAsynNotifyEvent(2, prop);
                        helper.SetNewValue(prop);
                    }

                    LuaFunction fun2 = m_lua.GetFunction(GetRealFunctionName(prop.Key, "afternewrecord"));
                    if (fun2 != null)
                    {
                        object[] retobjs = fun2.Call();
                    }
					else
					{
	                    LuaFunction fun3 = m_lua.GetFunction(GetRealFunctionName(prop.Key, "onafternewrecord"));
    	                if (fun3 != null)
        	            {
            	            object[] retobjs = fun3.Call();
                	    }					
					}
                }
            }
        }
Exemple #12
0
        private object OnCustomEditorEditValueEvent(CustomProperty sender, CustomEditorEventArgs e)
        {
            CustomProperty prop = sender;

            string svalue;
            if (e.value is DBCustomClass)
                svalue = ((DBCustomClass)e.value).Value.ToString();
            else
                svalue = e.value.ToString();
            
            try
            {
                if (m_lua != null)
                {
                    DoScript(prop);
                    
                    //如果是树结点,需要额外的增加事件,以支持新建从表记录
                    if (prop.Value is DBCustomClass)
                    {
                        LuaFunction fun = m_lua.GetFunction(GetRealFunctionName(prop.Key, "neednewrecord"));//"__fname__" + prop.Key + ".oneditvalue");
                        if (fun != null)
                        {
                            object[] retobjs = fun.Call(prop, e);
                            if (retobjs != null && retobjs.GetLength(0) > 0)
                            {
                                if (retobjs[0] is bool && (bool)retobjs[0])
                                {
                                    NewRecord(prop);
                                }
                            }
                        }
                    }
                    //else
                    {
                        LuaFunction fun = m_lua.GetFunction(GetRealFunctionName(prop.Key, "oneditvalue"));//"__fname__" + prop.Key + ".oneditvalue");
                        if (fun != null)
                        {
                            object[] retobjs = fun.Call(prop, e);
                            if (retobjs != null && retobjs.GetLength(0) > 0)
                            {
                                if (retobjs[0] is bool)
                                {
                                    if ((bool)retobjs[0] == true)
                                    {
                                        if (retobjs.GetLength(0) == 2)
                                        {
                                            //prop.DisplayValue = null;
                                            return retobjs[1];
                                        }
                                        else if (retobjs.GetLength(0) > 2)
                                        {
                                            //prop.DisplayValue = retobjs[2];
                                            //prop.IsClearDisplayValue = false;
                                            return retobjs[1];
                                        }
                                    }
                                }
                            }
                            return e.value;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                //ScriptDebugForm frm = Program.MainForm.DebugForm;
                //frm.OutputBox.Text += ex.Message + "\r\n";
                //frm.Show();
                //frm.BringToFront();
                Helper.AddLog(ex.Message);
            }
            return e.value;//取消修改值,或者未更改值
        }
Exemple #13
0
        public void  SetScriptCode(CustomProperty prop, string strCode)
        {
            string strfnID;
            if (prop == null)
                strfnID = "#";
            else
                strfnID = prop.ID;

            DBCustomClass cls = null;
            if (strfnID == "#")
            {
                cls = this;
            }
            else if (prop.Parent is DBCustomClass)
            {
                cls = GetTopParent(prop);
                //if (prop.Parent != this)
                //    cls = ((DBCustomClass)(prop.Parent));
                //else
                //    cls = this;
            }

            cls.ScriptCode[strfnID] = strCode;
            cls.ScriptExecState[strfnID] = false;
        }
Exemple #14
0
        public void SaveScript(CustomProperty prop)
        {
            //如果是从表里面的属性,需要找到正确地从表名
            if (prop != null && prop.Parent is DBCustomClass && prop.Parent != this)
            {
                //((DBCustomClass)(prop.Parent)).SaveScript(prop);
                DBCustomClass cls = GetTopParent(prop);
                if (this != cls)
                {
                    cls.SaveScript(prop);
                    return;
                }
            }
            string strFieldid = prop == null ? "0" : prop.Key;
            string strFieldName = prop == null ? "#" : prop.ID;
            string strMainTable = prop == null ? "" : (prop.Parent as DBCustomClass).MainTable;

            DBProcess.SaveScriptByID(strMainTable, strFieldid, m_nModlTabId.ToString(), m_luacodes[strFieldName].ToString());
            CustomClassCache.DelAllCaches();
#if false

            string ssql = string.Format("SELECT * FROM sys_scriptstore WHERE fieldid={0} AND modtabid = {1} AND tablename='{2}' AND fieldname='{3}'", strFieldid, m_nModlTabId, m_strMainTableName, strFieldName);
            SqlDataAdapter adp = new SqlDataAdapter(ssql, m_conn);
            System.Data.DataSet DS = new System.Data.DataSet();
            adp.Fill(DS);

            //先判断数据库中是否存在记录
            //存在,则更新
            DataTable tbl = DS.Tables[0];
            if (tbl.Rows.Count > 0)
            {
                DataRow row = tbl.Rows[0];
                row["fieldid"] = strFieldid;
                row["modtabid"] = m_nModlTabId;
                row["tablename"] = m_strMainTableName;
                row["fieldname"] = strFieldName;
                row["scriptlanguage"] = "LUA";
                row["scriptcode"] = Helper.GetByteArrayFromString(m_luacodes[strFieldName].ToString());
                //使用SqlCommandBuilder  对像填充SqlDataAdapter 的InsertCommand、DeleteCommand、UpdateCommand对像
                SqlCommandBuilder cmdBuilder = new SqlCommandBuilder(adp);
                adp.UpdateCommand = cmdBuilder.GetUpdateCommand();

                int val = adp.Update(tbl);
                tbl.AcceptChanges();
            }
            //不存在,则新建记录
            else
            {
                DataRow row = tbl.NewRow();
                row["fieldid"] = strFieldid;
                row["modtabid"] = m_nModlTabId;
                row["tablename"] = m_strMainTableName;
                row["fieldname"] = strFieldName;
                row["scriptlanguage"] = "LUA";
                row["scriptcode"] = Helper.GetByteArrayFromString(m_luacodes[strFieldName].ToString());
                tbl.Rows.Add(row);
                SqlCommandBuilder cmdBuilder = new SqlCommandBuilder(adp);
                adp.InsertCommand = cmdBuilder.GetInsertCommand();

                int val = adp.Update(tbl);
                tbl.AcceptChanges();
            }
#endif
        }
Exemple #15
0
        public bool DeleteRecord(CustomProperty prop)
        {
            string[] findKeys;
            if (prop.Tag == null)
            {
                DBCustomClass cls = prop.Parent as DBCustomClass;
                findKeys = (string[])cls.FindKeys;
            }
            else
                findKeys = (string[])prop.Tag;

            if (findKeys != null)
            {
                //SqlCommandBuilder cmdBuilder = new SqlCommandBuilder(m_adp);
                //m_adp.DeleteCommand = cmdBuilder.GetDeleteCommand();
                DataRow delRow = m_tbl_MainData.Rows.Find(PreProcessKeys(findKeys));
                if (delRow == null)
                {
                    MessageBox.Show(string.Format("在[{0}]中删除记录失败。", MainTable), "错误",
                            MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return false;
                }
                delRow.Delete();
                //int nRet = m_adp.Update(new DataRow[] { delRow });
                Helper.SaveTable(m_tbl_MainData, StrSql, MainForm.conn);
                m_tbl_MainData.AcceptChanges();
                DBCustomClass cls = this;
                while (cls.ParentFieldType != 2 && cls.Parent != null)
                {
                    if (cls.Parent is DBCustomClass)
                    {
                        cls = (DBCustomClass)(cls.Parent);
                    }
                }
                CustomClassCache.DelAllDataTableCache(); //清除缓冲
                if (cls.Property == null) //虚拟字段在顶层
                {
                    cls.GetDynamicClass(cls.FindKeys);
                    cls.OnAsynNotifyEvent(1, null);//todo:多个页存在同一表同一字段时,会导致重复刷新多次                    
                }
                else
                    cls.Property.SetValue(cls.Value);

                {
                    DBCustomClass parentcls = prop.Parent as DBCustomClass;
                    if (parentcls != null)
                        parentcls = parentcls.Parent as DBCustomClass;

                    if (parentcls.Property != null)
                    {
                        LuaFunction fun2 = m_lua.GetFunction(GetRealFunctionName(parentcls.Property.Key, "onafterdelrecord"));
                        if (fun2 != null)
                        {
                            object[] retobjs = fun2.Call();
                        }
                    }
                }

                return true;
            }
            return false;
        }               
Exemple #16
0
 public void Add(CustomProperty Value)
 {
     base.List.Add(Value);
 }
Exemple #17
0
 public CustomPropertyDescriptor(ref CustomProperty myProperty, Attribute[] attrs)
     : base(myProperty.Name, attrs)
 {
     m_Property = myProperty;
 }
Exemple #18
0
 public void DoScript(CustomProperty prop)
 {   
     if (prop == null)
     {
         this.DoScript("##", "##");
         this.DoScript("#", "#");
     }
     else if (prop.Parent is DBCustomClass)
     {
         //((DBCustomClass)(prop.Parent)).DoScript(prop.Key, prop.ID);
         DBCustomClass cls = GetTopParent(prop);
         cls.DoScript(prop.Key, prop.ID);
     }
 }
Exemple #19
0
        // 生成被修改的默认值的list,作为baseform的更新依据。
        public void GenerateModifiedDefaultList(CustomProperty prop, ref ArrayList lsTblNeedUpdateDefault)
        {
            // 判断 m_findkeys, 是否在修改默认值
            // 所有的tablename, 老值, 新值, 
            bool bThisPropInDefaultRow = true;

            if (m_findkeys != null)
            {
                foreach (object key in m_findkeys)
                {
                    if (key.ToString().Trim() != "0")
                    {
                        bThisPropInDefaultRow = false;
                        break;
                    }
                }
            }
            else
            {
                if (prop.Tag is object[])
                {
                    foreach (object obj in (object[])(prop.Tag))
                    {
                        if (obj.ToString().Trim() != "0")
                        {
                            bThisPropInDefaultRow = false;
                            break;
                        }
                    }
                }
            }

            if (bThisPropInDefaultRow)
            {
                bool bAlreadyAdd = false;
                foreach (TblUpdateDefault tud in lsTblNeedUpdateDefault)
                {
                    if (tud.tblName == m_strMainTableName)
                    {
                        bAlreadyAdd = true;
                        break;
                    }
                }

                if (!bAlreadyAdd)
                {
                    TblUpdateDefault tud = new TblUpdateDefault();
                    tud.tblName = m_strMainTableName;
                    //DataTable tbl = Helper.GetDataTable("SELECT * FROM " + m_strMainTableName, Conn);
                    DataTable tbl = Helper.GetDataTableProxy(m_strMainTableName, Conn);
                    DataRow row = tbl.Rows.Find(PreProcessKeys(m_findkeys));
                    tud.oldValue = row;
                    DataRow newrow = m_tbl_MainData.Rows.Find(PreProcessKeys(m_findkeys));
                    tud.newValue = newrow;
                    lsTblNeedUpdateDefault.Add(tud);
                }
            }
        }
Exemple #20
0
 //查看某属性中是否有函数,没有就到全局中找,找到就执行
 public object[] CallLuaFunction(CustomProperty prop, string strfuncName, object[] args)
 {            
     if (m_lua != null)
     {
         m_lua.DoString(prop == null ? GetPrefixCode("#") : GetPrefixCode(prop.Key));
         LuaFunction fun = m_lua.GetFunction(GetRealFunctionName(prop.Key, strfuncName));//"__fname__" + prop.Key + "." + strfuncName);
         if (fun != null)
         {
             object[] retobjs = fun.Call(args);
             return retobjs;
         }
     }
     return null;
 }
Exemple #21
0
 public object OnCustomGetTreeValue(CustomProperty prop)//, object Value)
 {
     if (OnGetTreeValue != null)
     {
         return OnGetTreeValue(this, new TreeValueEventArgs(this, prop));
     }          
     return Value;
 }
Exemple #22
0
        //修改从表中的findkeys
        public void ReplaceSubFindKey(CustomProperty prop, object value)
        {
            //不能直接使用value,因可能是修改的非主键字段,要获取这个真正的主键
            //Value = value;
            //GetDynamicClass(value);
            //需要根据value值获得真正的key值
            //其实KEY没有变,只是与其他表关联的字段内容在内存中改变了(如represent1)
            object oldvalue = Value;
            prop.Tag = m_findkeyvalues;
            try
            {
                //先解锁之前关联的可能修改过的从表记录
                OnLockRecord(false, null, null);

                Value = value;
                m_ReplaceSubKeyProperty = prop; //记住当前修改的字段ID,以便临时改动子结点中的内容
                GetDynamicClass(m_findkeyvalues);
            }
            finally
            {
                m_ReplaceSubKeyProperty = null;
            }
        }
Exemple #23
0
 public bool OnDataValidate(CustomProperty prop, object ID, object Value)
 {
     if (DataValidate != null)
     {
         if (prop.ValueType == enumValueType.vtCombo)
             DataValidate(prop, new PropertyChangeEventArgs(prop.ComboValues[prop.Value], prop.Value, ID, Value));
         else
             DataValidate(prop, new PropertyChangeEventArgs(prop.Value, prop.Value, ID, Value));
     }
     return true;
 }
Exemple #24
0
 public void ModifyFindKeys(CustomProperty prop, object value)
 {
     //如果非顶层的DBCLASS的主表关键值被修改,则需要修改findkeys
     //如果同时还是顶层的DBCLASS(parentfield=-1),则还需要在保存的同时通知模块树,FINDKEYS发生了变化            
     if (ModifyFindKeys(prop.ID, value))
     {
         DBCustomClass cls = this;
         while (cls.ParentFieldType != 2 && cls.Parent != null)
         {
             if (cls.Parent is DBCustomClass)
             {
                 cls = (DBCustomClass)(cls.Parent);
             }
         }
         if (Parent == null || this.MainTable == cls.MainTable) //顶层或者是修改了模块主表中的主键值
         {
             OnAsynNotifyEvent(3, prop);//通知FORM,保存时要刷新模块树
         }
     }
 }
Exemple #25
0
        public void Add(CustomProperty Value)
		{
			base.List.Add(Value);
		}
Exemple #26
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);
        }
Exemple #27
0
 public CombxHelper(CustomProperty prop)
 {
     m_prop = prop;
 }
Exemple #28
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;
            }
        }
Exemple #29
0
 public BoolConverter(CustomProperty aproperty)
 {
     m_property = aproperty;
 }
Exemple #30
0
 //完成刷新后,主表字段值的新内容可能会变化,需要下面给出
 //主表字段的外键是从表的关联关系中的一个字段,则返回新值
 private object GetNewValue(CustomProperty prop)
 {
     if (m_newvalue.Contains(prop.ID.ToLower()))
     {
         Hashtable htkeyvalue = Helper.TransHashTableCase(m_keyvalue, true);
         return htkeyvalue[m_newvalue[prop.ID.ToLower()]];
     }
     
     return (prop.Value as DBCustomClass).Value;
 }
Exemple #31
0
 public TreeConverter(CustomProperty aproperty)
 {
     m_property = aproperty;
 }
Exemple #32
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);
        }
Exemple #33
0
 public CombxHelper(CustomProperty prop)
 {
     m_prop = prop;
 }
Exemple #34
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;
            }
        }
Exemple #35
0
 public BoolConverter(CustomProperty aproperty)
 {
     m_property = aproperty;
 }
Exemple #36
0
 //当前选中的记录主键值被修改,需要同步修改树中的内容
 private void RefreshTreeFindKey(CustomProperty prop)
 {
     //m_bDisableQuestion = true;
     try
     {
         //如果改了主键值,则需要特殊处理
         if (prop.Parent != null && prop.Parent is DBCustomClass)
         {
             DBCustomClass parentClass = (DBCustomClass)prop.Parent;
             
             TreeNode selected = baseTree.SelectedNode;
             int level = selected == null ? 0 : selected.Level;
             object[] keys = parentClass.FindKeys;
             LoadTree();
             baseTree.SelectedNode = FindTreeNode(keys, level);
         }
     }
     finally
     {
         //m_bDisableQuestion = false;
     }
 }
Exemple #37
0
 public TreeConverter(CustomProperty aproperty)
 {
     m_property = aproperty;
 }
Exemple #38
0
        /// <summary>
        /// 标记值改变 add by suntao
        /// </summary>
        /// <param name="prop">CustomProperty</param>
        private void MarkValueChanged(CustomProperty prop)
        {
            DBCustomClass dbCustomClass = prop.Parent as DBCustomClass;

            if (dbCustomClass != null)
            {
                dbCustomClass.MarkValueChanged();
            }
        }