public int UpdateWorkShiftByWorkShiftCode(WorkShift obj) { string sql = @"UPDATE [BE_WorkShift] SET [WorkShiftID]=@WorkShiftID , [WorkShiftName]=@WorkShiftName , [Started]=@Started , [Ended]=@Ended , [Created]=@Created , [CreatedBy]=@CreatedBy , [Modified]=@Modified , [ModifiedBy]=@ModifiedBy WHERE [WorkShiftCode]=@WorkShiftCode" ; SqlCommand cmd = new SqlCommand(sql, this.conn, this.trans); SqlParameter pWorkShiftID = new SqlParameter("WorkShiftID", Convert2DBnull(obj.WorkShiftID)); pWorkShiftID.SqlDbType = SqlDbType.UniqueIdentifier; cmd.Parameters.Add(pWorkShiftID); SqlParameter pWorkShiftName = new SqlParameter("WorkShiftName", Convert2DBnull(obj.WorkShiftName)); pWorkShiftName.SqlDbType = SqlDbType.NVarChar; cmd.Parameters.Add(pWorkShiftName); SqlParameter pStarted = new SqlParameter("Started", Convert2DBnull(obj.Started)); pStarted.SqlDbType = SqlDbType.NVarChar; cmd.Parameters.Add(pStarted); SqlParameter pEnded = new SqlParameter("Ended", Convert2DBnull(obj.Ended)); pEnded.SqlDbType = SqlDbType.NVarChar; cmd.Parameters.Add(pEnded); SqlParameter pCreated = new SqlParameter("Created", Convert2DBnull(obj.Created)); pCreated.SqlDbType = SqlDbType.DateTime; cmd.Parameters.Add(pCreated); SqlParameter pCreatedBy = new SqlParameter("CreatedBy", Convert2DBnull(obj.CreatedBy)); pCreatedBy.SqlDbType = SqlDbType.NVarChar; cmd.Parameters.Add(pCreatedBy); SqlParameter pModified = new SqlParameter("Modified", Convert2DBnull(obj.Modified)); pModified.SqlDbType = SqlDbType.DateTime; cmd.Parameters.Add(pModified); SqlParameter pModifiedBy = new SqlParameter("ModifiedBy", Convert2DBnull(obj.ModifiedBy)); pModifiedBy.SqlDbType = SqlDbType.NVarChar; cmd.Parameters.Add(pModifiedBy); SqlParameter pWorkShiftCode = new SqlParameter("WorkShiftCode", Convert2DBnull(obj.WorkShiftCode)); pWorkShiftCode.SqlDbType = SqlDbType.NVarChar; cmd.Parameters.Add(pWorkShiftCode); return(cmd.ExecuteNonQuery()); }
public List <WorkShift> LoadWorkShiftsByStarted(string started) { string sql = @"SELECT [WorkShiftID] , [WorkShiftCode] , [WorkShiftName] , [Started] , [Ended] , [Created] , [CreatedBy] , [Modified] , [ModifiedBy] FROM [BE_WorkShift] WHERE [Started]=@Started" ; SqlCommand cmd = new SqlCommand(sql, this.conn, this.trans); SqlParameter pStarted = new SqlParameter("Started", started); pStarted.SqlDbType = SqlDbType.NVarChar; cmd.Parameters.Add(pStarted); List <WorkShift> ret = new List <WorkShift>(); SqlDataReader dr = cmd.ExecuteReader(); try { while (dr.Read()) { WorkShift iret = new WorkShift(); if (!Convert.IsDBNull(dr["WorkShiftID"])) { iret.WorkShiftID = (Guid)dr["WorkShiftID"]; } iret.WorkShiftCode = dr["WorkShiftCode"].ToString(); iret.WorkShiftName = dr["WorkShiftName"].ToString(); iret.Started = dr["Started"].ToString(); iret.Ended = dr["Ended"].ToString(); if (!Convert.IsDBNull(dr["Created"])) { iret.Created = (DateTime)dr["Created"]; } iret.CreatedBy = dr["CreatedBy"].ToString(); if (!Convert.IsDBNull(dr["Modified"])) { iret.Modified = (DateTime)dr["Modified"]; } iret.ModifiedBy = dr["ModifiedBy"].ToString(); ret.Add(iret); } } finally { dr.Close(); } return(ret); }
public int LoadWorkShiftByWorkShiftID(WorkShift obj) { string sql = @"SELECT [WorkShiftID] , [WorkShiftCode] , [WorkShiftName] , [Started] , [Ended] , [Created] , [CreatedBy] , [Modified] , [ModifiedBy] FROM [BE_WorkShift] WITH(NOLOCK) WHERE [WorkShiftID]=@WorkShiftID" ; SqlCommand cmd = new SqlCommand(sql, this.conn, this.trans); SqlParameter pWorkShiftID = new SqlParameter("WorkShiftID", Convert2DBnull(obj.WorkShiftID)); pWorkShiftID.SqlDbType = SqlDbType.UniqueIdentifier; cmd.Parameters.Add(pWorkShiftID); int ret = 0; SqlDataReader dr = cmd.ExecuteReader(); try { while (dr.Read()) { if (!Convert.IsDBNull(dr["WorkShiftID"])) { obj.WorkShiftID = (Guid)dr["WorkShiftID"]; } obj.WorkShiftCode = dr["WorkShiftCode"].ToString(); obj.WorkShiftName = dr["WorkShiftName"].ToString(); obj.Started = dr["Started"].ToString(); obj.Ended = dr["Ended"].ToString(); if (!Convert.IsDBNull(dr["Created"])) { obj.Created = (DateTime)dr["Created"]; } obj.CreatedBy = dr["CreatedBy"].ToString(); if (!Convert.IsDBNull(dr["Modified"])) { obj.Modified = (DateTime)dr["Modified"]; } obj.ModifiedBy = dr["ModifiedBy"].ToString(); ret += 1; } } finally { dr.Close(); } return(ret); }
public int InsertWorkShift(WorkShift obj) { string sql = @"INSERT INTO[BE_WorkShift]([WorkShiftID] , [WorkShiftCode] , [WorkShiftName] , [Started] , [Ended] , [Created] , [CreatedBy] , [Modified] , [ModifiedBy] ) VALUES(@WorkShiftID , @WorkShiftCode , @WorkShiftName , @Started , @Ended , @Created , @CreatedBy , @Modified , @ModifiedBy )" ; SqlCommand cmd = new SqlCommand(sql, this.conn, this.trans); SqlParameter pWorkShiftID = new SqlParameter("WorkShiftID", Convert2DBnull(obj.WorkShiftID)); pWorkShiftID.SqlDbType = SqlDbType.UniqueIdentifier; cmd.Parameters.Add(pWorkShiftID); SqlParameter pWorkShiftCode = new SqlParameter("WorkShiftCode", Convert2DBnull(obj.WorkShiftCode)); pWorkShiftCode.SqlDbType = SqlDbType.NVarChar; cmd.Parameters.Add(pWorkShiftCode); SqlParameter pWorkShiftName = new SqlParameter("WorkShiftName", Convert2DBnull(obj.WorkShiftName)); pWorkShiftName.SqlDbType = SqlDbType.NVarChar; cmd.Parameters.Add(pWorkShiftName); SqlParameter pStarted = new SqlParameter("Started", Convert2DBnull(obj.Started)); pStarted.SqlDbType = SqlDbType.NVarChar; cmd.Parameters.Add(pStarted); SqlParameter pEnded = new SqlParameter("Ended", Convert2DBnull(obj.Ended)); pEnded.SqlDbType = SqlDbType.NVarChar; cmd.Parameters.Add(pEnded); SqlParameter pCreated = new SqlParameter("Created", Convert2DBnull(obj.Created)); pCreated.SqlDbType = SqlDbType.DateTime; cmd.Parameters.Add(pCreated); SqlParameter pCreatedBy = new SqlParameter("CreatedBy", Convert2DBnull(obj.CreatedBy)); pCreatedBy.SqlDbType = SqlDbType.NVarChar; cmd.Parameters.Add(pCreatedBy); SqlParameter pModified = new SqlParameter("Modified", Convert2DBnull(obj.Modified)); pModified.SqlDbType = SqlDbType.DateTime; cmd.Parameters.Add(pModified); SqlParameter pModifiedBy = new SqlParameter("ModifiedBy", Convert2DBnull(obj.ModifiedBy)); pModifiedBy.SqlDbType = SqlDbType.NVarChar; cmd.Parameters.Add(pModifiedBy); return(cmd.ExecuteNonQuery()); }