Пример #1
0
        public decimal SaveRecord()
        {
            string sql = string.Empty;
            int    len = 0;

            if (this.id < 0)
            {
                this.id = DBControl.GetSystemID(1)[0];
                // 新增
                len = this.fields.Count;
                sql = sql + "insert into " + this.tableName + "(id,";
                for (int i = 0; i < len; i++)
                {
                    if (i != len - 1)
                    {
                        sql = sql + this.fields[i].FieldName + ",";
                    }
                    else
                    {
                        sql = sql + this.fields[i].FieldName + ") values (" + this.id + ",";
                    }
                }
                for (int i = 0; i < len; i++)
                {
                    if (i != len - 1)
                    {
                        sql = sql + "'" + this.fields[i]._GetControlValue() + "',";
                    }
                    else
                    {
                        sql = sql + "'" + this.fields[i]._GetControlValue() + "')";
                    }
                }
            }
            else
            {
                // 修改
                len = this.fields.Count;
                sql = sql + "update " + this.tableName + " set ";
                for (int i = 0; i < len; i++)
                {
                    if (i != len - 1)
                    {
                        sql = sql + this.fields[i].FieldName + "='" + this.fields[i]._GetControlValue() + "',";
                    }
                    else
                    {
                        sql = sql + this.fields[i].FieldName + "='" + this.fields[i]._GetControlValue() + "'";
                    }
                }
                sql = sql + " where id = " + this.id;
            }
            DBControl.ExcuteSql(sql);
            return(this.id);
        }
Пример #2
0
        //添加
        public void DeletRecord()
        {
            string sql = string.Empty;
            int    len = 0;

            // 新增
            len = this.fields.Count;
            sql = sql + "delete from " + this.tableName + " where id=" + this.id;
            DBControl.ExcuteSql(sql);
            SetId(-1);
        }
Пример #3
0
 public void ExcuteSql(string sql)
 {
     DBControl.ExcuteSql(sql);
 }