コード例 #1
0
 public void Insert()
 {
     try
     {
         if (InsertCommand.Connection.State == ConnectionState.Closed)
         {
             InsertCommand.Connection.Open();
             InitialiseInsert();
         }
         InsertCommand.Parameters["@UserIterationID"].Value = null;
         InsertCommand.Parameters["@UserID"].Value          = CheckParameterDBNull(this.UserID);
         InsertCommand.Parameters["@IterationID"].Value     = CheckParameterDBNull(this.IterationID);
         try
         {
             InsertCommand.ExecuteNonQuery();
         }
         catch (System.Data.SqlClient.SqlException SQLex) { }
         this._UserIterationID = (Int32)InsertCommand.Parameters["@UserIterationID"].Value;
     }
     finally
     {
         InsertCommand.Parameters.Clear();
         InsertCommand.Connection.Close();
     }
 }
コード例 #2
0
 public void Insert()
 {
     try
     {
         if (InsertCommand.Connection.State == ConnectionState.Closed)
         {
             InsertCommand.Connection.Open();
             InitialiseInsert();
         }
         InsertCommand.Parameters["@IterationID"].Value                = null;
         InsertCommand.Parameters["@IterationDescription"].Value       = CheckParameterDBNull(this.IterationDescription);
         InsertCommand.Parameters["@IterationTypeID"].Value            = CheckParameterDBNull(this.IterationTypeID);
         InsertCommand.Parameters["@DefaultIterationTimePeriod"].Value = CheckParameterDBNull(this.DefaultIterationTimePeriod);
         InsertCommand.Parameters["@IterationOwner"].Value             = CheckParameterDBNull(this.IterationOwner);
         try
         {
             InsertCommand.ExecuteNonQuery();
         }
         catch (System.Data.SqlClient.SqlException SQLex) { }
         this._IterationID = (Int32)InsertCommand.Parameters["@IterationID"].Value;
     }
     finally
     {
         InsertCommand.Parameters.Clear();
         InsertCommand.Connection.Close();
     }
 }
コード例 #3
0
ファイル: Task.cs プロジェクト: stevenwcooper/Web-Development
 public void Insert()
 {
     try
     {
         if (InsertCommand.Connection.State == ConnectionState.Closed)
         {
             InsertCommand.Connection.Open();
             InitialiseInsert();
         }
         InsertCommand.Parameters["@TaskID"].Value            = null;
         InsertCommand.Parameters["@StoryID"].Value           = CheckParameterDBNull(this.StoryID);
         InsertCommand.Parameters["@TaskDescription"].Value   = CheckParameterDBNull(this.TaskDescription);
         InsertCommand.Parameters["@TaskStartDate"].Value     = CheckParameterDBNull(this.TaskStartDate);
         InsertCommand.Parameters["@TaskEndDate"].Value       = CheckParameterDBNull(this.TaskEndDate);
         InsertCommand.Parameters["@TaskEstimatedTime"].Value = CheckParameterDBNull(this.TaskEstimatedTime);
         InsertCommand.Parameters["@TaskClockedTime"].Value   = CheckParameterDBNull(this.TaskClockedTime);
         InsertCommand.Parameters["@TaskStatusID"].Value      = CheckParameterDBNull(this.TaskStatusID);
         InsertCommand.Parameters["@TaskAssignedUser"].Value  = CheckParameterDBNull(this.TaskAssignedUser);
         try
         {
             InsertCommand.ExecuteNonQuery();
         }
         catch (System.Data.SqlClient.SqlException SQLex) { }
         this._TaskID = (Int32)InsertCommand.Parameters["@TaskID"].Value;
     }
     finally
     {
         InsertCommand.Parameters.Clear();
         InsertCommand.Connection.Close();
     }
 }
