示例#1
0
文件: Class1.cs 项目: weimingtom/pap2
        public void UpdateAllPrice()
        {
            LuaEx lua = new LuaEx();

            lua["Conn"] = Conn;
            lua.RegisterFunction("GetDbRowField", this, typeof(Class1).GetMethod("GetDbRowField"));
            lua.RegisterFunction("SetDbRowField", this, typeof(Class1).GetMethod("SetDbRowField"));
            lua.DoString("function trace(txt)\r\n    MainForm.LogEditBox.Visible = true\r\n    MainForm.LogEditBox.Text = MainForm.LogEditBox.Text ..txt..'\\r\\n' \r\n end");
            try
            {
                string luafile = Application.StartupPath + @"\OtherTblUpdatePrice.lua";
                if (!File.Exists(luafile))
                {
                    return;
                }
                lua.DoFile(luafile);
                LuaFunction fun = lua.GetFunction("UpdateAllPrice");
                if (fun == null)
                {
                    return;
                }

                DataTable tblOther = GetDataTable("SELECT * FROM Other", Conn);

                for (int i = 0; i < tblOther.Rows.Count; i++)
                {
                    m_curRow = tblOther.Rows[i];
                    fun.Call();
                }

                SqlDataAdapter    adp        = new SqlDataAdapter("SELECT * FROM Other", Conn);
                SqlCommandBuilder cmdBuilder = new SqlCommandBuilder(adp);
                adp.UpdateCommand = cmdBuilder.GetUpdateCommand();
                int val = adp.Update(tblOther);
                tblOther.AcceptChanges();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Other更新错误。\r\n\r\n" + ex.Message);
            }
        }
示例#2
0
文件: Class1.cs 项目: viticm/pap2
        public void UpdateAllPrice()
        {
            LuaEx lua = new LuaEx();
            lua["Conn"] = Conn;
            lua.RegisterFunction("GetDbRowField", this, typeof(Class1).GetMethod("GetDbRowField"));
            lua.RegisterFunction("SetDbRowField", this, typeof(Class1).GetMethod("SetDbRowField"));
            lua.DoString("function trace(txt)\r\n    MainForm.LogEditBox.Visible = true\r\n    MainForm.LogEditBox.Text = MainForm.LogEditBox.Text ..txt..'\\r\\n' \r\n end");
            try
            {
                string luafile = Application.StartupPath + @"\OtherTblUpdatePrice.lua";
                if (!File.Exists(luafile))
                    return;
                lua.DoFile(luafile);
                LuaFunction fun = lua.GetFunction("UpdateAllPrice");
                if (fun == null)
                    return;

                DataTable tblOther = GetDataTable("SELECT * FROM Other", Conn);

                for (int i = 0; i < tblOther.Rows.Count; i++)
                {
                    m_curRow = tblOther.Rows[i];
                    fun.Call();
                }

                SqlDataAdapter adp = new SqlDataAdapter("SELECT * FROM Other", Conn);
                SqlCommandBuilder cmdBuilder = new SqlCommandBuilder(adp);
                adp.UpdateCommand = cmdBuilder.GetUpdateCommand();
                int val = adp.Update(tblOther);
                tblOther.AcceptChanges();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Other更新错误。\r\n\r\n" + ex.Message);
            }   
        }