CodeImp.Gluon.AgendaItem.SqlInsert C# (CSharp) Method

SqlInsert() public method

public SqlInsert ( ) : bool
return bool
        public bool SqlInsert()
        {
            string q = "INSERT INTO `agenda` " +
                            "(`color`, `description`, `startdate`, `duration`, `alarm`, `alarmdate`, " +
                            "`recur`, `dayofweek`, `dayofmonth`, `month`) " +
                       "VALUES " +
                            "('" + (int)color + "', '" + description + "', '" + startdate.Ticks + "', " +
                            "'" + duration.Ticks + "', '" + Tools.Bool2Int(alarm) + "', '" + alarmdate.Ticks + "', " +
                            "'" + (int)recur + "', '" + startdate.DayOfWeek + "', '" + startdate.Day + "', '" + startdate.Month + "');";

            General.DB.ConnectSafe();
            int result = General.DB.Update(q);
            General.DB.Disconnect();

            // Query was successful when 1 row was modified
            if(result == 1)
            {
                // Get the ID
                id = General.DB.LastInsertID;
                return true;
            }
            else
            {
                // One row should have been inserted!
                return false;
            }
        }

Usage Example

Esempio n. 1
0
 // This adds an agenda item or updates an existing one
 public bool AddOrUpdateItem(AgendaItem i)
 {
     if(i.id <= 0)
         return i.SqlInsert();
     else
         return i.SqlUpdate();
 }
All Usage Examples Of CodeImp.Gluon.AgendaItem::SqlInsert