public List <PartnerTaskResource> LoadPartnerTaskResourcesByStartedBy(string startedBy) { string sql = @"SELECT [TaskID] , [Resource] , [Request] , [Started] , [StartedBy] FROM [BE_PartnerTaskResource] WHERE [StartedBy]=@StartedBy" ; SqlCommand cmd = new SqlCommand(sql, this.conn, this.trans); SqlParameter pStartedBy = new SqlParameter("StartedBy", startedBy); pStartedBy.SqlDbType = SqlDbType.NVarChar; cmd.Parameters.Add(pStartedBy); List <PartnerTaskResource> ret = new List <PartnerTaskResource>(); SqlDataReader dr = cmd.ExecuteReader(); try { while (dr.Read()) { PartnerTaskResource iret = new PartnerTaskResource(); if (!Convert.IsDBNull(dr["TaskID"])) { iret.TaskID = (Guid)dr["TaskID"]; } iret.Resource = dr["Resource"].ToString(); iret.Request = dr["Request"].ToString(); if (!Convert.IsDBNull(dr["Started"])) { iret.Started = (DateTime)dr["Started"]; } iret.StartedBy = dr["StartedBy"].ToString(); ret.Add(iret); } } finally { dr.Close(); } return(ret); }
public int InsertPartnerTaskResource(PartnerTaskResource obj) { string sql = @"INSERT INTO[BE_PartnerTaskResource]([TaskID] , [Resource] , [Request] , [Started] , [StartedBy] ) VALUES(@TaskID , @Resource , @Request , @Started , @StartedBy )" ; SqlCommand cmd = new SqlCommand(sql, this.conn, this.trans); SqlParameter pTaskID = new SqlParameter("TaskID", Convert2DBnull(obj.TaskID)); pTaskID.SqlDbType = SqlDbType.UniqueIdentifier; cmd.Parameters.Add(pTaskID); SqlParameter pResource = new SqlParameter("Resource", Convert2DBnull(obj.Resource)); pResource.SqlDbType = SqlDbType.NVarChar; cmd.Parameters.Add(pResource); SqlParameter pRequest = new SqlParameter("Request", Convert2DBnull(obj.Request)); pRequest.SqlDbType = SqlDbType.NVarChar; cmd.Parameters.Add(pRequest); SqlParameter pStarted = new SqlParameter("Started", Convert2DBnull(obj.Started)); pStarted.SqlDbType = SqlDbType.DateTime; cmd.Parameters.Add(pStarted); SqlParameter pStartedBy = new SqlParameter("StartedBy", Convert2DBnull(obj.StartedBy)); pStartedBy.SqlDbType = SqlDbType.NVarChar; cmd.Parameters.Add(pStartedBy); return(cmd.ExecuteNonQuery()); }
public int LoadPartnerTaskResourceByTaskID(PartnerTaskResource obj) { string sql = @"SELECT [TaskID] , [Resource] , [Request] , [Started] , [StartedBy] FROM [BE_PartnerTaskResource] WITH(NOLOCK) WHERE [TaskID]=@TaskID" ; SqlCommand cmd = new SqlCommand(sql, this.conn, this.trans); SqlParameter pTaskID = new SqlParameter("TaskID", Convert2DBnull(obj.TaskID)); pTaskID.SqlDbType = SqlDbType.UniqueIdentifier; cmd.Parameters.Add(pTaskID); int ret = 0; SqlDataReader dr = cmd.ExecuteReader(); try { while (dr.Read()) { if (!Convert.IsDBNull(dr["TaskID"])) { obj.TaskID = (Guid)dr["TaskID"]; } obj.Resource = dr["Resource"].ToString(); obj.Request = dr["Request"].ToString(); if (!Convert.IsDBNull(dr["Started"])) { obj.Started = (DateTime)dr["Started"]; } obj.StartedBy = dr["StartedBy"].ToString(); ret += 1; } } finally { dr.Close(); } return(ret); }
public int UpdatePartnerTaskResourceByTaskID(PartnerTaskResource obj) { string sql = @"UPDATE [BE_PartnerTaskResource] SET [Resource]=@Resource , [Request]=@Request , [Started]=@Started , [StartedBy]=@StartedBy WHERE [TaskID]=@TaskID" ; SqlCommand cmd = new SqlCommand(sql, this.conn, this.trans); SqlParameter pResource = new SqlParameter("Resource", Convert2DBnull(obj.Resource)); pResource.SqlDbType = SqlDbType.NVarChar; cmd.Parameters.Add(pResource); SqlParameter pRequest = new SqlParameter("Request", Convert2DBnull(obj.Request)); pRequest.SqlDbType = SqlDbType.NVarChar; cmd.Parameters.Add(pRequest); SqlParameter pStarted = new SqlParameter("Started", Convert2DBnull(obj.Started)); pStarted.SqlDbType = SqlDbType.DateTime; cmd.Parameters.Add(pStarted); SqlParameter pStartedBy = new SqlParameter("StartedBy", Convert2DBnull(obj.StartedBy)); pStartedBy.SqlDbType = SqlDbType.NVarChar; cmd.Parameters.Add(pStartedBy); SqlParameter pTaskID = new SqlParameter("TaskID", Convert2DBnull(obj.TaskID)); pTaskID.SqlDbType = SqlDbType.UniqueIdentifier; cmd.Parameters.Add(pTaskID); return(cmd.ExecuteNonQuery()); }