Example #1
0
        public void Update(DataCore dc,params string[] whereFieldArray)
        {
            try
            {
                _createTableOnDatabase(dc);
                sqlText = sqlBuilder.getUpdateScript();

                if (whereFieldArray.Length == 0)
                {
                    whereFieldArray = new string[1] { "IDFIELD" };
                }

                foreach (string value in whereFieldArray)
                {
                    sqlText += " AND " + value + "= @" + value;
                }

                _addParams(dc);
                dc.executeNonQuery(sqlText);
            }
            catch (Exception)
            {
                throw;
            }
        }
Example #2
0
        public void Insert(DataCore dc)
        {
            try
            {
                _createTableOnDatabase(dc);
                sqlText = sqlBuilder.getInsertScript();
                _addParams(dc);
                this.IDFIELD = dc.executeScalar(sqlText);

            }
            catch (Exception)
            {
                throw;
            }
        }
Example #3
0
        public void Delete(DataCore dc, params string[] whereFieldArray)
        {
            try
            {
                _createTableOnDatabase(dc);
                sqlText = "DELETE FROM " + this.GetType().Name + " WHERE 1=1 ";
                if (whereFieldArray.Length == 0)
                {
                    whereFieldArray = new string[1] { "IDFIELD" };
                }

                foreach (string value in whereFieldArray)
                {
                    sqlText += " AND " + value + "= @" + value;
                }

                _addParams(dc);
                dc.executeNonQuery(sqlText);
            }
            catch (Exception)
            {
                throw;
            }
        }
Example #4
0
 private void _createTableOnDatabase(DataCore dc)
 {
     try
     {
         sqlText = sqlBuilder.getTableCreateScript();
         dc.executeNonQuery(sqlText);
     }
     catch (Exception)
     {
         throw;
     }
 }
Example #5
0
        private void _addParams(DataCore dc)
        {
            try
            {
                foreach (FieldInfo fInfo in this.GetType().GetFields())
                {
                    if (fInfo.Name.EndsWith("FIELD"))
                    {
                        dc.addCommandParameter( "@"+fInfo.Name, fInfo.GetValue(this) );
                    }

                }
            }
            catch (Exception)
            {
                throw;
            }
        }