コード例 #4
0
ファイル: User.cs プロジェクト: stevenwcooper/Web-Development
 public void Insert()
 {
     try
     {
         if (InsertCommand.Connection.State == ConnectionState.Closed)
         {
             InsertCommand.Connection.Open();
             InitialiseInsert();
         }
         InsertCommand.Parameters["@UserID"].Value               = null;
         InsertCommand.Parameters["@UserFirstName"].Value        = CheckParameterDBNull(this.UserFirstName);
         InsertCommand.Parameters["@UserLastName"].Value         = CheckParameterDBNull(this.UserLastName);
         InsertCommand.Parameters["@UserName"].Value             = CheckParameterDBNull(this.UserName);
         InsertCommand.Parameters["@UserEmail"].Value            = CheckParameterDBNull(this.UserEmail);
         InsertCommand.Parameters["@UserThemeID"].Value          = CheckParameterDBNull(this.UserThemeID);
         InsertCommand.Parameters["@UserAspNetMembership"].Value = CheckParameterDBNull(this.UserAspNetMembership);
         InsertCommand.Parameters["@UserPicture"].Value          = CheckParameterDBNull(this.UserPicture);
         try
         {
             InsertCommand.ExecuteNonQuery();
             this._UserID = (Int32)InsertCommand.Parameters["@UserID"].Value;
         }
         catch (System.Data.SqlClient.SqlException SQLex) { }
     }
     finally
     {
         InsertCommand.Parameters.Clear();
         InsertCommand.Connection.Close();
     }
 }
コード例 #5
0
ファイル: ObjectDAO.cs プロジェクト: danjiewu/MyOrm
 /// <summary>
 /// 将对象添加到数据库
 /// </summary>
 /// <param name="t">待添加的对象</param>
 /// <returns>是否成功添加</returns>
 public virtual bool Insert(T t)
 {
     if (t == null)
     {
         throw new ArgumentNullException("t");
     }
     foreach (IDataParameter param in InsertCommand.Parameters)
     {
         ColumnDefinition column = TableDefinition.GetColumn(ToNativeName(param.ParameterName));
         param.Value = ConvertToDBValue(column.GetValue(t), column);
     }
     if (IdentityColumn == null)
     {
         InsertCommand.ExecuteNonQuery();
     }
     else
     {
         IDataParameter param = InsertCommand.Parameters.Contains(ToParamName(IdentityColumn.PropertyName)) ? (IDataParameter)InsertCommand.Parameters[ToParamName(IdentityColumn.PropertyName)] : null;
         if (param != null && param.Direction == ParameterDirection.Output)
         {
             InsertCommand.ExecuteNonQuery();
             IdentityColumn.SetValue(t, ConvertValue(param.Value, IdentityColumn.PropertyType));
         }
         else
         {
             IdentityColumn.SetValue(t, ConvertValue(InsertCommand.ExecuteScalar(), IdentityColumn.PropertyType));
         }
     }
     return(true);
 }
コード例 #6
0
 public override void Write(byte[] buffer, int offset, int count)
 {
     byte[] data = buffer;
     if (offset != 0 || count != buffer.Length)
     {
         data = new byte[count];
         Array.Copy(buffer, offset, data, 0, count);
     }
     if (Position == 0 && InsertCommand != null)
     {
         InsertDataParam.Value = data;
         InsertCommand.ExecuteNonQuery();
     }
     else
     {
         UpdateDataParam.Value = data;
         UpdateCommand.ExecuteNonQuery();
     }
     Position += count;
 }
コード例 #7
0
        public static bool InsertMark(Mark mark)
        {
            InsertCommand.Parameters["@PeopleID"].Value = mark.PeopleId;
            InsertCommand.Parameters["@SubjectID"].Value = mark.SubjectId;
            InsertCommand.Parameters["@DateMark"].Value = mark.DateMark;
            InsertCommand.Parameters["@Mark"].Value = mark.Value;

            int result = 0;
            try
            {
                Connection.Open();
                result = InsertCommand.ExecuteNonQuery();
            }
            catch (Exception) { return false; }
            finally
            {
                if (Connection.State == ConnectionState.Open)
                    Connection.Close();
            }

            if (result > 0)
                return true;
            return false;
        }